Skip to main content

Module fieldmap

Module fieldmap 

Source
Expand description

Multi-echo phase combination and B0 field mapping.

Building blocks for turning multi-echo wrapped phase into a B0 field map: phase-offset removal (MCPC-3D-S / ASPIRE), weighted B0 estimation, linear multi-echo fitting, and MEDI’s complex fit (Fit_ppm_complex).

Structs§

CoilCombinationResult
Result of MCPC-3D-S multi-coil combination (mcpc3ds_combine).
EchoQuality
Per-echo evidence that an echo did not fit the model the others agree on.
FitPpmComplexParams
Settings of fit_ppm_complex, the opts of Fit_ppm_complex.m (defaults as there).
FitPpmComplexResult
Output of fit_ppm_complex. Each map has one value per voxel.
LinearFitParams
Parameters for multi-echo linear fit.
LinearFitResult
Result of multi-echo linear fit
PhaseOffsetParams
Parameters for phase offset removal.
PhaseOffsetRemoval
Result of phase_offset_removal (MCPC-3D-S on coil-combined echoes).
RobustFitParams
Parameters for multi_echo_robust_fit.
RobustFitResult
A robust multi-echo fit: the field map, and the evidence about each echo that produced it.

Enums§

B0WeightType
B0 weighting types. All but B0WeightType::AssumedDecay match MriResearchTools.jl.
RobustLoss
How a standardised residual becomes a weight.

Constants§

FIT_PPM_COMPLEX_SPACING_TOLERANCE_S
How far, in seconds, each echo spacing may be from the first for fit_ppm_complex and MEDI’s noise map (fit_ppm_complex_noise) to count the echoes as evenly spaced: 0.02 ms.

Functions§

bipolar_correction
Bipolar gradient correction for multi-echo phase data.
calculate_b0_weighted
Calculate B0 field from unwrapped phase using weighted averaging
echo_spacing_problem
Why fit_ppm_complex (and so MEDI’s field map and noise map, which every pipeline entry point that runs them checks with this) cannot use these echo times, or None if it can: they must be finite, increasing (a single echo after TE = 0), and evenly spaced, each spacing within FIT_PPM_COMPLEX_SPACING_TOLERANCE_S of the first. A host can call this to reject a run before any work starts, and so applies exactly the rule and tolerance QSM.rs does.
field_to_hz
Convert field from rad/s to Hz
fit_ppm_complex
Complex multi-echo field fit, a port of Fit_ppm_complex.m (MEDI toolbox 2024.11.26; Liu et al., MRM 2013;69:467; Kressler et al., IEEE TMI 2010;29:273; de Rochefort et al., MRM 2008;60:1003).
fit_ppm_complex_noise
Noise standard deviation of the field fit, as Fit_ppm_complex.m in the MEDI toolbox returns it (dp1, MEDI’s N_std): the a priori error of the frequency in a magnitude-weighted linear fit of phase to echo index, sqrt(a11 / (a11·a22 − a12²)) with a_jk = Σ_e |S_e|² e^(j+k−2) over echo indices e = 0, 1, …. It depends only on the echo magnitudes, so this is fit_ppm_complex’s noise without the phase. A single echo is treated as Fit_ppm_complex.m does, as two echoes of the same magnitude. Voxels where the fit is undefined get 0, as there (MEDI’s data weight then ignores them).
gaussian_box_sizes
Box-filter widths approximating a Gaussian of sigma (voxels) with n passes — the getboxsizes of MriResearchTools.jl (Kovesi’s “fast almost-Gaussian” construction). Returns all-ones (i.e. no smoothing) when sigma is not positive.
mcpc3ds_combine
MCPC-3D-S multi-coil phase combination (Eckstein et al., MRM 2018), as in MriResearchTools.jl’s mcpc3ds for 5D (multi-echo, uncombined) input.
multi_echo_linear_fit
Multi-echo linear fit with magnitude weighting
multi_echo_robust_fit
Multi-echo fit that downweights echoes which disagree with the rest, and reports which.
nan_box_smooth_3d
Masked 3D smoothing by repeated NaN-aware box filtering — the mask branch of gaussiansmooth3d! in MriResearchTools.jl (4 passes per axis, alternating direction on even passes, box widths from gaussian_box_sizes). Voxels outside mask become NaN before filtering and are only given values where the filter extrapolates across the boundary; the result is written in place.
nan_box_smooth_3d_phase
Masked phase smoothing via the complex representation, using nan_box_smooth_3d — gaussiansmooth3d_phase(phase, sigma; mask) of MriResearchTools.jl. Returns NaN where the smoothed complex value is undefined (far outside the mask).
phase_offset_removal
Remove phase offset from multi-echo phase data using HIP (Hermitian Inner Product): MCPC-3D-S, as MriResearchTools.jl’s mcpc3ds does it for one channel (src/mcpc3ds.jl:38-57, 771eadf; v3.8.0).