ome / napari-ome-zarr

A napari plugin for zarr backed OME-NGFF images
https://www.napari-hub.org/plugins/napari-ome-zarr
BSD 3-Clause "New" or "Revised" License
27 stars 21 forks source link

OME-XML metadata support #47

Open joshmoore opened 2 years ago

joshmoore commented 2 years ago

NB: currently built on top of #42

Make use of metadata parsed via https://github.com/ome/ome-zarr-metadata for enriching the images in napari.

codecov-commenter commented 2 years ago

Codecov Report

Base: 92.43% // Head: 91.62% // Decreases project coverage by -0.80% :warning:

Coverage data is based on head (2ec3548) compared to base (d9ff37a). Patch coverage: 71.42% of modified lines in pull request are covered.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #47 +/- ## ========================================== - Coverage 92.43% 91.62% -0.81% ========================================== Files 3 3 Lines 185 191 +6 ========================================== + Hits 171 175 +4 - Misses 14 16 +2 ``` | [Impacted Files](https://codecov.io/gh/ome/napari-ome-zarr/pull/47?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=ome) | Coverage Δ | | |---|---|---| | [napari\_ome\_zarr/\_reader.py](https://codecov.io/gh/ome/napari-ome-zarr/pull/47/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=ome#diff-bmFwYXJpX29tZV96YXJyL19yZWFkZXIucHk=) | `87.50% <71.42%> (-1.28%)` | :arrow_down: | Help us with your feedback. Take ten seconds to tell us [how you rate us](https://about.codecov.io/nps?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=ome). Have a feature suggestion? [Share it here.](https://app.codecov.io/gh/feedback/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=ome)

:umbrella: View full report at Codecov.
:loudspeaker: Do you have feedback about the report comment? Let us know in this issue.

joshmoore commented 2 years ago

:+1: Converted example&series=2.fake loads and has properly named layers:

viewer.open("/opt/ome-zarr-py/bf2raw/fake-series-2.zarr/")
/usr/local/anaconda3/envs/z/lib/python3.9/site-packages/ome_types/_convenience.py:105: FutureWarning: The default XML parser will be changing from 'xmlschema' to 'lxml' in version 0.4.0.  To silence this warning, please provide the `parser` argument, specifying either 'lxml' (to opt into the new behavior), or'xmlschema' (to retain the old behavior).!
Out[4]: 
[<Image layer 'series' at 0x1b43d4f70>,
 <Image layer 'series 2' at 0x1b44abee0>]

:-1: For a converted plate&plates=1&plateRows=1.fake the naming does not get applied and only one image is loaded:

viewer.open("/opt/ome-zarr-py/bf2raw/plate-rows-2.zarr/")
/usr/local/anaconda3/envs/z/lib/python3.9/site-packages/ome_types/_convenience.py:105: FutureWarning: The default XML parser will be changing from 'xmlschema' to 'lxml' in version 0.4.0.  To silence this warning, please provide the `parser` argument, specifying either 'lxml' (to opt into the new behavior), or'xmlschema' (to retain the old behavior).!
Out[5]: [<Image layer 'unnamed' at 0x1b5336b50>]

viewer.open("/opt/ome-zarr-py/bf2raw/plate-no-bf2raw.zarr/")
Out[6]: [<Image layer 'unnamed [1]' at 0x1b4384dc0>]

Additionally: only loading from the internal console works. Loading from the command line with napari ...zarr hangs :warning:

joshmoore commented 2 years ago

Ah, the lack of plate loading is apparently the ome-types validation issue:

Traceback (most recent call last):
  File "/usr/local/anaconda3/envs/z/lib/python3.9/site-packages/ome_zarr/bioformats2raw.py", line 33, in __init__
    data = self.handle(node)
  File "/usr/local/anaconda3/envs/z/lib/python3.9/site-packages/ome_zarr/bioformats2raw.py", line 98, in handle
    return self.parse_xml(metadata)
  File "/usr/local/anaconda3/envs/z/lib/python3.9/site-packages/ome_zarr/bioformats2raw.py", line 92, in parse_xml
    return ome_types.from_xml(t.name)
  File "/usr/local/anaconda3/envs/z/lib/python3.9/site-packages/ome_types/_convenience.py", line 106, in from_xml
    return OME(**d)
  File "/usr/local/anaconda3/envs/z/lib/python3.9/site-packages/ome_types/model/ome.py", line 137, in __init__
    super().__init__(**data)
  File "/usr/local/anaconda3/envs/z/lib/python3.9/site-packages/ome_types/_base_type.py", line 80, in __init__
    super().__init__(**data)
  File "pydantic/main.py", line 331, in pydantic.main.BaseModel.__init__
pydantic.error_wrappers.ValidationError: 2 validation errors for OME
images -> 0 -> pixels -> planes -> 0 -> hash_sha1
  ensure this value has at most 20 characters (type=value_error.any_str.max_length; limit_value=20)
images -> 1 -> pixels -> planes -> 0 -> hash_sha1
  ensure this value has at most 20 characters (type=value_error.any_str.max_length; limit_value=20)
imagesc-bot commented 1 year ago

This pull request has been mentioned on Image.sc Forum. There might be relevant details there:

https://forum.image.sc/t/saving-volumetric-data-with-voxel-size-colormap-annotations/85537/24