R/preprocessing.R
preprocess_rr_intervals.RdApplies a comprehensive preprocessing pipeline to RR intervals, including physiological filtering and artifact detection. This is a convenience function that combines multiple preprocessing steps.
preprocess_rr_intervals(
rr_intervals,
min_rr = 272,
max_rr = 2000,
window_size = 7,
threshold = 0.2,
centered_window = FALSE
)Numeric vector of RR intervals in milliseconds
Minimum physiologically plausible RR interval in milliseconds. Default is 272 ms
Maximum physiologically plausible RR interval in milliseconds. Default is 2000 ms
Size of the moving window for artifact detection. Default is 7 intervals
Threshold for artifact detection as a proportion. Default is 0.2
Logical indicating whether the moving window should be centered. Default is FALSE
A list containing:
cleaned_rr: Numeric vector of cleaned RR intervals (artifacts removed)
valid_mask: Logical vector indicating which original intervals are valid
n_removed_physiological: Number of intervals removed for physiological reasons
n_removed_artifacts: Number of intervals removed as artifacts
n_original: Original number of intervals
n_final: Final number of valid intervals
The preprocessing pipeline applies the following steps in order:
Physiological filtering using filter_physiological_rr()
Artifact detection using detect_rr_artifacts()
Combines both filters to create final valid mask
Returns both cleaned data and diagnostic information
This function is designed to be the main entry point for RR interval preprocessing in the HRV analysis pipeline.