Batch convert zvi to RGB

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

Batch convert zvi to RGB

Fabrice Senger
Dera all,

hereby a macro I wrote, it works fine but it probably might be improved

thanks in advance for comments and suggestions,

Fabrice.

--
Senger Fabrice


//Fabrice Senger 09/07/09
//Adapted from :

// recursiveTiffConvert.txt
// Written by Curtis Rueden
// Last updated on 2008 May 6

// Recursively converts files to TIFF using Bio-Formats.

// It was originally written to convert Gatan DM3 files, but you can easily
// change the code to work with any or all extensions of your choice.

ext = "zvi"; // this variable controls the extension of source files

requires("1.39u");
inDir = getDirectory("Choose Directory Containing " + ext + " Files ");
outDir = getDirectory("Choose Directory for TIFF Output ");
setBatchMode(true);
processFiles(inDir, outDir, "");
print("-- Done --");

function processFiles(inBase, outBase, sub) {
 
  list = getFileList(inBase + sub);
   File.makeDirectory(outBase + sub);
  for (i=0; i<list.length; i++) {
    path = sub + list[i];
    if (endsWith(path, "/")) {
      // recurse into subdirectories
      processFiles(inBase, outBase, path);
    }
     {
      print("-- Processing file: " + path + " --");
      run("Bio-Formats Importer", "open='" + inBase + path + "' autoscale split_channels  view=[Standard ImageJ] stack_order=Default");

name = getTitle;
            dotIndex = indexOf(name, ".");
           joe = substring(name, 0, dotIndex);



n=nImages;
 for (j=0; j<n; j++) {
     
     
run("Misc...", "divide=Infinity hide");
selectImage(j+1);
run("Duplicate...",  "duplicate range=[] title=Channel"+j+1);

}

run("Merge Channels...", "red=Channel3 green=Channel2 blue=Channel1 gray=*None*");


saveAs("tiff", outDir+joe);


     
    }
  }
}

exit()