troutpy.pp.add_morphological_metrics#
- troutpy.pp.add_morphological_metrics(sdata, labels_key='cell_labels', copy=False)#
Extract cell morphology metrics from a labels layer and add them to
sdata.table.obs.Computes region properties (area, perimeter, solidity, axis lengths) via
skimage.measure.regionprops_tableand derives circularity, protrusion length, and morphological complexity. Existing overlapping columns are replaced.- Parameters:
sdata (spatialdata.SpatialData) – SpatialData object that must contain a
"table"AnnData and the specified labels layer.labels_key (str) – Key in
sdata.labelsidentifying the segmentation label image.copy (bool, optional) – If
True, operate on a copy ofsdataand return it. Otherwise modify in place and returnNone. Defaults toFalse.
- Return type:
- Returns:
spatialdata.SpatialData or None Updated SpatialData with morphology columns added to
sdata.table.obsifcopy=True; otherwiseNone.- Raises:
ValueError – If
sdatadoes not contain a"table"AnnData object.