extract_graph_features

Note

This page is a reference documentation. It only explains the function signature, and not how to use it. Please refer to the Habitat Guide and Python API guide (v2.0) for usage.

extract_graph_features(label_array: ndarray, *, options: HabitatGraphFeatureOptions | None = None, expected_labels: Sequence[int] | None = None, **kwargs: Any) → Dict[str, float][source]

Extract subject-level graph features from a habitat label map.

Default options use node_method='uniform_grid' (8-voxel cubes, one node per in-cell subregion centroid) and edge_method='min_distance' with distance_threshold=5.0. Pass node_method='component' / edge_method='adjacency' for the older connected-component contact graph.

Keyword arguments that match HabitatGraphFeatureOptions fields may be passed directly (for example extract_graph_features(labels, include_extended_metrics=False)). When both options and kwargs are given, kwargs override individual fields via dataclasses.replace().

Parameters:
  • label_array – Already segmented habitat map. Label 0 is treated as background and excluded from graph construction. A full-CT lattice is cropped to the tumour VOI before nodes, edges, metrics, and size-normalized companions are computed.

  • options – Graph construction and metric options. When None, a default instance is built (optionally from kwargs).

  • expected_labels – Optional canonical habitat ids to report. When given, every listed label produces its single_h* columns and every unordered pair its pair_h*_h* columns even when the label is absent from this subject (empty graphs yield zero-valued metrics), so cohort-level tables have stable columns. When None, only labels actually present in label_array are reported (the historical v0.1 behaviour).

  • **kwargs – Optional field overrides for HabitatGraphFeatureOptions (merged as described above).

Returns:

Flat feature dictionary ready for table assembly.

Return type:

Dict[str, float]

Examples using habit.kernels.extract_graph_features

Graph features

Graph features