Title: | Fast detection of R peaks in ecg data |
---|---|

Description: | Package for fast detection of R peaks using a simplified pan-tompkins algorithm. Uses fast C++ code to speed up computations for long ecg recordings. |

Authors: | Erik-Jan van Kesteren |

Maintainer: | Erik-Jan van Kesteren <[email protected]> |

License: | GPL-3 |

Version: | 1.5 |

Built: | 2024-10-27 06:19:56 UTC |

Source: | https://github.com/vankesteren/rpeaks |

Fast implementation of the Pan-Tompkins algorithm. The default parameters are taken from the original pan and tompkins paper.

`rpeaks_pan_tompkins( ecg, sample_rate, integration_window = 0.15, refractory = 0.2, band_low = 5, band_high = 15 )`

`rpeaks_pan_tompkins( ecg, sample_rate, integration_window = 0.15, refractory = 0.2, band_low = 5, band_high = 15 )`

`ecg` |
raw ecg data vector |

`sample_rate` |
sampling rate in Hz of the ecg |

`integration_window` |
size of the integration window in seconds |

`refractory` |
refractory period in seconds (minimum time between peaks) |

`band_low` |
lower bound of the band-pass filter in Hz |

`band_high` |
upper bound of the band-pass filter in Hz |

This algorithm uses a butterworth filter of order 1 for the band-pass step, and a 3rd-order length-5 Savitzky-Golay smoothing filter to compute the derivative of the band-passed signal. Peak detection on the preprocessed signal works in a simplified way: we take the first value above the lower bound (3 * the mean signal value) which is higher than its neighbours, and not within the refractory period after the previous R peak.

Pan, J., & Tompkins, W. J. (1985). A real-time QRS detection algorithm. IEEE transactions on biomedical engineering, (3), 230-236.

`ecg_url <- "https://physionet.org/files/ecgiddb/1.0.0/Person_01/rec_2.dat?download" ecg_dat <- readBin(ecg_url, integer(), 500*30) ecg_sec <- (0:(length(ecg_dat) - 1)) / 500 # rel. time in seconds r_peaks <- rpeaks_pan_tompkins(ecg = ecg_dat, sample_rate = 500) plot(x = ecg_sec, y = ecg_dat, type = "l", xlab = "time (seconds)", ylab = "ecg") abline(v = r_peaks, col = "blue", lty = 3)`

`ecg_url <- "https://physionet.org/files/ecgiddb/1.0.0/Person_01/rec_2.dat?download" ecg_dat <- readBin(ecg_url, integer(), 500*30) ecg_sec <- (0:(length(ecg_dat) - 1)) / 500 # rel. time in seconds r_peaks <- rpeaks_pan_tompkins(ecg = ecg_dat, sample_rate = 500) plot(x = ecg_sec, y = ecg_dat, type = "l", xlab = "time (seconds)", ylab = "ecg") abline(v = r_peaks, col = "blue", lty = 3)`