-
Notifications
You must be signed in to change notification settings - Fork 28
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
Extension proposal: multiscale arrays v0.1 #50
Comments
I'm really happy see this. We also used a similar layout for storing pyramids initially to that proposed above and it's fantastic to see this formalized. I'm curious about the decision to store the base array in the same group as the downsampled levels. We initially did the same, but then moved towards a structure separating the two:
as a more general "image" format in zarr. One could expect to find a "base" array and then check for the "sub-resolutions" group to determine if it is a pyramid or not. We thought this structure would allow for other types of data (e.g. segmentation) to be store along side the base array. Again, thanks for the work here in formalizing this! |
Thanks, @manzt. Let's see if there are more votes for the deeper representation. It's certainly also what I was originally thinking about in #23. The downside is that one likely needs metadata on all the datasets pointing up and down the hierarchy in order to support detection of the sequence from any scale. It's the other major design layout I can think of. (If anyone has more, those would be very welcome.) |
@joshmoore amazing to see this kick off. A couple short comments
|
Glad to see the discussion here. Some thoughts:
Here's example metadata that implements this concept. The specifics of the "transform attributes" don't really matter -- this could be an affine transform, or something fancier. But I think the basic idea of putting the spatial information of each dataset in the group attributes is solid.
For posterity, I've written about this issue (as it pertains to the data our group works with) here |
I generally have the same feelings. I'm for the simplicity of the current proposal, and I wonder if my suggestion adds an extra layer of complexity unnecessarily.
Wouldn't this require copying the base image into a separate group? Perhaps I'm misunderstanding. |
The base image would be in the same group with the downscaled versions. So on the file system, it would look like this:
|
Apologies, I thought you were suggesting that separate groups should be created for different sampling of the same base image (e.g. gaussian and laplacian). |
@manzt |
Adding to the practical importance here: the spatial position of the first pixel is shifted in subresolutions, and the physical spacing between pixels changes also. This must be accounted for during visualization or analysis when other datasets, e.g. other images or segmentations, come into play. If this metadata is readily and independently available for every subresolution, i.e. scale factors do not need to be fetched and computations made, each subresolution image can be used independently, effortlessly, and without computational overhead. One option is to build on the model implied by storing images in the Xarray project data structures, which has Zarr support. This enables storing metadata such as the position of the first pixel, the spacing between pixels, and identification of the array dimensions, e.g., Generated from this example, here is what it looks like:
This is the layout generated by The metadata looks like this:
Open for rest
Here This example is generated with itk, but it could also just as easily be generated with scikit-image, or dask-image via [1] (work in progress) or pyimagej. |
Thanks for the link to that example @thewtex! Conforming with @constantinpape, @bogovicj, @axtimwalde might also be interested in weighing in. |
👍 to flat vs hierarchical representation. Also 👍 to "multiscale". I also like the constraint that the sub-datasets should be openable as zarr arrays by themselves. I think @thewtex's example satisfies this. Having said this, @thewtex, the xarray model looks too complex to me compared to @joshmoore's proposed spec. It would be great if it could be stripped down to its bare essentials. I agree that it's nice to have the pixel start coordinate handy, but it can also be computed after the fact, so it should be optional I think. Last thing, which may be out of scope, but might not be: for visualisation, it is sometimes convenient to have the same array with different chunk sizes, e.g. orthogonal planes to all axes for a 3D image. I wonder if the same data/metadata layout standard can be used in these situations. Oh and @joshmoore
whose. Regret pinging me yet? =P |
Great to see so much discussion on this proposal. I didn't have time to read through all of it yet, will try to catch up on the weekend. |
Great to see this moving on! In our projects xcube and xcube-viewer image pyramids look like so:
As @joshmoore mentioned, also this goes without special metadata, because
(See also the We are looking forward to adopt our code to any commonly agreed-on Zarr "standard". |
All- Here's a quick summary from my side of discussions up to this point. Please send corrections/additions as you see fit. ~Josh Apparent agreementNameThe name "multiscale" seems to be generally acceptable (#50 (comment), #50 (comment)) Multiple seriesSupport for multiple series per groups seems to be generally acceptable (e.g. #50 (comment)). Special namesThere are a few explicit votes for no special dataset names (e.g. #50 (comment)), but under "New ideas" there was one mention of group naming schemes. Less clearLayoutOne primary decision point seems to be whether to use a deep or a flat layout:
Here I'd add that if flat is generally accepted as being the simplest approach for getting started, later revisions can always move to something more sophisticated. However, I'm pretty sure at that point we would want metadata not just at a single group level but either on multiple groups or all related datasets (or both). Scaling informationAnother key issue seems to be the scaling information. There are a range of ways that have been shown:
@sofroniewn even asked if they are even useful as they stand (#50 (comment)). To be honest, I punted on this issue knowing that it would be harder to find consensus on it. To my mind, this could even be a second though related extension proposal. My reasoning for that is that it can also be used to represent the relationship between non-multiscale arrays, along the lines of @jni's "multiple chunk sizes" question below, and in the case of BDV, the relationship between the individual timepoints, etc. My first question then would be: to what extent can the current multiscale proposal be of value without the spatial/scale/transform information? New ideasExplicit "name" key@d-v-b's New proposed COSEM style from #50 (comment) uses this format:
Though this would prevent directly consuming the list (e.g. Group naming@forman showed an example from xcube in #50 (comment) in which group names were used rather than metadata to detect levels:
Links@forman also showed in #50 (comment) one solution for linking: "The level zero, can also be named 0.lnk. In this case it contains the path the original data rather then a copy of the 'pyramidized' original dataset." This would likely need to be a pre-requisite proposal for this one if we were to follow that route. cc: @alimanfoo Either/or logicIn @d-v-b's COSEM writeup from #50 (comment), there is an example of either/or logic, where could would need to check in more than one location for a given piece of metadata:
Multiple chunk sizes@jni pondered in #50 (comment): "for visualisation, it is sometimes convenient to have the same array with different chunk sizes, e.g. orthogonal planes to all axes for a 3D image. I wonder if the same data/metadata layout standard can be used in these situations." For the record, I'd currently err on the side of:
(whew) But opinions, as always, are very welcome. Further CCs: @saalfeldlab @axtimwalde @tpietzsch |
I think there's value in the current effort, insofar as standardizing spatial metadata is a separable issue. For a multiscale image spec, I would propose abstracting over the specific implementation of spatial metadata, e.g. by stipulating that the group
These all look good to me! |
@joshmoore outstanding summary! Thanks for leading this endeavor.
To correctly analyze or visualize the data as a multiscale image pyramid, then some spatial/scale/transform information is required. To:
Spacing / scale and offset / origin and/or transforms are required. Without them, these use cases are either complex and error prone (requiring provenance and computation related to source pixel grids), or not possible. This is why the majority of scientific imaging file formats have at least spacing / scale and offset / origin in some form. That said, the specs could still be split into two to keep things moving along. |
Thanks so much to everyone who is putting detailed thought into this complex issue. Since the discussion has mostly focused on the bioimaging side of things, I'll try to add the xarray & geospatial perspective.
|
Great discussion. These are my $0.02. Largely, I agree with @joshmoore's summary in #50 (comment). Being able to open each scale level as an individual data set and not part of a pyramid is probably the most important feature and should be part of any standard the comes out of this. With this in mind, the spatial meta data (
This also does not consider other spatial meta data like rotations. As far as I know, this is a relevant use case for @tpietzsch. If such (arbitrary) transforms should not be considered in the standard, then the question arises of how to combine this with the Other than that, here are a few comments:
[{"name": "s0", "meta1": ...}, {"name": "s1", "meta1": ...}] over storing multiple arrays like {"datasets": ["s0", "s1", ...], "meta1": [...]}
I think that a common standard would be a great thing to have and help interaction between the wealth of tools that we are looking at. Paintera does not have a great standard and should update its format if a reasonable standard comes out of this (while maintaining backwards compatibility). Disclaimer: I will start a position outside academia soon and will not be involved in developing tools in this realm after that. My comment should be regarded as food for thought and to raise concerns that may not have been considered yet. Ultimately, I will not be involved in the decision making of any specifics of this standard. cc @igorpisarev |
Apologies, all, for letting this slip into April. Hopefully everyone's managing these times well enough despite the burden of long spec threads. I've updated the description to include the new A few points on the more recent comments:
Otherwise, it sounds like the newer comments are generally onboard with the current proposal, but let me know if I've dropped anyone's concerns. |
I like
This is a valid concern. Personally I don't like duplicating spatial metadata in the group -- my original conception a long time ago was for the group multiscale metadata to simply list the names/paths to the datasets that comprise the pyramid, with no additional information. But I was reminded by @axtimwalde that accessing metadata from multiple files on cloud stores can be bothersome, and this led to the idea of consolidating the array metadata at the group level. Maybe this can be addressed via the consolidated metadata functionality that has already been added to zarr: https://zarr.readthedocs.io/en/latest/tutorial.html#consolidating-metadata. For a spec, a way to resolve this could be to specify that, for dataset entry in the group multiscale metadata, a |
What would we do if cloud storage wouldn't have high latency? I am similarly worried about the consolidated meta-data hack because we may store a lot of meta-data and parsing very long JSON texts isn't particularly fast either, it also doesn't scale very well. |
NB: Updated description to use "path". I had never considered a level of consolidation between none and everything, e.g. all arrays (but not groups) within a group are cached within the group metadata. It's an interesting idea, but discussing it here seems dangerous. If we assume that consolidation is out-of-scope for this issue, I think the only question remaining is if we want optional spatial metadata at the group level, where the array metadata would take precedence. Here, I'd likely also vote for being conservative and not doing that at this point, though we could add it in the future (more easily than we could remove it). If all agree, I'll add hopefully one last update to remove all mention of "scale" and then start collecting all the spatial ideas that we've tabled in this issue into a new one. |
By listing pyramids in the group attributes which contain the pyramids, clients can lookup the number of resolutions without needing to know beforehand or perform a directory listing. see: zarr-developers/zarr-specs#50
By listing pyramids in the group attributes which contain the pyramids, clients can lookup the number of resolutions without needing to know beforehand or perform a directory listing. see: zarr-developers/zarr-specs#50
This issue has been migrated to image.sc after the 2020-05-06 community discussion and will be closed. Authors are still encouraged to make use of the specification in their own libraries. As the v3 extension mechanism matures, the specification will be updated and registered as appropriate. Many thanks to everyone who has participated to date. Further feedback and request changes are welcome either on this repository or on image.sc. |
This issue has been migrated to an image.sc topic after the 2020-05-06 community discussion. Authors are still encouraged to make use of the specification in their own libraries. As the v3 extension mechanism matures, the specification will be updated and registered as appropriate. Feedback and request changes are welcome either on this repository or on image.sc.
As a first draft of support for the multiscale use-case (#23), this issue proposes an intermediate nomenclature for describing groups of Zarr arrays which are scaled down versions of one another, e.g.:
This layout was independently developed in a number of implementations and has since been implemented in others, including:
Using a common metadata representation across implementations:
A basic example of the metadata that is added to the containing Zarr group is seen here:
Process
An RFC process for Zarr does not yet exist. Additionally, the v3 spec is a work-in-progress. However, since the implementations listed above as well as others are already being developed, I'd propose that if a consensus can be reached here, this issue should be turned into an .rst file similar to those in the v3 branches (e.g. filters) and used as a temporary spec for defining arrays with the understanding that this a prototype intended to be amended and brought into the general extension mechanism as it develops.
I'd welcome any suggestions/feedback, but especially around:
Deadline for a first round of comments:
March 15, 2020Deadline for a second round of comments: April 15, 2020
Detailed example
Color key (according to https://www.ietf.org/rfc/rfc2119.txt):
Color-coded example:
Explanation
Type enumeration:
gaussian
, e.g. skimage.transform.pyramid_gaussianlaplacian
, e.g. skimage.transform.pyramid_laplacianreduce
, e.g. skimage.transform.pyramid_laplacianpick
, e.g. SimpleImageScaler's “top-left” strategySample code
which results in a
.zattrs
file of the form:and the following on-disk layout:
Thanks to @ryan-williams, @jakirkham, @freeman-lab, @petebankhead, @jni, @sofroniewn, @chris-allan, and anyone else whose GitHub account I've forgotten for the preliminary discussions.
The text was updated successfully, but these errors were encountered: