Skip to main content

Module nextqsm

Module nextqsm 

Source
Expand description

NeXtQSM single-step deep-learning reconstruction (onnx feature).

NeXtQSM (Cognolato 2023) is a hybrid method: a background-removal U-Net followed by a 6-step variational dipole inversion. Each variational step is a gradient-descent update x ← x − (λ_k·∇E_D + ∇E_R)·mask, where E_D is an RMSE data-consistency term through the FFT dipole forward and E_R = mean(|VarNet(x)|) is a learned regularizer whose gradient is a backprop through the VarNet U-Net.

The two U-Net pieces run as ONNX (nextqsm-bf.onnx = BFR forward; nextqsm-vjp.onnx = the regularizer gradient ∇ₓ mean(|VarNet(x)|), hand-coded as a forward graph). The FFT data-consistency gradient and the unroll live here in Rust (rustfft), since tract can’t do in-graph FFT.

Weights are not bundled; the caller passes both ONNX byte buffers.

Constants§

NEXTQSM_LAMBDAS
Trained data-consistency weights λ_k (one per variational step) shipped with the NeXtQSM checkpoint. Scalars, like a normalization constant.

Functions§

dipole_forward 🔒
Dipole forward D(y) = real(ifft3(fft3(y) · kernel_shifted)).
dipole_kernel_shifted 🔒
fftshift(get_dipole_kernel_fourier(...)) in column-major layout.
l2 🔒
nextqsm
Run NeXtQSM on a total field map.
nextqsm_padded
NeXtQSM on a grid already sized to a multiple of 64 (no internal padding). Exposed for validation against the reference trajectory.
nextqsm_tiled
Memory-bounded NeXtQSM via whole-algorithm overlap-tiling — the full VarNet gradient-descent loop runs on each patch sub-volume (each internally padded to /64). NeXtQSM’s forward model is global, so tiling is strongly off-design and approximate; prefer a whole-volume run (e.g. QSMxT). See crate::inversion::tiled::tiled_volume_algorithm.
run_unet 🔒
Run a single-input/single-output 3D U-Net ONNX on a column-major volume.