Towards Understanding ECG Rhythm Classification Using Convolutional Neural Networks and Attention Mappings

Sebastian D. Goodfellow, Andrew J. Goodwin, Robert Greer, Peter C. Laussen, Mjaye Mazwi, Danny EytanMLHC 2018

Abstract

While deep learning models have achieved high performance in automated electrocardiogram (ECG) rhythm classification, their "black box" nature often hinders clinical adoption. This study presents a 13-layer Deep Convolutional Neural Network (CNN) architecture modified to support Class Activation Mappings (CAM). By visualizing the model's focus, the researchers demonstrate that the network identifies clinically relevant features, such as the absence of P-waves in Atrial Fibrillation and the presence of premature beats. The model achieves a competitive F1 score of 0.84, proving that interpretability can be achieved without significant performance trade-offs.

Introduction

Electrocardiograms (ECGs) are fundamental in diagnosing cardiac arrhythmias, yet their interpretation requires significant expertise. Deep learning has emerged as a powerful tool for end-to-end classification, but the lack of transparency in how these models arrive at a diagnosis remains a barrier to trust in high-stakes clinical environments. This research addresses the interpretability gap by adapting computer vision techniques—specifically Class Activation Mappings—to 1D temporal signals, allowing clinicians to visualize the specific segments of a waveform that drive the model's decision.

Methodology

The core of the approach is a 13-layer Deep CNN designed for both accuracy and high-resolution interpretability. Key architectural choices include:

  • Dilated Convolutions: These expand the receptive field, allowing the model to capture long-range temporal dependencies without losing fine-grained signal detail.
  • Global Average Pooling (GAP): Replacing traditional fully connected layers with GAP enables the projection of classification weights back onto the input signal, creating the "attention maps."
  • Temporal Resolution Preservation: To maintain precise localization of features, the authors removed 10 of the 13 max-pooling layers. Although this increased training time, it prevented the loss of temporal information necessary for accurate CAM visualization.

Datasets and Experimental Setup

The study utilized the 2017 Physionet Challenge dataset, comprising 12,186 single-lead ECG recordings collected via AliveCor devices. The dataset includes four primary categories: Normal Sinus Rhythm, Atrial Fibrillation (AFib), Other Rhythm, and Noisy signals. For this analysis, the "Noisy" class was excluded to focus on rhythm differentiation.

Examples of ECG rhythm classes and the AliveCor recording device.

The data was partitioned using a 70/30 stratified split to ensure consistent class distribution across training and testing sets.

Results and Interpretability

The model achieved an overall accuracy of 0.88 and an average F1 score of 0.84, performing on par with top-tier non-interpretable models. Class-specific F1 scores were 0.92 for Normal rhythms, 0.81 for AFib, and 0.80 for Other rhythms.

Beyond metrics, the "attention maps" provided significant clinical insights:

  • Atrial Fibrillation: The model's attention spiked in the isoelectric intervals between beats. This aligns with clinical practice, where AFib is characterized by the absence of organized P-waves.
  • Premature Beat Detection: In the "Other Rhythm" category, attention maps showed sharp peaks precisely at the location of ectopic beats, mirroring how a human cardiologist scans a strip for irregularities.
  • Normal Rhythm: The model exhibited relatively constant attention across the signal, suggesting it recognizes the overall regularity of the sinus rhythm.

Limitations and Future Work

A current limitation involves the precise morphology of the attention maps. While the model correctly identifies when to look (e.g., during a specific beat), the internal representation of the waveform shape (P-waves, T-waves) does not yet perfectly mirror human physiological templates.

ECG signal analysis showing R-peak detection and template generation.

Future research will focus on training with more diverse pathological datasets and integrating these visualizations into real-time bedside monitoring systems to provide clinicians with explainable AI-driven diagnostic support.

Summary updated

BibTeX
@inproceedings{goodfellow2018towards,
  author = {Sebastian D. Goodfellow and Andrew J. Goodwin and Robert Greer and Peter C. Laussen and Mjaye Mazwi and Danny Eytan},
  title = {{Towards Understanding ECG Rhythm Classification Using Convolutional Neural Networks and Attention Mappings}},
  booktitle = {MLHC},
  year = {2018},
}
Figure