dti_advisories
tit.pre.qsi.dti_advisories ¶
Non-blocking DTI checks and provenance recorded in DTI_coregT1_qc.json (numpy/scipy only).
The QC gate in :mod:tit.pre.qsi.dti_extractor decides whether a tensor is written; the advisories
here are measured on the same tensor, never block (ARCHITECTURE.md §9, §14), and are stored as
tit.reporting.html.components.Check records whose label, role, citation and plain text come
from tit.reporting.qc_rules.RULES["dti"]. The numbers behind them go to metrics.
Everything works on world-frame tensors in a canonical RAS voxel order (:class:DtiVolumes), so
the numbers do not depend on how the grid is stored on disk. Cost on CHN (176 x 256 x 256, 1.4 M
tensors): about 9 s on an Apple M-series host, most of it the flip test and the residual-shift
search; hashing the 2 GB DWI for provenance adds a few seconds.
DtiVolumes
dataclass
¶
World-frame tensors and their anatomy on one canonical (RAS voxel order) grid.
t6w holds (X, Y, Z, 6) world tensors in FSL order, zero where no tensor was written;
mni is charm's Conform2MNI_nonl warp on the same grid (MNI mm per voxel) or None.
load_volumes ¶
load_volumes(m2m_dir: Path, tensor_path: Path | None = None) -> DtiVolumes
Read the written tensor (SimNIBS frame), T1, labels and MNI warp of one m2m folder.
Source code in tit/pre/qsi/dti_advisories.py
tissue_stats ¶
Median, IQR and a normalised histogram of FA and MD per charm tissue (WM, GM, CSF).
Source code in tit/pre/qsi/dti_advisories.py
tract_orientation ¶
Share of high-FA voxels in three landmark tracts whose V1 lies along the expected world axis.
Source code in tit/pre/qsi/dti_advisories.py
flip_test ¶
flip_test(t6w: ndarray, affine: ndarray, fa_vol: ndarray, labels: ndarray, step_mm: float = 1.5, n_seeds: int = 60000) -> dict
Fibre coherence of V1 for every axis permutation and sign flip of the gradient table.
From WM seeds with FA > 0.5, step step_mm along the transformed V1 both ways and score
|V1_seed . V1_neighbour|. A correct table scores highest as written (Jeurissen et al.
2014); a flipped or permuted one breaks the continuity of tracts.
Source code in tit/pre/qsi/dti_advisories.py
residual_shift ¶
residual_shift(fa_vol: ndarray, labels: ndarray, affine: ndarray, mni: ndarray, limit_mm: int = 5, max_voxels: int = 200000) -> dict
Per region, the world A–P and S–I shift of smoothed FA that best matches charm WM.
A positive value moves FA anterior / superior, so +3 means FA sits 3 mm posterior of the
anatomy. Coarse-to-fine: every 2 mm within ±4 mm, then a 1 mm neighbourhood of each region's
best, within ±limit_mm. The search space is the same as an exhaustive 1 mm grid for any
smooth, single-peaked correlation surface, at a fraction of its cost.
Source code in tit/pre/qsi/dti_advisories.py
fix_eigv ¶
SimNIBS 4.6 cond_utils._fix_eigv on descending eigenvalues (column 0 is the largest).
Source code in tit/pre/qsi/dti_advisories.py
vn_eigenvalues ¶
vn_eigenvalues(e: ndarray, c: float, max_cond: float = MAX_COND, max_ratio: float = MAX_RATIO) -> ndarray
Conductivity eigenvalues of vn: normalise to unit volume, clamp, renormalise, clamp, times c.
Source code in tit/pre/qsi/dti_advisories.py
conductivity_preview ¶
How often SimNIBS's anisotropy clamps bind in WM: the ratio cap (any mode) and vn's aniso_maxcond.
Source code in tit/pre/qsi/dti_advisories.py
sdc_status ¶
What QSIPrep reported for susceptibility distortion correction, and the DWI fieldmaps on disk.
Source code in tit/pre/qsi/dti_advisories.py
acquisition ¶
Scanner, shells and QSIPrep settings from QSIPrep's own output files.
Source code in tit/pre/qsi/dti_advisories.py
motion ¶
Framewise displacement per volume and QSIPrep's image-quality numbers.
Source code in tit/pre/qsi/dti_advisories.py
advisories ¶
advisories(metrics: dict, sdc: dict, mot: dict, acq: dict, reference_fa: float | None = None) -> list[dict]
The non-blocking rows, as QC-check records: advisories (warn, never block) and reported values.
Label, rule text, role and citations come from tit.reporting.qc_rules.RULES["dti"].
Source code in tit/pre/qsi/dti_advisories.py
452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 | |
measure ¶
measure(vols: DtiVolumes) -> dict
Every tensor-derived number the report shows: tissue statistics, orientation, flip test, shifts.
Source code in tit/pre/qsi/dti_advisories.py
compute ¶
compute(vols: DtiVolumes, qsiprep_sub: Path, bids_sub: Path, reference_fa: float | None = None) -> dict
The QC-JSON additions: advisories, metrics, acquisition, motion, sdc.
reference_fa is the reference subject's WM median FA (:func:reference), shown beside this one's.
Source code in tit/pre/qsi/dti_advisories.py
provenance ¶
provenance(inputs: dict[str, Path], config: dict, project_dir: Path, qsiprep_version: str | None, recorded_by: str) -> dict
Software versions, input SHA-256s (paths relative to the project) and the configuration hash.
Source code in tit/pre/qsi/dti_advisories.py
reference ¶
White-matter median FA of the project's ernie tensor (SimNIBS's example subject), if it has one.