Reset variables ?
Posted by LP on Apr 21, 2017; 7:26pm
URL: http://imagej.273.s1.nabble.com/Reset-variables-tp5018587.html
Dear ImageJ community,
I'm writing a macro where I create multiple ROIs based on a threshold and then I want to select them all and combine them. And repeat this on multiple frames.
But unfortunately my macro only works for the first frame and then it says " Invalid index: 0 in line 12. roiManager("select" ,array <)>; "
Maybe I should reset the array variable ? But I didn't manage to do it...
So far I have the following:
___________________________________________
Stack.getDimensions(width,height,channels,slices,frames);
for (t=1; t<=frames; t++) {
setAutoThreshold("Yen dark");
run("Analyze Particles...", "size=4-Infinity exclude add slice"); //Creates multiple ROIS
array=newArray("0"); //in order to be able to select all the ROIS
for (i=1;i<roiManager("count");i++){
array=Array.concat(array,i);
}
roiManager("select",array); // selects all the ROIS
roiManager("Combine"); // Combines all the ROIS
roiManager("Add");
m = roiManager("count");
roiManager("Select", m-1 ); // selects the last ROI
roiManager("Measure"); // measures the newly created ROI
roiManager("Deselect");
roiManager("Delete");
run("Next Slice [>]");
}
__________________________________________
Any suggestion and help will be very appreciated.
Thank you very much for your help in advance,
LP