Loop for ROIs
Posted by LP on Jan 07, 2017; 7:00pm
URL: http://imagej.273.s1.nabble.com/Loop-for-ROIs-tp5017852.html
Dear ImageJ community,
I'm trying to make a macro that from picture with multiple cells creates one file per cell based on a threshold.
However I don't know how to make a loop for the ROIs.
So far I have this:
______________________________________________
input="C:\\Users\\"
output=input+"zoutput\\"
list=getFileList(input);
for(i=0;i<list.length;i++){
open(input+list[i]);
name = File.nameWithoutExtension();
setBatchMode(false);
selectWindow(name + ".tif");
run("Split Channels");
selectWindow("C2-" + name + ".tif");
run("Duplicate...", " ");
setAutoThreshold("Percentile dark");
run("Convert to Mask");
run("Analyze Particles...", "size=100-Infinity show=Outlines display exclude clear include add");
selectWindow("C1-" + name + ".tif");
roiManager("Select", <b>0);
run("Duplicate...", " ");
selectWindow("C2-" + name + ".tif");
roiManager("Select", 0);
run("Duplicate...", " ");
selectWindow("C3-" + name + ".tif");
roiManager("Select", 0);
run("Duplicate...", " ");
run("Merge Channels...", "c1=C1-"+name+"-1.tif c2=C2-"+name+"-2.tif c3=C3-"+name+"-1.tif create keep");
Stack.setDisplayMode("color");
roiManager("Select", 0);
run("Clear Outside", "stack");
saveAs("tiff", output + name + "0");
close();
selectWindow("C3-" + name + "-1.tif");
close();
selectWindow("C2-" + name + "-2.tif");
close();
selectWindow("C1-" + name + "-1.tif");
close();
selectWindow("Drawing of C2-" + name +"-1.tif");
close();
_____________________________________________________________
So I'd like to replace all the 0 by a variable.
I tried to use
i= roiManager("index");
But with no success.
Any suggestion and help will be very appreciated.
Thank you very much for your help in advance,
LP