We're Hiring!

Programmatic import guidance

General user discussion about using the OMERO platform to its fullest. Please ask 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

There are workflow guides for various OMERO functions on our help site - http://help.openmicroscopy.org

You should find answers to any basic questions about using the clients there.

Programmatic import guidance

Postby austinMLB » Mon Aug 06, 2018 9:45 pm

I’m looking to programmatically create a dataset and import some images into it. Ideally, I’d like to do this through Python. My impression is that the Gateway interface doesn’t currently have this functionality. (Is that accurate?) I’ve seen an example or two where people essentially called the Omero.CLI from within Python, though, for example, Popen(). But, I noticed in the Omero.CLI importer help:
“This is a Python wrapper around the Java importer”
This made me hopeful there might be a more direct route, from within my Python code, to call this functionality, a route that didn’t involve the external process. What is the recommended approach for me to take? (I suspect the answer is in the docs, but the complete picture hasn’t come together for me, yet.)
Thanks for any guidance.
austinMLB
 
Posts: 19
Joined: Wed Jul 25, 2018 3:26 pm

Re: Programmatic import guidance

Postby wmoore » Tue Aug 07, 2018 4:12 pm

Hi,

We have not done much work towards supporting import with vanilla Python, but there is some example code for how to do this at https://gitlab.com/openmicroscopy/incub ... rectory.py

This is a work in progress so is not considered production-ready.

This code will upload all the files within a directory and create a Fileset (a collection of file(s) that maps to 1 or more images in OMERO, depending on file format).
This is then imported. Bio-Formats on the server will parse the files in the fileset and try to work out which files to import.

The main limitation with importing via Python without using Bio-Formats logic on the client is that you need to know how to assign images to filesets. E.g. image.dv and image.log make up a single fileset and image2.dv and image2.log are a different fileset.

Let us know how you get on,

Regards,

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

Re: Programmatic import guidance

Postby austinMLB » Wed Aug 08, 2018 6:12 pm

@wmoore, thanks, that was very helpful.

This approach worked well to get my basic functionality: creating a dataset with a group of *.tif files. To do that, I put each file in its own Fileset. I would like to extend this to group my TIFF files into a time series. So, I have A_T1.tif, A_T2.tif, and A_T3.tif. Is there some specific way to group these files, plus perhaps metadata like a *pattern file, into the Fileset(s) which will create a time series?

Thanks.
austinMLB
 
Posts: 19
Joined: Wed Jul 25, 2018 3:26 pm

Re: Programmatic import guidance

Postby wmoore » Wed Aug 08, 2018 9:09 pm

This link should have everything you need:
http://docs.openmicroscopy.org/bio-form ... -file.html
Simply name the TIFFs correctly and include a pattern text file.

Hope that helps,

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

Re: Programmatic import guidance

Postby austinMLB » Thu Aug 09, 2018 3:52 pm

If I understand you correctly, the expectation is that if I point the code in your first link to a directory with all my TIFF's and my pattern file, I should get the expected grouped object when visualized through the omero web interface, as I do when I import that pattern file through Insight. I'm currently only seeing one of my TIFF files in my Dataset when I try that. My real test case has multiple channels and many timepoints, so I'll simplify my case to try to debug my problem. But, if anyone sees I'm mis-interpretting the expected behavior, please let me know.
Thanks,
MLB
austinMLB
 
Posts: 19
Joined: Wed Jul 25, 2018 3:26 pm

Re: Programmatic import guidance

Postby austinMLB » Thu Aug 09, 2018 6:55 pm

Perhaps I see my issue. If I ensure the *.pattern is the first file added to the Fileset, the result looks correct, on a simple example.
Thanks,
MLB
austinMLB
 
Posts: 19
Joined: Wed Jul 25, 2018 3:26 pm

Re: Programmatic import guidance

Postby jmoore » Mon Aug 13, 2018 8:51 am

Hi all,

in the way of a quick explanation, the current importer (`bin/omero import` which makes use of the Java code under lib/client) uses Bio-Formats to loop over all files and determine which file should be the first in the list with a fairly high success rate. This code doesn't exist in Python, so until the server reorders the files that are uploaded, some hard-coding of the ordering will be necessary when using this code. The need to upload all related files will remain a requirement on the Python code.

~Josh
User avatar
jmoore
Site Admin
 
Posts: 1591
Joined: Fri May 22, 2009 1:29 pm
Location: Germany


Return to User Discussion

Who is online

Users browsing this forum: No registered users and 1 guest