Skip to content

Wrong window metadata in projected image? #941

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
tcompa opened this issue Apr 17, 2025 · 5 comments · Fixed by #943
Closed

Wrong window metadata in projected image? #941

tcompa opened this issue Apr 17, 2025 · 5 comments · Fixed by #943

Comments

@tcompa
Copy link
Collaborator

tcompa commented Apr 17, 2025

See also https://github.com/fractal-analytics-platform/fractal-deployments/issues/116#issuecomment-2812444135.

I have these two plates:

18M	./20200812-CardiomyocyteDifferentiation14-Cycle1_mip.zarr
35M	./20200812-CardiomyocyteDifferentiation14-Cycle1.zarr

created with v1.5.0a2.

I ran

$ pip install "napari[all]" "napari-ome-zarr"

And then

$ napari --plugin napari-ome-zarr ./20200812-CardiomyocyteDifferentiation14-Cycle1.zarr/
$ napari --plugin napari-ome-zarr ./20200812-CardiomyocyteDifferentiation14-Cycle1_mip.zarr/

3D image

Image

2D image

Image

Here are the napari --verbose outputs.

3D image

napari --plugin napari-ome-zarr ./20200812-CardiomyocyteDifferentiation14-Cycle1.zarr/ --verbose
12:35:50 : INFO : MainThread : root_attr: plate
12:35:50 : INFO : MainThread : plate_data: {'acquisitions': [{'id': 0, 'name': '20200812-CardiomyocyteDifferentiation14-Cycle1'}], 'columns': [{'name': '03'}], 'rows': [{'name': 'B'}], 'version': '0.4', 'wells': [{'columnIndex': 0, 'path': 'B/03', 'rowIndex': 0}]}
12:35:50 : INFO : MainThread : root_attr: well
12:35:50 : INFO : MainThread : well_data: {'images': [{'path': '0'}], 'version': '0.4'}
12:35:50 : INFO : MainThread : root_attr: multiscales
12:35:50 : INFO : MainThread : root_attr: omero
12:35:50 : INFO : MainThread : datasets [{'coordinateTransformations': [{'scale': [1, 1.0, 0.1625, 0.1625], 'type': 'scale'}], 'path': '0'}, {'coordinateTransformations': [{'scale': [1, 1.0, 0.325, 0.325], 'type': 'scale'}], 'path': '1'}, {'coordinateTransformations': [{'scale': [1, 1.0, 0.65, 0.65], 'type': 'scale'}], 'path': '2'}, {'coordinateTransformations': [{'scale': [1, 1.0, 1.3, 1.3], 'type': 'scale'}], 'path': '3'}, {'coordinateTransformations': [{'scale': [1, 1.0, 2.6, 2.6], 'type': 'scale'}], 'path': '4'}]
12:35:50 : INFO : MainThread : resolution: 0
12:35:50 : INFO : MainThread :  - shape ('c', 'z', 'y', 'x') = (1, 2, 2160, 5120)
12:35:50 : INFO : MainThread :  - chunks =  ['1', '2', '2160', '2560']
12:35:50 : INFO : MainThread :  - dtype = uint16
12:35:50 : INFO : MainThread : resolution: 1
12:35:50 : INFO : MainThread :  - shape ('c', 'z', 'y', 'x') = (1, 2, 1080, 2560)
12:35:50 : INFO : MainThread :  - chunks =  ['1', '2', '1080', '2560']
12:35:50 : INFO : MainThread :  - dtype = uint16
12:35:50 : INFO : MainThread : resolution: 2
12:35:50 : INFO : MainThread :  - shape ('c', 'z', 'y', 'x') = (1, 2, 540, 1280)
12:35:50 : INFO : MainThread :  - chunks =  ['1', '2', '540', '1280']
12:35:50 : INFO : MainThread :  - dtype = uint16
12:35:50 : INFO : MainThread : resolution: 3
12:35:50 : INFO : MainThread :  - shape ('c', 'z', 'y', 'x') = (1, 2, 270, 640)
12:35:50 : INFO : MainThread :  - chunks =  ['1', '2', '270', '640']
12:35:50 : INFO : MainThread :  - dtype = uint16
12:35:50 : INFO : MainThread : resolution: 4
12:35:50 : INFO : MainThread :  - shape ('c', 'z', 'y', 'x') = (1, 2, 135, 320)
12:35:50 : INFO : MainThread :  - chunks =  ['1', '2', '135', '320']
12:35:50 : INFO : MainThread :  - dtype = uint16
12:35:50 : INFO : MainThread : root_attr: multiscales
12:35:50 : INFO : MainThread : root_attr: omero

2D image:

12:36:01 : INFO : MainThread : root_attr: plate
12:36:01 : INFO : MainThread : plate_data: {'acquisitions': [{'id': 0, 'name': '20200812-CardiomyocyteDifferentiation14-Cycle1'}], 'columns': [{'name': '03'}], 'rows': [{'name': 'B'}], 'version': '0.4', 'wells': [{'columnIndex': 0, 'path': 'B/03', 'rowIndex': 0}]}
12:36:01 : INFO : MainThread : root_attr: well
12:36:01 : INFO : MainThread : well_data: {'images': [{'path': '0'}], 'version': '0.4'}
12:36:01 : INFO : MainThread : root_attr: multiscales
12:36:01 : INFO : MainThread : root_attr: omero
12:36:01 : INFO : MainThread : datasets [{'coordinateTransformations': [{'scale': [1.0, 1.0, 0.1625, 0.1625], 'type': 'scale'}], 'path': '0'}, {'coordinateTransformations': [{'scale': [1.0, 1.0, 0.325, 0.325], 'type': 'scale'}], 'path': '1'}, {'coordinateTransformations': [{'scale': [1.0, 1.0, 0.65, 0.65], 'type': 'scale'}], 'path': '2'}, {'coordinateTransformations': [{'scale': [1.0, 1.0, 1.3, 1.3], 'type': 'scale'}], 'path': '3'}, {'coordinateTransformations': [{'scale': [1.0, 1.0, 2.6, 2.6], 'type': 'scale'}], 'path': '4'}]
12:36:01 : INFO : MainThread : resolution: 0
12:36:01 : INFO : MainThread :  - shape ('c', 'z', 'y', 'x') = (1, 1, 2160, 5120)
12:36:01 : INFO : MainThread :  - chunks =  ['1', '1', '2160', '2560']
12:36:01 : INFO : MainThread :  - dtype = uint16
12:36:01 : INFO : MainThread : resolution: 1
12:36:01 : INFO : MainThread :  - shape ('c', 'z', 'y', 'x') = (1, 1, 1080, 2560)
12:36:01 : INFO : MainThread :  - chunks =  ['1', '1', '1080', '2560']
12:36:01 : INFO : MainThread :  - dtype = uint16
12:36:01 : INFO : MainThread : resolution: 2
12:36:01 : INFO : MainThread :  - shape ('c', 'z', 'y', 'x') = (1, 1, 540, 1280)
12:36:01 : INFO : MainThread :  - chunks =  ['1', '1', '540', '1280']
12:36:01 : INFO : MainThread :  - dtype = uint16
12:36:01 : INFO : MainThread : resolution: 3
12:36:01 : INFO : MainThread :  - shape ('c', 'z', 'y', 'x') = (1, 1, 270, 640)
12:36:01 : INFO : MainThread :  - chunks =  ['1', '1', '270', '640']
12:36:01 : INFO : MainThread :  - dtype = uint16
12:36:01 : INFO : MainThread : resolution: 4
12:36:01 : INFO : MainThread :  - shape ('c', 'z', 'y', 'x') = (1, 1, 135, 320)
12:36:01 : INFO : MainThread :  - chunks =  ['1', '1', '135', '320']
12:36:01 : INFO : MainThread :  - dtype = uint16
12:36:01 : INFO : MainThread : root_attr: multiscales
12:36:01 : INFO : MainThread : root_attr: omero

And here is the diff of the image zattrs:

30c30
<                                 1,
---
>                                 1.0,
44c44
<                                 1,
---
>                                 1.0,
58c58
<                                 1,
---
>                                 1.0,
72c72
<                                 1,
---
>                                 1.0,
86c86
<                                 1,
---
>                                 1.0,
96a97
>             "name": "MIP",
108,111c109,112
<                     "end": 800,
<                     "max": 65535,
<                     "min": 0,
<                     "start": 110
---
>                     "end": 65535.0,
>                     "max": 65535.0,
>                     "min": 0.0,
>                     "start": 0.0
114,117c115
<         ],
<         "id": 1,
<         "name": "TBD",
<         "version": "0.4"
---
>         ]
@tcompa
Copy link
Collaborator Author

tcompa commented Apr 17, 2025

If I manually edit the 2D-image metadata, and use the same window start/end/min/max as the 3D one, then I see the image correctly.

@tcompa
Copy link
Collaborator Author

tcompa commented Apr 17, 2025

Possibly relevant: Is it expected that in https://github.com/fractal-analytics-platform/ngio/blob/6bf7c0e54b5c4d40a0025075c50389879d174a03/src/ngio/images/image.py#L478 we are not deriving the window property?

@tcompa tcompa changed the title Some issue in viewing a projected image in vizarr/napari Wrong window metadata in projected image? Apr 17, 2025
@jluethi
Copy link
Collaborator

jluethi commented Apr 17, 2025

Not deriving the window property sounds like a bug to me. I think the 2 valid options would be to derive the window property or to recalculate based on percentiles. I'd favor the derive approach.

Setting it to full range will make things appear black on our typical underexposed microscopy images (even though the data in there likely is still correct)

@lorenzocerrone
Copy link
Collaborator

The bug is going to be resolved with an upstream ngio fix.
The fix is already here fractal-analytics-platform/ngio#61 and will be realesed by Tuesday

@tcompa tcompa mentioned this issue Apr 23, 2025
1 task
@tcompa tcompa linked a pull request Apr 23, 2025 that will close this issue
1 task
@tcompa
Copy link
Collaborator Author

tcompa commented Apr 23, 2025

closed with #943

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Development

Successfully merging a pull request may close this issue.

3 participants