Arrhythmia detection method fusing improved CBAM attention mechanism
By integrating the improved CBAM attention mechanism, constructing CNN and BiLSTM modules, and enhancing the local and temporal feature expression of ECG signals, the misdiagnosis and missed diagnosis problems of existing arrhythmia detection methods are solved, and high-precision arrhythmia detection is achieved.
Patent Information
- Application Number
- CN202510676780.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-05-26
- Publication Date
- 2025-09-05
AI Technical Summary
Existing arrhythmia detection methods rely on manual feature extraction and are easily affected by subjective factors, leading to misdiagnosis and missed diagnosis. They also have limited long-term time series dependence in ECG signals and lack sensitivity to subtle features.
The improved CBAM attention mechanism is adopted to construct CNN module, BiLSTM module and classification module. The local and temporal features of the ECG signal are weightedly fused through the CBAM module to enhance the feature expression ability. The cross entropy loss function and Adam optimizer are used for model training.
The accuracy of arrhythmia detection and the feature expression ability of the model were significantly improved, and the detection precision was improved to 99.4%, which is an increase of 3.4%, 1.4% and 1.6% respectively compared with traditional methods.
Smart Images

Figure CN120597129A_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the technical field of medical diagnosis of heart disease, and in particular relates to a method for detecting arrhythmia by integrating an improved CBAM attention mechanism. Background Art
[0002] With the aging of the population and the increasing changes in lifestyle, the incidence of arrhythmia, a common and complex cardiovascular disease, has been increasing year by year, posing a serious threat to human health and life safety. As an important precursor to cardiovascular disease, timely and accurate detection and classification of arrhythmia are crucial for preventing cardiovascular events. They not only provide an important basis for subsequent precision treatment, but also effectively reduce the risk of serious cardiovascular events in patients. Traditional arrhythmia detection methods rely too much on manual feature extraction and are easily affected by subjective factors when processing large amounts of complex electrocardiogram data, resulting in frequent misdiagnosis and missed diagnoses.
[0003] In recent years, the application of artificial intelligence technology in medical diagnosis has gradually increased, and the emergence of deep learning technology has provided new solutions for ECG signal analysis. Chinese Patent Publication No. CN115024706A discloses a contactless heart rate measurement method that integrates ConvLSTM and CBAM attention mechanisms. This method uses facial videos to extract regions of interest and corresponding physiological signal labels to construct a dataset. The network model constructed integrates ConvLSTM and CBAM attention mechanisms and consists of a first convolutional layer, a first ConvLSTM layer, a cascade of N convolutional blocks incorporating the CBAM attention mechanism, a second ConvLSTM layer, a fully connected layer, and a dropout layer. This model is used to predict rPPG, which is then measured through filtering and power spectral density calculation. However, the skin color changes recorded by this method are very subtle and easily affected by noise such as ambient fiber optic variations and the subject's head movement. Furthermore, the network model, which uses multiple CBAM convolutional blocks sandwiched between two ConvLSTM layers, has limited medium- and long-term temporal dependencies in ECG signals, resulting in a lack of sensitivity to subtle features in heart rate anomalies.
[0004] In view of this, how to combine advanced feature extraction technology and deep learning models to obtain a heart rhythm detection method with stronger anti-interference ability, higher detection accuracy and lighter weight is a technical problem that needs to be solved urgently, which can provide more effective technical support for early warning and intervention of cardiovascular diseases. Summary of the Invention
[0005] In view of the shortcomings of the existing technology, the technical problem to be solved by the present invention is to provide a heart rhythm disorder detection method integrating an improved CBAM attention mechanism, aiming to improve the accuracy of arrhythmia detection and the feature expression ability of the model.
[0006] The present invention solves the technical problem by adopting the following technical solutions:
[0007] A method for detecting arrhythmia by integrating an improved CBAM attention mechanism, the method comprising the following steps:
[0008] Step 1, data preprocessing: Collect ECG signals from the ECG dataset, segment the ECG signals, and label different types of arrhythmia. All ECG signal segments and corresponding labels constitute the ECG signal dataset;
[0009] Step 2: Build a fusion arrhythmia detection model:
[0010] The fusion arrhythmia detection model includes a CNN module, a BiLSTM module, a CBAM module and a classification module. The ECG signal segments are respectively input into a local branch composed of a CNN module and a CBAM module connected in series, and a time series branch composed of a BiLSTM module and a CBAM module connected in series. The results of the two branches are weightedly fused in the channel dimension and then classified by the classification module to obtain a classification result.
[0011] Step 3: Model training:
[0012] Using the electrocardiogram signal dataset to train the fused arrhythmia detection model to obtain a trained fused arrhythmia detection model;
[0013] Step 4: Input the ECG signal data to be tested into the trained fusion arrhythmia detection model to automatically identify the specific category to which the ECG signal belongs.
[0014] Furthermore, in step 1, the process of segmenting the ECG signal is: using a sliding window strategy to segment the ECG signal, with the window length set to 1800 sampling points and an overlap rate of 50%.
[0015] Furthermore, the CNN module includes three convolutional layers and three pooling layers. The number of convolution kernels increases layer by layer, namely 64, 128, and 256, respectively. The convolution layer uses the ReLu activation function. The pooling kernel size of the three pooling layers is 2, and the stride is 2. The bidirectional output dimension of the BiLSTM module is 128.
[0016] The classification module consists of two layers of fully connected neural networks; the first layer maps 384 dimensions to 128 dimensions and uses ReLU activation, and the second layer outputs the probability prediction results of the target classification number dimension.
[0017] Furthermore, the CBAM module includes a channel attention module and a spatial attention module. In the channel attention module, the input feature map F is subjected to maximum pooling and global average pooling to obtain the convolution feature F.max and F avg , after splicing, it is normalized through a shared fully connected layer and a sigmoid activation function to obtain the channel attention weight A c ; The expression of the channel attention module is:
[0018] A c (F)=σ(W c ·[F avg ,F max ])
[0019] Among them, σ is the sigmoid activation function, W c is the weight of the shared fully connected layer; [...] represents the concatenation of two features;
[0020] In the spatial attention module, the input feature map F undergoes global maximum pooling and mean pooling operations to obtain the feature map F max and F avg The two feature maps are channel-joined, and a 7×7 convolution operation and a sigmoid activation function are performed to obtain the spatial attention weight A. s , whose expression is:
[0021] A s (F)=σ(W s ·[F avg ,F max ])
[0022] Among them, W s Represents a convolution operation, and the size of the convolution kernel is 7×7.
[0023] Furthermore, the model training process was optimized using the cross entropy loss function, using the Adam optimizer, with the initial learning rate set to 0.001, the batch size to 32, and the number of training rounds to 50.
[0024] Furthermore, the method performs arrhythmia detection with an accuracy of over 99%, a recall rate of over 68%, an accuracy of over 70%, and an F1-score of over 69%.
[0025] Compared with the prior art, the present invention has the following beneficial effects:
[0026] 1. The present invention integrates an improved CBAM attention mechanism into the arrhythmia detection method, integrating the CBAM module into the CNN module and the BiLSTM module respectively, constructing a dual-channel feature weighted structure, enhancing the local feature and temporal feature expression of the ECG signal, and effectively improving the model's ability to recognize the key features of arrhythmia, thereby improving the accuracy of arrhythmia detection.
[0027] 2. The proposed method achieved an accuracy of 99.4% on the MIT-BIH arrhythmia dataset, representing improvements of 3.4%, 1.4%, and 1.6%, respectively, compared to the traditional SVM method (96.0%), a single LSTM model (98.0%), and a CNN-BiLSTM model without CBAM integration (97.8%). It also achieved significant improvements in comprehensive performance metrics such as precision, recall, and F1 score, validating the proposed method's superior performance in arrhythmia detection. BRIEF DESCRIPTION OF THE DRAWINGS
[0028] Figure 1 Schematic diagram of the overall structure of the integrated arrhythmia detection model in the present invention.
[0029] Figure 2 Result diagrams of ECG signals before and after data preprocessing in the present invention; (a) is the original ECG signal, (b) is a schematic diagram of the signal segmentation result; (c) is a schematic diagram of the signal after normalization.
[0030] Figure 3 Schematic diagram of the structure of a CNN module in one embodiment of the present invention.
[0031] Figure 4 Schematic diagram of the structure of a BiLSTM module in one embodiment of the present invention.
[0032] Figure 5 Schematic diagram of the structure of a CBAM module in an embodiment of the present invention.
[0033] Figure 6 This is a feature distribution result diagram after T-SNE dimensionality reduction in one embodiment of the present invention. DETAILED DESCRIPTION
[0034] In order to better understand the present invention, the following Figure 1-6 , the present invention is further explained based on the embodiments and drawings, but the content of the present invention is not limited to the following embodiments.
[0035] Example 1
[0036] The arrhythmia detection method of this embodiment, which integrates the improved CBAM attention mechanism, includes the following steps:
[0037] Step 1, data preprocessing: Collect ECG signals from the ECG dataset, segment, label and normalize the ECG signals to ensure the consistency of data quality. Specifically, a sliding window strategy is used for signal segmentation, with the window length set to 1800 sampling points and an overlap rate of 50%, as shown in the following example: Figure 2 As shown in Figure (b).
[0038] The process of standardization is to unify the numerical range of the collected signal data in order to eliminate the influence caused by the amplitude difference between different signals. This embodiment uses mean normalization to make the mean 0 and the standard deviation 1 to unify the signal amplitude scale. Figure 2 As shown in Figure (c).
[0039] Step 2: Build a fusion arrhythmia detection model:
[0040] The fusion arrhythmia detection model (see Figure 1 ) includes a CNN module, a BiLSTM module, a CBAM module and a classification module, wherein the ECG signal segments are respectively input into a local branch formed by the CNN module and the CBAM module connected in series, and a time series branch formed by the BiLSTM module and the CBAM module connected in series, and the results of the two branches are weightedly fused in the channel dimension and then classified by the classification module to obtain a classification result;
[0041] The model was built using PyTroch. The CNN module was used to extract the local features of the ECG signal, and the BiLSTM module was used to extract the temporal features of the ECG signal. The temporal features and local features were then input into two independent CBAM modules to optimize the local features and temporal features respectively, thereby enhancing the model's sensitivity to arrhythmia classification.
[0042] Step 3: Model training:
[0043] Using the electrocardiogram signal dataset to train the fused arrhythmia detection model to obtain a trained fused arrhythmia detection model;
[0044] Model training was optimized using the cross-entropy loss function and the Adam optimizer. The initial learning rate was set to 0.001, the batch size was 32, and the number of training rounds was 50 to ensure model convergence and stability. A cross-validation strategy was used to ensure the generalization ability of the model, with the training set and validation set ratios of 80% and 20%.
[0045] Step 4: Input the ECG signal data to be tested into the trained fusion arrhythmia detection model to automatically identify the specific category to which the ECG signal belongs.
[0046] In order to verify the performance of the model, four performance indicators, Accuracy, Precision, Recall and F1-score, are used to evaluate the effectiveness and reliability of the model.
[0047] In order to more comprehensively analyze the impact of different detection and classification model architectures on arrhythmia detection performance, this paper selects the first 100 groups of data from the MIT-BIH dataset to form a local dataset, and uses the local dataset to experimentally analyze the depth of the CNN module and the number of convolution kernels. The output results under different numbers of convolution layers (1 to 5 layers) and corresponding numbers of convolution kernels are verified, namely
[64] , [64,128], [64,128,256], [64,128,256,512], and [64,128,256,512,512]. The evaluation indicators include Accuracy, Precision, Recall and F1-score to determine the optimal network structure combination.
[0048] The specific experimental results are shown in Table 1. The experimental results show that the performance of the model shows a gradual upward trend with the increase of the number of convolution layers. When the number of layers reaches 3 and the convolution kernel configuration is [64, 128, 256], the model has the best comprehensive performance in the four performance evaluation indicators of Accuracy, Precision, Recall and F1-score. When the number of convolution layers is 4 and 5, although some indicators are slightly improved, the overall performance of the model decreases due to feature overfitting caused by the excessive depth of the network. Therefore, the present invention adopts three-layer convolution as the structural configuration of the CNN feature extraction module, which not only ensures the local feature expression ability, but also avoids the problem of model overfitting, providing a stable foundation for the subsequent fusion of CBAM modules.
[0049] Table 1
[0050]
[0051] Example 2
[0052] The overall model of this embodiment consists of an input layer, a feature extraction module, a classification module, and an output layer. First, the input layer receives the original ECG signal and performs data preprocessing; the feature extraction module consists of a CNN module, a BiLSTM module, and a dual-channel CBAM module, and the two CBAM modules act on the feature maps output by the CNN module and the BiLSTM module respectively. The local features output by the CNN module are input into the first CBAM module for extracting channel attention and spatial attention, and the temporal features output by the BiLSTM module are input into the second CBAM module for extracting channel attention and spatial attention in the time dimension; by independently weighting the channel and spatial dimensions of different types of features, the model's ability to express key features is enhanced, thereby improving the accuracy and reliability of arrhythmia detection. The weighted features output by the two CBAM modules are fused in the channel dimension to form a fused joint feature vector, which is then input into the classification module for multi-type discrimination.
[0053] During model training, the training set and validation set ratios were 80% and 20%, respectively. The cross-entropy loss function was used to evaluate model performance, and the Adam optimizer was used for parameter optimization. The initial learning rate was set to 0.001, the batch size was 32, and the number of training rounds was 50 to ensure model convergence and stability. A cross-validation strategy was used to ensure the generalization ability of the model.
[0054] The CNN module consists of three convolutional layers and three pooling layers, with the number of convolution kernels increasing layer by layer to 64, 128, and 256 respectively. The convolutional layer uses the ReLu activation function, which is expressed as follows:
[0055] f(x)=max(0,x)
[0056] Where x represents the input vector from the previous layer. The ReLU activation function can effectively improve the efficiency of gradient descent and backpropagation, avoiding the problems of gradient explosion and gradient vanishing.
[0057] Each pooling layer uses maximum pooling with a pooling kernel size of 2 and a step size of 2 to compress the feature length and retain the main feature information.
[0058] In the BiLSTM module, the number of hidden units of a single-layer BiLSTM is 64, and the bidirectional output dimension is 128.
[0059] After processing in the two CBAM modules, 256-dimensional CNN features and 128-dimensional BiLSTM features are extracted respectively, and the two are spliced in the channel dimension to form a 384-dimensional fusion feature.
[0060] The CBAM module includes a channel attention module and a spatial attention module. In the channel attention module, the input feature map F is subjected to maximum pooling and global average pooling to obtain the convolution feature F. max and F avg , after splicing, it is normalized through a shared fully connected layer and a sigmoid activation function to obtain the channel attention weight A c ; The expression of the channel attention module is:
[0061] A c (F)=σ(W c ·[F avg ,F max ])
[0062] Among them, σ is the sigmoid activation function, W c is the weight of the shared fully connected layer; [...] represents the concatenation of two features;
[0063] In the spatial attention module, the input feature map F undergoes global maximum pooling and mean pooling operations to obtain the feature map F max and Favg The two feature maps are channel-joined, and a 7×7 convolution operation and a sigmoid activation function are performed to obtain the spatial attention weight A. s , whose expression is:
[0064] A s (F)=σ(W s ·[F avg ,F max ])
[0065] Among them, W s Represents a convolution operation, and the size of the convolution kernel is 7×7.
[0066] The CBAM module can effectively enhance the model's attention to important features, thereby improving the detection performance of arrhythmia.
[0067] To verify the impact of different positions of the CBAM attention mechanism on model performance, the present invention selects the aforementioned three-layer CNN module and performs three different CBAM fusion structures, namely CBAM-CNN-BiLSTM, CNN-CBAM-BiLSTM, and CNN-BiLSTM-CBAM, and compares them with the model proposed in this embodiment. The specific results are shown in Table 2. The experimental results show that the model of the present invention outperforms the other three structures in terms of Accuracy, Precision, Recall, and F1-score indicators. The reason for this is that the dual-channel CBAM module can effectively highlight key features by performing channel and spatial weighted enhancement on the features output by CNN and BiLSTM, thereby improving the overall recognition ability of the model.
[0068] Table 2
[0069]
[0070] This application guarantees that under the premise of high precision of more than 99%, the recall rate and accuracy are higher, with Precision above 70%, Recall above 68% and F1-score above 69%.
[0071] In order to verify the effectiveness of the proposed method, experiments were conducted on the MIT-BIH dataset to evaluate the classification performance of different heart rate types. The vertical axis represents different arrhythmia types, namely normal heartbeat (N), left bundle branch block (LBBB), right bundle branch block (RBBB), atrial premature beat (PAB), ventricular premature beat (PVB) and paced heartbeat (PAC), corresponding to 0-5 respectively. The specific results are shown in Table 3.
[0072] Table 3
[0073]
[0074] The feature distribution result after T-SNE dimension reduction of the present invention is shown in FIG Figure 6 As shown in Figure 3, the high-dimensional features are reduced to two-dimensional space and the single-type analysis effect is considered, which is consistent with the detection effect in Table 3.
[0075] The comparison of the evaluation results of the present invention and other classification models is shown in Table 4.
[0076] Table 4
[0077]
[0078] In summary, the method of the present invention has obvious effectiveness and reliability in arrhythmia detection, which is significantly better than the existing model.
[0079] The above shows and describes the main features and advantages of the present invention. It is obvious to those skilled in the art that the specific implementation of the present invention is not limited to the details of the above exemplary embodiments. In addition, without departing from the spirit or essential characteristics of the present invention, the creative ideas and design concepts of the present invention can be implemented in other specific forms, which should be equivalent to the scope of protection disclosed in the technical solution of the present invention. Therefore, from all points of view, the embodiments should be regarded as exemplary and non-restrictive. The scope of the present invention is defined by the appended claims rather than the above description. Therefore, all changes that fall within the meaning and scope of the equivalent elements of the claims are intended to be included in the present invention.
[0080] In addition, it should be understood that although this specification is described in terms of implementation methods, not every implementation method contains only one independent technical solution. This narrative method of the specification is only for the sake of clarity. Those skilled in the art should regard the specification as a whole. The technical solutions in each embodiment can also be appropriately combined to form other implementation methods that can be understood by those skilled in the art.
[0081] Any matters not described in the present invention are applicable to the prior art.
Claims
1. A method for detecting arrhythmia by integrating an improved CBAM attention mechanism, characterized by: The detection method comprises the following steps: Step 1, data preprocessing: Collect ECG signals from the ECG dataset, segment the ECG signals, and label different types of arrhythmia. All ECG signal segments and corresponding labels constitute the ECG signal dataset; Step 2: Build a fusion arrhythmia detection model: The fusion arrhythmia detection model includes a CNN module, a BiLSTM module, a CBAM module and a classification module. The ECG signal segments are respectively input into a local branch composed of a CNN module and a CBAM module connected in series, and a time series branch composed of a BiLSTM module and a CBAM module connected in series. The results of the two branches are weightedly fused in the channel dimension and then classified by the classification module to obtain a classification result. Step 3: Model training: Using the electrocardiogram signal dataset to train the fused arrhythmia detection model to obtain a trained fused arrhythmia detection model; Step 4: Input the ECG signal data to be tested into the trained fusion arrhythmia detection model to automatically identify the specific category to which the ECG signal belongs.
2. The arrhythmia detection method integrating the improved CBAM attention mechanism according to claim 1 is characterized in that: In step 1, the process of segmenting the ECG signal is as follows: a sliding window strategy is used to segment the ECG signal, the window length is set to 1800 sampling points, and the overlap rate is 50%.
3. The arrhythmia detection method integrating the improved CBAM attention mechanism according to claim 1 is characterized in that: The CNN module includes three convolutional layers and three pooling layers. The number of convolution kernels increases layer by layer, namely 64, 128, and 256 respectively. The convolution layer uses the ReLu activation function. The pooling kernel size of the three pooling layers is 2, and the stride is 2. The bidirectional output dimension of the BiLSTM module is 128. The classification module consists of two layers of fully connected neural networks; the first layer maps 384 dimensions to 128 dimensions and uses ReLU activation, and the second layer outputs the probability prediction results of the target classification number dimension.
4. The arrhythmia detection method integrating the improved CBAM attention mechanism according to claim 1 is characterized in that: The CBAM module includes a channel attention module and a spatial attention module. In the channel attention module, the input feature map F is subjected to maximum pooling and global average pooling to obtain the convolution feature F. max and F avg , after splicing, it is normalized through a shared fully connected layer and a sigmoid activation function to obtain the channel attention weight A c ; The expression of the channel attention module is: A c (F)=σ(W c ·[F avg ,F max ]) Among them, σ is the sigmoid activation function, W c is the weight of the shared fully connected layer; [...] represents the concatenation of two features; In the spatial attention module, the input feature map F undergoes global maximum pooling and mean pooling operations to obtain the feature map F max and F avg The two feature maps are channel-joined, and a 7×7 convolution operation and a sigmoid activation function are performed to obtain the spatial attention weight A. s , whose expression is: A s (F)=σ(W s ·[F avg ,F max ]) Among them, W s Represents a convolution operation, and the size of the convolution kernel is 7×7.
5. The arrhythmia detection method integrating the improved CBAM attention mechanism according to claim 1 is characterized in that: The model training process is optimized using the cross entropy loss function, using the Adam optimizer, with the initial learning rate set to 0.001, the batch size to 32, and the number of training rounds to 50.
6. The arrhythmia detection method integrating the improved CBAM attention mechanism according to claim 1 is characterized in that: The method performs arrhythmia detection with an accuracy of over 99%, a recall rate of over 68%, an accuracy of over 70%, and an F1-score of over 69%.
Citation Information
Patent Citations
ConvLSTM and CBAM attention mechanism fused non-contact heart rate measurement method
CN115024706A