Skip to main content

qsm_core/
lib.rs

1//! # QSM-Core
2//!
3//! A Rust library for Quantitative Susceptibility Mapping (QSM) of the brain.
4//!
5//! QSM-Core provides a complete set of algorithms for reconstructing magnetic
6//! susceptibility maps from MRI phase data, including brain extraction, phase
7//! unwrapping, background field removal, dipole inversion, and susceptibility
8//! source separation.
9//!
10//! ## Pipeline Overview
11//!
12//! A typical QSM pipeline follows these steps:
13//!
14//! 1. **Brain extraction** ([`bet`]) — mask the brain region from magnitude images
15//! 2. **Phase unwrapping** ([`unwrap`]) — remove 2π wraps from MRI phase data
16//! 3. **Background field removal** ([`bgremove`]) — isolate the local field from background sources
17//! 4. **Dipole inversion** ([`inversion`]) — reconstruct susceptibility from the local field
18//!
19//! Additional processing modules:
20//!
21//! - **SWI** ([`swi`]) — Susceptibility Weighted Imaging (CLEAR-SWI)
22//! - **Chi-separation** ([`separation`]) — decompose susceptibility into paramagnetic/diamagnetic components
23//! - **Multi-echo processing** ([`utils`]) — R2\*/T2\* mapping, phase combination (MCPC-3D-S), bias correction
24//!
25//! ## Feature Flags
26//!
27//! - **`parallel`** — enables [Rayon](https://docs.rs/rayon)-based multi-threading for FFT and iterative solvers
28//! - **`simd`** — enables SIMD acceleration via the [`wide`](https://docs.rs/wide) crate
29//!
30//! ## Algorithms
31//!
32//! | Stage | Methods |
33//! |-------|---------|
34//! | Brain extraction | BET |
35//! | Phase unwrapping | ROMEO, Laplacian |
36//! | Background removal | V-SHARP, SHARP, PDF, iSMV, LBV, SDF |
37//! | Dipole inversion | TKD, TSVD, Tikhonov, TV-ADMM, NLTV, RTS, MEDI, TGV, iLSQR |
38//! | SWI | CLEAR-SWI |
39//! | Separation | Chi-separation (MEDI-based) |
40//! | Multi-echo | MCPC-3D-S, R2\*/T2\* (ARLO), bias correction |
41//! | Utilities | Frangi vesselness, surface curvature, Otsu thresholding, QSMART |
42
43// Conditional parallelism (must be first for macro visibility)
44#[macro_use]
45pub mod par;
46
47// Core modules
48pub mod fft;
49pub mod priority_queue;
50pub mod region_grow;
51
52// Algorithm modules
53pub mod kernels;
54pub mod unwrap;
55pub mod bgremove;
56pub mod inversion;
57pub mod separation;
58pub mod solvers;
59pub mod utils;
60pub mod swi;
61
62// I/O modules
63pub mod nifti_io;
64
65// Brain extraction
66pub mod bet;