harpy.im.add_labels

Contents

harpy.im.add_labels#

harpy.im.add_labels(sdata, arr, output_labels_name, dims=None, chunks=None, transformations=None, scale_factors=None, overwrite=False)#

Add a labels element to a SpatialData object.

This function allows you to add a labels element to sdata. If sdata is backed by a zarr store, the resulting labels element will be backed to the zarr store, otherwise arr will be persisted in memory. All layers of the Dask graph associated with arr will therefore be materialized upon calling add_labels.

Parameters:
  • sdata (SpatialData) – The SpatialData object to which the new labels element will be added.

  • arr (Array) – The array containing the labels data to be added. Should be of type int.

  • output_labels_name (str) – The name of the output labels element where the labels data will be stored.

  • dims (tuple[str, ...] | None (default: None)) – A tuple specifying the dimensions of the labels data (e.g., (“”z”, “y”, “x”)). If None, defaults will be inferred.

  • chunks (str | tuple[int, ...] | int | None (default: None)) – Specification for chunking the data.

  • transformations (dict[str, BaseTransformation] | None (default: None)) – Transformations that will be added to resulting output_labels_name.

  • scale_factors (Sequence[dict[str, int] | int] | None (default: None)) – Scale factors to apply for multiscale data. If specified output_labels_name will be multiscale

  • overwrite (bool (default: False)) – If True, overwrites the output_labels_name if it already exists in sdata.

Return type:

SpatialData

Returns:

: The sdata object with the labels element added.