PLOS ONE · June 2024

Deep Learning ECG Segmentation for Delineation of Diverse Arrhythmias

Chankyu Joung, Mijin Kim, Taejin Paik, Seong-Ho Kong, Seung-Young Oh, Won Kyeong Jeon, Jae-hu Jeon, Joong-Sik Hong, Wan-Joong Kim, Woong Kook, Myung-Jin Cha, Otto van Koert — Seoul National University · Asan Medical Center · Medifarmsoft

TL;DR

Deep learning models can find the P, QRS, and T waves in an ECG almost perfectly on standard benchmarks — but those benchmarks barely contain fast or irregular heartbeats. This paper shows that a segmentation model trained on the usual public data quietly fails on tachycardia and heart block, then fixes the problem with a more diverse training set and a small "arrhythmia-aware" branch that suppresses hallucinated P waves during atrial fibrillation and flutter.

F1 > 99% QRS/T waves (LUDB) F1 > 97% P waves (LUDB) Up to 15% F1 drop on tachycardia if undertrained 4.5× fewer false P waves in AFib 30-min Holter delineated in <3s

Why this matters

Every heartbeat on an ECG traces the same basic story: a small P wave (the atria contracting), a sharp QRS complex (the ventricles contracting), and a rounded T wave (the ventricles resetting). Measuring exactly where each wave starts and ends — called delineation — is how cardiologists quantify things like PR interval or QT interval, which feed directly into diagnoses.

Deep segmentation models have gotten very good at this task on the two standard public benchmarks, QTDB and LUDB. The catch: both benchmarks are small and skew toward calm, regular heartbeats. They contain almost no examples of fast rhythms like tachycardia. A model can ace these benchmarks while quietly failing on exactly the abnormal rhythms doctors most want flagged — a bit like a self-driving car that's only ever been tested on sunny highways.

This paper asks a simple but under-explored question: what happens to delineation quality when the heart isn't behaving normally? The answer, as the authors put it, is that "models with a strong performance on standard benchmarks may still perform poorly on arrhythmias that are underrepresented in these benchmarks, such as tachycardias."

The big idea

The authors build a U-Net-like 1D segmentation network that labels every time-point of a single-lead ECG as P wave, QRS complex, T wave, or "none," followed by a rule-based post-processing step that turns those pixel-level labels into clean onset/offset boundaries. That part is familiar from prior work. The contribution is twofold: (1) train on a newly assembled internal dataset of 1,557 patients deliberately enriched with arrhythmias — atrial fibrillation, flutter, heart block, tachycardia — rather than relying on the arrhythmia-poor public benchmarks, and (2) add an optional classification branch that predicts whether the current signal is atrial fibrillation or flutter, and uses that prediction to actively suppress spurious P-wave detections during those rhythms (since AFib/AFL, by definition, has no true P wave). The result is a model that keeps benchmark-level accuracy on QTDB/LUDB while closing much of the arrhythmia performance gap.

How it works

Anatomy of a heartbeat

Before the model, the target. Hover over each labeled part of this synthetic ECG trace to see what it represents and why it's tricky to detect.

Hover a wave above to learn more.

The architecture: U-Net + a watchful classifier

The backbone is a 1D U-Net-style encoder–decoder with full-scale skip connections (borrowed from UNet3+): the encoder repeatedly downsamples the signal into deeper, coarser feature maps, and the decoder rebuilds a full-resolution output from features at every scale at once, not just the adjacent one. A parallel classification branch taps into all five encoder levels to decide if the current window looks like atrial fibrillation or flutter — a decision that can later switch off P-wave predictions entirely. Hover the diagram to explore each part.

Hover or tap a block to see its role in the network.

Cleaning up: the post-processing rule

The raw segmentation output is noisy — the network might flicker between labels for a few milliseconds. The authors discard any labeled segment shorter than a duration threshold (40 ms by default) and reassign it: if its two neighbors agree, the gap is glued into one segment; if they disagree, it's relabeled "none." Drag the slider to see how the threshold reshapes a toy noisy segmentation into clean waveform boundaries.

40 ms

Raw model output (before)

After post-processing (live)

Suppressing phantom P waves in AFib/AFL

In atrial fibrillation the atria don't produce a clean P wave — they quiver, generating a fibrillatory baseline that a segmentation model can easily mistake for many tiny P waves. The classification branch predicts "AFib/AFL vs. not," and when it fires positive, P-wave outputs are suppressed directly. Toggle below to see the effect on a real example (based on Fig 11, an AFib recording).

P wave (predicted) QRS T wave

Results

Training data diversity is everything

The clearest experiment in the paper: train one model only on LUDB (the standard, arrhythmia-poor benchmark) and another on the diverse internal dataset, then test both on the same arrhythmia-rich internal test set. Select a waveform below — the gap is dramatic for P waves during sinus tachycardia (ST) and first-degree AV block (AVB1), and for T waves during ventricular tachycardia (VT).

Trained on LUDB only Trained on diverse dataset

Source: Table 3. No P wave is annotated for AFIB/AFL/VT (bars omitted). Values are onset F1-scores (%).

Classification guidance kills false P waves

On the internal test set's AFib and atrial flutter recordings, adding the classification-guided suppression cuts false-positive P-wave detections roughly 4–18×, while barely denting overall recall (95.43% → 95.31%) and slightly improving precision (97.53% → 98.70%).

Source: Table 5, averaged over 20 runs (P-onset false positives per test set: 1,437 AFib beats, 540 AFL beats).

Still competitive on the standard benchmarks

Crucially, none of this diversity training hurts standard benchmark performance — the model (trained exclusively on the internal dataset, never touching QTDB/LUDB training splits) is comparable to or better than prior wavelet-based and deep-learning methods.

DatasetMethodP onset PPVQRS SeT offset Se

Selected rows from Table 4. "Our Method" trained only on internal data, tested on QTDB/LUDB without fine-tuning.

Limitations & open questions

The authors are candid about where the approach still breaks:

  • Only one P wave per RR interval. The post-processing step picks a single longest P-wave segment between consecutive QRS complexes. That fails for second- or third-degree AV block, where multiple P waves can occur before a single QRS.
  • No overlapping waveforms. The model assumes P, QRS, and T never overlap in time — but they can, again in higher-grade AV blocks.
  • Higher timing variance than wavelet methods. Deep-learning delineation shows larger standard deviation of boundary error (σ), especially for T-offset on QTDB — a pattern also seen by Jimenez-Perez et al. (σ > 30ms).
  • The classification-guided suppression is coarse. It works best on short, single-rhythm signals; it can't handle an ECG where the rhythm itself changes mid-recording, since a whole window gets one classification label.
  • Rare arrhythmias remain data-starved. Even the enriched internal dataset has only 29 VT and 59 AFL recordings — visibly the weakest categories in Table 3.

The authors suggest future work on multi-label / multi-P-wave detection, separate atrial vs. ventricular sub-models, and more advanced augmentation for rare rhythms that are hard to collect at scale.

Glossary

Citation

@article{joung2024ecg,
  title   = {Deep learning based ECG segmentation for delineation of diverse arrhythmias},
  author  = {Joung, Chankyu and Kim, Mijin and Paik, Taejin and Kong, Seong-Ho and Oh, Seung-Young
             and Jeon, Won Kyeong and Jeon, Jae-hu and Hong, Joong-Sik and Kim, Wan-Joong
             and Kook, Woong and Cha, Myung-Jin and van Koert, Otto},
  journal = {PLOS ONE},
  volume  = {19},
  number  = {6},
  pages   = {e0303178},
  year    = {2024},
  doi     = {10.1371/journal.pone.0303178}
}

Code: github.com/ckjoung/ecg-segmentation

Made with Flash Papers — make your own