Hi All,
Is there any API that can set/retrieve the "tag" on/from images?
Best,
BK
			
		 
    

% Simple example of using omero.api.IMetadataPrx
% to retrieve the annotations associated with an
% Image.
[client, sf] = loadOmero;
try
    metadataService = sf.getMetadataService();
    imageIds = java.util.ArrayList();
    imageIds.add(java.lang.Long(1));
    annotationTypes = java.util.ArrayList();
    annotationTypes.add('TagAnnotation');
    % Unused
    annotatorIds = java.util.ArrayList();
    parameters = omero.sys.Parameters();
    idSetMap = metadataService.loadAnnotations('Image', imageIds, annotationTypes, annotatorIds, parameters);
    itr = idSetMap.keySet().iterator();
    while itr.hasNext()
        disp(itr.next()); % Each image id in imageIds
    end
catch ME
    disp(ME);
    client.closeSession();
end

imageIds = java.util.ArrayList();
imageIds.add(java.lang.Long(1));
imageIds = java.util.ArrayList();
imageIds.add(java.lang.Long(1));
in this part I put the image file ID instead of "1", such as 4779.
And the result is that file ID again.
I clearly put some text tag to that Image from OMERO.Insight though.
Am I misunderstanding something?
idSetMap.get(itr.next());

>> idSetMap
idSetMap =
 
{4777=[]}
>> idSetMap.get(itr.next())
??? Java exception occurred:
java.util.NoSuchElementException
        at java.util.HashMap$HashIterator.nextEntry(Unknown Source)
        at java.util.HashMap$KeyIterator.next(Unknown Source)ome.model.annotations.TagAnnotation

>> idSetMap              
 
idSetMap =
 
{4776=[omero.model.TagAnnotationI@760951a0]}tag.getTextValue().getValue()
In [3]: m = client.sf.getMetadataService()
In [4]: images = client.sf.getQueryService().findAll("Image",None)
In [5]: idSetMap = m.loadAnnotations("Image",[x.id.val for x in images], ["ome.model.annotations.TagAnnotation"], [],None)
In [6]: for k,v in idSetMap.items():
   ...:     if len(v) > 0:
   ...:         print k, [x.getTextValue().getValue() for x in v if x.getTextValue() is not None]
4518 ['Classlabel: 2']
4520 ['Classlabel: 1']
4519 ['Classlabel: 1']

Return to Developer Discussion
Users browsing this forum: Google [Bot] and 0 guests