Heart rate variability (HRV) is a standard metric for assessing autonomic nervous system function, psychophysiological stress, and exercise intensity and recovery. Extra, missing, or misaligned beat detections in HRV measurements can cause severe distortion in HRV analysis.
This repository contains MATLAB code for HRV time series artifact correction based on NeuroKit implementation. The correction algorithm proposed by Lipponen et al. (2019) uses time-varying thresholds calculated from the distribution of successive RR-interval discrepancies paired with a unique beat categorization methodology.
The function fixpeaks()
has been provided to perform peak correction directly on data stored in MATLAB. The function can be used as follows:
% Load your file containing indices of detected R waves, for example
% peak.txt or use your variable that contains them
load peaks.txt
% Call the main function fixpeaks()
[artifacts, peaks_clean] = fixpeaks(peaks, 500, true, true);
If the last argument show
in the function is set to true, the detected artifacts and subspaces described in [1] are then visualized. Further input arguments are described in the function itself.
- [1] Jukka A. Lipponen & Mika P. Tarvainen (2019): A robust algorithm for heart rate variability time series artefact correction using novel beat classification, Journal of Medical Engineering & Technology
- [2] Makowski, D., Pham, T., Lau, Z. J., Brammer, J. C., Lespinasse, F., Pham, H., Schölzel, C., & Chen, S. A. (2021). NeuroKit2: A Python toolbox for neurophysiological signal processing. Behavior Research Methods, 53(4), 1689–1696.