def test_find_rois_for_plane(self, projection): def getIds(objs, robject=True): if robject: return sorted(unwrap(o.getId()) for o in objs) return sorted(objs) im = self.create_image() iid = unwrap(im.getId()) r1 = utils.create_roi_for_plane( self.sess, unwrap(im.getId()), 2, 3, 4, robject=True) r2 = utils.create_roi_for_plane( self.sess, unwrap(im.getId()), 2, 4, 6, robject=True) r3 = utils.create_roi_for_plane( self.sess, unwrap(im.getId()), 2, 4, 8, robject=True) r3.getShape(0).setWidth(rdouble(1)) r3 = self.sess.getUpdateService().saveAndReturnObject(r3) r4 = utils.create_roi_for_plane( self.sess, unwrap(im.getId()), 2, 4, 8, robject=True) r4.addShape(omero.model.RectI()) r4 = self.sess.getUpdateService().saveAndReturnObject(r4) rs = utils.find_rois_for_plane(self.sess, iid=iid, z=1000) assert rs == [] rs = utils.find_rois_for_plane( self.sess, iid=iid, fullplane=True, projection=projection) assert getIds(rs, not projection) == getIds([r1, r2]) rs = utils.find_rois_for_plane( self.sess, iid=iid, singleshape=False, projection=projection) assert getIds(rs, not projection) == getIds([r1, r2, r4]) rs = utils.find_rois_for_plane( self.sess, iid=iid, fullplane=False, projection=projection) assert getIds(rs, not projection) == getIds([r1, r2, r3]) rs = utils.find_rois_for_plane( self.sess, iid=iid, c=4, fullplane=False, singleshape=False, projection=projection) assert getIds(rs, not projection) == getIds([r2, r3, r4])
def test_create_roi_for_plane(self, robject): im = self.create_image() r = utils.create_roi_for_plane( self.sess, unwrap(im.getId()), 2, 4, 6, robject=robject) if not robject: p = omero.sys.ParametersI() p.addId(r) r = self.sess.getQueryService().findByQuery( 'FROM Roi r JOIN FETCH r.shapes where r.id=:id', p) assert r.getImage().getId() == im.getId() assert r.sizeOfShapes() == 1 s = r.getShape(0) assert unwrap(s.getX()) == 0 assert unwrap(s.getY()) == 0 assert unwrap(s.getWidth()) == 4 assert unwrap(s.getHeight()) == 5 assert unwrap(s.getTheZ()) == 2 assert unwrap(s.getTheC()) == 4 assert unwrap(s.getTheT()) == 6