Login  Register

Re: roimanager: delete all ROIs not selected

Posted by Rasband, Wayne (NIH/NIMH) [E] on Mar 21, 2015; 2:06am
URL: http://imagej.273.s1.nabble.com/roimanager-delete-all-ROIs-not-selected-tp5012100p5012103.html

> On Mar 20, 2015, at 2:46 PM, Emanuele Martini <[hidden email]> wrote:
>
> Hi to all,
> I've a maybe simple question but i didn't find a quick solution, there is a
> way to automatically (in a script, or java/jython plugin) delete all NOT
> selected rois from roimanager?
> Or i have to implement a for cycle for each roi present and check if there
> are selected?

The following JavaScript code deletes all not selected ROIs from the ROI Manager. It requires ImageJ 1.49p or later.

-wayne

  rm = RoiManager.getInstance();
  indexes = new Array();
  index=0;
  for (i=0; i<rm.getCount(); i++) {
     if (!rm.isSelected(i))
        indexes[index++] = i;
  }
  rm.setSelectedIndexes(indexes);
  rm.runCommand("deleteā€);


> --
> View this message in context: http://imagej.1557.x6.nabble.com/roimanager-delete-all-ROIs-not-selected-tp5012100.html
> Sent from the ImageJ mailing list archive at Nabble.com.



--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html