Electrocardiogram arrhythmia diagnosis method
The Bi-λ-Equal transfer learning mechanism with CNN-HPA model generates synthetic samples to address data imbalance and long-term dependency issues in ECG analysis, improving heart rhythm detection accuracy and adaptability.
Patent Information
- Application Number
- CN202510192960.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-02-21
- Publication Date
- 2025-07-15
AI Technical Summary
Existing heart rate irregularity detection methods in electrocardiogram (ECG) analysis face challenges due to input data length limitations, inability to capture long-term contextual dependencies, and imbalanced data sets, leading to suboptimal performance in real-world applications.
A Bi-λ-Equal transfer learning mechanism integrated with a convolutional pyramid attention mechanism (CNN-HPA) model is employed to generate synthetic abnormal samples, balance data distribution, and enhance feature extraction in ECG signals, using a residual conditional generative adversarial network (ResNet-cGAN) and pyramid attention to improve model adaptability and accuracy.
The proposed method effectively addresses data imbalance and enhances the model's ability to detect and predict heart rhythm abnormalities with improved accuracy and broader applicability across diverse populations and devices.
Smart Images

Figure CN120304842A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of medical diagnosis, and particularly relates to an electrocardiogram arrhythmia diagnosis method. Background Art
[0002] Cardiovascular diseases (CVDs) are the leading cause of death globally. Over the past three decades, the number of deaths caused by CVDs has increased significantly, rising from 12.1 million in 1990 to 20.5 million in 2021. With the changes in modern social lifestyles, the incidence trend of CVDs is gradually becoming younger. At the same time, the global aging process has also exacerbated the incidence of CVDs. Due to the complex pathogenesis and rapid progression of CVDs, early prevention and diagnosis are crucial. Currently, electrocardiogram (ECG) analysis remains the main means for CVD diagnosis, but its accuracy highly depends on doctors' experience and is easily affected by subjective factors.
[0003] In recent years, deep learning-based cardiovascular diagnostic assistance systems have made significant progress and become one of the core methods for automated ECG analysis. Convolutional neural networks (CNNs) and long short-term memory networks (LSTMs) have demonstrated significant advantages in capturing features in electrocardiogram time series data. To further improve the model's understanding of ECG signals, researchers have introduced the attention mechanism to enhance the model's attention to key information. However, existing methods generally have limitations in the length of input data, making it difficult to fully capture the context dependencies in long time series. At the same time, ECG datasets also generally have the problem of data imbalance, with the number of normal samples far exceeding that of abnormal samples, which limits the detection ability of deep learning-based ECG models in practical applications. Summary of the Invention
[0004] In view of this, the present invention proposes a convolutional pyramid attention mechanism (CNN-HPA) model integrated with a Bi-λ-Equal transfer learning mechanism for the automatic detection and early warning of electrocardiogram arrhythmias, so as to improve the generality and adaptability of the model among different populations and different devices.
[0005] To solve the above-mentioned at least one technical problem, the technical solution provided by the present invention is:
[0006] An electrocardiogram arrhythmia diagnosis method, comprising the following steps:
[0007] Step S1: Select samples from an electrocardiogram database for denoising. After beat segmentation, obtain the positions of R waves and perform standardization processing on the signal data;
[0008] Step S2: Based on existing samples, use a generator with a residual conditional generative adversarial network architecture to generate abnormal samples and incorporate them into the overall samples;
[0009] Step S3: Use a convolutional neural network combined with a pyramid attention mechanism to learn and identify abnormal samples from all samples, and train a convolutional pyramid attention mechanism model;
[0010] Step S4: Introduce a Bi-λ-Equal transfer learning mechanism module into the convolutional pyramid attention mechanism model, and continue to train with the original samples to obtain a new transfer learning model;
[0011] Step S5: Use the new transfer learning model for arrhythmia diagnosis.
[0012] The technical effects achieved by the present invention are:
[0013] 1. The present invention generates synthetic abnormal samples for training through a Residual Conditional Generative Adversarial Network (ResNet-cGAN) architecture, solving the imbalance problem that easily occurs in conventional ECG sample data.
[0014] 2. The present invention proposes a convolutional pyramid attention mechanism model for automatic detection and early warning of electrocardiogram arrhythmias, effectively balancing various types of beat data, significantly optimizing the performance of the classification model on imbalanced datasets, with both the accuracy (ACC) and F1-score of the model at a relatively high level, effectively improving the accuracy and scope of application of the electrocardiogram arrhythmia prediction method. Brief Description of the Drawings
[0015] In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the following will briefly introduce the drawings required for the embodiments. It should be understood that the following drawings only show some embodiments of the present invention, and therefore should not be regarded as limiting the scope. For those of ordinary skill in the art, other related drawings can be obtained based on these drawings without creative efforts.
[0016] Figure 1 Morphological comparison of the data generated by ResNet-cGAN and the real data in the present invention. Detailed Embodiments
[0017] The following will further elaborate on the present invention in detail in conjunction with the embodiments and the drawings.
[0018] To make the objectives, technical solutions, and advantages of the embodiments of the present invention clearer, the technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings in the embodiments of the present invention. Obviously, the described embodiments are some, but not all, of the embodiments of the present invention. All other embodiments obtained by those of ordinary skill in the art based on the embodiments of the present invention without creative efforts shall fall within the protection scope of the present invention. Therefore, the following detailed description of the embodiments of the present invention provided in the drawings is not intended to limit the scope of the claimed present invention, but merely represents the selected embodiments of the present invention.
[0019] An electrocardiogram arrhythmia diagnosis method includes the following steps:
[0020] Step S1: Select samples in the electrocardiogram database for denoising. After beat segmentation, obtain the R-wave positions and perform normalization processing on the signal data;
[0021] To improve the quality of ECG sample data, the present invention first uses a power frequency filter to denoise the signals of the ECG sample data, eliminate baseline drift and power frequency noise, so as to obtain a smooth basic signal. Subsequently, wavelet transform is used for denoising processing to retain effective information and reduce the interference of random noise, thereby improving the signal-to-noise ratio of the signal and enhancing the reliability of subsequent analysis.
[0022] In the arrhythmia detection experiment, accurately segmenting each cardiac beat is a key step. For this, the present invention adopts a method of fusing the PT algorithm with a smoothing function to accurately detect the R-wave positions. Based on the R-wave positions, symmetric and equal-length segments are intercepted before and after the signal to form two sub-segments, ensuring that the length of each segment is 360 sampling points. Cubic B-spline interpolation is used to integrate them into a complete electrocardiogram segment to complete the normalization processing of the ECG sample data.
[0023] Step S2: Based on the existing samples, use a generator with a residual conditional generative adversarial network architecture to generate abnormal samples and incorporate them into the overall samples;
[0024] In the ECG sample data, the number of normal samples is much larger than that of abnormal samples. This data imbalance problem will significantly affect the training performance of the model. Therefore, the present invention introduces a generator with a residual conditional generative adversarial network (cGAN) architecture. The generator extracts multi-level deep features through residual blocks and combines the idea of conditional generation. It accepts conditional labels and noise vectors as inputs to generate synthetic abnormal samples, thereby maintaining the number of abnormal samples at an appropriate level.
[0025] Among them, the input formula of the generator with a residual conditional generative adversarial network architecture is shown in Equation (1):
[0026] G(z, y) = G(z|y) (1)
[0027] In equation (1), z is the noise vector and y is the conditional label.
[0028] Meanwhile, the generator extracts and integrates the local and global features of the time-series data through multiple residual blocks, and the formula is shown in equation (2):
[0029] Gres(x) = x + f(x) (2)
[0030] In equation (2), Gres(x) is the output of the residual block, x is the feature input to the residual block, and f(x) is the residual function.
[0031] After the output of the generator passes through a one-dimensional convolution, the sequence length is adjusted by interpolation to meet the feature requirements of the ECG signal. The discriminator introduces gradient penalty (GP) to constrain the gradient of the discriminator, thereby ensuring the stability of the generation process. The loss function of the discriminator is shown in equation (5):
[0032]
[0033] In equation (5), L D is the loss function of the discriminator; E is the expected value; logD(x) is the logarithm of the predicted probability of the discriminator for the real data x; log(1 - D(G(z, y))) is the logarithm of the predicted probability of the discriminator for the generated data G(z, y); λ is the weight parameter; is the gradient penalty term, which is used to constrain the gradient of the discriminator; is the L2 norm of the gradient of the discriminator input data x; is the calculation method of the gradient penalty, which is used to punish the discriminator behavior that makes the gradient norm deviate from 1.
[0034] Step S3: Use a convolutional neural network combined with a pyramid attention mechanism to learn and identify abnormal samples from all samples, and train a convolutional pyramid attention mechanism model;
[0035] Traditional convolutional neural networks (CNNs) have limitations in capturing long-term dependence features, while the Hierarchical Pyramid Attention (HPA) mechanism can effectively model the local and global dependencies in time-series data by hierarchically focusing on the features of different time windows. In the present invention, the HPA structure is added to the CNN. Among them, the HPA structure is added to the CNN framework in the form of a computing module, and the added position is between the feature extraction and the fully connected layer of the CNN framework. The resulting model can enhance the model's representation ability for the ECG signal sequence, and the HPA module in it can summarize features layer by layer, thereby effectively capturing the local information and global dependencies in the signal.
[0036] The specific implementation steps of its training include:
[0037] (1) Write a convolutional neural network architecture, including a one-dimensional convolutional layer, a pooling layer, a batch normalization layer, and an activation function;
[0038] (2) Introduce a hierarchical attention mechanism into the CNN architecture to enhance the model's ability to capture key features in the ECG signal;
[0039] (3) Input ECG heart beats with arrhythmia labels for training, and use the built CNN_HPA model to detect arrhythmia in the original ECG signal;
[0040] (4) Generate specific results, use the detected arrhythmia beat categories of the ECG signal, compare the label verification accuracy, draw a confusion matrix and an ROC curve, and calculate the F1 score.
[0041] Among them, the multi-head attention mechanism of HPA can be expressed as:
[0042]
[0043] Among them, Q, K, and V are the query, key, and value matrices respectively, d k is the dimension of the key, and T represents the transpose operation on K. In the pyramid structure, each layer focuses on different time steps to adapt to the dependency relationships of different event scales. Suppose there are L layers in the pyramid, and the input of the l-th layer is denoted as X (l) , and its calculation method is shown in Equation (4):
[0044] X(l) = Attention(Q (l) , K (l) , V (l) ) (4)
[0045] Step S4: Introduce a Bi-λ-Equal transfer learning mechanism module into the convolutional pyramid attention mechanism model, and use the original samples to continue training to obtain a new transfer learning model.
[0046] To enhance the adaptability and generalization ability of the transfer learning model, based on the CNN-HPA model, the present invention also combines the Bi-λ-Equal transfer learning mechanism and proposes a multi-level and dynamically weighted learning framework. The Bi-λ-Equal transfer learning model can be specifically referred to in the relevant literature: the NeurIPS conference journal "Efficient Equivariant Transfer Learning from Pretrained Models" (Sourya Basu, etc.). By dynamically adjusting the feature weights in the time and space dimensions, during the training process, the parameters of the Bi-λ-Equal layer will be optimized through the backpropagation algorithm to learn the optimal weighting strategy and optimize the feature learning process, thereby improving the performance of the model in the target task.
[0047] In the Bi-λ-Equal mechanism, the CNN is responsible for weighting the features in the time dimension. Traditional convolutional neural networks use fixed weights to perform convolutional operations on input data, but in the Bi-λ-Equal mechanism, the features in the time dimension are dynamically weighted according to their importance in the target task. Assuming the input feature map is X, the convolutional kernel is W, and the bias is b, the weighted convolutional operation is shown in Equation (6):
[0048] Conv(X, W, b) = ∑ i λ i W i ·X + b (6)
[0049] In Equation (6), λ i is the dynamic weighting factor.
[0050] The HPA mechanism then performs weighting in the space dimension. By aggregating features layer by layer, each layer focuses on different time steps and gradually integrates local features with global information. The input feature X l After being weighted by HPA, Equation (7) is obtained:
[0051]
[0052] The Bi-λ-Equal mechanism combines time weighting (CNN) and space weighting (HPA), and adaptively adjusts the importance of features through the dynamic weighting factor, thereby optimizing the learning process.
[0053] Step S5: Use the new transfer learning model for arrhythmia diagnosis. Substitute the actual electrocardiogram samples into the new transfer learning model to perform arrhythmia diagnosis.
[0054] Effect evaluation
[0055] To verify the reliability of the generated data and consider the influence of factors such as the resting heart rate among patients, multiple beat data of the same type were randomly selected and input into ResNet-cGAN for training. Meanwhile, the generated samples were visualized. Figure 1 It shows the comparison between the synthetic data and the real data. The synthetic data and the real data present similar signal distributions visually, which proves the effectiveness of generating electrocardiogram beat samples through the ResNet-cGAN model.
[0056] In addition, to further verify the robustness of the generation results, the present invention also calculated four indicators, namely the percentage root-mean-square difference (PRD), Frechet distance (FD), root-mean-square error (RMSE), and mean absolute error (MAE), by comparing with multiple groups of different types of conventional benchmark models. The models respectively include Bidirectional Long Short-Term Memory Convolutional Neural Network Generative Adversarial Network (BILSTM_CNN GAN), Recurrent Neural Network Autoencoder Generative Adversarial Network (RNN-AE GAN), Long Short-Term Memory Autoencoder Generative Adversarial Network (LSTM-AE GAN), Recurrent Neural Network Variational Autoencoder Generative Adversarial Network (RNN-VAEGAN), Long Short-Term Memory Variational Autoencoder Generative Adversarial Network (LSTM-VAE GAN), Bidirectional Long Short-Term Memory Multilayer Perceptron Generative Adversarial Network (BILSTM_MLP GAN), Time Series Generative Adversarial Network (TimeGAN). The results are shown in Table 1. It can be seen from the results in Table 1 that this study achieved the optimal result in terms of MAE and performed well in FD, RMSE, and PRD, further verifying the feasibility of the model proposed in the present invention.
[0057] Table 1 Comparison Table of Model Metrics
[0058]
[0059] As mentioned above, it is only the preferred specific implementation manner of the present invention, but the protection scope of the present invention is not limited thereto. Any changes or substitutions that can be easily thought of by those skilled in the art within the technical scope disclosed in the embodiments of the present invention should be covered by the protection scope of the present invention. Therefore, the protection scope of the present invention should be subject to the protection scope of the claims.
Claims
1. An electrocardiogram arrhythmia diagnosis method, characterized in that, It includes the following steps: Step S1: Select samples from the electrocardiogram database for denoising. After beat segmentation, obtain the R-wave positions and perform normalization processing on the signal data; Step S2: Based on the existing samples, use a generator with a residual conditional generative adversarial network architecture to generate abnormal samples and incorporate them into the overall samples; Step S3: Use a convolutional neural network combined with a pyramid attention mechanism to learn and identify abnormal samples from the overall samples, and train to obtain a convolutional pyramid attention mechanism model; Step S4: Introduce a Bi-λ-Equal transfer learning mechanism module into the convolutional pyramid attention mechanism model, and continue to train with the original samples to obtain a new transfer learning model; Step S5: Use the new transfer learning model for arrhythmia diagnosis.
2. The electrocardiogram arrhythmia diagnosis method according to claim 1, characterized in that: The sample denoising method in Step S1 is power frequency filter and wavelet transform denoising.
3. The electrocardiogram arrhythmia diagnosis method according to claim 1, wherein: The method of the normalization processing in Step S1 is: Based on the R-wave positions, intercept equal-length segments symmetric before and after the signal to form two sub-segments, ensure that the length of each segment is 360 sampling points, and use cubic B-spline interpolation to integrate them into a complete electrocardiogram segment.
4. The electrocardiogram arrhythmia diagnosis method according to claim 1, characterized in that: The input formula of the generator with the residual conditional generative adversarial network architecture in Step S2 is shown in Equation (1): G(z, y) = G(z|y) (1) In Equation (1), z is the noise vector and y is the conditional label; At the same time, the generator extracts and integrates the local and global features of the time series data through multiple residual blocks, and the formula is shown in Equation (2): Gres(x) = x + f(x) (2) In Equation (2), Gres(x) is the output of the residual block, x is the feature input to the residual block, and f(x) is the residual function.
5. A method for diagnosing electrocardiogram arrhythmia according to claim 1, characterized in that: The multi-head attention mechanism in the pyramid attention mechanism in Step S3 is shown in Equation (3): In Equation (3), Q, K, and V are the query, key, and value matrices respectively, and d k is the dimension of the key, and T represents the transpose operation on K; The calculation of the pyramid input is shown in Equation (4): X(l) = Attention(O (l) , K (l) , V (l) ) (4) In Equation (4), l is the number of layers of the pyramid.
6. The electrocardiogram arrhythmia diagnosis method according to claim 1, wherein: The generation method of the convolutional neural network combined with the pyramid attention mechanism in Step S3 is: Load the pyramid attention mechanism module between the feature extraction and fully connected layers in the convolutional neural network model architecture.