pub fn run_nextqsm(
total_field_ppm: &[f64],
mask: &[u8],
metadata: &ScanMetadata,
tile: Option<(usize, usize)>,
progress: &mut dyn FnMut(usize, usize),
) -> Result<Vec<f64>, PipelineError>Expand description
Run NeXtQSM end-to-end from the total field (it does its own background removal), sourcing both weight files from the registry.
NeXtQSM spans BFR + dipole inversion, so unlike the other entries in
InversionAlgorithm its input is the total field rather than a local one. It is
reachable both ways: as InversionAlgorithm::Nextqsm through
run_dipole_inversion, and directly here for a caller that wants it standalone.
total_field_ppm and mask are column-major (nx,ny,nz); the grid and B0 direction come
from metadata. Requires the onnx feature; both weight files resolve through crate::models
(supplied bytes first, as for every network). Returns susceptibility (ppm), masked.
Refuses a volume whose slices are not contiguous, like every other stage here: NeXtQSM’s
unrolled data-consistency term is an FFT dipole convolution, so a gap invalidates it as
thoroughly as it does a classical inversion. See
ScanMetadata::require_contiguous_slices.