Applies 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
)

Arguments

rr_intervals

Numeric vector of RR intervals in milliseconds

alpha

Scaling factor for threshold calculation. Default is 5.2

c1

Constant for ectopic beat detection boundary. Default is 0.13

c2

Constant for ectopic beat detection boundary. Default is 0.17

qd_window

Window size for quartile deviation calculation. Default is 91

Value

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

Details

This function implements the complete Lipponen-Tarvainen algorithm:

  1. Uses existing classify_hrv_artefacts_lipponen() for detection

  2. 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

  3. 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.

References

Lipponen & Tarvainen (2019). A robust algorithm for heart rate variability time series artefact correction. Journal of Medical Engineering & Technology.

Examples

if (FALSE) { # \dontrun{
rr_data <- c(800, 850, 400, 1600, 830, 810)
result <- correct_rr_lipponen_tarvainen(rr_data)
corrected_data <- result$corrected_rr
} # }