fn reanchor_to_wrapped(
u: &mut [f64],
p: &[f64],
labels: &[u32],
n_components: u32,
)Expand description
Re-anchor a Laplacian solution so it differs from the wrapped phase by whole 2π.
laplacian_unwrap solves a Poisson equation and zeroes the DC mode, so its output is
only defined up to an arbitrary real constant. In 3D that constant is global and harmless
— a receive phase offset, which the background removal or a multi-echo fit absorbs. Per
slice it is neither: an arbitrary real offset on each slice is worse than the 2π ambiguity
slice-wise unwrapping is entitled to, and it would make the inter-echo correction
meaningless, since that correction can only move a slice by whole multiples of 2π.
Subtracting the circular mean of u - p over each component restores the entitlement:
afterwards u - p is a whole multiple of 2π, and the only freedom left is which one.
The region-growing unwrappers already satisfy that by construction, so they skip this.