Writer (ome_zarr.writer)

Image writer utility

ome_zarr.writer.write_image(image: Array | ndarray, group: Group, scaler: Scaler = Scaler(copy_metadata=False, downscale=2, in_place=False, labeled=False, max_layer=4, method='nearest'), chunks: Tuple[Any, ...] | int | None = None, fmt: Format = FormatV04, axes: str | List[str] | List[Dict[str, str]] | None = None, coordinate_transformations: List[List[Dict[str, Any]]] | None = None, storage_options: Dict[str, Any] | List[Dict[str, Any]] | None = None, compute: bool | None = True, **metadata: str | Dict[str, Any] | List[Dict[str, Any]]) List

Writes an image to the zarr store according to ome-zarr specification

Parameters:
  • image (numpy.ndarray or dask.array.Array) – The image data to save. A downsampling of the data will be computed if the scaler argument is non-None. Image array MUST be up to 5-dimensional with dimensions ordered (t, c, z, y, x). Image can be a numpy or dask Array.

  • group (zarr.hierarchy.Group) – The group within the zarr store to write the metadata in.

  • scaler (ome_zarr.scale.Scaler) – Scaler implementation for downsampling the image argument. If None, no downsampling will be performed.

  • chunks (int or tuple of ints, optional) –

    The size of the saved chunks to store the image.

    Deprecated since version 0.4.0: This argument is deprecated and will be removed in a future version. Use storage_options instead.

  • fmt (ome_zarr.format.Format, optional) – The format of the ome_zarr data which should be used. Defaults to the most current.

  • axes (list of str or list of dicts, optional) – The names of the axes. e.g. [“t”, “c”, “z”, “y”, “x”]. Ignored for versions 0.1 and 0.2. Required for version 0.3 or greater.

  • coordinate_transformations (list of dict) – For each resolution, we have a List of transformation Dicts (not validated). Each list of dicts are added to each datasets in order.

  • storage_options (dict or list of dict, optional) – Options to be passed on to the storage backend. A list would need to match the number of datasets in a multiresolution pyramid. One can provide different chunk size for each level of a pyramid using this option.

  • compute – If true compute immediately otherwise a list of dask.delayed.Delayed is returned.

Returns:

Empty list if the compute flag is True, otherwise it returns a list of dask.delayed.Delayed representing the value to be computed by dask.

ome_zarr.writer.write_label_metadata(group: Group, name: str, colors: List[Dict[str, Any]] | None = None, properties: List[Dict[str, Any]] | None = None, fmt: Format = FormatV04, **metadata: List[Dict[str, Any]] | Dict[str, Any] | str) None

Write image-label metadata to the group.

The label data must have been written to a sub-group, with the same name as the second argument.

Parameters:
  • group (zarr.hierarchy.Group) – The group within the zarr store to write the metadata in.

  • name (str) – The name of the label sub-group.

  • colors (list of JSONDict, optional) – Fixed colors for (a subset of) the label values. Each dict specifies the color for one label and must contain the fields “label-value” and “rgba”.

  • properties (list of JSONDict, optional) – Additional properties for (a subset of) the label values. Each dict specifies additional properties for one label. It must contain the field “label-value” and may contain arbitrary additional properties.

  • fmt (ome_zarr.format.Format, optional) – The format of the ome_zarr data which should be used. Defaults to the most current.

ome_zarr.writer.write_labels(labels: ndarray | Array, group: Group, name: str, scaler: Scaler = Scaler(copy_metadata=False, downscale=2, in_place=False, labeled=False, max_layer=4, method='nearest'), chunks: Tuple[Any, ...] | int | None = None, fmt: Format = FormatV04, axes: str | List[str] | List[Dict[str, str]] | None = None, coordinate_transformations: List[List[Dict[str, Any]]] | None = None, storage_options: Dict[str, Any] | List[Dict[str, Any]] | None = None, label_metadata: Dict[str, Any] | None = None, compute: bool | None = True, **metadata: Dict[str, Any]) List

Write image label data to disk.

Including the multiscales and image-label metadata. Creates the label data in the sub-group “labels/{name}”

Parameters:
  • labels (numpy.ndarray) – The label data to save. A downsampling of the data will be computed if the scaler argument is non-None. Label array MUST be up to 5-dimensional with dimensions ordered (t, c, z, y, x)

  • group (zarr.hierarchy.Group) – The group within the zarr store to write the metadata in.

  • name (str, optional) – The name of this labels data.

  • scaler (ome_zarr.scale.Scaler) – Scaler implementation for downsampling the image argument. If None, no downsampling will be performed.

  • chunks (int or tuple of ints, optional) –

    The size of the saved chunks to store the image.

    Deprecated since version 0.4.0: This argument is deprecated and will be removed in a future version. Use storage_options instead.

  • fmt (ome_zarr.format.Format, optional) – The format of the ome_zarr data which should be used. Defaults to the most current.

  • axes (list of str or list of dicts, optional) – The names of the axes. e.g. [“t”, “c”, “z”, “y”, “x”]. Ignored for versions 0.1 and 0.2. Required for version 0.3 or greater.

  • coordinate_transformations (list of dict) – For each resolution, we have a List of transformation Dicts (not validated). Each list of dicts are added to each datasets in order.

  • storage_options (dict or list of dict, optional) – Options to be passed on to the storage backend. A list would need to match the number of datasets in a multiresolution pyramid. One can provide different chunk size for each level of a pyramid using this option.

  • label_metadata (dict, optional) – Image label metadata. See write_label_metadata() for details

  • compute – If true compute immediately otherwise a list of dask.delayed.Delayed is returned.

Returns:

Empty list if the compute flag is True, otherwise it returns a list of dask.delayed.Delayed representing the value to be computed by dask.

ome_zarr.writer.write_multiscale(pyramid: List[Array] | List[ndarray], group: Group, chunks: Tuple[Any, ...] | int | None = None, fmt: Format = FormatV04, axes: str | List[str] | List[Dict[str, str]] | None = None, coordinate_transformations: List[List[Dict[str, Any]]] | None = None, storage_options: Dict[str, Any] | List[Dict[str, Any]] | None = None, name: str | None = None, compute: bool | None = True, **metadata: str | Dict[str, Any] | List[Dict[str, Any]]) List

Write a pyramid with multiscale metadata to disk.

Parameters:
  • pyramid (list of numpy.ndarray or dask.array.Array) – The image data to save. Largest level first. All image arrays MUST be up to 5-dimensional with dimensions ordered (t, c, z, y, x)

  • group (zarr.hierarchy.Group) – The group within the zarr store to store the data in

  • chunks (int or tuple of ints, optional) –

    The size of the saved chunks to store the image.

    Deprecated since version 0.4.0: This argument is deprecated and will be removed in a future version. Use storage_options instead.

  • fmt (ome_zarr.format.Format, optional) – The format of the ome_zarr data which should be used. Defaults to the most current.

  • axes (str list of str or list of dict, optional) – List of axes dicts, or names. Not needed for v0.1 or v0.2 or if 2D. Otherwise this must be provided

  • coordinate_transformations (2Dlist of dict, optional) – List of transformations for each path. Each list of dicts are added to each datasets in order and must include a ‘scale’ transform.

  • storage_options (dict or list of dict, optional) – Options to be passed on to the storage backend. A list would need to match the number of datasets in a multiresolution pyramid. One can provide different chunk size for each level of a pyramid using this option.

  • compute – If true compute immediately otherwise a list of dask.delayed.Delayed is returned.

Returns:

Empty list if the compute flag is True, otherwise it returns a list of dask.delayed.Delayed representing the value to be computed by dask.

ome_zarr.writer.write_multiscale_labels(pyramid: List, group: Group, name: str, chunks: Tuple[Any, ...] | int | None = None, fmt: Format = FormatV04, axes: str | List[str] | List[Dict[str, str]] | None = None, coordinate_transformations: List[List[Dict[str, Any]]] | None = None, storage_options: Dict[str, Any] | List[Dict[str, Any]] | None = None, label_metadata: Dict[str, Any] | None = None, compute: bool | None = True, **metadata: Dict[str, Any]) List

Write pyramidal image labels to disk.

Including the multiscales and image-label metadata. Creates the label data in the sub-group “labels/{name}”

Parameters:
  • pyramid (list of numpy.ndarray) – the image label data to save. Largest level first All image arrays MUST be up to 5-dimensional with dimensions ordered (t, c, z, y, x)

  • group (zarr.hierarchy.Group) – The group within the zarr store to write the metadata in.

  • name (str, optional) – The name of this labels data.

  • chunks (int or tuple of ints, optional) –

    The size of the saved chunks to store the image.

    Deprecated since version 0.4.0: This argument is deprecated and will be removed in a future version. Use storage_options instead.

  • fmt (ome_zarr.format.Format, optional) – The format of the ome_zarr data which should be used. Defaults to the most current.

  • axes (list of str or list of dicts, optional) – The names of the axes. e.g. [“t”, “c”, “z”, “y”, “x”]. Ignored for versions 0.1 and 0.2. Required for version 0.3 or greater.

  • coordinate_transformations (list of dict) – For each resolution, we have a List of transformation Dicts (not validated). Each list of dicts are added to each datasets in order.

  • storage_options (dict or list of dict, optional) – Options to be passed on to the storage backend. A list would need to match the number of datasets in a multiresolution pyramid. One can provide different chunk size for each level of a pyramid using this option.

  • label_metadata (dict, optional) – Image label metadata. See write_label_metadata() for details

  • compute – If true compute immediately otherwise a list of dask.delayed.Delayed is returned.

Returns:

Empty list if the compute flag is True, otherwise it returns a list of dask.delayed.Delayed representing the value to be computed by dask.

ome_zarr.writer.write_multiscales_metadata(group: Group, datasets: List[dict], fmt: Format = FormatV04, axes: str | List[str] | List[Dict[str, str]] | None = None, name: str | None = None, **metadata: str | Dict[str, Any] | List[Dict[str, Any]]) None

Write the multiscales metadata in the group.

Parameters:
  • group (zarr.hierarchy.Group) – The group within the zarr store to write the metadata in.

  • datasets (list of dicts) – The list of datasets (dicts) for this multiscale image. Each dict must include ‘path’ and a ‘coordinateTransformations’ list for version 0.4 or later that must include a ‘scale’ transform.

  • fmt (ome_zarr.format.Format, optional) – The format of the ome_zarr data which should be used. Defaults to the most current.

  • axes (list of str or list of dicts, optional) – The names of the axes. e.g. [“t”, “c”, “z”, “y”, “x”]. Ignored for versions 0.1 and 0.2. Required for version 0.3 or greater.

ome_zarr.writer.write_plate_metadata(group: Group, rows: List[str], columns: List[str], wells: List[str | dict], fmt: Format = FormatV04, acquisitions: List[dict] | None = None, field_count: int | None = None, name: str | None = None) None

Write the plate metadata in the group.

Parameters:
  • group (zarr.hierarchy.Group) – The group within the zarr store to write the metadata in.

  • rows (list of str) – The list of names for the plate rows.

  • columns (list of str) – The list of names for the plate columns.

  • wells (list of str or dict) – The list of paths for the well groups.

  • fmt (ome_zarr.format.Format, optional) – The format of the ome_zarr data which should be used. Defaults to the most current.

  • acquisitions (list of dict, optional) – A list of the various plate acquisitions.

  • name (str, optional) – The plate name.

  • field_count (int, optional) – The maximum number of fields per view across wells.

ome_zarr.writer.write_well_metadata(group: Group, images: List[str | dict], fmt: Format = FormatV04) None

Write the well metadata in the group.

Parameters:
  • group (zarr.hierarchy.Group) – The group within the zarr store to write the metadata in.

  • images (list of dict) – The list of dictionaries for all fields of views.

  • fmt (ome_zarr.format.Format, optional) – The format of the ome_zarr data which should be used. Defaults to the most current.