zarr-python
Activate the conda environment ngff_workshop
:
Browse into the example data directory and then access Python:
Import the relevant tools
Read remote local and remote OME-Zarrs
# path = "https://uk1s3.embassy.ebi.ac.uk/idr/zarr/v0.4/idr0062A/6001240.zarr"
path = "./6001240.zarr"
dataset = zarr.open_group(path, mode = 'r')
Inspect the group-level metadata
Print the data type
Summarize group-level metadata:
Note the store type, the number of arrays and groups. \ Note also the group named 'labels'.Print the full metadata:
Get multiscales metadata:
Print the axis ordering and the units
pprint.pprint(meta['axes'])
axis_order = ''.join(item['name'] for item in meta['axes'])
print(f"Axis order is {axis_order}")
for idx, transform in enumerate(meta['datasets']):
print(f"\033[1mVoxel transform for the level {idx}:\033[0m")
pprint.pprint(transform)
Inspect individual resolution layers
Get the top resolution array:
zarr_array0 = dataset[0]
print(f"Array type: {type(zarr_array0)}")
print(f"Shape of the top-level array: {zarr_array0.shape}")
zarr_array1 = dataset[1]
print(f"Array type: {type(zarr_array1)}")
print(f"Shape of the first-level downscaled array: {zarr_array1.shape}")
Convert the zarr array to a numpy array: