We're Hiring!

uploading an image from a dir with annotations using python

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.

uploading an image from a dir with annotations using python

Postby jwarren » Wed Jul 09, 2014 2:52 pm

Hi - it was great meeting many of you in Paris recently :)

Is there a "basic" example of how to load an image from a local file into omero using python?
I can get an ImageI object using the following below but not from scratch/a file?

imageb = conn.getQueryService().get("Image", image.getId())
print type(imageb)
and then save it using:
conn.getUpdateService().saveObject(imageb)

Maybe it's because I'm new to python but I can't find anything in the python APIs to help me. In the examples I see they get images from omero and maybe add a text file as annotation - I would like to add a number of tagName=tagValue type annotations? How can I do that?

I guess the alternative is using the python cli wrapper using the import command which I've tried - but I have two issues:
1) if I run the import again it duplicates the images in omero - how would I stop that?
2) I can't add annotations or further info.

This is using omero 5.0.2 and appropriate apis.

Another question: I presume if I use any other method than the In-place import described at https://www.openmicroscopy.org/site/sup ... mport.html
I will be duplicating data on the server somewhere?

Many thanks in advance

Jonathan.
jwarren
 
Posts: 102
Joined: Wed Jul 09, 2014 1:35 pm

Re: uploading an image from a dir with annotations using pyt

Postby atarkowska » Thu Jul 10, 2014 9:28 am

Dear Johnathan

Was nice to see you in Paris too.

I am afraid you cannot use query service to import image because it allows to query existing data in OMERO server. Please look at the example import script we use locally to import images, like here . You need to invoke command line importer and then you can do pretty mach you want with the imported data.

Depends on your usecase might be easier for you to write shall script, like here.

You could first create tags using

Code: Select all
bin/omero tag -h

and then let CLI links existing tags on import, see http://www.openmicroscopy.org/site/supp ... ne-options.

Code: Select all
--annotation_link ANNOTATION_LINK Comment annotation ID to link all images to


There is no way to prevent from duplicates with re-importing the same images except when you use in-place import. Why do you need to import the same image few times?

I hope that will help

Ola
atarkowska
 
Posts: 327
Joined: Mon May 18, 2009 12:44 pm

Re: uploading an image from a dir with annotations using pyt

Postby jwarren » Thu Jul 10, 2014 1:51 pm

Thanks Ola for the reply - it helps to know the limitations of each tool to decide which ones to use and how we are going to use them as part of our wider system.

Seem like I should use my python script to determine what images need uploading and then invoke the importer for that specific file or directory or use the in place importer.

Then add annotations as a second phase once in.

I think I may have more questions but will ask them as new threads so they should be easy to find for other people.

Thanks again.
jwarren
 
Posts: 102
Joined: Wed Jul 09, 2014 1:35 pm


Return to Developer Discussion

Who is online

Users browsing this forum: No registered users and 1 guest