Skip to contents

Removes the DC component (baseline offset) from EMG signals using various methods.

Usage

remove_dc_offset(data, method = "mean", poly_order = 1)

Arguments

data

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

method

Method for DC removal:

  • "mean": Subtract the mean (default)

  • "median": Subtract the median (robust to outliers

  • "linear": Remove linear trend (detrend)

  • "polynomial": Remove polynomial trend

poly_order

Polynomial order when method = "polynomial". Default is 1 (equivalent to linear detrending).

Value

Data with DC offset removed, same structure as input.

Examples

# Single channel
signal <- rnorm(1000) + 0.5
clean <- remove_dc_offset(signal)

# Multi-channel matrix
emg <- matrix(rnorm(1000 * 8), nrow = 1000, ncol = 8)
emg_clean <- remove_dc_offset(emg, method = "linear")