[ome-devel] connecting to omero via python

Adam Fraser afraser at broadinstitute.org
Fri Feb 4 18:45:01 GMT 2011


I'm in the process of developing the first OMERO interface from CellProfiler
2.0 <http://cellprofiler.org/>, and I'd like a little help in writing clean
efficient code. The first module I'm working on is one that will import
image channels into CP directly from OMERO.

>From a user point of view, the controls will look like this:

*server*: *my server*
*username*: *afraser*
*password*: *******
*project*: *adams_project*
*dataset*: *adams_dataset*


...and they'll specify a name for each of their channels somehow:

*channel 1 name*: *DNA*
*channel 2 name*: *Actin*
(add channel button)

(these names will be used in the input controls of downstream modules in
CellProfiler)

Just before the pipeline is run, I'd like to connect to the server, and
create a list of all the image ids that I'll be accessing during each
iteration. One way to do this would be:

        c = omero.client(self.server.value)
        s = c.createSession(self.username.value, self.password.value)
        cs = s.getContainerService()
        blitzcon = client_wrapper(self.username.value,
                                  self.password.value,
                                  host=self.host.value, port=4064)

        blitzcon.connect()
        for p in blitzcon.listProjects():
            for dataset in p.listChildren():
                if dataset.getName() == self.dataset.value
                    *dataset_id* = dataset.getId()

        imgs = cs.getImages("Dataset", [*dataset_id*], None)
        d = self.get_dictionary(image_set_list)
        for i, img in enumerate(imgs):
            image_set = image_set_list.get_image_set(i)
            d[i] = img.getId().getValue()

I emboldened dataset_id because you can see that I am establishing a whole
second connection just to get it because I was unable to find equivalent
methods within omero.gateway which I am using (so far) for everything else.

I was hoping someone could give me a better way of doing this. Additionally
I have yet to run into trouble regarding keeping the session alive, but I'm
not doing anything special to prevent it from going away so I expect this
will be a problem eventually.

Thanks for your help,
Adam
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openmicroscopy.org.uk/pipermail/ome-devel/attachments/20110204/d285747b/attachment.html>


More information about the ome-devel mailing list