Selecting Multiple ROIs with Jython RoiManager

Hello everyone,

I am trying to select multiple ROIs with the RoiManager in Jython.
I import:
from ij.plugin.frame import RoiManager
RM = RoiManager()
rm = RM.getRoiManager()

Then works but I cannot find any way to select multiple ROIs. When I call only the ROI at index 4 is selected.

I’m aware of the roiManager(“Select”, newArray(0,1)); logic but there doesn’t seem to be a equivalent.[2,4]) raises an error.

Any input is appreciated. Thank you for your help.

Kind regards,

Hi Daniel,
You are probably looking for the
rm.setSelectedIndexes(array) method.


Hey @scidanm,

if you activate the Macro Recoder and select language “Java”, you can observe that it records this while selecting multiple ROIs in the ROI Manager:

rm.setSelectedIndexes(new int[]{3,4,5,7,9});

You can then translate it to Jython:



1 Like

Hello Robert and Thomas,

Thank you both for the prompt response. You are correct. rm.setSelectedIndexes([3,4,5,7,9]); does the job. Actually, my macro recorder is not recording anything that happens in the ROI manager, making this quite a bit harder.


1 Like