Page 1 of 1

copyShapes() method is not found

PostPosted: Thu Jan 24, 2019 12:28 pm
by Kouichi_C_Nakamura
Looking at this page (https://docs.openmicroscopy.org/latest/ ... #read-data), I'm following the example in Retrieve ROIs linked to an Image in MATLAB.

Code: Select all
ROIFacility roifac = gateway.getFacility(ROIFacility.class);

//Retrieve the roi linked to an image
List<ROIResult> roiresults = roifac.loadROIs(ctx, image.getId());
ROIResult r = roiresults.iterator().next();
if (r == null) return;
Collection<ROIData> rois = r.getROIs();
List<Shape> list;
Iterator<Roi> j = rois.iterator();
while (j.hasNext()) {
  roi = j.next();
  list = roi.copyShapes();
  // Do something
}


In my practice, roi is an omero.gateway.model.ROIData object and it does not have a method called copyShapes(): https://javadoc.scijava.org/OMERO/omero ... IData.html

I could not find it in the index either: https://javadoc.scijava.org/OMERO/index-all.html


MATLAB code
Code: Select all
roifac = getGatewayFacility(gateway,'ROIFacility'); %see https://www.openmicroscopy.org/community/viewtopic.php?f=6&t=8615&p=20473#p20473

//Retrieve the roi linked to an image
roiresults = roifac.loadROIs(ctx, image.getId());
r = roiresults.iterator().next();
if isempty(r)
    return;
end
rois = r.getROIs();

j = rois.iterator();
while (j.hasNext()) {
  roi = j.next();
  list = roi.copyShapes();  %TODO
  // Do something
}


I guess that the code example is obsolete and requires renewal.

Re: copyShapes() method is not found

PostPosted: Thu Jan 24, 2019 1:44 pm
by Dominik
You are right. Thanks for pointing this out. I'll update the documentation.

The example should rather be like this:
Code: Select all
       // Retrieve the roi linked to an image
        List<ROIResult> roiresults = roifac.loadROIs(userCtx, imgId);
        ROIResult r = roiresults.iterator().next();
        if (r == null)
            return;
        Collection<ROIData> rois = r.getROIs();
        Iterator<ROIData> j = rois.iterator();
        while (j.hasNext()) {
            ROIData roi = j.next();
            List<ShapeData> shapes = roi.getShapes(-1, -1);
            // Do something
        }


Regards,
Dominik

Edit: See http://downloads.openmicroscopy.org/ome ... s-int-int-
Alternatively you can also get the shapes via the getIterator() method, which returns Lists of shapes.