SlicSupervoxelizer
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 SlicSupervoxelizer(n_supervoxels: int = 100, compactness: float = 10.0, enforce_connectivity: bool = True, estimator_params: Mapping[str, Any] | None = None)[source]
Bases:
objectPartition the ROI into SLIC supervoxels and average features within each.
SLIC (Simple Linear Iterative Clustering) groups spatially coherent, feature-similar voxels; the v0.1 pipeline exposed the same algorithm through its clustering factory. Here it is one ordinary subject-level operator: field in, partition out.
Implements
Seedableso every supervoxelizer shares the same seeding surface as kmeans/gmm and soHabitatSpec.random_seedreaches this stage during assembly. The currentskimage.segmentation.slicbackend has no RNG parameter;set_random_statetherefore records the seed for API uniformity and future backends without changing today’s deterministic partitions.- Parameters:
n_supervoxels – Requested number of supervoxels. Clamped to the number of ROI voxels (a partition cannot have more non-empty regions than voxels).
compactness – Balance between colour similarity and spatial proximity (
skimage.segmentation.slicsemantics).enforce_connectivity – When
True, disconnected segments are relabelled so every supervoxel is connected.estimator_params – Extra keyword arguments forwarded verbatim to
skimage.segmentation.slic(e.g.{"sigma": 1.0}), for vendor parameters HABIT does not declare. Keys colliding with a declared parameter or with a call argument HABIT controls (n_segments,mask,channel_axis,start_label) are rejected, and every key is validated against the vendor signature at call time: a key recorded in the spec fingerprint must reach the vendor function, never be silently dropped.
- __init__(n_supervoxels: int = 100, compactness: float = 10.0, enforce_connectivity: bool = True, estimator_params: Mapping[str, Any] | None = None) None[source]
- set_random_state(seed: int) None[source]
Record the study seed for this supervoxelizer.
- Parameters:
seed – Non-negative study seed from
HabitatSpec.random_seedor an explicit caller. Stored for Seedable uniformity; the current skimage SLIC call does not consume it.
- __call__(field: VoxelFeatureField) Supervoxelization[source]
Group voxels into supervoxels and aggregate their features.
- Parameters:
field – Per-voxel features for one subject.
- Returns:
The supervoxel partition (
0= outside ROI,1..K= supervoxels) together with per-supervoxel mean features. Pass aSupervoxelFeatureExtractorto the pipeline to describe the same regions differently.