Skip to content
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

[feature] Reuse zarr metadata from one image for others in plate #75

Open
manzt opened this issue Feb 23, 2021 · 3 comments
Open

[feature] Reuse zarr metadata from one image for others in plate #75

manzt opened this issue Feb 23, 2021 · 3 comments

Comments

@manzt
Copy link
Member

manzt commented Feb 23, 2021

Motivation:

Currently we initialize each ZarrArray in a plate layout independently. This means that we make row x col requests for .zarray metadata prior to fetching any unique pixel data. This can lead to a substantial overhead of just waiting for metadata to load for large plates; time that could be spent fetching the actual pixel data.

In addition, if we do end up supporting multiscale plates, we would need to make row x col x n_levels requests to initialize all arrays in the grid. For example, this plate from the OME-Blog: https://s3.embassy.ebi.ac.uk/idr/zarr/v0.1/plates/5966.zarr would require 394 * 5 = 1970 requests to initialize prior to fetching any data.

Proposal

Similar to reusing the omero metadata for the first image in the plate, we should be able to reuse the .zarray metadata for the first image in the plate to initialize all other ZarrArray objects at the same resolution. By taking this approach, we can initialize all the ZarrArray objects for a plate with the same number of requests regardless of plate size.

This approach assumes that the .zarray metadata is consistent for all arrays at the same resolution (shape, chunk, compressor, etc are all identical). Perhaps this is too strong of an assumption, and thoughts @joshmoore or @will-moore ?

@will-moore
Copy link
Collaborator

I like the idea. Makes sense and certainly most of the plates I've seen do have identical sized images in every Well.
But it's probably too restrictive to say that ALL Plates must have all Images the same size. So we could maybe 'consolidate' that info into a parameter like "all_images_same_size" in the plate metadata?
Maybe open an issue at https://github.com/ome/ngff ?

@manzt
Copy link
Member Author

manzt commented Feb 23, 2021

Sure, I'll look into opening an issue. It's worth noting that in order to render to the grid currently (for plate or well), we require identically sized images:

vizarr/src/gridLayer.ts

Lines 44 to 55 in 1ef2163

function validateWidthHeight(d: { data: { width: number; height: number } }[]) {
const [first] = d;
// Return early if no grid data. Maybe throw an error?
const { width, height } = first.data;
// Verify that all grid data is same shape (ignoring undefined)
d.forEach(({ data }) => {
if (data?.width !== width || data?.height !== height) {
throw new Error('Grid data is not same shape.');
}
});
return { width, height };
}

And vizarr will throw an error otherwise. So this issue is suggesting that we make that assumption initially as well, when initializing arrays.

@joshmoore
Copy link

Maybe open an issue at https://github.com/ome/ngff ?

Agreed. I think we have something along the lines of "all dtypes for the multiresolutions will be of the same type" and we might could generalize that for "all items in a certain type of collection".

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants