V0.6 Scenes support#157
Conversation
Add CoordinateSystems node for RFC-5
|
Testing with examples from https://forum.image.sc/t/ngff-weekly-dev-update-thread/110810/98 https://ome.github.io/ome-ngff-validator/?source=https://s3.zih.tu-dresden.de/johamuel:rfc5-transform-sanity-checks/logan_shepp_rotation_30_clockwise.ome.zarr
So I don't see napari behaving as described will-moore#4 (comment) @jo-mueller ? |
|
I tried to open the more complex example at https://ome.github.io/ome-ngff-validator/?source=https://radosgw.public.os.wwu.de/s2v/P2A_B6_M2.ome.zarr/ but this failed due to a 403 response instead of a 404 for |
|
If I hard-code the plugin to expect |
The 30° clockwise rotation looks alright to me? 😃
Found the error. In the affine matrix, i wrote the transform in homogeneous coordinates ( @will-moore fixed, should work now |
|
@jo-mueller - not quite there yet! |
|
@will-moore shoot, there were more than one affines in the transforms 🙈 Now I should have fixed them all |
|
@jo-mueller This is looking good at https://ome.github.io/ome-ngff-validator/?source=https://radosgw.public.os.wwu.de/s2v/P2A_B6_M2.ome.zarr/ (thumbnails are working, suggesting a change in the 403 response from the server), but now this has stopped working with napari, even with the |
This reverts commit 67bdef3.
|
@will-moore Do I have write access to your fork? 😨 Oh no, hope I didn't mess it up with my experiments. I think I made a bit of a mess of things will checking out your branch |
|
@will-moore ok, fixed and loading works on my end. There were some trailing commas in the json, which apparently is not a problem for the json decoder used by the ome-ngff-validator, but it is a problem for the python json decoder 🙄 |
|
Fixed-up sample at https://livingobjects.ebi.ac.uk/idr/zarr/test-data/v0.6.dev4/idr0050/4995115_output_to_ms.zarr - see screenshot in description above |
|
Cool stuff @will-moore! How confident are you to merge? Should we add the opening of the above datasets to the tests? Actually, I think this would also be a nicy addition to that sanity testing dataset on image.sc, if you don't mind :) |
|
@jo-mueller I haven't looked at this code in a long while and I think there's a bunch of assumptions and TODOs that I need to check on. |
|
@jo-mueller OK, I've had a bit of a tidy up. Added some notes for users to the README and added to these in the description above to help reviewers etc understand what's in the PR. It may be that all this logic is replaced in due course by |
|
@will-moore: perhaps beyond this PR, but what's the best next step here with @clbarnes, @kevinyamauchi & co. to move us towards reusing transformnd? |
|
My headcanon would be:
The general framework will likely stay the same of how things are implemented here (I.e. the usage of the spec class) which could at some point be moved upstream into ome-zarr-py. I can flesh that out a bit more on Monday :) |
There was a problem hiding this comment.
Hey @will-moore cool stuff! Will try locally with a few sample images, in the meantime find above some minor notes from my side. Also note that in my set of sanity checking datasets, I had the affine matrices written out incorrectly, but it's updated now.
|
Works like a charm! I also tried loading the example with the displacements field, an informative warning message would be good there. Otherwise I think this is good to go, as far as we can test it atm. |
|
With 4f9ff95 and the displacements example above, we see: |
|
@jo-mueller Made a few fixes from your feedback. |
|
The last commit comes from testing of various samples I created from ome/ome-zarr-py#582 - handling transforms for a single image in-line with the spec.
|


This PR adds support for RFC-5 Scenes.
From the README:
"If the
path_to_image.zarrcontains aScene, thecoordinateTransformswith theirinputandoutputpath/names are used to build a "graph" that includes transforms from the child images. The
coordinateSystemat the "top" of the graph is used to display all the images, with all relevant transforms being applied to
each image. If the graph contains multiple "top"
coordinateSystems, the one with the most input imagesis chosen for display.
Only the first
coordinateSystemfrom each image is read in order to determine theAxes. The Scene graph isconstructed purely from
coordinateTransforms.Supported
coordinateTransformsincludeidentity,scale,translation,rotation,affineandsequence(containing these other transforms)."
The implementation is quite light on validation and only reads what it needs to create the transform graph.
E.g. No
coordinateSystemsare used to construct the transform graph. We simply match theinputandoutputfrom eachcoordinateTransformto link them together. AnycoordinateTransformthat doesn't have adataset[0].coordinateTransformas it's ultimate input is ignored.The pyramid of dataset resolutions is passed as a stack to napari, without reading any coordinateTransforms apart from the first dataset resolution (same as existing behaviour for multiscale images).
If there is more than 1
coordinateTransformin the datasets[0].coordinateTransformations list, this will lead to the image being duplicated in the graph, as the input from each one is assumed to be the corresponding datasets pyramid (as in the Spec).We combine the series of transforms that link each image to the "top" coordinateSystem by converting each into a napari affine transform, then multiplying them into a single affine transform which is passed to napari with the image metadata. Any mismatch of dimensions in transforms (e.g. size of matrix or length of 'transforms' list etc) is not validated but will instead result in an error when we try to multiply them or when they are passed to napari.
To test, try the scene at https://ome.github.io/ome-ngff-validator/?source=https://livingobjects.ebi.ac.uk/idr/zarr/test-data/v0.6.dev4/idr0050/4995115_output_to_ms.zarr which has a moderately interesting sequence of transforms, ending with a rotation of the whole scene:
After playing with layer blending and colours to emphasise that the alignment is correct:
This was previously will-moore#4 - now opened against ome main branch