squidpy.im.ImageContainer.features_segmentation

ImageContainer.features_segmentation(label_layer, intensity_layer=None, library_id=None, feature_name='segmentation', channels=None, props=('label', 'area', 'mean_intensity'))

Calculate segmentation features using skimage.measure.regionprops().

Features are calculated using label_layer, a cell segmentation of intensity_layer, resulting from from calling e.g. squidpy.im.segment().

Depending on the specified parameters, mean and std of the requested props are returned. For the ‘label’ feature, the number of labels is returned, i.e. the number of cells in this image.

Parameters:
  • label_layer (str) – Name of the image layer used to calculate the non-intensity properties.

  • intensity_layer (Optional[str]) – Name of the image layer used to calculate the intensity properties.

  • library_id (Optional[str]) – Name of the Z-dimension that this function should be applied to.

  • feature_name (str) – Base name of feature in resulting feature values dict.

  • channels (Union[int, Sequence[int], None]) – Channels for this feature is computed. If None, use all channels. Only relevant for features that use the intensity_layer.

  • props (Sequence[str]) –

    Segmentation features that are calculated. See properties in skimage.measure.regionprops_table(). Each feature is calculated for each segment (e.g., nucleus) and mean and std values are returned, except for ‘centroid’ and ‘label’. Valid options are:

    • ’area’ - number of pixels of segment.

    • ’bbox_area’ - number of pixels of bounding box area of segment.

    • ’centroid’ - centroid coordinates of segment.

    • ’convex_area’ - number of pixels in convex hull of segment.

    • ’eccentricity’ - eccentricity of ellipse with same second moments as segment.

    • ’equivalent_diameter’ - diameter of circles with same area as segment.

    • ’euler_number’ - Euler characteristic of segment.

    • ’extent’ - ratio of pixels in segment to its bounding box.

    • ’feret_diameter_max’ - longest distance between points around convex hull of segment.

    • ’filled_area’ - number of pixels of segment with all holes filled in.

    • ’label’ - number of segments.

    • ’major_axis_length’ - length of major axis of ellipse with same second moments as segment.

    • ’max_intensity’ - maximum intensity of intensity_layer in segment.

    • ’mean_intensity’ - mean intensity of intensity_layer in segment.

    • ’min_intensity’ - min intensity of intensity_layer in segment.

    • ’minor_axis_length’ - length of minor axis of ellipse with same second moments as segment.

    • ’orientation’ - angle of major axis of ellipse with same second moments as segment.

    • ’perimeter’ - perimeter of segment using 4-connectivity.

    • ’perimeter_crofton’ - perimeter of segment approximated by the Crofton formula.

    • ’solidity’ - ratio of pixels in the segment to the convex hull of the segment.

Return type:

dict[str, Any]

Returns:

: Returns features with the following keys:

  • '{feature_name}_label' - if ‘label` is in props.

  • '{feature_name}_centroid' - if ‘centroid` is in props.

  • '{feature_name}_{p}_mean' - mean for each non-intensity property p in props.

  • '{feature_name}_{p}_std' - standard deviation for each non-intensity property p in props.

  • '{feature_name}_ch-{c}_{p}_mean' - mean for each intensity property p in props and channel c in channels.

  • '{feature_name}_ch-{c}_{p}_std' - standard deviation for each intensity property p in props and channel c in channels.