28 July 2014

Morning

  • Worked on #LDA-metagenomics project. Did a bit more on testing assumption of the project here.

Afternoon

  • Worked a little on #PGHG project (PhyloGenetic Habitat Heterogeneity). Added some documentation to the one function currently there.

  • Rest of the afternoon will be going through images of insects. These are photos of trays, in which we spread whole insect samples from our Kimberley insect traps. These samples later went to be sequenced. I need to rename all the image files with their sample IDs (currently a label is visible within the image). I wrote an imageJ script to make this go faster. This won’t mean much to anyone but me and my collaborators, but I am sticking it here in case I lose the file (which almost happened already, when I was trying to find the file this afternoon). It simply loops through all .jpg in a directory, opening each one zoomed to the label (always in upper left corner) and opens a dialog box were user can fill in label data. It then resaves the .jpg and its associated RAW file (.cr2) with informative filenames.

    var dPatch=12;
    var dSlash=1
    var dSite="S1"
    var dDirection="ne"
    var dColumn="A"
    var dRow=0

    macro "FileRenamer" {

        dir = getDirectory("Choose a Directory ");
        ndir=dir+"renamed";
        File.makeDirectory(ndir);

        n=0;
        count=0;
        processFiles(dir,ndir);
        function processFiles(dir,ndir) {
            list = getFileList(dir);
	          for (i=0; i<list.length; i++) {
		            path = dir+list[i];
		            processFile(path,list[i],dir,ndir);
	          }
        }

        function processFile (path,filename,dir,ndir) {
            if (endsWith(path, ".JPG")|endsWith(path, ".jpg")) {
	              open(path);
	              setLocation(0, 0, screenWidth/2,screenHeight/2 );
		
	              Dialog.create("DataCollect");
	              Dialog.addSlider("Patch", 1,28,dPatch); 
	              Dialog.addSlider("/", 1,4,dSlash) ;
	              Dialog.addChoice("Site", newArray("S1","E2","R3","R4"),dSite);
	              Dialog.addChoice("Direction", newArray("nw","ne","sw","se","ra","rb","sa","sb"),dDirection);
	              Dialog.addCheckbox("Label?", false);
	              Dialog.addChoice("Column", newArray("A","B","C","D"),dColumn);
	              numA=newArray("1","2","3","4");
	              Dialog.addChoice("Row", numA,numA[dRow]);
	              Dialog.show();
	              nPatch=Dialog.getNumber() ;
	              nSlash=Dialog.getNumber();
	              nSite=Dialog.getChoice();
	              nDirection=Dialog.getChoice();
	              nLabel=Dialog.getCheckbox();
	              nColumn=Dialog.getChoice();
	              nRow=Dialog.getChoice();
	              dPatch=nPatch;
	              dSlash=nSlash;
	              dSite=nSite;
	              dDirection=nDirection;
	              dColumn=nColumn;
	              dRow=parseFloat(nRow);
	              if (dRow>3) {
		                dRow=0;
	              }
	              if (nLabel==true) {
	                	lab="L";
	              } else {
		                lab="";
	              }
	              fname="M"+d2s(nPatch,0)+"-"+d2s(nSlash,0)+nSite+nDirection+"-"+nColumn+d2s(nRow,0)+"-";
	              fnamej=ndir+"\\"+fname+"J"+lab+".jpg";
	              fnamec=ndir+"\\"+fname+"R"+lab+".cr2";
	              close();
	              File.rename(path,fnamej);
	              cpath=replace(path,"JPG","cr2");
	              cpath=replace(cpath,"jpg","cr2");
	              File.rename(cpath,fnamec);
            }		
        }    
    }

Todo

  • Need to make a “Current Projects” index page with links to each of my github repos. I am starting to forget what some of them are called.


blog comments powered by Disqus