FIR: FIR filter for physiological signals This is a wrapper for...

View source: R/generic_filters.R

FIRR Documentation

FIR filter for physiological signals This is a wrapper for signal::fir1, calculating decent values of filter order based on engineering rules of thumb

Description

FIR filter for physiological signals This is a wrapper for signal::fir1, calculating decent values of filter order based on engineering rules of thumb

Usage

FIR(
  x,
  cut,
  type = c("low", "high"),
  NAsub = NA,
  attenDb = 50,
  burnSec = 0,
  maxN = 500,
  plot = F
)

Arguments

x

a rats object

cut

filter cut in Hz

type

lowpass or highpass

NAsub

signal::fir1 does not allow to have NAs. So they have to be substituted

attenDb

attenuation in Db

burnSec

head and tail of the filtered signals are bad. Burnsec specifies an amount of seconds over which the filtered signal is crossfaded with the original one.

maxN

maximum filter order

plot

logical. if TRUE plots frequency response, pass and stop bands

Details

The filter order is calculated automatically following "fred harris' rule of thumb" and a maximum transition bandwidth of 1.2 times the cut frequency for lowpass (e.g. a cut at 10Hz will achieve maximum attenuation at )

Examples

Fs = 100; t = 5; samples = seq(0,t,len=Fs*t)
x = ts(sin(2*pi*3*samples) + seq(-0.5,0.5,length.out = Fs*t), frequency = Fs)
x[1:50] = NA
xn = x+runif(1000,-0.5,0.5);
x1 = FIR(xn, "low", cut = 3,attenDb = 50,burnSec = 0, plot=TRUE)
plot(xn,col="grey");lines(x,col=3,lwd=2);lines(x1,col=2,lwd=3)

kleinbub/rIP documentation built on Dec. 21, 2024, 9:15 a.m.