.. _sphx_glr_auto_examples_06_matching:
6. Matching Habitat Labels
==========================
**Background.** A clustering run numbers its habitats in arbitrary order,
so the same tissue can be habitat 1 in one run or patient and habitat 3 in
another (**label switching**). **Purpose.** These pages show how HABIT
matches the ids so that Dice, volume fractions and cohort tables compare
like with like.
Calling it on a fitted study:
:doc:`/auto_examples/06_matching/plot_07_match_labels`.
The pages below show why ids switch and how each matcher works.
Habitat ids from independent clusterings are arbitrary: habitat 1 of one
fit can be habitat 3 of another. Anything that compares habitats by id
(Dice, volume fractions, a cohort feature table) must match the ids
first. HABIT has two matchers, chosen by what the two sides share:
* **Voxel overlap** -- the maps label the *same voxels* (a restart,
another ``k``, another feature set, a perturbed image, a second reader).
Hungarian assignment on the voxel-overlap table.
:func:`~habit.precision.align_habitat_map`,
:func:`~habit.precision.habitat_stability`.
* **Shared prototypes** -- the maps label *different subjects*. Each
subject's habitat summaries are matched one-to-one onto ``K`` shared
prototypes, iterated until stable; prototypes can be frozen to name a
new cohort. :func:`~habit.precision.align_habitat_maps_to_prototypes`.
A shared cohort model (two-step, direct pooling, an applied saved model)
already uses one id space and needs neither. Formulas, proofs, and
literature: :doc:`/reference/habitat_matching`.
.. raw:: html
.. thumbnail-parent-div-open
.. raw:: html
.. only:: html
.. image:: /auto_examples/06_matching/images/thumb/sphx_glr_plot_01_label_switching_thumb.png
:alt:
:doc:`/auto_examples/06_matching/plot_01_label_switching`
.. raw:: html
Why habitat ids must be matched
.. raw:: html
.. only:: html
.. image:: /auto_examples/06_matching/images/thumb/sphx_glr_plot_02_overlap_cases_thumb.png
:alt:
:doc:`/auto_examples/06_matching/plot_02_overlap_cases`
.. raw:: html
Matching maps of the same voxels by overlap
.. raw:: html
.. only:: html
.. image:: /auto_examples/06_matching/images/thumb/sphx_glr_plot_03_prototype_steps_thumb.png
:alt:
:doc:`/auto_examples/06_matching/plot_03_prototype_steps`
.. raw:: html
Prototype matching step by step
.. raw:: html
.. only:: html
.. image:: /auto_examples/06_matching/images/thumb/sphx_glr_plot_04_prototype_metrics_thumb.png
:alt:
:doc:`/auto_examples/06_matching/plot_04_prototype_metrics`
.. raw:: html
Choosing the distance for prototype matching
.. raw:: html
.. only:: html
.. image:: /auto_examples/06_matching/images/thumb/sphx_glr_plot_05_frozen_prototypes_thumb.png
:alt:
:doc:`/auto_examples/06_matching/plot_05_frozen_prototypes`
.. raw:: html
Naming a new cohort with frozen prototypes
.. raw:: html
.. only:: html
.. image:: /auto_examples/06_matching/images/thumb/sphx_glr_plot_06_downstream_tables_thumb.png
:alt:
:doc:`/auto_examples/06_matching/plot_06_downstream_tables`
.. raw:: html
What matching changes in a cohort feature table
.. raw:: html
.. only:: html
.. image:: /auto_examples/06_matching/images/thumb/sphx_glr_plot_07_match_labels_thumb.png
:alt:
:doc:`/auto_examples/06_matching/plot_07_match_labels`
.. raw:: html
Matching habitat labels across subjects
.. thumbnail-parent-div-close
.. raw:: html
.. toctree::
:hidden:
/auto_examples/06_matching/plot_01_label_switching
/auto_examples/06_matching/plot_02_overlap_cases
/auto_examples/06_matching/plot_03_prototype_steps
/auto_examples/06_matching/plot_04_prototype_metrics
/auto_examples/06_matching/plot_05_frozen_prototypes
/auto_examples/06_matching/plot_06_downstream_tables
/auto_examples/06_matching/plot_07_match_labels