Skip to contents

Forward-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.

Usage

sosfiltfilt(sos, x, padlen = NULL)

Arguments

sos

SOS matrix (n_sections x 6).

x

Numeric input vector.

padlen

Number of samples of odd reflection padding at each edge. Defaults to min(3 * (2 * n_sections + 1), length(x) - 1).

Value

The zero-phase filtered numeric vector, same length as x.

See also

Examples

sos <- sosDesign(high = 40, type = "low", sr = 250, order = 4)
y <- sosfiltfilt(sos, rnorm(1000))