Page 1 of 1

Tagging ScreenPlateWell

PostPosted: Fri Jan 14, 2011 2:24 pm
by achessel
Hi all,

I recently begun to code against omero in matlab and python script for high throughput data and the learning curve is quite steep (but there certainly is a lot of doc around). In particular I have some problems/comments about wells tagging:

-are 'fields' in Insight 'WellSample' in the model? When tagging a field (which have a different id than the actual image behind it) in insight, it seems to actually tag the image (and you cannot really tag a well?); when tagging in a script, tagging well or wellsample does not seem to have any effect (the tag appears in the tag list in insight but seems to be linked to 0 objects), when tagging the image of a wellsample, the tag appear when clicking the field in insight and the image appear in the image list for that tag. So in the end (as far as Insight is concerned anyway), it seems that tags are to be at the level of screens, plates, or images?...

-in insight when an image is looked up outside of the plate interface (like searched for or through the tag interface), its very hard to know where it is from: the name would tend to be generic ('001001000.flex [Well G-11; Field #1]'), the 'contained in Dataset' is empty (as it should be) and there is not 'contained in Plate'. A minor point but that may come in handy... (actually it may be a larger problem: a file attached to a plate come up as 'attached to:''wild and free (...)' if you look it up in the attachment interface)

-about tags and users/group: can tags and tag sets be used across users in the same group completely transparently? Between groups? Can you nest tag sets, can a tag belong to several tag sets?

-I am on a script to automatically tag wells (or images in wells, as it happens). Given a text to tag with, I search for a tag with it; if it does not yet exist I create it else I re-use the existing one. I run into a problem trying to update the database: it works with a newly created tag but fail if I re-use an old one: ('ws' is a wellsample from a query service, 'tag' a tag from a search service)

link=ImageAnnotationLinkI()
img = ws.getImage()
link.setParent(img)
link.setChild(tag)
updateService.saveObject(link)

gives me (the same happens if I use img.linkAnnotation(tag)):

* serverExceptionClass = ome.conditions.ValidationException
* message = could not insert: [ome.model.annotations.ImageAnnotationLink]; SQL [insert into imageannotationlink (child, creation_id, external_id, group_id, owner_id, permissions, update_id, parent, version, id) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)]; constraint [imageannotationlink_parent_key]; nested exception is org.hibernate.exception.ConstraintViolationException: could not insert: [ome.model.annotations.ImageAnnotationLink]
* }

whereas ('totag' being a string)

tag = TagAnnotationI()
tag.setTextValue(rstring(totag))
img = ws.getImage()
link=img.linkAnnotation(tag)
updateService.saveObject(link)

works... What am I doing wrong?

Many thanks

A.

Re: Tagging ScreenPlateWell

PostPosted: Fri Jan 14, 2011 2:47 pm
by jmoore
achessel wrote:-I am on a script to automatically tag wells (or images in wells, as it happens). Given a text to tag with, I search for a tag with it; if it does not yet exist I create it else I re-use the existing one. I run into a problem trying to update the database: it works with a newly created tag but fail if I re-use an old one: ('ws' is a wellsample from a query service, 'tag' a tag from a search service)

link=ImageAnnotationLinkI()
img = ws.getImage()
link.setParent(img)
link.setChild(tag)
updateService.saveObject(link)

gives me (the same happens if I use img.linkAnnotation(tag)):

* serverExceptionClass = ome.conditions.ValidationException
* message = could not insert: [ome.model.annotations.ImageAnnotationLink]; SQL [insert into imageannotationlink (child, creation_id, external_id, group_id, owner_id, permissions, update_id, parent, version, id) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)]; constraint [imageannotationlink_parent_key]; nested exception is org.hibernate.exception.ConstraintViolationException: could not insert: [ome.model.annotations.ImageAnnotationLink]
* }


This would seem to say that the image has already been linked to that particular tag. Is that possible in your case?

~Josh

Re: Tagging ScreenPlateWell

PostPosted: Fri Jan 14, 2011 3:18 pm
by wmoore
I wonder if this is a problem with using loaded objects that are being concurrently modified?
Maybe try something like this, which uses unloaded Image and Tag:

Code: Select all
link.setParent(ImageI(img.id.val, False))
link.setChild(TagI(tag.id.val, False))


Jean-Marie (Insight guy) is not here just now...

I am not so familiar with the SPW model in Insight, but it's likely that field == well-sample and that Insight only uses Tags on Images, not fields.

The 'Wild and Free' is Jean-Marie's way of saying 'not in a Dataset'. I think he hasn't got around to showing what Wells an Image is in. I'll create a ticket: http://trac.openmicroscopy.org.uk/omero/ticket/3871

Tags can be shared by users in 'collaborative' groups and seen by users in 'read-only' groups. See demo movie http://cvs.openmicroscopy.org.uk/snapsh ... sions2.mov
Tag sets are not part of the data model. They are just an annotation on an annotation that Insight uses to organise tags a bit (I think Tags and Tag-sets have different namespace in the DB), and a Tag can be in more than one Tag set.

Hope that helps.

Will.

Re: Tagging ScreenPlateWell

PostPosted: Fri Jan 14, 2011 4:51 pm
by achessel
Thanks for the answers. It seems like I was indeed trying to re-tag an already tagged image (things got a bit messed up while testing script/adding/removing tags)...

It does not seems like you can get the images tagged by a particular tag... Is there an easy way to check whether a particular image is tagged by a particular tag? Are Ids unique among all Annotation or specific to TagAnnotation, etc, so that checking for the tag id in the image's ImageAnnotationLink is enough?

(another quick question while I am here: in python, to access a specific omero class you have to do stuff like
"From omero_model_TagAnnotationI import TagAnnotationI" for each one? Or am i doing it wrong and there is global "import"?)

Many thanks...

Re: Tagging ScreenPlateWell

PostPosted: Fri Jan 14, 2011 6:21 pm
by jburel
Hi

Field = Well Sample
Insight displays the annotation associated to the selected field/Well Sample. Not the well itself.
It is actually tricky b/c when we browse a plate we actually do not display the well but a well sample.
When you view the "image", you view the "well sample"
We have not done enough investigation on how to display in a meaningful way i.e.
well sample vs well for example. Any feedback welcome
If you want to see the tag, you should link it to the well sample not to the image linked to the well sample.

section of the model related to well is a follow
well -- wellSample -- image
A well can have multiple well samples.
A well sample will point to an image.

Hope that's not too confusing.

jmarie

Re: Tagging ScreenPlateWell

PostPosted: Fri Jan 14, 2011 8:47 pm
by wmoore
In python you should be able to do

Code: Select all
>>> from omero.model import *
>>> i = ImageI(100, False)


Although this imports everything, which may be a bit excessive?

Maybe 'better' to just import what you need like this:
Code: Select all
>>> from omero.model import TagAnnotationI, CommentAnnotationI, ImageI


All annotations are in a single Annotations table in the DB, so you can simply check the Image-link ID to check for a particular Tag.

Will.

Re: Tagging ScreenPlateWell

PostPosted: Mon Jan 17, 2011 8:27 am
by jmoore
Another option for referencing the model classes is to just use the "omero" namespace. Once a client is created, all of the omero.model objects have been loaded:

Code: Select all
Python 2.6.6 (r266:84292, Dec 30 2010, 16:35:14)
[GCC 4.2.1 (Apple Inc. build 5664)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import omero
>>> omero.model.ImageI
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: 'module' object has no attribute 'model'
>>> c = omero.client("localhost")
>>> ImageI = omero.model.ImageI
>>> img = ImageI()
>>>


Cheers,
~Josh

Re: Tagging ScreenPlateWell

PostPosted: Mon Jan 17, 2011 11:26 am
by achessel
thanks for all the answers; it's also the first time I code in python, so...

about field/well sample: I may be wrong, but it do seems that it is the image's tags that are shown and not the well sample's: if I tag a well sample, it won't show, and the tag will appear but linked to 0 items; it do work as expected if I tag the ws image. Maybe it is better that way: there is a one to one correspondence between ws and images anyway and it keeps the images as a common unit?...

Re: Tagging ScreenPlateWell

PostPosted: Thu Jan 20, 2011 7:38 pm
by jburel
I will have to review the code to check the links.
jmarie