def ellipse(): o = EllipseI() populate_shape(o) if SCHEMA_VERSION == "2015-01": o.cx = rdouble(1.0) o.cy = rdouble(2.0) o.rx = rdouble(3.0) o.ry = rdouble(4.0) else: o.x = rdouble(1.0) o.y = rdouble(2.0) o.radiusX = rdouble(3.0) o.radiusY = rdouble(4.0) o.id = rlong(1L) return o
def __init__(self, shape = None): ShapeData.__init__(self); if(shape==None): self.setValue(EllipseI()); self.setCx(0); self.setCy(0); self.setRx(0); self.setRy(0); else: self.setValue(shape);
def __init__(self, shape=None): ShapeData.__init__(self) if(shape is None): self.setValue(EllipseI()) self.setCx(0) self.setCy(0) self.setRx(0) self.setRy(0) else: self.setValue(shape)
def __init__(self, shape=None): ShapeData.__init__(self) if (shape is None): self.setValue(EllipseI()) self.setX(0) self.setY(0) self.setRadiusX(0) self.setRadiusY(0) else: self.setValue(shape)
def ellipse(): o = EllipseI() populate_shape(o) o.cx = rdouble(1.0) o.cy = rdouble(2.0) o.rx = rdouble(3.0) o.ry = rdouble(4.0) o.id = rlong(1L) return o
def shapes(self): """Create a bunch of unsaved Shapes.""" rect = RectangleI() rect.x = rdouble(10) rect.y = rdouble(20) rect.width = rdouble(30) rect.height = rdouble(40) # Only save theT, not theZ rect.theT = rint(0) rect.textValue = rstring("test-Rectangle") rect.fillColor = rint(rgba_to_int(255, 255, 255, 255)) rect.strokeColor = rint(rgba_to_int(255, 255, 0, 255)) # ellipse without saving theZ & theT ellipse = EllipseI() ellipse.x = rdouble(33) ellipse.y = rdouble(44) ellipse.radiusX = rdouble(55) ellipse.radiusY = rdouble(66) ellipse.textValue = rstring("test-Ellipse") line = LineI() line.x1 = rdouble(200) line.x2 = rdouble(300) line.y1 = rdouble(400) line.y2 = rdouble(500) line.textValue = rstring("test-Line") point = PointI() point.x = rdouble(1) point.y = rdouble(1) point.theZ = rint(1) point.theT = rint(1) point.textValue = rstring("test-Point") polygon = PolygonI() polygon.theZ = rint(5) polygon.theT = rint(5) polygon.fillColor = rint(rgba_to_int(255, 0, 255, 50)) polygon.strokeColor = rint(rgba_to_int(255, 255, 0)) polygon.strokeWidth = LengthI(10, UnitsLength.PIXEL) points = "10,20, 50,150, 200,200, 250,75" polygon.points = rstring(points) mask = MaskI() mask.setTheC(rint(0)) mask.setTheZ(rint(0)) mask.setTheT(rint(0)) mask.setX(rdouble(100)) mask.setY(rdouble(100)) mask.setWidth(rdouble(500)) mask.setHeight(rdouble(500)) mask.setTextValue(rstring("test-Mask")) mask.setBytes(None) return [rect, ellipse, line, point, polygon, mask]
def ellipse_with_annotations(): o = EllipseI() populate_shape(o) add_annotations(o) o.cx = rdouble(1.0) o.cy = rdouble(2.0) o.rx = rdouble(3.0) o.ry = rdouble(4.0) o.id = rlong(1L) return o
def _parse_neo_roi(self, columns): """Parses out ROI from OmeroTables columns for 'NEO' datasets.""" log.debug("Parsing %s NEO ROIs..." % (len(columns[0].values))) image_ids = columns[self.IMAGE_COL].values rois = list() # Save our file annotation to the database so we can use an unloaded # annotation for the saveAndReturnIds that will be triggered below. self.file_annotation = \ self.update_service.saveAndReturnObject(self.file_annotation) unloaded_file_annotation = \ FileAnnotationI(self.file_annotation.id.val, False) batch_no = 1 batches = dict() for i, image_id in enumerate(image_ids): unloaded_image = ImageI(image_id, False) roi = RoiI() shape = EllipseI() values = columns[6].values diameter = rdouble(float(values[i])) shape.theZ = rint(0) shape.theT = rint(0) values = columns[4].values shape.cx = rdouble(float(values[i])) values = columns[3].values shape.cy = rdouble(float(values[i])) shape.rx = diameter shape.ry = diameter roi.addShape(shape) roi.image = unloaded_image roi.linkAnnotation(unloaded_file_annotation) rois.append(roi) if len(rois) == self.ROI_UPDATE_LIMIT: self.thread_pool.add_task( self.update_rois, rois, batches, batch_no) rois = list() batch_no += 1 self.thread_pool.add_task(self.update_rois, rois, batches, batch_no) self.thread_pool.wait_completion() batch_keys = batches.keys() batch_keys.sort() for k in batch_keys: columns[self.ROI_COL].values += batches[k]
def shapes(self): """Create a bunch of unsaved Shapes.""" rect = RectangleI() rect.x = rdouble(10) rect.y = rdouble(20) rect.width = rdouble(30) rect.height = rdouble(40) rect.textValue = rstring("test-Rectangle") rect.fillColor = rint(rgba_to_int(255, 255, 255, 255)) rect.strokeColor = rint(rgba_to_int(255, 255, 0, 255)) ellipse = EllipseI() ellipse.x = rdouble(33) ellipse.y = rdouble(44) ellipse.radiusX = rdouble(55) ellipse.radiusY = rdouble(66) ellipse.textValue = rstring("test-Ellipse") line = LineI() line.x1 = rdouble(20) line.x2 = rdouble(30) line.y1 = rdouble(40) line.y2 = rdouble(50) line.textValue = rstring("test-Line") point = PointI() point.x = rdouble(50) point.y = rdouble(50) point.textValue = rstring("test-Point") polygon = PolygonI() polygon.fillColor = rint(rgba_to_int(255, 0, 255, 50)) polygon.strokeColor = rint(rgba_to_int(255, 255, 0)) polygon.strokeWidth = LengthI(10, UnitsLength.PIXEL) points = "10,20, 50,150, 100,100, 150,75" polygon.points = rstring(points) polyline = PolylineI() polyline.points = rstring(points) return [rect, ellipse, line, point, polygon, polyline]
def createBaseType(self): return EllipseI()
def createBaseType(self): warnings.warn("This module is deprecated as of OMERO 5.3.0", DeprecationWarning) return EllipseI()
def create_omero_shape(shape_type, data, image): # "line", "path", "polygon", "rectangle", "ellipse" # NB: assume all points on same plane. # Use first point to get Z and T index z_index = get_z(data[0], image) t_index = get_t(data[0], image) shape = None if shape_type == "line": shape = LineI() shape.x1 = rdouble(get_x(data[0])) shape.y1 = rdouble(get_y(data[0])) shape.x2 = rdouble(get_x(data[1])) shape.y2 = rdouble(get_y(data[1])) shape.textValue = rstring("line-from-napari") elif shape_type == "path" or shape_type == "polygon": shape = PolylineI() if shape_type == "path" else PolygonI() # points = "10,20, 50,150, 200,200, 250,75" points = ["%s,%s" % (get_x(d), get_y(d)) for d in data] shape.points = rstring(", ".join(points)) shape.textValue = rstring("polyline-from-napari") if shape_type == "path" else rstring("polygon-from-napari") elif shape_type == "rectangle" or shape_type == "ellipse": # corners go anti-clockwise starting top-left x1 = get_x(data[0]) x2 = get_x(data[1]) x3 = get_x(data[2]) x4 = get_x(data[3]) y1 = get_y(data[0]) y2 = get_y(data[1]) y3 = get_y(data[2]) y4 = get_y(data[3]) print(x1,x2) if shape_type == "rectangle": # Rectangle not rotated if x1 == x2: shape = RectangleI() # TODO: handle 'updside down' rectangle x3 < x1 shape.x = rdouble(x1) shape.y = rdouble(y1) shape.width = rdouble(x3 - x1) shape.height = rdouble(y2 - y1) else: # Rotated Rectangle - save as Polygon shape = PolygonI() points = "%s,%s, %s,%s, %s,%s, %s,%s" % ( x1, y1, x2, y2, x3, y3, x4, y4 ) shape.points = rstring(points) shape.textValue = rstring("rectangle-from-napari") elif shape_type == "ellipse": # Ellipse not rotated (ignore floating point rouding) if int(x1) == int(x2): shape = EllipseI() shape.x = rdouble((x1 + x3) / 2) shape.y = rdouble((y1 + y2) / 2) shape.radiusX = rdouble(abs(x3 - x1) / 2) shape.radiusY = rdouble(abs(y2 - y1) / 2) else: # TODO: Need to calculate transformation matrix print("Rotated Ellipse not yet supported!") shape.textValue = rstring("ellipse-from-napari") if shape is not None: shape.theZ = rint(z_index) shape.theT = rint(t_index) return shape
def ellipse(): o = EllipseI() populate_shape(o) if SCHEMA_VERSION == '2015-01': o.cx = rdouble(1.0) o.cy = rdouble(2.0) o.rx = rdouble(3.0) o.ry = rdouble(4.0) else: o.x = rdouble(1.0) o.y = rdouble(2.0) o.radiusX = rdouble(3.0) o.radiusY = rdouble(4.0) o.id = rlong(1L) return o