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. Ifsdatais backed by a zarr store, the resulting labels element will be backed to the zarr store, otherwisearrwill be persisted in memory. All layers of the Dask graph associated witharrwill therefore be materialized upon callingadd_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 resultingoutput_labels_name.scale_factors (
Sequence[dict[str,int] |int] |None(default:None)) – Scale factors to apply for multiscale data. If specifiedoutput_labels_namewill be multiscaleoverwrite (
bool(default:False)) – If True, overwrites theoutput_labels_nameif it already exists insdata.
- Return type:
- Returns:
: The
sdataobject with the labels element added.