Searching and removing ROIs in OMERO using Python API

I would like to use ROIs stored in OMERO from my own Python scripts. While there are examples at OMERO Python language bindings — OMERO 5.6.3 documentation, there are few questions regarding it:

  1. loading ROIs associated with an image is done via
roi_service = conn.getRoiService()
result = roi_service.findByImage(imageId, None)

According to OMERO Application Programming Interface — OMERO 5.6.3 documentation, RoiService is deprecated. Is there some replacement for it? Example on how to get ROIs out of OMERO database using some recommended API?

  1. How do you delete ROI? Let’s say, I want to delete all ROIs associated with some image.

Hi,

You can ignore the “deprecated” note for now. It’s long been our intention to replace ROI service but have not made progress on that.

To delete ROIs on an image, you can get the ROIs as you do above, then:

roi_ids = [roi.id.val for roi in result.rois]
conn.deleteObjects("Roi", roi_ids)

Or, you can use the command line, using the Image ID: 123

$ omero delete Image/Roi:123 --report

You can add a --dry-run argument if you want to check what’s deleted before you go ahead.

Regards,
Will

1 Like

Thank you very much, delete worked nicely.