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: object

Partition 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 Seedable so every supervoxelizer shares the same seeding surface as kmeans/gmm and so HabitatSpec.random_seed reaches this stage during assembly. The current skimage.segmentation.slic backend has no RNG parameter; set_random_state therefore 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.slic semantics).

  • 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]
property spec: Spec

Return the algorithm specification.

set_random_state(seed: int) → None[source]

Record the study seed for this supervoxelizer.

Parameters:

seed – Non-negative study seed from HabitatSpec.random_seed or 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 a SupervoxelFeatureExtractor to the pipeline to describe the same regions differently.

Examples using habit.supervoxel.SlicSupervoxelizer

Supervoxel feature extraction and acceleration

Supervoxel feature extraction and acceleration

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