Skip to main content
https://github.com/ome/omero-cli-zarr/workflows/Precommit/badge.svg https://badge.fury.io/py/omero-cli-zarr.svg

OMERO CLI Zarr plugin

This OMERO command-line plugin allows you to import and export Images and ROIs from OME-Zarr format into OMERO and vice versa.

Import

NB: This feature currently works only with OME-Zarr files hosted on public object stores OR a local filesystem accessible to the OMERO server.

The import process is similar to an “in-place” import; It does not move the data into OMERO. Instead the data is accessed via the omero-zarr-pixel-buffer, which must be installed on the OMERO server.

Images are created in OMERO and the link to the OME-Zarr data is stored in the ExternalInfo of the Image. Images are created in one of two ways:

  • If the OME-Zarr data is in the bioformats2raw layout, which includes an OME/METADATA.ome.xml file, then this file is copied to the the server and imported to create a Fileset and one or more Images. This preserves all of the OME metadata in the xml file.

  • Otherwise, Images are created via the OMERO API, using the metadata in the OME-Zarr files.

Export

This feature supports export of any regular Images and Plates from OMERO into the OME-Zarr format, according to the spec at https://ngff.openmicroscopy.org/0.4/index.html as well as Masks and Polygons on the Images.

Images are exported as nD arrays of shape, up to (t, c, z, y, x). Plates are a hierarchy of plate/row/column/field(image). Masks in OMERO are 2D bitmasks which can exist on multiple planes of an Image. Polygons are 2D shapes defined by a set of vertices. In both cases, they are exported as OME-Zarr labels, with Polygons being converted to bitmasks during export.

Export is supported using 2 alternative methods:

  • By default the OMERO API is used to load planes as numpy arrays and the zarr file is created from this data.

  • Alternatively, if you can read directly from the OMERO binary repository and have installed https://github.com/glencoesoftware/bioformats2raw then you can use this to create zarr files.

Usage

Import OME-Zarr files

To import a public OME-Zarr data into OMERO, use the import command:

$ omero zarr import https://example.com/path/to/file.ome.zarr

# Use --target DATASET_ID to import into a Dataset
$ omero zarr import https://example.com/path/to/file.ome.zarr --target 1234

# Or import local data which must be accessible to the OMERO server
$ omero zarr import /path/to/file.ome.zarr

Export Images and Plates

To export Images or Plates via the OMERO API:

# Image will be saved in current directory as 1.ome.zarr
$ omero zarr export Image:1

# Plate will be saved in current directory as 2.ome.zarr
$ omero zarr export Plate:2

# Specify the OME-Zarr format, e.g. 0.4. Default is 0.5
$ omero zarr --format 0.4 export Image:1

# Use the Image or Plate 'name' to save e.g. my_image.ome.zarr
$ omero zarr --name_by name export Image:1

# Specify an output directory
$ omero zarr --output /home/user/zarr_files export Image:1

# By default, a tile (chunk) size of 1024 is used. Specify values with
$ omero zarr export Image:1 --tile_width 256 --tile_height 256

NB: If the connection to OMERO is lost and the Image or Plate is partially exported, re-running the command will attempt to complete the export.

To export images via bioformats2raw we use the `--bf` flag:

export MANAGED_REPO=/var/omero/data/ManagedRepository
export BF2RAW=/opt/tools/bioformats2raw-0.2.0-SNAPSHOT

$ omero zarr --output /home/user/zarr_files export 1 --bf
Image exported to /home/user/zarr_files/2chZT.lsm

Export Masks and Polygons

To export Masks or Polygons for an Image or Plate, use the masks or polygons command:

# Saved under 1.ome.zarr/labels/0
# 1.ome.zarr/ should already exist...
$ omero zarr masks Image:1

# ...or specify path with --source-image
$ omero zarr masks Image:1 --source-image my_image.ome.zarr

# Labels saved under each image. e.g 2.ome.zarr/A/1/0/labels/0
# 2.ome.zarr should already be exported or specify path with --source-image
$ omero zarr masks Plate:2

# Saved under zarr_files/1.ome.zarr/labels/0
$ omero zarr --output /home/user/zarr_files masks Image:1

# Specify the label-name. (default is '0')
# e.g. Export to 1.ome.zarr/labels/A
$ omero zarr masks Image:1 --label-name=A

# Allow overlapping masks or polygons (overlap will be maximum value of the dtype)
$ omero zarr polygons Image:1 --overlaps=dtype_max

The default behaviour is to export all masks or polygons on the Image to a single nD “labeled” zarr array, with a different value for each Shape. An exception will be thrown if any of the masks overlap, unless the –overlaps option is used as above.

An alternative to handle overlapping masks is to split masks into non-overlapping zarr groups using a “label-map” which is a csv file that specifies the name of the zarr group for each ROI on the Image. Columns are ID, NAME, ROI_ID.

For example, to create a group from the textValue of each Shape, you can use this command:

omero hql --style=plain "select distinct s.textValue, s.roi.id from Shape s where s.roi.image.id = 5514375" --limit=-1 | tee 5514375.rois

This creates a file 5514375.rois like this:

0,Cell,1369132
1,Cell,1369134
2,Cell,1369136
...
40,Chromosomes,1369131
41,Chromosomes,1369133
42,Chromosomes,1369135
...

This will create zarr groups of Cell and Chromosomes under 5514375.zarr/labels/:

$ omero zarr masks Image:5514375 --label-map=5514375.rois

License

This project, similar to many Open Microscopy Environment (OME) projects, is licensed under the terms of the GNU General Public License (GPL) v2 or later.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

omero_cli_zarr-0.9.0.tar.gz (40.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

omero_cli_zarr-0.9.0-py3-none-any.whl (39.3 kB view details)

Uploaded Python 3

File details

Details for the file omero_cli_zarr-0.9.0.tar.gz.

File metadata

  • Download URL: omero_cli_zarr-0.9.0.tar.gz
  • Upload date:
  • Size: 40.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for omero_cli_zarr-0.9.0.tar.gz
Algorithm Hash digest
SHA256 d5a6d14537395333a2415afe471d235998e0fa98ccf7afb5948936244909ab11
MD5 818b0bc414106b4626b921bd77b4cbd2
BLAKE2b-256 ba9d82f242da9f6df4c91390b785199e37c7e10341aa016485a25124b5931065

See more details on using hashes here.

File details

Details for the file omero_cli_zarr-0.9.0-py3-none-any.whl.

File metadata

  • Download URL: omero_cli_zarr-0.9.0-py3-none-any.whl
  • Upload date:
  • Size: 39.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for omero_cli_zarr-0.9.0-py3-none-any.whl
Algorithm Hash digest
SHA256 1425442b7878af3018c551838850a919f47a51f9c2a239ad992c0671f40466cf
MD5 998faa0178d5476992c3d4cb951a0eaa
BLAKE2b-256 d9123f70b728a461128a81ce563b9a7ca24af8c7f17f25ed5fd70b98d9a831a6

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

0.9.0 This release

2 files

0.8.0

2 files

0.7.0

2 files

0.6.1

2 files

0.6.0

2 files

0.5.5

2 files

0.5.4

2 files

0.5.3

2 files

0.5.2

2 files

0.5.1

2 files

0.5.0

2 files

0.4.0

2 files

0.3.0

2 files

0.2.1

2 files

0.2.0

2 files

0.1.0

2 files

0.0.10

2 files

0.0.9

2 files

0.0.8

2 files

0.0.7

2 files

0.0.6

2 files

0.0.5

2 files

0.0.4

2 files

0.0.3

2 files

0.0.2

2 files

0.0.1

1 file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page