Skip to main content

Module inversion

Module inversion 

Source
Expand description

Dipole inversion stage

Dispatcher for standard dipole inversion algorithms. Also contains TGV and QSMART pipeline runners which combine multiple stages internally.

MEDI Hz↔radians conversion is handled internally — the caller passes ppm fields and receives ppm results.

Constants§

IQSM_ERODED_RAD 🔒
IQSM_PHASE_SIGN 🔒
The authors’ fixed inference conventions for the iQSM/iQFM LoT-Unet family: phase sign -1 and a 3-voxel mask-erosion radius. These are training-time constants, not user knobs, so the pipeline runners bake them in.

Functions§

echo_magnitudes 🔒
The echo magnitudes a MEDI-toolbox method requires (MEDI’s edge mask, and the Fit_ppm_complex noise map that MEDI and PDF weight the data by): one volume per echo, echo slowest, for evenly spaced echoes (as Fit_ppm_complex.m assumes). method names the method in the error messages.
heidi_params 🔒
HEIDI’s parameters with the scan’s: NESTA’s result depends on χ’s scale in upstream’s phase units (see the HEIDI module docs), so the field strength and echo times come from metadata, and config.heidi.te picks the echo time of the field (by default the last, as qsm_heidi’s phase2susceptibilityfactor uses).
heidi_seed_problem
Why HEIDI’s cone fill cannot follow config’s inversion, if it cannot (None when HEIDI is off or the seed is allowed). The hard errors of run_heidi_cone_fill, for hosts to check at plan time:
invert 🔒
run_dipole_inversion without HEIDI’s cone fill after a non-LSQR seed.
run_autoqsm 🔒
Source the AutoQSM weights and run inference (requires the onnx feature). field is the total field (AutoQSM does its own background removal).
run_dipole_inversion
Run a dipole inversion on the field its method takes.
run_heidi_cone_fill
HEIDI’s cone fill on a seed χ map: streaking reduction after config’s inversion (crate::inversion::heidi_cone_fill). run_dipole_inversion calls it when InversionConfig::cone_fill_after holds; a host that combines several inversions (two-pass) runs them with apply_heidi off and calls this once on the combined map, for any seed.
run_iqfm
Run iQFM: joint unwrapping + background removal from wrapped phase in one network (the tissue-field head of the iQSM LoT-Unet). Returns the local (background-removed) field in ppm — feed it to any dipole inversion. This is a deep-learning replacement for the unwrap + BFR stages, not an inversion. Multi-echo inputs are combined with echo_weighting, as in run_iqsm. Requires the onnx feature + iqfm weights.
run_iqsm
Run iQSM single-step reconstruction from wrapped phase (joint unwrap + background removal + dipole inversion). Multi-echo inputs are reconstructed per echo and combined with echo_weighting (default (magnitude·TE)², the inverse-variance weight; see IqsmEchoWeighting). Requires the onnx feature + iqsm weights.
run_iqsm_plus
Run iQSM+ single-step reconstruction from wrapped phase (orientation-adaptive variant; the B0 direction is a genuine network input). See run_iqsm; the echoes are combined with (magnitude·TE)² weights, as in both of the authors’ implementations.
run_ir2qsm 🔒
Source the IR2QSM weights and run inference (requires the onnx feature).
run_lpcnn 🔒
Source the LPCNN proximal-CNN weights and run inference (requires the onnx feature). LPCNN’s k-space data-consistency step uses the B0 direction.
run_modl_qsm 🔒
Source the MoDL-QSM prior-CNN weights and run inference (requires the onnx feature). Output is the STI χ33 component.
run_nextqsm
Run NeXtQSM end-to-end from the total field (it does its own background removal), sourcing both weight files from the registry.
run_qsmgan 🔒
Source the QSMGAN generator weights and run inference (requires the onnx feature).
run_qsmnet 🔒
Source a QSMnet-family model’s weights and run inference (requires the onnx feature). model_id selects the registry entry (qsmnet / qsmnet-plus), norm supplies that checkpoint’s normalization constants.
run_qsmnetme 🔒
Source the QSMnetME weights and run it by the authors’ route (requires the onnx feature). tile (the deep-learning inversions’ (core, halo)) turns the toolbox’s whole-volume pass into a sliding window of core + 2·halo rounded up to a multiple of 16, for memory-limited hosts.
run_tgv
Run TGV single-step QSM reconstruction.
run_xqsm 🔒
Source the xQSM weights and run inference. Requires the onnx feature; weights resolve through crate::models (bytes supplied with crate::models::provide_weights, then $QSM_MODEL_DIR/cache/download on native).
scan_echo_times 🔒
The scan’s echo times for a method that converts ppm to radians at the echo time its te choice picks, checked here so the method itself does not panic on them.