In ROI manager, how can I select specific ROIs by their index number?

My question seems similar to one asked ~2 years ago (Nov '15) by emartini and answered by Jan Eglinger, but JE’s answer doesn’t quite apply. I’m trying to select a subset of ROIs in an ROI manager by specifying their index number. I suppose I should use the Built In macro “roiManager(“select”, indexes)”. The ImageJ documentation states “… indexes is an array of integers”. How does one enter this array? For instance, if I want to select ROIs #7, 12, 43, and 61, how do I enter these numbers in the macro? If I enter

roiManager("select", 7)

this selects ROI #7. But if I enter

roiManager("select", 7, 12, 43, 61) 

I get an error. What is the proper syntax for entering an array such as 7, 12, 43, 61?

As a followup, is there a good tutorial or website that explains ImageJ macros and how to use Built-in Macros, other than the official ImageJ Documentation site?

I assume you mean this discussion:

From the [documentation](http://imagej.net/developer/macro/functions.html#roiManager("select",):

roiManager(“select”, indexes)
Selects multiple items in the ROI Manager list, where indexes is an array of integers

You can create a new array using the newArray macro function:

roiManager("select", newArray(0,2,4));
1 Like

got it! Tnx for the prompt help.

A followup Q: now that you showed me how to select a subset of ROIs in the ROI manager, can you tell me how to show those selected ROIs, and just those ROIs, on the image? If I check “Show All” on the ROI manage, I of course see all the ROIs, not just the selected subset.

You can only have one active selection (i.e. ROI) per image. You can work around that limitation - if you just want to visualize the ROIs - by creating a new, temporary ROI that combines the selected ones:

roiManager("select", newArray(0,2,4));
roiManager("Combine");
1 Like