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 😄 |
napari_ome_zarr/ome_zarr_reader.py
Outdated
| def matches(group: Group) -> bool: | ||
| return "multiscales" in Spec.get_attrs(group) | ||
|
|
||
| def children(self): |
There was a problem hiding this comment.
@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.
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.
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 ome-zarr-models/ome-zarr-models-py#92
There was a problem hiding this comment.
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.
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.
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.
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.
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.
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 😄
There was a problem hiding this comment.
Thanks, ome-zarr-models/ome-zarr-models-py#96 looks good
|
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 |
|
Thanks, this is working... |
bc3d71a to
e4cda75
Compare
|
If we wanted to use ome-zarr-models-py to handle some of the graph traversal (e.g. labels), this would now look like this: |
|
@joshmoore I'll stop working on this for now, as I think there's enough here to evaluate this approach. |
|
To chip in from |
920d9cf to
dd63922
Compare
e908d7a to
a92c2a1
Compare
b8758ad to
e338190
Compare
a8ffede to
e34c881
Compare
|
@jluethi - Apologies: just tested the Plate with Labels above and some minor bug since the previous screenshot - looking to fix now...
|
|
OK @jluethi - PlateLabels fixed now, at least for the test data I have. |
|
Oh, that's exciting! Thanks for the tag Will, will try to test this next week! |
| @@ -0,0 +1,409 @@ | |||
| # zarr v3 | |||
There was a problem hiding this comment.
No, I don't see any other files in this repo having a header, same for ome-zarr-py.
|
Hi @will-moore , just went through this in a superficial manner. What's implemented here is exactly the kind of API that I (personally) think is missing over at ome-zarr-py, i.e. exposing the data from ome.zarr files through some sort of object-oriented logic. In this case it makes it easy for napari to grab the data to be viewed from Do you think it would be possible to move this upstream into ome-zarr-py? This would also allow ome-zarr-py to expose some of the cool tools of ome-zarr-models-py through its own API and keep naparei-ome-zarr really lightweight. Edit: typo |
|
@jo-mueller Those What we do with them at ome-zarr-py can be discussed next week |
|
@will-moore thanks for the pointer, definitely helpful to get on the same page until then. I think what's confusing (at least to me) about the I guess my idea (for ome-zarr-py) but also for the changes here would be:
I'd have some other ideas particularly for the Plate structure (maybe a getter à la |
|
Thanks @jo-mueller - All good points to discuss next week... |
adf6093 to
ba7e50f
Compare
|
@jo-mueller I guess we need to revive this discussion... This PR fixes a bunch of issues and I'm adding all the RFC5 / v0.6 stuff on top of it, so it would be nice to get merged. Maybe discuss at next week's Tuesday call? |
|
Hey @will-moore thanks for the ping. Totally agree! Personally I was hoping to
I'm relatively confident that I can get the development at ome/ome-zarr-py#515 into a presentable state by then 🤞 |
|
(I assume the title of this PR can be updated now? 😄 ) |

Investigating a lighter-weight alternative to ome-zarr-py.
Uses zarrv3.
This includes the functionality from un-merged Plate Labels Fix (ome/ome-zarr-py#207 with #54).
Also includes the handling of
bioformats2raw, similar to behaviour from un-merged ome/ome-zarr-py#174Pros:
Cons:
napari-ome-zarrandome-zarr-pyThe PR handles bioformats2raw, channels metadata, labels, plates and plates with labels. Testing with:
TODO: