[ome-devel] OMERO: load annotations of projects and datasets

Josh Moore josh at glencoesoftware.com
Sun Jun 10 11:04:55 BST 2012


On Jun 5, 2012, at 8:25 PM, Tom Kazimiers wrote:

> Will,
> 
> thanks for your reply, I made some progress.
> 
> On 05.06.2012 16:56, Will Moore wrote:
>> If you want to use the Java API, look under this bullet point on the OmeroJava page:
>> 
>> Load all the annotations with a given namespace linked to images.
>> 
>> Projects and Datasets can be treated in the same way as Images when loading annotations.
> 
> Okay, so I managed to load my tag annotations in the namespace
> "test_namespace" with:
> 
> nsToInclude = ArrayList()
> nsToInclude.add( "test_namespace" )
> nsToExclude = ArrayList()
> proxy = entry.getMetadataService()
> annotations = proxy.loadSpecifiedAnnotations(TagAnnotationI.canonicalName, nsToInclude, nsToExclude, param)
> 
> Now it isn't clear to me how I restrict this annotation loading
> to annotations from a specific project or a dataset. I added to
> a dataset and a project one tag annotation in namespace
> "test_namespace". When I retrieve annotations like above I get
> all annotations.
> 
> So is it possible to load project and dataset annotations
> separately with this way? The documentation[1] lets me suspect
> that proxy.loadAnnotations(…) might be of use here. However, I
> couldn't find a correct parameterization for that method -- I
> couldn't find out what exactly I have to put there as
> "rootType".

The rootType is like your canonicalName but for the container types: "Project", "Dataset", "Image", etc.

Here's an example:

$ python tom.py 
found for ProjectI:  1
found for DatasetI:  2

$ cat tom.py 

import omero
c = omero.client("localhost")
s = c.createSession("root","ome")
u = s.getUpdateService()
m = s.getMetadataService()

anns = []
for x in range(3):
    x = omero.model.CommentAnnotationI()
    anns.append(u.saveAndReturnObject(x))
    anns[-1].unload()

p = omero.model.ProjectI()
p.setName(omero.rtypes.rstring("tom"))
d = omero.model.DatasetI()
d.setName(omero.rtypes.rstring("tom"))
p.linkDataset(d)
p.linkAnnotation(anns[0])
d.linkAnnotation(anns[1])
d.linkAnnotation(anns[2])

p = u.saveAndReturnObject(p)
d = p.linkedDatasetList()[0]

for x in (p, d):
    anns = m.loadAnnotations(x.__class__.__name__, [x.id.val], None, None, None)
    print "found for %s: " % x.__class__.__name__, len(anns[x.id.val])



> And how would I do lazy loading myself to use the applications I tried in the first place?

Sorry, I don't follow. Where and what would you like to lazy load? If the question is - is there any lazy loading in OmeroJava, the answer is no.


Cheers,
~Josh

>> However, since you're using Jython, I wondered if the OmeroPy page would be more useful than OmeroJava?
>> 
>> http://trac.openmicroscopy.org.uk/ome/wiki/OmeroPy
>> 
>> In Python we have a "Blitz Gateway" which is a client side library that does a lot of lazy loading of the graph, so you can do
>> 
>> dataset = conn.getObject("Dataset", datasetId)
>> for ann in dataset.listAnnotations():
>>    print ann
>> which is loading the Annotations on the fly.
> 
> This would be definitely of help. However for my application
> it was easier to have it done with OmeroJava as I will probably
> move to Java once I got a better understanding of OMERO. However,
> thanks for the suggestion.
> 
> Cheers,
> Tom
> 
> [1] http://hudson.openmicroscopy.org.uk/job/OMERO/javadoc/slice2html/omero/api/IMetadata.html#loadAnnotations

-------------- next part --------------
A non-text attachment was scrubbed...
Name: PGP.sig
Type: application/pgp-signature
Size: 243 bytes
Desc: This is a digitally signed message part
URL: <http://lists.openmicroscopy.org.uk/pipermail/ome-devel/attachments/20120610/222d1c9f/attachment.pgp>


More information about the ome-devel mailing list