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

Tom Kazimiers tom at voodoo-arts.net
Mon Jun 11 10:54:17 BST 2012


Hi Josh,

On 10.06.2012 12:04, Josh Moore wrote:
> On Jun 5, 2012, at 8:25 PM, Tom Kazimiers wrote:
> 
>> […]
>>
>> proxy = entry.getMetadataService()
>> annotations = proxy.loadSpecifiedAnnotations(TagAnnotationI.canonicalName, nsToInclude, nsToExclude, param)
>>
>> […]
>>
>> 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])

Great, thanks a lot for this example. This clarified things for me.

>> 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.

The question I had, was whether and how I can do lazy loading with
OmeroJava myself. A question that I should ask before this is actually
whether OmeroJava's loadSpecifiedAnnotations() (used in a previous mail)
loads and transmits all the annotations when called. I understood it
like this and on large datasets it might be good to first get all the
IDs for the linked annotations and read only the ones linked to a
particular image or even only single ones.

Now your code example above cleared up this question as well. I guess to
only load the annotations of one particular image I would just call
loadAnnotations() and pass the Image class name and the image's id.

Cheers,
Tom

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 227 bytes
Desc: OpenPGP digital signature
URL: <http://lists.openmicroscopy.org.uk/pipermail/ome-devel/attachments/20120611/2c8dfe06/attachment.pgp>


More information about the ome-devel mailing list