Command to select the last roi from roi manager

Hi,
I generate all these ROIs automatically using a plugin that outlines all the thresholded areas of my image, however I do add one last roi to the manager manually which is the little square that I ran the plugin on. SO if i am scripting this, how do I script “choose the last Roi” I mean the recorder records something that means choose roi number x. however if I am running this on a whole set of images, the number of rois will differ and x won’t probably be the actual last place for my handmade roi on all images.

thanks

Hi Noor,

These two lines below should work for you if you slot them in once all your ROIs have been generated.

count = roiManager("count");
roiManager("select", count-1);

The ROI functions section of the macro functions page is a good place to check out the other options there are for utilising the ROI manager in a macro.

3 Likes