Data Augmentation for Electrocardiograms

Aniruddh Raghu, Divya Shanmugam, Eugene Pomerantsev, John V. Guttag, Collin M. Stultz

Abstract

Neural network models have demonstrated impressive performance in predicting pathologies and outcomes from the 12-lead electrocardiogram (ECG). However, these models often need to be trained with large, labelled datasets, which are not available for many predictive tasks of interest. In this work, we perform an empirical study examining whether training time data augmentation methods can be used to improve performance on such data-scarce ECG prediction problems. We investigate how data augmentation strategies impact model performance when detecting cardiac abnormalities from the ECG. Motivated by our finding that the effectiveness of existing augmentation strategies is highly task-dependent, we introduce a new method, TaskAug, which defines a flexible augmentation policy that is optimized on a per-task basis. We outline an efficient learning algorithm to do so that leverages recent work in nested optimization and implicit differentiation. In experiments, considering three datasets and eight predictive tasks, we find that TaskAug is competitive with or improves on prior work, and the learned policies shed light on what transformations are most effective for different tasks. We distill key insights from our experimental evaluation, generating a set of best practices for applying data augmentation to ECG prediction problems.

Introduction

Predicting cardiac abnormalities from 12-lead ECGs using deep learning typically requires massive labeled datasets. However, for many clinical tasks—such as inferring central hemodynamics which usually requires invasive procedures—large datasets are unavailable. While data augmentation is a standard technique in computer vision, its application to time-series ECG data is non-trivial. Fine-grained temporal details and relative amplitudes carry vital predictive signals; a generic augmentation like time warping or noise might improve detection for one pathology while destroying the signal for another.

Figure 1: Task-dependency of standard augmentations. SpecAugment improves RVH detection but degrades AFib detection performance.

Methodology: TaskAug

To address the limitations of fixed augmentation strategies, we introduce TaskAug, a learnable policy that optimizes transformations on a per-task and per-class basis. TaskAug employs a multi-stage augmentation pipeline where the choice of operation (e.g., temporal warping, baseline wander, Gaussian noise) and its intensity are learned during training.

Key innovations include:

  1. Online Optimization: TaskAug uses a bi-level optimization algorithm with implicit differentiation, alternating between updating model weights and refining the augmentation policy based on validation performance.
  2. Class-Specific Strengths: The method learns different augmentation strengths for positive and negative classes. This prevents "label-flipping," where a healthy ECG might be augmented so severely that it mimics a pathological state.

Experimental Evaluation

We evaluated TaskAug across three datasets:

  • Dataset A: Focuses on rare structural (RVH) and electrical (AFib) abnormalities.
  • Dataset B (PTB-XL): A public benchmark for broader categories like Myocardial Infarction (MI) and Hypertrophy (HYP).
  • Dataset C: A rare hemodynamics dataset for predicting Low Cardiac Output (CO) and High PCWP.
Figure 4: Performance comparison (AUROC) across Datasets A and B. TaskAug consistently ranks among the top-performing methods, especially in low-prevalence tasks.

Key Results and Insights

Experimental results demonstrate that TaskAug is particularly effective in data-scarce regimes ($N=1000$). For instance, in RVH detection, TaskAug improved AUROC from 72.6% to 78.4%. On the challenging hemodynamics tasks of Dataset C, TaskAug improved AUROC for detecting high PCWP from 66.7% to 67.9% in the low-sample regime. In the highly imbalanced RVH and AFib tasks, it was the only method to provide statistically significant improvements in AUPRC.

Our analysis yielded several key insights:

  • Task-Dependency: The optimal augmentation is highly specific to the pathology. For AFib, TaskAug favored "Time Masking," which preserves the irregular rhythm signal while providing variety.
  • Data Scarcity Bottleneck: The benefits of augmentation are most pronounced when data is limited. As sample sizes increase ($N \ge 2500$), the performance gains from TaskAug and other methods diminish.
  • Interpretability: The learned policies provide clinical hypotheses regarding which ECG features are most robust for specific diagnoses.

Conclusion

TaskAug provides a systematic way to apply data augmentation to ECG prediction without manual tuning. By adapting to the specific requirements of each task and class, it offers a robust solution for medical machine learning in data-scarce environments. Future work will explore its application to multiclass settings and self-supervised pre-training frameworks.

Summary updated

BibTeX
@inproceedings{raghu2022data,
  author = {Aniruddh Raghu and Divya Shanmugam and Eugene Pomerantsev and John V. Guttag and Collin M. Stultz},
  title = {{Data Augmentation for Electrocardiograms}},
  booktitle = {CHIL},
  year = {2022},
  url = {https://openreview.net/forum?id=x1A5h2R3Zq},
}
Figure