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

V05 dev1 #35

Merged
merged 9 commits into from
Oct 28, 2024
Merged

V05 dev1 #35

merged 9 commits into from
Oct 28, 2024

Conversation

Copy link

netlify bot commented Jun 14, 2024

Deploy Preview for ome-ngff-validator ready!

Name Link
🔨 Latest commit e5b5bef
🔍 Latest deploy log https://app.netlify.com/sites/ome-ngff-validator/deploys/667ebfce592a5b0008ecee88
😎 Deploy Preview https://deploy-preview-35--ome-ngff-validator.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@will-moore
Copy link
Member Author

will-moore commented Jun 14, 2024

@joshmoore @d-v-b
The data above at https://minio-dev.openmicroscopy.org/idr/v0.5-dev1/6001240.zarr was generated from a local v0.4 NGFF sample with this code (NB: this isn't using ome-zarr-py, just plain zarr v3):
One issue is that it doesn't preserve the chunk sizes, since it reads the data as numpy rather than with Dask, so we lose chunks info.
Also this code doesn't handle labels, plates, bioformats2raw layout etc.

moved to repo
import numpy as np
import zarr
import os

path = "/Users/wmoore/Desktop/ZARR/data/6001240.zarr"
# remote fails - see below
# path = "https://uk1s3.embassy.ebi.ac.uk/idr/zarr/v0.4/idr0062A/6001240.zarr"

rootpath = "6001240_V0.5-dev1.zarr"
if os.path.exists(rootpath):
    import shutil
    shutil.rmtree(rootpath)

store_class = zarr.store.LocalStore
if path.startswith("http"):
    # TypeError: Can't instantiate abstract class RemoteStore with abstract methods get_partial_values, list, list_dir, list_prefix, set_partial_values
    store_class = zarr.store.RemoteStore
read_store = store_class(path, mode="r")
# Needs zarr_format=2 or we get ValueError("store mode does not support writing")
read_root = zarr.open_group(store=read_store, zarr_format=2)

# Create new Image...
write_store = zarr.store.LocalStore(rootpath, mode="w")
root = zarr.Group.create(write_store)
# copy NGFF attrs
for key in read_root.attrs.keys():
    root.attrs[key] = read_root.attrs[key]
# update version
root.attrs["multiscales"][0]["version"] = "0.5-dev"

# convert arrays
multiscales = read_root.attrs.get("multiscales")
for ds in multiscales[0]["datasets"]:
    ds_path = ds["path"]
    data = zarr.load(store=read_store, path=ds_path)
    print('array', ds_path, data.shape)
    a = root.create_array(str(ds_path), shape=data.shape, chunk_shape=[64] * data.ndim, dtype=data.dtype)
    # These 2 lines are equivalent to e.g. a[:,:] = data (for any number of dimensions)
    s = [np.s_[:]] * len(data.shape)
    a[tuple(s)] = data

see: ome/ome2024-ngff-challenge@88317e6

@imagesc-bot
Copy link

This pull request has been mentioned on Image.sc Forum. There might be relevant details there:

https://forum.image.sc/t/ome2024-ngff-challenge/97363/9

@will-moore
Copy link
Member Author

Updated the samples at https://minio-dev.openmicroscopy.org/idr/v0.5-dev1/6001240.zarr and https://minio-dev.openmicroscopy.org/idr/v0.5-dev1/6001240b.zarr with version 0.5-dev1 to corresponds to last commit above and fix of version in schemas at ome/ngff#249
cc @joshmoore

@will-moore will-moore merged commit e5b5bef into ome:main Oct 28, 2024
5 checks passed
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

Successfully merging this pull request may close these issues.

2 participants