Explaining deep learning for ECG using time-localized clusters

Ahcène Boubekki, Konstantinos Patlatzoglou, Joseph Barker, Fu Siong Ng, Antônio H. RibeiroarXiv 2025 · DOI

Introduction

Deep learning has significantly advanced the field of electrocardiogram (ECG) analysis, demonstrating remarkable performance in tasks ranging from routine arrhythmia detection to identifying subtle "hidden" signatures such as age prediction or electrolyte imbalances. Despite these successes, deep neural networks often operate as "black boxes," providing little insight into their decision-making processes. This lack of transparency presents two primary challenges: establishing clinical trust among medical professionals who require explanations for diagnoses, and facilitating knowledge discovery by identifying the specific electrophysiological features the model utilizes.

Existing interpretability techniques, such as Grad-CAM, often produce coarse or inconsistent heatmaps that lack the granularity required for precise clinical interpretation. This paper introduces a novel post-hoc inspection method that extracts "time-localized clusters" from a model's internal representations, providing a structured and granular way to visualize what the model "sees" within the ECG waveform.

Methodology

The proposed method treats the internal states of a Convolutional Neural Network (CNN) as discrete concepts that can be clustered and mapped back to the input signal. The architecture employed is a 1D-ResNet.

Overview of the proposed interpretability pipeline, showing feature extraction from ResNet blocks followed by clustering and time-localized visualization.

The process involves several key steps:

  1. Feature Extraction: Activations are extracted from the final three residual blocks of the encoder. These layers contain high-level features learned by the network.
  2. Alignment and Upsampling: Because the network is convolutional, the spatial (temporal) order of data in these internal layers corresponds to specific timestamps in the input. These activations are linearly upsampled to match the original ECG's time dimension.
  3. Clustering: $k$-means clustering is applied to the concatenated internal features across a dataset. The authors determined that $K=20$ clusters provide an optimal balance between complexity and interpretability.
  4. Uncertainty Quantification: The entropy of the cluster assignments is calculated to measure the model's "certainty" regarding its representation of a specific segment.
  5. Visualization: The final output is a color-coded ECG where colors represent specific learned clusters and opacity reflects the model's certainty.

Results and Key Insights

Emergent Physiology

A significant finding of this work is that the model's internal clusters naturally align with standard electrophysiological segments, such as the P-wave, QRS complex, and T-wave, without any explicit supervision. This suggests that the deep learning model "discovers" fundamental medical concepts as an emergent property of solving the classification or regression task.

Class-Specific Signatures

The method reveals distinct "signatures" for different cardiac conditions. For instance, in cases of Myocardial Infarction (MI), the model exhibits highly confident clustering around the QRS complex and the early ST segment—precisely the regions human cardiologists examine for signs of ischemia.

Time-localized cluster visualizations for various clinical labels, demonstrating how different conditions correspond to specific learned patterns.

Predictive Power of Clusters

To validate the meaningfulness of these clusters, the researchers trained a simple Random Forest (RF) classifier using only the proportions of the 20 clusters found in each ECG. This "RF cluster" model achieved an AUROC between 0.77 and 0.86, nearly matching the performance of the full 1D-ResNet. This demonstrates that the clusters successfully capture the essential discriminative information required for clinical diagnosis.

Age Prediction and Aging Signatures

In age regression tasks using the CODE-15% dataset, the model showed distinct behaviors across age groups. Younger patients' ECGs were typically represented by a smaller set of highly "certain" clusters. In contrast, older patients exhibited more dispersed and uncertain cluster representations, likely reflecting the increased physiological variability and "noise" associated with aging.

Discussion

The time-localized clustering method serves as a powerful "sanity check" for clinical models. In several instances where the model's prediction disagreed with the ground truth label, the cluster visualizations revealed that the human labeler had made an error, while the model had correctly identified the underlying pathology.

However, limitations remain. The method still requires human experts to assign clinical meaning to the discovered clusters. Furthermore, while the clustering is unsupervised, it may still inherit biases from the original training task. Future research will focus on integrating these clusters across all 12 leads of the ECG to provide a more holistic, three-dimensional view of cardiac activity.

Conclusion

By transforming abstract neural activations into interpretable, time-localized clusters, this research bridges the gap between high-performance deep learning and clinical utility. The discovery that models naturally learn physiological structures provides a strong foundation for building trust and advancing our understanding of electrophysiology through AI.

Summary updated

BibTeX
@misc{boubekki2025explaining,
  author = {Ahcène Boubekki and Konstantinos Patlatzoglou and Joseph Barker and Fu Siong Ng and Antônio H. Ribeiro},
  title = {{Explaining deep learning for ECG using time-localized clusters}},
  year = {2025},
  eprint = {2509.15198},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2509.15198},
}
Figure