msi_features_from_matrix
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.
- msi_features_from_matrix(matrix: ndarray) Dict[str, float][source]
Derive the MSI feature set from a spatial interaction matrix.
Replicates the v0.1
MSIFeatureExtractor.calculate_MSI_featuresdefinition exactly, so migrated features stay numerically comparable with previously published results:first-order counts
firstorder_{i}_and_{j}for the strict upper triangle (including the background row) plus the non-background diagonal;the same entries normalised by the sum of the lower triangle with the background row removed (zero denominator yields all-zero normalised features, as in v0.1);
second-order
contrast/homogeneity/correlation/energycomputed on the normalised matrix (correlation falls back to1.0when a marginal standard deviation vanishes).
- Parameters:
matrix – Square non-negative interaction matrix, typically from
spatial_interaction_matrix().- Returns:
Feature name to value mapping with the exact v0.1 key scheme.
- Raises:
ValueError – If the matrix is not square or contains negatives.