We're Hiring!

Import images using the Gateway

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.

Import images using the Gateway

Postby rguichard » Mon Nov 27, 2017 9:10 am

Dear Omero team,
A quick question, I am developing a in-house image importer for Omero in Python. I have a simple question, can I use the Gateway to import images without the CLI ?
Best regards
Roland Guichard
rguichard
 
Posts: 1
Joined: Fri Nov 24, 2017 2:36 pm

Re: Import images using the Gateway

Postby jmoore » Mon Nov 27, 2017 3:26 pm

Hi Roland,

rguichard wrote:I am developing a in-house image importer for Omero in Python. I have a simple question, can I use the Gateway to import images without the CLI ?


The BlitzGateway doesn't yet provide a Python-only import mechanism, though it is likely something we'll be interested in as well in the coming months.

In the meantime, you might take a look at the test_reimport.py file. The methods startUpload and uploadFileset reproduce what the Java importer does in pure Python.

The major drawback is not having access to Bio-Formats in order to determine the list of files that need uploading. If you can manage that internally, however, then there's no reason not to work directly from Python.

Let us know how it goes!
~Josh
User avatar
jmoore
Site Admin
 
Posts: 1591
Joined: Fri May 22, 2009 1:29 pm
Location: Germany

Re: Import images using the Gateway

Postby wmoore » Thu Nov 30, 2017 7:35 am

Josh,
In that example, createSynthetic() seems to first import a 16 x 16 multi-image file and duplicate it. But do startUpload() and uploadFileset() need to use a newImg created in this way, or can you create a newImage (with unknown dimensions) in a simpler way?
User avatar
wmoore
Team Member
 
Posts: 674
Joined: Mon May 18, 2009 12:46 pm

Re: Import images using the Gateway

Postby jmoore » Thu Nov 30, 2017 8:14 am

Hi Roland,

Apologies. You can definitely create a new image this way, but the test_reimport.py class is trying to do too many things for this example. The method I was looking for had actually been refactored out into the `omero.testlib` package:

https://github.com/openmicroscopy/openmicroscopy/blob/develop/components/tools/OmeroPy/src/omero/testlib/__init__.py#L1340

Code: Select all
    def full_import(self, client):
        """
        Re-usable method for a basic import
        """
        mrepo = self.get_managed_repo(client)
        folder = self.create_test_dir()
        fileset = self.create_fileset(folder)
        settings = self.create_settings()

        proc = mrepo.importFileset(fileset, settings)
        try:
            return self.assert_import(client, proc, folder)
        finally:
            proc.close()


That should hopefully be a bit more straight-forward.

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

Re: Import images using the Gateway

Postby wmoore » Fri Dec 01, 2017 10:15 am

Thanks Josh,

I created a stand-alone script to import, taking and tweaking code from the testlib.

https://gist.github.com/will-moore/f540 ... 8b38a077ce

This imports all the images in the target folder as a single 'Fileset' in OMERO.
A Fileset is what BioFormats recognises as a single import, where the files are part of the same collection.
E.g. A deltavision file + log file, or Leica fileset consisting of multiple tiffs + image.lei file.

If there are additional unrelated files that are not part of the first Fileset that BioFormats recognises, they will be uploaded by the code above and stored on the server, but ignored by the import (won't show up as separate images).

I don't know if there's a way to group a collection of files into separate filesets, but probably not since BioFormats functionality is really server-side in this case.
So you'd have to know somehow, which files to include in each fileset when you do the upload & import.

Hope that helps,

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

Re: Import images using the Gateway

Postby wmoore » Fri Dec 01, 2017 10:17 am

Josh,

I guess we should consider making this code available in the BlitzGateway or similar place, instead of only in testlib, where it can't really be used for real import.

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

Re: Import images using the Gateway

Postby jmoore » Fri Dec 01, 2017 11:11 am

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


Return to Developer Discussion

Who is online

Users browsing this forum: No registered users and 0 guests