IDR Python API for ROIs?

from idr import connection
conn = connection('idr.openmicroscopy.org', 'public', 'public')

# %matplotlib inline
imageId = 1229801
# Pixels and Channels will be loaded automatically as needed
image = conn.getObject("Image", imageId)
roi_service = conn.getRoiService()
result = roi_service.findByImage(imageId, None)

roi = result.rois[0]
roi_image = roi.getImage() # UnloadedEntityException: Object unloaded:object #0 (::omero::model::Image)
roi_shape = roi.getPrimaryShape()
roi_points = roi_shape.getPoints()

string_points = roi_points.getValue()

Hi all,

Using the idr-py package in python I have been extract images from the IDR succesfully. As far as I understand idr-py is a wrapper for the omero blitz-gateway to the IDR (please correct me if I’ve wrong). Now, firstly I’m struggling to find much decent documentation on using the idr-py api and the blitzgateway documentation either I can’t find or it’s slim (if anyone could help with that I’d grateful).

With this in mind I can’t seem to pull ROIs off of the IDR in a sensible format, see code above). Following the obvious trail of get functions, getImage on an ROI object fails # UnloadedEntityException: Object unloaded:object #0 (::omero::model::Image)
Using getPrimary shape leads down a trail where you get a coordinate pair string, I’m happy to parse this and make my own ROI masks from it, but it feels like I’ve gone the wrong way if this is what i’ll end up doing.

Any advice welcome on how to properly extract ROIs from IDR images.

Best

Craig R

Hi Craig,

You can get coordinates for ROIs as shown at https://docs.openmicroscopy.org/latest/omero/developers/Python.html#rois
(look under the heading “Retrieve ROIs linked to an Image”.

If you’re using Masks, you can get the png for a particular Shape ID using
http://idr.openmicroscopy.org/webgateway/render_shape_mask/1301072/
which comes from this image: http://idr.openmicroscopy.org/webclient/?show=image-4496763

The code that generates this mask can be found at https://github.com/ome/omero-web/blob/71bd342b9a554fb23e465b19a86aa132cf1a5bdd/omeroweb/webgateway/views.py#L708 (python 3).

Hope that helps?

Will