Kitware / itk-vtk-viewer

2D / 3D web image, mesh, and point set viewer using itk-wasm and vtk.js
https://kitware.github.io/itk-vtk-viewer/
BSD 3-Clause "New" or "Revised" License
202 stars 61 forks source link

is .zarr/ suffix strictly required? any other ".subsuffixes." considered (like in .ome.zarr) #738

Open yarikoptic opened 4 months ago

yarikoptic commented 4 months ago

For DANDI we are considering to implement custom support for zarr "filesets" versioning. There is an experimental webdav which is reverse proxied by apache at is https://dandi.centerforopenneuroscience.org .

What we discovered, is that despite the fact that our integration works just fine for URLs like https://kitware.github.io/itk-vtk-viewer/app/?gradientOpacity=0.3&image=https://dandiarchive.s3.amazonaws.com/zarr/6c18ad23-8bc9-404e-b902-d9ccb598dfca (BTW, doesn't work if you add trailing / since then it doesn't strip it before adding /.zattrs and fails), it does not work for https://kitware.github.io/itk-vtk-viewer/app/?gradientOpacity=0.3&image=https://dandi.centerforopenneuroscience.org/zarrs/6c1/8ad/6c18ad23-8bc9-404e-b902-d9ccb598dfca/c33f80763aafea111b5c51c291b22238-83143--96359783338 or with trailing / and you get just image with console showing image

But if I add .zarr/ (through rewrite at apache level to remove .zarr for the forwarded to webdav URL) -- it works: https://kitware.github.io/itk-vtk-viewer/app/?gradientOpacity=0.3&image=https://dandi.centerforopenneuroscience.org/zarrs/6c1/8ad/6c18ad23-8bc9-404e-b902-d9ccb598dfca/c33f80763aafea111b5c51c291b22238-83143--96359783338.zarr

So the question is really - is .zarr suffix required for the tool? but then how come it works for original URL pointing to S3 prefix?

Also, looking forward -- is subsuffix, like .ome in .ome.zarr somehow important/used? (I hope not)

Thank you in advance for the answers/ideas.

PaulHax commented 4 months ago

Thanks for the well researched issue =)

The second URL is not recongzied as a zarr image because it has /zarrs/ rather than /zarr/ like the first URL. There is a regular expression testing if a image URL shall be treated as a zarr image: https://github.com/Kitware/itk-vtk-viewer/blob/3622a93d3d64859ccde91e0f4e6fc643304b4fc7/src/IO/ZarrMultiscaleSpatialImage.js#L12-L13

So adding the .zarr at the end passes the RegEx test. A few more positive and negative zarr URL examples here: https://github.com/Kitware/itk-vtk-viewer/blob/3622a93d3d64859ccde91e0f4e6fc643304b4fc7/test/zarrTest.js#L30-L60

Zarr URL format does seem to be a continual pain point: https://github.com/Kitware/itk-vtk-viewer/pull/721

We could add another URL parameter &zarr that always treats the URL as a zarr image. Or change the toMulticalseSpatialImage logic: https://github.com/Kitware/itk-vtk-viewer/blob/3622a93d3d64859ccde91e0f4e6fc643304b4fc7/src/IO/toMultiscaleSpatialImage.js#L68

.ome is not checked/used.

yarikoptic commented 4 months ago

+1 on adding explicit option to specify the format - "explicit better than implicit" they said while language is called after a part of the name of a movie coincidental with a full name of a snake... What other formats do you consider that you can't/don't want to sense for having some /.zgroup or /.zattrs or even just trying to open it as a zarr for that URL?

yarikoptic commented 4 months ago

FYI, we now addressed this on our (dandidav) end by adding .zarr/ to those listings of zarrs so now we natively have https://dandi.centerforopenneuroscience.org/zarrs/001/e3b/001e3b6d-26fb-463f-af28-520a25680ab4/326273bcc8730474323a66ea4e3daa49-113328--97037755426.zarr/ and no analogous without .zarr/ (so examples above might no longer reproduce). Let us know if you would need/like to try on some older version