Saving more than one output file imagej

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

Saving more than one output file imagej

ng129
Hi,

I completely don't understand the macro language and this is taking me forever. I got as far as writing this simple macro to split a folder of z stack file images into their respective stacks and then split the stacks into separate images and save them into a different folder.

The macro works except there is more than one output (an 0001, 0002, 0003) and currently the macro only saves the final 0003 image since that is what is 'selected' when saving.
How do I edit the macro so that it saves all 3 images separately? My issue is that if I record a macro that selects the images separately before saving then the file/image name appears in the macro and it will not then work on subsequent images.

The macro is below....

Thanks
Nicola


dir1 = getDirectory("Choose Source Directory "); //select an input folder
dir2 = getDirectory("Choose a folder to save to"); //select an output folder.
list = getFileList(dir1); //make a list of the filenames
setBatchMode(true); //turn on batch mode
for (i=0; i<list.length; i++) {
  showProgress(i+1, list.length);
  filename = dir1 + list[i];
open(filename);
Imagename = File.nameWithoutExtension;

run("Z Project...", "projection=[Max Intensity]");
run("Stack to Images");

saveAs("Jpeg", dir2+Imagename + "Collagen");
run("Clear Results"); //clear the results
run("Close All");
}
print("All done")