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
. Ifsdata
is backed by a zarr store, the resulting labels layer will be backed to the zarr store, otherwisearr
will be persisted in memory. All layers of the Dask graph associated witharr
will therefore be materialized upon callingadd_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 resultingoutput_layer
.scale_factors (
Optional
[Sequence
[Union
[dict
[str
,int
],int
]]] (default:None
)) – Scale factors to apply for multiscale data. If specifiedoutput_layer
will be multiscaleoverwrite (
bool
(default:False
)) – If True, overwrites theoutput_layer
if it already exists insdata
.
- Return type:
SpatialData
- Returns:
: The
sdata
object with the labels layer added.