[ome-devel] get annotations java code
Dominik Lindner (Staff)
d.lindner at dundee.ac.uk
Mon Jun 4 11:56:13 BST 2018
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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openmicroscopy.org.uk/pipermail/ome-devel/attachments/20180604/ea92d40c/attachment.html>
More information about the ome-devel
mailing list