Interpretation of Intracardiac Electrograms Through Textual Representations

William Jongwon Han, Diana Gómez, Avi Alok, Chaojing Duan, Michael A. Rosenberg, Douglas Weber, Emerson Liu, Ding Zhao

Abstract

Understanding the irregular electrical activity of atrial fibrillation (AFib) has been a key challenge in electrocardiography. For serious cases of AFib, catheter ablations are performed to collect intracardiac electrograms (EGMs). EGMs offer intricately detailed and localized electrical activity of the heart and are an ideal modality for interpretable cardiac studies. Recent advancements in artificial intelligence (AI) has allowed some works to utilize deep learning frameworks to interpret EGMs during AFib. Additionally, language models (LMs) have shown exceptional performance in being able to generalize to unseen domains, especially in healthcare. In this study, we are the first to leverage pretrained LMs for finetuning of EGM interpolation and AFib classification via masked language modeling. We formulate the EGM as a textual sequence and present competitive performances on AFib classification compared against other representations. Lastly, we provide a comprehensive interpretability study to provide a multi-perspective intuition of the model's behavior, which could greatly benefit the clinical use.

Introduction

Atrial Fibrillation (AFib) is a chaotic heart rhythm affecting millions of patients worldwide. When medication fails, clinicians often turn to invasive catheter ablation, a procedure where intracardiac electrograms (EGMs) are recorded directly from the heart's surface. These signals provide high-fidelity, localized data that are essential for identifying the sources of arrhythmia. However, the sheer volume and complexity of EGM data make manual interpretation at scale a significant challenge.

While previous deep learning approaches have treated these signals as images or standard time-series data, they often function as "black boxes," offering little clinical intuition and struggling to generalize across different patient populations. This research introduces a novel paradigm: treating heart signals as a language. By converting EGMs into textual sequences, we can leverage the sophisticated architecture of pretrained Language Models (LMs) to achieve both high diagnostic accuracy and deep clinical interpretability.

Methodology

Tokenization and Representation

The foundational step in our framework is the discretization of continuous EGM amplitude values. Inspired by "Pix2seq" methodologies in computer vision, we map the continuous signal into 250 discrete "levels." Each level corresponds to a unique token ID. This process transforms a one-second EGM signal into a "sentence" consisting of 1,000 tokens, effectively creating a textual representation of the heart's electrical grammar.

Model Architecture

We utilize Transformer architectures specifically designed to handle long sequences: BigBird and LongFormer. These models are trained using a Masked Language Modeling (MLM) objective. During training, 75% of the signal tokens are hidden (masked), and the model is tasked with predicting these missing values while simultaneously identifying the presence of AFib via a specialized classification token. This joint task ensures the model learns the underlying structural morphology of the EGM rather than just superficial patterns.

Multi-Perspective Interpretability

To ensure clinical utility, we move beyond simple classification by employing three distinct interpretability methods:

  1. Attention Maps: These visualize which specific segments of the signal the model prioritizes during decision-making.
  2. Integrated Gradients (IG): This technique attributes the final AFib prediction to specific input tokens, highlighting the features that drive the model's output.
  3. Counterfactual Analysis: We test model robustness through Token Substitution (smoothing signals), Token Addition (injecting noise), and Label Flipping to observe how the model reacts to perturbations.

Experimental Setup and Datasets

The models were evaluated using two primary datasets:

  • Internal Dataset: Collected at Allegheny General Hospital using an Octoray catheter, this dataset includes 92,640 one-second samples from 65 different catheter placements across two patients (one healthy, one with AFib).
  • External Dataset: To test generalization, we utilized the Intracardiac Atrial Fibrillation Database (IAFDB) from PhysioNet, which includes data from eight patients recorded with different hardware.

Results and Discussion

Classification Performance

The "Clinical LongFormer" model achieved a state-of-the-art 99.7% accuracy in AFib classification. This significantly outperformed traditional machine learning baselines, such as CatBoost (70.1%) and Support Vector Machines (79.7%). Furthermore, when applied to the external IAFDB dataset, the model maintained a 99.9% accuracy, demonstrating that the textual representation allows the model to generalize across different clinical environments and recording equipment.

The Power of Pretraining

A critical finding of this study is that models pretrained on massive natural language corpora (such as Wikipedia) perform substantially better on EGM data than those trained from scratch. Pretraining boosted BigBird's accuracy from 63.6% to 96.7%. This suggests that the hierarchical structures and "syntax" learned from human language are transferable to the rhythmic patterns of cardiac signals—a phenomenon we describe as the model becoming "heart-literate."

Signal Interpolation

Beyond classification, the model demonstrated a deep understanding of EGM morphology through its ability to reconstruct masked segments. The model achieved a low Mean Squared Error (MSE) of 0.80 during interpolation, indicating it can accurately predict missing electrical activity based on the surrounding context.

Clinical Interpretability Insights

Our interpretability suite revealed that the model naturally focuses on sharp oscillations and rapid fluctuations within the EGM. These are the same morphological features that electrophysiologists use to diagnose arrhythmias. Additionally, counterfactual testing via "Token Addition" showed that the model is highly robust to noise; it effectively ignores injected random segments and maintains focus on the original, meaningful signal components.

Conclusion and Future Work

By representing intracardiac electrograms as text, we have unlocked the power of pretrained Transformers for cardiac electrophysiology. This approach provides not only industry-leading accuracy but also the transparency required for clinical adoption.

Future research will focus on expanding the patient cohort to account for broader pathological diversity and optimizing the model for real-time integration into the electrophysiology lab. Ultimately, this framework could pave the way for AI systems that generate descriptive clinical notes directly from raw cardiac signals, assisting doctors in real-time during complex ablation procedures.

Summary updated

Abstract

Understanding the irregular electrical activity of atrial fibrillation (AFib) has been a key challenge in electrocardiography. For serious cases of AFib, catheter ablations are performed to collect intracardiac electrograms (EGMs). EGMs offer intricately detailed and localized electrical activity of the heart and are an ideal modality for interpretable cardiac studies. Recent advancements in artificial intelligence (AI) has allowed some works to utilize deep learning frameworks to interpret EGMs during AFib. Additionally, language models (LMs) have shown exceptional performance in being able to generalize to unseen domains, especially in healthcare. In this study, we are the first to leverage pretrained LMs for finetuning of EGM interpolation and AFib classification via masked language modeling. We formulate the EGM as a textual sequence and present competitive performances on AFib classification compared against other representations. Lastly, we provide a comprehensive interpretability study to provide a multi-perspective intuition of the model's behavior, which could greatly benefit the clinical use.
BibTeX
@inproceedings{han2024interpretation,
  author = {William Jongwon Han and Diana Gómez and Avi Alok and Chaojing Duan and Michael A. Rosenberg and Douglas Weber and Emerson Liu and Ding Zhao},
  title = {{Interpretation of Intracardiac Electrograms Through Textual Representations}},
  booktitle = {CHIL},
  year = {2024},
}
Figure