Skip to main content

get_sensitivity

Function get_sensitivity 

Source
pub fn get_sensitivity(
    mag: &[f64],
    grid: &Grid,
    sigma_mm: f64,
    nbox: usize,
) -> Result<Vec<f64>, InputError>
Expand description

Get sensitivity (bias field) from magnitude

This estimates the RF receive field inhomogeneity (sensitivity map) that can be divided out to correct the image.

MriResearchTools’ getsensitivity (771eadf). Agreement: bit-identical to MriResearchTools’ makehomogeneous(mag; sigma = 7 mm in voxels, nbox = 15) on the 20×18×14, 1×1×1.5 mm phantom of tests/mritools_parity.rs (verified QSM-CI julia-qsm image, QSMxT/QSM-CI#299; measured 2026-10-30), where it was 3.3 % NRMSE in the mask before three port errors were fixed (astewartau/QSM.rs#319). Each measured alone, with the other two fixed:

  • the masked smoothing’s nanboxfilterline! wrote each fill-mode extrapolation onto the last voxel of the line as well (an off-by-one from Julia’s 1-based index): 4.0 %;
  • [box_segment]’s boxes stopped one voxel short of c + boxshift, which the original includes: 1.05 %;
  • its 90th percentile was a nearest-rank index, not Statistics.quantile (type 7): 0.35 %.

Also now as the original, at rounding level: Julia’s ties-to-even round in the box widths, and the Float32 weights of fillandsmooth!’s weighted smoothing (gaussiansmooth3d! converts them). These are port fixes, not tuning: the algorithm and its defaults are unchanged.

§Errors

If nbox (boxes per dimension for the tissue segmentation) is 0.