Single-lead ecg arrhythmia detection method and system based on adaptive attention
Patent Information
- Application Number
- CN202411072085.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-06
- Publication Date
- 2026-08-21
- Estimated Expiration
- 2044-08-06
AI Technical Summary
如今可穿戴式单导联心电图设备已经应用于远程心脏健康监测,但由于心电信号包含大量的非线性和非光滑特征,且个体差异、数据采集噪声、算法等条件的限制,其实际应用效果并不理想
[0061]本发明与现有技术相比,其显著优点为:(1)运用时空特征并行提取网络和自适应注意力机制结合多尺度结构实现模型的跨尺度调控,使模型关注于更具有判别力的信息,提高分类的准确率;(2)时空特征提取模块具有高效率与极强的灵活性,可以灵活地加载现有的网络框架之中,具有较好的可移植性和鲁棒性;(3)采用跨尺度的全局-局部时间注意力整合策略,从多尺度进行特征提取,并结合膨胀卷积减少数据冗余,结合残差结构解决深度网络梯度消失问题,提高了网络的分类速度和最终的效果。
Smart Images

Figure CN119046724B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of portable wearable mobile terminal control technology, and in particular to a method and system for detecting arrhythmias in single-lead electrocardiograms based on adaptive attention. Background Technology
[0002] Portable wearable single-lead electrocardiogram (ECG) devices are lightweight medical devices used to monitor and record ECG data in real time, detecting cardiac abnormalities such as arrhythmias. Due to their compact and convenient design, users can wear them on their chest or wrist without affecting daily activities. Furthermore, these devices typically have Bluetooth or wireless connectivity, allowing real-time transmission of ECG data to smartphones or cloud platforms, facilitating remote medical monitoring and home health management, and providing strong support for the prevention and early detection of heart disease. The current trend of an aging population further necessitates high-performance, high-precision signal processing and data analysis algorithms for effective monitoring of human health.
[0003] Cardiovascular disease is a leading cause of death, and modern medicine typically uses electrocardiogram (ECG) signals as a non-invasive diagnostic tool for cardiovascular diseases. Currently, many medical technologies are available for monitoring arrhythmias, but most are used for clinical diagnosis. For example, hospitals use 12-lead ECG devices to record and reflect the heart's electrical activity by placing electrodes on different parts of the body to examine for heart-related diseases. These methods are not suitable for remote real-time health monitoring. Wearable single-lead ECG devices are now used for remote cardiac health monitoring, but their practical application is not ideal due to the large number of nonlinear and non-smooth features in ECG signals, as well as limitations imposed by individual differences, data acquisition noise, and algorithms. Therefore, there is an urgent need to research an algorithm to achieve high-accuracy classification of single-lead ECGs for real-time monitoring of cardiac status. Summary of the Invention
[0004] The purpose of this invention is to provide an accurate, efficient, and real-time method and system for detecting arrhythmias using a single-lead electrocardiogram based on adaptive attention, enabling wearable single-lead electrocardiogram devices to accurately identify the type of heart rhythm.
[0005] The technical solution to achieve the purpose of this 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: Extract the spatial and temporal features of the electrocardiogram signal using a multi-scale parallel spatiotemporal feature extraction module;
[0008] Step 3: Weight the temporal features using an adaptive attention mechanism;
[0009] Step 4: Concatenate 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 used to output classification results through a classifier containing stacked BiLSTM and multilayer perceptron;
[0011] Step 6: Iteratively train and optimize the parameters of the entire network to obtain the best classification results.
[0012] Furthermore, in step 1, the electrocardiogram data is preprocessed, specifically including:
[0013] The ECG data is denoised, oversampled and balanced, R-wave detection is used to segment the ECG data, and the dataset is divided into training and testing sets.
[0014] Furthermore, step 1 is specifically as follows:
[0015] First, discrete wavelet threshold noise reduction is performed on the electrocardiogram data;
[0016] Secondly, to address the class imbalance problem, the ADASYN method is used to adaptively generate synthetic samples to balance the class distribution;
[0017] Next, R-wave detection is performed, and the electrocardiogram (ECG) is divided into multiple segments based on the R-wave. The ECG signal and its corresponding real label are represented as follows: ,in This is an electrocardiogram (ECG) signal. For the corresponding heart rhythm type, ;
[0018] Finally, the dataset is divided into a training set and a test set, which account for 80% and 20% of the total dataset, respectively. Gaussian noise with a mean of 0 and a standard deviation of 0.1 is added to the training dataset.
[0019] Furthermore, the division of the electrocardiogram into multiple segments based on the R wave specifically involves:
[0020] Each heartbeat includes 100 sampling points before the R peak and 200 sampling points after the R peak. The heart 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. Temporal Feature Network The module consists of two sub-modules, each containing multiple branches with different sampling rates to extract spatial features at different scales. and time series characteristics .
[0022] Furthermore, the spatial feature network Specifically as follows:
[0023] Based on the dynamic characteristics of the electrocardiogram signal, maximum pooling is selected. and global average pooling Combining CNN to form two parallel spatial branches of the spatial feature network , The formula is shown below:
[0024]
[0025]
[0026] in, For input data, Here, ReLU activation function is used, and Conv1D represents one-dimensional convolution. The kernel size is [size]. The number of output channels is given by Deconvd, which represents the transposed convolution.
[0027] The temporal feature network Specifically as follows:
[0028] Combining dilated convolution and residual structures, feature capture at different granularities is achieved through varying dilation rates; three parallel convolutions are configured. , , Temporal branches yield temporal features , , , The formula is shown below:
[0029] ,
[0030] in, The main operation function, For skip connections, For input data, For expansion rate, The expansion rate of the three branches is , , .
[0031] Furthermore, in step 3, the temporal features obtained in step 2 are processed using an adaptive attention mechanism. We obtain the weighted results separately. The details are as follows:
[0032] To address the dynamic characteristics of electrocardiogram (ECG) signals in the time dimension, a three-level adaptive modeling scheme is established: a local branch L, a global branch G, and a convergent branch A; both the local branch and the convergent branch are... Data divided by local time windows The above operation, among which The sequence length of data in each window;
[0033] The formula for the adaptive attention mechanism is shown below:
[0034]
[0035] in, It is a local-global aggregated feature; in order to match The dimension, through Will Rescale to ; This represents the convolution operation. Indicates a splicing operation; For global branches, For local branches, This is an aggregate branch;
[0036] Local branches We use a one-dimensional convolution to slide along the time dimension, focusing on time series features within a time window, and learn importance weights based on the local time window, as shown in the following formula:
[0037]
[0038] in, This represents element-wise multiplication, with sigmoid as the activation function. To reduce computational complexity, the number of output channels for the first convolution is reduced to [number missing]. The second convolution restores the number of output channels to... ;
[0039] Global branch Using a self-attention mechanism, the importance of each time step in the sequence is dynamically learned globally to capture long-term dependencies, as shown in the following formula:
[0040]
[0041] , , These are the transpose of the query vector, the key vector, and the value vector, respectively. Obtained by linear transformation; The dimension of the key vector is denoted by ; softmax is the activation function; the result obtained from the global branch is divided using a local time window. Then with local features splicing and fusion;
[0042] Aggregate branches The network with two fully connected layers is guided to learn adaptive convolutional kernels within a local time window for adaptive aggregation of global and local features, as shown in the following formula:
[0043]
[0044]
[0045] in, , To adapt the kernel size, For the number of channels, It is used in a convolutional manner to achieve aggregation from the channel dimension; , For fully connected layers The weights are denoted by , and softmax is the activation function. It is a global-local aggregation feature.
[0046] Furthermore, step 4 involves concatenating and fusing the spatial features and weighted temporal features, and integrating cross-channel information to obtain spatiotemporal fusion features, as detailed below:
[0047] spatial features Temporal features processed by adaptive attention mechanism The fusion forms a spatiotemporal fusion feature that incorporates spatial and temporal information. The formula is shown below:
[0048]
[0049] in, , For spatial features, For temporal features; using a convolution kernel of 1, with an output channel of... One-dimensional convolution performs linear transformation on splicing and fusion features to achieve cross-channel information integration.
[0050] Furthermore, the spatiotemporal fusion features described in step 5 output classification results through a classifier comprising stacked BiLSTM and multilayer perceptron, as detailed below:
[0051] Sequence learning is performed on spatiotemporal fusion features using stacked BiLSTMs, and the MLP is responsible for mapping these features to the final classification result; the classification model uses... For input, For output, , The predicted label refers to the corresponding electrocardiogram signal; therefore, the arrhythmia classification task can be described as a function transformation that, given the input... Find the corresponding output The process; the goal of model classification is to minimize the network predictions. and reality Cross-entropy loss between:
[0052]
[0053] in, The number of samples; This represents the probability distribution of a sample belonging to category y given a certain input feature X; This represents the probability distribution of a sample belonging to class z given a certain input feature X; For indicator functions, Otherwise, it is 0.
[0054] A single-lead electrocardiogram (ECG) arrhythmia detection system based on adaptive attention is disclosed. This system implements the aforementioned single-lead ECG 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 and fusion module, a classifier module, and an iterative optimization module, wherein:
[0055] The preprocessing module preprocesses the electrocardiogram data;
[0056] A multi-scale parallel spatiotemporal feature extraction module is used to extract spatial and temporal features of electrocardiogram signals;
[0057] The weighting module is used to weight temporal features through an adaptive attention mechanism;
[0058] The splicing and fusion module is used to splice and fuse spatial features and weighted temporal features, and to integrate cross-channel information to obtain spatiotemporal fusion features;
[0059] The classifier module outputs classification results through a classifier containing stacked BiLSTM and multilayer perceptron, based on spatiotemporal fusion features.
[0060] The iterative optimization module iteratively trains and optimizes the parameters of the entire network to obtain the best classification results.
[0061] Compared with the prior art, the present invention has the following significant advantages: (1) It uses a spatiotemporal feature parallel extraction network and an adaptive attention mechanism combined with a multi-scale structure to achieve cross-scale control of the model, so that the model focuses on more discriminative information and improves the accuracy of classification; (2) The spatiotemporal feature extraction module has high efficiency and strong flexibility, and can be flexibly loaded into the existing network framework, with good portability and robustness; (3) It adopts a cross-scale global-local temporal attention integration strategy to extract features from multiple scales, and combines dilated convolution to reduce data redundancy, and combines residual structure to solve the gradient vanishing problem of deep networks, thereby improving the classification speed and final effect of the network. Attached Figure Description
[0062] Figure 1 This is a flowchart of a single-lead electrocardiogram arrhythmia detection method based on adaptive attention.
[0063] Figure 2 This diagram illustrates the specific implementation process of a single-lead electrocardiogram arrhythmia detection method based on adaptive attention.
[0064] Figure 3 This is a diagram showing the specific structure of the network model for a single-lead electrocardiogram arrhythmia detection method based on adaptive attention.
[0065] Figure 4 This is a graph showing the changes in Loss value and accuracy during the testing process in an embodiment of the present invention. Detailed Implementation
[0066] To make the objectives, technical solutions, and advantages of this application clearer, the following detailed description is provided in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative and not intended to limit the scope of this application.
[0067] Combination Figures 1-3 The present invention provides a single-lead electrocardiogram arrhythmia detection method based on adaptive attention, comprising the following steps:
[0068] Step 1: Preprocess the electrocardiogram data;
[0069] Step 2: Extract the spatial and temporal features of the electrocardiogram signal using a multi-scale parallel spatiotemporal feature extraction module;
[0070] Step 3: Weight the temporal features using an adaptive attention mechanism;
[0071] Step 4: Concatenate and fuse the spatial features and weighted temporal features, and integrate cross-channel information to obtain spatiotemporal fusion features;
[0072] Step 5: The spatiotemporal fusion features are used to output classification results through a classifier containing stacked BiLSTM and multilayer perceptron;
[0073] Step 6: Iteratively train and optimize the parameters of the entire network to obtain the best classification results.
[0074] To more clearly illustrate the functional characteristics and structural parameters of the present invention, further explanation is provided below in conjunction with the accompanying drawings and specific embodiments.
[0075] As a specific example, step 1 involves preprocessing the electrocardiogram (ECG) data, specifically including:
[0076] First, discrete wavelet threshold noise reduction is performed on the electrocardiogram data;
[0077] Secondly, to address the class imbalance problem, the ADASYN method is used to adaptively generate synthetic samples to balance the class distribution;
[0078] Next, R-wave detection is performed, and the electrocardiogram (ECG) is divided into multiple segments based on the R-wave. The ECG signal and its corresponding real label are represented as follows: ,in This is an electrocardiogram (ECG) signal. For the corresponding heart rhythm type, ;
[0079] Finally, the dataset was divided into a training set and a test set, which accounted for 80% and 20% of the total dataset, respectively. To improve the robustness of the model, Gaussian noise with a mean of 0 and a standard deviation of 0.1 was added to the training dataset.
[0080] As a specific example, the division of the electrocardiogram into multiple segments based on the R wave is as follows:
[0081] Each heartbeat includes 100 sampling points before the R peak and 200 sampling points after the R peak. The heart 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.
[0082] As a specific example, in step 2, the multi-scale parallel spatiotemporal feature extraction module includes a spatial feature network. Temporal Feature Network The module consists of two sub-modules, each containing multiple branches with different sampling rates to extract spatial features at different scales. and time series characteristics .
[0083] As a specific example, preprocessed electrocardiogram signals Simultaneously, the inputs are fed into two sub-modules of the multi-scale parallel spatiotemporal feature extraction module: the spatial feature network. Temporal Feature Network .
[0084] The spatial feature network Specifically as follows:
[0085] Based on the dynamic characteristics of the electrocardiogram signal, maximum pooling is selected. and global average pooling Combining CNN to form two parallel spatial branches of the spatial feature network , The formula is shown below:
[0086]
[0087]
[0088] in, For input data, Here, ReLU activation function is used, and Conv1D represents one-dimensional convolution. The kernel size is [size]. The number of output channels is given by Deconvd, which represents the transposed convolution.
[0089] The temporal feature network Specifically as follows:
[0090] By combining dilated convolution and residual structures, features of different granularities are captured through varying dilation rates. Considering both real-time performance and accuracy, three parallel convolutional layers are configured. , , Temporal branches yield temporal features , , , The formula is shown below:
[0091] ,
[0092] in, The main operation function, For skip connections, For input data, For expansion rate, The expansion rate of the three branches is , , .
[0093] As a specific example, in step 3, the temporal features obtained in step 2 are processed using an adaptive attention mechanism. We obtain the weighted results separately. The details are as follows:
[0094] To address the dynamic characteristics of electrocardiogram (ECG) signals in the time dimension, a three-level adaptive modeling scheme is established: a local branch L, a global branch G, and a convergent branch A; both the local branch and the convergent branch are... Data divided by local time windows The above operation, among which The sequence length of data in each window;
[0095] The formula for the adaptive attention mechanism is shown below:
[0096]
[0097] in, It is a local-global aggregated feature; in order to match The dimension, through Will Rescale to ; This represents the convolution operation. Indicates a splicing operation; For global branches, For local branches, This is an aggregate branch;
[0098] Local branches We use a one-dimensional convolution to slide along the time dimension, focusing on time series features within a time window, and learn importance weights based on the local time window, as shown in the following formula:
[0099]
[0100] in, This represents element-wise multiplication, with sigmoid as the activation function. To reduce computational complexity, the number of output channels for the first convolution is reduced to [number missing]. The second convolution restores the number of output channels to... ;
[0101] Global branch Using a self-attention mechanism, the importance of each time step in the sequence is dynamically learned globally to capture long-term dependencies, as shown in the following formula:
[0102]
[0103] , , These are the transpose of the query vector, the key vector, and the value vector, respectively. Obtained by linear transformation; The dimension of the key vector is denoted by ; softmax is the activation function; the result obtained from the global branch is divided using a local time window. Then with local features splicing and fusion;
[0104] Aggregate branches A network with two fully connected layers is guided to learn adaptive convolutional kernels within a local time window for adaptive aggregation of global and local features. This addresses the problem that fixed convolutional kernels cannot describe the complex dynamic changes in electrocardiogram signals. The formula is shown below:
[0105]
[0106]
[0107] in, , To adapt the kernel size, For the number of channels, It is used in a convolutional manner to achieve aggregation from the channel dimension; , For fully connected layers The weights are denoted by , and softmax is the activation function. It is a global-local aggregation feature.
[0108] As a specific example, step 4 involves concatenating and fusing spatial features and weighted temporal features, and then integrating cross-channel information to obtain spatiotemporal fusion features, as detailed below:
[0109] spatial features Temporal features processed by adaptive attention mechanism The fusion forms a spatiotemporal fusion feature that incorporates spatial and temporal information. The formula is shown below:
[0110]
[0111] in, , For spatial features, For temporal features; using a convolution kernel of 1, with an output channel of... One-dimensional convolution performs linear transformation on splicing and fusion features to achieve cross-channel information integration.
[0112] As a specific example, the spatiotemporal fusion features described in step 5 output classification results through a classifier containing stacked BiLSTM and multilayer perceptron, as follows:
[0113] The bidirectional nature of BiLSTM allows the model to simultaneously capture forward and backward dependencies in a sequence. Stacked BiLSTMs are used for further sequence learning of spatiotemporal fusion features, while the MLP is responsible for mapping these complex features to the final classification result. The classification model uses... For input, For output, , The predicted label refers to the corresponding electrocardiogram signal; therefore, the arrhythmia classification task can be described as a function transformation that, given the input... Find the corresponding output The process; the goal of model classification is to minimize the network predictions. and reality Cross-entropy loss between:
[0114]
[0115] in, The number of samples; This represents the probability distribution of a sample belonging to category y given a certain input feature X; This represents the probability distribution of a sample belonging to class z given a certain input feature X; For indicator functions, Otherwise, it is 0.
[0116] As a specific example, step 6 involves iterative training to optimize the parameters of the entire network to obtain the best classification results, as detailed below:
[0117] The model is trained iteratively using backpropagation to update its parameters, following the typical deep learning process, until the optimal model classification performance is obtained through testing. This optimal model is then used for heart rhythm classification. The invention will be further described in detail below with reference to the accompanying drawings and specific embodiments.
[0118] This invention also provides a single-lead electrocardiogram arrhythmia detection system based on adaptive attention. This system is used to implement the aforementioned 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 and fusion module, a classifier module, and an iterative optimization module, wherein:
[0119] The preprocessing module preprocesses the electrocardiogram data;
[0120] A multi-scale parallel spatiotemporal feature extraction module is used to extract spatial and temporal features of electrocardiogram signals;
[0121] The weighting module is used to weight temporal features through an adaptive attention mechanism;
[0122] The splicing and fusion module is used to splice and fuse spatial features and weighted temporal features, and to integrate cross-channel information to obtain spatiotemporal fusion features;
[0123] The classifier module outputs classification results through a classifier containing stacked BiLSTM and multilayer perceptron, based on spatiotemporal fusion features.
[0124] The iterative optimization module iteratively trains and optimizes the parameters of the entire network to obtain the best classification results.
[0125] The present invention will be further described in detail below with reference to the accompanying drawings and specific embodiments.
[0126] Example
[0127] This embodiment uses an open-source electrocardiogram dataset to experimentally verify the present invention.
[0128] Using an open-source dataset, five types of atrial contractions were classified: N (normal beats), A (premature atrial contractions), V (atrial escape beats), L (left bundle branch block), and R (right bundle branch block). When analyzing algorithm performance, the loss value was used to observe the convergence effect, and the accuracy was used to observe the classification effect.
[0129] Figure 4 This is a graph showing the changes in Loss value and accuracy during the testing process in this embodiment. (Source: [Graphic data would be inserted here]) Figure 4 As shown in (b), the Loss value gradually decreases with the increase of the number of training rounds, and eventually approaches 0. Figure 4 As shown in (a), the classification accuracy also improved from less than 75% initially to nearly 99.6%. Furthermore, the processing time for a single heartbeat is much less than 1 second.
[0130] In summary, the method of this invention can improve the accuracy and real-time performance of arrhythmia classification using single-lead ECG data. It can be widely applied in various fields such as remote medical monitoring, home health management, and sports and health tracking.
[0131] The technical features of the above embodiments can be combined in any way. For the sake of brevity, 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] In summary, the method of this invention can improve the accuracy and real-time performance of arrhythmia classification using single-lead ECG data, reducing the misdiagnosis rate. This invention can enhance the ability of portable wearable single-lead ECG devices to identify heart rhythm categories and can be widely applied in various fields such as remote medical monitoring, home health management, and sports and health tracking.
[0133] The technical features of the above embodiments can be combined in any way. For the sake of brevity, 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.
[0134] The embodiments described above are merely illustrative of several implementation methods of this application, and while the descriptions are relatively specific and detailed, they should not be construed as limiting the scope of the invention patent. It should be noted that those skilled in the art can make various modifications and improvements without departing from the concept of this application, and these all fall within the protection scope of this application. Therefore, the protection scope of this patent application should be determined by the appended claims.
Claims
1. A method for detecting single-lead electrocardiogram arrhythmias based on adaptive attention, characterized in that, Includes the following steps: Step 1: Preprocess the electrocardiogram data; Step 2: Extract the spatial and temporal features of the electrocardiogram signal using a multi-scale parallel spatiotemporal feature extraction module; The multi-scale parallel spatiotemporal feature extraction module includes a spatial feature network. Temporal Feature Network The module consists of two sub-modules, each containing multiple branches with different sampling rates to extract spatial features at different scales. and time series characteristics ; Step 3: Weight the temporal features using an adaptive attention mechanism, specifically as follows: The temporal features obtained in step 2 are processed using an adaptive attention mechanism. We obtain the weighted results separately. The details are as follows: To address the dynamic characteristics of electrocardiogram (ECG) signals in the time dimension, a three-level adaptive modeling scheme is established: a local branch L, a global branch G, and a convergent branch A; both the local branch and the convergent branch are... Data divided by local time windows The above operation, among which The sequence length of data in each window; The formula for the adaptive attention mechanism is shown below: in, It is a local-global aggregated feature; in order to match The dimension, through Will Rescale to ; This represents the convolution operation. Indicates a splicing operation; For global branches, For local branches, This is an aggregate branch; Local branches We use a one-dimensional convolution to slide along the time dimension, focusing on time series features within a time window, and learn importance weights based on the local time window, as shown in the following formula: in, This represents element-wise multiplication, with sigmoid as the activation function. To reduce computational complexity, the number of output channels for the first convolution is reduced to [number missing]. The second convolution restores the number of output channels to... ; Global branch Using a self-attention mechanism, the importance of each time step in the sequence is dynamically learned globally to capture long-term dependencies, as shown in the following formula: , , These are the transpose of the query vector, the key vector, and the value vector, respectively. Obtained by linear transformation; The dimension of the key vector is denoted by ; softmax is the activation function; the result obtained from the global branch is divided using a local time window. Then with local features splicing and fusion; Aggregate branches The network with two fully connected layers is guided to learn adaptive convolutional kernels within a local time window for adaptive aggregation of global and local features, as shown in the following formula: in, , To adapt the kernel size, For the number of channels, It is used in a convolutional manner to achieve aggregation from the channel dimension; , For fully connected layers The weights are denoted by , and softmax is the activation function. It is a global-local aggregation feature; Step 4: Concatenate 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 used to output classification results through a classifier containing stacked BiLSTM and multilayer perceptron; Step 6: Iteratively train and optimize the parameters of the entire network to obtain the best classification results.
2. The method for detecting single-lead electrocardiogram arrhythmias based on adaptive attention according to claim 1, characterized in that, Step 1 involves preprocessing the electrocardiogram (ECG) data, specifically including: The ECG data is denoised, oversampled and balanced, R-wave detection is used to segment the ECG data, and the dataset is divided into training and testing sets.
3. The method for detecting single-lead electrocardiogram arrhythmias based on adaptive attention according to claim 2, characterized in that, Step 1 is described in detail as follows: First, discrete wavelet threshold noise reduction is performed on the electrocardiogram data; Secondly, to address the class imbalance problem, the ADASYN method is used to adaptively generate synthetic samples to balance the class distribution; Next, R-wave detection is performed, and the electrocardiogram (ECG) is divided into multiple segments based on the R-wave. The ECG signal and its corresponding real label are represented as follows: ,in This is an electrocardiogram (ECG) signal. For the corresponding heart rhythm type, ; Finally, the dataset is divided into a training set and a test set, which account for 80% and 20% of the total dataset, respectively. Gaussian noise with a mean of 0 and a standard deviation of 0.1 is added to the training dataset.
4. The method for detecting single-lead electrocardiogram arrhythmias based on adaptive attention according to claim 3, characterized in that, The process of dividing the electrocardiogram into multiple segments based on the R wave is as follows: Each heartbeat includes 100 sampling points before the R peak and 200 sampling points after the R peak. The heart 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 method for detecting single-lead electrocardiogram arrhythmias based on adaptive attention according to claim 4, characterized in that, The spatial feature network Specifically as follows: Based on the dynamic characteristics of the electrocardiogram signal, maximum pooling is selected. and global average pooling Combining CNN to form two parallel spatial branches of the spatial feature network , The formula is shown below: in, For input data, Here, ReLU activation function is used, and Conv1D represents one-dimensional convolution. The kernel size is [size]. The number of output channels is given by Deconvd, which represents the transposed convolution. The temporal feature network Specifically as follows: Combining dilated convolution and residual structures, feature capture at different granularities is achieved through varying dilation rates; three parallel convolutions are configured. , , Temporal branches yield temporal features , , , The formula is shown below: , in, The main operation function, For skip connections, For input data, For expansion rate, The expansion rate of the three branches is , , .
6. The method for detecting single-lead electrocardiogram arrhythmias based on adaptive attention according to claim 5, characterized in that, Step 4 involves concatenating and fusing spatial features and weighted temporal features, and integrating cross-channel information to obtain spatiotemporal fusion features, as detailed below: spatial features Temporal features processed by adaptive attention mechanism The fusion forms a spatiotemporal fusion feature that incorporates spatial and temporal information. The formula is shown below: in, , For spatial features, For temporal features; using a convolution kernel of 1, with an output channel of... One-dimensional convolution performs linear transformation on splicing and fusion features to achieve cross-channel information integration.
7. The method for detecting single-lead electrocardiogram arrhythmias based on adaptive attention according to claim 6, characterized in that, The spatiotemporal fusion features described in step 5 output classification results through a classifier containing stacked BiLSTM and multilayer perceptron, as detailed below: Sequence learning is performed on spatiotemporal fusion features using stacked BiLSTMs, and the MLP is responsible for mapping these features to the final classification result; the classification model uses... For input, For output, , The predicted label refers to the corresponding electrocardiogram signal; therefore, the arrhythmia classification task can be described as a function transformation that, given the input... Find the corresponding output The process; the goal of model classification is to minimize the network predictions. and reality Cross-entropy loss between: in, The number of samples; This represents the probability distribution of a sample belonging to category y given a certain input feature X; This represents the probability distribution of a sample belonging to class z given a certain input feature X; For indicator functions, Otherwise, it is 0.
8. A single-lead electrocardiogram arrhythmia detection system based on adaptive attention, characterized in that, This 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 7. 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: The preprocessing module preprocesses the electrocardiogram data; A multi-scale parallel spatiotemporal feature extraction module is used to extract spatial and temporal features of electrocardiogram signals; The weighting module is used to weight temporal features through an adaptive attention mechanism; The splicing and fusion module is used to splice and fuse spatial features and weighted temporal features, and to integrate cross-channel information to obtain spatiotemporal fusion features; The classifier module outputs classification results through a classifier containing stacked BiLSTM and multilayer perceptron, based on spatiotemporal fusion features. The iterative optimization module iteratively trains and optimizes the parameters of the entire network to obtain the best classification results.