Skip to main content

qsm_core/pipeline/
mod.rs

1//! QSM pipeline stages and utilities
2//!
3//! Shared stage functions that both qsmxt.rs and qsmbly call to ensure
4//! identical processing. Each consumer calls the stages individually with
5//! its own I/O and caching layer on top.
6//!
7//! ## Pipeline stages (typical order)
8//!
9//! 1. [`run_field_mapping`] — multi-echo phase → B0 field map (ppm)
10//! 2. [`run_bg_removal`] — total field → local field (ppm)
11//! 3. [`run_dipole_inversion`] — local field → susceptibility (ppm)
12//! 4. [`apply_reference`] — mean subtraction
13//!
14//! For TGV, use [`run_tgv`] which combines steps 1-4 internally.
15//!
16//! ## Combined algorithms
17//!
18//! - HARPERELLA: SMV-based exterior Laplacian estimation (Li et al., 2014)
19//! - iHARPERELLA: Phase-domain exterior estimation with improved low-freq suppression (Li et al., 2015)
20
21// HARPERELLA / iHARPERELLA live in `bgremove` (their single canonical home);
22// the pipeline uses them via `crate::bgremove::...`.
23
24// Pipeline stage modules
25pub mod config;
26pub mod phase_utils;
27pub mod referencing;
28pub mod masking;
29pub mod field_mapping;
30pub mod bg_removal;
31pub mod inversion;
32pub mod separation;
33pub mod qsmart;
34
35pub use config::*;
36pub use phase_utils::{
37    scale_phase_to_pi, hz_to_ppm, rads_to_ppm, rss_combine,
38    erode_mask, dilate_mask,
39};
40pub use referencing::apply_reference;
41pub use masking::{apply_mask_ops, build_mask_section, run_masking};
42pub use field_mapping::run_field_mapping;
43pub use bg_removal::run_bg_removal;
44pub use inversion::{run_dipole_inversion, run_tgv, run_nextqsm, run_iqsm, run_iqsm_plus, run_iqfm};
45pub use separation::{run_separation, SeparationInputs, SeparationResult};
46pub use qsmart::run_qsmart;