Implements research-validated artifact detection using Kubios-style time-varying thresholds with dRR series analysis. This method differentiates ectopic beats from normal sinus rhythm using adaptive thresholding.

detect_artifacts_kubios(
  rr_intervals,
  threshold_level = "medium",
  hr_adaptive = TRUE
)

Arguments

rr_intervals

Numeric vector of RR intervals in milliseconds

threshold_level

Character string specifying threshold level: "low" (0.35s), "medium" (0.25s), or "strong" (0.15s). Default is "medium"

hr_adaptive

Logical indicating whether to use HR-adaptive thresholds. Default is TRUE

Value

A list containing:

  • artifact_indices: Integer vector of detected artifact positions

  • artifact_mask: Logical vector indicating artifacts

  • threshold_used: Numeric threshold value used for detection

  • drr_series: Difference RR series used for analysis

Details

This function implements the Kubios-style artifact detection algorithm:

  1. Calculates dRR (difference RR) series for adaptive analysis

  2. Applies time-varying thresholds based on local HRV levels

  3. Uses medium threshold (0.25s) as optimal for most populations

  4. Differentiates ectopic beats from normal sinus rhythm

  5. Adapts thresholds based on HR when hr_adaptive = TRUE

The method follows research recommendations from Kubios HRV 2023-2024 updates for automatic beat correction using research-validated thresholds.

References

Based on Kubios HRV methodology and research on time-varying thresholds for optimal RMSSD calculation accuracy across populations.

Examples

if (FALSE) { # \dontrun{
rr_data <- c(800, 850, 400, 1600, 820, 830)  # Data with artifacts
result <- detect_artifacts_kubios(rr_data, threshold_level = "medium")
artifact_positions <- result$artifact_indices
} # }