plot_habitat_label_compare
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.
- plot_habitat_label_compare(image: np.ndarray, labels_a: np.ndarray, labels_b: np.ndarray, *, titles: Tuple[str, str] = ('Reference', 'Predict'), alpha: float = 1.0, axis: int = 0, index: int | None = None, direction: Sequence[float] | None = None, spacing: Sequence[float] | None = None, display_convention: DisplayConvention = 'radiological', show_disagreement: bool = True, colorbar: ColorbarSpec = True, colorbar_label: str = 'Habitat', align_labels: bool | None = None, crop_to: str = 'none', crop_pad: int = 6) Figure[source]
Side-by-side habitat overlays, optional disagreement mask.
Independently clustered maps permute integer ids. By default this remaps
labels_b(panel 2 only) ontolabels_aby maximal voxel overlap – the same Hungarian pairinghabitat_stability()uses – before colouring and before the disagreement panel. Habitat 2 on the left is then the same spatial region as habitat 2 on the right. Disagreement isaligned_b != aon labelled voxels, not raw id inequality. Maps that already share amodel_id(apply-saved-model, or maps renamed byalign_habitat_maps_to_prototypes()) are left unchanged – those ids are already the same definition.- Parameters:
image – Anatomy volume
(z, y, x)or 2D.labels_a – Reference / train labels (same shape).
labels_b – Compared / predicted labels (same shape).
titles – Panel titles for A and B.
alpha – Overlay opacity (default
1.0= opaque habitat colours).axis – Slice axis for 3D volumes.
index – Slice index; densest union of labels when omitted.
direction – Optional SimpleITK direction cosines.
spacing – Optional SimpleITK spacing
(x, y[, z]).display_convention – Radiological / neurological / native.
show_disagreement – If True, add a third panel for label mismatch.
colorbar – Discrete habitat-ID colorbar on the last habitat panel (default
True). The disagreement panel is not a habitat map and does not get this bar. PassFalseto hide it.colorbar_label – Colorbar label (English default
"Habitat").align_labels –
None(default) aligns unless both inputs share amodel_id;Truealways aligns;Falsenever aligns. Independentone_stepfits on the same subject share a model_id (spec + subject-id digest) and needTrue.crop_to –
"none"(default) draws the full field of view;"labels"zooms every panel to the bounding box of the union of non-background voxels in both maps so a small tumour fills the frame. Display-only zoom: values, spacing and orientation are unchanged.crop_pad – Voxels of anatomical context kept around the bounding box when
crop_to="labels"(default6).
- Returns:
A matplotlib
Figure.