imageJ/FIJI: can i add a new ROI in the middle of a ROI manager list of ROIs

519 views Asked by At

I have some code that processes saved lists of ROIs in a specific order. I am trying to go back through and add ROIs where they are missing but can only seem to add them to the end of the list of ROIs in ROI manager. Is there a way to add them into a specific place?

Thanks

1

There are 1 answers

0
ctrueden On BEST ANSWER

Is there a way to add them into a specific place?

There is no simple way. The RoiManager class has no API for it. And it maintains parallel data structures (java.awt.List list and java.util.ArrayList rois) which both track the list of ROIs. So you would need to:

  • Get the list of ROIs from the RoiManager
  • Remove all ROIs after the index of interest
  • Add the new ROI (to the end of the temporarily truncated list)
  • Readd the previously removed ROIs