Skip to content

Pan-Tompkins-style ECG R-wave detection

What it does

This detector locates ordered R-wave occurrence times in a sampled ECG signal. It can also return the filtered ECG, squared derivative, and integrated envelope used to inspect detections.

When to use it

Use it for conventional QRS-oriented R-wave detection when the ECG sampling frequency is known. The intermediate signals are useful for checking why a beat was accepted or missed.

Canonical ID: ecg.pantompkins

Inputs

Name Meaning Type Unit Requirements
ecg Sampled ECG signal in which R waves will be detected. real vector a.u. NaN allowed; finite
sampling_frequency Sampling frequency of the ECG signal. real scalar Hz greater than: 0; no NaN; finite

Parameters

Name Meaning Type Unit Default Requirements
bandpass_frequency Lower and upper cutoff frequencies of the detection band-pass filter. real vector Hz [5, 12] minimum length: 2
integration_window_size Duration of the moving integration window used by the detector. real scalar s 0.15 greater than: 0
minimum_peak_distance Minimum accepted temporal separation between candidate R waves. real scalar s 0.5 greater than: 0
snap_to_peak_window_size Local search radius used to refine each detection on the ECG. real scalar sample 20 greater than: 0

Outputs

Name Meaning Type Unit
r_wave_times Detected R-wave occurrence times in ascending order. real vector s
ecg_filtered Band-pass-filtered ECG used by the detection chain. real vector a.u.
decg_squared Squared derivative signal used to emphasize rapid QRS changes. real vector a.u.^2
decg_envelope Integrated detection envelope used to locate candidate beats. real vector a.u.^2

How it works

Finite ECG segments pass through band-pass filtering, derivative filtering, squaring, moving-window integration, peak detection, and local peak refinement. NaN samples separate independent finite segments so filtering and detection never cross a missing-data gap.

Interpretation and limitations

The detector follows the Pan-Tompkins processing approach but is not an exact reproduction of the original real-time algorithm. Noise, atypical QRS morphology, poor parameter choices, or records shorter than the required processing context can reduce detection reliability.

References

  • Jiapu Pan and Willis J. Tompkins (1985). A Real-Time QRS Detection Algorithm. IEEE Transactions on Biomedical Engineering.

Implementations and technical resources

Python source | MATLAB source

Normative JSON | Validation cases