[ome-devel] Fwd: Re: get annotations java code

Thomas Boudier boudier.t at wehi.edu.au
Tue Jun 5 00:36:34 BST 2018




-------- Forwarded Message --------
Subject:        Re: [ome-devel] get annotations java code
Date:   Tue, 5 Jun 2018 09:36:06 +1000
From:   Thomas Boudier <boudier.t at wehi.edu.au><mailto:boudier.t at wehi.edu.au>
To:     Dominik Lindner (Staff) <d.lindner at dundee.ac.uk><mailto:d.lindner at dundee.ac.uk>



Hi Dominik,

Thanks, I was a bit confused I guess between Facility classes. Maybe in the future you may  want to also have some setAnnotations methods ;-) .

Here my code for information :

Map<String, String> map = new HashMap<>();
        MetadataFacility metadataFacility = gateway.getFacility(MetadataFacility.class);
        List<AnnotationData> list = metadataFacility.getAnnotations(ctx, image);
        for (AnnotationData annotationData : list) {
            //IJ.log("" + annotationData.getClass().getName() + " " + annotationData.getLastModified());
            if (annotationData instanceof MapAnnotationData) {
                MapAnnotationData mapAnnotationData = (MapAnnotationData) annotationData;
                //IJ.log("FOUND PAIR " + mapAnnotationData.getContentAsString());
                String[] data = mapAnnotationData.getContentAsString().split("=");
                map.put(data[0], data[1]);
            }
        }


Many thanks.

Best,

Thomas

On 04/06/18 20:56, Dominik Lindner (Staff) wrote:
Hi Thomas,

it looks like you're using the java gateway. In that case you can use the "MetadataFacility" to load
the MapAnnotations. Here's a github gist with an example:

https://gist.github.com/dominikl/b16bc46f702dbc1cdea1b8ffeb0421c9

Kind Regards,
Dominik


On 1 Jun 2018, at 01:00, Thomas Boudier <boudier.t at wehi.edu.au<mailto:boudier.t at wehi.edu.au>> wrote:


Dear Omero devs,

I would like to access key value pairs assocaited to an image but created by other users. It seems, thanks to the code provided on the omero website, to extract all annotations from me, but I do not know how to get only annotatins assocaited to a specific image.

here the code I wrote with "image" being an imageData object.

long userId = gateway.getLoggedInUser().getId();
List<String> nsToInclude = new ArrayList<>();
//nsToInclude.add(MapAnnotationData.NS_CLIENT_CREATED);
List<String> nsToExclude = new ArrayList<>();
ParametersI param = new ParametersI();
//param.exp(omero.rtypes.rlong(userId)); // user
param.exp(omero.rtypes.rlong(image.getId())); // image ??
IMetadataPrx proxy = gateway.getMetadataService(ctx);
try {
    List<Annotation> annotations = proxy.loadSpecifiedAnnotations(MapAnnotation.class.getName(), nsToInclude, nsToExclude, param);
    IJ.log(annotations.size() + "  annotations found");
    for (Annotation annotation : annotations) {
        IJ.log(" "+annotation.getClass()+" "+annotation.getId());
        MapAnnotation mapAnnotation = (MapAnnotation) annotation;
        List<NamedValue> list = mapAnnotation.getMapValue();
        for (NamedValue namedValue : list)
            IJ.log(namedValue.name + "  " + namedValue.value);
    }
} catch (ServerError serverError) {
    IJ.log("Pb reading annotation " + serverError.message);
    serverError.printStackTrace();
}



Thanks for any help.

best

Thomas

--
/***************************************************************/
      Thomas Boudier, Senior Research Officer,
      BioImage Analyst, Dynamic Imaging Centre,
      Walter and Eliza Hall Institute (WEHI), Australia.
/**************************************************************/


_______________________________________________

The information in this email is confidential and intended solely for the addressee.
You must not disclose, forward, print or use it without the permission of the sender.

The Walter and Eliza Hall Institute acknowledges the Wurundjeri people of the Kulin
Nation as the traditional owners of the land where our campuses are located and
the continuing connection to country and community.
_______________________________________________

_______________________________________________
ome-devel mailing list
ome-devel at lists.openmicroscopy.org.uk<mailto:ome-devel at lists.openmicroscopy.org.uk>
http://lists.openmicroscopy.org.uk/mailman/listinfo/ome-devel


The University of Dundee is a registered Scottish Charity, No: SC015096


_______________________________________________
ome-devel mailing list
ome-devel at lists.openmicroscopy.org.uk<mailto:ome-devel at lists.openmicroscopy.org.uk>
http://lists.openmicroscopy.org.uk/mailman/listinfo/ome-devel



--
/***************************************************************/
      Thomas Boudier, Senior Research Officer,
      BioImage Analyst, Dynamic Imaging Centre,
      Walter and Eliza Hall Institute (WEHI), Australia.
/**************************************************************/


_______________________________________________

The information in this email is confidential and intended solely for the addressee.
You must not disclose, forward, print or use it without the permission of the sender.

The Walter and Eliza Hall Institute acknowledges the Wurundjeri people of the Kulin
Nation as the traditional owners of the land where our campuses are located and
the continuing connection to country and community.
_______________________________________________
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openmicroscopy.org.uk/pipermail/ome-devel/attachments/20180604/8bc5cec9/attachment.html>


More information about the ome-devel mailing list