Ome_zarr: label segmentation independent of image group

I have a multiscale zarr group of labels and would like to make use of the omero-ms-zarr “labels” metadata to easily load the group into napari for viewing.

Looking at the spec, it seems like labels must live within the zarr group of the image the segmentation belongs to, but I would like, if possible to be able to load the labels independently of the source image.

Is this possible given the current metadata spec?

I’ve tried adding zattrs and zgroup metadata to the label group:

{
    "multiscales": [
        {
            "datasets": [
                {
                    "path": "0"
                },
                {
                    "path": "1"
                },
                {
                    "path": "2"
                },
                {
                    "path": "3"
                }
            ],
            "version": "0.1"
        }
    ],
    "image-label": {
        "version": "0.1",
        "colors": [
            {
                "label-value": 1,
                "rgba": [
                    255,
                    100,
                    100,
                    1
                ]
            },
            {
                "label-value": 2,
                "rgba": [
                    0,
                    40,
                    200,
                    1
                ]
            },
         ...
        ]
    }
}

However, this seems insufficient for the ome_zarr napari plugin, as we open a grayscale image layer instead of a labels layer with the associated colours.

My questions are:

  1. Is it possible to use the napari ome_zarr plugin to open a multiscale zarr group of labels independently of the source image?
  2. If so, what is the minimal directory structure and metadata required for this to work (e.g. it can work but you must follow the tree structure in the spec even if your image directories are empty)?
  3. If not, is this something that could be enabled in the future, and where is the right place to have that discussion?

I have attached an example labels image with the metadata I used.
LabelsExample.zip (13.1 MB)

1 Like

Hi @DragaDoncila. Welcome to image.sc :wink:

A couple of things in no particular order:

  • Storing labels under the “${image}/labels” group is largely for discovery purposes. We haven’t (yet) dealt with the “how do I discover everything in a zarr?” issue.
  • That being said, it is permissible for the image-label objects to exist elsewhere.
  • That doesn’t mean that the implementation yet knows how to do anything with that.

Hmm… locally this works for me though I do get a warning for the missing image data:

ome_zarr info LabelsExample.zarr/
WARNING:ome_zarr.reader:no parent found for <ome_zarr.reader.Label object at 0x7fe7e005a1d0>: None
/private/tmp/LabelsExample.zarr [zgroup]
 - metadata
   - Label
   - Multiscales
 - data
   - (1, 1, 1, 10980, 10980)
   - (1, 1, 1, 5490, 5490)
   - (1, 1, 1, 2745, 2745)
   - (1, 1, 1, 1373, 1373)

I don’t think so. The directory layout in omero-ms-zarr has an additional aspect which is IDR-specific beyond the individual specs like Multi-scale image labels v0.1

If it’s not working, definitely :+1: for making it work. (Additionally, PRs against ome-zarr-py more than welcome) and image.sc is the perfect place to discuss it!

All the best,
~Josh

2 Likes

Thanks for the detailed reply, @joshmoore - it’s much appreciated.

I’ve loaded my labels as well now! It worked perfectly once I actually remembered to update ome_zarr… :woman_facepalming:

1 Like