Package 'PhysioECG'

Title: ECG Analysis Functions for PhysioExperiment Objects
Description: Provides electrocardiography (ECG) analysis functions for PhysioExperiment objects. Includes R-peak detection (adaptive Pan-Tompkins), RR interval computation, HRV time-domain metrics (SDNN, RMSSD, pNN50), HRV frequency-domain analysis (VLF, LF, HF power), nonlinear HRV (Poincare, Sample Entropy, DFA), ECG morphology analysis (QRS boundaries, QT/QTc intervals), and signal quality assessment with ectopic beat correction.
Authors: Yusuke Matsui
Maintainer: Yusuke Matsui <[email protected]>
License: MIT + file LICENSE
Version: 0.2.0
Built: 2026-05-16 05:30:04 UTC
Source: https://github.com/x-biosignal/PhysioECG

Help Index


Correct Baseline Wander in ECG Signals

Description

Removes low-frequency baseline drift from ECG data using either a high-pass moving-average subtraction or a running-median subtraction.

Usage

ecgBaselineCorrect(
  x,
  method = c("highpass", "median"),
  cutoff = 0.5,
  assay_name = NULL,
  output_assay = "baseline_corrected"
)

Arguments

x

A PhysioExperiment object with ECG data.

method

Correction method: "highpass" (default) subtracts a moving average; "median" subtracts a running median.

cutoff

Approximate cutoff frequency in Hz (default: 0.5). Controls the window size of the moving average or median filter.

assay_name

Name of the input assay. If NULL the default assay is used.

output_assay

Name of the assay in which to store the corrected signal (default: "baseline_corrected").

Value

A PhysioExperiment with the corrected signal stored in output_assay.

References

Clifford, G.D., Azuaje, F. & McSharry, P.E. (2006). Advanced Methods and Tools for ECG Data Analysis. Artech House.

See Also

ecgSignalQuality for signal quality assessment, ecgDetectRpeaks for R-peak detection, ecgQualityCheck for ectopic beat detection.


Delineate ECG Waveform Morphology

Description

For each detected R-peak, identifies QRS complex boundaries (onset and offset) and P-wave and T-wave peaks. QRS boundaries are detected using a gradient-based search from the R-peak, while P and T waves are found as local maxima in physiologically plausible time windows.

Usage

ecgDelineate(x, peaks, assay_name = NULL)

Arguments

x

A PhysioExperiment object with ECG data.

peaks

A data.frame of detected R-peaks as returned by ecgDetectRpeaks, with columns channel and sample.

assay_name

Name of the assay to use. If NULL, the default assay is used.

Value

A data.frame with one row per beat and the following columns:

channel

Integer channel index (1-based).

beat

Integer beat number within the channel (1-based).

r_peak

Sample index of the R-peak.

qrs_onset

Sample index of QRS complex onset.

qrs_offset

Sample index of QRS complex offset (J-point).

qrs_duration_ms

QRS complex duration in milliseconds.

p_peak

Sample index of P-wave peak, or NA if not found in the search window (300–80 ms before R-peak).

t_peak

Sample index of T-wave peak, or NA if not found in the search window (80–500 ms after R-peak).

t_end

Sample index of T-wave end estimated by tangent-intercept method, or NA if T-wave not found.

Returns a zero-row data.frame with the same column structure if no beats are delineated.

References

Goldberger, A.L., et al. (2000). "PhysioBank, PhysioToolkit, and PhysioNet: Components of a new research resource for complex physiologic signals." Circulation, 101(23), e215–e220. doi:10.1161/01.CIR.101.23.e215

See Also

ecgDetectRpeaks for R-peak detection, ecgIntervals for computing clinical ECG intervals from delineation results, ecgSignalQuality for signal quality assessment.

Examples

## Not run: 
pe <- make_ecg(n_time = 5000, sr = 500, heart_rate = 72)
peaks <- ecgDetectRpeaks(pe)
delin <- ecgDelineate(pe, peaks)
head(delin)

## End(Not run)

Detect R-Peaks in ECG Signal Using Pan-Tompkins Algorithm

Description

Identifies R-peaks in ECG data using an adaptive dual-threshold Pan-Tompkins detector. The algorithm applies bandpass filtering (5-15 Hz), differentiation, squaring, and moving-window integration followed by adaptive thresholding with running signal and noise level estimates. Automatically detects and handles inverted ECG signals.

Usage

ecgDetectRpeaks(
  x,
  method = "pan_tompkins",
  threshold_factor = 0.6,
  refractory_ms = 200,
  assay_name = NULL
)

Arguments

x

A PhysioExperiment object with ECG data.

method

Detection method. Currently only "pan_tompkins" is supported.

threshold_factor

Fraction of the peak integrated signal used as the detection threshold (default: 0.6).

refractory_ms

Refractory period in milliseconds. No two peaks can be closer than this (default: 200).

assay_name

Name of the assay to use. If NULL, the default assay is used.

Value

A data.frame with one row per detected R-peak and the following columns:

channel

Integer channel index (1-based).

sample

Integer sample index of the R-peak within the assay matrix.

time_sec

Time of the R-peak in seconds from signal onset.

amplitude

Amplitude of the raw signal at the R-peak location (in original units, not inverted).

Returns a zero-row data.frame with the same column structure if no peaks are detected.

References

Pan, J. & Tompkins, W.J. (1985). "A real-time QRS detection algorithm." IEEE Transactions on Biomedical Engineering, 32(3), 230–236. doi:10.1109/TBME.1985.325532

See Also

ecgRRintervals for computing RR intervals from detected peaks, ecgDelineate for full waveform morphology analysis, ecgSignalQuality for signal quality assessment.

Examples

## Not run: 
pe <- make_ecg(n_time = 5000, sr = 500, heart_rate = 72)
peaks <- ecgDetectRpeaks(pe)
head(peaks)

## End(Not run)

Detrended Fluctuation Analysis of RR Intervals

Description

Performs detrended fluctuation analysis (DFA) on RR interval data to characterize fractal scaling properties. Computes alpha1 (short-range correlations, 4–16 beats) and alpha2 (long-range correlations, 16–64 beats).

Usage

ecgDFA(rr, short_range = c(4, 16), long_range = c(16, 64))

Arguments

rr

A data.frame with columns channel, rr_ms, and time_sec, as returned by ecgRRintervals.

short_range

Numeric vector of length 2 defining the scale range (in beats) for alpha1 (default: c(4, 16)).

long_range

Numeric vector of length 2 defining the scale range (in beats) for alpha2 (default: c(16, 64)).

Value

A data.frame with one row per channel and the following columns:

channel

Integer channel index.

alpha1

Short-range scaling exponent. Values near 1.0 indicate fractal-like (healthy) correlations; values near 0.5 indicate uncorrelated (random) behavior; values near 1.5 suggest Brownian noise. NA if the series is too short.

alpha2

Long-range scaling exponent with the same interpretation as alpha1 but over larger time scales. NA if the series is too short.

References

Peng, C.-K., et al. (1994). "Mosaic organization of DNA nucleotides." Physical Review E, 49(2), 1685–1689. doi:10.1103/PhysRevE.49.1685

See Also

ecgHRVnonlinear for the combined nonlinear analysis wrapper, ecgSampleEntropy for sample entropy, ecgHRVpoincare for Poincare plot descriptors.


HRV Frequency-Domain Analysis

Description

Computes heart rate variability frequency-domain metrics from RR interval data using Welch's method or Lomb-Scargle periodogram.

Usage

ecgHRVfreq(
  rr,
  method = c("welch", "lomb"),
  vlf_band = c(0.003, 0.04),
  lf_band = c(0.04, 0.15),
  hf_band = c(0.15, 0.4)
)

Arguments

rr

A data.frame with columns channel, rr_ms, and time_sec, as returned by ecgRRintervals.

method

Spectral estimation method: "welch" (default) for uniformly resampled FFT-based PSD, or "lomb" for Lomb-Scargle periodogram on unevenly sampled data.

vlf_band

Numeric vector of length 2 defining VLF band in Hz (default: c(0.003, 0.04)).

lf_band

Numeric vector of length 2 defining LF band in Hz (default: c(0.04, 0.15)).

hf_band

Numeric vector of length 2 defining HF band in Hz (default: c(0.15, 0.4)).

Value

A data.frame with one row per channel and the following columns:

channel

Integer channel index.

vlf

Absolute power in the very-low-frequency band (ms^2).

lf

Absolute power in the low-frequency band (ms^2), associated with sympathetic and parasympathetic modulation.

hf

Absolute power in the high-frequency band (ms^2), associated with parasympathetic (vagal) modulation.

lf_hf_ratio

Ratio of LF to HF power, or NA if HF power is zero.

total_power

Sum of VLF, LF, and HF power (ms^2).

References

Task Force of the European Society of Cardiology and the North American Society of Pacing and Electrophysiology (1996). "Heart rate variability: Standards of measurement, physiological interpretation and clinical use." Circulation, 93(5), 1043–1065.

See Also

ecgRRintervals for computing RR intervals, ecgHRVtime for time-domain HRV metrics, ecgHRVnonlinear for nonlinear HRV analysis, ecgRRcorrect for ectopic beat correction before analysis.

Examples

n <- 300
time_sec <- cumsum(rep(0.85, n))
rr_ms <- 850 + 30 * sin(2 * pi * 0.1 * time_sec)
rr <- data.frame(channel = rep(1L, n), rr_ms = rr_ms, time_sec = time_sec)
result <- ecgHRVfreq(rr, method = "welch")

Nonlinear HRV Analysis (Convenience Wrapper)

Description

Computes all nonlinear HRV metrics by calling ecgHRVpoincare, ecgSampleEntropy, and ecgDFA, and merging the results into a single data.frame.

Usage

ecgHRVnonlinear(
  rr,
  m = 2L,
  r_factor = 0.2,
  short_range = c(4, 16),
  long_range = c(16, 64)
)

Arguments

rr

A data.frame with columns channel, rr_ms, and time_sec, as returned by ecgRRintervals.

m

Embedding dimension for sample entropy (default: 2).

r_factor

Tolerance factor for sample entropy (default: 0.2).

short_range

Scale range for DFA alpha1 (default: c(4, 16)).

long_range

Scale range for DFA alpha2 (default: c(16, 64)).

Value

A data.frame with columns: channel, sd1, sd2, sd1_sd2_ratio, sample_entropy, m, r, alpha1, alpha2.

References

Shaffer, F. & Ginsberg, J.P. (2017). "An overview of heart rate variability metrics and norms." Frontiers in Public Health, 5, 258. doi:10.3389/fpubh.2017.00258

Task Force of the European Society of Cardiology and the North American Society of Pacing and Electrophysiology (1996). "Heart rate variability: Standards of measurement, physiological interpretation and clinical use." Circulation, 93(5), 1043–1065.

See Also

ecgHRVpoincare for Poincare plot descriptors, ecgSampleEntropy for sample entropy, ecgDFA for detrended fluctuation analysis, ecgHRVtime for time-domain HRV metrics, ecgHRVfreq for frequency-domain HRV analysis.


Poincare Plot Descriptors for HRV Analysis

Description

Computes Poincare plot descriptors (SD1, SD2, SD1/SD2 ratio) from RR interval data. SD1 reflects short-term variability (perpendicular to the identity line), while SD2 reflects long-term variability (along the identity line).

Usage

ecgHRVpoincare(rr)

Arguments

rr

A data.frame with columns channel, rr_ms, and time_sec, as returned by ecgRRintervals.

Value

A data.frame with one row per channel and the following columns:

channel

Integer channel index.

sd1

Standard deviation perpendicular to the identity line (ms), reflecting beat-to-beat (short-term) variability.

sd2

Standard deviation along the identity line (ms), reflecting long-term variability.

sd1_sd2_ratio

Ratio of SD1 to SD2, or NA if SD2 is zero.

References

Task Force of the European Society of Cardiology and the North American Society of Pacing and Electrophysiology (1996). "Heart rate variability: Standards of measurement, physiological interpretation and clinical use." Circulation, 93(5), 1043–1065.

See Also

ecgHRVnonlinear for the combined nonlinear analysis wrapper, ecgSampleEntropy for sample entropy, ecgDFA for detrended fluctuation analysis.


HRV Time-Domain Metrics

Description

Compute standard heart rate variability (HRV) time-domain metrics from RR interval data. Calculates SDNN, RMSSD, pNN50, mean RR interval, and mean heart rate for each channel.

Usage

ecgHRVtime(rr)

Arguments

rr

A data.frame with columns channel, rr_ms, and time_sec, as returned by ecgRRintervals.

Value

A data.frame with one row per channel and the following columns:

channel

Integer channel index.

mean_rr

Mean RR interval in milliseconds.

sdnn

Standard deviation of all RR intervals (ms), reflecting overall HRV.

rmssd

Root mean square of successive RR interval differences (ms), reflecting short-term vagal modulation.

pnn50

Percentage of successive RR intervals differing by more than 50 ms.

mean_hr

Mean heart rate in beats per minute (60000 / mean_rr).

References

Task Force of the European Society of Cardiology and the North American Society of Pacing and Electrophysiology (1996). "Heart rate variability: Standards of measurement, physiological interpretation and clinical use." Circulation, 93(5), 1043–1065.

See Also

ecgRRintervals for computing RR intervals, ecgHRVfreq for frequency-domain HRV analysis, ecgHRVnonlinear for nonlinear HRV metrics, ecgQualityCheck for ectopic beat detection before analysis.


Compute ECG Intervals from Delineation

Description

Calculates standard clinical ECG intervals from the waveform delineation produced by ecgDelineate: PR interval, QT interval, QTc (Bazett correction), QRS duration, and RR interval.

Usage

ecgIntervals(delineation, sr)

Arguments

delineation

A data.frame as returned by ecgDelineate, with columns channel, beat, r_peak, qrs_onset, qrs_offset, p_peak, t_peak, t_end.

sr

Sampling rate in Hz.

Value

A data.frame with one row per beat and the following columns:

channel

Integer channel index (1-based).

beat

Integer beat number within the channel.

pr_ms

PR interval in milliseconds (P-wave peak to QRS onset), or NA if the P wave was not detected.

qt_ms

QT interval in milliseconds (QRS onset to T-wave end), or NA if the T wave was not detected.

qtc_ms

Corrected QT interval using Bazett's formula (QT / sqrt(RR_sec)), or NA if QT or RR is unavailable.

qrs_ms

QRS complex duration in milliseconds.

rr_ms

RR interval in milliseconds to the next beat, or NA for the last beat in each channel.

Returns a zero-row data.frame with the same column structure if no beats are present.

References

Goldberger, A.L., et al. (2000). "PhysioBank, PhysioToolkit, and PhysioNet: Components of a new research resource for complex physiologic signals." Circulation, 101(23), e215–e220. doi:10.1161/01.CIR.101.23.e215

See Also

ecgDelineate for waveform delineation, ecgDetectRpeaks for R-peak detection, ecgRRintervals for RR interval computation.

Examples

## Not run: 
pe <- make_ecg(n_time = 5000, sr = 500, heart_rate = 72)
peaks <- ecgDetectRpeaks(pe)
delin <- ecgDelineate(pe, peaks)
intervals <- ecgIntervals(delin, samplingRate(pe))
head(intervals)

## End(Not run)

Detect Ectopic Beats in RR Interval Data

Description

Identifies ectopic (abnormal) beats by comparing each RR interval to the local median computed over a sliding window of 5 beats. Beats with deviation exceeding the threshold are marked as ectopic.

Usage

ecgQualityCheck(rr, threshold_ms = 300)

Arguments

rr

A data.frame with columns channel, rr_ms, and time_sec, as returned by ecgRRintervals.

threshold_ms

Maximum allowed deviation from local median in milliseconds (default: 300).

Value

The input data.frame with an additional logical column is_ectopic.

References

Clifford, G.D., Azuaje, F. & McSharry, P.E. (2006). Advanced Methods and Tools for ECG Data Analysis. Artech House.

Task Force of the European Society of Cardiology and the North American Society of Pacing and Electrophysiology (1996). "Heart rate variability: Standards of measurement, physiological interpretation and clinical use." Circulation, 93(5), 1043–1065.

See Also

ecgRRcorrect for correcting detected ectopic beats, ecgRRintervals for computing RR intervals, ecgHRVtime for time-domain HRV analysis, ecgSignalQuality for signal quality assessment.


Correct Ectopic Beats in RR Interval Data

Description

Replaces or removes ectopic beats identified by ecgQualityCheck. The "interpolate" method uses linear interpolation from surrounding non-ectopic intervals, while "remove" simply drops ectopic rows.

Usage

ecgRRcorrect(rr, method = c("interpolate", "remove"))

Arguments

rr

A data.frame with an is_ectopic logical column, as returned by ecgQualityCheck.

method

Correction method: "interpolate" (default) replaces ectopic values with linear interpolation; "remove" drops ectopic rows.

Value

A data.frame with corrected RR intervals. The is_ectopic column is removed from the output.

References

Clifford, G.D., Azuaje, F. & McSharry, P.E. (2006). Advanced Methods and Tools for ECG Data Analysis. Artech House.

See Also

ecgQualityCheck for detecting ectopic beats, ecgRRintervals for computing RR intervals, ecgHRVtime for time-domain HRV analysis.


Compute RR Intervals from Detected R-Peaks

Description

Calculates the time intervals between consecutive R-peaks for each channel. The resulting RR interval series is the standard input for all HRV analysis functions in this package.

Usage

ecgRRintervals(x, peaks)

Arguments

x

A PhysioExperiment object.

peaks

A data.frame of detected peaks as returned by ecgDetectRpeaks, with columns channel, sample, and time_sec.

Value

A data.frame with one row per consecutive beat pair and the following columns:

channel

Integer channel index (1-based).

rr_ms

RR interval in milliseconds (time between successive R-peaks).

time_sec

Time of the first beat in each pair (seconds from signal onset).

Returns a zero-row data.frame with the same column structure if fewer than two peaks are available.

References

Pan, J. & Tompkins, W.J. (1985). "A real-time QRS detection algorithm." IEEE Transactions on Biomedical Engineering, 32(3), 230–236. doi:10.1109/TBME.1985.325532

See Also

ecgDetectRpeaks for R-peak detection, ecgHRVtime for time-domain HRV metrics, ecgHRVfreq for frequency-domain HRV analysis, ecgQualityCheck for ectopic beat detection.

Examples

## Not run: 
pe <- make_ecg(n_time = 5000, sr = 500, heart_rate = 60)
peaks <- ecgDetectRpeaks(pe)
rr <- ecgRRintervals(pe, peaks)
head(rr)

## End(Not run)

Sample Entropy of RR Intervals

Description

Computes sample entropy (SampEn) from RR interval data. Sample entropy measures the regularity or predictability of a time series. Lower values indicate more regular (predictable) signals, while higher values indicate more complex (irregular) signals.

Usage

ecgSampleEntropy(rr, m = 2L, r_factor = 0.2)

Arguments

rr

A data.frame with columns channel, rr_ms, and time_sec, as returned by ecgRRintervals.

m

Embedding dimension (default: 2). Length of template patterns to compare.

r_factor

Tolerance factor (default: 0.2). The tolerance r is computed as r_factor * sd(rr_ms).

Value

A data.frame with one row per channel and the following columns:

channel

Integer channel index.

sample_entropy

Sample entropy value (nats). Lower values indicate more regular signals; higher values indicate more complex signals. NA if the series is too short or constant.

m

Embedding dimension used.

r

Tolerance threshold (ms) computed as r_factor * sd(rr_ms).

References

Richman, J.S. & Moorman, J.R. (2000). "Physiological time-series analysis using approximate entropy and sample entropy." American Journal of Physiology-Heart and Circulatory Physiology, 278(6), H2039–H2049. doi:10.1152/ajpheart.2000.278.6.H2039

See Also

ecgHRVnonlinear for the combined nonlinear analysis wrapper, ecgHRVpoincare for Poincare plot descriptors, ecgDFA for detrended fluctuation analysis.


Assess ECG Signal Quality Per Channel

Description

Computes per-channel signal quality metrics for ECG data stored in a PhysioExperiment object. When detected R-peak locations are provided the signal-to-noise ratio is estimated from QRS vs.\ baseline power; otherwise a variance-based estimate is used.

Usage

ecgSignalQuality(x, peaks = NULL, assay_name = NULL)

Arguments

x

A PhysioExperiment object with ECG data.

peaks

Optional data.frame of detected R-peaks as returned by ecgDetectRpeaks, with at least columns channel and sample.

assay_name

Name of the assay to use. If NULL the default assay is used.

Value

A data.frame with one row per channel and columns:

channel

Integer channel index.

snr_db

Signal-to-noise ratio in decibels.

baseline_wander

RMS amplitude of the low-frequency drift.

saturation_ratio

Fraction of samples within 1\ min or max.

quality_score

Composite quality score in the range [0, 1], where 1 indicates excellent quality.

References

Clifford, G.D., Azuaje, F. & McSharry, P.E. (2006). Advanced Methods and Tools for ECG Data Analysis. Artech House.

Shaffer, F. & Ginsberg, J.P. (2017). "An overview of heart rate variability metrics and norms." Frontiers in Public Health, 5, 258. doi:10.3389/fpubh.2017.00258

See Also

ecgDetectRpeaks for R-peak detection, ecgBaselineCorrect for baseline wander correction, ecgQualityCheck for ectopic beat detection.


Create Simulated ECG PhysioExperiment

Description

Generates a PhysioExperiment object containing synthetic ECG data with Gaussian-shaped R-peaks at regular intervals. The resulting object is suitable for testing R-peak detection, RR interval computation, and HRV analysis pipelines.

Usage

make_ecg(n_time = 5000, n_channels = 1, sr = 500, heart_rate = 72)

Arguments

n_time

Number of time points (default: 5000).

n_channels

Number of ECG channels (default: 1).

sr

Sampling rate in Hz (default: 500).

heart_rate

Heart rate in beats per minute (default: 72).

Value

A PhysioExperiment object with a single "raw" assay containing the simulated ECG signal.

References

Pan, J. & Tompkins, W.J. (1985). "A real-time QRS detection algorithm." IEEE Transactions on Biomedical Engineering, 32(3), 230–236. doi:10.1109/TBME.1985.325532

Clifford, G.D., Azuaje, F. & McSharry, P.E. (2006). Advanced Methods and Tools for ECG Data Analysis. Artech House.

See Also

make_ecg_irregular for ECG with ectopic beats, make_ecg_pqrst for ECG with full PQRST morphology, make_ecg_noisy for ECG with noise artifacts, ecgDetectRpeaks for R-peak detection.

Examples

pe <- make_ecg(n_time = 5000, sr = 500, heart_rate = 72)
pe

Create Simulated ECG with Irregular R-R Intervals

Description

Generates a PhysioExperiment object containing synthetic ECG data with irregular beat timing. Every 5th beat is premature (60\ interval), followed by a compensatory pause (140\ Useful for testing ectopic beat detection and RR interval correction.

Usage

make_ecg_irregular(n_time = 5000, sr = 500, heart_rate = 72)

Arguments

n_time

Number of time points (default: 5000).

sr

Sampling rate in Hz (default: 500).

heart_rate

Base heart rate in beats per minute (default: 72).

Value

A PhysioExperiment object with a single "raw" assay containing the simulated ECG signal with irregular beats.

References

Clifford, G.D., Azuaje, F. & McSharry, P.E. (2006). Advanced Methods and Tools for ECG Data Analysis. Artech House.

Task Force of the European Society of Cardiology and the North American Society of Pacing and Electrophysiology (1996). "Heart rate variability: Standards of measurement, physiological interpretation and clinical use." Circulation, 93(5), 1043–1065.

See Also

make_ecg for regular ECG data, ecgQualityCheck for ectopic beat detection, ecgRRcorrect for ectopic beat correction, ecgRRintervals for RR interval computation.

Examples

pe <- make_ecg_irregular(n_time = 5000, sr = 500, heart_rate = 72)
pe

Create Simulated ECG with Noise Artifacts

Description

Generates a PhysioExperiment object containing synthetic ECG data contaminated with multiple noise sources: baseline wander (0.3 Hz sinusoidal drift), powerline interference (50 Hz), and broadband Gaussian noise. Useful for testing signal quality assessment, baseline correction, and filtering pipelines.

Usage

make_ecg_noisy(
  n_time = 5000,
  n_channels = 1,
  sr = 500,
  heart_rate = 72,
  baseline_amp = 0.3,
  powerline_amp = 0.1,
  noise_sd = 0.15
)

Arguments

n_time

Number of time points (default: 5000).

n_channels

Number of ECG channels (default: 1).

sr

Sampling rate in Hz (default: 500).

heart_rate

Heart rate in beats per minute (default: 72).

baseline_amp

Amplitude of baseline wander in arbitrary units (default: 0.3).

powerline_amp

Amplitude of 50 Hz powerline noise (default: 0.1).

noise_sd

Standard deviation of broadband Gaussian noise (default: 0.15).

Value

A PhysioExperiment object with a single "raw" assay containing the noisy ECG signal.

References

Clifford, G.D., Azuaje, F. & McSharry, P.E. (2006). Advanced Methods and Tools for ECG Data Analysis. Artech House.

Shaffer, F. & Ginsberg, J.P. (2017). "An overview of heart rate variability metrics and norms." Frontiers in Public Health, 5, 258. doi:10.3389/fpubh.2017.00258

See Also

make_ecg for clean ECG data, ecgSignalQuality for signal quality assessment, ecgBaselineCorrect for baseline wander removal, ecgDetectRpeaks for R-peak detection.

Examples

pe <- make_ecg_noisy(n_time = 5000, sr = 500)
pe

Create Simulated ECG with PQRST Morphology

Description

Generates a PhysioExperiment object containing synthetic ECG data with physiologically realistic P, Q, R, S, and T wave components. Returns both the PhysioExperiment and a data.frame of known fiducial points for validation testing of waveform delineation algorithms.

Usage

make_ecg_pqrst(
  n_time = 10000,
  n_channels = 1,
  sr = 500,
  heart_rate = 72,
  noise_sd = 0.02
)

Arguments

n_time

Number of time points (default: 10000, i.e., 20 seconds at 500 Hz).

n_channels

Number of ECG channels (default: 1).

sr

Sampling rate in Hz (default: 500).

heart_rate

Heart rate in beats per minute (default: 72).

noise_sd

Standard deviation of baseline noise (default: 0.02).

Value

A list with two components:

pe

PhysioExperiment object with the simulated ECG signal.

fiducials

A data.frame with columns: beat, r_peak, p_peak, q_point, s_point, t_peak, qrs_onset, qrs_offset (all in sample indices).

References

Goldberger, A.L., et al. (2000). "PhysioBank, PhysioToolkit, and PhysioNet: Components of a new research resource for complex physiologic signals." Circulation, 101(23), e215–e220. doi:10.1161/01.CIR.101.23.e215

Clifford, G.D., Azuaje, F. & McSharry, P.E. (2006). Advanced Methods and Tools for ECG Data Analysis. Artech House.

See Also

make_ecg for basic ECG data, ecgDelineate for PQRST waveform delineation, ecgIntervals for computing clinical ECG intervals, ecgDetectRpeaks for R-peak detection.

Examples

result <- make_ecg_pqrst(n_time = 10000, sr = 500, heart_rate = 72)
pe <- result$pe
fiducials <- result$fiducials
head(fiducials)