Skip to contents

Applies a notch (band-stop) filter to remove power line interference (50 Hz or 60 Hz) and optionally its harmonics.

Usage

notch_filter(
  data,
  sampling_rate,
  notch_freq = 50,
  Q = 30,
  harmonics = TRUE,
  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.

notch_freq

Frequency to remove in Hz. Default is 50 Hz. Use 60 Hz for regions with 60 Hz power lines (e.g., Americas, Japan).

Q

Quality factor determining the filter bandwidth. Higher Q = narrower notch. Default is 30.

harmonics

Logical. If TRUE (default), also removes harmonics (2x, 3x, etc. of notch_freq up to Nyquist frequency).

zero_phase

Logical. If TRUE (default), applies zero-phase filtering.

Value

Filtered EMG signal with power line noise removed.

Details

Power line interference (50/60 Hz) is a common artifact in EMG recordings. The notch filter creates a narrow band-stop at the specified frequency. When harmonics = TRUE, harmonics (100/120 Hz, 150/180 Hz, etc.) are also removed.

Examples

if (FALSE) { # \dontrun{
# Remove 50 Hz power line noise
clean_emg <- notch_filter(emg, sampling_rate = 1000, notch_freq = 50)

# Remove 60 Hz (Americas) with harmonics
clean_emg <- notch_filter(emg, sampling_rate = 1000, notch_freq = 60, harmonics = TRUE)
} # }