Fact-checked by Grok 2 weeks ago

Pan–Tompkins algorithm

The Pan–Tompkins algorithm is a digital signal processing method for detecting QRS complexes in electrocardiogram (ECG) signals, designed to identify the characteristic sharp deflections representing ventricular in the heart's electrical activity. Developed in 1985 by biomedical engineers Jiapu Pan and Willis J. Tompkins, it processes ECG data through a sequence of filters and operations—bandpass filtering to isolate QRS frequencies, to emphasize slope changes, squaring to highlight peaks, and moving-window integration to assess width—followed by adaptive thresholding to locate R-waves with minimal false detections. This approach enables efficient, low-computational analysis suitable for clinical monitoring and automated diagnostic systems. The algorithm was specifically created to address challenges in real-time ECG analysis, such as from muscle artifacts, power-line interference, and baseline wander, which can obscure QRS features in or Holter monitoring applications. By employing integer arithmetic on microprocessors like the Z80 or NSC800, it achieves hardware-efficient implementation without requiring floating-point operations, making it practical for medical devices. Its adaptive thresholds dynamically adjust to variations in QRS morphology and , reducing the need for manual tuning and improving reliability across diverse patient populations. Key components include a with a 5–12 Hz to enhance QRS energy while attenuating irrelevant frequencies, a five-point filter for slope extraction, nonlinear squaring to amplify QRS peaks relative to slower waves, and a 150 ms integration window to capture the complex's duration. Decision rules incorporate dual thresholds—one for periods post-detection and a lower one for search-back in noisy segments—to handle missed beats or premature ventricular contractions. These elements collectively prioritize without excessive false positives, distinguishing it from earlier analog-based detectors. Widely regarded as a for QRS detection, the Pan–Tompkins algorithm demonstrated 99.3% accuracy on the MIT/BIH Database, with only 0.239% false negatives and 0.437% false positives across over 116,000 beats from 48 half-hour excerpts. It has become a foundational technique in cardiac monitoring, wearable ECG devices, and extensions to fetal ECG analysis, influencing subsequent algorithms that build upon its filtering and thresholding framework.

Introduction

Overview

The Pan–Tompkins algorithm is a method for detecting QRS complexes in electrocardiogram (ECG) signals, enabling the identification of individual heartbeats through digital analysis of signal slope, amplitude, and width. Developed by Jiapu Pan and Willis J. Tompkins, it was introduced in a 1985 publication in the IEEE Transactions on . The algorithm is designed for applications such as monitoring and automated ECG analysis, where accurate and timely heartbeat detection is essential. It takes as input a raw digital ECG signal, typically sampled at 200 samples per second, and produces as output a series of timestamps or markers indicating the locations of R-peaks or onsets. The overall workflow begins with preprocessing stages that enhance the QRS-related features while suppressing noise, followed by rule-based decision mechanisms to classify and confirm detected peaks. In evaluations on the MIT/BIH Arrhythmia Database, the algorithm achieves a detection of 99.3%, with a false negative rate of 0.239% and a of 0.437%, demonstrating high positive predictivity and suitability for processing.

Historical Development

The Pan–Tompkins algorithm was developed in 1985 by Jiapu Pan and Willis J. Tompkins at the , addressing the need for an automated, method to detect QRS complexes in electrocardiogram (ECG) signals. Prior to this, manual annotation of ECG data was labor-intensive, particularly for clinical analysis and long-term Holter , where false detections could compromise and ambulatory . The algorithm was motivated by the requirement for a reliable, computationally efficient approach suitable for implementation, enabling applications in monitors and reducing reliance on human intervention. The original algorithm was detailed in the seminal paper "A QRS Detection Algorithm," published in IEEE Transactions on , Volume BME-32, Number 3, March 1985, pages 230–236. Initial evaluation involved 48 half-hour ECG excerpts from the MIT-BIH Database, comprising 109,514 beats from diverse recordings. The algorithm achieved a 99.3% QRS detection rate, with a total failure rate of 0.675% (0.437% false positives and 0.239% false negatives), demonstrating high and positive predictivity even in noisy conditions. Following its publication, the Pan–Tompkins algorithm rapidly influenced ECG processing in the and , establishing a for QRS detection due to its simplicity, real-time performance, and accuracy. It was implemented in early microprocessor-based systems, such as Z80 assembly language programs, and inspired modifications like adaptive thresholding by and Tompkins in 1986, which further improved robustness. This early adoption shaped subsequent software and hardware for clinical and analysis, becoming a foundational method in .

Signal Preprocessing

Bandpass Filtering

The bandpass filtering stage in the Pan–Tompkins algorithm serves as the initial preprocessing step to mitigate various sources of noise in electrocardiogram (ECG) signals, thereby enhancing the and facilitating accurate detection. Specifically, it attenuates low-frequency baseline wander caused by or electrode movement (typically below 5 Hz) and high-frequency noise such as interference at 50–60 Hz or muscle artifacts above 25 Hz, while preserving the spectral content associated with the . This noise reduction allows for the use of lower detection thresholds in subsequent stages, improving overall sensitivity without increasing false positives. The filter is designed as a recursive digital bandpass filter with integer coefficients, constructed by cascading a high-pass filter to eliminate baseline drift and a low-pass filter to suppress high-frequency noise. The approximate 3 dB passband is 5–12 Hz, targeted to align with the dominant frequency range of QRS complexes (5–15 Hz), ensuring that the steep slopes of the Q, R, and S waves are emphasized relative to slower P and T waves. In implementations suitable for offline analysis, this is often realized as a bidirectional infinite impulse response (IIR) filter using forward-backward processing to achieve zero-phase distortion, avoiding signal shifts that could misalign fiducial points; however, the original real-time design employs causal recursive filtering for microprocessor efficiency. The mathematical formulation approximates the bandpass through these cascaded components, assuming a of 200 Hz. The , with a around 11–12 Hz and a of 36, follows the difference equation: y_{LP} = 2y_{LP}[n-1] - y_{LP}[n-2] + x - 2x[n-6] + x[n-12] This introduces a delay of 6 samples. The high-pass filter, with a around 5 Hz and a of 32, uses: y_{HP} = 32x[n-16] - y_{HP}[n-1] - x + x[n-32] with a delay of 16 samples. The overall bandpass output is the cascade y_{BP} = y_{LP}(y_{HP}(x)), enabling integer arithmetic for low computational cost in real-time applications. These equations were derived to match the QRS spectrum while minimizing hardware requirements on devices like the Z80 microprocessor. This filtering step effectively amplifies the high-frequency components of the QRS complex's slope, making it stand out against attenuated P and T waves, baseline artifacts, and noise, thus preparing the signal for time-domain enhancement in the derivative stage. The 5–15 Hz passband parameters were selected based on spectral analysis of QRS energy in standard ECG databases, ensuring robust performance across varying heart rates and noise conditions.

Differentiation

The differentiation step computes the time derivative of the bandpass-filtered ECG signal to provide slope information on the , thereby emphasizing its steep transitions relative to the gentler slopes of the P and T waves. This enhances the high-frequency content associated with the rapid ventricular in the while attenuating lower-frequency components from slower atrial and waves. The derivative is approximated using a simple five-point digital with the difference equation y(nT) = \frac{1}{8T} \left[ -x(nT - 2T) - 2x(nT - T) + 2x(nT + T) + x(nT + 2T) \right], where x denotes the input samples, y the output signal, n the time , and T the sampling . This is non-causal due to the use of future samples and introduces a two-sample delay to enable . The corresponding transfer function is H(z) = \frac{1}{8T} (-z^{-2} - 2z^{-1} + 2z + z^{2}), which yields a nearly linear response from to 30 Hz and introduces a two-sample delay. The output exhibits positive peaks corresponding to upward slopes (such as the Q-to-R transition) and negative peaks for downward slopes (such as the R-to-S transition), thereby amplifying QRS-related changes while suppressing flat or slowly varying segments. This is tailored for ECG sampling rates of 200 samples per second, as used in the original implementation with 12-bit analog-to-digital conversion hardware prevalent in the mid-1980s.

Squaring

The squaring step in the Pan–Tompkins algorithm performs a nonlinear transformation on the differentiated ECG signal to negative values and emphasize the magnitude of slope changes, particularly those associated with the QRS complex. This operation discards directional information from the , allowing the algorithm to focus on the absolute steepness of waveform transitions, which is crucial for distinguishing the prominent QRS slopes from shallower features like P or T waves. By converting the signal into a purely positive domain, squaring enhances the detectability of QRS-related peaks while mitigating the impact of biphasic patterns. The method entails point-wise squaring of each sample in the differentiated signal, a straightforward that applies the transformation instantaneously without requiring windowing or additional filtering. Mathematically, this is formulated as s = (d)^2 where d represents the output of the stage at time n. This equation ensures all output values are non-negative, with the nonlinear amplification disproportionately boosting larger derivative magnitudes—typically those exceeding 1 in —while attenuating smaller ones. A primary effect of this step is the transformation of the QRS complex's , which often exhibits biphasic (positive-negative) excursions due to the Q-R-S sequence, into a unimodal positive centered around the R-wave slope. This unimodal shape simplifies for peak identification and further suppresses low-amplitude , as squaring reduces the relative influence of small fluctuations (e.g., wander remnants or high-frequency artifacts) compared to the amplified QRS signals. Additionally, the operation steepens the curve of the preceding , helping to limit false positives from T-waves that might otherwise carry elevated spectral energy. From a computational perspective, the squaring operation is highly efficient, relying solely on that can be implemented using integer arithmetic on low-power microprocessors. This simplicity makes it well-suited for ECG analysis in resource-constrained systems, such as portable monitors, without introducing significant processing delays or demands.

Moving Window Integration

The moving window integration serves as the concluding preprocessing stage in the Pan–Tompkins algorithm, integrating the squared signal over a brief temporal window to approximate the duration while attenuating high-frequency noise components. This integration is performed as a running sum across a 150 ms , equivalent to approximately 30 samples at the 200 Hz sampling rate specified in the original implementation. The size is selected to align with the typical QRS duration of 80–120 ms observed in adult ECGs, ensuring comprehensive coverage of the without excessive broadening that could obscure distinctions from adjacent features. The mathematical formulation computes the integrated signal i as the mean of the squared signal s over the : i = \frac{1}{30} \sum_{k=0}^{29} s[n-k] For efficient real-time computation, a recursive approximation is employed: i = i[n-1] + \frac{1}{30} (s - s[n-30]) This approach minimizes arithmetic operations by leveraging prior values. The resulting signal features broadened QRS peaks spanning roughly 150 ms, with diminished noise, thereby enhancing the signal's suitability for subsequent threshold-based peak identification. The squared signal, which emphasizes instantaneous slope magnitudes, forms the direct input to this integration.

QRS Detection Rules

Fiducial Mark Placement

Fiducial mark placement in the Pan–Tompkins algorithm serves to locate candidate R-wave peaks as reference points, or fiducial marks, for determining heartbeat timing within the ECG signal. These marks approximate the onset or center of the , enabling subsequent analysis of cardiac and detection. The process relies on the preprocessed integrated signal, which emphasizes the QRS complex's characteristic slope and duration following bandpass filtering, , squaring, and moving-window . The method involves identifying peaks in the integrated signal that surpass the adaptive , with the fiducial mark determined from the rising of the integrated waveform, corresponding to the R-wave peak in the original ECG signal—typically by locating the point of maximal slope or searching back a fixed number of samples from the integrated peak. This step transforms the envelope-like integrated waveform into discrete markers aligned with ventricular events. By focusing on features of this signal, achieves high to QRS features while minimizing from baseline wander or . In the detection process, the integrated signal i is examined sample by sample. A in i exceeding the triggers placement of the fiducial mark at the corresponding R-peak position in the original signal. This criterion ensures precise localization of prominent R-wave candidates without requiring complex feature extraction. These fiducial marks act as the initial anchors in the overall , facilitating the of detected events and serving as points for interval measurements like RR intervals. As the algorithm processes incoming ECG data, the marks are iteratively refined based on confirmed QRS detections, supporting continuous real-time monitoring. To address scenarios with multiple candidate peaks from a single QRS complex, the algorithm enforces a period of 200 ms after the previous fiducial mark, during which only the highest qualifying is selected as the valid fiducial. This avoids duplicate markings for the same , enhancing detection reliability in noisy or variable ECG recordings.

Threshold Setting

The threshold setting in the Pan-Tompkins algorithm utilizes adaptive s to dynamically adjust detection thresholds, enabling robust identification amid ECG signal variability, such as amplitude fluctuations from patient motion, electrode shifts, or physiological changes. These thresholds float above noise levels while tracking genuine QRS s, thereby minimizing false detections and missed s across diverse signal conditions. Thresholds are initialized during an initial 2-second learning phase, starting at low values to broadly capture early signal and features without prior assumptions about ECG . Two parallel sets are employed: one for the bandpass-filtered ECG (THRESHOLD_F1 and THRESHOLD_F2) and one for the moving-window output (THRESHOLD_I1 and THRESHOLD_I2), reflecting the algorithm's multi-stage feature extraction. Signal estimates (SPKF for filtered, SPKI for ) and estimates (NPKF, NPKI) are established from peaks detected in this phase, serving as the foundation for ongoing adaptations. The algorithm maintains two exponentially weighted moving averages of the RR interval: RR-AVERAGE1 (short-term, updated with weight 1/16 for rapid adaptation to arrhythmias) and RR-AVERAGE2 (long-term, weight 1/64 for stable rhythms). Irregular rhythms are detected when the new RR interval exceeds 1.66 × RR-AVERAGE1 or is less than 0.66 × RR-AVERAGE1, triggering enhanced . Updates to these estimates occur continuously using exponentially weighted moving averages, with a primary of 0.125 for the current and 0.875 for the estimate to ensure . For a classified as a QRS signal in the (PEAKI), the signal estimate updates as: \text{SPKI}(n) = 0.125 \times \text{PEAKI} + 0.875 \times \text{SPKI}(n-1) If the peak is deemed noise, the noise estimate follows analogously: \text{NPKI}(n) = 0.125 \times \text{PEAKI} + 0.875 \times \text{NPKI}(n-1) Identical updates apply to the filtered waveform using PEAKF, SPKF, and NPKF. The primary signal for (THRESHOLD_I1) is then computed relative to levels: \text{THRESHOLD\_I1} = \text{NPKI} + 0.25 \times (\text{SPKI} - \text{NPKI}) The secondary , used for lower-amplitude events, is half this value (THRESHOLD_I2 = 0.5 × THRESHOLD_I1), with corresponding formulas for THRESHOLD_F1 and THRESHOLD_F2. In cases of irregular heart rates or potential low-amplitude QRS detections via the secondary , updates accelerate by doubling the weight on the current peak (e.g., SPKI = 0.25 × PEAKI + 0.75 × SPKI), and thresholds may halve temporarily to enhance . These mechanisms ensure thresholds decay toward baselines during quiet periods while rising with prominent QRS activity, maintaining a dynamic 1.25:1 ratio between signal and noise influences. A 200 ms period follows each QRS detection, during which no new detections are permitted, preventing redundant triggers from prolonged QRS slopes or artifacts and stabilizing threshold updates by avoiding clustered false positives. This period aligns with physiological constraints, as no two QRS complexes can occur closer than approximately 200 ms in normal rhythms.

Search Back Mechanism

The search back mechanism in the –Tompkins algorithm serves to recover QRS complexes that may have been missed during initial forward detection due to high adaptive thresholds, particularly in scenarios involving arrhythmias or degraded signal quality where low-amplitude events fail to exceed the primary signal threshold. This retrospective procedure enhances the algorithm's by addressing false negatives without compromising specificity in normal conditions. The mechanism is triggered when no QRS complex is detected within a time window equivalent to 1.66 times the current average RR interval (using RR-AVERAGE2), which approximates the expected duration for up to eight beats assuming a of 60 beats per minute. Upon expiration of this search interval—following an initial 200 refractory period after the last confirmed beat—the algorithm initiates a search back over the interval since the last detection, identifying the maximum exceeding the secondary (e.g., THRESHOLD_I2). If this aligns with physiologically plausible timing relative to the prior beat (e.g., avoiding intervals shorter than the refractory period), it is classified as a valid QRS fiducial point. This temporary relaxation leverages the ongoing adaptive thresholding process to focus on subtle features that were borderline in the forward pass. Upon confirmation of a beat via search back, the average RR interval is immediately updated using the new interval measurement, resetting the search parameters and accelerating threshold adaptations to twice the normal rate for subsequent cycles to better track potential ongoing irregularities. This dynamic update helps mitigate cumulative errors in noisy segments by restoring nominal detection sensitivity promptly. The search back mechanism contributes significantly to the algorithm's overall performance, achieving high detection rates on the , particularly for low-amplitude QRS complexes as seen in recordings, where it reduces missed beats and supports an aggregate sensitivity exceeding 99%.

T-Wave Discrimination

The T-wave rule in the Pan-Tompkins algorithm serves to prevent false positive QRS detections caused by tall T-waves, which can mimic QRS complexes particularly in conditions like or when R-R intervals are short (less than 360 ms). This step is crucial for maintaining high detection accuracy, as large T-waves may produce peaks in the preprocessed integrated signal that resemble those of QRS complexes. The discrimination process activates for candidate peaks occurring after a 200 ms refractory period following the previous QRS but within 360 ms of it. In such cases, the algorithm evaluates the maximal of the candidate in the integrated signal; if this is less than half the of the preceding , the candidate is classified as a T-wave and rejected. This slope-based criterion leverages the sharper, steeper profile of true QRS complexes compared to the more rounded shape of T-waves, where the signal indicates lower peak values relative to the integrated signal peak (typically less than 0.5 times the signal peak). An additional check compares the -to-integrated signal ratio against a to further confirm the rounded indicative of a T-wave, ensuring rejection if the ratio falls below half the typical value for a QRS. Introduced in the original 1985 formulation of the algorithm, this T-wave discrimination mechanism addressed potential false detections from T-wave interference, contributing to an overall QRS detection sensitivity and positive predictivity of 99.3% on the MIT/BIH Arrhythmia Database. Without such shape analysis, preliminary tests showed elevated false positive rates of approximately 5-10% in noisy or abnormal ECGs, highlighting the rule's role in robust performance.

Implementation and Applications

Algorithm Implementation

The Pan–Tompkins algorithm is typically implemented for ECG signals sampled at 200 Hz, as specified in the original design, but adaptations for higher rates like 360 Hz—common in databases such as MIT-BIH—are achieved through downsampling or filter coefficient adjustments to maintain the 5–11 Hz . For rates exceeding 360 Hz, downsampling to 200–360 Hz is recommended to avoid and ensure filter efficacy without excessive computational overhead. The algorithm exhibits O(N) linear time complexity, where N is the number of samples, due to its sequential filtering and thresholding operations, making it efficient for resource-constrained devices. On 1980s-era microprocessors like the Z80, the implementation in assembly language enabled real-time processing at 200 Hz, demonstrating its suitability for embedded systems even with integer arithmetic. A high-level pseudocode outline for the algorithm processes an input ECG signal to produce a list of R-peak indices, integrating preprocessing and detection in a over samples:
[function](/page/Function) r_peaks = pan_tompkins(ecg_signal, fs)
    % Initialize buffers and thresholds
    N = [length](/page/Length)(ecg_signal)
    bandpass_signal = zeros(N, 1)
    differentiated = zeros(N, 1)
    squared = zeros(N, 1)
    integrated = zeros(N, 1)
    rr_avg1 = 0  % Short-term average [RR](/page/RR) interval
    rr_avg2 = 0  % Long-term average [RR](/page/RR) interval
    qrs_threshold1 = 0
    qrs_threshold2 = 0
    noise_threshold = 0
    search_back_window = 0
    
    % Step 1: Bandpass filtering (5-11 Hz, causal IIR)
    for i = 1 to N
        bandpass_signal(i) = apply_bandpass_filter(ecg_signal(i), previous_states)
        % Low-pass: y(n) = [2*y(n-1) - y(n-2) + x(n) - 2*x(n-2) + x(n-4)] / 8 + gain adjustments
        % High-pass: difference equation for slope approximation
    end
    
    % Step 2: [Differentiation](/page/Differentiation)
    for i = 5 to N  % Adjusted for 5-point window
        differentiated(i) = [-bandpass_signal(i-2) - 2*bandpass_signal(i-1) + 2*bandpass_signal(i) + bandpass_signal(i+1)] / 8
        % 5-point [derivative](/page/Derivative) approximation (causal version may use delayed samples)
    end
    
    % Step 3: Squaring
    squared = differentiated .^ 2
    
    % Step 4: Moving window integration (window width ~0.15 s, e.g., 30 samples at 200 Hz)
    for i = window_width to N
        integrated(i) = sum(squared(i-window_width+1 : i)) / window_width
    end
    
    % Step 5: QRS detection with adaptive thresholds and rules
    r_peaks = []
    for i = 1 to N
        signal_i = integrated(i)
        
        % Update thresholds based on recent peaks (refractory period ~200 ms)
        if signal_i > qrs_threshold1 and i - last_rr > 200/fs
            % Potential QRS: check slope and noise
            if is_QRS_candidate(signal_i, bandpass_signal(i), noise_threshold)
                r_peaks.append(i)
                % Update RR averages and thresholds
                if [length](/page/Length)(r_peaks) > 1
                    rr = i - r_peaks(end-1)
                    rr_avg1 = 0.125 * rr + 0.875 * rr_avg1
                    rr_avg2 = 0.25 * rr + 0.75 * rr_avg2
                end
                qrs_threshold1 = 0.5 * signal_i + 0.5 * qrs_threshold1  % Adaptive update
                search_back_window = 1.66 * rr_avg2  % For missed beats
            else
                noise_threshold = 0.15 * signal_i + 0.85 * noise_threshold
            end
        % Search back for missed beats within window if no recent QRS
        elif [length](/page/Length)(r_peaks) > 0 and i - r_peaks(end) > 1.66 * rr_avg1
            % [Scan](/page/Scan) back in bandpass signal for [peak](/page/Peak) > qrs_threshold2
            back_peak = find_peak_in_back(bandpass_signal, i - search_back_window, i, qrs_threshold2)
            if back_peak
                r_peaks.append(back_peak)
        end
    end
    return r_peaks
end
This follows the sequential steps from the original , with loops for each transformation and detection logic to handle adaptive thresholding and search-back. Software implementations are available in languages like and for core and detection. For example, a snippet for the (high-pass followed by low-pass at 200 Hz) is:
matlab
% High-pass filter coefficients (for QRS slope)
b_hp = [1 -2 2 -1]; a_hp = [1];  % Simple [differentiator](/page/Differentiator) approximation
% Low-pass filter (span 12 ms, 6-sample delay at 200 Hz)
b_lp = [1 1 1 1 1 1 1 1 1 1 1 1]; a_lp = 12 * ones(1,12);
[bandpass = filter](/page/Band-pass_filter)(b_lp, a_lp, filter(b_hp, a_hp, ecg_signal));
In , the NeuroKit2 library provides a Pan–Tompkins-based R-peak detector via ecg_findpeaks with the 'pan' method, integrating the full pipeline. Open-source examples also exist in py-ecg-detectors, which implements the original thresholding for QRS detection. For real-time execution, the algorithm employs causal filters to minimize latency, with a total delay of approximately 24 samples from filtering (6 for low-pass, 16 for high-pass, 2 for ), equating to about 67 ms at 360 Hz or 120 ms at 200 Hz. Buffering is required for the moving-window integration (e.g., 30 samples) and search-back mechanism (up to 1.66 times the average interval, typically 200–400 ms), enabling low-latency processing under 50 ms in optimized high-sampling-rate variants on modern hardware.

Clinical and Research Uses

The Pan–Tompkins algorithm is widely employed in clinical settings for real-time through Holter devices, which facilitate ECG analysis over extended periods to detect irregularities in cardiac rhythm. In intensive care units (ICUs), it supports detection by identifying QRS complexes to reduce false alarms for conditions such as , , and , enabling timely interventions. For wearable ECG systems, modified versions of the algorithm process single-lead signals for continuous , achieving high efficiency in low-power environments suitable for remote patient care. In research, the algorithm serves as a benchmark for evaluating QRS detection on standard ECG datasets such as the MIT-BIH Arrhythmia Database and PhysioNet repositories, where it demonstrates sensitivity and positive predictivity exceeding 99% for normal sinus rhythms. It is frequently utilized in over a thousand studies for feature extraction, particularly RR intervals, to train machine learning classifiers for arrhythmia identification and heartbeat categorization. In atrial fibrillation (AFib) scenarios, while base accuracy may drop due to irregular rhythms, hybrid adaptations combining it with deep learning enhance detection rates to over 95%. As of 2025, integrations with deep learning have further improved its robustness for real-time detection in noisy wearable and telemedicine applications. The algorithm aligns with standards like ANSI/ EC13 for ECG analyzers, where implementations are validated against test waveforms to ensure performance in cardiac monitoring systems. Open-source tools such as the WFDB library on PhysioNet incorporate Pan–Tompkins-based detectors like ECGPUWAVE for reproducible validation and of ECG data. Post-1985 developments have extended its use to fetal ECG from abdominal signals, with optimized thresholds improving QRS detection in noisy maternal-fetal recordings. Adaptations also support protocols by handling motion artifacts in exercise-induced ECG variations.

Limitations and Enhancements

Known Limitations

The Pan–Tompkins algorithm demonstrates notable sensitivity to noise, particularly in scenarios involving high-motion artifacts or poor contact, as commonly encountered in ECG monitoring. In such conditions, detection accuracy can fall below 90%, with empirical evaluations on low-quality databases simulating wearable device signals reporting rates as low as 74.49% for the original implementation due to artifacts and sudden amplitude fluctuations disrupting threshold-based decisions. In arrhythmia detection, the algorithm can struggle with premature beats or ventricular ectopic beats that deviate significantly in timing or morphology from normal sinus rhythm, potentially leading to false negatives. The algorithm also faces challenges with amplitude variability, struggling to detect very low-amplitude QRS complexes, despite the partial mitigation offered by the search back mechanism. Its fixed parameters, tuned to 5–15 Hz for enhancing adult QRS features while suppressing noise, assume standard adult ECG characteristics and perform less effectively on non-adult signals, such as fetal ECG, where QRS and content differ significantly. Critiques of the algorithm's evaluation highlight a in original testing on the MIT-BIH database, which primarily includes clean, controlled signals yielding over 99% accuracy, whereas real-world diverse datasets show performance drops to approximately 95% or lower, underscoring limitations in generalizing to noisy, heterogeneous conditions. Additionally, while efficient, the algorithm's multi-stage filtering can pose challenges for ultra-low-power systems without optimization.

Modern Variants

Modern variants of the Pan–Tompkins algorithm have emerged since the to enhance its robustness against noise, adaptivity to varying signal conditions, and integration with advanced computational techniques, addressing challenges in ECG for portable and multi-channel applications. Wavelet-based hybrids combine the bandpass filtering and derivative stages of Pan–Tompkins with discrete wavelet transforms (DWT) to improve feature extraction in noisy environments, such as motion artifacts in ambulatory monitoring. For instance, the Complex-Pan-Tompkins-Wavelets (CPTW) approach replaces the traditional derivative with a fourth-scale approximation for cross-channel detection, achieving higher (up to 99.8%) on MIT-BIH database signals corrupted by baseline wander and muscle noise. Similarly, a 2012 integrates multi-resolution coefficients with Pan–Tompkins thresholding to delineate QRS boundaries more accurately, reducing false positives by 15-20% in low-signal-to-noise ratio (SNR) conditions compared to the original algorithm. These enhancements leverage wavelets' time-frequency localization to better isolate QRS complexes from overlapping T-waves or artifacts. Machine learning integrations utilize QRS locations detected by Pan–Tompkins as fiducial points or features for subsequent tasks, particularly in detection . In the PhysioNet/Computing in Cardiology 2020, hybrid models employed Pan–Tompkins-derived R-R intervals and morphological features as inputs to convolutional neural (CNNs) and recurrent neural (RNNs), such as LSTMs, enabling end-to-end 12-lead ECG with F1-scores exceeding 0.85 for multiple cardiac . A 2025 enhanced model combines Pan–Tompkins QRS detection with CNN-BiLSTM architectures and attention mechanisms, extracting spatiotemporal features for beat and achieving 99.20% accuracy on the MIT-BIH Database, outperforming standalone Pan–Tompkins by mitigating errors in irregular rhythms. These approaches treat Pan–Tompkins outputs as robust anchors, feeding them into deep to handle variability in cohorts without retraining the core detector. Adaptive variants incorporate least mean squares (LMS) algorithms to dynamically adjust filter parameters, such as bandpass cutoffs or thresholds, in response to signal variations like motion or respiratory . A 2017 adaptive filtering framework based on LMS modifies the Pan–Tompkins differentiator stage to track changing QRS slopes, yielding high detection rates (up to 99.68% ) on noisy MIT-BIH records. This adjustment via LMS error minimization reduces computational overhead while maintaining low , suitable for battery-constrained devices. Multi-lead extensions extend Pan–Tompkins to 12-lead ECG systems by incorporating signal quality indices (SQIs) to weight contributions from individual leads, prioritizing those with higher fidelity for collective QRS detection. A 2018 algorithm fuses outputs across leads using weighted averaging based on noise variance estimates, improving overall sensitivity to 99.5% on multi-lead PTB diagnostics database by suppressing artifacts in poor-quality channels like V1-V3 during exercise. Further, a 2025 compression-aware variant applies lead-specific Pan–Tompkins with quality-weighted thresholding, enabling sparse representation of 12-lead signals while preserving QRS fidelity for telecardiology applications. Recent developments up to 2025 emphasize -augmented versions tailored for wearables, where Pan–Tompkins serves as a lightweight preprocessor for edge-based . In ECG-enabled devices like those from and similar platforms, hybrid models using Pan–Tompkins R-peak detection achieve over 99% accuracy in noisy wrist-worn data, as validated in remote monitoring studies for screening. Open-source evolutions, such as implementations like the py-ecg-detectors library, facilitate community-driven refinements for integration into consumer health . These advancements enable seamless integration into consumer health .

References

  1. [1]
    [PDF] A Real-Time QRS Detection Algorithm
    PAN AND TOMPKINS: REAL-TIME QRS DETECTION ALGORITHM. Fig. 6. Experimental setup for evaluating theQRS detection algorithm using the MIT/BIH database. 1: ECG ...
  2. [2]
    A Real-Time QRS Detection Algorithm | IEEE Journals & Magazine
    We have developed a real-time algorithm for detection of the QRS complexes of ECG signals. It reliably recognizes QRS complexes based upon digital analyses.
  3. [3]
    Pan-Tompkins++: A Robust Approach to Detect R-peaks in ECG ...
    The Pan-Tompkins algorithm is the most widely used QRS complex detector for the monitoring of many cardiac diseases including arrhythmia detection.Missing: applications | Show results with:applications
  4. [4]
    (PDF) QRS Detection and Heart Rate Variability Analysis: A Survey
    Nov 20, 2014 · A robust and accurate QRS detection algorithm is needed to obtain valid heart rate variability data [48] . The Pan-Tompkins algorithm, which ...
  5. [5]
    None
    ### Summary of Bandpass Filtering in Pan-Tompkins QRS Detection Algorithm (1985 Paper)
  6. [6]
  7. [7]
  8. [8]
    (PDF) The Accuracy on the Common Pan-Tompkins Based QRS ...
    Aug 6, 2025 · In this paper, three Pan-Tompkins based QRS complex detectors were tested on both high and low-quality ECG databases.
  9. [9]
    Fast QRS Detection with an Optimized Knowledge-Based Method
    The Pan and Tompkins algorithm requires a resampling step for any ECG signal not sampled at 200 Hz. Its filters are designed for 200 Hz, so performance will be ...
  10. [10]
    Real time electrocardiogram QRS detection using combined ...
    Aug 27, 2004 · The sampling frequency is 360 Hz with resolution 5 μV/bit. Two cardiologists have annotated all beats. Approximately 70 % of the beats are ...
  11. [11]
    An Adaptive and Time‐Efficient ECG R‐Peak Detection Algorithm
    Sep 6, 2017 · This study proposed an adaptive and time-efficient R-peak detection algorithm for ECG processing. First, wavelet multiresolution analysis was applied to ...Missing: mechanism | Show results with:mechanism
  12. [12]
    Complete Pan Tompkins Implementation ECG QRS detector
    QRS Detection using Pan–Tompkins Algorithm from ECG Signal. 1.1K Downloads. An online algorithm for R, S and T wave detection. 9K Downloads. ECG P QRS T wave ...Missing: original | Show results with:original
  13. [13]
    ECG — NeuroKit2 0.2.13 documentation
    Defaults to 120 ms. - typical_st_segment : Typical duration of the ST segment. Defaults to 150 ms. - max_p_basepoint_interval : The maximum interval between ...HRV · PPG · Signal ProcessingMissing: integration | Show results with:integration<|control11|><|separator|>
  14. [14]
    py-ecg-detectors - PyPI
    Implementation of Jiapu Pan and Willis J. Tompkins. “A Real-Time QRS ... Uses the Pan and Tompkins thresolding method. The ECG template is a text ...
  15. [15]
    QRS detection and classification in Holter ECG data in one ... - Nature
    Jul 25, 2022 · We present a deep-learning model to detect and classify QRS complexes in single-lead Holter ECG. We introduce a novel approach, delivering QRS detection and ...Qrs Detection · Qrs Classification · Compared Qrs Detectors And...
  16. [16]
  17. [17]
    Horizons in Single-Lead ECG Analysis From Devices to Data
    The Pan-Tompkins algorithm can be implemented through hardware making it an efficient algorithm for long-term remote monitoring that may need low-power device ...
  18. [18]
    Translation from Wearable PPG to 12-Lead ECG - arXiv
    Sep 29, 2025 · Wearable devices (e.g., Apple Watch and Fitbit wristbands) further simplify ECG ... Using a modified Pan-Tompkins algorithm (Pan and Tompkins, ...
  19. [19]
    Performance Analysis of Ten Common QRS Detectors on Different ...
    Apr 10, 2018 · Three criteria for selecting the suitable algorithms were used in this study: algorithm efficiency, detection accuracy, and implementability.
  20. [20]
    Analysis of Pan-Tompkins Algorithm Performance with Noisy ECG ...
    In this paper, the performance of the Pan-Tompkins algorithm was analysed in extracting the QRS complex from standard ECG data that includes noise-stressed ECG ...Missing: original | Show results with:original<|control11|><|separator|>
  21. [21]
    Classification of ECG Signal Using Machine Learning Techniques
    ... ECG signal. PAN TOMPKINSONS algorithm is considered in our study as it serves best for precise identification of most prominent features namely QRS ...
  22. [22]
    An accurate and efficient method to train classifiers for atrial ...
    This study aimed to provide an efficient and reliable method to train a classifier for AF detection using large datasets of real-life ECGs.
  23. [23]
    Arrhythmia Detection and Classification by Using Modified ...
    The overall classification accuracy for 17 cardiac arrhythmias was 95.33%. For each 10 s ECG data, the classification time was 0.015 s. The proposed technique ...
  24. [24]
    [PDF] Open Source ECG Analysis - Computing in Cardiology
    We then modified this platform independent, simplified QRS detector so that it would pass the. ANSI/AAMI EC13 standard. We included a hard minimum on the ...
  25. [25]
    ECGPUWAVE v1.3.4 - PhysioNet
    The QRS detector is based on the algorithm of Pan and Tompkins (reference 1) with some improvements that make use of slope information ( ...
  26. [26]
    Noninvasive Fetal Electrocardiography Part I: Pan-Tompkins ... - NIH
    Mar 31, 2017 · Pan-Tompkins' algorithm (PTA) [9] is a popular and traditional method for R-peak detection, originally designed for adult applications [10].
  27. [27]
    A two-step pre-processing tool to remove Gaussian and ectopic ...
    Nov 1, 2022 · The Pan Tompkins was modified to identify the additional ectopic beats which would not be detected otherwise, by lowering the fiducial ...
  28. [28]
    Missing low amplitude R-peaks by Pan-Tompkins (highlighted by ...
    To detect the QRS intervals, we implemented a function based on the Pan-Tompkins alorithm [17, 29], that applies a series of preprocessing and filtering ...Missing: obese | Show results with:obese
  29. [29]
    [PDF] Choosing the Appropriate QRS Detector - SciTePress
    It works with basic waveform comparison and analysis techniques. Pan-Tompkins (Pan and Tompkins, 1985): uses two adaptive thresholds and bandpass filtering to ...
  30. [30]
    Revisiting QRS Detection Methodologies for Portable, Wearable ...
    We investigate current QRS detection algorithms based on three assessment criteria: 1) robustness to noise, 2) parameter choice, and 3) numerical efficiency.
  31. [31]
    Complex-Pan-Tompkins-Wavelets: Cross-channel ECG beat ...
    The presented Complex-Pan-Tompkins-Wavelets (CPTW) algorithm aims at detecting and delineating heart beats in real-time across any number of channels.Missing: paper | Show results with:paper
  32. [32]
    [PDF] QRS DETECTION OF ECG - A STATISTICAL ANALYSIS
    In this paper, a novel hybrid algorithm is proposed which integrates various wavelet coefficients and Pan-Tompkins' method for extracting features [10] and ...
  33. [33]
  34. [34]
    An Enhanced Hybrid Model Combining CNN, BiLSTM, and Attention ...
    Jun 17, 2025 · The Pan-Tompkins algorithm created by Pan and Tompkins is a commonly used method for detecting QRS complexes in electrocardiogram (ECG) signals.Ecg Dataset · Preprocessing · Proposed Model Architecture<|separator|>
  35. [35]
    QRS detection using adaptive filters: A comparative study
    Adaptive filtering is generally implemented through least mean squares (LMS) and recursive least squares (RLS) algorithms [23]. In this paper, an improved ...
  36. [36]
    Combining 12-Lead ECG Information for a Beat Detection Algorithm
    Mar 16, 2018 · This paper proposes a beat detection algorithm specially tailored to be used with 12 channel ECG records.
  37. [37]
    An ECG compression method exploiting a QRS detector for sparse ...
    Oct 5, 2025 · A Pan-Tompkins detector, improved with multi-lead adjustment, is used to accurately find QRS complexes. •. The Deterministic Binary Block ...
  38. [38]
    Wearable Devices and AI-Driven Remote Monitoring in ...
    Aug 16, 2025 · (1) Electrical-based wearables: ECG-based wearables detect HR using R-R interval algorithms such as Pan-Tompkins. ... 99% diagnostic accuracy ...