Page 1 of 1

A way to flip well coordinates during/after import

PostPosted: Tue Jun 26, 2012 2:23 pm
by rguha
Hi, we have collected Incell images from a set of 1536 well plates on our robot, but due to a setup issue the well coordinates have been flipped in the output files - ie the XDCE file and the plate file names.

I have been able to import these plates successfully via the importer GUI and I can see the wells in their 'flipped' layout.

Is there a way during the import process (or after the import is done) that I could flip the well coordinates? Can this be solved by some sort of plugin that could hook into the import process?

I could go through the actual XDCE and image files and do the flip myself via a Python script, but was wondering if OME could handle this type of problem.

Thanks,
Rajarshi

Re: A way to flip well coordinates during/after import

PostPosted: Wed Jun 27, 2012 8:24 am
by cxallan
There are currently no real extension points within the importer that would allow you to do this. Your options really are limited to modifying the XDCE file with a Python script or similar as you've already suggested or write an OMERO Python script that switches the Well coordinates after import.

Re: A way to flip well coordinates during/after import

PostPosted: Wed Jun 27, 2012 8:52 pm
by rguha
Thanks for the suggestions. Are there any examples of OMERO Python scripts that I could work of of?

Re: A way to flip well coordinates during/after import

PostPosted: Wed Jun 27, 2012 10:49 pm
by wmoore
If you look in the Insight or Web client, run a script Util_Scripts > Dataset_To_Plate, you will see how to create a plate from a series of images.

Demo Movie:
http://cvs.openmicroscopy.org.uk/snapsh ... -4.3.2.mov

You can access the script from the run-script dialog (bottom left of dialog - "View Script") or look at the code:
https://github.com/openmicroscopy/openm ... o_Plate.py


But really I think all you want to do is switch the column and row values on each well.
In fact, the code below almost does what you want:

Code: Select all
import omero.clients
from omero.gateway import BlitzGateway
from omero.rtypes import rint

user = 'root'
pw = 'ome'
host = 'localhost'

conn = BlitzGateway(user, pw, host=host, port=4064)
conn.connect()

pId = 57
plate = conn.getObject("Plate", pId)

wells = []
for well in plate.listChildren():
    c = well.column
    r = well.row
    print r, c
    well._obj.column = rint(r)
    well._obj.row = rint(c)
    wells.append(well._obj)

conn.getUpdateService().saveArray(wells)


The only problem is that the Save action generates a ValidationException since when you try to swap the position of 2 wells, you try to save one of them in position that is already occupied. It is not valid to have two wells in the same position in a Plate!

You may be able to get around this by first saving all the wells to vacant position E.g. column = 100+column, then placing them back in the desired location. I'll try and think of a nicer solution....!

Re: A way to flip well coordinates during/after import

PostPosted: Thu Jun 28, 2012 10:31 am
by wmoore
After a bit of discussion, it turns out that the DB will not allow a "nice" way of doing this, due to various constraints etc. Probably the best way to do it is to temporarily save the wells to a new Plate when switching their rows & columns. Then save them back to the original plate.

The complete script for doing this is at https://gist.github.com/3010541

If you want to allow users to run this from the clients, you can put this logic into an OMERO script (see Dataset_To_Plate.py above). If you get Data_Type as "Plate" instead of "Dataset", and use IDs to get the Plate ID, then the clients will auto-populate these when a Plate is selected and you run the script.