Closed JunMa11 closed 1 year ago
You can write a numpy
array to a persistent zarr
array and then use the rest of the pipeline as is, here is an example:
import numpy as np
import zarr
from numcodecs import Blosc
raw = np.random.randint(0, 256, (256, 256, 256), dtype=np.uint8)
labels = np.random.randint(0, 2, (256, 256, 256), dtype=np.uint32)
x = zarr.open(
store="test.zarr",
path="volumes/raw",
mode="w-",
shape=raw.shape,
chunks=(128,128,128),
dtype=raw.dtype,
compressor=Blosc(cname="zlib", clevel=3),
)
x.attrs.put({"offset": [0, 0, 0], "resolution": [5, 5, 5]})
x[:] = raw
y = zarr.open(
store="test.zarr",
path="volumes/labels/somestructure",
mode="w-",
shape=labels.shape,
chunks=(128,128,128),
dtype=labels.dtype,
compressor=Blosc(cname="zlib", clevel=3),
)
y.attrs.put({"offset": [0, 0, 0], "resolution": [5, 5, 5]})
y[:] = labels
Hi @bentaculum ,
Thanks for your help very much.
How can I write the zarr
file to numpy
? since I'd like to build my own pipeline based on numpy format data.
Simply by slicing, here is a nice tutorial: https://zarr.readthedocs.io/en/stable/tutorial.html.
Thanks for sharing the awesome work.
I'm not familiar with the zarr format. Would it be possible for you to share a demo on how to load the data as NumPy array?