Applies linear interpolation to correct identified artifacts in RR intervals. This method provides the lowest RMSSD bias according to research and is particularly effective for single-beat artifacts.

correct_rr_linear(rr_intervals, artifact_indices, preserve_boundaries = TRUE)

Arguments

rr_intervals

Numeric vector of RR intervals in milliseconds

artifact_indices

Integer vector of indices identifying artifacts

preserve_boundaries

Logical indicating whether to preserve segment boundaries to avoid "flattening" effects. Default is TRUE

Value

Numeric vector of corrected RR intervals with same length as input

Details

This function implements enhanced linear interpolation following research recommendations:

  • Uses the 20% rule for artifact detection when artifact_indices not provided

  • Handles single beats differently from longer gaps (>3 beats)

  • Preserves segment boundaries to maintain physiological variability

  • For edge artifacts, uses nearest valid value rather than extrapolation

Linear interpolation has been shown to produce the lowest RMSSD bias among correction methods, making it ideal for HRV analysis.

References

Research shows linear interpolation provides lowest RMSSD bias for artifact correction in HRV analysis.

Examples

if (FALSE) { # \dontrun{
rr_data <- c(800, 850, 400, 830, 810)  # 400 is an artifact
corrected <- correct_rr_linear(rr_data, artifact_indices = 3)
} # }