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 |
Dear LP,
Not sure what the problem is but if I replace " with " the macro runs fine. Kees -----Original Message----- From: LP [mailto:[hidden email]] Sent: 21 April 2017 20:27 To: [hidden email] Subject: Reset variables ? 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 -- View this message in context: http://imagej.1557.x6.nabble.com/Reset-variables-tp5018587.html Sent from the ImageJ mailing list archive at Nabble.com. -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html |
Free forum by Nabble | Edit this page |