Electrocardiosignal synthesis method based on WGAN and attention mechanism cooperation
Through the ECG signal synthesis method synthesized by WGAN and attention mechanism, high-quality synthetic signals are generated, which solves the problems of insufficient data and unbalanced categories in ECG signal analysis, and improves the accuracy and robustness of ECG signal classification, especially providing effective diagnostic support in resource-scarce areas.
Patent Information
- Application Number
- CN202510886410.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-06-30
- Publication Date
- 2025-08-19
AI Technical Summary
There are problems of insufficient data and uneven category distribution in existing ECG signal analysis, which leads to low accuracy and efficiency of arrhythmia diagnosis, especially in resource-scarce areas that are difficult to obtain timely and accurate diagnosis.
The ECG signal synthesis method based on WGAN and attention mechanism is adopted to generate synthetic signals of specified categories by constructing a conditional generation adversarial network. Combined with multiple feature expression methods, the model's ability to capture complex features of the ECG signal is enhanced, and a closed-loop model is formed through dynamic optimization generators and discriminators to generate high-quality synthetic signals to build a balanced data set.
It significantly improves the accuracy and robustness of ECG signal classification, improves the accuracy and efficiency of arrhythmia diagnosis, alleviates the impact of data imbalance, and provides preliminary diagnosis and recommendations in resource-scarce areas.
Smart Images

Figure CN120501434A_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the technical field of biological signal processing methods, and specifically relates to an electrocardiogram signal synthesis method based on the collaboration of WGAN and attention mechanism. Background Art
[0002] The electrocardiogram (ECG) is an important biomedical signal that detects the heart's electrical activity using electrodes. As the heart continuously beats, regular electrophysiological changes occur. The ECG can visualize these changes in real time and generate an ECG waveform. Through detailed analysis of ECG signals, doctors can obtain a wealth of critical information about the heart's condition. The ECG not only helps identify the regularity of the heart's rhythm and diagnose heart diseases such as arrhythmias and myocardial ischemia, but also comprehensively reflects the heart's overall health. Therefore, the ECG plays a crucial role in the early diagnosis of cardiovascular disease, the development of treatment plans, and disease monitoring.
[0003] Initially, ECG diagnosis relied primarily on the physician's clinical experience, a method characterized by low efficiency and subjectivity. Differences in experience and understanding between physicians can lead to varying interpretations of the same ECG, impacting the accuracy and reliability of the diagnosis. With the continuous advancement of science and technology, machine learning has been gradually introduced into ECG analysis, giving rise to automated ECG analysis methods. In this phase, experts design useful features, known as "expert features," based on the raw ECG and specialized knowledge. These features are then applied using decision rules or other machine learning models to generate the final results. However, this approach is limited by data quality and expert knowledge.
[0004] The emergence of deep learning technologies, particularly the introduction of architectures like convolutional neural networks (CNNs), has revolutionized the field of ECG signal analysis. Leveraging its powerful feature learning capabilities, CNNs are able to automatically learn higher-level, more abstract feature representations from complex ECG signals. Through layer-by-layer convolution and pooling operations, CNNs effectively extract key information from ECG signals, significantly improving understanding and analysis capabilities.
[0005] Despite this, the analysis and processing of ECG signals still face many challenges. First, ECG signals are highly sensitive, and the use of patient ECGs is strictly regulated, which makes it very difficult to obtain large amounts of high-quality data. Second, in the diagnosis of arrhythmias, samples of normal heart rhythms far outnumber samples of arrhythmias, resulting in an imbalanced distribution of categories. This may cause the algorithm to be more inclined to predict the larger number of normal heart rhythms and ignore the smaller number of arrhythmia categories. This bias not only causes the algorithm to perform poorly in identifying patients with arrhythmias, but may even result in missed diagnoses or misdiagnoses, which has a negative impact on the effectiveness of the algorithm and poses potential risks to patients in clinical applications.
[0006] Therefore, generating a large number of realistic ECG samples can help address the problem of insufficient medical data, thereby training a high-precision arrhythmia classification model. This model not only helps doctors detect arrhythmias early and take timely treatment measures, alleviate patient symptoms, and prevent potentially serious consequences, but also reduces misdiagnosis rates, improves diagnostic accuracy and efficiency, and effectively alleviates the workload of medical staff, enabling them to better handle more cases. Most importantly, in some resource-poor areas, where professional physicians are scarce and patients struggle to obtain timely and accurate diagnoses, such an automated arrhythmia classification model can provide patients with preliminary diagnoses and recommendations, helping to expand access to medical resources. Summary of the Invention
[0007] The purpose of this invention is to provide an ECG signal synthesis method based on the collaboration of WGAN and attention mechanism, which solves the problem of uneven distribution of existing ECG signal categories.
[0008] The technical solution adopted by the present invention is: an ECG signal synthesis method based on the collaboration of WGAN and attention mechanism, comprising the following steps: Step 1: Obtain a real ECG signal dataset of the target time series and complete preprocessing, divide the continuous signal into independent single-cycle signals, and count the distribution of each category of signals; Step 2: Using the category label as the conditional input, an improved conditional generative adversarial network is constructed using the single-cycle signal obtained in step 1. The generator of the conditional generative adversarial network generates a synthetic signal of the specified category. Step 3: Perform similarity evaluation on the synthetic signal generated in step 2 and the corresponding real signal to verify the authenticity and validity of the synthetic signal in terms of temporal and statistical characteristics, and screen out high-quality synthetic signals; Step 4: Mix the high-quality synthetic signal obtained in step 3 with the real signal, build a relatively balanced data set, and train and evaluate it on multiple classifiers to obtain the optimal mixing ratio of the synthetic signal and the real signal. Then, feed the optimal mixing ratio back to the discriminator of the conditional generative adversarial network in step 2. The discriminator guides the generator to optimize the quality of the synthetic signal.
[0009] The present invention is also characterized in that: Step 1 specifically includes the following steps: Step 1.1: Collect continuous time-series ECG signal data, perform noise reduction processing, and identify key feature points; Step 1.2: Divide the continuous signal into independent single-cycle signals based on the key feature points, and resample each signal to a uniform length; Step 1.3: Count and output the distribution of samples in each category to clarify the category structure and imbalance of the dataset.
[0010] The key feature points in step 1.1 include locating peaks and turning points.
[0011] Methods for resampling each signal to a uniform length in step 1.2 include Min-Max normalization or Z-score normalization.
[0012] Step 2 specifically includes the following steps: Step 2.1: Define the single-cycle signal obtained in step 1 as a signal containing C1, C2, ..., C n List of categories; Step 2.2: Traverse all signals and determine their category based on the corresponding labels. If the conditions are met, classify the corresponding signal into the category list defined in step 2.1 and assign the corresponding integer index to each category as the conditional label c; Step 2.3: Construct a conditional generative adversarial network with the objective function:
[0013] Step 2.4: The generator of the conditional generative adversarial network receives the class label c and the random noise z that follows the Gaussian distribution at the same time. The embedding layer fuses the two into an input vector. The input vector is mapped into the query, key, and value vectors through the fully connected layer. The attention score AttentionScores is calculated based on the dot product of the query and key:
[0014] Step 2.5: Introduce scaling factor Alleviate the impact of extreme values and calculate the ScaledAttention Scores:
[0015] Then the objective function of the improved conditional generative adversarial network is expressed as:
[0016] Where G attn Represents the generator that introduces scaled dot product attention, and the internal attention score is ScaledAttention Scores; Then, Softmax normalization is applied to the Scaled Attention Scores to obtain the attention weights, and finally the weighted summation of the values is performed based on the weights to generate the attention feature map x; Step 2.6: The attention module outputs the feature map x, which is gradually upsampled through the deconvolution layer; Step 2.7: Perform three nonlinear transformations on the feature map x to obtain the context vector F(x). Adjust the number of channels of F(x) to be consistent with the feature map x. Step 2.8: Add the context vector F(x) to the input feature map x through the residual connection to obtain the intermediate feature F(x)+x; Step 2.9: Normalize the intermediate feature F(x)+x to gradually generate a high-resolution synthetic signal X. fake .
[0017] Step 3 specifically includes the following steps: for each composite signal X i fake , randomly select a real signal X from the set of real signals of the same category i1 real, X i2 real, ...,X i3 real , respectively calculate the real signal X i1 real, X i2 real, ...,X i3 real With the synthetic signal X i fake The DTW distance and Frechet distance between them are calculated and the corresponding average values are calculated. and ; Different categories of thresholds are set according to different application scenarios. If a single synthetic signal X i fake Satisfy at the same time and , τ is the threshold determined by the real signal statistics, then the synthetic signal X ifake Similar to the real signal, keep the synthetic signal X i fake As a high-quality synthetic signal.
[0018] Step 4 is as follows: the high-quality synthetic signal X obtained in step 3 is converted into fake The synthesized signal is mixed with the real signal dataset in proportion to form a relatively balanced dataset, and then input into multiple classifiers for training and evaluation. By comparing the classification effects before and after balancing, the mixing ratio of the synthesized signal and the real signal is dynamically adjusted according to the evaluation results to obtain the optimal mixing ratio of the synthesized signal and the real signal. The optimal mixing ratio is then fed back to the discriminator of the conditional generative adversarial network in step 2. The discriminator guides the generator to optimize the quality of the synthesized signal to form a closed-loop ECG signal synthesis model.
[0019] The evaluation metric is the F1 score.
[0020] The beneficial effects of the present invention are as follows: the present invention is based on the ECG signal synthesis method that collaborates with WGAN and the attention mechanism, generates high-quality synthetic samples by introducing a conditional generative adversarial network, and alleviates the impact of data imbalance; and integrates multiple feature expression methods to enhance the model's ability to capture the complex features of ECG signals, thereby significantly improving the classification performance, improving the accuracy and robustness of ECG signal classification, and dynamically optimizing the synthesis model through classification performance feedback. BRIEF DESCRIPTION OF THE DRAWINGS
[0021] Figure 1 This is a flowchart of the ECG signal synthesis method based on the collaboration of WGAN and attention mechanism in the present invention; Figure 2 This is a schematic diagram of the structure of the generative adversarial network in the ECG signal synthesis method based on the collaboration of WGAN and attention mechanism in the present invention; Figure 3 This is a schematic diagram of the skip-layer connection used in the generative adversarial network in the ECG signal synthesis method based on the collaboration of WGAN and attention mechanism in the present invention; Figures 4(a) to 4(c) are two-dimensional representations of single heartbeat samples synthesized in the early and late stages of model training, as well as the five types of electrocardiogram (ECG) signal samples of N, L, R, / , and A to be ultimately obtained. Figures 5(a) to 5(b) show the DTW and Frechet quantitative index performances of the five types of ECG signal samples (N, L, R, / , A) synthesized by the present invention; Figure 6 This is a schematic diagram of data partitioning in the present invention using synthetic samples to balance a real unbalanced data set; FIG7 (a) and FIG7 (b) are schematic diagrams of the classification confusion matrix of the ECG signal before and after the application of the synthetic data of the present invention. DETAILED DESCRIPTION
[0022] The present invention will be described in detail below with reference to the accompanying drawings and specific embodiments.
[0023] Example 1 The present invention provides an ECG signal synthesis method based on the collaboration of WGAN and attention mechanism, comprising the following steps: Step 1: Obtain a real ECG signal dataset of the target time series and complete preprocessing, divide the continuous signal into independent single-cycle signals, and count the distribution of each category of signals; Step 2: Using the category label as the conditional input, an improved conditional generative adversarial network is constructed using the single-cycle signal obtained in step 1. The generator of the conditional generative adversarial network generates a synthetic signal of the specified category. Step 3: Perform similarity evaluation on the synthetic signal generated in step 2 and the corresponding real signal to verify the authenticity and validity of the synthetic signal in terms of temporal and statistical characteristics, and screen out high-quality synthetic signals; Step 4: Mix the high-quality synthetic signal obtained in step 3 with the real signal, build a relatively balanced data set, and train and evaluate it on multiple classifiers to obtain the optimal mixing ratio of the synthetic signal and the real signal. Then, feed the optimal mixing ratio back to the discriminator of the conditional generative adversarial network in step 2. The discriminator guides the generator to optimize the quality of the synthetic signal.
[0024] Example 2 The present invention provides an ECG signal synthesis method based on the collaboration of WGAN and attention mechanism. Based on Example 1, step 1 is preferably the following steps: Step 1.1: Collect continuous time-series ECG signal data and perform noise reduction processing to identify key feature points, including locating peaks and turning points; Step 1.2: Divide the continuous signal into independent single-cycle signals based on the key feature points, and resample each signal to a uniform length using methods such as Min-Max normalization or Z-score normalization. Step 1.3: Count and output the distribution of samples in each category to clarify the category structure and imbalance of the dataset.
[0025] Example 3 The present invention provides an ECG signal synthesis method based on the collaboration of WGAN and attention mechanism. Based on Example 1, step 2 is preferably the following steps: Step 2.1: Define the single-cycle signal obtained in step 1 as a signal containing C1, C2, ..., C n List of categories; Step 2.2: Traverse all signals and determine their category based on the corresponding labels. If the conditions are met, classify the corresponding signal into the category list defined in step 2.1 and assign the corresponding integer index to each category as the conditional label c; Step 2.3: Construct a conditional generative adversarial network with the objective function:
[0026] Step 2.4: The generator of the conditional generative adversarial network receives the class label c and the random noise z that follows the Gaussian distribution at the same time. The embedding layer fuses the two into an input vector. The input vector is mapped into the query, key, and value vectors through the fully connected layer. The attention score AttentionScores is calculated based on the dot product of the query and key:
[0027] Step 2.5: Introduce scaling factor Alleviate the impact of extreme values and calculate the ScaledAttention Scores:
[0028] Then the objective function of the improved conditional generative adversarial network is expressed as:
[0029] Where G attn Represents the generator that introduces scaled dot product attention, and the internal attention score is ScaledAttention Scores; Then, Softmax normalization is applied to the Scaled Attention Scores to obtain the attention weights, and finally the values are weighted summed based on the weights to generate the attention feature map x; Step 2.6: The attention module outputs the feature map x, which is gradually upsampled through the deconvolution layer; Step 2.7: Perform three nonlinear transformations on the feature map x to obtain the context vector F(x). Adjust the number of channels of F(x) to be consistent with the feature map x. Step 2.8: Add the context vector F(x) to the input feature map x through the residual connection to obtain the intermediate feature F(x)+x; Step 2.9: Normalize the intermediate feature F(x)+x to gradually generate a high-resolution synthetic signal X. fake .
[0030] Example 4 The present invention provides an ECG signal synthesis method based on the collaboration of WGAN and attention mechanism. Based on Example 1, step 3 is preferably: For each composite signal X i fake , randomly select a real signal X from the set of real signals of the same category i1 real, X i2 real, ...,X i3 real , respectively calculate the real signal X i1 real, X i2 real, ...,X i3 real With the synthetic signal X i fake The DTW distance and Frechet distance between them are calculated and the corresponding average values are calculated. and ; Different categories of thresholds are set according to different application scenarios. If a single synthetic signal X i fake Satisfy at the same time and , τ is the threshold determined by the real signal statistics, then the synthetic signal X i fake Similar to the real signal, keep the synthetic signal X i fake As a high-quality synthetic signal.
[0031] Example 5 The present invention provides an ECG signal synthesis method based on the collaboration of WGAN and attention mechanism. Based on Example 1, step 4 is preferably: The high-quality synthetic signal X obtained in step 3 fake The synthesized signal is mixed with the real signal data set in proportion to form a relatively balanced data set, and is input into multiple classifiers for training and evaluation. The evaluation indicators can be F1 scores, etc. By comparing the classification effects before and after balancing, the mixing ratio of the synthetic signal and the real signal is dynamically adjusted according to the evaluation results to obtain the optimal mixing ratio of the synthetic signal and the real signal. The optimal mixing ratio is then fed back to the discriminator of the conditional generative adversarial network in step 2. The discriminator guides the generator to optimize the quality of the synthetic signal to form a closed-loop ECG signal synthesis model.
[0032] Example 6 The present invention provides an ECG signal synthesis method based on the collaboration of WGAN and attention mechanism, such as Figure 1As shown in Figure 1, we first introduce the Wasserstein distance based on the generative adversarial network and combine it with the gradient penalty mechanism. At the same time, we use the attention mechanism to enhance the ability to capture contextual information and efficiently aggregate contextual information through the scaled dot product operation. The model structure is as follows: Figure 2 In the process of model construction, circular convolution, feature extraction and skip layer connection are applied to the synthesis task of ECG signal, where the schematic diagram of skip layer connection is shown in Figure 3 As shown in the figure, the similarity between the synthesized beats and real heartbeats is quantitatively analyzed. Frechet and DTW methods are used to quantitatively evaluate the similarity between samples based on overall shape similarity and local similarity, respectively, to accurately measure the similarity between samples. Finally, 10,000 synthetic samples are generated for each target category (N, L, R, / , A).
[0033] Table 1 Heartbeat categories
[0034] A control group was set up to train the classifier using the original real dataset. Meanwhile, the experimental group mixed the original real dataset with the generated synthetic dataset to form a relatively balanced dataset, and trained the classifier based on this mixed dataset. The classification performance was evaluated on the same test set, and the improvement effect of synthetic data on classification performance was verified through comparative analysis. Figure 1 As shown, please follow the steps below: Step 1: Preprocess the ECG signal to reduce the impact of baseline drift, myoelectric interference, and power frequency noise, locate the QRS wave, use the annotation file provided by the MIT-BIH arrhythmia dataset, accurately locate the R wave peak in the ECG signal, and segment the continuous ECG signal into independent single ECG signals.
[0035] Step 2: Build a conditional generative adversarial network to generate specific types of ECG signals, such as normal heart rhythm, left and right bundle branch block, etc. The details are as follows: Step 2.1: By introducing the category labels in the dataset as conditional information for the generative adversarial network generator, ECG signals of specific categories, such as normal heart rhythm and left or right bundle branch block, are generated, effectively improving the diversity and specificity of the generated signals. To more effectively capture the time series characteristics of the signal, an attention mechanism is introduced into the generator, making the generated signal more realistic both visually and statistically, thereby better modeling the dependencies between different parts of the sequence. This design helps the network focus more on those parts that significantly affect the signal quality and characteristics during the generation process. In terms of the representation method of the attention score, scaled dot product attention is adopted. The similarity between the query and key is represented by calculating the dot product between them, and dynamic weights are applied to different keys to achieve selective attention to the value. In this process, larger vectors may lead to amplification of the results, while smaller vectors may lead to a reduction of the results. Therefore, a scaling factor is introduced to mitigate this effect and ensure a more stable calculation result. Specifically, the attention score is calculated as follows: First, we calculate the dot product similarity between the query and the key to get a preliminary attention score. Secondly, in order to avoid the deviation caused by the different sizes of vectors during the calculation process, we introduce a scaling factor to optimize the attention score:
[0036]
[0037] This approach effectively aggregates contextual information, helping neural networks extract key features. By directly optimizing sample quality during the generation phase without performing threshold screening, it avoids the risks associated with manually setting thresholds, such as incorrectly excluding valid samples or mistakenly accepting unqualified ones. This approach not only reduces subsequent screening steps but also significantly minimizes the impact of human intervention, making the sample generation process more automated and reliable.
[0038] The application of the scaled dot product attention mechanism makes the distribution of attention weights smoother, thereby helping the model to focus more accurately on time steps related to the target signal. This feature is particularly important for ECG signal synthesis because ECG signals have significant time dependence. The introduction of the scaling mechanism can effectively highlight features closely related to signal synthesis, while ensuring the stability and reasonable range of attention distribution, suppressing the influence of noise and irrelevant features, thereby generating higher quality and more accurate ECG synthesis signals, and making the model's performance more stable and controllable under different conditions. In terms of multi-view feature extraction, 4-head attention is used to extract features from 4 different subspaces to enhance the model's understanding of ECG signals, focusing on multiple information sources in parallel, and effectively capturing the rich features of ECG signals.
[0039] Step 2.2: A skip connection mechanism is introduced into the synthesis task, aiming to achieve better feature representation and generation. Specifically, the model consists of two one-dimensional convolutional layers, which map the feature dimensions of the input time series data to the number of channels used to generate the query and key in the attention mechanism. The first convolutional layer extracts low-level features from the input data, while the second further enhances the feature representation. The third convolutional layer then converts the context vector back to the number of channels of the original input. Furthermore, the model uses three batch normalization layers, one for each convolutional layer, to help stabilize the output and accelerate convergence during training. When calculating the attention weights, the model first scales the dot product by dividing it by the square root of the key dimension and then applies a softmax to the attention weights. After the context vector is processed by the third convolutional layer, its number of channels is converted back to its original number, and the convolution output is added to the original input x to form a skip connection. This method can effectively retain the original input information, ensuring that key information is not lost during the information transmission process. It can also help alleviate the gradient vanishing problem of deep networks, enabling the network to better propagate gradients during training. Figures 4 (a) to 4 (c) respectively show the early stage of model training, the late stage of model training, and the final five types of synthetic samples.
[0040] Step 3: Using the synthesized heartbeat obtained in step 2, randomly select the corresponding template heartbeat and quantitatively evaluate the similarity between the generated beat and the real heartbeat from the perspective of local alignment of time series and global similarity of curve shape. The details are as follows: To evaluate the quality of generated ECG signals, dynamic time warping (DTW) and Frechet distance are used as quantitative evaluation metrics for each type of synthetic sample. These metrics provide complementary evaluation capabilities from the perspectives of local alignment of time series and global similarity of curve shapes.
[0041] Let the real signal be , the synthetic signal is , if C(i,j) represents the minimum cumulative distance from (1,1) to (i,j), its cumulative matrix C is:
[0042] The alignment path P = (p1, p2, ..., pK) is a set of path points from (1, 1) to (n, m), which must be monotonically increasing over time and must be continuous without skipping any points. The DTW distance is defined as the minimum cumulative distance:
[0043] The Frechet distance focuses on measuring the similarity between two curves. Using the dynamic programming algorithm to calculate the minimum matching distance between X and Y, the mathematical definition can be simplified to:
[0044] The comparison between DTW and Frechet is as follows: Table 2 Comparison between DTW and Frechet
[0045] Based on a WGAN-based ECG signal synthesis method with an attention mechanism, the similarity between the synthesized heartbeats of five categories and their corresponding templates is quantitatively evaluated using average dynamic time warping (DTW) and Frechet distance. Heartbeats are synthesized using the MIT-BIH dataset, and templates of corresponding categories are randomly selected from the dataset for comparison using DTW and Frechet distances. The MIT-BIH dataset contains data from 47 test individuals, including 25 men (aged 32 to 89) and 22 women (aged 23 to 89), with a total of 48 30-minute two-channel Holter recordings. The relevant experimental data are listed in Tables 2 and 3, respectively. The corresponding bar charts are visualized in Figures 5(a) and 5(b). Smaller DTW and Frechet distance values indicate a higher similarity between the synthesized signal and the true template signal, indicating a better matching effect.
[0046] Table 3 DTW distance between synthetic signal and template signal
[0047] Table 4 Frechet distance between synthetic signal and template signal
[0048] Step 4: Re-divide the data set, the division strategy is as follows Figure 6 As shown in the figure, we designed experiments to build HeartNet, CNN, and ResNet50 classifiers to verify the effect of data augmentation on ECG signal category balance. The specific steps include: Step 4.1: The control group extracts real samples of each category from the original dataset and trains the benchmark classifier.
[0049] Step 4.2: The experimental group is formed by mixing the original dataset used in step 4.1 with the generated synthetic samples (X fake ), to build a relatively balanced training dataset. During the balancing process, methods such as oversampling the minority class or adjusting the number of class samples to an intermediate level can be used.
[0050] Step 4.3: Output the quantity distribution of each category to reflect the data balance.
[0051] Step 4.4: Calculate the five performance metrics: precision, recall, F1 score, macro-average, and weighted average on the same test set. The F1 score is selected as the core evaluation metric. This metric balances precision and recall through a harmonic average, comprehensively reflecting the model's classification performance. Analyze how the mixed dataset improves classification performance for each category, especially for minority class samples, focusing on the transformation of the F1 score.
[0052] Step 4.5: When the number of samples in certain classes differs significantly, simply increasing the number of samples for all classes to match the number of samples for the majority class may result in a decrease in metrics such as recall for the minority class. Therefore, avoid over-expansion. Adjust the mix of real and synthetic samples to increase the number of minority class samples to a moderate level. Experimental observations show that appropriately increasing the number of minority class samples significantly improves recall. The optimal sample expansion strategy is determined based on the magnitude of the improvement in the F1 metric.
[0053] Step 4.6: This synthesis method effectively alleviates the class imbalance problem in ECG signals. By properly adjusting the mixing ratio of real and synthesized signals, the number of Class A samples was increased to 4,000, and the number of Class R and / samples was increased to 7,500, significantly improving minority class performance. The recall rate of Class A on ResNet50 increased from 72.73% to 85.96%, ultimately confirming this optimal sample synthesis method. The improved recall rate of Class A on the ResNet50 classifier (72.73% → 85.96%) was fed back to the generator to increase the weight of Class A noise samples.
[0054] The performance comparisons of different classifiers before and after data augmentation are as follows: Table 4 shows the experimental results for the HeartNet classifier, Table 5 shows the performance comparisons for the CNN classifier, and Table 6 summarizes the performance changes for the ResNet50 classifier. These comparative data intuitively demonstrate the differences in the impact of data augmentation strategies on the classification performance of each model, providing a key reference for subsequent model optimization and algorithm improvement.
[0055] Table 5 Comparison of classification results on HeartNet classifier before and after data enhancement
[0056] Table 6 Comparison of classification effects on CNN before and after data enhancement
[0057] Table 7 Comparison of classification effects on ResNet50 before and after data enhancement
[0058] Overall, after data augmentation, the model achieved significant improvements in key metrics such as precision, recall, and F1 score, with even better performance on ResNet50. The corresponding confusion matrices are shown in Figures 7(a) and 7(b). The improvement was particularly significant for category A, which exhibits significant imbalance. These results fully demonstrate the effectiveness and potential of this method in handling imbalanced datasets.
[0059] Through the above-mentioned approach, the present invention not only achieves an overall expansion of the total sample size by generating realistic sample signals, but also can divide the data set in combination with synthetic signals to achieve a relatively balanced state. This method is particularly targeted at the shortage of minority arrhythmia samples in the data set and can improve the model's classification ability for these minority classes. To evaluate the effectiveness of synthetic samples on minority arrhythmia samples in the original data set, experiments were conducted using three different classifiers: HeartNet, convolutional neural network (CNN), and one-dimensional ResNet50. The results showed that after data augmentation processing, the model achieved significant improvements in key indicators such as precision, recall rate, and F1 score. The improvement was particularly significant for categories with more obvious imbalanced features.
Claims
1. An ECG signal synthesis method based on WGAN and attention mechanism is characterized by: include: Step 1: Obtain a real ECG signal dataset of the target time series and divide the continuous signal into independent single-cycle signals; Step 2: Using the category label as the conditional input, an improved conditional generative adversarial network is constructed using the single-cycle signal, whose generator generates a synthetic signal of the specified category; Step 3: perform similarity evaluation on the generated synthetic signal and the corresponding real signal to obtain a high-quality synthetic signal; Step 4: Mix the high-quality synthetic signal with the real signal to construct a relatively balanced data set. The classifier is used to evaluate the optimal mixing ratio of the synthetic and real signals, and the optimal mixing ratio is fed back to the discriminator. The discriminator guides the generator to optimize the quality of the synthetic signal.
2. The ECG signal synthesis method based on WGAN and attention mechanism collaboration as claimed in claim 1, characterized in that: The step 1 specifically includes the following steps: Step 1.1: Collect continuous time-series ECG signal data, perform noise reduction processing, and identify key feature points; Step 1.2: Divide the continuous signal into independent single-cycle signals based on the key feature points, and resample each signal to a uniform length; Step 1.3: Count and output the distribution of samples in each category to clarify the category structure and imbalance of the dataset.
3. The ECG signal synthesis method based on WGAN and attention mechanism collaboration as claimed in claim 2, characterized in that: The key feature points in step 1.1 include positioning peaks and turning points.
4. The ECG signal synthesis method based on WGAN and attention mechanism collaboration as claimed in claim 2, characterized in that: The method of resampling each signal to a uniform length in step 1.2 includes Min-Max normalization or Z-score normalization.
5. The ECG signal synthesis method based on WGAN and attention mechanism collaboration as claimed in claim 1, characterized in that: The step 2 specifically includes the following steps: Step 2.1: Define the single-cycle signal obtained in step 1 as a signal containing C1, C2, ..., C n List of categories; Step 2.2: Traverse all signals and determine their category based on the corresponding labels. If the conditions are met, classify the corresponding signal into the category list defined in step 2.1 and assign the corresponding integer index to each category as the conditional label c; Step 2.3: Construct a conditional generative adversarial network with the objective function: Step 2.4: The generator of the conditional generative adversarial network receives the class label c and the random noise z that follows the Gaussian distribution at the same time. The embedding layer fuses the two into an input vector. The input vector is mapped into the query, key, and value vectors through the fully connected layer. The attention score AttentionScores is calculated based on the dot product of the query and key: Step 2.5: Introduce scaling factor Alleviate the impact of extreme values and calculate the Scaled AttentionScores: Then the objective function of the improved conditional generative adversarial network is expressed as: Where G attn Represents the generator that introduces scaled dot product attention, and the internal attention score is Scaled AttentionScores; Then, Softmax normalization is applied to the Scaled Attention Scores to obtain the attention weights, and finally the weighted summation of the values is performed based on the weights to generate the attention feature map x; Step 2.6: The attention module outputs the feature map x, which is gradually upsampled through the deconvolution layer; Step 2.7: Perform three nonlinear transformations on the feature map x to obtain the context vector F(x). Adjust the number of channels of F(x) to be consistent with the feature map x. Step 2.8: Add the context vector F(x) to the input feature map x through the residual connection to obtain the intermediate feature F(x)+x; Step 2.9: Normalize the intermediate feature F(x)+x to gradually generate a high-resolution synthetic signal X. fake .
6. The ECG signal synthesis method based on WGAN and attention mechanism collaboration as claimed in claim 5, characterized in that: The step 3 specifically includes the following steps: for each composite signal X i fake , randomly select a real signal X from the set of real signals of the same category i1 real, X i2 real, ...,X i3 real , respectively calculate the real signal X i1 real, X i2 real, ...,X i3 real With the synthetic signal X i fake The DTW distance and Frechet distance between them are calculated and the corresponding average values are calculated. and ; Different categories of thresholds are set according to different application scenarios. If a single synthetic signal X i fake Satisfy at the same time and , τ is the threshold determined by the real signal statistics, then the synthetic signal X i fake Similar to the real signal, keep the synthetic signal X i fake As a high-quality synthetic signal.
7. The ECG signal synthesis method based on WGAN and attention mechanism collaboration as claimed in claim 6, characterized in that: The step 4 is specifically as follows: the high-quality synthetic signal X obtained in step 3 is converted into fake The synthesized signal is mixed with the real signal dataset in proportion to form a relatively balanced dataset, and then input into multiple classifiers for training and evaluation. By comparing the classification effects before and after balancing, the mixing ratio of the synthesized signal and the real signal is dynamically adjusted according to the evaluation results to obtain the optimal mixing ratio of the synthesized signal and the real signal. The optimal mixing ratio is then fed back to the discriminator of the conditional generative adversarial network in step 2. The discriminator guides the generator to optimize the quality of the synthesized signal to form a closed-loop ECG signal synthesis model.
8. The ECG signal synthesis method based on WGAN and attention mechanism collaboration as claimed in claim 7, characterized in that: The evaluation metric is the F1 score.