Posted by
bluebird-2 on
Jun 16, 2020; 8:47pm
URL: http://imagej.273.s1.nabble.com/Macro-to-split-images-and-save-as-title-tp5023353p5023533.html
Dear Philippe,
Apologies once again for my delay. I really appreciate you helping me, I
will need to do this split+save operation thousands of times in the future
so it would be great to find a way not to have to do it manually.
To answer your first reply, I tried replacing the line that you mentioned to
save, now it says 'undefined error in line 11: saveAs("tiff",
dir2+title+".tif");
Maybe I put it in the wrong place? The entire macro below.
Meanwhile, because I keep getting asked by the Olympus plugin to open each
file individually when running this macro it seems it's not the ideal way.
However, it's easy for me to open all the .vsi files at once (they are the
files that need to be split into channels and saved) in ImageJ using another
Olympus plugin (called 'Drag Drop'). If I can just run a macro that targets
every open .vsi file one at a time, splits it, saves the results relative to
their title names (typically something like C1-process_1352.vsi) and then
moves onto the next open vsi file it would be perfect. Then I can just open
a whole folder at once, run the macro and have it all autosave.
To answer your question about what the command to call Olympus Viewer is, it
simply calls:
run("Viewer");
In the macro recorder.
Thank you once again!
Best,
Marc
dir1 = getDirectory("Select folder with images");
list = getFileList(dir1);
dir2 = getDirectory("Select folder to save the results");
for (i=0; i<list.length; i++){
path = dir1 + list[i];
run("Viewer", "open=[path]");
getDimensions(width, height, channels, slices, frames);
run("Split Channels");
for (j=0; j<channels;j++){
save(dir2+replace(substring(getTitle(),0,lastIndexOf(getTitle(),".")),":","_")+".tif");
saveAs("tiff", dir2+title+".tif");
close();
}
}
--
Sent from:
http://imagej.1557.x6.nabble.com/--
ImageJ mailing list:
http://imagej.nih.gov/ij/list.html