예제 #1
0
 def get_rois(self, imageId):
     try:
         rois = []
         roiService = self._connection.getRoiService()
         result = roiService.findByImage(long(imageId), None, self._connection.SERVICE_OPTS)
     
         for r in result.rois:
             roi = {}
             roi['id'] = r.getId().getValue()
             # go through all the shapes of the ROI
             shapes = []
             for s in r.copyShapes():
                 if s is None:   # seems possible in some situations
                     continue
                 shapes.append(shapeMarshal(s))
             # sort shapes by Z, then T.
             shapes.sort(
                 key=lambda x: "%03d%03d"
                 % (x.get('theZ', -1), x.get('theT', -1)))
             roi['shapes'] = shapes
             rois.append(roi)
     
         rois.sort(key=lambda x: x['id'])
     
         return rois
     except Exception as e:
         print e
         return None
예제 #2
0
 def testInsightPolygonMarshal(self):
     shape = omero.model.PolygonI()
     shape.id = rlong(self.DEFAULT_ID)
     shape.points = rstring("points[1,2 2,3 4,5] points1[1,2 2,3 4,5] points2[1,2 2,3 4,5] mask[0,0,0]")
     marshaled = shapeMarshal(shape)
     self.assertEqual("Polygon", marshaled["type"])
     self.assertEqual(self.DEFAULT_ID, marshaled["id"])
     self.assertEquals("M 1 2 L 2 3 L 4 5 z", marshaled["points"])
예제 #3
0
 def testOmeXmlPolygonMarshal(self):
     shape = omero.model.PolygonI()
     shape.id = rlong(self.DEFAULT_ID)
     shape.points = rstring("1,2 2,3 4,5")
     marshaled = shapeMarshal(shape)
     self.assertEqual("Polygon", marshaled["type"])
     self.assertEqual(self.DEFAULT_ID, marshaled["id"])
     self.assertEquals("M 1 2 L 2 3 L 4 5 z", marshaled["points"])
예제 #4
0
 def testOmeXmlPolyLineFloatMarshal(self):
     shape = omero.model.PolylineI()
     shape.id = rlong(self.DEFAULT_ID)
     shape.points = rstring("1.5,2.5 2,3 4.1,5.1")
     marshaled = shapeMarshal(shape)
     self.assertEqual("PolyLine", marshaled["type"])
     self.assertEqual(self.DEFAULT_ID, marshaled["id"])
     self.assertEquals("M 1.5 2.5 L 2 3 L 4.1 5.1", marshaled["points"])
예제 #5
0
 def testOmeXmlPolyLineMarshal(self):
     shape = omero.model.PolylineI()
     shape.id = rlong(self.DEFAULT_ID)
     shape.points = rstring('1,2 2,3 4,5')
     marshaled = shapeMarshal(shape)
     self.assertEqual('PolyLine', marshaled['type'])
     self.assertEqual(self.DEFAULT_ID, marshaled['id'])
     self.assertEquals('M 1 2 L 2 3 L 4 5' , marshaled['points'])
def _roi_to_json(roi_object):
    return {
        'id': roi_object.getId().getValue(),
        'shapes': [shapeMarshal(s) for s in roi_object.copyShapes()]
    }
예제 #7
0
 def test_point_marshal(self, basic_point):
     marshaled = shapeMarshal(basic_point)
     self.assert_marshal(marshaled, 'Point')
     assert 0.0 == marshaled['x']
     assert 0.1 == marshaled['y']
예제 #8
0
 def test_polygon_marshal(self, basic_polygon):
     marshaled = shapeMarshal(basic_polygon)
     self.assert_marshal(marshaled, 'Polygon')
     assert 'M 1 2 L 2 3 L 4 5 z' == marshaled['points']
예제 #9
0
 def test_polyline_marshal(self, basic_polyline):
     marshaled = shapeMarshal(basic_polyline)
     self.assert_marshal(marshaled, 'PolyLine')
     assert 'M 1 2 L 2 3 L 4 5' == marshaled['points']
예제 #10
0
 def testShapeUnrecognisedRoiShapePointsString(self):
     shape = omero.model.PolygonI()
     shape.id = rlong(self.DEFAULT_ID)
     shape.points = rstring('')
     marshaled = shapeMarshal(shape)
     self.assertEquals(' z', marshaled['points'])
예제 #11
0
 def test_point_marshal(self, basic_point):
     marshaled = shapeMarshal(basic_point)
     self.assert_marshal(marshaled, "Point")
     assert 0.0 == marshaled["x"]
     assert 0.1 == marshaled["y"]
예제 #12
0
 def test_polygon_marshal(self, basic_polygon):
     marshaled = shapeMarshal(basic_polygon)
     self.assert_marshal(marshaled, "Polygon")
     assert "M 1 2 L 2 3 L 4 5 z" == marshaled["points"]
예제 #13
0
 def test_polyline_float_marshal(self, float_polyline):
     marshaled = shapeMarshal(float_polyline)
     self.assert_marshal(marshaled, "PolyLine")
     assert "M 1.5 2.5 L 2 3 L 4.1 5.1" == marshaled["points"]
예제 #14
0
 def test_polyline_marshal(self, basic_polyline):
     marshaled = shapeMarshal(basic_polyline)
     self.assert_marshal(marshaled, "PolyLine")
     assert "M 1 2 L 2 3 L 4 5" == marshaled["points"]
예제 #15
0
 def test_arrow_marshal(self, basic_arrow):
     marshaled = shapeMarshal(basic_arrow)
     self.assert_marshal(marshaled, "Line")
     assert marshaled["markerStart"] == "Arrow"
     assert marshaled["markerEnd"] == "Arrow"
예제 #16
0
 def testShapeUnrecognisedRoiShapePointsString(self):
     shape = omero.model.PolygonI()
     shape.id = rlong(self.DEFAULT_ID)
     shape.points = rstring("")
     marshaled = shapeMarshal(shape)
     self.assertEquals(" z", marshaled["points"])
예제 #17
0
 def test_arrow_marshal(self, basic_arrow):
     marshaled = shapeMarshal(basic_arrow)
     self.assert_marshal(marshaled, 'Line')
     assert marshaled['markerStart'] == 'Arrow'
     assert marshaled['markerEnd'] == 'Arrow'
예제 #18
0
 def test_ployline_marshal(self, basic_polyline):
     marshaled = shapeMarshal(basic_polyline)
     self.assert_polyline(marshaled)
     assert 'M 1 2 L 2 3 L 4 5' == marshaled['points']
예제 #19
0
 def test_polyline_float_marshal(self, float_polyline):
     marshaled = shapeMarshal(float_polyline)
     self.assert_marshal(marshaled, 'PolyLine')
     assert 'M 1.5 2.5 L 2 3 L 4.1 5.1' == marshaled['points']
예제 #20
0
 def test_polyline_float_marshal(self, float_polyline):
     marshaled = shapeMarshal(float_polyline)
     self.assert_polyline(marshaled)
     assert 'M 1.5 2.5 L 2 3 L 4.1 5.1' == marshaled['points']
예제 #21
0
 def test_unrecognised_roi_shape_points_string(self, empty_polygon):
     marshaled = shapeMarshal(empty_polygon)
     assert ' z' == marshaled['points']
예제 #22
0
 def test_polygon_marshal(self, basic_polygon):
     marshaled = shapeMarshal(basic_polygon)
     self.assert_polygon(marshaled)
     assert 'M 1 2 L 2 3 L 4 5 z' == marshaled['points']
예제 #23
0
def _roi_to_json(roi_object):
    return {
        'id': roi_object.getId().getValue(),
        'shapes': [shapeMarshal(s) for s in roi_object.copyShapes()]
    }
예제 #24
0
 def test_unrecognised_roi_shape_points_string(self, empty_polygon):
     marshaled = shapeMarshal(empty_polygon)
     assert ' z' == marshaled['points']