Designs a Butterworth IIR filter and applies it using zero-phase filtering (forward-backward) to avoid phase distortion.
Usage
butterworthFilter(
x,
cutoff,
sampling_rate,
type = c("lowpass", "highpass", "bandpass", "bandstop"),
order = 4
)Arguments
- x
A numeric vector or matrix (time x channels).
- cutoff
Cutoff frequency in Hz. A single value for "lowpass" or "highpass"; a length-2 vector
c(low, high)for "bandpass" or "bandstop".- sampling_rate
Sampling rate in Hz.
- type
Filter type: "lowpass", "highpass", "bandpass", or "bandstop".
- order
Filter order (default: 4).
Details
Requires the signal package. NAs in the input are temporarily interpolated before filtering and restored afterward.
References
Butterworth S (1930). "On the Theory of Filter Amplifiers." Wireless Engineer, 7, 536-541.
See also
filterSignals() for filtering PhysioExperiment objects,
savgolFilter() for Savitzky-Golay polynomial smoothing.