Single-lead electrocardiogram arrhythmia detection method and system based on adaptive attention
By adopting adaptive attention mechanism and multi-scale parallel spatiotemporal feature extraction in single-lead ECG devices, combined with BiLSTM and multi-layer perceptron, the accuracy problem of single-lead ECG devices in monitoring arrhythmia is solved, achieving high Accuracy and real-time arrhythmia detection.
Patent Information
- Application Number
- CN202411072085.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-06
- Publication Date
- 2024-11-29
- Estimated Expiration
- 2044-08-06
AI Technical Summary
When monitoring arrhythmia, existing single-lead electrocardiogram devices have poor classification results due to the nonlinear and non-smooth characteristics of the electrocardiogram signal, individual differences and data noise, which makes it difficult to achieve real-time monitoring of high accuracy.
Using a single-lead electrocardiogram arrhythmia detection method based on adaptive attention, spatial and timing features are extracted through a multi-scale parallel spatiotemporal feature extraction module, combined with an adaptive attention mechanism to weight the timing features, and cross-channel information is integrated. Use stacked BiLSTM and multi-layer perceptron for classification, and iterative training to optimize network parameters.
It improves the accuracy and real-time nature of arrhythm classification, enhances the portability and robustness of the model, reduces the rate of misdiagnosis, and enables more accurate identification of cardiac rhythm types.
Smart Images

Figure CN119046724A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of portable wearable mobile terminal control technology, in particular to a single-lead electrocardiogram arrhythmia detection method and system based on adaptive attention. Background Art
[0002] A portable wearable single-lead ECG device is a lightweight medical device used to monitor and record ECG data in real time, and can detect heart abnormalities such as arrhythmias. Due to its compact and convenient design, users can wear it on their chest or wrist without affecting their daily activities. In addition, the device usually has Bluetooth or wireless connection capabilities, which can transmit ECG data to smartphones or cloud platforms in real time, facilitating remote medical monitoring and family health management, and providing strong support for the prevention and early detection of heart disease. Today's aging population trend requires high-performance and high-precision signal processing and data analysis algorithms to effectively monitor the human body.
[0003] Cardiovascular disease is the leading cause of death, and modern medicine often uses electrocardiogram signals as a non-invasive means of diagnosing cardiovascular disease. There are many medical technologies that can be used to monitor arrhythmias, but most of them are used for clinical diagnosis. For example, hospitals use 12-lead electrocardiogram devices to record and reflect the electrical activity of the heart by placing electrodes on different parts of the body to check for heart-related diseases. These detection methods are not suitable for remote real-time health monitoring. Today, wearable single-lead electrocardiogram devices have been used for remote heart health monitoring, but because the electrocardiogram signal contains a large number of nonlinear and non-smooth features, and is limited by individual differences, data acquisition noise, algorithms and other conditions, its actual application effect is not ideal. Therefore, it is urgent to study an algorithm to achieve high-accuracy classification of single-lead electrocardiograms and monitor heart status in real time. Summary of the invention
[0004] The purpose of the present invention is to provide an accurate, efficient, real-time single-lead electrocardiogram arrhythmia detection method and system based on adaptive attention, so that a wearable single-lead electrocardiogram device can accurately identify the type of heart rhythm.
[0005] The technical solution to achieve the purpose of the present invention is: a single-lead electrocardiogram arrhythmia detection method based on adaptive attention, comprising the following steps:
[0006] Step 1: Preprocess the electrocardiogram data;
[0007] Step 2: extracting the spatial features and temporal features of the ECG signal through a multi-scale parallel spatiotemporal feature extraction module;
[0008] Step 3: Weight the temporal features through the adaptive attention mechanism;
[0009] Step 4: splice and fuse the spatial features and weighted temporal features, and integrate cross-channel information to obtain spatiotemporal fusion features;
[0010] Step 5: The spatiotemporal fusion features are classified by a classifier including stacked BiLSTM and multi-layer perceptron to output the classification results;
[0011] Step 6: Iterate the training to optimize the parameters of the entire network to obtain the best classification effect.
[0012] Furthermore, in step 1, the electrocardiogram data is preprocessed, specifically including:
[0013] The ECG data is denoised, the oversampling is used to balance the data set, the R-wave detection is used to divide the ECG segments, and the data set is divided into a training set and a test set.
[0014] Furthermore, the step 1 is specifically as follows:
[0015] First, the ECG data is subjected to discrete wavelet threshold denoising;
[0016] Secondly, to address the problem of class imbalance, the ADASYN method is used to adaptively generate synthetic samples to balance the class distribution;
[0017] Next, R wave detection is performed, and the ECG is divided into multiple ECG segments according to the R wave; the ECG signal and the corresponding true label are expressed as R = (x1, y1), (x2, y2), ..., (x N ,y N ), where x i ∈X is the ECG signal, y i ∈{0,1,2,...,M} is the corresponding heart rhythm type, i∈{1,2,...,N};
[0018] Finally, the dataset is divided into training and test sets, which are 80% and 20% of the total dataset respectively, and Gaussian noise with a mean of 0 and a standard deviation of 0.1 is added to the training dataset.
[0019] Furthermore, the electrocardiogram is divided into a plurality of electrocardiogram segments according to the R wave, specifically:
[0020] Each heart beat includes 100 sampling points before the R peak and 200 sampling points after the R peak. The rhythm type is converted into a one-hot form, that is, 0 represents N normal beat, 1 represents A atrial premature beat, 2 represents V atrial escape beat, 3 represents L left bundle branch block, and 4 represents R right bundle branch block.
[0021] Furthermore, in step 2, the multi-scale parallel spatiotemporal feature extraction module includes a spatial feature network F i and temporal feature network Mi Two submodules, each of which contains multiple branches with different sampling rates to extract spatial features at different scales and timing characteristics
[0022] Furthermore, the spatial feature network F i The details are as follows:
[0023] According to the dynamic characteristics of ECG signals, the maximum pooling Ψ and the global average pooling Φ are selected to combine with CNN to form two parallel spatial branches F1 and F2 of the spatial feature network. The formula is as follows:
[0024] f1=F1(X)=Deconvd(((Ψ(δConv1D(X,k,αC)),k,C)
[0025] f2=F2(X)=Deconvd(((Φ(δConv1D(X,k,αC)),k,C)
[0026] Among them, X is the input data, δ is the ReLU activation function, Conv1D represents one-dimensional convolution, k is the convolution kernel size, αC is the number of output channels, and Deconvd represents transposed convolution;
[0027] The temporal feature network M i The details are as follows:
[0028] Combining the dilated convolution and residual structure, different dilation rates are used to capture features of different granularities; three parallel M1, M2, and M3 time series branches are set to obtain time series features m1, m2, and m3 respectively. i The formula is as follows:
[0029] m i =M i (X,D i )=f1(X,D i )+f2(X), i=1,2,3
[0030] Among them, f1(·) is the main operation function, f2(·) is the skip connection, X is the input data, and D i is the expansion rate, i=1,2,3; the expansion rates of the three branches are D1=2, D2=3, D3=9.
[0031] Furthermore, in step 3, the temporal feature m obtained in step 2 is used through an adaptive attention mechanism. i , m2, and m3 are weighted respectively to obtain The details are as follows:
[0032] According to the dynamic characteristics of ECG signals in the time dimension, a three-level adaptive modeling scheme is established: local branch L, global branch G and aggregation branch A; local branch and aggregation branch are both in Data divided by local time window The above operation, where L = S / T is the sequence length of the data in each window;
[0033] The adaptive attention mechanism formula is as follows:
[0034]
[0035] in, It is a local-global aggregation feature; in order to match the dimensions of f1 and f2, through F rescale (·)Will Rescale to represents the convolution operation, Concat(·) represents the concatenation operation; G(·) is the global branch, L(·) is the local branch, and A(·) is the aggregation branch;
[0036] The local branch L(·) uses one-dimensional convolution to slide on the time dimension, focusing on the time series features within the time window, and learning the importance weights based on the local time window. The formula is as follows:
[0037]
[0038] Among them, ⊙ represents the multiplication of each element, sigmoid is the activation function, and in order to reduce the computational complexity, the number of output channels of the first convolution is reduced to The second convolution restores the number of output channels to C;
[0039] The global branch G(·) uses a self-attention mechanism to dynamically learn the importance of each time step in the sequence globally and capture long-term dependencies. The formula is as follows:
[0040]
[0041] K T , Q, and V are the transpose of the query vector, the key vector, and the value vector, respectively. Linear change; d k is the dimension of the key vector; softmax is the activation function; the local time window is used to split the results of the global branch into Then with the local features splicing and fusion;
[0042] The aggregation branch A(·) guides the network with two fully connected layers to learn adaptive convolution kernels in local time windows for adaptive aggregation of global-local features. The formula is as follows:
[0043]
[0044] in, is the adaptive convolution kernel size, c∈{0,1,...C} is the number of channels, Θ1,Θ2,...,Θ c It is used in a convolutional way to achieve aggregation from the channel dimension; W1, W2 are the weights of the fully connected layer F(·), and softmax is the activation function. is a global-local aggregation feature.
[0045] Furthermore, in step 4, the spatial features and the weighted temporal features are spliced and fused, and cross-channel information is integrated to obtain spatiotemporal fusion features, as follows:
[0046] The spatial feature f i And the temporal features processed by the adaptive attention mechanism Fusion forms a spatiotemporal fusion feature H containing spatial and temporal information. The formula is as follows:
[0047] H=Conv1D(Concat(f1,f2,m1,m2,m3),1,C)
[0048] Among them, f1 and f2 are spatial features, and m1, m2, and m3 are temporal features. The concatenated fusion features are linearly transformed through a one-dimensional convolution with a convolution kernel of 1 and an output channel of C to achieve cross-channel information integration.
[0049] Furthermore, the spatiotemporal fusion features described in step 5 are classified by a classifier including a stacked BiLSTM and a multi-layer perceptron, as follows:
[0050] The stacked BiLSTM is used to sequentially learn the spatiotemporal fusion features, and the MLP is responsible for mapping these features to the final classification results; the classification model is based on x i is the input, z i is the output, z i ∈{0,1,2,...,M}, i∈{0,1,2...N} refers to the predicted label of the corresponding ECG signal; then the arrhythmia classification task is described as a function transformation for a given input x i Find the corresponding output z i The goal of model classification is to minimize the network prediction z i and the actual i The cross entropy loss between:
[0051]
[0052] Where N is the number of samples; p(X,y) represents the probability distribution of a sample belonging to category y given a certain input feature X; p(X,z) represents the probability distribution of a sample belonging to category z given a certain input feature X; I{·} is an indicator function, I{true}=1 otherwise 0.
[0053] A single-lead electrocardiogram arrhythmia detection system based on adaptive attention, the system is used to implement the single-lead electrocardiogram arrhythmia detection method based on adaptive attention, the system includes a preprocessing module, a multi-scale parallel spatiotemporal feature extraction module, a weighting module, a splicing fusion module, a classifier module and an iterative optimization module, wherein:
[0054] A preprocessing module preprocesses the electrocardiogram data;
[0055] Multi-scale parallel spatiotemporal feature extraction module, used to extract the spatial and temporal features of ECG signals;
[0056] The weighting module is used to weight the temporal features through an adaptive attention mechanism;
[0057] The splicing and fusion module is used to splice and fuse the spatial features and the weighted temporal features, and integrate the cross-channel information to obtain the spatiotemporal fusion features;
[0058] Classifier module, the spatiotemporal fusion features output the classification results through a classifier including stacked BiLSTM and multi-layer perceptron;
[0059] Iterative optimization module, iterative training optimizes the parameters of the entire network to obtain the best classification effect.
[0060] Compared with the prior art, the present invention has the following significant advantages: (1) The spatiotemporal feature parallel extraction network and adaptive attention mechanism are combined with a multi-scale structure to realize cross-scale regulation of the model, so that the model focuses on more discriminative information and improves the classification accuracy; (2) The spatiotemporal feature extraction module is highly efficient and extremely flexible, and can be flexibly loaded into the existing network framework, with good portability and robustness; (3) A cross-scale global-local temporal attention integration strategy is adopted to extract features from multiple scales, and the dilated convolution is combined to reduce data redundancy, and the residual structure is combined to solve the gradient vanishing problem of the deep network, thereby improving the classification speed of the network and the final effect. BRIEF DESCRIPTION OF THE DRAWINGS
[0061] Figure 1 Flowchart of the adaptive attention-based single-lead ECG arrhythmia detection method.
[0062] Figure 2 This is a specific implementation process diagram of the single-lead ECG arrhythmia detection method based on adaptive attention.
[0063] Figure 3 This is a specific structure diagram of the network model of the single-lead ECG arrhythmia detection method based on adaptive attention.
[0064] Figure 4 This is a graph showing changes in the Loss value and accuracy during the test process in an embodiment of the present invention. DETAILED DESCRIPTION
[0065] In order to make the purpose, technical solution and advantages of the present application more clearly understood, the present application is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and are not used to limit the present application.
[0066] Combination Figure 1 to Figure 3 The present invention provides a single-lead electrocardiogram arrhythmia detection method based on adaptive attention, comprising the following steps:
[0067] Step 1: Preprocess the electrocardiogram data;
[0068] Step 2: extracting the spatial features and temporal features of the ECG signal through a multi-scale parallel spatiotemporal feature extraction module;
[0069] Step 3: Weight the temporal features through the adaptive attention mechanism;
[0070] Step 4: splice and fuse the spatial features and weighted temporal features, and integrate cross-channel information to obtain spatiotemporal fusion features;
[0071] Step 5: The spatiotemporal fusion features are classified by a classifier including stacked BiLSTM and multi-layer perceptron to output the classification results;
[0072] Step 6: Iterate the training to optimize the parameters of the entire network to obtain the best classification effect.
[0073] In order to more clearly illustrate the functional characteristics and structural parameters of the present invention, further description is given below in conjunction with the accompanying drawings and specific implementation methods.
[0074] As a specific example, in step 1, the electrocardiogram data is preprocessed, specifically including:
[0075] First, the ECG data is subjected to discrete wavelet threshold denoising;
[0076] Secondly, to address the problem of class imbalance, the ADASYN method is used to adaptively generate synthetic samples to balance the class distribution;
[0077] Next, R wave detection is performed, and the ECG is divided into multiple ECG segments according to the R wave; the ECG signal and the corresponding true label are expressed as R = (x1, y1), (x2, y2), ..., (x N ,y N ), where x i ∈X is the ECG signal, y i ∈{0,1,2,...,M} is the corresponding heart rhythm type, i∈{1,2,...,N};
[0078] Finally, the dataset is divided into training and test sets, which are 80% and 20% of the total dataset respectively. In order to improve the robustness of the model, Gaussian noise with a mean of 0 and a standard deviation of 0.1 is added to the training dataset.
[0079] As a specific example, the electrocardiogram is divided into a plurality of electrocardiogram segments according to the R wave, specifically:
[0080] Each heart beat includes 100 sampling points before the R peak and 200 sampling points after the R peak. The rhythm type is converted into a one-hot form, that is, 0 represents N normal beat, 1 represents A atrial premature beat, 2 represents V atrial escape beat, 3 represents L left bundle branch block, and 4 represents R right bundle branch block.
[0081] As a specific example, in step 2, the multi-scale parallel spatiotemporal feature extraction module includes a spatial feature network F i and temporal feature network M i Two submodules, each of which contains multiple branches with different sampling rates to extract spatial features at different scales and timing characteristics
[0082] As a specific example, the preprocessed ECG signal X is simultaneously input into two submodules of the multi-scale parallel spatiotemporal feature extraction module: the spatial feature network F i and temporal feature network M i .
[0083] The spatial feature network F i The details are as follows:
[0084] According to the dynamic characteristics of ECG signals, the maximum pooling Ψ and the global average pooling Φ are selected to combine with CNN to form two parallel spatial branches F1 and F2 of the spatial feature network. The formula is as follows:
[0085] f1=F1(X)=Deconvd(((Ψ(δConv1D(X,k,αC)),k,C)
[0086] f2=F2(X)=Deconvd(((Φ(δConv1D(X,k,αC)),k,C)
[0087] Among them, X is the input data, δ is the ReLU activation function, Conv1D represents one-dimensional convolution, k is the convolution kernel size, αC is the number of output channels, and Deconvd represents transposed convolution;
[0088] The temporal feature network M i The details are as follows:
[0089] Combining the dilated convolution and residual structure, different dilation rates are used to capture features of different granularities. Considering the real-time performance and accuracy of the model, three parallel M1, M2, and M3 time series branches are set to obtain time series features m1, m2, and m3 respectively. i The formula is as follows:
[0090] m i =M i (X,D i )=f1(X,D i )+f2(X), i=1,2,3
[0091] Among them, f1(·) is the main operation function, f2(·) is the skip connection, X is the input data, and D i is the expansion rate, i=1,2,3; the expansion rates of the three branches are D1=2, D2=3, D3=9.
[0092] As a specific example, in step 3, the temporal feature m obtained in step 2 is centered by an adaptive attention mechanism. i , m2, and m3 are weighted respectively to obtain The details are as follows:
[0093] According to the dynamic characteristics of ECG signals in the time dimension, a three-level adaptive modeling scheme is established: local branch L, global branch G and aggregation branch A; local branch and aggregation branch are both in Data divided by local time window The above operation, where L = S / T is the sequence length of the data in each window;
[0094] The adaptive attention mechanism formula is as follows:
[0095]
[0096] in, It is a local-global aggregation feature; in order to match the dimensions of f1 and f2, through F rescale (·)Will Rescale to represents the convolution operation, Concat(·) represents the concatenation operation; G(·) is the global branch, L(·) is the local branch, and A(·) is the aggregation branch;
[0097] The local branch L(·) uses one-dimensional convolution to slide on the time dimension, focusing on the time series features within the time window, and learning the importance weights based on the local time window. The formula is as follows:
[0098]
[0099] Among them, ⊙ represents the multiplication of each element, sigmoid is the activation function, and in order to reduce the computational complexity, the number of output channels of the first convolution is reduced to The second convolution restores the number of output channels to C;
[0100] The global branch G(·) uses a self-attention mechanism to dynamically learn the importance of each time step in the sequence globally and capture long-term dependencies. The formula is as follows:
[0101]
[0102] K T , Q, and V are the transpose of the query vector, the key vector, and the value vector, respectively. Linear change; d k is the dimension of the key vector; softmax is the activation function; the local time window is used to split the results of the global branch into Then with the local features splicing and fusion;
[0103] The aggregation branch A(·) guides the network with two fully connected layers to learn adaptive convolution kernels in the local time window for adaptive aggregation of global-local features, solving the problem that fixed convolution kernels cannot describe the complex dynamic changes of ECG signals. The formula is as follows:
[0104]
[0105] in, is the adaptive convolution kernel size, c∈{0,1,...C} is the number of channels, Θ1,Θ2,...,Θ c It is used in a convolutional way to achieve aggregation from the channel dimension; W1, W2 are the weights of the fully connected layer F(·), and softmax is the activation function. is a global-local aggregation feature.
[0106] As a specific example, in step 4, the spatial features and the weighted temporal features are concatenated and fused, and cross-channel information is integrated to obtain spatiotemporal fusion features, as follows:
[0107] The spatial feature f i And the temporal features processed by the adaptive attention mechanism Fusion forms a spatiotemporal fusion feature H containing spatial and temporal information. The formula is as follows:
[0108] H=Conv1D(Concat(f1,f2,m1,m2,m3),1,C)
[0109] Among them, f1 and f2 are spatial features, and m1, m2, and m3 are temporal features. The concatenated fusion features are linearly transformed through a one-dimensional convolution with a convolution kernel of 1 and an output channel of C to achieve cross-channel information integration.
[0110] As a specific example, the spatiotemporal fusion features described in step 5 are classified by a classifier including a stacked BiLSTM and a multi-layer perceptron, as follows:
[0111] The bidirectional characteristics of BiLSTM enable the model to capture the forward and backward dependencies of the sequence at the same time. The stacked BiLSTM performs further sequence learning on the spatiotemporal fusion features, and MLP is responsible for mapping these complex features to the final classification results. i is the input, z i is the output, z i ∈{0,1,2,...,M}, i∈{0,1,2...N} refers to the predicted label of the corresponding ECG signal; then the arrhythmia classification task is described as a function transformation for a given input x i Find the corresponding output z i The goal of model classification is to minimize the network prediction z i and the actual i The cross entropy loss between:
[0112]
[0113] Where N is the number of samples; p(X,y) represents the probability distribution of a sample belonging to category y given a certain input feature X; p(X,z) represents the probability distribution of a sample belonging to category z given a certain input feature X; I{·} is an indicator function, I{true}=1 otherwise 0.
[0114] As a specific example, the iterative training described in step 6 optimizes the parameters of the entire network to obtain the best classification effect, as follows:
[0115] Iterative training is performed according to the general deep learning process to back-propagate and update the model parameters until the best model classification effect is obtained after testing, and the final model is used to classify the heart rhythm. The present invention is further described in detail below in conjunction with the accompanying drawings and specific embodiments.
[0116] The present invention also provides a single-lead electrocardiogram arrhythmia detection system based on adaptive attention, which is used to implement the single-lead electrocardiogram arrhythmia detection method based on adaptive attention. The system includes a preprocessing module, a multi-scale parallel spatiotemporal feature extraction module, a weighting module, a splicing fusion module, a classifier module and an iterative optimization module, wherein:
[0117] A preprocessing module preprocesses the electrocardiogram data;
[0118] Multi-scale parallel spatiotemporal feature extraction module, used to extract the spatial and temporal features of ECG signals;
[0119] The weighting module is used to weight the temporal features through an adaptive attention mechanism;
[0120] The splicing and fusion module is used to splice and fuse the spatial features and the weighted temporal features, and integrate the cross-channel information to obtain the spatiotemporal fusion features;
[0121] Classifier module, the spatiotemporal fusion features output the classification results through a classifier including stacked BiLSTM and multi-layer perceptron;
[0122] Iterative optimization module, iterative training optimizes the parameters of the entire network to obtain the best classification effect.
[0123] The present invention is further described in detail below with reference to the accompanying drawings and specific embodiments.
[0124] Example
[0125] This example uses an open source electrocardiogram dataset to experimentally verify the present invention:
[0126] Using open source data sets, five types of classification are performed: N normal beats, A atrial premature beats, V atrial escape beats, L left bundle branch block, and R right bundle branch block. When analyzing the performance of the algorithm, the Loss value is used to observe the convergence effect of the algorithm, and the accuracy rate is used to observe the classification effect of the algorithm.
[0127] Figure 4 This is a graph showing the changes in the Loss value and accuracy during the test of this embodiment. Figure 4 As shown in (b) of , as the number of training rounds increases, the Loss value gradually decreases, and the final value is close to 0. Figure 4As shown in (a), the classification accuracy has also increased from less than 75% at the beginning to nearly 99.6%. And the processing time of a single heartbeat is much less than 1 second.
[0128] In summary, the method of the present invention can improve the accuracy and real-time performance of arrhythmia classification of single-lead ECG data, and can be widely used in multiple fields such as remote medical monitoring, family health management, and sports health tracking.
[0129] The technical features of the above embodiments may be combined arbitrarily. To make the description concise, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.
[0130] In summary, the method of the present invention can improve the accuracy and real-time performance of arrhythmia classification of single-lead ECG data, and reduce the misdiagnosis rate. The present invention can improve the ability of portable wearable single-lead ECG devices to identify heart rhythm categories, and can be widely used in multiple fields such as remote medical monitoring, family health management, and sports health tracking.
[0131] The technical features of the above embodiments may be combined arbitrarily. To make the description concise, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.
[0132] The above-mentioned embodiments only express several implementation methods of the present application, and the descriptions thereof are relatively specific and detailed, but they cannot be understood as limiting the scope of the invention patent. It should be pointed out that, for a person of ordinary skill in the art, several variations and improvements can be made without departing from the concept of the present application, and these all belong to the protection scope of the present application. Therefore, the protection scope of the patent of the present application shall be subject to the attached claims.
Claims
1. A single-lead electrocardiogram arrhythmia detection method based on adaptive attention, characterized in that: The following steps are involved: Step 1: Preprocess the electrocardiogram data; Step 2: extracting the spatial features and temporal features of the ECG signal through a multi-scale parallel spatiotemporal feature extraction module; Step 3: Weight the temporal features through the adaptive attention mechanism; Step 4: splice and fuse the spatial features and weighted temporal features, and integrate cross-channel information to obtain spatiotemporal fusion features; Step 5: The spatiotemporal fusion features are classified by a classifier including stacked BiLSTM and multi-layer perceptron to output the classification results; Step 6: Iterate the training to optimize the parameters of the entire network to obtain the best classification effect.
2. The single-lead electrocardiogram arrhythmia detection method based on adaptive attention according to claim 1, characterized in that: In step 1, the electrocardiogram data is preprocessed, including: The ECG data is denoised, the oversampling is used to balance the data set, the R-wave detection is used to divide the ECG segments, and the data set is divided into a training set and a test set.
3. The single-lead electrocardiogram arrhythmia detection method based on adaptive attention according to claim 2, characterized in that: The step 1 is specifically as follows: First, the ECG data is subjected to discrete wavelet threshold denoising; Secondly, to address the problem of class imbalance, the ADASYN method is used to adaptively generate synthetic samples to balance the class distribution; Next, R wave detection is performed, and the ECG is divided into multiple ECG segments according to the R wave; the ECG signal and the corresponding true label are expressed as R = (x1, y1), (x2, y2), ..., (x N ,y N ), where x i ∈X is the ECG signal, y i ∈{0,1,2,...,M} is the corresponding heart rhythm type, i∈{1,2,...,N}; Finally, the dataset is divided into training and test sets, which are 80% and 20% of the total dataset respectively, and Gaussian noise with a mean of 0 and a standard deviation of 0.1 is added to the training dataset.
4. The single-lead electrocardiogram arrhythmia detection method based on adaptive attention according to claim 3, characterized in that: The electrocardiogram is divided into a plurality of electrocardiogram segments according to the R wave, specifically: Each heart beat includes 100 sampling points before the R peak and 200 sampling points after the R peak. The rhythm type is converted into a one-hot form, that is, 0 represents N normal beat, 1 represents A atrial premature beat, 2 represents V atrial escape beat, 3 represents L left bundle branch block, and 4 represents R right bundle branch block.
5. The single-lead electrocardiogram arrhythmia detection method based on adaptive attention according to claim 4, characterized in that: In step 2, the multi-scale parallel spatiotemporal feature extraction module includes a spatial feature network F i and temporal feature network M i Two submodules, each of which contains multiple branches with different sampling rates to extract spatial features at different scales and timing characteristics 6. The single-lead electrocardiogram arrhythmia detection method based on adaptive attention according to claim 5, characterized in that: The spatial feature network F i The details are as follows: According to the dynamic characteristics of ECG signals, the maximum pooling Ψ and the global average pooling Φ are selected to combine with CNN to form two parallel spatial branches F1 and F2 of the spatial feature network. The formula is as follows: f1=F1(X)=Deconvd(((Ψ(δConv1D(X,k,αC)),k,C) f2=F2(X)=Deconvd(((Φ(δConv1D(X,k,αC)),k,C) Among them, X is the input data, δ is the ReLU activation function, Conv1D represents one-dimensional convolution, k is the convolution kernel size, αC is the number of output channels, and Deconvd represents transposed convolution; The temporal feature network M i The details are as follows: Combining the dilated convolution and residual structure, different dilation rates are used to capture features of different granularities; three parallel M1, M2, and M3 time series branches are set to obtain time series features m1, m2, and m3 respectively. i The formula is as follows: m i =M i (X,D i )=f1(X,D i )+f2(X),i=1,2,3 Among them, f1(·) is the main operation function, f2(·) is the skip connection, X is the input data, and D i is the expansion rate, i=1,2,3; the expansion rates of the three branches are D1=2, D2=3, D3=9.
7. The single-lead electrocardiogram arrhythmia detection method based on adaptive attention according to claim 6, characterized in that: In step 3, the temporal feature m obtained in step 2 is processed by an adaptive attention mechanism. i , m2, and m3 are weighted respectively to obtain The details are as follows: According to the dynamic characteristics of ECG signals in the time dimension, a three-level adaptive modeling scheme is established: local branch L, global branch G and aggregation branch A; local branch and aggregation branch are both in Data divided by local time window The above operation, where L = S / T is the sequence length of the data in each window; The adaptive attention mechanism formula is as follows: in, It is a local-global aggregation feature; in order to match the dimensions of f1 and f2, through F rescale (·)Will Rescale to represents the convolution operation, Concat(·) represents the concatenation operation; G(·) is the global branch, L(·) is the local branch, and A(·) is the aggregation branch; The local branch L(·) uses one-dimensional convolution to slide on the time dimension, focusing on the time series features within the time window, and learning the importance weights based on the local time window. The formula is as follows: Among them, ⊙ represents the multiplication of each element, sigmoid is the activation function, and in order to reduce the computational complexity, the number of output channels of the first convolution is reduced to The second convolution restores the number of output channels to C; The global branch G(·) uses a self-attention mechanism to dynamically learn the importance of each time step in the sequence globally and capture long-term dependencies. The formula is as follows: K T , Q, and V are the transpose of the query vector, the key vector, and the value vector, respectively. Linear change; d k is the dimension of the key vector; softmax is the activation function; the local time window is used to split the results of the global branch into Then with the local features splicing and fusion; The aggregation branch A(·) guides the network with two fully connected layers to learn adaptive convolution kernels in local time windows for adaptive aggregation of global-local features. The formula is as follows: in, is the adaptive convolution kernel size, c∈{0,1,...C} is the number of channels, Θ1,Θ2,...,Θ c It is used in a convolutional way to achieve aggregation from the channel dimension; W1, W2 are the weights of the fully connected layer F(·), and softmax is the activation function. is a global-local aggregation feature.
8. The single-lead electrocardiogram arrhythmia detection method based on adaptive attention according to claim 7, characterized in that: In step 4, the spatial features and the weighted temporal features are concatenated and fused, and cross-channel information is integrated to obtain spatiotemporal fusion features, as follows: The spatial feature f i And the temporal features processed by the adaptive attention mechanism Fusion forms a spatiotemporal fusion feature H containing spatial and temporal information. The formula is as follows: H=Conv1D(Concat(f1,f2,m1,m2,m3),1,C) Among them, f1 and f2 are spatial features, and m1, m2, and m3 are temporal features. The concatenated fusion features are linearly transformed through a one-dimensional convolution with a convolution kernel of 1 and an output channel of C to achieve cross-channel information integration.
9. The single-lead electrocardiogram arrhythmia detection method based on adaptive attention according to claim 7, characterized in that: The spatiotemporal fusion features described in step 5 are classified by a classifier including stacked BiLSTM and multi-layer perceptron, as follows: The stacked BiLSTM is used to sequentially learn the spatiotemporal fusion features, and the MLP is responsible for mapping these features to the final classification results; the classification model is based on x i is the input, z i is the output, z i ∈{0,1,2,...,M}, i∈{0,1,2...N} refers to the predicted label of the corresponding ECG signal; then the arrhythmia classification task is described as a function transformation for a given input x i Find the corresponding output z i The goal of model classification is to minimize the network prediction z i and the actual i The cross entropy loss between: Where N is the number of samples; p(X,y) represents the probability distribution of a sample belonging to category y given a certain input feature X; p(X,z) represents the probability distribution of a sample belonging to category z given a certain input feature X; I{·} is an indicator function, I{true}=1 otherwise 0.
10. A single-lead electrocardiogram arrhythmia detection system based on adaptive attention, characterized in that: The system is used to implement the single-lead electrocardiogram arrhythmia detection method based on adaptive attention as described in any one of claims 1 to 9, and the system includes a preprocessing module, a multi-scale parallel spatiotemporal feature extraction module, a weighting module, a splicing and fusion module, a classifier module and an iterative optimization module, wherein: A preprocessing module preprocesses the electrocardiogram data; Multi-scale parallel spatiotemporal feature extraction module, used to extract the spatial and temporal features of ECG signals; The weighting module is used to weight the temporal features through an adaptive attention mechanism; The splicing and fusion module is used to splice and fuse the spatial features and the weighted temporal features, and integrate the cross-channel information to obtain the spatiotemporal fusion features; Classifier module, the spatiotemporal fusion features output the classification results through a classifier including stacked BiLSTM and multi-layer perceptron; Iterative optimization module, iterative training optimizes the parameters of the entire network to obtain the best classification effect.
Citation Information
Patent Citations
Infrared and visible light image double-domain self-attention interactive fusion method
CN117788989A
Image classifier optimization method based on local features and position attention
CN117934970A
Multi-feature auxiliary diagnosis method based on double-lead ECG signal, terminal and readable storage medium
CN118285809A
Person re-identification method and apparatus for fusing global features with ladder-shaped local features
WO2024021394A1
Cited By
Electrocardiogram signal classification method and device and electrocardiogram monitor
CN119924848A
A method and device for classifying electrocardiogram signals and an electrocardiogram monitor
CN119924848B
Phi-OTDR vibration event classification method and system based on feature fusion
CN120067878A
Congenital heart disease four-dimensional echocardiogram dynamic segmentation system
CN120672778A
Four-dimensional echocardiography dynamic segmentation system for congenital heart disease
CN120672778B
