Zero-phase SOS filtering with state-initialised edge handling
Source:R/filters-causal.R
sosfiltfilt.RdForward-backward (zero-phase) SOS filtering that mirrors
scipy.signal.sosfiltfilt: it odd-reflects the signal at both edges,
initialises the delay-line to steady state (scaled by the boundary sample) to
suppress start-up transients, filters forward and then backward. The result
has zero phase distortion but is non-causal (both directions are used). For
strictly causal / real-time-equivalent filtering, use sosfilt
or butterworthFilter with causal = TRUE.