bw_filter {spiro} | R Documentation |
Smooth data with a (zero-phase) Butterworth filter
Description
Internal function for spiro_smooth
.
Usage
bw_filter(x, n = 3, W = 0.04, zero_lag = TRUE)
Arguments
x |
A numeric vector on which the digital filter should be applied |
n |
Order of the Butterworth filter, defaults to 3 |
W |
Low-pass cut-off frequency of the filter, defaults to 0.04 |
zero_lag |
Whether a zero phase (forwards-backwards) filter should be applied. |
Details
Digital filtering might be a preferable processing strategy for smoothing data from gas exchange measures when compared to moving averages. Robergs et al. (2010) proposes a third order Butterworth filter with a low-pass cut-off frequency of 0.04 for filtering VO2 data.
It should be noted that Butterworth filter comprise a time lag. A method to create a time series with zero lag is to subsequently apply two Butterworth filters in forward and reverse direction (forwards-backwards filtering). While this procedure removes any time lag it changes the magnitude of the filtering response, i.e. the resulting filter has not the same properties (order and cut-off frequency) as a single filter.
Value
A numeric vector of the same length as x.
Examples
# Get VO2 data from example file
vo2_vector <- spiro(spiro_example("zan_gxt"))$VO2
out <- bw_filter(vo2_vector)
head(out, n = 20)