Skip to contents

Applies a bandpass filter to EMG signals to extract the frequency band of interest (typically 20-450 Hz for surface EMG).

Usage

bandpass_filter(
  data,
  sampling_rate,
  low_cutoff = 20,
  high_cutoff = 450,
  filter_order = 4,
  filter_type = "butterworth",
  zero_phase = TRUE
)

Arguments

data

EMG signal. Can be a numeric vector (single channel), a matrix (T x M, time x channels), or a list of matrices.

sampling_rate

Sampling frequency in Hz.

low_cutoff

Lower cutoff frequency in Hz. Default is 20 Hz.

high_cutoff

Upper cutoff frequency in Hz. Default is 450 Hz.

filter_order

Filter order. Default is 4 (creates 4th order filter, 8th order effective with zero-phase filtering).

filter_type

Type of filter: "butterworth" (default), "chebyshev1", or "chebyshev2".

zero_phase

Logical. If TRUE (default), applies zero-phase filtering (forward-backward filtering) to avoid phase distortion.

Value

Filtered EMG signal, same structure as input.

Details

The bandpass filter removes:

  • Low-frequency noise and motion artifacts (below low_cutoff)

  • High-frequency noise (above high_cutoff)

Standard EMG bandwidth is 20-450 Hz for surface EMG. The lower cutoff helps remove motion artifacts, while the upper cutoff prevents aliasing and removes high-frequency noise.

Examples

if (FALSE) { # \dontrun{
# Generate sample EMG-like signal
fs <- 1000  # 1000 Hz sampling rate
t <- seq(0, 1, by = 1/fs)
emg <- rnorm(length(t)) + 0.1 * sin(2 * pi * 10 * t)  # with low-freq noise

# Apply bandpass filter
filtered <- bandpass_filter(emg, sampling_rate = fs)
} # }