[ome-devel] connecting to omero via python
Will Moore
will at lifesci.dundee.ac.uk
Sat Feb 5 08:04:50 GMT 2011
Hi Adam,
Sorry for the confusion, but the connection you're using for most
stuff is the 'blitzcon' connection?
Or is 'blitzcon' the "second" connection you're using to get Dataset ID?
Confusingly, we have a 'gateway' service in the createSession()
connection, but we also refer to the 'blitzcon' connection as
omero.gatewa
You want to allow the user to browse their Projects and Datasets by
name, to get Dataset ID?
You can use the container service to list Projects and Datasets...
>>> projects = cs.loadContainerHierarchy("Project", None, None)
>>> for p in projects:
>>> print p.getName().getValue()
>>> for d in p.linkedDatasetList():
>>> print d.getName().getValue()
But if you know the name of the Dataset from the start, and you simply
want the ID, you CAN use the query service.
Using the query service is a 'quick and dirty' way of writing your own
database queries, but could be more susceptible to changes in the
OMERO data model etc.
Generally you will find it much easier to work with the blitzcon
connection.
You can do
i = blitzcon.getImage(ID)
for c in i.listChannels():
c.getName()
However, the blitzcon connection may make more calls to the server and
you have less control of this.
Let us know how you get on,
Will.
On 4 Feb 2011, at 18:45, Adam Fraser wrote:
> I'm in the process of developing the first OMERO interface from
> CellProfiler 2.0, 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
> _______________________________________________
> ome-devel mailing list
> ome-devel at lists.openmicroscopy.org.uk
> http://lists.openmicroscopy.org.uk/mailman/listinfo/ome-devel
William Moore
Wellcome Trust Centre for Gene Regulation & Expression
College of Life Sciences
MSI/WTB/JBC Complex
University of Dundee
Dow Street
Dundee DD1 5EH
United Kingdom
Phone 01382 386364
http://openmicroscopy.org
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openmicroscopy.org.uk/pipermail/ome-devel/attachments/20110205/242e3095/attachment.html>
More information about the ome-devel
mailing list