Login  Register

merging and z-projection in batch mode

Posted by Johannes-P. Koch on Jun 10, 2009; 2:23pm
URL: http://imagej.273.s1.nabble.com/merging-and-z-projection-in-batch-mode-tp3692193.html

Dear Listers,

This might be quite an easy question for you, yet not for me, I sort of miss the logic...

I have some (appr. 6000) files from a live cell imaging experiment indexed with "yyCxxxZyyyTzzz", where the yy stand for arbitrary letters and xxx, yyy, zzz indicate the numbers (001-999). C, Z, T of course are for channel, z-position, time...
as the header indicates I want to merge the channels of a Z-projection and save the files in another directory, maybe not only TIFF but even as AVI.

My starting point was the macro at the ImageJ homepage: http://rsbweb.nih.gov/ij/macros/Batch_RGB_Merge.txt

But the big problem here is, that this macro just accounts for indexes at the end of file names. My filename contains three indices and I want to call them separately, so I tried the "substring" macro function...does not work out though....

maybe somebody has some simple and logic advice for me. I included my modified macro in the end.

Thanks
Johannes

PS: by now I have just implemented the merge function and not the z-projection, but that would be easy when my first problem is solved...


Dialog.create("RGB Batch Convert");
  Dialog.addString("Red Prefix:", "d1");
  Dialog.addString("Green Prefix:", "d2");
 Dialog.show();
  redSuffix = Dialog.getString() + ".";
  greenSuffix = Dialog.getString() + ".";
  batchConvert();
  exit;

function batchConvert() {
      dir1 = getDirectory("Choose Source Directory ");
      dir2 = getDirectory("Choose Destination Directory ");
      list = getFileList(dir1);
      setBatchMode(true);
      n = list.length;
      if ((n%2)!=0)
         exit("The number of files must be a multiple of 2");
      stack = 0;
      first = 0;
      for (i=0; i<n/2; i++) {
          showProgress(i+1, n/2);
          red="?"; green="?";
          for (j=first; j<first+2; j++) {
              if (substring(list[j], redSuffix)!=-1)
                  red = list[j];
              if (substring(list[j], greenSuffix)!=-1)
                  green = list[j];
                 }

          open(dir1 +red);
          open(dir1 +green);

          run("RGB Merge...", "red=["+red+"] green=["+green+"]");
          index = indexOf(red, redSuffix);
          name = substring(red, 0, index);
          saveAs("tiff", dir2+name);
          first += 2;
      }
  }




________________________________________
Johannes-P. KOCH
University of Vienna
Department of Biochemistry and Cell Biology
Dr. Bohrgasse 9/5
A-1030 Vienna
Austria

phone: 00431427752809
fax: 0043142779528

mail to: [hidden email]

--
Ich verwende die kostenlose Version von SPAMfighter für private Anwender,
die bei mir bis jetzt 305 Spammails entfernt hat.
Rund 6 Millionen Leute nutzen SPAMfighter schon.
Laden Sie SPAMfighter kostenlos herunter: http://www.spamfighter.com/lde