// ROI Manager Stack Demo // // This batch mode macro demonstrates how to use the // "count", "reset", "add", "select" and "deselect" options // of the roiManager() function. It creates a 100 slice // stack, creates an oval selection for each slice and // adds it to the ROI Manager, then it restores each of // the 100 selections and measures the area and mean. // // It closes the ROI Manager if it is open because the // ROI Manager runs faster and more reliably in batch // mode macros if it is not displayed. // // There is a JavaScript version of this macro at // rsb.info.nih.gov/ij/macros/js/RoiManagerStackDemo.js if (isOpen("ROI Manager")) { selectWindow("ROI Manager"); run("Close"); } setBatchMode(true); newImage("Test Stack", "8-bit black", 500, 500, 100); for (i=1; i<=nSlices; i++) { setSlice(i); makeOval(i*2, i*2, i*4, i*4); roiManager("add"); setColor(i+99); fill(); } n = roiManager("count"); for (i=0; i