Abstract
ECGTwin is a novel two-stage diffusion framework designed to generate personalized "digital twins" of a patient's electrocardiogram (ECG) tailored to specific cardiac conditions. By decoupling individual-specific traits from clinical diagnoses using contrastive learning and a dual-pathway "AdaX" injector, the model produces high-fidelity, personalized signals that significantly improve the accuracy of automated diagnostic tools.
Introduction
While generative AI has made significant strides in creating synthetic medical data, generating personalized ECGs remains a critical challenge in digital health. Most existing models generate population-level ECGs—essentially "average" heart signals for a given condition—failing to account for the unique physiological signatures of individual patients.
The development of ECGTwin addresses two primary roadblocks:
- Identity Extraction: Capturing the unique "signature" of a patient’s heart (individual anatomy and physiology) without explicit ground-truth labels for these features.
- Condition Confusion: Managing the integration of heterogeneous data, such as textual clinical reports, numerical heart rates, and demographic information, which can lead to poor signal quality or model collapse if not handled correctly.
By overcoming these hurdles, ECGTwin enables the creation of "digital twins"—simulating how a specific patient's heart would respond to various arrhythmias. This capability is invaluable for rare disease research and the advancement of personalized medicine.
Proposed Framework
ECGTwin utilizes a two-stage architecture to effectively separate a patient's identity from their cardiac condition.
Stage 1: Individual Base Extractor (IBExtractor)
The researchers employed contrastive learning to train the IBExtractor. By presenting the model with pairs of ECGs from the same patient and contrasting them with signals from others, the model learns to extract a "Base Vector." This vector serves as a compact representation of a patient's unique cardiac traits, remaining consistent across different underlying heart conditions.
Stage 2: Latent Diffusion with AdaX Injector
The generation process is handled by a Latent Diffusion Model (LDM) integrated with the novel AdaX Condition Injector. This injector utilizes two specialized pathways:
- Cardiac Condition Pathway: Employs cross-attention to process clinical text reports. This allows the model to map specific clinical terms (e.g., "PVC" or "ST elevation") to corresponding segments of the heartbeat waveform.
- Base Vector and Time Pathway: Uses Adaptive Layer Normalization (adaLN) to inject the patient's identity (Base Vector) and the diffusion timestamp. This treats the patient's unique signature as a global "style" that modulates the entire generated signal.
Experimental Results
The model was trained on the MIMIC-IV-ECG dataset (~6.4 million ECG pairs) and validated against the PTB-XL benchmark. ECGTwin significantly outperformed state-of-the-art methods such as LAVQ and DiffuSETS-p across several metrics:
- Fidelity: ECGTwin achieved a Fréchet Inception Distance (FID) of 18, a substantial improvement over the leading baseline's score of 234 (lower is better).
- Diagnostic Utility: Fine-tuning a standard diagnostic model with synthetic "digital twins" increased diagnostic accuracy to 81.6%, compared to 75.5% for models trained only on general population data.
- Robustness: The IBExtractor demonstrated high resistance to noise, maintaining accurate patient identification even with heavily corrupted input signals.
Discussion and Conclusion
A core finding of this work is that a patient's identity is the invariant component of the signal across different recordings. Contrastive learning effectively distills this identity without requiring manual labeling. Furthermore, visualization of cross-attention maps confirms that the model focuses on clinically relevant waveform features (e.g., malformed QRS complexes for PVC) when prompted with specific conditions, providing essential clinical explainability.
While the model currently relies on high-quality clinical text reports, its performance in generating high-fidelity, patient-specific ECGs is unprecedented. Future research will explore Flow Matching to accelerate generation and aim to incorporate more granular physiological variables into the cardiac condition definitions.
Summary updated