Expand description
AutoQSM single-step deep-learning reconstruction (onnx feature).
AutoQSM (Wei 2019) is a patch V-Net that maps a total field (ppm) directly
to susceptibility (ppm) — no brain extraction, no separate background removal.
The network takes a fixed 64³ input patch and returns the central 32³. Whole
volumes are reconstructed by overlap-tiled sliding-window inference: 32³ output
patches at stride 24 (8-voxel overlap), each from a 64³ input patch with a
16-voxel context margin, edge-padded and linearly blended across the overlap.
This mirrors the authors’ util.data_predict / patch_process.
Upstream weights are Keras; QSM.rs ships a clean PyTorch re-export
(scripts/onnx-export/export_autoqsm.py) so tract runs it. The network is
all Conv3D+ReLU with no normalization, so no input scaling is applied.
Field sign. AutoQSM was trained on fields of the opposite sign to this
crate’s (field = D * chi with D = 1/3 - kz^2/k^2, so a paramagnetic source
raises the field along B0). On the authors’ own test_data/0.mat input the
network returns bright deep grey matter, while the same field read in this
crate’s convention (SHARP + TKD) anticorrelates with that output (r = -0.42);
fed this crate’s field unchanged it returns -chi-like maps (r = -0.50 on the
test phantom). The field is therefore negated on the way in: the network sees
its own training convention and its output is already susceptibility in ppm
with the usual sign. The network is non-linear, so negating the output instead
would not be equivalent.
Weights are not bundled; the caller passes the exported autoqsm.onnx bytes.
§Reference pipeline
From Wei et al., NeuroImage 2019 (doi:10.1016/j.neuroimage.2019.116064), Methods:
- Training data: 3T GE MR750, 0.86×0.86×1 mm (reconstructed), 256×256 matrix, 8 echoes.
- Input: Laplacian-unwrapped total phase of every echo, combined as
ψ = Σφᵢ / (γ·B0·ΣTEᵢ)(a TE-weighted mean ofφ/TE) — a total field in ppm over the whole FOV, no brain mask. Labels were STAR-QSM after SMV background removal, masked with FSL BET. - Orientation: training inputs are axial; sagittal/coronal data “should be resliced to the axial orientation”.
- Resampling: the authors’
code/test.pyandutil.data_predictdo not resample.
§Agreement with the original
tests/models_onnx/field.rs runs it on a 36×32×28 box of in-vivo data (1 mm, 2.89 T, across the
brain’s edge) against its original’s verified QSM-CI entry, AutoQSM b59f5e7 (autoqsm)
(QSMxT/QSM-CI#316; the fixture is regenerated in Actions by
tests/data/dl_field_qsmci_small.py): NRMSE 1.8e-4 %, max |Δ| 2.5e-7 ppm (measured 2026-10-30):
float32 rounding.
§Pipeline rules
The facts above that a configuration can depart from are published as rules in
crate::pipeline::rules::RULES (each with its strength, basis, reason and source): autoqsm.unwrap-laplacian, autoqsm.echo-combination, autoqsm.echo-weights.
Constants§
Functions§
- autoqsm
- Run AutoQSM on a total field map.
- blend 🔒
- Blend the leading
OVERLAPslabs ofpatchwith the trailing slabs of a previously-placedneighboralongdir(0=x,1=y,2=z), ramping neighbor→patch (matchesutil.patch_process). - output_
extent 🔒 - The output-grid extent for an axis of
dvoxels: the smallest whole number of output patches (OUT, then one more perSHIFT) that covers it. An axis shorter than one patch gets one patch; the samples pastdare edge-padded and cropped away. - ri 🔒