R/preprocessing.R
correct_rr_lipponen_tarvainen.RdApplies the complete Lipponen-Tarvainen algorithm for artifact detection and correction. This state-of-the-art method achieves <2% HRV error by combining robust classification with appropriate correction strategies.
correct_rr_lipponen_tarvainen(
rr_intervals,
alpha = 5.2,
c1 = 0.13,
c2 = 0.17,
qd_window = 91
)Numeric vector of RR intervals in milliseconds
Scaling factor for threshold calculation. Default is 5.2
Constant for ectopic beat detection boundary. Default is 0.13
Constant for ectopic beat detection boundary. Default is 0.17
Window size for quartile deviation calculation. Default is 91
A list containing:
corrected_rr: Numeric vector of corrected RR intervals
classifications: Character vector of beat classifications
corrections_applied: Number of corrections applied
rmssd_error: Estimated RMSSD error from corrections
This function implements the complete Lipponen-Tarvainen algorithm:
Uses existing classify_hrv_artefacts_lipponen() for detection
Applies appropriate correction for each artifact type:
Extra beats: Removed from sequence
Missed beats: Insert estimated beat at half interval
Ectopic/Long/Short: Cubic spline interpolation
Targets <2% HRV error as demonstrated in research
The algorithm represents the current state-of-the-art in HRV artifact correction, providing superior accuracy for research applications.
Lipponen & Tarvainen (2019). A robust algorithm for heart rate variability time series artefact correction. Journal of Medical Engineering & Technology.
if (FALSE) { # \dontrun{
rr_data <- c(800, 850, 400, 1600, 830, 810)
result <- correct_rr_lipponen_tarvainen(rr_data)
corrected_data <- result$corrected_rr
} # }