PhysioECG PhysioECG logo

ECG Analysis Functions for PhysioExperiment Objects

PhysioECG provides electrocardiography (ECG) analysis functions for the PhysioExperiment ecosystem. With 18 exported functions, it delivers a complete ECG analysis pipeline -- from R-peak detection using an adaptive Pan-Tompkins algorithm, through RR interval computation and ectopic beat correction, to comprehensive heart rate variability (HRV) analysis across time-domain, frequency-domain, and nonlinear methods. It also includes ECG morphology analysis (PQRST waveform delineation, clinical interval measurement) and signal quality assessment.

Installation

You can install PhysioECG from r-universe:

# the containers build on Bioconductor, so its repositories are needed too
install.packages("BiocManager", repos = "https://cloud.r-project.org")
install.packages("PhysioECG",
  repos = c("https://x-biosignal.r-universe.dev", BiocManager::repositories()))

Or install the development version from GitHub:

# install.packages("remotes", repos = "https://cloud.r-project.org")
remotes::install_github("x-biosignal/PhysioECG")

Quick Start

library(PhysioECG)

# Generate a simulated ECG signal (10 seconds at 500 Hz, 72 bpm)
pe <- make_ecg(n_time = 5000, sr = 500, heart_rate = 72)

# Detect R-peaks using the adaptive Pan-Tompkins algorithm
peaks <- ecgDetectRpeaks(pe)
head(peaks)
#>   channel sample time_sec amplitude
#> 1       1    347    0.692      1.50
#> 2       1    764    1.526      1.50
#> ...

# Compute RR intervals
rr <- ecgRRintervals(pe, peaks)

# Time-domain HRV metrics
hrv_time <- ecgHRVtime(rr)
hrv_time
#>   channel mean_rr   sdnn rmssd pnn50 mean_hr
#> 1       1  833.33   1.23  0.87     0   72.00

# Frequency-domain HRV analysis (Welch PSD)
hrv_freq <- ecgHRVfreq(rr, method = "welch")

# Nonlinear HRV (Poincare, Sample Entropy, DFA)
hrv_nl <- ecgHRVnonlinear(rr)

# ECG morphology: delineate P, QRS, T waves
delin <- ecgDelineate(pe, peaks)
intervals <- ecgIntervals(delin, sr = 500)
head(intervals)
#>   channel beat  pr_ms  qt_ms  qtc_ms qrs_ms  rr_ms
#> 1       1    1  126.0  360.0   394.1   80.0  833.3

Features

R-Peak Detection

Adaptive dual-threshold Pan-Tompkins detector with automatic inverted-signal handling:

RR Interval Analysis

RR interval computation and ectopic beat correction:

HRV Time-Domain Analysis

Standard time-domain HRV metrics per ESC/NASPE Task Force guidelines:

HRV Frequency-Domain Analysis

Power spectral density estimation with standard frequency band integration:

HRV Nonlinear Analysis

Nonlinear dynamics and complexity measures:

ECG Morphology Analysis

Waveform delineation and clinical interval measurement:

Signal Quality Assessment

Signal quality evaluation and baseline correction:

Simulated ECG Data

Synthetic ECG generators for testing and demonstration:

Dependencies

PhysioExperiment Ecosystem

PhysioECG is the ECG analysis module of the PhysioExperiment ecosystem, a suite of R packages for multi-modal physiological signal analysis:

Package Description
PhysioCore Core data structures and accessors
PhysioIO File I/O (EDF, HDF5, BIDS, CSV, MAT)
PhysioPreprocess Preprocessing (filters, ICA, resampling)
PhysioAnalysis Analysis and visualization
PhysioECG ECG analysis and HRV
PhysioEDA Electrodermal activity analysis

Visit the r-universe page to browse all available packages.

References

License

MIT License. See LICENSE for details.

Author

Yusuke Matsui

Governance & support

Part of the Physio ecosystem. Community and policy documents live in the umbrella repository: