ConnectedComponentPostprocess
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 ConnectedComponentPostprocess(*, min_component_size: int = 30, connectivity: int = 1, reassign_method: str = 'neighbor_vote', max_iterations: int = 3)[source]
Bases:
objectClean tiny connected components inside an ROI label map.
- Parameters:
min_component_size – Minimum voxels required to keep a component.
connectivity – Neighborhood connectivity in
{1, 2, 3}.reassign_method – Strategy name reserved for future variants; only
"neighbor_vote"(nearest-seed refill) is implemented.max_iterations – Cleanup iteration cap retained for YAML parity; the current kernel performs a single remove+refill pass.
- __init__(*, min_component_size: int = 30, connectivity: int = 1, reassign_method: str = 'neighbor_vote', max_iterations: int = 3) None[source]
- apply_to_label_array(label_map: ndarray, roi_mask: ndarray) ndarray[source]
Clean a raw label array inside
roi_mask.- Parameters:
label_map – 3D integer label map (0 = background).
roi_mask – 3D boolean ROI mask.
- Returns:
Cleaned int32 label map.
- apply_to_habitat_map(habitat_map: HabitatMap) HabitatMap[source]
Return a cleaned copy of a habitat label map.
ROI is
label_array > 0.habitat_idsstay the model’s assignable set (unchanged), matching the contract that ids are model capability rather than presence in one subject.- Parameters:
habitat_map – Habitat labels for one subject.
- Returns:
New
HabitatMapwith cleaned labels and derived provenance.
- apply_to_supervoxelization(units: Supervoxelization, field: VoxelFeatureField) Supervoxelization[source]
Clean a supervoxel partition and re-aggregate feature means.
Features must be recomputed after label reassignment so the feature matrix stays row-aligned with the surviving supervoxel ids.
- Parameters:
units – Supervoxel partition to clean.
field – Per-voxel features used to rebuild region means.
- Returns:
New
Supervoxelizationwith cleaned labels and means.- Raises:
HABITAPIError – If
fieldandunitsdisagree on subject or geometry shape.