Identify the slice of each roi

Hi there,

is there a simple way to select all the rois in one frame, that is different from retrieving the slice from Rois’ name?

Thank you.



You can use the macro function call:


According to the Built In Macro Functions list, the definition of that function is:

Returns the number of the currently displayed stack image, an integer between 1 and nSlices. Returns 1 if the active image is not a stack. See also: setSlice, Stack.getPosition.

So you can loop through all your ROIs in ROI Manager and find the ones that have the slice # you need - something like:

count = roiManager("count"); 
slice = 3; // you set this as you need...
for(i = 0; i < count; i++) { 
	roiManager("Select", i);
	roiSlice = getSliceNumber();
	if (roiSlice == slice) {
		// DO SOMETHING - in this example, I rename the ROI...
		roiManager("Rename", "slice" + slice + "_ROI" + i);  

You will have to adapt the code above… but that gives you a start at least.