Supervoxelization

Note

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

class Supervoxelization(subject_id: str, label_array: ndarray, features: DataFrame, geometry: Geometry, provenance: Provenance)[source]

Bases: object

Within-subject partition of the ROI into supervoxels, plus their features.

Scientific role: supervoxels denoise voxel-level features and reduce the clustering unit from a single voxel to a coherent local region, which is the first step of the two_step strategy.

subject_id

Owning subject.

Type:

str

label_array

Supervoxel id per voxel, shape equal to the ROI grid; 0 denotes voxels outside the ROI.

Type:

numpy.ndarray

features

Index is supervoxel id, columns are aggregated features. This is the payload that a federated deployment would transmit instead of the images themselves.

Type:

pandas.core.frame.DataFrame

geometry

Grid label_array refers to.

Type:

habit.contracts.geometry.Geometry

provenance

How this partition was produced.

Type:

habit.contracts.provenance.Provenance

__post_init__() → None[source]

Coerce the label array and record its dtype for downstream reuse.

feature_frame() → DataFrame[source]

Return the bare unit-by-feature matrix.

The counterpart of VoxelFeatureField.feature_frame(), so one implementation of a matrix-level operation serves both granularities. Here the frame is already the native representation; the supervoxel index is dropped to a positional one so callers cannot accidentally depend on label values during a column-wise computation.

Returns:

Feature matrix with a positional index, in column order.

with_feature_frame(frame: DataFrame, *, produced_by: str, spec_fingerprint: str) → Supervoxelization[source]

Return a copy carrying a recomputed feature matrix.

Parameters:
  • frame – Replacement matrix, row-aligned with the current features. Columns may be fewer; the row count must match, since each row still describes one label of label_array.

  • produced_by – Provenance label of the step that produced frame.

  • spec_fingerprint – Fingerprint of that step’s specification.

Returns:

label_array is inherited unchanged, because describing supervoxels never redraws them.

Return type:

A new partition with the same regions described differently

Raises:

HABITAPIError – If frame has a different number of rows.

__init__(subject_id: str, label_array: ndarray, features: DataFrame, geometry: Geometry, provenance: Provenance) → None

Examples using habit.contracts.Supervoxelization

Feature preprocessing

Feature preprocessing

Supervoxel feature extraction and acceleration

Supervoxel feature extraction and acceleration

Clustering habitats from a derived map

Clustering habitats from a derived map

Clustering habitats from a texture field

Clustering habitats from a texture field

Preprocessing features before clustering

Preprocessing features before clustering

Partitioning a ROI into supervoxels

Partitioning a ROI into supervoxels

Fitting a cohort habitat model

Fitting a cohort habitat model

Assigning habitat labels

Assigning habitat labels

Why habitat ids must be matched

Why habitat ids must be matched

Matching maps of the same voxels by overlap

Matching maps of the same voxels by overlap

Prototype matching step by step

Prototype matching step by step

Naming a new cohort with frozen prototypes

Naming a new cohort with frozen prototypes

What matching changes in a cohort feature table

What matching changes in a cohort feature table

Matching habitat labels across subjects

Matching habitat labels across subjects