sparrow.im.filter_labels_layer#
- sparrow.im.filter_labels_layer(sdata, labels_layer, min_size=10, max_size=100000, depth=100, chunks='auto', output_labels_layer=None, output_shapes_layer=None, scale_factors=None, overwrite=False)#
Filter labels in labels layer
labels_layer
of Spatialdata object that have a size less thanmin_size
or size greater thanmax_size
.- Parameters:
sdata (
SpatialData
) – The spatialdata object containing the labels layer to be filtered.labels_layer (
str
) – The name of the labels layer to be filtered.min_size (
int
(default:10
)) – labels inlabels_layer
with size smaller thanmin_size
will be set to 0.max_size (
int
(default:100000
)) – labels inlabels_layer
with size larger thanmax_size
will be set to 0.depth (
tuple
[int
,int
] |int
(default:100
)) – The depth around the boundary of each block to load when the array is split into blocks (for alignment). This ensures that the split isn’t causing misalignment along the edges. Default is 100. Please set depth>cell diameter to avoid chunking effects.chunks (
str
|int
|tuple
[int
,int
] |None
(default:'auto'
)) – The desired chunk size for the Dask computation, or “auto” to allow the function to choose an optimal chunk size based on the data. Default is “auto”.output_labels_layer (
Optional
[str
] (default:None
)) – The name of the output labels layer where results will be stored. This must be specified.output_shapes_layer (
Optional
[str
] (default:None
)) – The name for the new shapes layer generated from the aligned labels layer. If None, no shapes layer is created. Default is None.scale_factors (
Optional
[Sequence
[Union
[dict
[str
,int
],int
]]] (default:None
)) – Scale factors to apply for multiscale.overwrite (
bool
(default:False
)) – If True, overwrites the output layer if it already exists insdata
.
- Return type:
SpatialData
- Returns:
: The modified spatial data object with the filtered labels layers.
Notes
The function works with Dask arrays and can handle large datasets that don’t fit into memory.
Examples
>>> sdata = expand_labels_layer( sdata, labels_layer='layer', distance=10, depth=(100, 100), chunks=(1024, 1024), output_labels_layer='layer_expanded', output_shapes_layer='layer_expanded_boundaries', overwrite=True, )