// Concentric Circle ROIs with cropped stimulator // Made with the help of Oliver Buri's script: // http://forum.imagej.net/t/dividing-circle-into-8-equal-areas/1995 // Written by Wilson Adams | Siciliano Lab | November 2021 // Start by getting concentric circle ROIs // You will be prompted for a line to be drawn, which will // specify the diameter of your largest circle ROI setTool("line"); runMacro("drawCirclesAndQuadrants.ijm"); // Then, draw a polygon over the simulator to block any signal it generates. setTool("polygon"); waitForUser("Draw ROI to block the stimulator"); // Add the stim ROI to the manager roiManager("add"); // How many ROIs are there now? count = roiManager("count"); print("count = "+count) // Select the last ROI (zero-based indexed) roiManager("select", count-1); roiManager("rename", "stim"); roiManager("show all"); // Generate a KEEP roi selection using XOR with the stim ROI roiManager("select", Array.getSequence(count)); roiManager("XOR"); roiManager("add"); roiManager("select", count); roiManager("rename", "blocked"); // Remove the stim from each ROI for (i = 0; i < count-1; i++) { roiManager("select", i); // process roi here toselect = newArray(i, count); roiManager("select", toselect); roiManager("and"); roiManager("add"); roiManager("show none"); } // Delete original ROIs, keep cropped ROIs. for (i = 0; i < count+1; i++) { roiManager("select", 0); roiManager("delete"); }