Skip to content

How do I...?

Validate an OME-Zarr group

Command line

Use ome-zarr-models validate <path to group>.

Python

If you know what type of group it is, use the from_zarr() method on one of the group objects:

import zarr
import ome_zarr_models.v04

zarr_group = zarr.open(path_to_group, mode="r")
hcs_group = ome_zarr_models.v04.HCS.from_zarr(zarr_group)

If you don't know what type of group it is, use open_ome_zarr():

import zarr
import ome_zarr_models

zarr_group = zarr.open(path_to_group, mode="r")
ome_group = ome_zarr_models.open_ome_zarr(zarr_group)

If there aren't any errors, the Zarr group is a valid OME-Zarr group.

Create a new OME-Zarr group

Use the .new() method on one of the group objects (currently only supported on Image):

import ome_zarr_models.v04

image_group = ome_zarr_models.v04.Image.new(...)

Save an OME-Zarr group

Use the .to_zarr() method on one of the group objects:

import ome_zarr_models.v04
import zarr

store = zarr.DirectoryStore(path=...)
my_image_group.to_zarr(store=store, path="/")