ome / ngff

Next-generation file format (NGFF) specifications for storing bioimaging data in the cloud.
https://ngff.openmicroscopy.org
Other
111 stars 38 forks source link

Interpreting OME Zarr data #163

Open aliaksei-chareshneu opened 1 year ago

aliaksei-chareshneu commented 1 year ago

Dear all,

I would like to ask you help in interpreting the OME Zarr data of this dataset: https://uk1s3.embassy.ebi.ac.uk/idr/zarr/v0.4/idr0062A/6001240.zarr (https://hms-dbmi.github.io/vizarr/?source=https://uk1s3.embassy.ebi.ac.uk/idr/zarr/v0.4/idr0062A/6001240.zarr&viewState={%22zoom%22:0.9973745305931767,%22target%22:[135.5,137.5]})

Do I understand it correctly that in fact, when it comes to segmentation, there are just 2 unique segments: LaminB1 and Dapi, which correspond to 2 image channels?

Also, color of all of 61 labels is the same [128,128,128,128]. What could that mean?

Finally, does this dataset represent volumetric data? While scrolling through slices, it looks like Z dimension may be time, not space (objects seem to move).

Thank you for any input, Aliaksei

joshmoore commented 1 year ago

there are just 2 unique segments: LaminB1 and Dapi, which correspond to 2 image channels?

I'm unsure what you mean here with "segments" but otherwise, that sounds correct.

The label or segmentation information, as I think of it, is stored in a secondary object:

https://ome.github.io/ome-ngff-validator/?source=https://uk1s3.embassy.ebi.ac.uk/idr/zarr/v0.4/idr0062A/6001240.zarr/labels/0

with the dimensions: (t,c,z,y,x) = (1,236,275,271).

The value of each of those elements ("pixels" if you prefer) represent the unique "object" that has been segmented.

The color representation in the "image-label" metadata is simply for display purposes and doesn't have any further semantic meaning. (e.g. in this case, you can imagine the user wanted all nuclear objects to appear in the same color)

will-moore commented 1 year ago

Hi Aliaksei, - Ah, Josh beat me to it!....

There are 2 image channels (LaminB1 and Dapi), and I believe that the Dapi channel has been used to segment the image to generate labels.

The labels should show up in when you open the image in napari. You can also view them in vizarr if you know that at /6001240.zarr/labels/.zattrs/ is simply {"labels";["0"]} (e.g. see https://ome.github.io/ome-ngff-validator/?source=https://uk1s3.embassy.ebi.ac.uk/idr/zarr/v0.4/idr0062A/6001240.zarr/labels/) which means you can find the labels at https://ome.github.io/ome-ngff-validator/?source=https://uk1s3.embassy.ebi.ac.uk/idr/zarr/v0.4/idr0062A/6001240.zarr/labels/0 and even open this as an OME-NGFF image in vizarr: https://hms-dbmi.github.io/vizarr/?source=https://uk1s3.embassy.ebi.ac.uk/idr/zarr/v0.4/idr0062A/6001240.zarr/labels/0 (you'll need to move the Z-slider before you can see the segmented labels).

The labels is a single-channel image. The labels are not explicitly linked to either of the parent image channels.

aliaksei-chareshneu commented 1 year ago

there are just 2 unique segments: LaminB1 and Dapi, which correspond to 2 image channels?

I'm unsure what you mean here with "segments" but otherwise, that sounds correct.

The label or segmentation information, as I think of it, is stored in a secondary object:

https://ome.github.io/ome-ngff-validator/?source=https://uk1s3.embassy.ebi.ac.uk/idr/zarr/v0.4/idr0062A/6001240.zarr/labels/0

with the dimensions: (t,c,z,y,x) = (1,236,275,271).

The value of each of those elements ("pixels" if you prefer) represent the unique "object" that has been segmented.

The color representation in the "image-label" metadata is simply for display purposes and doesn't have any further semantic meaning. (e.g. in this case, you can imagine the user wanted all nuclear objects to appear in the same color)

Thank you very much. So, there are still 61 unique objects?

aliaksei-chareshneu commented 1 year ago

@will-moore, thank you. Is labels always a single channel image, or just here? Also, how, based on NGFF content (this specific NGFF or any other NGFF), can you tell which channel was used to segment image?

joshmoore commented 1 year ago

Thank you very much. So, there are still 61 unique objects?

Exactly:

$ python test.py
[ 0  1  2  3  4  5  6  7  8  9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47
 48 49 50 51 52 53 54 55 56 57 58 59 60 61]

$ cat test.py
import numpy as np
import zarr as zr
z = zr.open("https://uk1s3.embassy.ebi.ac.uk/idr/zarr/v0.4/idr0062A/6001240.zarr/labels/0/0")
print(np.unique(z[:]))
will-moore commented 1 year ago

I think all the examples we've created have labels as a single channel image (or possibly even with NO channel dimension). The spec doesn't say anything about the dimensionality of the labels image. I think that napari-ome-zarr expects a single channel image for labels.

Hmmm - there is the "source": {} metadata specified for labels (see https://ngff.openmicroscopy.org/latest/#label-md) but this says "it MAY include a key image whose value MUST be a string specifying the relative path to a Zarr image group" so it doesn't point to a particular channel. However, you could add additional metadata to that object for your own usage.

Please feel free to open a new Issue for that, and even better to propose a specification.

aliaksei-chareshneu commented 1 year ago

@joshmoore, thank you.

Could you tell me please if the following is correct?

  1. Pixel values of the image (non-labeled one) itself represent the intensities.
  2. Labeled image shows where one each unique segmented object is located on non-labeled image.

In general, how can one find out what each labeled object actually represents (nucleus, mitochondria etc.)? In 'properties' of label-image dict there are omero:roiId and omero:shapeId - what do they mean?

Also, does this dataset indeed represent volumetric data? While scrolling through slices, it looks like Z dimension may be time, not space (objects seem to move).

aliaksei-chareshneu commented 1 year ago

Also, am I right that order of channels in "omero" metadata correspond to the order of channels in array of labelled image (i.e. 0th 3D subarray is for LaminB1, 1th 3D subarray is for Dapi)?

will-moore commented 1 year ago

Yes, 1 & 2 are correct.

There is the option of giving names to labels. E.g. This image has labels for "Cell" and "Chromosomes" - see labels/.zattrs at https://ome.github.io/ome-ngff-validator/?source=https://uk1s3.embassy.ebi.ac.uk/idr/zarr/v0.4/idr0052A/5514375.zarr/labels

The omero:roiId and omero:shapeId are really just examples of how to store custom values for a label. In this case they are the IDs of the Shapes and ROIs (collection of shapes) in IDR where this Image was exported from (see ROIs tab at https://idr.openmicroscopy.org/webclient/img_detail/6001240/).

You can see a 3D volume view of this image (not labels) at https://kitware.github.io/itk-vtk-viewer/app/?rotate=false&fileToLoad=https://uk1s3.embassy.ebi.ac.uk/idr/zarr/v0.4/idr0062A/6001240.zarr which you should find more convincing?

And yes, the order of channels in omero metadata corresponds to the order of channels in the image (but as mentioned above the labels tend not to be multi-channel in the examples created so far).

aliaksei-chareshneu commented 1 year ago

@will-moore, thank you very much. So, if names to labels have not been given (as in the case of https://uk1s3.embassy.ebi.ac.uk/idr/zarr/v0.4/idr0062A/6001240.zarr), there is no way to determine (based solely on the OME Zarr data) exactly what each segmented object actually represents (nucleus, mitochondria etc.)?

will-moore commented 1 year ago

Apologies - I failed to respond earlier... That is correct. The spec doesn't enforce you to define what labels represent.