habitat_stability
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.
- habitat_stability(reference: HabitatMap, perturbed: Sequence[HabitatMap]) DataFrame[source]
Score habitat stability between a reference map and perturbed maps.
Each perturbed map is paired to the reference by maximal voxel overlap (the Prior 2024 Hungarian /
munkresstep, the same pairing asalign_habitat_map()), then ordinary Dice is computed on that pair:2 * intersection / (n_reference + n_matched), where the two counts are voxel sizes of one reference habitat and its matched perturbed habitat. Unmatched reference habitats (fewer clusters on the perturbed map) score Dice 0.This function does not rewrite the input maps. Pass the original independently clustered pair, not a map that was already remapped.
- Parameters:
reference – Habitat map of the original subject.
perturbed – Habitat maps computed independently on perturbed copies, each on the same voxel grid as
reference.
- Returns:
Long-format DataFrame with one row per perturbation per reference habitat:
perturbation(positional index),habitat_id,matched_id(NA when unmatched),dice,n_referenceandn_matchedvoxel counts.- Raises:
HABITAPIError – If no perturbed map is given or the grids differ.