harpy.im.expand_labels#
- harpy.im.expand_labels(sdata, labels_name, distance=10, depth=100, chunks=None, output_labels_name=None, output_shapes_name=None, scale_factors=None, overwrite=False, iou_depth=2, iou_threshold=0.7)#
Expand cells in the labels element
labels_nameusingskimage.segmentation.expand_labels.- Parameters:
sdata (
SpatialData) – The SpatialData object containing the labels element to be expanded.labels_name (
str) – The name of the labels element to be expanded.distance (
int(default:10)) – distance passed to skimage.segmentation.expand_labels.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 + distance to avoid chunking effects.chunks (
str|int|tuple[int,int] |None(default:None)) – 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_name (
str|None(default:None)) – The name of the output labels element where results will be stored. This must be specified.output_shapes_name (
str|None(default:None)) – The name for the new shapes element generated from the expanded labels element. If None, no shapes element is created. Default is None.scale_factors (
Sequence[dict[str,int] |int] |None(default:None)) – Scale factors to apply for multiscale.overwrite (
bool(default:False)) – If True, overwritesoutput_labels_nameandoutput_shapes_nameif they already exist insdata.iou_depth (
tuple[int,int] |int(default:2)) – iou depth used for linking labels.iou_threshold (
float(default:0.7)) – iou threshold used for linking labels.
- Return type:
- Returns:
: The modified SpatialData object with the expanded labels element.
Notes
The function works with Dask arrays and can handle large datasets that don’t fit into memory.
Examples
>>> sdata = expand_labels( sdata, labels_name='segmentation_mask', distance=10, depth=(100, 100), chunks=(1024, 1024), output_labels_name='segmentation_mask_expanded', output_shapes_name='segmentation_mask_expanded_boundaries', overwrite=True, )