pub fn apply_mask_ops(
mask: Vec<u8>,
ops: &[MaskOp],
input_data: &[f64],
magnitude: Option<&[f64]>,
metadata: &ScanMetadata,
) -> Result<Vec<u8>, PipelineError>Expand description
Apply mask operations to an existing mask, in order.
This is the one implementation of what every mask op means; build_mask_section is this
function starting from an all-ones mask, and hosts that drive masking themselves (e.g. an
interactive UI applying one refinement at a time) should call it rather than reimplement the
operations, so a mask built step-by-step matches the one a --mask section would produce.
Two different images. input_data is what a generator looks at — thresholding may use a
phase-quality map, for instance. magnitude is the magnitude image, and is what the ops that
need real signal use: MaskOp::Bet, MaskOp::HdBet and MaskOp::SignalErode. Passing
the section input as magnitude is a bug: signal-gated erosion divides out a receive-coil bias
estimate and gates on the in-mask median, which only means anything for a magnitude image.
Those ops error when magnitude is None.
§Arguments
mask- Starting mask (0/1), lengthnx*ny*nzops- Operations to apply, in orderinput_data- Image the generators threshold (may be a phase-quality map)magnitude- Magnitude image, for BET / HD-BET / signal-gated erosionmetadata- Scan metadata (dims + voxel size)