spiro_smooth {spiro} | R Documentation |
Apply a smoothing filter to data from cardiopulmonary exercise testing.
Description
Filter vectors and data frames with moving averages and digital filters.
Provides the data filtering for spiro_max
and
spiro_plot
.
Usage
spiro_smooth(data, smooth = 30, columns = NULL, quiet = FALSE)
Arguments
data |
A data frame of the class |
smooth |
An integer or character string specifying the smoothing
strategy and parameters. Default is |
columns |
A character vector of the data columns that should be
filtered. By default the filtering applies to all data column of
|
quiet |
Whether warning message should be suppressed. Default is FALSE. |
Details
Raw data from cardiopulmonary is usually noisy due to measurement error and biological breath-to-breath variability. When processing or visualizing the gas exchange data, it is often helpful to filter the raw data. This function provides different filtering methods (time average, breath average, digital filters).
Breath-based and digital filters will be applied on the raw breath-by-breath data. Time-based averages will be used on the interpolated data.
Value
A data frame
Filtering Methods
- Time-Based Average (e.g.
smooth = 30
) A (centered) moving average over a defined time span. The number can be given as an integer or as a character (e.g.
smooth = "30"
) and defines the length of the calculation interval in seconds.- Breath-Based Average (e.g.
smooth = "15b"
) A (centered) moving average over a defined number of breaths. The integer before the letter 'b' defines the number of breaths for the calculation interval.
- Butterworth filter (e.g.
smooth = "0.04f3"
) A digital Butterworth filter (with lag). The number before the letter 'f' defines the low-pass cut-off frequency, the number after the letter 'f' gives the order of the filter. See
bw_filter
for more details.- Zero-lag Butterworth filter (e.g.
smooth = "0.04fz3"
) A digital forwards-backwards Butterworth filter (without lag). The number before the letter 'f' defines the low-pass cut-off frequency, the number after gives the order of the filter. See
bw_filter
for more details.
Examples
# Get example data
file <- spiro_example("zan_gxt")
d <- spiro(file)
out <- spiro_smooth(d, 30)
head(out)
# filter only the VO2 column with a zero-phase Butterworth filter
out2 <- spiro_smooth(d, "0.04fz3", columns = "VO2")
head(out2)