///|
/// Statistics-sensitive nonlinear iterative peak clipping. Uses synchronous
/// neighbors, leaves unavailable edge pairs unchanged, and optionally applies
/// the log(log(sqrt(y+1)+1)+1) count transform. Transformed input must be >= 0.
pub fn snip(
  input : Spectrum,
  half_window~ : Int32 = 20,
  decreasing~ : Bool = true,
  count_transform~ : Bool = false,
) -> BaselineResult raise SpectralError {
  let n = input.length()
  if half_window < 1 || half_window > 2048 || 2 * half_window >= n {
    raise Invalid(
      "SNIP half window must be 1..2048 and smaller than half the signal",
    )
  }
  let mut baseline = input.values.copy()
  if count_transform {
    for i in 0..