-
Notifications
You must be signed in to change notification settings - Fork 21
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
investigate dropping ome-zarr dependency #123
base: main
Are you sure you want to change the base?
investigate dropping ome-zarr dependency #123
Conversation
As discussed with @joshmoore this morning, I looked into whether https://github.com/BioImageTools/ome-zarr-models-py could perform some of the graph traversal logic in this PR, e.g. multiscales -> labels or bioformats2raw -> multiscales (not yet done in this PR). But I don't see any of that functionality in ome-zarr-models.py? |
I had a quick look at the diff, but didn't quite understand what the required logic is. Could you explain a bit more? (or maybe add some short docstrings to the new classes/methods?) We are generally 👍 on adding helpful functionality to ome-zarr-models-py, and I'm going to be sprinting to a first release tomorrow actually, so now is a good time to request stuff 😄 |
def matches(group: Group) -> bool: | ||
return "multiscales" in Spec.get_attrs(group) | ||
|
||
def children(self): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@dstansby By "graph traversal" logic, I mean, if I start with multiscales group e.g. group = zarr.open("https://uk1s3.embassy.ebi.ac.uk/idr/zarr/v0.4/idr0062A/6001240.zarr")
I then want to get the labels (if they exist). Here this is implemented in the children()
method, where we know to look in a child "labels" group and check attrs for "labels": ["labels1.zarr", "labels2.zarr"]
then return objects for those child labels so that the arrays (and metadata) can be added to the layers that are passed to napari.
I don't see that ome-zarr-models-py includes that kind of logic for traversing the graph between these objects?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can get the list of labels paths from Image.attributes.labels
. But the labels part of the spec just says these point to "labels objects", which I don't think are more specifically defined anywhere else?
If the OME-Zarr spec was more prescriptive about what these "labels objects" were (are they meant to be groups with image-label metadata ??) then we could certainly do more, but I don't think the spec allows us to make those assumptions unfortunately.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am only now reading version 0.5 of OME-zarr, and see that the labels section is much improved over 0.4 😄 . It's definitely within scope of ome-zarr-models-py
to provide logic for getting from an Image dataset to the labels dataset if it's in the metadata. Tracking issue at BioImageTools/ome-zarr-models-py#92
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Currently in the tutorial at https://github.com/BioImageTools/ome-zarr-models-py/blob/main/docs/tutorial.py
If I add:
print(ome_zarr_image.attributes.labels)
I get None
(even though that image does have labels).
I don't see any population of the labels in https://github.com/BioImageTools/ome-zarr-models-py/blob/7659a114a2428fe9d8acbd06aa7bc1c9d32624bb/src/ome_zarr_models/v04/image.py#L85 ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
even though that image does have labels
There's a labels group, but looking at that dataset in the validator the top level group is missing the labels metadata, which is why .labels is giving None.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The image group doesn't have labels metadata though, so ome-zarr-models-py has no way to find a way from the image group to the labels group.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To be precise, if you look at the image group in the validator, it should have a "labels" key at the same level as the "multiscales" and "omero" keys. If that was there, the paths under the "labels" key would be in the .labels attribute in ome-zarr-models-py
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh hold on, am I just reading the spec wrong? Does:
The special group "labels" found under an image Zarr
Really mean:
The special Zarr group "labels" found inside an image Zarr group
?
If so then we should definitely implement that in ome-zarr-models-py!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, image.zarr/labels/
group.
This is shown a bit more clearly in the layout at https://ngff.openmicroscopy.org/0.4/index.html#image-layout
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Gotcha, I always thought the "labels" group was an arbitrary name and the example was just an example 🤦 - thanks for explaining, and I'll let you know once I've implemented this in ome-zarr-models-py 😄
One issue I'm having with supporting E.g. I'm trying something like:
but I want to avoid using async In https://github.com/ome/ome-zarr-py/pull/174/files it looks like this only handles local OME.xml files with |
Then that would have been a bug. I assume a method like |
Seems this works for getting XML, but need to check if there's a better way that doesn't use testing classes...
|
Better to just use the SyncMixing for now: https://github.com/zarr-developers/zarr-python/blob/4455726a0dbdeebb00d146b3b7a4bfa4e63374b5/src/zarr/core/sync.py#L181 |
Investigating a lighter-weight alternative to ome-zarr-py.
Work in progress...
Not looking to fully replace ome-zarr-py yet, but just investigating what an alternative could look like to inform discussions.
Pros:
Currently handles channels metadata and labels. Testing with: