Summary
Single-lead electrocardiograms can be collected by portable devices, but such devices are not suitable for the mainstream 12-lead electrocardiogram diagnoses. Some studies have attempted to reconstruct missing electrocardiogram leads. However, these methods focus only on signal reconstruction without using annotation information of electrocardiogram records. In this paper, a “condition-fusion-and-hiding denoising diffusion probabilistic model” is proposed to use annotated text and diagnosis conclusions for promoting the generative model in learning electrocardiogram pathological knowledge. A two-step training strategy is designed. In the first stage, a condition-fusion module combines description text with electrocardiogram signals to guide pathological learning. In the second stage, a condition-hiding module supervises pathological feature reconstruction through representation learning, without inputting annotated text. With this strategy, the model reconstructs fixed-length, 10-s 12-lead electrocardiograms from single-lead inputs, emphasizing pathological waveforms and rhythms. Experimental results show that the proposed method outperforms state-of-the-art approaches in terms of reconstruction performance and classification consistency.
Subject areas: health sciences, medicine, medical specialty, cardiovascular medicine, health technology
Graphical abstract

Highlights
-
•
Reconstruction of 12-lead ECGs from single-lead ECGs, using a disease knowledge-guided DDPM
-
•
A condition-fusion module fuses ECG report with signal for pathology-aware reconstruction
-
•
A condition-hiding module provides category guidance for report-independent inference
-
•
Reconstruction quality and pathological consistency superior to those of SOTA methods
Health sciences; medicine; medical specialty; cardiovascular medicine; health technology
Introduction
Electrocardiogram (ECG) is the primary means to check the status of heart health and is widely used because of its non-invasive and low-cost characteristics. The most commonly used ECG in clinical settings is a 12-lead ECG, consisting of six limb leads (I, II, III, aVR, aVL, and aVF) and six chest leads (V1, V2, V3, V4, V5, and V6), to reflect the electrical activity of the heart at different angles. In recent years, with the development of deep learning technology and the release of large-scale ECG datasets, researchers have widely studied the automatic diagnosis method of 12-lead ECG based on deep learning. Han et al.1 designed a multi-lead residual network to identify and locate myocardial infarction from ECG. Yao et al.2 combined the attention mechanism and convolutional neural network (CNN) to realize the automatic diagnosis of eight heart diseases, including left bundle branch block (LBBB). Yang et al.3 classified 12 leads according to the corresponding heart position and realized the classification of heart diseases through multi-view and multi-scale CNNs. In addition, deep learning architectures such as recurrent neural networks4,5,6 and Transformers7,8,9 have also been widely used in 12-lead ECG automatic diagnosis tasks. However, 12-lead ECG devices are not portable, and, therefore, 12-lead ECG can only be collected in hospitals, and portable single-lead ECG devices are more suitable for daily use. Single-lead ECGs do not directly use automated diagnostic methods designed for 12-lead ECGs. Most of the studies on automatic diagnosis methods of single-lead ECG aim at diagnosing only arrhythmia,10,11,12 and even only atrial fibrillation (AF)13,14,15 because some heart diseases show not only abnormal rhythms but also abnormal morphology or amplitude in one or several leads. Therefore, most single-lead ECG diagnostic models focus on diagnosing rhythm abnormalities. In order to make diagnostic methods designed for 12-lead ECG applicable to single-lead ECG, this paper proposes a condition-fusion-and-hiding denoising diffusion probabilistic model (CFH-DDPM), which can generate 12-lead ECG from single-lead ECG.
The generation task of ECG signals is a hot research direction, which originated from the earliest cardiac electrophysiological modeling.16 As early as 2004, Oosterom et al.17 developed a simulation software, ECGSim, to generate chest ECG based on cardiac electrical activity. However, such electrophysiological modeling-based studies can generate only a limited number of fixed rhythm types, using physiological parameters such as height and weight, and therefore cannot be applied to real multi-lead ECG reconstruction. Early studies on ECG lead reconstruction were primarily based on data-driven linear transformations. Maheshwari et al.18 used least squares fitting and cardiac vector projection to achieve 12-lead ECG reconstruction from two limb leads and one chest lead. Trobec et al.19 tried to find the three best personalized leads for reconstructing 12-lead ECG. Linear transformation-based lead reconstruction methods are generally computationally efficient and provide explicit mappings between leads. However, the assumption of linear relationships among leads is idealized and cannot fully capture the inherently non-linear spatial characteristics of cardiac electrical activity, thereby limiting their ability to accurately reconstruct missing leads.
In recent years, the success of deep learning generative models in the ECG data augmentation task20,21,22,23,24,25,26,27 has encouraged researchers to explore the application of these models in ECG lead reconstruction.28 Wang et al.29 proposed a CNN method for reconstructing 12-lead ECG from lead I, lead II, and lead V2. Kapfo et al.30 used long short-term memory and achieved better reconstruction quality, using the same three leads. In addition, there is also a study31 that used three chest leads to achieve the reconstruction task. Lead I, lead II, and lead V2 were used as reconstruction conditions in most studies because the other four limb leads can be directly calculated based on lead I and lead II, and lead V2 can directly provide information about a specific angle of the heart. Therefore, three-lead-based reconstruction essentially reduces to estimating the five missing precordial leads from six known limb leads and one known chest lead, which substantially simplifies the reconstruction problem. However, acquiring three-lead ECG signals requires the placement of electrodes on the right arm, left arm, left leg, and chest at the V2 position, along with an additional right-leg electrode commonly used for grounding to suppress noise. Because the setup involves both limb and precordial electrodes, three-lead devices cannot offer the same level of convenience and portability as single-lead devices, which can be used anytime and anywhere.
Currently, most of the portable ECG devices support the detection of only lead I. Reconstructing a 12-lead ECG from a single-limb lead is more challenging than from three leads. Generative adversarial network (GAN)32 has achieved great success in image conversion tasks,33,34 prompting researchers to try applying it to ECG reconstruction tasks. Lee et al.35 embedded the time-domain ECG of a single heartbeat into two-dimensional space and used GAN to achieve one-to-one reconstruction from lead II to a single chest lead. Seo et al.36 trained 11 GAN models to realize the task of reconstructing 2.5-s short ECG segments from lead I to the remaining 11 leads and manually screened some results to evaluate the reconstruction performance. Beco et al.37 compared the GAN reconstruction performance of 11 reconstruction leads by using independent encoders, with all leads sharing a single encoder, and tested the diagnostic performance of their 5-s short ECG reconstruction. Although these studies restrict the length of ECG segments to maintain training stability and reconstruction fidelity, this limitation hinders their ability to accurately reconstruct long-duration signals that carry rhythm information. For long-sequence lead reconstruction, Joo et al.38 developed an EKGAN that can directly perform 12-lead ECG generation and achieved better reconstruction quality than existing GAN-based methods such as CardioGAN.39 When trained on sufficiently large datasets, GAN-based method is capable of reconstructing both local waveform details and global rhythmic patterns in long-sequence ECG. However, it still suffers from mode collapse and training instability. In addition, variational autoencoder (VAE), as a classical generative model architecture, has also been applied to ECG lead reconstruction tasks,40 but it also exhibits instability when synthesizing long sequences, and the reconstructed signals are often excessively smoothed, sometimes retaining only a few sharp components such as the P-wave and R-wave.
Researchers have recently begun to pay more attention to diffusion models to achieve stable and high-quality artificial intelligence-generated content (AIGC). The DDPM41 has achieved better authenticity, diversity, and stability than GAN in image generation tasks. In particular, studies based on diffusion models42,43 have almost replaced GAN in text-to-image generation tasks. After showing its superiority in image generation, DDPM began to be applied in time-series signal generation tasks44 and inspired researchers in the field of ECG generation. Adib et al.25 embedded a single heartbeat into a two-dimensional space and then used classical DDPM45 to generate normal sinus heartbeats unconditionally. Although this method validated the feasibility of using DDPMs for ECG synthesis, it neither investigated conditional generation frameworks nor could be extended to more diverse rhythm classes. Tran et al.46 further employed a one-dimensional diffusion model (1D-DDPM) to generate 10-s length ECG recordings with multiple types of abnormalities, aiming to address the problem of data imbalance in the ECG domain. This approach supports unconditional synthesis of multiple arrhythmias, including AF and atrial flutter, and conditional generation of sinus rhythms with varying heart rates, while exhibiting strong stability and high fidelity in long-sequence ECG generation. Nonetheless, its goal is to diversify the dataset through augmentation, rather than to perform explicit reconstruction of missing leads. The DDPM study most closely related to ECG lead reconstruction is the regional decoupling diffusion model (RDDM) proposed by Xiao et al.,47 which aims to reconstruct lead II ECG signals from photoplethysmography (PPG). Although this method effectively captures the global rhythm of ECG signals, its cross-modal design limits further investigation of waveform-related characteristics and morphological details. Compared with VAE and GAN, DDPM exhibits more stable training and better global quality when dealing with one-dimensional long-sequence signals. However, its multi-step iterative architecture results in higher computational cost.
We note that almost all existing ECG lead reconstruction studies have used only single-lead ECG signals as conditions and did not use disease information as auxiliary conditions for model training, which may not be conducive to downstream tasks such as diagnosis. In contrast, in other domains such as image or audio synthesis, prior studies42,48 have employed multi-modal conditions, such as text, labels, and conditional images/audio, to jointly guide the training of generative models. Inspired by this, we designed the CFH-DDPM, which uses disease diagnosis information recorded by ECG to provide additional pathological guidance for generating models. The most significant difference between our method and the existing methods is that in our model, the disease category recorded by ECG is used as an auxiliary condition, and the single-lead ECG signal is used to train the conditional generation model, which promotes the model to directly establish the association between each lead signal and the disease. Specifically, we design a two-stage training strategy. In the first stage, disease information is directly injected into the model through a condition-fusion module. In the second stage, the disease information is no longer directly used as input, but the disease category guidance is provided to the model through the representation learning method.
The contributions of this paper are summarized as follows:
-
1.
We propose CFH-DDPM, a diffusion model using a two-step training strategy, for reconstruction from a single-lead ECG to a 12-lead ECG. It can preserve pathological features well by adding disease information input in the first stage and category representation learning in the second stage.
-
2.
We propose a condition-fusion module that introduces conditional information from different modalities into the UNet model. This module acts on the skip connection process of the UNet model, uses disease information as an auxiliary condition, enhances feature representation of the single-lead ECG as the primary condition, and strengthens the model’s understanding of the primary condition to obtain a better generation effect.
-
3.
We design a condition-hiding module to replace the direct input of disease information conditions in the second stage of training. This module is based on a representation learning model, and the comparison loss and classification loss are used to supervise the diffusion model to strengthen its reconstruction ability for pathological features.
Results
Dataset and metrics
The data used in this study came from three databases, namely MIMIC-IV-ECG: https://doi.org/10.13026/4NQG-SB35,49,50,51,52 PTB-XL: https://doi.org/10.13026/X4TD-X982,52,53,54 and the China Physiological Signal Challenge 2018 (CPSC2018),55 and all raw recordings in these datasets consist of 12-lead ECG signals. The training of DDPM requires a large amount of training data, and the dataset scale previously used for diagnostic tasks does not meet the requirements; so, we used MIMIC-IV-ECG to pre-train the proposed method and other comparison methods. MIMIC-IV-ECG is a huge database, publicly available since 2023 and containing more than 800,000 10-s length 12-lead ECG data and partially matched text reports that are either machine-generated or cardiologists’ diagnoses. We extracted 350 ECG description keywords from all reports and screened a total of 5,35,592 records containing these keywords and good ECG signal quality; of these, 5,15,592 records were randomly selected as a large training set, 10,000 records were selected as a validation set, and 10,000 records were selected as a test set. In addition, we randomly sampled 1,00,000 records from the training set to construct a small training set. Because the text reports of the MIMIC-IV-ECG database are partly generated by machines and are unreliable for diagnostic tasks, we used the PTB-XL and CPSC2018 databases to test the classification performance of the reconstructed signals. We retained 21,388 ECG records in the PTB-XL database that did not contain severely abnormal amplitude, with each record containing a corresponding cardiologist diagnostic description. These ECG descriptions can be reduced to five superclass labels, with the following data distribution: 9,508 normal ECG (NORM), 5,457 myocardial infarction (MI), 2,643 myocardial hypertrophy (HYP), 5,267 ST-T changes (STTCs), and 4,939 conduction block (CD). Multiple positive labels may exist for a single record. In addition, we used all 6,877 records from the CPSC2018 database. Because the length of records in the CPSC2018 database is not fixed, we used zero-padding or phasing to unify all record lengths to 10 s. The records from CPSC2018 contain nine labels, with the data distribution as follows: 918 normal ECG (NORM), 1221 AF, 722 first-degree atrioventricular block (I-AVB), 236 LBBB, 1857 right bundle branch block (RBBB), 616 premature atrial contraction (PAC), 700 premature ventricular contraction (VPC), 869 ST-segment depression (STD), and 220 ST-segment elevation (STE), which may have multiple positive labels in a single record. The PTB-XL and CPSC2018 databases were randomly selected, with 80% as the training set, 10% as the validation set, and 10% as the test set. All data were sampled at 100 Hz, with 16-bit precision and without additional filtering or normalization.
To evaluate the model’s reconstruction performance, we employed quality evaluation and classification consistency evaluation. Quality evaluation was used to quantify the agreement between the actual signal and the generated signal, including the sum of squared difference (SSD), percentage root-mean-square difference (PRD), cosine similarity(COS_SIM), and signal-to-noise ratio (SNR). Because there are 12 leads, the final result of quality evaluation is the mean of the respective results of all leads. Classification consistency was evaluated to quantify whether the generated signal accurately reflects the actual signal of the disease characteristics, including area under the curve (AUC), accuracy, precision, recall, and F1_score. Formula definitions of all evaluation metrics can be found in the STAR Methods.
Overview of the CFH-DDPM framework
We propose a two-stage conditional diffusion model41,56 consisting of a condition-fusion stage and a condition-hiding stage, as shown in Figure 1. The core noise-generating network is the Unet, its layer-by-layer processing details are shown in Table 1. When training the 12-lead ECG reconstruction model, we used not only the single-lead ECG as a condition but also the additional category information to guide the model in restoring critical features of the signal. The condition-fusion stage can be viewed as pre-training stage 1, where we explicitly injected the signal conditions together with the textual information conditions into the model by using the condition-fusion module. The structure of the condition-fusion module is shown in Figure 2. As shown in stage 1 of Figure 1, we used only the mean absolute error (MAE) loss between noise and noise prediction to guide the model. The model establishes the relationship between ECG waveform and description text and obtains the ability to reconstruct 12-lead ECG based on single-lead ECG condition and description text condition. The condition-hiding stage can be viewed as the fine-tuning stage 2, where we used the condition-hiding module to implicitly guide the model in maintaining category consistency of the reconstructed result with the original signal. As shown in stage 2 of Figure 1, we no longer provide the model with the description text of the ECG record as a condition. Instead, we added a pre-trained XResNet18 representation learning model to evaluate the reconstruction results, ensuring that the model can still effectively reconstruct pathological features without input of the disease description text. To summarize, the model first learns to reconstruct the pathological features of the signal, using additional text conditions in stage 1, and then learns to maintain the ability to reconstruct the pathological features without using text conditions in stage 2.
Figure 1.
Framework of the proposed CFH-DDPM
Table 1.
UNet processing details
| Block | Input | Output | Block | Input | Output |
|---|---|---|---|---|---|
| Encoder | 13∗1000 | 64∗1000 | Up Block 2 | 256∗125 | 128∗125 |
| Down Block 1 | 64∗1000 | 64∗1000 | Up Simple 1 | 128∗125 | 128∗250 |
| Down Simple 1 | 64∗1000 | 64∗500 | Up Block 3 | 128∗250 | 128∗250 |
| Down Block 2 | 64∗500 | 64∗500 | Up Block 4 | 128∗250 | 64∗250 |
| Down Simple 2 | 64∗500 | 64∗250 | Up Simple 2 | 64∗250 | 64∗500 |
| Down Block 3 | 64∗250 | 128∗250 | Up Block 5 | 64∗500 | 64∗500 |
| Down Simple 3 | 128∗250 | 128∗125 | Up Block 6 | 64∗500 | 64∗500 |
| Down Block 4 | 128∗125 | 256∗125 | Up Simple 3 | 64∗500 | 64∗1000 |
| Residual Block 1 | 256∗125 | 256∗125 | Up Block 7 | 64∗1000 | 64∗1000 |
| Residual Block 1 | 256∗125 | 256∗125 | Up Block 8 | 64∗1000 | 64∗1000 |
| Up Block 1 | 256∗125 | 256∗125 | Decoder | 64∗1000 | 12∗1000 |
Figure 2.
Structure of the condition-fusion module
Comparison with state-of-the-art methods
We verified the effectiveness of the proposed method by comparing it with state-of-the-art methods. We selected three classical generation architectures, VAE, EKGAN, and DDPM, for comparison with the proposed method. In recent years, most studies on ECG lead reconstruction have been based on GAN, and EKGAN38 is the most advanced one. There are also a few studies based on VAE.40 Because no study using DDPM for such tasks was found, we modified the DDPM framework used by Li et al.56 for ECG denoising to make it competent for the 12-lead ECG reconstruction task, which can be regarded as a classical one-dimensional conditional DDPM. The proposed method first trains ten epochs with a learning rate of 1e-3 on the MIMIC-IV-ECG large training set to complete stage 1, and then trains ten epochs with a learning rate of 1e-4 on the PTB-XL or CPSC2018 training set based on the best weights of stage 1 to complete stage 2. To be fair, all the comparison models except VAE are trained on the MIMIC-IV-ECG large training set, with a learning rate of 1e-3 for ten epochs as pre-training, and then trained on the PTB-XL or CPSC2018 training set, with a learning rate of 1e-4 for ten epochs to complete fine-tuning. VAE is trained on the MIMIC-IV-ECG large training set for 100 epochs and then on the PTB-XL or CPSC2018 training set for 50 epochs due to its poor convergence speed and stability.
-
1.
In this experiment, we compared the reconstruction quality of the proposed CFH-DDPM method with other methods on the PTB-XL and CPSC2018 test sets. Table 2 shows the quantitative evaluation results of reconstruction quality. Tables S1–S4 present the quality evaluation of different methods for reconstructing 12-lead signals of 10-s length from single-lead ECG as the condition, including the reconstruction quality of each individual lead as well as the average reconstruction quality. It can be seen that the VAE method has the worst COS_SIM and SNR, which means that its reconstructed signal has the least similarity with the original signal and the most irrelevant components. Although it achieves the best SSD performance on the CPSC2018 dataset, this is due to its conservative reconstruction strategy, which, in fact, compromises the reconstruction of pathological features. As one of the most advanced methods in the field of ECG reconstruction, EKGAN can reconstruct the morphology and trend of the original ECG better than VAE and classical DDPM. However, EKGAN has the worst SSD. On the CPSC2018 dataset, its SSD reached four times the optimal value. The worst SSD means that GAN-based methods such as EKGAN pay more attention to the signal’s shape than the amplitude, which is especially problematic when dealing with unnormalized data. The PRD, COS_SIM, and SNR of the classical DDPM method were slightly poor than those of EKGAN. In the CPSC2018 dataset, the proposed CFH-DDPM method showed a clear advantage in the reconstruction quality of chest leads, thereby achieving the best overall reconstruction quality. In the PTB-XL dataset, although the energy consistency of CFH-DDPM was weaker than that of EKGAN, its morphological reconstruction quality was superior to that achieved with EKGAN in most leads. This indicates that the proposed method allocates part of the attention from high-energy peak regions to low-energy detailed regions during reconstruction.
-
2.
In this experiment, we compared the classification consistency of the proposed CFH-DDPM method and the other methods on the PTB-XL and CPSC2018 test sets after reconstruction. To extensively evaluate the diagnostic applicability of the reconstructed signals, we trained the 5-classification model of PTB-XL and the 9-classification model of CPSC2018 based on the three model architectures. The three model architectures are Strodthoff et al.57’s LSTM,58 ResNet18,59 and XResNet1860 for ECG classification tasks. All classification models were trained on real 12-lead ECGs from the training set and tested separately on the real test set and the reconstructed test sets generated by each method. Because the classification performance of each classification model on the original data is different and not entirely correct, in order to intuitively reflect the classification consistency of the reconstructed signal, we used the achievement rate of each classification evaluation metric (that is, the ratio of the classification performance of the classification model on the reconstructed data to the classification performance on the reconstructed data), and averaged the results of the three models. Table 3 shows the classification consistency of each method on the PTB-XL and CPSC2018 test sets, where micro-averaging is used for precision, recall, and F1_score. Table 4 shows the F1_score achievement rate of each method for the five categories of PTB-XL and the nine categories of CPSC2018. It can be seen that the method proposed in this study achieved advantages in most kinds of comprehensive indicators, and only the accuracy on the PTB-XL dataset was weaker than that of the classical DDPM. This is because the NORM class accounts for a high proportion in the PTB-XL dataset, and the classical DDPM prefers the NORM class in the reconstruction, while the CFH-DDPM introduces additional classification information, and, therefore, the performance is more balanced on each class. The class distribution of CPSC2018 is more balanced than that of PTB-XL. However, data quality is slightly worse in CPSC2018, and the advantages of CFH-DDPM introducing additional classification information are more evident in this dataset.
-
3.
In this experiment, we selected forty 12-lead ECG samples from eight categories and extracted lead I as the conditioning input for reconstruction. Based on this single-lead input, four generative models, VAE, EKGAN, DDPM, and CFH-DDPM, were employed to reconstruct the complete 12-lead ECG signals. The resulting 12-lead ECGs (n = 200), including the originals and reconstructions, were then randomly shuffled and presented to physicians for diagnosis without disclosing whether the ECGs were real or reconstructed and from which method they came from. We evaluated each model’s reconstruction capability by comparing the physicians’ diagnostic conclusions on the reconstructed ECGs with those on the corresponding real ECGs. As shown in Figure 3, the outer color ring of each point represents the clinician’s diagnostic conclusion on the original ECG, while the inner color ring denotes the diagnosis based on the corresponding reconstructed ECG. The blue region in the background indicates the area where the diagnostic outcomes for the real and reconstructed signals are consistent. The results demonstrate that the proposed method yields the highest number of matched samples, suggesting that its reconstructed ECGs exhibit the best clinical interpretability and diagnostic reliability among all compared approaches.
Table 2.
Quality evaluation of comparison experiment
| Method | SSD (au)↓ | PRD (%)↓ | COS_SIM (%)↑ | SNR (dB)↑ |
|---|---|---|---|---|
| VAE (PTB-XL) | 34.19 | 82.01 | 58.50 | 2.17 |
| EKGAN (PTB-XL) | 35.43 | 69.78best | 66.98 | 4.26 |
| DDPM (PTB-XL) | 34.93 | 76.53 | 66.17 | 3.93 |
| CFH-DDPM (PTB-XL) | 31.84best | 73.78 | 68.59best | 4.79best |
| VAE (CPSC2018) | 65.24best | 86.22 | 54.24 | 1.67 |
| EKGAN (CPSC2018) | 277.46 | 82.40 | 63.48 | 3.67 |
| DDPM (CPSC2018) | 113.53 | 85.11 | 66.49 | 3.49 |
| CFH-DDPM (CPSC2018) | 65.67 | 74.73best | 68.25best | 4.68best |
The optimal results for each evaluation index of each dataset are marked in bold font.
Table 3.
Classification consistency of comparison experiment
| Method | AUC | Accuracy | Precision | Recall | F1-score |
|---|---|---|---|---|---|
| VAE (PTB-XL) | 81.96% | 68.07% | 75.26% | 63.15% | 68.57% |
| EKGAN (PTB-XL) | 84.35% | 72.81% | 78.36% | 66.84% | 72.04% |
| DDPM (PTB-XL) | 86.55% | 75.75%best | 79.93% | 71.71% | 75.53% |
| CFH-DDPM (PTB-XL) | 87.68%best | 74.32% | 80.33%best | 74.70%best | 77.37%best |
| VAE (CPSC2018) | 73.27% | 29.81% | 34.44% | 33.47% | 33.95% |
| EKGAN (CPSC2018) | 83.18% | 51.99% | 55.47% | 53.77% | 54.62% |
| DDPM (CPSC2018) | 87.45% | 63.20% | 67.75% | 65.44% | 66.58% |
| CFH-DDPM (CPSC2018) | 92.51%best | 74.76%best | 78.73%best | 77.88%best | 78.29%best |
The optimal results for each evaluation index of each dataset are marked in bold font.
Table 4.
Classification consistency of the PTB-XL and CPSC2018 categories
| Method | VAE | EKGAN | DDPM | CFH-DDPM |
|---|---|---|---|---|
| (PTB-XL)NORM | 82.37% | 87.85% | 89.13%best | 87.70% |
| (PTB-XL)MI | 58.01%best | 44.36% | 53.11% | 55.50% |
| (PTB-XL)HYP | 16.91% | 10.30% | 33.21% | 54.48%best |
| (PTB-XL)STTC | 78.82% | 86.13%best | 74.32% | 85.90% |
| (PTB-XL)CD | 28.70% | 34.12% | 65.36% | 67.51%best |
| (CPSC2018)NORM | 22.51% | 57.87% | 58.31% | 78.25%best |
| (CPSC2018)AF | 45.87% | 74.04% | 81.59% | 88.04%best |
| (CPSC2018)I-AVB | 19.32% | 72.54% | 85.24% | 90.30%best |
| (CPSC2018)LBBB | 95.16%best | 37.26% | 75.17% | 89.39% |
| (CPSC2018)RBBB | 5.94% | 49.33% | 73.22% | 79.19%best |
| (CPSC2018)PAC | 26.03% | 48.80% | 55.02% | 68.95%best |
| (CPSC2018)VPC | 7.75% | 19.05% | 55.48%best | 50.61% |
| (CPSC2018)STD | 6.32% | 11.61% | 60.64% | 62.72%best |
The optimal results for each evaluation index of each dataset are marked in bold font.
Figure 3.
Cardiologists’ diagnoses of real and reconstructed 12-lead ECGs
Ablation study
We determined the structure of the proposed method by ablation experiments. We used small training, test, and validation sets from the MIMIC-IV-ECG database for computational efficiency. In the first stage, for model stability, it trains for 100 epochs and retains the model weights with the optimal loss of the validation set. The second stage trains for ten epochs and retains the model weights with the optimal validation set loss. In this experiment, we used only quality evaluation to evaluate the method’s performance. Table 5 shows the signal reconstruction quality for the three ablation experiments.
-
1.
In the first stage of the proposed method, we used the condition-fusion module to repeatedly introduce the signal condition and text condition to the UNet skip connection process. This experiment compares the performance of the UNet model, Model1-1, using the condition-fusion module, and the classical UNet model Model1-2, which concatenates the condition vector with the noise vector directly at the input. Using the condition-fusion module makes better use of condition information than the method of directly concatenating the conditions at the UNet input and performs better on all metrics. In addition, we compared the effect of using PubMedBERT61 (Model1-1) and BioMedLM62 (Model1-3) as text-encoding methods on model reconstruction performance. The results showed that PubMedBERT can improve the reconstruction performance of the model to a greater extent than BioMedLM. This is because PubMedBERT is a dedicated medical semantic understanding model, while BioMedLM is a generative language model for medical context. Therefore, PubMedBERT is more suitable for extracting valuable pathological information from the non-standard text of the MIMIC-IV-ECG database to assist ECG reconstruction tasks.
-
2.
In the second stage of the proposed method, we used category representation learning, instead of text conditions, to guide the model to continue to optimize, including contrastive loss and classification loss. This experiment compares the performance of four DDPM models: Model2-1 using both contrastive loss and classification loss, Model2-2 using only contrastive loss, Model2-3 using only classification loss, and Model2-4 using neither loss. The results showed that both the classification loss and contrast loss can provide good guidance for the model on signal shape trend, and using them together can avoid the occurrence of irrelevant components in the reconstructed signal to the greatest extent.
-
3.
Our proposed training strategy uses two stages to explicitly introduce and implicitly maintain ECG category information in the diffusion model. This experiment compares the performance of Model2-1, using our training strategy, with Model0-1, which skips the first stage and directly trains in the second stage for 100 epochs. The results demonstrated the importance of explicitly introducing category information into the model in the first stage, which can improve the reconstruction performance of the model on all evaluation metrics.
Table 5.
Ablation study results
| Model | SSD (au)↓ | PRD (%)↓ | COS_SIM (%)↑ | SNR (dB)↑ |
|---|---|---|---|---|
| Model1-1 | 17.99 | 89.22 | 72.68 | 6.23 |
| Model1-2 | 22.13 | 90.23 | 68.87 | 5.38 |
| Model1-3 | 20.79 | 103.62 | 69.99 | 5.55 |
| Model2-1 | 20.00 | 102.78 | 68.42 | 6.20 |
| Model2-2 | 21.16 | 99.25 | 68.00 | 5.51 |
| Model2-3 | 20.46 | 105.10 | 67.18 | 4.92 |
| Model2-4 | 22.68 | 101.04 | 64.73 | 4.91 |
| Model0-1 | 21.55 | 103.17 | 67.01 | 5.46 |
Qualitative analysis
Figure 4A shows the original 12-lead ECG and the reconstruction results of various methods, where some visual features are consistent with the quantitative evaluation results. The VAE method is far weaker than the other methods in terms of the reconstruction ability of shapes and has more extra noise. EKGAN restores the waveforms of each channel but exaggerates some of them. Classical DDPM is conservative for reconstructing part of the waveform, so it ignores the unique morphology of part of the leads. CFH-DDPM achieves the best reconstruction quality. For abnormal rhythm ECGs, Figure 4B shows an AF ECG and the lead reconstruction results obtained by different methods. Figure 4C shows an ECG with I-AVB combined with PAC and the corresponding lead reconstruction results of each method.
Figure 4.
Visualization of original ECGs and the lead reconstruction results obtained by different methods
(A) Normal ECG.
(B) Atrial fibrillation ECG.
(C) First-degree atrioventricular block and premature atrial contraction ECG.
Figure 5A shows the reconstruction of lead V5 of an LBBB ECG. LBBB appears as a wide, notched R-wave in lead V5 or V6 of the ECG. The VAE method has serious noise. The EKGAN method successfully reconstructed the R-wave notch, but noise disturbed it. The classical DDPM failed to reproduce the pathological R-wave notches in most locations, whereas the proposed method not only successfully reconstructed and highlighted the majority of notched R waves but also preserved their amplitudes to the greatest extent.
Figure 5.
Visual comparison of abnormal leads in original ECGs with the reconstruction results obtained by different methods
(A–D) Reconstruction of (A) left bundle branch block ECG, (B) right bundle branch block ECG, (C) atrial fibrillation with ST-segment depression ECG, and (D) atrial fibrillation with left bundle branch block ECG
Figure 5B shows the reconstruction of lead V1 of an ECG of class RBBB. The RBBB appears as a “rabbit ear” type (R-S-R′ type) in lead V1 or V2 of the ECG. The VAE method could not reconstruct R′-waves. The reconstruction of the R-S-R′ waveform by EKGAN was severely distorted, exhibiting substantial errors in both the amplitude and the temporal position of the R′ wave. The conventional DDPM also showed instability in reconstructing the R-S-R′ morphology, and in some heartbeats, recovering only the R′ wave while missing the preceding R-S components. In contrast, the proposed CFH-DDPM consistently reconstructed the complete R-S-R′ waveform at all heartbeat positions.
Figure 5C shows the reconstruction of lead V5 of an ECG of class AF and STD. Both DDPM and CFH-DDPM were able to reconstruct the STD in the precordial leads, with CFH-DDPM achieving lower reconstruction error.
Figure 5D shows lead V5 reconstruction of an ECG of class AF and LBBB. All methods successfully reproduced the irregular R-R intervals and absence of P-wave characteristic of AF. CFH-DDPM best captured the secondary STTCs associated with LBBB and partially reconstructed R-wave notching.
To visually demonstrate that the classification consistency of our proposed CFH-DDPM method is superior to those of existing methods, we visualized t-SNE distribution of the intermediate features extracted from the ResNet18 classification model in the CPSC2018 test set reconstructed by each method. As shown in Figure 6, to ensure clarity, the nine categories of CPSC2018 were divided into three groups: the first group includes NORM, AF, PAC, and VPC; the second group includes NORM, I-AVB, LBBB, and RBBB; and the third group includes NORM, STD, and STE. In the first group, the proposed CFH-DDPM achieved the best clustering separation for NORM, AF, and PAC, while its clustering compactness for VPC was slightly inferior to that of the classical DDPM. In the second group, CFH-DDPM demonstrated better clustering separation for NORM, I-AVB, and RBBB than the other reconstruction methods, but its clustering compactness for LBBB was slightly worse than that of the VAE. In the third group, due to the high reconstruction difficulty of ST abnormalities in chest leads, the clustering separation of all methods was relatively low, with CFH-DDPM showing a slight advantage in clustering compactness over the others.
Figure 6.
t-SNE of original ECGs and the ECGs reconstructed by VAE, EKAGN, DDPM, and CFH-DDPM
Discussion
Because of the limitations of 12-lead ECG measurement, many studies have attempted to reconstruct a full 12-lead ECG using an I-lead ECG that can be obtained with a portable device. In recent years, VAE, GAN, and other deep learning methods have achieved good results in 12-lead ECG reconstruction tasks. However, these studies still need to overcome the following challenges: (1) To maintain the reconstruction stability, the existing reconstruction methods almost all normalize and filter the original ECG, inevitably leading to information loss of the reconstructed data. (2) The existing methods use only single-lead ECG signals as the generation condition of the model and do not pay attention to how to use the information, such as text description and diagnostic category of ECG records. We propose the CFH-DDPM to address these challenges in the 12-lead ECG reconstruction task. Specifically, we design a two-stage model training strategy based on the DDPM framework. In the first stage, we designed a condition-fusion module that can fuse signal conditions and description conditions and applied it to the UNet model of the DDPM framework. The condition-fusion module repeatedly introduces single-lead ECG signals and ECG category descriptions in the noise prediction process to help the model establish the connection between ECG signals and their categories. In the second stage, considering that the ECG category description cannot be directly obtained in the actual reconstruction task, we designed a condition-hiding module to prevent the model from forgetting the category knowledge without direct category conditional input. The condition-hiding module is a pre-trained representation learning model, which provides category knowledge guidance for the model through feature vectors in the middle layer and classification logits in the output layer, without additional category information input.
We experimentally demonstrated the effectiveness of CFH-DDPM. Benefiting from the performance of DDPM and the additional category information guidance, CFH-DDPM showed better reconstruction performance than the existing state-of-the-art methods. CFH-DDPM achieved advantages in almost all quality assessments, especially in COS_SIM, which reflects the trend of signal shape. In the classification task, CFH-DDPM showed not only the ability to restore the consistency of signal classification but also good anti-interference ability in the face of unstandardized signals. As for the classification performance of each disease, CFH-DDPM achieved the optimal classification consistency for most diseases, while for a few remaining diseases its performance is slightly below the SOTA methods, with only a minimal performance gap. In the qualitative analysis, we visually show the reconstruction results of the overall signal and pathological waveforms of ECG by using CFH-DDPM and use t-SNE to visualize the classification consistency between the reconstruction results and the original signal.
Limitations of the study
There are still some technical limitations that warrant further study: (1) The CFH-DDPM requires a large training data scale, and our current solution is to use a large dataset in the first stage of training and select the corresponding small dataset in the second stage of training according to the requirements of subsequent tasks. We tried training on small datasets like PTB-XL or CPSC2018 in the first stage, but it was far less effective than using large datasets. (2) Many non-disease characteristics of ECG differ from person to person, for example, the amplitude of each lead has noticeable individual differences. In this study, we focused on general reconstruction methods and, therefore, did not focus on individual patient information. Fortunately, these two problems can be solved as follows: (1) The ECG reconstruction model can adapt to the signal conditions of unequal length by zero-filling method; so, the accurate segmentation of ECG signals according to pathological characteristics is a feasible data enhancement method; (2) Knowledge distillation is a small-sample, fine-tuning method commonly used in classification tasks and can be used for personalized fine-tuning of ECG reconstruction models.
Beyond technical issues, we also plan to address limitations regarding practical applicability. The proposed method was developed based on a portable single-lead ECG device previously developed by our team, which could achieve clinical-level acquisition accuracy. At present, the method has been trained entirely on clinical ECG datasets. In the future, we plan to collaborate with hospitals to collect paired ECGs, using both our portable single-lead device and clinical 12-lead devices, in order to validate and further improve the quality of lead reconstruction in real-world scenarios. In addition, generation speed is another factor that constrains the practicality of the method. Under the experimental settings of this study, synthesizing a 10-s length, 12-lead ECG sample takes approximately 12.6 ms and may be slower when batch processing is not feasible. How to handle potential high-concurrency situations remains a challenge to be resolved before deploying this method in practical applications.
Resource availability
Lead contact
Requests for further information and resources should be directed to and will be fulfilled by the lead contact, Yanrui Jin (jinyanrui@sjtu.edu.cn).
Materials availability
This study did not generate new unique reagents.
Data and code availability
-
•
All data presented within this study are available in key resources table.
-
•
All original code has been deposited at GitHub and is publicly available as of the date of publication (see key resources table).
-
•
Any additional information required to reanalyze the data reported in this work paper is available from the lead contact upon request.
Acknowledgments
This project is supported by National Natural Science Foundation of China (no. 62406190), China Postdoctoral Science Foundation (grant no. 2023M732219), National Postdoctoral Program for Innovative Talents (no. BX20230215), and Shanghai Municipal Science and Technology Major Project (no. 2021SHZDZX0102).
Author contributions
X.W., Z.L., and Y.T. conceived the idea and designed the experiments; X.W. and Z.L. wrote the code, performed the experiments, and plotted the figures; X.W. analyzed the results and drafted the manuscript; M.W., Y.J., and W.D. carried out critical revisions of the manuscript and the results and discussion sections; Y.J. organized the doctors to re-annotate the reconstructed ECGs; X.W., Z.L., and Y.J. re-conducted the experiments and revised the manuscript format; Y.J. and C.L. supervised the projects, approved the submission, and accept responsibility for the overall integrity of the paper.
Declaration of interests
The authors declare no competing interests.
STAR★Methods
Key resources table
| REAGENT or RESOURCE | SOURCE | IDENTIFIER |
|---|---|---|
| Deposited data | ||
| MIMIC-IV-ECG | Beth Israel Deaconess Medical Center | PhysioNet: https://physionet.org/content/mimic-iv-ecg/1.0/ |
| PTB-XL | Physikalisch-Technische Bundesanstalt | PhysioNet: https://physionet.org/content/ptb-xl/1.0.2/ |
| CPSC2018 | The China Physiological Signal Challenge 2018 | http://2018.icbeb.org/Challenge.html |
| Software and algorithms | ||
| CFH-DDPM | This paper | Github: https://github.com/victor0926/CFH-DDPM.git |
| Pytorch | – | https://pytorch.org/ |
Experimental model and study participant details
This study is a retrospective study. Three datasets were used in total, among which MIMIC-IV-ECG, CPSC2018, and PTB-XL are all open-source datasets. MIMIC-IV-ECG is the ECG dataset from the population in the northeastern United States, which is used for model pre-training. CPSC2018 is the ECG dataset from China, and PTB-XL is the ECG dataset from Europe (70.89% from Germany, 27.9% from the British, and 1.21% from Sweden). CPSC2018 and PTB-XL are used to evaluate the leads reconstruction performance of the model. This study did not screen and process factors such as region, race, age, gender, and ECG collection equipment. Only the records with severe amplitude abnormalities in these datasets were excluded.
Method details
Details of the proposed CFH-DDPM
This study is based on the classical conditional DDPM, whose core noise-generating network is the Unet shown in Figure 1. This Unet includes the input encoder, DownBlock, DownSample, ResBlock, Condition-Fusion Module, Upsample, Upblock as well as the output decoder. The input encoder is a 1D convolution that performs channel conversion and feature extraction on the input signal. DownBlock, Upblock and ResBlock are residual modules with similar structure. This residual module first standardizes the input by GroupNorm, then goes through the first layer of convolution after Swish activation, plus the time embedding, then goes through the second normalization, activation, dropout and the second layer of convolution, and finally adds the input to the output through the residual connection to form the final result. DownSample reduces the feature map size by 1D convolution, and Upsample expands the feature map size by transposed convolution. The output decoder first normalizes and activates the final feature, and then maps it to a noise prediction using 1D convolution. The layer-by-layer processing details of Unet are shown in Table 1. In addition, we used PubMedBERT to encode the description text of ECG recordings. PubMedBERT is a pre-trained language model based on biomedical literature corpus, which has better semantic understanding ability than general multi-modal feature alignment methods. We also pre-trained a representation learning model for the condition-hiding module of stage 2. This model is based on XResNet18, and the pre-training is guided by the intermediate features of the four residual stages in the network and the final classification results.
Denoising diffusion probabilistic model
The DDPM architecture used in this study basically follows the classical conditional DDPM, whose idea is to construct a forward process of gradually adding noise to the target distribution and a reverse process of gradual denoising to restoring the target distribution from random noise. Specifically, the forward process is a Markov chain, as shown in Equation 1.
| (Equation 1) |
Where x0 is the original signal and xt is the intermediate state with noise; ϵ is Gaussian noise, the model learns to denoise by predicting ϵ; The cumulative noise coefficient , βi is the noise coefficient of the i-th time step generated in advance.
Equation 2 shows the inverse process for restoring the intermediate signal at the previous time step from the noise prediction at the current time step.
| (Equation 2) |
Where xc is the single lead ECG condition, fn is the encoded text description condition, is the noise prediction given by UNet based on intermediate state, time step and condition information. z is Gaussian noise, which is used to add randomness to the inverse process to achieve diversity of generated samples.
The following explains how the DDPM architecture is applied during training and inference.
During the training process, the model learns to predict the noise component contained in a noisy signal at an arbitrary diffusion time step. First, a time step t is randomly sampled, and a Gaussian noise vector ϵ controlled by t is added to the original 12-lead ECG signal x0 through the forward process, resulting in a noisy signal xt. Then, the time step t, the noisy signal xt, the conditional signal xc (single-lead ECG), and the text condition are fed into the Unet to obtain a noise prediction ϵθ. Finally, the model is optimized by minimizing the discrepancy between the injected Gaussian noise and the predicted noise.
During the inference process, the model executes the complete reverse diffusion process, starting from a randomly sampled noise signal and progressively reconstructing the signal. At each time step, the model first inputs the time step t, the noisy signal xt from the previous step, and the conditional signal xc (single-lead ECG) into the UNet to predict the noise component ϵθ contained in the noisy signal. Next, the original signal estimate is computed based on the time step t, the noisy signal xt, and the predicted noise ϵθ. Finally, the mean and log-variance of the posterior distribution are computed based on the time step t, the noisy signal xt, and the estimated original signal , and the noisy signal xt-1 to be passed to the next time step is obtained. At each step, the model corrects only a portion of the noise, and the final reconstructed signal is produced through this iterative procedure.
Condition-fusion module
Existing methods find ECG signal generation challenging because subtle variations in rhythm, morphology and amplitude of ECG signals can lead to severe deviations in their diagnostic significance. Existing methods usually only rely on intuitive features such as rhythm in a single input condition and ignore more nuanced morphological changes, so they cannot restore the disease characteristics of the original signal. Therefore, we design the condition-fusion module to implant different classes of conditions into the UNet of the diffusion model at multiple scales.
The condition-fusion module is added in the skip connection process of UNet, which is used to repeatedly inject the different scale features of the primary condition into UNet after fusion with the secondary condition. The primary condition (single-lead ECG) is passed through a multi-layer encoder with the same structure as the compression path of UNet to obtain a multi-scale feature fp(i) with the same size as the intermediate feature fm(i) of the i-th layer of the UNet compression path. The secondary conditions (disease description information) are encoded as the secondary condition feature fn using pre-trained PubMedBERT and multi-layer perceptron. The specific structure of the condition-fusion module is shown in Figure 2. The main condition feature fp(i) and the UNet intermediate feature fm(i) are concatenated in the feature channel dimension to obtain the channel information feature fc(i). Then, the channel attention module is used to obtain the channel weight vector Wc(i). The weight vector is used to weight the features. The weighted feature fw(i) is downsampled to be consistent with the intermediate feature fm(i) in the channel dimension, yielding f0(i). After that, we used cross-attention to introduce the secondary condition feature fn. f0(i) is used as the Query, and fn is used as the Key and Value, each time step of the Query and each sub-encoding of the Key are multiplied along the feature dimension to obtain a similarity matrix. The similarity matrix is then normalized via softmax to form the attention distribution, which is used to compute a weighted sum with the Value, thereby incorporating the text into the model. The cross-attention’s output fr(i) serves as the hop-connected input upsampling module.
Condition-hiding module
One of the purposes of ECG signal reconstruction is to enhance the acquisition results of portable single-lead ECG acquisition devices and make them suitable for deep-learning diagnosis models based on 12-lead ECG. In this case, we cannot access descriptions of diseases, as they come from more downstream diagnostic tasks. Therefore, we propose a condition-hiding module to omit the explicit input of the minor condition in the condition fusion module and keep its information implicitly within the model. Instead of directly using the report text corresponding to ECG records, we extract report text keywords and convert them into category labels according to the requirements of downstream tasks. The condition-hiding module is a pre-trained representation learning model based on the architecture of XResNet18. It possesses multi-scale feature extraction capability and strong classification performance, making it suitable for evaluating the reconstruction of pathological features in the generated results.
We use the four residual stages of the category representation learning model to extract the intermediate features of four different sizes of ECG signals and transform them into the category feature vector with the same size by average pooling and linear scaling. These category feature vectors are used to guide the diffusion model in retaining the critical category features of the generative target, which is achieved by contrastive loss. In training, we restore the signal prediction X0 based on the noise prediction ϵθ given by UNet and the added noise signal Xt, which is used as the anchor sample. The original signal Xp before adding noise is selected for positive samples, while for negative samples, samples that do not have precisely the same label as anchor samples are randomly selected. Information Noise Contrastive Estimation(InfoNCE) Loss is used as the contrastive loss, as shown in Equation 3.
| (Equation 3) |
Where N is the number of negative samples and is set to 16. , and represent the feature vectors of anchor samples, positive samples and negative samples at the t-th stage of XResNet18, respectively. τ is the temperature parameter and is set to 5.
In addition, we also use the difference between the predicted logits of the class representation learning model for the anchor sample and the positive sample as the classification loss guidance model. Kullback-Leibler Divergence is used for the classification loss, as shown in Equation 4.
| (Equation 4) |
Since the Mean Absolute Error loss can only measure the overall reconstruction error of the signal without assessing whether pathological features are preserved, we employ the aforementioned contrastive loss and classification loss to supervise the reconstruction of class-specific features. The classification loss enforces consistency between the reconstructed results and the original signals in the discrete label space, while the contrastive loss requires alignment between them in the continuous high-dimensional space across multiple scales. The combination of the two ensures that the model pays particular attention to pathological features during lead reconstruction.
Training strategy
Our training strategy consists of two stages. In the first stage, the disease text information corresponding to the ECG record is directly injected into the model using the condition-fusion module, as shown in Algorithm 1. We only use the MAE loss to optimize the model, as shown in Equation 5. In this stage, the generator acquires ECG signal reconstruction capability and establishes the connection between ECG signal features and texts describing categories.
| (Equation 5) |
Where L1 represents the total loss in the first stage; N is the number of samples. T is the sample length. is the true value of the t-th point of the noise of the i-th sample; is the predicted value of the t-th point of the noise of the i-th sample.
Algorithm 1. The Stage-1 training using the condition-fusion module.
| Input: Total time step T, Original signal xp, Single lead ECG condition xc, Encoded description text condition fn. | |
| Output: Loss for the Stage-1 training L1. | |
| 1: | Choose a time step t∼[0,T] at random, calculate the cumulative noise coefficient ; |
| 2: | Add noise ϵ∼N(0,1) to xp using Equation 1 to obtain xt; |
| 3: | Fed xt, , xc and fn into UNet to obtain the noise prediction ; |
| 4: | Calculate Stage-1 loss L1 with Equation 5; |
| 5: | Return L1. |
In the second stage, we no longer directly input the text information as a condition, as shown in Algorithm 2. To enable the model to maintain the category information introduced in stage one when only the signal input is available, we use the condition-hiding module to provide additional guidance to the model, as shown in Equation 6.
| (Equation 6) |
Where L2 represents the total loss in the second stage; hyperparameters λ1 = 0.01 and λ2 = 0.01.
Algorithm 2. The Stage-2 training using the condition-fusion module.
| Input: Total time step T, Original signal xp, Negative sample xn, Single lead ECG condition xc, Encoded meaningless text . | |
| Output: Loss for the Stage-2 training L2. | |
| 1: | Choose a time step t∼[0,T] at random, calculate the cumulative noise coefficient ; |
| 2: | Add noise ϵ∼N(0,1) to xp using Equation 1 to obtain xt; |
| 3: | Fed xt, , xc and into UNet to obtain the noise prediction ; |
| 4: | Calculate MAE loss LMAE with Equation 5; |
| 5: | Restore signal x0 with: ; |
| 6: | Fed x0, xp and xn into the representation learning model to obtain feature vectors v0, vp, vn and classification logits logits0 and logitsp; |
| 7: | Calculate contract loss LContrast and classification loss LClassification with Equations 3 and 4; |
| 8: | Calculate Stage-2 loss L2 with Equation 6; |
| 9: | Return L2. |
This study is similar to the classical conditional DDPM training method. The difference is that we use a two-stage training strategy, where the model establishes the relationship between the signal waveform and the disease description text in stage 1 and ends the demand for the text condition in stage 2. The model can focus on the pathological features of the reconstructed signal without the need for disease information hints, which is the core of the proposed method. In algorithm 1, disease category information is introduced directly through the encoded description text fn. In Algorithm 2, the reconstructed signal, the original signal, and other class negative samples calculate the classification loss and contrast loss through the representation learning module, and guide the generation model to learn the disease class information. The model gains the ability to reconstruct a 12-lead ECG in the stage of algorithm 1 and generates the correct ECG in the stage of algorithm 2, independent of class prompt inputs. In practical scenarios, the model does not require textual information or class labels during inference and uses only a single-lead ECG as input. The conditional fusion and representation learning modules have additional computational overhead. Taking the batch size of 128 as an example, in classic DDPM training, a batch takes 0.049 s, CFH-DDPM stage 1 takes 0.098 s, and stage 2 takes 0.169.
Implementation details
In this study, we used the Adam optimizer for all experiments. The learning rate was set to 0.001 for stage 1/pre-training stage and 0.0001 for stage 2/fine-tuning stage. The batch size was 128 for all experiments. Our experimental platform is NVIDIA RTX 4090 GPU, Intel Core i9-13900K CPU, 64 GB RAM, and the experimental environment is Python 3.11.4 and PyTorch 2.1.0.
Quantification and statistical analysis
Evaluation metrics
This study involves two types of reconstruction performance evaluation: quality evaluation and classification consistency evaluation. Quality evaluation is used to quantify the agreement between the actual signal and the generated signal, including SSD, PRD, COS_SIM, and SNR, as shown in Equations 7, 8, 9, and 10.
| (Equation 7) |
| (Equation 8) |
| (Equation 9) |
| (Equation 10) |
Where y is the original signal and is the reconstructed signal.
Classification consistency is evaluated to quantify whether the generated signal accurately reflects the actual signal of the disease characteristics, including Area Under the Curve(AUC), Accuracy, Precision, Recall, and F1_score, as shown in Equations 11, 12, 13, and 14.
| (Equation 11) |
| (Equation 12) |
| (Equation 13) |
| (Equation 14) |
Where TP represents true positives, FP is false positives, TN is true negatives, and FN is false negatives in the evaluation metrics.
Published: February 28, 2026
Footnotes
Supplemental information can be found online at https://doi.org/10.1016/j.isci.2026.115188.
Contributor Information
Yanrui Jin, Email: jinyanrui@sjtu.edu.cn.
Weiping Ding, Email: ding.wp@ntu.edu.cn.
Chengliang Liu, Email: profclliu@163.com.
Supplemental information
References
- 1.Han C., Shi L. ML–ResNet: A novel network to detect and locate myocardial infarction using 12 leads ECG. Comput. Methods Programs Biomed. 2020;185 doi: 10.1016/j.cmpb.2019.105138. [DOI] [PubMed] [Google Scholar]
- 2.Yao Q., Wang R., Fan X., Liu J., Li Y. Multi-class Arrhythmia detection from 12-lead varied-length ECG using Attention-based Time-Incremental Convolutional Neural Network. Inf. Fusion. 2020;53:174–182. doi: 10.1016/j.inffus.2019.06.024. [DOI] [Google Scholar]
- 3.Yang S., Lian C., Zeng Z., Xu B., Zang J., Zhang Z. A Multi-View Multi-Scale Neural Network for Multi-Label ECG Classification. IEEE Trans. Emerg. Top. Comput. Intell. 2023;7:648–660. doi: 10.1109/TETCI.2023.3235374. [DOI] [Google Scholar]
- 4.Roy M., Majumder S., Halder A., Biswas U. ECG-NET: A deep LSTM autoencoder for detecting anomalous ECG. Eng. Appl. Artif. Intell. 2023;124 doi: 10.1016/j.engappai.2023.106484. [DOI] [Google Scholar]
- 5.Song C., Zhou Z., Yu Y., Shi M., Zhang J. An improved Bi-LSTM method based on heterogeneous features fusion and attention mechanism for ECG recognition. Comput. Biol. Med. 2024;169 doi: 10.1016/j.compbiomed.2023.107903. [DOI] [PubMed] [Google Scholar]
- 6.Kusuma S., Jothi K.R. ECG signals-based automated diagnosis of congestive heart failure using Deep CNN and LSTM architecture. Biocybern. Biomed. Eng. 2022;42:247–257. doi: 10.1016/j.bbe.2022.02.003. [DOI] [Google Scholar]
- 7.Yang M.-U., Lee D.-I., Park S. Automated diagnosis of atrial fibrillation using ECG component-aware transformer. Comput. Biol. Med. 2022;150 doi: 10.1016/j.compbiomed.2022.106115. [DOI] [PubMed] [Google Scholar]
- 8.Li H., Han J., Zhang H., Zhang X., Si Y., Zhang Y., Liu Y., Yang H. Clinical knowledge-based ECG abnormalities detection using dual-view CNN-Transformer and external attention mechanism. Comput. Biol. Med. 2024;178 doi: 10.1016/j.compbiomed.2024.108751. [DOI] [PubMed] [Google Scholar]
- 9.El-Ghaish H., Eldele E. ECGTransForm: Empowering adaptive ECG arrhythmia classification framework with bidirectional transformer. Biomed. Signal Process Control. 2024;89 doi: 10.1016/j.bspc.2023.105714. [DOI] [Google Scholar]
- 10.Ma C., Lan K., Wang J., Yang Z., Zhang Z. Arrhythmia detection based on multi-scale fusion of hybrid deep models from single lead ECG recordings: A multicenter dataset study. Biomed. Signal Process Control. 2022;77 doi: 10.1016/j.bspc.2022.103753. [DOI] [Google Scholar]
- 11.Liu L.-R., Huang M.-Y., Huang S.-T., Kung L.-C., Lee C.H., Yao W.-T., Tsai M.-F., Hsu C.-H., Chu Y.-C., Hung F.-H., Chiu H.W. An Arrhythmia classification approach via deep learning using single-lead ECG without QRS wave detection. Heliyon. 2024;10 doi: 10.1016/j.heliyon.2024.e27200. [DOI] [PMC free article] [PubMed] [Google Scholar]
- 12.Islam M.R., Qaraqe M., Qaraqe K., Serpedin E. CAT-Net: Convolution, attention, and transformer based network for single-lead ECG arrhythmia classification. Biomed. Signal Process Control. 2024;93 doi: 10.1016/j.bspc.2024.106211. [DOI] [Google Scholar]
- 13.Geweid G.G.N., Chen J.D.Z. Automatic classification of atrial fibrillation from short single-lead ECG recordings using a Hybrid Approach of Dual Support Vector Machine. Expert Syst. Appl. 2022;198 doi: 10.1016/j.eswa.2022.116848. [DOI] [Google Scholar]
- 14.Msigwa G., Ntambala E., Yun J. Enhancing atrial fibrillation classification from single-lead electrocardiogram signals using attention-based networks and generative adversarial networks with density-based clustering. Eng. Appl. Artif. Intell. 2024;133 doi: 10.1016/j.engappai.2024.108607. [DOI] [Google Scholar]
- 15.Fang B., Yu Z., Zhang L.b., Teng Y., Chen J. K-B2S+: A one-dimensional CNN model for AF detection with short single-lead ECG waves from wearable devices. Digital Communications and Networks. 2025;11:613–621. doi: 10.1016/j.dcan.2024.05.004. [DOI] [Google Scholar]
- 16.Dössel O., Luongo G., Nagel C., Loewe A. Computer Modeling of the Heart for ECG Interpretation—A Review. Hearts. 2021;2:350–368. doi: 10.3390/hearts2030028. [DOI] [Google Scholar]
- 17.van Oosterom A., Oostendorp T.F. ECGSIM: an interactive tool for studying the genesis of QRST waveforms. Heart. 2004;90:165–168. doi: 10.1136/hrt.2003.014662. [DOI] [PMC free article] [PubMed] [Google Scholar]
- 18.Maheshwari S., Acharyya A., Rajalakshmi P., Puddu P.E., Schiariti M. Accurate and reliable 3-lead to 12-lead ECG reconstruction methodology for remote health monitoring applications. IRBM. 2014;35:341–350. doi: 10.1016/j.irbm.2014.07.004. [DOI] [Google Scholar]
- 19.Trobec R., Tomašić I. Synthesis of the 12-Lead Electrocardiogram From Differential Leads. IEEE Trans. Inf. Technol. Biomed. 2011;15:615–621. doi: 10.1109/TITB.2011.2159236. [DOI] [PubMed] [Google Scholar]
- 20.Zhu F., Ye F., Fu Y., Liu Q., Shen B. Electrocardiogram generation with a bidirectional LSTM-CNN generative adversarial network. Sci. Rep. 2019;9 doi: 10.1038/s41598-019-42516-z. [DOI] [PMC free article] [PubMed] [Google Scholar]
- 21.Golany T., Radinsky K. PGANs: Personalized Generative Adversarial Networks for ECG Synthesis to Improve Patient-Specific Deep ECG Classification. Proc. AAAI Conf. Artif. Intell. 2019;33:557–564. doi: 10.1609/aaai.v33i01.3301557. [DOI] [Google Scholar]
- 22.Wulan N., Wang W., Sun P., Wang K., Xia Y., Zhang H. Generating electrocardiogram signals by deep learning. Neurocomputing. 2020;404:122–136. doi: 10.1016/j.neucom.2020.04.076. [DOI] [Google Scholar]
- 23.Golany T., Radinsky K., Freedman D. Proceedings of the 37th International Conference on Machine Learning. PMLR; 2020. SimGANs: Simulator-Based Generative Adversarial Networks for ECG Synthesis to Improve Deep ECG Classification; pp. 3597–3606. [Google Scholar]
- 24.Zhang Y.-H., Babaeizadeh S. Synthesis of standard 12-lead electrocardiograms using two-dimensional generative adversarial networks. J. Electrocardiol. 2021;69:6–14. doi: 10.1016/j.jelectrocard.2021.08.019. [DOI] [PubMed] [Google Scholar]
- 25.Adib E., Fernandez A.S., Afghah F., Prevost J.J. Synthetic ECG Signal Generation Using Probabilistic Diffusion Models. IEEE Access. 2023;11:75818–75828. doi: 10.1109/ACCESS.2023.3296542. [DOI] [Google Scholar]
- 26.Tran T.D., Dang T.T.K., Tran N.Q. In: Computational Science and Its Applications – ICCSA 2024. Gervasi O., Murgante B., Garau C., Taniar D., Rocha A.M.A.C., Faginas Lago M.N., editors. Springer Nature Switzerland; 2024. An Innovative Approach for Long ECG Synthesis with Wasserstein GAN Model; pp. 339–351. [DOI] [Google Scholar]
- 27.Chung H., Kim J., Kwon J.-M., Jeon K.-H., Lee M.S., Choi E. Text-to-ECG: 12-Lead Electrocardiogram Synthesis Conditioned on Clinical Text Reports. ICASSP 2023. IEEE International Conference on Acoustics, Speech and Signal Processing (ICASSP) IEEE; 2023. pp. 1–5. [DOI] [Google Scholar]
- 28.Atoui H., Fayn J., Rubel P. A Novel Neural-Network Model for Deriving Standard 12-Lead ECGs From Serial Three-Lead ECGs: Application to Self-Care. IEEE Trans. Inf. Technol. Biomed. 2010;14:883–890. doi: 10.1109/TITB.2010.2047754. [DOI] [PubMed] [Google Scholar]
- 29.Wang L.d., Zhou W., Xing Y., Liu N., Movahedipour M., Zhou X.g. A novel method based on convolutional neural networks for deriving standard 12-lead ECG from serial 3-lead ECG. Frontiers Inf. Technol. Electronic Eng. 2019;20:405–413. doi: 10.1631/FITEE.1700413. [DOI] [Google Scholar]
- 30.Kapfo A., Datta S., Dandapat S., Bora P.K. LSTM based Synthesis of 12-lead ECG Signal from a Reduced Lead Set. IEEE International Conference on Signal Processing, Informatics, Communication and Energy Systems (SPICES) IEEE; 2022. pp. 296–301. [DOI] [Google Scholar]
- 31.Sohn J., Yang S., Lee J., Ku Y., Kim H.C. Reconstruction of 12-Lead Electrocardiogram from a Three-Lead Patch-Type Device Using a LSTM Network. Sensors. 2020;20 doi: 10.3390/s20113278. [DOI] [PMC free article] [PubMed] [Google Scholar]
- 32.Goodfellow I., Pouget-Abadie J., Mirza M., Xu B., Warde-Farley D., Ozair S., Courville A., Bengio Y. Advances in Neural Information Processing Systems. Curran Associates, Inc.; 2014. Generative Adversarial Nets. [Google Scholar]
- 33.Johnson J., Alahi A., Fei-Fei L. In: Computer Vision – ECCV 2016. Leibe B., Matas J., Sebe N., Welling M., editors. Springer International Publishing; 2016. Perceptual Losses for Real-Time Style Transfer and Super-Resolution; pp. 694–711. [DOI] [Google Scholar]
- 34.Isola P., Zhu J.-Y., Zhou T., Efros A.A. 2017 IEEE Conference on Computer Vision and Pattern Recognition (CVPR) IEEE; 2017. Image-To-Image Translation With Conditional Adversarial Networks; pp. 1125–1134. [Google Scholar]
- 35.Lee J., Oh K., Kim B., Yoo S.K. Synthesis of Electrocardiogram V-Lead Signals From Limb-Lead Measurement Using R-Peak Aligned Generative Adversarial Network. IEEE J. Biomed. Health Inform. 2020;24:1265–1275. doi: 10.1109/JBHI.2019.2936583. [DOI] [PubMed] [Google Scholar]
- 36.Seo H.-C., Yoon G.-W., Joo S., Nam G.-B. Multiple electrocardiogram generator with single-lead electrocardiogram. Comput. Methods Programs Biomed. 2022;221 doi: 10.1016/j.cmpb.2022.106858. [DOI] [PubMed] [Google Scholar]
- 37.Beco S.C., Pinto J.R., Cardoso J.S. Electrocardiogram lead conversion from single-lead blindly-segmented signals. BMC Med. Inform. Decis. Mak. 2022;22:314. doi: 10.1186/s12911-022-02063-6. [DOI] [PMC free article] [PubMed] [Google Scholar]
- 38.Joo J., Joo G., Kim Y., Jin M.-N., Park J., Im H. In: Medical Image Computing and Computer Assisted Intervention – MICCAI 2023. Greenspan H., Madabhushi A., Mousavi P., Salcudean S., Duncan J., Syeda-Mahmood T., Taylor R., editors. Springer Nature Switzerland); 2023. Twelve-Lead ECG Reconstruction from Single-Lead Signals Using Generative Adversarial Networks; pp. 184–194. [DOI] [Google Scholar]
- 39.Sarkar P., Etemad A. CardioGAN: Attentive Generative Adversarial Network with Dual Discriminators for Synthesis of ECG from PPG. Proc. AAAI Conf. Artif. Intell. 2021;35:488–496. doi: 10.1609/aaai.v35i1.16126. [DOI] [Google Scholar]
- 40.Matyschik M., Mauranen H., Bonizzi P., Karel J. 2020 Computing in Cardiology. IEEE; 2020. Feasibility of ECG Reconstruction From Minimal Lead Sets Using Convolutional Neural Networks; pp. 1–4. [DOI] [Google Scholar]
- 41.Ho J., Jain A., Abbeel P. Advances in Neural Information Processing Systems. Curran Associates, Inc.; 2020. Denoising Diffusion Probabilistic Models; pp. 6840–6851. [Google Scholar]
- 42.Nichol, A., Dhariwal, P., Ramesh, A., Shyam, P., Mishkin, P., McGrew, B., Sutskever, I., and Chen, M. (2021). GLIDE: Towards Photorealistic Image Generation and Editing with Text-Guided Diffusion Models.
- 43.Rombach R., Blattmann A., Lorenz D., Esser P., Ommer B. 2022 IEEE/CVF Conference on Computer Vision and Pattern Recognition (CVPR) IEEE; 2022. High-Resolution Image Synthesis with Latent Diffusion Models; pp. 10674–10685. [DOI] [Google Scholar]
- 44.Yi H., Hou L., Jin Y., Saeed N.A., Kandil A., Duan H. Time series diffusion method: A denoising diffusion probabilistic model for vibration signal generation. Mech. Syst. Signal Process. 2024;216 doi: 10.1016/j.ymssp.2024.111481. [DOI] [Google Scholar]
- 45.Nichol A.Q., Dhariwal P. Proceedings of the 38th International Conference on Machine Learning. PMLR; 2021. Improved Denoising Diffusion Probabilistic Models; pp. 8162–8171. [Google Scholar]
- 46.Tran D.T., Tran Q.N., Dang T.T.K., Tran D.H. Proceedings of the 2023 8th International Conference on Intelligent Information Technology ICIIT ’23. Association for Computing Machinery; 2023. A Novel Approach for Long ECG Synthesis Utilize Diffusion Probabilistic Model; pp. 251–258. [DOI] [Google Scholar]
- 47.Shome D., Sarkar P., Etemad A. Vol. 38. 2024. Region-Disentangled Diffusion Model for High-Fidelity PPG-to-ECG Translation; pp. 15009–15019. (Proceedings of the AAAI Conference on Artificial Intelligence). [DOI] [Google Scholar]
- 48.Ramesh A., Dhariwal P., Nichol A., Chu C., Chen M. Hierarchical Text-Conditional Image Generation with CLIP Latents. arXiv. 2022 Preprint at. [Google Scholar]
- 49.Johnson A.E.W., Bulgarelli L., Shen L., Gayles A., Shammout A., Horng S., Pollard T.J., Hao S., Moody B., Gow B., et al. MIMIC-IV, a freely accessible electronic health record dataset. Sci. Data. 2023;10:1. doi: 10.1038/s41597-022-01899-x. [DOI] [PMC free article] [PubMed] [Google Scholar]
- 50.Johnson A., Bulgarelli L., Pollard T., Horng S., Celi L.A., Mark R. MIMIC-IV. Version 2.2 (PhysioNet) [DOI]
- 51.Gow B., Pollard T., Nathanson L.A., Johnson A., Moody B., Fernandes C., Greenbaum N., Waks J.W., Eslami P., Carbonati T., et al. MIMIC-IV-ECG: Diagnostic Electrocardiogram Matched Subset. Version 1.0 (PhysioNet) [DOI]
- 52.Goldberger A.L., Amaral L.A., Glass L., Hausdorff J.M., Ivanov P.C., Mark R.G., Mietus J.E., Moody G.B., Peng C.K., Stanley H.E. PhysioBank, PhysioToolkit, and PhysioNet: components of a new research resource for complex physiologic signals. Circulation. 2000;101:E215–E220. doi: 10.1161/01.cir.101.23.e215. [DOI] [PubMed] [Google Scholar]
- 53.Wagner P., Strodthoff N., Bousseljot R.-D., Kreiseler D., Lunze F.I., Samek W., Schaeffter T. PTB-XL, a large publicly available electrocardiography dataset. Sci. Data. 2020;7:154. doi: 10.1038/s41597-020-0495-6. [DOI] [PMC free article] [PubMed] [Google Scholar]
- 54.Wagner, P., Strodthoff, N., Bousseljot, R.-D., Samek, W., and Schaeffter, T. PTB-XL, a large publicly available electrocardiography dataset. Version 1.0.1 (PhysioNet). 10.13026/X4TD-X982. [DOI] [PMC free article] [PubMed]
- 55.Liu F., Liu C., Zhao L., Zhang X., Wu X., Xu X., Liu Y., Ma C., Wei S., He Z., et al. An Open Access Database for Evaluating the Algorithms of Electrocardiogram Rhythm and Morphology Abnormality Detection. J. Med. Imaging Hlth. Inform. 2018;8:1368–1373. doi: 10.1166/jmihi.2018.2442. [DOI] [Google Scholar]
- 56.Li H., Ditzler G., Roveda J., Li A. DeScoD-ECG: Deep Score-Based Diffusion Model for ECG Baseline Wander and Noise Removal. IEEE J. Biomed. Health Inform. 2024;28:5081–5091. doi: 10.1109/JBHI.2023.3237712. [DOI] [PMC free article] [PubMed] [Google Scholar]
- 57.Strodthoff N., Wagner P., Schaeffter T., Samek W. Deep Learning for ECG Analysis: Benchmarks and Insights from PTB-XL. IEEE J. Biomed. Health Inform. 2021;25:1519–1528. doi: 10.1109/JBHI.2020.3022989. [DOI] [PubMed] [Google Scholar]
- 58.Cho K., van Merriënboer B., Gulcehre C., Bahdanau D., Bougares F., Schwenk H., Bengio Y. In: Proceedings of the 2014 Conference on Empirical Methods in Natural Language Processing (EMNLP) Moschitti A., Pang B., Daelemans W., editors. Association for Computational Linguistics; 2014. Learning Phrase Representations using RNN Encoder–Decoder for Statistical Machine Translation; pp. 1724–1734. [DOI] [Google Scholar]
- 59.He K., Zhang X., Ren S., Sun J. Deep Residual Learning for Image Recognition. 2016 IEEE Conference on Computer Vision and Pattern Recognition (CVPR) IEEE; 2016. Bag of Tricks for Image Classification with Convolutional Neural Networks; pp. 770–778. [DOI] [Google Scholar]
- 60.He T., Zhang Z., Zhang H., Zhang Z., Xie J., Li M. 2019 IEEE/CVF Conference on Computer Vision and Pattern Recognition (CVPR) IEEE; 2019. Bag of Tricks for Image Classification with Convolutional Neural Networks; pp. 558–567. [DOI] [Google Scholar]
- 61.Gu Y., Tinn R., Cheng H., Lucas M., Usuyama N., Liu X., Naumann T., Gao J., Poon H. Domain-Specific Language Model Pretraining for Biomedical Natural Language Processing. ACM Trans. Comput. Healthcare. 2021;3:1–23. doi: 10.1145/3458754. [DOI] [Google Scholar]
- 62.Bolton E., Venigalla A., Yasunaga M., Hall D., Xiong B., Lee T., Daneshjou R., Frankle J., Liang P., Carbin M., et al. BioMedLM: A 2.7B Parameter Language Model Trained On Biomedical Text. arXiv. 2024 doi: 10.48550/arXiv.2403.18421. Preprint at. [DOI] [Google Scholar]
Associated Data
This section collects any data citations, data availability statements, or supplementary materials included in this article.
Supplementary Materials
Data Availability Statement
-
•
All data presented within this study are available in key resources table.
-
•
All original code has been deposited at GitHub and is publicly available as of the date of publication (see key resources table).
-
•
Any additional information required to reanalyze the data reported in this work paper is available from the lead contact upon request.






