How to add Polygon ROI using python API ?
Posted: Thu May 15, 2014 7:06 am
The question is how to add a polygon to the database using the python API ?
I could be something similar to :
is there any example similarly to these given here http://www.openmicroscopy.org/site/support/omero5/developers/Python.html#ROIs ?
thanks !
I could be something similar to :
- Code: Select all
def add_polygon_roi(conn,imageid,x,y,label):
"""
add a ROI to the image object inside Omero
imageid
x,y : x and y coordinates (e.g. list or numpy arrays)
"""
image = conn.getObject("Image", imageid)
# create an ROI, link it to Image
roi = omero.model.RoiI()
roi.setImage(image._obj)
# add a shape to ROI
theZ = self.image.getSizeZ() / 2
theT = 0
# create a rectangle shape and add to ROI
xy = np.vstack((x,y)).T
poly.setPoints( ... ) # <---- ?
poly.theT = rint(theT)
poly.textValue = rstring(label)
roi.addShape(poly)
r = conn.getUpdateService().saveAndReturnObject(roi)
is there any example similarly to these given here http://www.openmicroscopy.org/site/support/omero5/developers/Python.html#ROIs ?
thanks !