Page 2 of 2

Re: A weird behavior of linkAnnotation

PostPosted: Tue Jul 17, 2018 11:30 am
by dgault
If you are able to use the Bio-Formats Java API then there is an example of writing MapAnnotations here: https://github.com/openmicroscopy/biofo ... ample.java

Note that example uses hard coded index values, but if you wanted to base them on the current size of the annotation list then you can retrieve that using:
Code: Select all
int annotationIndex = metadata.getMapAnnotationCount();


The indexing would be independent for each type of Annotation. I would also recommend avoiding the reuse of previous ID's when deleting objects.

Re: A weird behavior of linkAnnotation

PostPosted: Wed Jul 18, 2018 10:54 am
by Kouichi_C_Nakamura
Sorry, I don't really understand. We're trying to retrieve the maximum ID of MapAnnotation used in a OMERO server. How can we get that value with Bioformats API rather than OMERO API? It doesn't seem that metadata has access to a OMERO session or OMERO server in the example given (https://github.com/openmicroscopy/biofo ... ample.java). Forgive me if I'm totally lost.

MetatadataService offers countSpecifiedAnnotations method and this can be the one for me, but 'map' seems inadequate to specify MapAnnotation and there is no clue in the documentation. 'MapAnnotation' seems the right one.

Code: Select all
ms = session.getMetadataService();
cnt = ms.countSpecifiedAnnotations('MapAnnotation',[],[],[])


cnt.getValue() was 60, whereas I'm already using ID 169. So maybe countSpecifiedAnnotations is not the one I need after all.

Re: A weird behavior of linkAnnotation

PostPosted: Fri Jul 20, 2018 7:07 am
by Kouichi_C_Nakamura
Effectively. the snippet below from writeMapAnnotation does the job. MapAnnotationI object ma will be sent to OMERO and there assigned with a new proper ID. Still you'll need to use linkAnnotation.m to actually link ma with an image.

Code: Select all
% Save the map annotation
context = java.util.HashMap;
if ~isempty(ip.Results.group)
    context.put(...
        'omero.group', java.lang.String(num2str(ip.Results.group)));
end
ma = session.getUpdateService().saveAndReturnObject(ma, context);