sparrow.im.add_labels_layer

sparrow.im.add_labels_layer#

sparrow.im.add_labels_layer(sdata, arr, output_layer, dims=None, chunks=None, transformations=None, scale_factors=None, overwrite=False)#

Add a labels layer to a SpatialData object.

This function allows you to add a labels layer to sdata. If sdata is backed by a zarr store, the resulting labels layer 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_layer.

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

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

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

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

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

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

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

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

Return type:

SpatialData

Returns:

: The sdata object with the labels layer added.