filterdata: Filter Data

View source: R/filterdata.R

filterdataR Documentation

Filter Data

Description

Filter data in a ctd object.

Usage

filterdata(ctd_obj, filt)

Arguments

ctd_obj

object of class 'ctd' containing continuous time domain data.

filt

filter object recognized by the gsignal package (of class Arma, Ma, Sos, or Zpg, characterizing a FIR or a IIR filter.)

Details

Filtering is done using the filtfilt function in the gsignal package, which minimizes filter startup transients by pre- and postpending reflected pieces of the input signal, which are tapered to zero. Forward and reverse filtering the signals corrects for phase distortion (not perfect in practice).

Value

A ctd object containing the filtered data.

Author(s)

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

Examples


data(EEGdata)
fs <- fs(EEGdata)
nyq <- fs / 2

## 10 Hz low-pass (Butterworth; maximally flat)
but <- gsignal::butter(3, 10 / nyq)
lpd <- filterdata(EEGdata, but)
plot(lpd)

## 8-12 Hz low-pass filter 
## note that selecting a subset of signal
filt <- gsignal::fir1(50, c(8, 12) / nyq, "pass")
alpha <- filterdata(selectdata(EEGdata, signals = 1:28), filt)
plot(alpha, ylim=c(-10,10))


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