Skip to main content

Module lpcnn

Module lpcnn 

Source
Expand description

LPCNN dipole inversion (onnx feature).

LPCNN (Lai 2020) solves the dipole deconvolution by unrolling proximal gradient descent (iter_num = 3): each iteration takes a k-space data-consistency step with the dipole kernel D, then applies a learned 3D-CNN proximal operator gen. Only gen is a network (exported ONNX, a plain conv/BN/ReLU residual stack); the FFT data-consistency, the unroll, the learned step size alpha, and the mean/std normalization live here in Rust.

Input is the background-removed local field in ppm (single orientation). The authors’ Hz↔ppm round-trip (×tesla·γ then ÷tesla·γ) cancels, so the field is consumed directly in ppm. Weights are not bundled; the caller passes lpcnn.onnx.

Constants§

ITER_NUM 🔒
LPCNN_ALPHA
Learned data-consistency step size (checkpoint alpha, Bmodel).
LPCNN_GT_MEAN
Ground-truth normalization (ppm), baked into the training pipeline.
LPCNN_GT_STD

Functions§

dipole_apply 🔒
D(v) = real(ifft3(fft3(v)·dk)) with dk in fftfreq (unshifted) layout.
lpcnn
Run LPCNN on a background-removed local field (ppm), column-major (nx,ny,nz). bdir is the B0 direction (for the dipole kernel). Returns χ (ppm), masked.
lpcnn_dipole_kernel 🔒
LPCNN dipole kernel D = 1/3 − (k·B̂)²/|k|² with k from fftfreq (DC at the array corner, D[0,0,0]=0) — the convention the model’s ortho-FFT expects.
lpcnn_tiled
Memory-bounded LPCNN via whole-algorithm overlap-tiling — the entire unrolled net is run on each patch sub-volume so peak memory is bounded (for the 32-bit WASM heap). LPCNN’s k-space data-consistency step is global, so tiling is strongly off-design and approximate; for real work run whole-volume (e.g. in QSMxT). See crate::inversion::tiled::tiled_volume_algorithm.
run_gen 🔒
Run the single-in/single-out proximal CNN on a column-major volume.