We're Hiring!

Retrieving image name

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.

Retrieving image name

Postby icaoberg » Mon May 05, 2014 11:02 pm

Using the API I know I can retrieve the image name from the image object, i.e.

Code: Select all
In [11]: iid = 1
In [12]: img = conn.getObject( 'Image', iid )
In [13]: img.getId()
Out[13]: 1L
In [14]: img.getName()
Out[14]: 'cell10_ome.tif'


Now, when I try to retrieve the image name from the list of children from a dataset
Code: Select all
list_of_images = []
# connect as above
for project in conn.listProjects():
    for dataset in project.listChildren():
        links = dataset.getChildLinks()
        for image in links:
            temp = {}
            temp['iid'] = long(image.getId())
            temp['name'] = image.getName()
            list_of_images.append( temp )

print json.dumps( list_of_images )


produces the output
Code: Select all
omero@developers:/usr0/local/OMERO/OMERO.server-5.0.0-ice34-b19/lib/scripts/omero_scripts$ omero script launch 298
Using session a882c5b3-9557-4808-b2cf-11f631688333 (icaoberg@localhost:4064). Idle timeout: 10.0 min. Current group: murphylab
Job 284 ready
Waiting....
Callback received: FINISHED

   *** start stdout (id=303)***
   * [{"iid": 1, "name": null}, {"iid": 2, "name": null}, {"iid": 3, "name": null}, {"iid": 4, "name": null}, {"iid": 5, "name": null}, {"iid": 6, "name": null}, {"iid": 7, "name": null}]
   *
   *** end stdout ***


Since the names should the filenames at import, am I using the methods incorrectly? Is this an error? I don't have the same issue trying to retrieve the names of datasets or projects.
icaoberg
 
Posts: 145
Joined: Fri Sep 17, 2010 9:05 pm
Location: Pittsburgh, PA

Re: Retrieving image name

Postby wmoore » Tue May 06, 2014 8:42 am

Hi,

You simply need to use dataset.listChildren() in exactly the same way you do for project.listChildren().
This will give you a generator of ImageWrappers (same as you get with conn.getObject("Image", iid).

Will.
User avatar
wmoore
Team Member
 
Posts: 674
Joined: Mon May 18, 2009 12:46 pm


Return to Developer Discussion

Who is online

Users browsing this forum: No registered users and 0 guests