CellProfiler / CellProfiler-plugins

Community-contributed and experimental CellProfiler modules.
http://plugins.cellprofiler.org/
54 stars 65 forks source link

Add CellProfiler 5 OMERO plugins #220

Open DavidStirling opened 9 months ago

DavidStirling commented 9 months ago

Resolves cellprofiler/cellprofiler#4684, resolves cellprofiler/cellprofiler#3722, partially addresses cellprofiler/cellprofiler#1772

Todo: Remove legacy OMERO connector from the main CP repo (currently commented out).

Following cellprofiler/core#133, OMERO integration in the main CellProfiler builds is not functional in Cellprofiler 5. Relying on javabridge/bioformats to access OMERO data wasn't ideal in the first place, and so using omero-py is a preferred solution. However, omero-py's dependencies can be tricky to install and, given the new policy towards what should be in the main builds vs what should be a plugin, it perhaps makes more sense for OMERO support to be a plugin going forwards.

Therefore this PR adds and expands upon OMERO support within CellProfiler in the form of plugins. We've taken this opportunity to address some of the longstanding issues with the original integration and add some new features to improve user experience.

Components

omero_helper - These helper scripts manage the connection and GUI components needed by the plugins. These are also responsible for injecting entries into the Plugins menu and managing/safely closing active connections when you exit CellProfiler.

OMEROReader - An image reader plugin which reads image data using the omero-py package.

SaveImagesToOMERO - A module plugin which uploads a CellProfiler image onto an OMERO server.

ExportToOMEROTable - A module plugin designed to upload measurement results directly into an OMERO.table on a server.

OMEROBrowseDlg - An OMERO browser which runs within CellProfiler (wx). This should allow basic server browsing and adding of images to pipelines. Most server traversal is done using the http web api rather than through omero-py/ice, since that API is a bit more refined.

OMERO Browser

Install scripts were included in setup.py under the omero flag. In that setup we've provided some direct links to premade zeroc-ice wheels for platforms which have trouble running the build system for the specific version omero-py needs.

Unit tests are unfortunately not easy to design for these plugins, since user credentials and a persistent, public server would be needed to do any such tests. Automating validation of any test results on OMERO itself would also be a challenge.

Key problems addressed

"Once my session times out I have to restart CellProfiler to reconnect to OMERO" - The login dialog is now available from the new 'Plugins' menu. The connection is also kept active automatically instead of the user needing to perform an operation every 10 minutes.

"Adding OMERO files to the file list is painful and clunky" - While support for the original OMERO URI format (omero:iid=<ImageId>) is maintained, we have added the ability to detect and process full OMERO server urls (e.g. my.omero.server/webclient/?show=image-101). These URLs can be pasted directly into the file list box in the Images module for added convenience. In case that wasn't enough, we've also added an OMERO server browser to the plugins menu, allowing you to select and add images from within CellProfiler. In that dialog images can be added by selecting them individually and using the 'Add' button, or by dragging containers from the browser tree onto the Images module file list.

"Entering login details every run is annoying" - The connection dialog is now more responsive and supports hotkeys such as pressing 'Enter' to connect/close once connected. We've also added support for the omero_user_token package, which can store a long-lived token to automatically reconnect to a previous session. On the connect dialog you'll now find a "Set Token" button to store your credentials as a token. A similar system (token stored in CP's temp directory) is used to pass connection details to workers during an analysis run, so that login details no longer need to be transmitted over the zmq request/reply system.

"Image reading is slow and doesn't work with 3D data" - Loading data no longer occurs via the java bridge or it's replacement, the omero-py-based reader is pure Python and should be more efficient. The new reader also fully supports the metadata extraction features in the Images module, meaning that multi-plane images can be split up by the input modules or loaded as stacks (previous iterations forced loading of the first plane only).

"I have to manually upload results onto OMERO" - Added plugin modules to do just this. Together it should now be possible to read data off OMERO, analyse it and return the results to the server in a single pipeline.