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

Not parsing "multiscales" metadata if "omero" metadata is missing #270

Open
yuriyzubov opened this issue Feb 10, 2025 · 1 comment
Open
Labels
bug Something isn't working NGFF OME-NGFF (OME-Zarr format)
Milestone

Comments

@yuriyzubov
Copy link

Hello!
The official OME-NGFF spec states that omero metadata is optional.

When I try to open a zarr group that contains multi-scale image pyramid with iohub.open_ome_zarr() method, with the following .zattrs metadata:

 "multiscales": [
       {
         "name": "ds_1",
         "version": "0.4",
         "axes": [
           { "name": "z", "type": "space", "unit": "micrometer" },
           { "name": "y", "type": "space", "unit": "micrometer" },
           { "name": "x", "type": "space", "unit": "micrometer" }
         ],
         "datasets": [
           {
             "path": "s0",
             "coordinateTransformations": [
               {
                 "type": "scale",
                 "scale": [0.5, 0.5, 0.5]
               }
             ]
           }
         ]
       }
     ]

It invokes the warning method, since the omero metadata is missing, but self.metadata.multiscales remains empty as well.

Perhaps it is better to make the omero field optional in the definition of ImagesMeta?

class ImagesMeta(MetaBase):
    """Metadata needed for 'Images' (or positions/FOVs) in an OME-NGFF dataset.
    https://ngff.openmicroscopy.org/0.4/index.html#image-layout"""

    multiscales: list[MultiScaleMeta]
    omero: Optional[OMEROMeta] = None

And rewrite _parse_meta() method?

def _parse_meta(self):
    multiscales = self.zattrs.get("multiscales")
    omero = self.zattrs.get("omero")
    if multiscales:
        try:
            self.metadata = ImagesMeta(
                multiscales=multiscales, omero=omero
            )
            self.axes = self.metadata.multiscales[0].axes
            if omero:
                self._channel_names = [
                    c.label for c in self.metadata.omero.channels
                ]
        except ValidationError:
            self._warn_invalid_meta()
    else:
        self._warn_invalid_meta()

so the multiscales metadata is parsed properly, even when the omero attribute is missing.

@yuriyzubov yuriyzubov changed the title Not opening zarr array if "omero" metadata is missing. Not parsing "multiscales" metadata if "omero" metadata is missing Feb 10, 2025
@ziw-liu ziw-liu added bug Something isn't working NGFF OME-NGFF (OME-Zarr format) labels Feb 11, 2025
@ziw-liu
Copy link
Collaborator

ziw-liu commented Feb 11, 2025

@yuriyzubov Thanks for reporting this bug! Would you want to turn your code snippets into a PR?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working NGFF OME-NGFF (OME-Zarr format)
Projects
None yet
Development

No branches or pull requests

2 participants