We're Hiring!

Tagging ScreenPlateWell

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.

Tagging ScreenPlateWell

Postby achessel » Fri Jan 14, 2011 2:24 pm

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.
achessel
 
Posts: 67
Joined: Fri Jan 14, 2011 1:58 pm

Re: Tagging ScreenPlateWell

Postby jmoore » Fri Jan 14, 2011 2:47 pm

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
User avatar
jmoore
Site Admin
 
Posts: 1591
Joined: Fri May 22, 2009 1:29 pm
Location: Germany

Re: Tagging ScreenPlateWell

Postby wmoore » Fri Jan 14, 2011 3:18 pm

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.
User avatar
wmoore
Team Member
 
Posts: 674
Joined: Mon May 18, 2009 12:46 pm

Re: Tagging ScreenPlateWell

Postby achessel » Fri Jan 14, 2011 4:51 pm

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...
achessel
 
Posts: 67
Joined: Fri Jan 14, 2011 1:58 pm

Re: Tagging ScreenPlateWell

Postby jburel » Fri Jan 14, 2011 6:21 pm

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
User avatar
jburel
Team Member
 
Posts: 348
Joined: Thu May 21, 2009 6:38 pm
Location: dundee

Re: Tagging ScreenPlateWell

Postby wmoore » Fri Jan 14, 2011 8:47 pm

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.
User avatar
wmoore
Team Member
 
Posts: 674
Joined: Mon May 18, 2009 12:46 pm

Re: Tagging ScreenPlateWell

Postby jmoore » Mon Jan 17, 2011 8:27 am

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
User avatar
jmoore
Site Admin
 
Posts: 1591
Joined: Fri May 22, 2009 1:29 pm
Location: Germany

Re: Tagging ScreenPlateWell

Postby achessel » Mon Jan 17, 2011 11:26 am

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?...
achessel
 
Posts: 67
Joined: Fri Jan 14, 2011 1:58 pm

Re: Tagging ScreenPlateWell

Postby jburel » Thu Jan 20, 2011 7:38 pm

I will have to review the code to check the links.
jmarie
User avatar
jburel
Team Member
 
Posts: 348
Joined: Thu May 21, 2009 6:38 pm
Location: dundee


Return to Developer Discussion

Who is online

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