[ome-devel] connecting to omero via python
Adam Fraser
afraser at broadinstitute.org
Mon Feb 7 21:43:32 GMT 2011
Hi Will,
Thanks for your response, I would have gotten back to you sooner but I was
traveling.
On Sat, Feb 5, 2011 at 3:04 AM, Will Moore <will at lifesci.dundee.ac.uk>wrote:
> Hi Adam,
>
> Sorry for the confusion, but the connection you're using for most stuff is
> the 'blitzcon' connection?
>
No, I was primarily connecting via:
c = omero.client('ome2-copy.fzk.de')
s = c.createSession('afraser', '****')
g = s.createGateway()
> Or is 'blitzcon' the "second" connection you're using to get Dataset ID?
>
yup.
> Confusingly, we have a 'gateway' service in the createSession() connection,
> but we also refer to the 'blitzcon' connection as omero.gateway
>
hrm, I'm definitely confused then because I can do g.getPlane(ID, 0,0,0)
with the above gateway, but there's no such getPlane method in what we're
calling blitzcon.
Also confusingly, I can get a session from blitzcon, but it's apparently not
the same as the type of session I get from
omero.clients.BaseClient.createSession(user, password)
blitzcon = client_wrapper("afraser", "****", host="ome2-copy.fzk.de",
port=4064)
blitzcon.connect()
s = blitzcon.getSession()
s.getGateway() #fails
... of course the only reason I'm trying to get the gateway here is because
I need getPlane().
>
> 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()
>
Ok, this would prevent me from having to connect via the blitzcon thing
but...
> But if you know the name of the Dataset from the start, and you simply want
> the ID, you CAN use the query service.
>
Hrm, I know _nothing_ about the db schema, so I'd like to avoid this unless
it's going to give me a serious performance improvement.
> Generally you will find it much easier to work with the blitzcon
> connection.
>
Ok, so I should use blitzcon = omero.client_wrapper(...), that's fine.
Thanks for clearing this up. I don't want to use the gateway if it's going
to change on me, I had the impression it was the right thing to use after
reading this page<http://trac.openmicroscopy.org.uk/omero/wiki/OmeroPy/Gateway>
.
So here's where this puts me in terms of code:
import omero
from omero import client_wrapper
import numpy as np
user = 'xxx'
pw = 'xxx'
host = 'xxx'
project = 'xxx'
dataset = 'xxx'
blitzcon = client_wrapper(user, pw, host, port=4064)
blitzcon.connect()
# get all image ids from dataset:
*image_ids = #???*
for image_id in image_ids:
im = blitzcon.getImage(image_id)
# Get raw image plane.
# previously: plane = g.getPlane(image_id, 0, 0, 0)
*plane = #???*
px = im.getPixels(0)
h = px.getSizeY().getValue()
w = px.getSizeX().getValue()
imdata = np.array(list(plane))
imdata.shape = (h,w)
# now I can do stuff with imdata
Any chance you can help me fill in those 2 blanks?
Thanks again,
Adam
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openmicroscopy.org.uk/pipermail/ome-devel/attachments/20110207/b7d2536c/attachment.html>
More information about the ome-devel
mailing list