removetrend: removetrend

View source: R/removetrend.R

removetrendR Documentation

removetrend

Description

Perform detrending or high pass filtering to remove low frequencies

Usage

removetrend(
  x,
  fs = 1,
  type = c("highpass", "linear", "mean", "constant", "none"),
  hpcf = 1,
  hptbw = 1,
  hpdev = 0.01
)

Arguments

x

input time series, specified as a numeric matrix or vector. In case of a vector it represents a single signal; in case of a matrix each column is a signal. Alternatively, an object of class ctd

fs

sampling frequency of x in Hz. Default: 1. Overruled if x is a ctd object, in which case the sampling frequency is fs(x). Only used when type = "highpass".

type

character string indicating which type of trend removal is performed for line noise removal bad channel detection; one of:

highpass

use a high-pass FIR filter with cutoff frequency specified by the parameter hpfc (default)

linear

remove polynomial linear trend

mean|constant

remove mean

none

no detrending

hpcf

high-pass cutoff frequency in Hz, specified as a positive numeric value. Default: 1 Hz

hptbw

high-pass transition bandwith in Hz, specified as a positive numeric value. For instance, if the high-pass cutoff frequency is 1 Hz, and the transition bandwith is also 1 Hz, the transition band of 1 Hz is located between 0.5 and 1.5 Hz. Default: 1 Hz.

hpdev

deviation from desired stop- and passband of the high-pass filter, specified as a positive numeric value

Details

When high-pass filtering is requested, an optimal-length FIR filter is designed, which has a linear phase. The filger delay is corrected for by the function. Before filtering, reflected parts of the input data (equal to the calculated filter length) are added to the beginning and end of the data to avoid filter edge effects.

Value

a list containing consisting of:

y

the detrended data

h

the filter coefficients

mean|constant

remove mean

none

no detrending

Author(s)

Geert van Boxtel, G.J.M.vanBoxtel@gmail.com

Examples


data(EEGdata)
det <- removetrend(EEGdata, hpcf = 1, hptbw = 1, hpdev = 0.01)
plot(det$y)


gjmvanboxtel/eegr documentation built on May 20, 2023, 4:26 a.m.