Skip to content
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

OME-XML metadata support #47

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft

OME-XML metadata support #47

wants to merge 2 commits into from

Conversation

joshmoore
Copy link
Member

@joshmoore joshmoore commented May 4, 2022

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.

TODO:

@joshmoore joshmoore marked this pull request as draft May 4, 2022 09:14
@codecov-commenter
Copy link

codecov-commenter commented May 4, 2022

Codecov Report

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

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
@@            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 Coverage Δ
napari_ome_zarr/_reader.py 87.50% <71.42%> (-1.28%) ⬇️

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

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

@joshmoore
Copy link
Member Author

joshmoore commented Sep 15, 2022

👍 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>]

👎 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 ⚠️

@joshmoore
Copy link
Member Author

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)

joshmoore added a commit to joshmoore/ome-types that referenced this pull request Sep 15, 2022
While trying to get the `bioformats2raw.layout` specification
(ome/ngff#112) this raised its head
again. Following the discussion in ome/ome-model#158
changing the size checks to `40` passes.

fix: ome/bioformats#3810
fix: ome/napari-ome-zarr#47 (comment)
@@ -132,7 +133,19 @@ def f(*args: Any, **kwargs: Any) -> List[LayerData]:
data = [
np.squeeze(level, axis=channel_axis) for level in node.data
]
metadata["name"] = [
metadata.get("name", "unnamed") for x in range(3)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is range(3) hard-coded for a 3-channel image?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good question. I assume that's what that was about, yes.

tlambert03 pushed a commit to tlambert03/ome-types that referenced this pull request Sep 16, 2022
* Update Hex40 definition

While trying to get the `bioformats2raw.layout` specification
(ome/ngff#112) this raised its head
again. Following the discussion in ome/ome-model#158
changing the size checks to `40` passes.

fix: ome/bioformats#3810
fix: ome/napari-ome-zarr#47 (comment)

* Bump to min_length=40
@imagesc-bot
Copy link

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

@imagesc-bot
Copy link

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

https://forum.image.sc/t/constructing-zarr-for-napari-ome-zarr/65398/4

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

Successfully merging this pull request may close these issues.

4 participants