Learn R Programming

heartbeatr (version 1.0.0)

pulse_smooth: Smooth PULSE data

Description

The performance of the algorithm employed in the downstream function pulse_heart() for the detection of heart beat wave crests depends significantly on the data not being too noisy. pulse_smooth() reshapes the data and improves the likelihood of pulse_heart() successfully estimating the inherent heartbeat rates.

  • SMOOTHING should be experimented with when pulse_heart() produces too many heartbeat rate estimates that are clearly incorrect. In such situations, pulse_smooth() applies a smoothing filter (normal Kernel Regression Smoother) to the data to smooth out high-frequency noise and render a more sinusoidal wave, which is easier to handle. Unlike interpolation_freq, users should exercise caution when setting bandwidth and generally opt for lower values, as there's a threshold to bandwidth values above which the resulting smoothed pulse data becomes completely unrelated to the original data, and the subsequent heartbeat rates computed with pulse_heart() may be wrong. Always double-check the data after applying a stronger smoothing. Nonetheless, note that if applied with the default bandwidth, smoothing incurs no penalty and hardly changes the data - so it isn't worth going out of the way to not apply smoothing.

Usage

pulse_smooth(split_window, bandwidth = 0.2)

Value

The same PULSE tibble supplied in split_window, but now with data for all channels transformed by smoothing.

Arguments

split_window

one element of the pulse_data_split list() (which is the output from pulse_split()).

bandwidth

numeric, defaults to 0.2; the bandwidth for the Kernel Regression Smoother. If equal to 0 (zero) no smoothing is applied. Normally kept low (0.1 - 0.3) so that only very high frequency noise is removed, but can be pushed up all the way to 1 or above (especially when the heartbeat rate is expected to be slow, as is typical of oysters, but double check the resulting data). Type ?ksmooth for additional info.

See Also

  • ksmooth() is used for the kernel smoothing of PULSE data

  • pulse_optimize() is a wrapper function that executes pulse_interpolate() and pulse_smooth sequentially

  • pulse_read(), pulse_split(), pulse_heart(), pulse_doublecheck() and pulse_choose_keep() are the other functions needed for the complete PULSE processing workflow

  • PULSE() is a wrapper function that executes all the steps needed to process PULSE data at once

Examples

Run this code
## Begin prepare data ----
pulse_data_sub <- pulse_data
pulse_data_sub$data <- pulse_data_sub$data[,1:5]
pulse_data_split <- pulse_split(pulse_data_sub)
## End prepare data ----

# Smooth data slightly ('bandwidth' = 0.2)
pulse_smooth(pulse_data_split$data[[1]], 0.2)

Run the code above in your browser using DataLab