Page 1 of 1

Programmatic import guidance

PostPosted: Mon Aug 06, 2018 9:45 pm
by austinMLB
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.

Re: Programmatic import guidance

PostPosted: Tue Aug 07, 2018 4:12 pm
by wmoore
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.

Re: Programmatic import guidance

PostPosted: Wed Aug 08, 2018 6:12 pm
by austinMLB
@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.

Re: Programmatic import guidance

PostPosted: Wed Aug 08, 2018 9:09 pm
by wmoore
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

Re: Programmatic import guidance

PostPosted: Thu Aug 09, 2018 3:52 pm
by austinMLB
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

Re: Programmatic import guidance

PostPosted: Thu Aug 09, 2018 6:55 pm
by austinMLB
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

Re: Programmatic import guidance

PostPosted: Mon Aug 13, 2018 8:51 am
by jmoore
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