tract_similarity — per-patient/cohort tract similarity#
Schema: TractSimilarityConfig in src/thesis/core/config/validators.py. Drives the tract_similarity (per-patient) and tract_similarity_cohort (cohort) workflows. Both compare native-space tractography density against a warped cohort mean atlas.
Top-level fields#
Field |
Type |
Default |
Constraints |
Description |
|---|---|---|---|---|
|
|
|
— |
Relative path to the tractography output directory. Auto-detects single-run vs hemisphere-split ( |
|
|
|
— |
Filename of the density volume within each run directory. |
|
|
|
— |
Filename of the waytotal text file within each run directory. MRtrix3 writes this as |
|
|
|
— |
Relative path or glob pattern for the warped cohort mean atlas in patient space (typically produced by |
|
|
|
— |
Binarisation threshold for the subject’s tractography volume. See below. |
|
|
|
— |
Binarisation threshold for the warped atlas volume. |
|
|
|
|
Histogram bin count for normalised mutual information. |
|
|
|
— |
Patient-level output subdirectory for |
|
|
|
— |
Cohort-level output subdirectory for aggregated metrics. |
|
|
|
— |
Per-HCP-subject leave-one-out comparison against the cohort atlas. See below. |
subject_threshold / atlas_threshold — SideThresholdConfig#
Field |
Type |
Default |
Constraints |
Description |
|---|---|---|---|---|
|
|
|
— |
|
|
|
|
|
Threshold value. |
hcp_loo — HcpLooConfig#
Drives the cohort-scope tract_similarity_hcp_loo workflow, which emits per-HCP-subject metrics (full four-family suite) against an in-memory leave-one-out cohort mean atlas. The artefacts mirror the per-patient layout, so the cohort aggregator (tract_similarity_cohort) and downstream notebooks pick HCP rows up alongside patient rows automatically.
Field |
Type |
Default |
Constraints |
Description |
|---|---|---|---|---|
|
|
|
|
Minimum cohort size. LOO is mathematically valid at 2; the floor of 3 enforces a meaningful cohort reference. |
|
|
|
— |
If true, write |
Invoke with thesis run -w tract_similarity_hcp_loo -c <profile>. Use this when you want unbiased HCP-vs-atlas dice (and the other three metric families) directly comparable to the per-patient metrics produced by tract_similarity.
Metric families#
The per-patient metrics.json contains four metric families:
Family |
Metrics |
|---|---|
|
Dice, Jaccard, subject_voxels, atlas_voxels, intersection, union |
|
Pearson, Spearman, cosine |
|
Hausdorff-95, mean-surface, centroid_distance |
|
NMI, symmetric KL, Bhattacharyya |
The cohort workflow emits summary.csv, per_patient.csv, and outliers.json.
Example#
tract_similarity:
probtrackx_relpath: tractography/probtrackx2
fdt_name: fdt_paths.nii.gz
waytotal_name: waytotal
atlas_relpath: "atlas_in_patient_space/atlas_mean*.nii.gz"
subject_threshold:
mode: fraction
value: 0.05
atlas_threshold:
mode: fraction
value: 0.05
n_bins: 64
output_subdir: tract_similarity
cohort_output_subdir: cohort/tract_similarity
Notes#
The workflow is registered twice —
tract_similarityfor per-patient runs andtract_similarity_cohort(cohort-level,scope="cohort") for aggregation. Both share this config block.For grid-searching the thresholds, see
tract_similarity_sweep.full_pipelineauto-runstract_similarityas its final stage; the CLI then surfaces headline Dice/Pearson/Hausdorff95/NMI in the run summary.