We're Hiring!

A weird behavior of linkAnnotation

General and open developer discussion about using OMERO APIs from C++, Java, Python, Matlab and more! Please new questions at https://forum.image.sc/tags/omero
Please note:
Historical discussions about OMERO. Please look for and ask new questions at https://forum.image.sc/tags/omero

If you are having trouble with custom code, please provide a link to a public repository, ideally GitHub.

Re: A weird behavior of linkAnnotation

Postby dgault » Tue Jul 17, 2018 11:30 am

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.
User avatar
dgault
Team Member
 
Posts: 208
Joined: Fri Aug 14, 2015 2:56 pm

Re: A weird behavior of linkAnnotation

Postby Kouichi_C_Nakamura » Wed Jul 18, 2018 10:54 am

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.
Kouichi_C_Nakamura
 
Posts: 165
Joined: Thu Oct 19, 2017 1:35 pm

Re: A weird behavior of linkAnnotation

Postby Kouichi_C_Nakamura » Fri Jul 20, 2018 7:07 am

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);
Kouichi_C_Nakamura
 
Posts: 165
Joined: Thu Oct 19, 2017 1:35 pm

Previous

Return to Developer Discussion

Who is online

Users browsing this forum: Majestic-12 [Bot] and 1 guest

cron