Skip to contents

Zero-phase Butterworth bandpass filter. Isolates a frequency band of interest (e.g., 0.5–40 Hz for EEG, 25–400 Hz for phonocardiogram).

Usage

buttbp(x, fs, low, high, order = 4L)

Arguments

x

Numeric vector.

fs

Sampling frequency (Hz).

low

Lower cutoff (Hz).

high

Upper cutoff (Hz).

order

Filter order (default 4).

Value

List with filtered (numeric vector), fs, order, name.

Examples

# \donttest{
if (requireNamespace("signal", quietly = TRUE)) {
  set.seed(1)
  t <- seq(0, 1, length.out = 1000)
  # 2 Hz drift + 10 Hz band of interest + 60 Hz noise
  x <- sin(2 * pi * 2 * t) + sin(2 * pi * 10 * t) +
    0.3 * sin(2 * pi * 60 * t)
  y <- buttbp(x, fs = 1000, low = 5, high = 20)
  length(y$filtered)
}
#> [1] 1000
# }