We're Hiring!

retrieving "tag" API?

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: retrieving "tag" API?

Postby bhcho » Fri Dec 10, 2010 8:34 pm

Hi Josh,

the problem is I cannot get the value using the key of idSetMap in Matlab.

Code: Select all
>> idSetMap             
idSetMap =
{4776=[omero.model.TagAnnotationI@760951a0]}

>> idSetMap.get('4776')               
ans =
     []

>> idSetMap.put('aaa','bbb')
ans =
     []

>> idSetMap
idSetMap =
{aaa=bbb, 4776=[omero.model.TagAnnotationI@760951a0]}

>> idSetMap.get('aaa')
ans =
bbb

>> idSetMap.get('4776')
ans =
     []
bhcho
 
Posts: 236
Joined: Mon Apr 05, 2010 2:15 pm

Re: retrieving "tag" API?

Postby jmoore » Fri Dec 10, 2010 8:46 pm

If you don't use the iterator method to retrieve the actual key object, then you will need to create a java.lang.Long instead:
Code: Select all
idSetMap.get(java.lang.Long(4776)).


get('4776') is using a string.
~J.
User avatar
jmoore
Site Admin
 
Posts: 1591
Joined: Fri May 22, 2009 1:29 pm
Location: Germany

Re: retrieving "tag" API?

Postby bhcho » Fri Dec 10, 2010 10:04 pm

Thanks so much Josh,

I finally found a way to retrieve them.


Code: Select all
metadataService = omepslid.session.getMetadataService();
try
    imageIds = java.util.ArrayList();
    for i=1:length(IIDs)  % IIDs is a matlab array that holds the image IDs
        imageIds.add(java.lang.Long(IIDs(i)));
    end

    annotationTypes = java.util.ArrayList();
    annotationTypes.add('ome.model.annotations.TagAnnotation');

    % Unused
    annotatorIds = java.util.ArrayList();
    parameters = omero.sys.Parameters();

    idSetMap = metadataService.loadAnnotations('Image', imageIds, annotationTypes, annotatorIds, parameters);
    for i=1:idSetMap.size
        ArrList = idSetMap.get(java.lang.Long(IIDs(i)));
        for j=1:ArrList.size
            tagValue = ArrList.get(j-1).getTextValue().getValue();
            txt = ['Image ID: ' num2str(IIDs(i)) '    TagVale: ' char(tagValue)];
            disp(txt);
        end
    end
   
catch ME
    disp(ME);
    omepslid.client.closeSession();
end


Image ID: 4779    TagVale: I believe
Image ID: 4779    TagVale: Classlabel: Septins
Image ID: 4781    TagVale: Classlabel: Septins
Image ID: 4780    TagVale: Classlabel: Septins
Image ID: 4778    TagVale: Classlabel: vector
Image ID: 4776    TagVale: Classlabel: vector
Image ID: 4777    TagVale: Classlabel: vector


bhcho
 
Posts: 236
Joined: Mon Apr 05, 2010 2:15 pm

Re: retrieving "tag" API?

Postby jmoore » Fri Dec 10, 2010 10:12 pm

Glad to hear it, BK!
~J.
User avatar
jmoore
Site Admin
 
Posts: 1591
Joined: Fri May 22, 2009 1:29 pm
Location: Germany

Previous

Return to Developer Discussion

Who is online

Users browsing this forum: Google [Bot] and 0 guests