Electrocardiosignal classification method and device based on multi-branch weighted attention and medium
By using a multi-branch weighted attention network to automatically weighted fusion of multi-lead ECG signals in the electrocardiogram classification method, the shortcomings of single-cardiogram training and insufficient feature extraction of multi-lead ECG data in the prior art are solved. The problem of this has achieved higher accuracy in ECG classification and better classification ability for a few types of heart diseases.
Patent Information
- Application Number
- CN202411472631.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-10-22
- Publication Date
- 2025-02-18
AI Technical Summary
The existing ECG signal classification method is based on single-center shooting training, and cannot effectively utilize multi-center shooting data, resulting in low classification accuracy of a few types of heart diseases, and insufficient feature extraction of multi-lead ECG data, ignoring repeated features, affecting cardiovascular status The accuracy of the information.
Using a method based on a multi-branch weighted attention network, the multi-lead electrocardiogram signals are automatically weighted and fusion features are extracted and fused through a multi-branch automatic weighted splicing module, a triple attention feature fusion module and multiple convolutional networks. Improve the accuracy of classification results.
Through the automatic weighted fusion of the characteristics of the multi-branch weighted attention network, the accuracy of the classification results of ECG signals can be effectively improved, and is suitable for multi-lead ECG data, improving the classification ability and cardiovascular status information of a few types of heart diseases accuracy.
Smart Images

Figure CN119454048A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to but is not limited to the field of electrocardiogram signal detection technology, and in particular to an electrocardiogram signal classification method, device, and medium based on multi-branch weighted attention. Background Art
[0002] The electrocardiogram is a reliable non-invasive diagnostic tool that is widely used to screen and evaluate cardiac abnormalities. It characterizes the electrophysiological patterns of myocardial depolarization and repolarization during each heartbeat. Among them, the 12-lead electrocardiogram is the most commonly used type of electrocardiogram, which has a wide range of clinical applications and can provide cardiologists with important information about the patient's cardiovascular status. After obtaining the electrocardiogram, cardiologists or doctors need to manually analyze the electrocardiogram signals. Disease screening requires rich clinical experience and a lot of time, which is inefficient. Based on this, the existing methods use deep learning or machine learning to process electrocardiogram signals to obtain cardiovascular status information, providing effective auxiliary information for doctors to diagnose heart diseases. However, most of the existing studies are based on single-beat training, which is inconsistent with the multi-beat electrocardiogram data required for clinical examinations, and the classification accuracy for some minority heart diseases is not high; and the existing feature extraction method for multi-lead electrocardiogram data is to use a deep convolutional network for extraction. The feature extraction is not sufficient and the occurrence of repeated features is ignored, resulting in poor accuracy of the obtained cardiovascular status information. Summary of the invention
[0003] The embodiments of the present application provide a method, device, and medium for classifying ECG signals based on multi-branch weighted attention, which can improve the accuracy of ECG signal analysis results.
[0004] In a first aspect, an embodiment of the present application provides an electrocardiogram signal classification method based on multi-branch weighted attention, comprising:
[0005] Acquire multiple groups of ECG data, each group of the ECG data includes multiple first multi-lead ECG signals, the classification labels corresponding to the first multi-lead ECG signals in the same group of the ECG data are the same, and the classification labels corresponding to the first multi-lead ECG signals belonging to different groups of the ECG data are different from each other;
[0006] Performing denoising processing on all of the first multi-lead ECG signals based on a preset denoising algorithm to obtain a second multi-lead ECG signal;
[0007] Dividing all of the second multi-lead ECG signals to obtain a training set and a test set;
[0008] Using the training set to train a preset multi-branch weighted attention network to obtain a trained ECG signal classification model, wherein the ECG signal classification model includes a multi-branch automatic weighted splicing module, a triple attention feature fusion module and a plurality of convolutional networks, and the number of the convolutional networks is equal to the number of leads of the second multi-lead ECG signal in the test set;
[0009] The test set is input into the ECG signal classification model to obtain the corresponding target ECG signal classification result.
[0010] In some embodiments, performing denoising on all of the first multi-lead ECG signals based on a preset denoising algorithm to obtain a second multi-lead ECG signal includes:
[0011] Performing multi-level decomposition on the first multi-lead ECG signal to obtain multiple signal components;
[0012] Calculating detail coefficients and approximate coefficients corresponding to each of the signal components, and obtaining corresponding wavelet components and detail components based on the detail coefficients and the approximate coefficients, wherein the wavelet components are used to indicate high-frequency components of the first multi-lead ECG signal, and the detail components are used to indicate low-frequency components of the first multi-lead ECG signal;
[0013] The wavelet component and the detail component are subjected to inverse wavelet transformation and reorganized to obtain the second multi-lead electrocardiogram signal.
[0014] In some embodiments, each of the second multi-lead ECG signals further corresponds to a user label, and all of the second multi-lead ECG signals are divided to obtain a training set and a test set, including:
[0015] Randomly shuffle all of the second multi-lead ECG signals to obtain shuffled second multi-lead ECG signals;
[0016] The shuffled second multi-lead ECG signal is divided into the training set and the test set according to a preset ratio, wherein the user label corresponding to the second multi-lead ECG signal in the test set is different from the user label of the second multi-lead ECG signal in the training set.
[0017] In some embodiments, the ECG signal classification model further includes a discard layer, a dimensionality reduction layer and a fully connected layer, each of the convolutional networks includes a preset number of one-dimensional deep neural network convolutional blocks, and the test set is input into the ECG signal classification model to obtain the corresponding target ECG signal classification result, including:
[0018] Inputting each lead signal in the second multi-lead ECG signal of the test set into each convolutional network for feature extraction to obtain a plurality of first intermediate features;
[0019] Inputting all the first intermediate features into the multi-branch automatic weighted splicing module for splicing processing to obtain second intermediate features;
[0020] Inputting the second intermediate feature into the triple attention feature fusion module to obtain a third intermediate feature;
[0021] The second intermediate feature is input into the discard layer, the dimension reduction layer and the fully connected layer connected in sequence to obtain the target electrocardiogram signal classification result.
[0022] In some embodiments, all the first intermediate features are input into the multi-branch automatic weighted splicing module for splicing processing to obtain the second intermediate features, including:
[0023] Each of the first intermediate features is subjected to a dilated convolution branch to obtain the first sub-features corresponding to each of them;
[0024] The first intermediate features are stacked, and the stacked results are globally pooled to obtain a ninth intermediate feature;
[0025] The ninth intermediate feature is sequentially subjected to full connection layer dimensionality reduction, batch one processing, activation layer activation, and full connection layer dimensionality increase to obtain a tenth intermediate feature;
[0026] Inputting the tenth intermediate feature into a softmax layer to obtain a plurality of block weighted information, wherein the number of the block weighted information is the same as the number of the first intermediate features;
[0027] Multiplying each of the block weighted information with the corresponding first sub-feature to obtain corresponding eleventh intermediate features;
[0028] All of the eleventh intermediate features are passed through a convolutional layer to complete weighted feature branch splicing to obtain the second intermediate features.
[0029] In some embodiments, the triple attention feature fusion module includes a self-attention module, a spatial attention module, and a channel attention module, and the second intermediate feature is input into the triple attention feature fusion module to obtain a third intermediate feature, including:
[0030] Inputting the second intermediate features into the spatial attention module and the self-attention module in parallel respectively, to obtain local features and global features, wherein the local features are outputs of the spatial attention module, and the global features are outputs of the self-attention module;
[0031] The seventh intermediate feature obtained by adding the local feature and the global feature is input into the channel attention module for feature fusion to obtain the third intermediate feature.
[0032] In some embodiments, the spatial attention module includes a maximum pooling layer, an average pooling layer, an activation function layer, a convolution layer and a sigmiod layer, the self-attention module includes a first branch, a second branch, a third branch, an activation normalization layer, a second convolution layer and a second activation layer, the first branch, the second branch and the third branch all include a third convolution layer, and the second intermediate feature is input into the spatial attention module and the self-attention module in parallel to obtain local features and global features, including:
[0033] Inputting the second intermediate features into the maximum pooling layer and the average pooling layer of the spatial attention module respectively, and concatenating the output result of the maximum pooling layer with the output result of the average pooling layer to obtain a concatenated feature;
[0034] The concatenated features are passed through an activation function layer, a convolution layer, and a sigmiod layer to obtain a second sub-feature;
[0035] Performing a dot product of the concatenated feature and the second sub-feature to obtain the local feature;
[0036] Input the second intermediate feature into the third convolutional layer corresponding to the first branch, the second branch, and the third branch respectively, to obtain a fourth intermediate feature, a fifth intermediate feature, and a sixth intermediate feature;
[0037] Performing a cross product on the fourth intermediate feature and the fifth intermediate feature to obtain a first product result, and inputting the first product result to the activation normalization layer to obtain a seventh intermediate feature;
[0038] multiplying the seventh intermediate feature by the sixth intermediate feature to obtain a second product result;
[0039] The second product result is input into the second convolutional layer and the second activation layer connected in sequence to obtain the global feature.
[0040] In some embodiments, the channel attention module includes a global maximum pooling layer, a first one-dimensional convolution layer, an activation layer, a second one-dimensional convolution layer and a sigmiod layer, and the seventh intermediate feature obtained by adding the local feature and the global feature is input into the channel attention module for feature fusion to obtain the third intermediate feature, including:
[0041] The seventh intermediate feature is sequentially passed through a global maximum pooling layer, a first one-dimensional convolutional layer, an activation layer, a second one-dimensional convolutional layer and a sigmiod layer to obtain an eighth intermediate feature;
[0042] The third intermediate feature is obtained by performing a dot product of the seventh intermediate feature and the eighth intermediate feature.
[0043] In a second aspect, an embodiment of the present application provides an electronic device comprising at least one control processor and a memory for communicating with the at least one control processor; the memory stores instructions executable by the at least one control processor, and the instructions are executed by the at least one control processor so that the at least one control processor can execute the electrocardiogram signal classification method based on multi-branch weighted attention as described in the first aspect.
[0044] In a third aspect, an embodiment of the present application further provides a computer-readable storage medium storing computer-executable instructions, wherein the computer-executable instructions are used to execute the electrocardiogram signal classification method based on multi-branch weighted attention as described in the first aspect.
[0045] The embodiment of the present application provides an ECG signal classification method, device, and medium based on multi-branch weighted attention, the method comprising: obtaining multiple groups of ECG data, each group of the ECG data comprising multiple first multi-lead ECG signals, the classification labels corresponding to each of the first multi-lead ECG signals in the same group of the ECG data being the same, and the classification labels corresponding to the first multi-lead ECG signals belonging to different groups of the ECG data being different from each other; performing denoising on all of the first multi-lead ECG signals based on a preset denoising algorithm to obtain second multi-lead ECG signals; dividing all of the second multi-lead ECG signals to obtain a training set and a test set; using the training set to train a preset multi-branch weighted attention network to obtain a trained ECG signal classification model; inputting the test set into the ECG signal classification model to obtain the corresponding target ECG signal classification result. According to the scheme provided in the embodiment of the present application, the multi-lead ECG signals are automatically weighted and fused by using a multi-branch weighted attention network, which can effectively ensure the accuracy of the ECG signal classification results compared to the existing manual analysis or deep learning analysis schemes, and thus provide effective auxiliary information for doctors to diagnose heart diseases. BRIEF DESCRIPTION OF THE DRAWINGS
[0046] Figure 1 is a flowchart of the steps of an electrocardiogram signal classification method based on multi-branch weighted attention provided by an embodiment of the present application;
[0047] Figure 2 is a model architecture diagram of an electrocardiogram signal classification model provided by another embodiment of the present application;
[0048] Figure 3 It is a structural diagram of an electronic device provided in another embodiment of the present application. DETAILED DESCRIPTION
[0049] 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.
[0050] It is understood that although the functional modules are divided in the device schematic diagram and the logical order is shown in the flow chart, in some cases, the steps shown or described may be performed in a different order than the module division in the device or the order in the flow chart. The terms "first", "second", etc. in the specification, claims or the above drawings are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence.
[0051] The electrocardiogram is a reliable non-invasive diagnostic tool that is widely used to screen and evaluate cardiac abnormalities. It characterizes the electrophysiological patterns of myocardial depolarization and repolarization during each heartbeat. Among them, the 12-lead electrocardiogram is the most commonly used type of electrocardiogram, which has a wide range of clinical applications and can provide cardiologists with important information about the patient's cardiovascular status. After obtaining the electrocardiogram, cardiologists or doctors need to manually analyze the electrocardiogram signals. Disease screening requires rich clinical experience and a lot of time, which is inefficient. Based on this, the existing methods use deep learning or machine learning to process electrocardiogram signals to obtain cardiovascular status information, providing effective auxiliary information for doctors to diagnose heart diseases. However, most of the existing studies are based on single-beat training, which is inconsistent with the multi-beat electrocardiogram data required for clinical examinations, and the classification accuracy for some minority heart diseases is not high; and the existing feature extraction method for multi-lead electrocardiogram data is to use a deep convolutional network for extraction. The feature extraction is not sufficient and the occurrence of repeated features is ignored, resulting in poor accuracy of the obtained cardiovascular status information.
[0052] To solve the above-mentioned problems, an embodiment of the present application provides an ECG signal classification method, device, and medium based on multi-branch weighted attention, the method comprising: obtaining multiple groups of ECG data, each group of the ECG data comprising multiple first multi-lead ECG signals, the classification labels corresponding to each of the first multi-lead ECG signals in the same group of the ECG data being the same, and the classification labels corresponding to the first multi-lead ECG signals belonging to different groups of the ECG data being different; denoising all of the first multi-lead ECG signals based on a preset denoising algorithm to obtain second multi-lead ECG signals; dividing all of the second multi-lead ECG signals to obtain a training set and a test set; using the training set to train a preset multi-branch weighted attention network to obtain a trained ECG signal classification model; inputting the test set into the ECG signal classification model to obtain the corresponding target ECG signal classification result. According to the solution provided in the embodiment of the present application, the features of multi-lead ECG signals are automatically weighted and fused through a multi-branch weighted attention network. Compared with the existing manual analysis or deep learning analysis solutions, the correlation between multiple leads is obtained, which effectively ensures the accuracy of the ECG signal classification results, and further provides effective auxiliary information for doctors to diagnose heart diseases.
[0053] The embodiments of the present application are further described below in conjunction with the accompanying drawings.
[0054] refer to Figure 1 , Figure 1 This is a flowchart of a method for classifying ECG signals based on multi-branch weighted attention provided by an embodiment of the present application. The embodiment of the present application provides a method for classifying ECG signals based on multi-branch weighted attention, which includes but is not limited to the following steps:
[0055] Step S10, obtaining multiple groups of ECG data, each group of ECG data includes multiple first multi-lead ECG signals, the classification labels corresponding to the first multi-lead ECG signals in the same group of ECG data are the same, and the classification labels corresponding to the first multi-lead ECG signals belonging to different groups of ECG data are different.
[0056] It should be noted that the embodiment of the present application does not limit the sampling frequency and acquisition size of the ECG data, and can be an ECG sequence with a sampling frequency of 500 Hz and a length of 10s.
[0057] It should be noted that the classification labels of the ECG signals in the ECG data of different groups in this embodiment can be classified according to the AMMI standard, and no further restrictions are made here. Labeling the classification labels for the ECG signals can provide an effective data basis for the subsequent training of the ECG signal classification model, and thus provide effective auxiliary information for the diagnosis of heart disease.
[0058] Step S20: performing denoising processing on all first multi-lead ECG signals based on a preset denoising algorithm to obtain second multi-lead ECG signals.
[0059] Specifically, in some embodiments, Figure 1 Step S20 includes but is not limited to the following steps:
[0060] Step S21, performing multi-level decomposition on the first multi-lead ECG signal to obtain multiple signal components;
[0061] Step S22, calculating detail coefficients and approximate coefficients corresponding to each signal component, and obtaining corresponding wavelet components and detail components based on the detail coefficients and approximate coefficients, wherein the wavelet components are used to indicate high-frequency components of the first multi-lead ECG signal, and the detail components are used to indicate low-frequency components of the first multi-lead ECG signal;
[0062] Step S23, performing inverse wavelet transform and reorganization on the wavelet component and the detail component to obtain a second multi-lead ECG signal.
[0063] Specifically, the method for denoising the first multi-lead ECG signal in this embodiment is: performing multi-level decomposition on the first multi-lead ECG signal to obtain multiple signal components; calculating the detail coefficient and the approximate coefficient corresponding to each signal component, and obtaining the corresponding wavelet component and detail component based on the detail coefficient and the approximate coefficient, wherein the wavelet component is used to indicate the high-frequency component of the first multi-lead ECG signal, and the detail component is used to indicate the low-frequency component of the first multi-lead ECG signal; performing inverse wavelet transform and reorganization on the wavelet component and the detail component to obtain the second multi-lead ECG signal. It can be understood that since the first multi-lead ECG signal is easily interfered by various noises during the acquisition process, such as power frequency interference, myoelectric noise, baseline drift, etc. These noises will seriously affect the analysis of the first multi-lead ECG signal, and then affect the accuracy of the subsequent model training results. This embodiment uses the wavelet transform algorithm to denoise the original first multi-lead ECG signal, which can improve the signal quality of the second multi-lead ECG signal, improve the model performance, and enhance the model generalization ability, providing effective support for obtaining accurate ECG signal classification results in the future.
[0064] Step S30, dividing all second multi-lead ECG signals to obtain a training set and a test set.
[0065] Specifically, dividing the second multi-lead ECG signal into a training set and a test set can provide an effective data basis for training a multi-branch weighted attention network to obtain accurate ECG signal classification results.
[0066] Specifically, in some embodiments, each second multi-lead ECG signal also corresponds to a user tag. Figure 1 Step S30 includes but is not limited to the following steps:
[0067] Step S31, randomly shuffling all the second multi-lead ECG signals to obtain shuffled second multi-lead ECG signals;
[0068] Step S32, dividing the shuffled second multi-lead ECG signals into a training set and a test set according to a preset ratio, wherein the user labels corresponding to the second multi-lead ECG signals in the test set are different from the user labels of the second multi-lead ECG signals in the training set.
[0069] It should be noted that in this embodiment, the shuffled second multi-lead ECG signal is divided into a training set and a test set in a ratio of 9 to 1, and the user labels corresponding to the second multi-lead ECG signals in the test set are different from the user labels of the second multi-lead ECG signals in the training set, which can provide sufficient data for model training, while also retaining sufficient independent data (i.e., the test set) to evaluate the performance of the model. In addition, the user labels corresponding to the second multi-lead ECG signals in the test set are different from the user labels of the second multi-lead ECG signals in the training set, which can ensure that the test set and the training set are independent of each other and do not contain patient data that has been seen in the training set. This is to prevent the model from making predictions simply by memorizing specific patients or features in the training data during testing, rather than truly learning generalized feature recognition capabilities.
[0070] It should be noted that the second multi-lead ECG signal in this embodiment may be a 12-lead ECG sequence, and the specific type of the ECG signal is not limited here.
[0071] Step S40, using the training set to train the preset multi-branch weighted attention network to obtain a trained ECG signal classification model, wherein the ECG signal classification model includes a multi-branch automatic weighted splicing module, a triple attention feature fusion module and multiple convolutional networks, and the number of convolutional networks is equal to the number of leads of the second multi-lead ECG signal in the test set.
[0072] It can be understood that the training of the multi-branch weighted attention network in this embodiment can be to set a model convergence condition for the trained ECG signal classification model, such as a loss function value or the number of iterations. The selection of the specific loss function and the specific number of iterations are not limited in this embodiment. For example, the cross entropy loss function is used as the loss function. The cross entropy loss function formula is as follows:
[0073]
[0074] Where k is the number of categories and y is the label. If category is i, then y i=1, otherwise it is equal to 0, p is the final output, that is, the probability that category i is selected, and those skilled in the art can select it according to actual conditions.
[0075] In the specific example, the multi-branch weighted attention network is iteratively trained once using the training set, the loss function value of the ECG signal classification model obtained by the current training is calculated once, and the number of iterations is recorded. When the loss function value is less than a preset threshold, the training is stopped to obtain the trained ECG signal classification model, or when the number of iterations reaches a preset number, the training is stopped to obtain the trained ECG signal classification model.
[0076] Step S50, input the test set into the ECG signal classification model to obtain the corresponding target ECG signal classification result.
[0077] Specifically, in some embodiments, referring to Figure 2 In addition to the multi-branch automatic weighted splicing module, the triple attention feature fusion module and multiple convolutional networks, the ECG signal classification model also includes a dropout layer, a dimensionality reduction layer and a fully connected layer. Each convolutional network includes a preset number of one-dimensional deep neural network convolution blocks. Figure 1 Step S50 includes but is not limited to steps S51 to S54:
[0078] Step S51, input each lead signal in the second multi-lead ECG signal of the test set into each convolutional network for feature extraction to obtain multiple first intermediate features.
[0079] Specifically, Figure 2 As shown, each convolution network includes a preset number of one-dimensional deep neural network convolution blocks. Each convolution network (i.e., each branch) of this embodiment includes 8 one-dimensional deep neural network convolution blocks, wherein the first deep neural network convolution block performs a one-dimensional convolution with a convolution kernel of 3×3 on the input data, and passes through a batch normalization activation layer; the second to eighth deep neural network convolution blocks pass through a one-dimensional convolution layer with a convolution kernel of 3×3 and a step size of 1, and each deep neural network convolution block is short-circuited and added. When the second multi-lead ECG signal is a 12-lead ECG signal, the multi-branch automatic weighted splicing module will obtain 12 first intermediate features output by 12 branches (corresponding to 12 convolution networks) as input feature data.
[0080] Step S52: input all the first intermediate features into a multi-branch automatic weighted splicing module for splicing processing to obtain second intermediate features.
[0081] Specifically, step S52 of this embodiment includes but is not limited to the following steps:
[0082] Step S521, each first intermediate feature is subjected to a dilated convolution branch to obtain its corresponding first sub-feature;
[0083] Step S522, performing a superposition process on each of the first intermediate features, and performing a global pooling on the superposition process result to obtain a ninth intermediate feature;
[0084] Step S523, the ninth intermediate feature is sequentially subjected to fully connected layer dimension reduction, batch one processing, activation of the activation layer, and fully connected layer dimension increase to obtain a tenth intermediate feature;
[0085] Step S524, inputting the tenth intermediate feature into the softmax layer to obtain a plurality of block weighted information, wherein the number of the block weighted information is the same as the number of the first intermediate feature;
[0086] Step S525, multiplying each block weighted information with the corresponding first sub-feature to obtain the corresponding eleventh intermediate features;
[0087] Step S526, all the eleventh intermediate features are passed through the convolution layer to complete the weighted feature branch splicing to obtain the second intermediate features.
[0088] Specifically, in step S521, each first intermediate feature is passed through a hole convolution branch to obtain its corresponding first sub-feature. Each first intermediate feature passes through its own hole convolution branch, and each hole convolution branch performs a convolution operation on its own first intermediate feature through four convolution branches (convolution branch 1 with a convolution kernel of 1*1 and a dilation rate of 1, convolution branch 2 with a convolution kernel of 1*1 and a dilation rate of 1, convolution branch 3 with a convolution kernel of 3*3 and a dilation rate of 1, and convolution branch 4 with a convolution kernel of 3*3 and a dilation rate of 2) to obtain four branch features. After adding the four branch features, the corresponding lead branch feature, i.e., the first sub-feature, is obtained.
[0089] It should be noted that each first intermediate feature is superimposed, and the superimposed processing result is globally pooled to obtain the ninth intermediate feature, which is obtained according to the following formula:
[0090]
[0091] Among them, X i (B,C,H,1) are the first intermediate features, i is the number of lead signals in the second multi-lead ECG signal, and the number of lead signals in this embodiment is 12, and X gp (B,C,1,1) It is the ninth intermediate feature.
[0092] It should be noted that the ninth intermediate feature is sequentially subjected to full connection layer dimensionality reduction, batch one processing, activation layer activation, and full connection layer dimensionality increase to obtain the tenth intermediate feature, which is obtained according to the following formula:
[0093] X fc2(B,12*C,1,1) =Fc2(Relu(Bn(Fc1 (B,C',1,1) (X gp ))));
[0094] Among them, Fc1 (B,C',1,1) , Fc2 represents the dimension reduction and dimension increase of the fully connected layer respectively, Relu is the activation function of the activation layer, and Bn is the batch processing.
[0095] It should be noted that the tenth intermediate feature is input into the softmax layer to obtain multiple block weighted information, which is obtained according to the following formula:
[0096] X sf [i] (B,C,1,1) =Reshape(Chunk (B,1,C,1) (X sf ));
[0097] Among them, Chunk (B,1,C,1) Represents blocks, here corresponding to 12 blocks of 12 leads, Reshape is used to deform the weight information size to be consistent with the branch lead features, X sf [i] (B,C,1,1) Weight information for each block.
[0098] Specifically, each block weighted information is multiplied by the corresponding first sub-feature to obtain the corresponding eleventh intermediate features, which are obtained according to the following formula:
[0099] Y i =X sf [i]×X i ′;
[0100] Among them, X i ′ is the branch feature of each lead after the dilated convolution branch, i.e., the first sub-feature, Y i Next, each eleventh intermediate feature is further learned through a 1*1 convolution layer to complete the weighted feature branch concatenation and obtain the second intermediate feature.
[0101] Step S53, input the second intermediate feature into the triple attention feature fusion module to obtain the third intermediate feature.
[0102] It should be noted that the number of convolutional networks in this embodiment is determined according to the specific sequence form of the second multi-lead ECG signal input. Figure 2 The second multi-lead ECG signal of this embodiment is a 12-lead ECG sequence (lead I, lead II, ..., lead V6), and the corresponding ECG signal classification model has 12 convolutional networks, which can fully extract features for each lead sequence.
[0103] Specifically, the convolutional network of this embodiment serves as a branch for each lead, and each convolutional network contains 8 one-dimensional deep neural network convolution blocks, wherein the first convolutional block inputs data for a one-dimensional convolution with a convolution kernel of 3×3, passes through a batch normalization activation layer, and passes through a one-dimensional convolution layer with a convolution kernel of 3×3 and a step size of 1 in the second to eighth convolutional blocks, and then short-circuit addition is performed.
[0104] Specifically, in some embodiments, the triple attention feature fusion module includes a self-attention module, a spatial attention module, and a channel attention module, and the second intermediate feature is input into the triple attention feature fusion module to obtain the third intermediate feature, including but not limited to the following steps:
[0105] Step S531, inputting the second intermediate feature into the spatial attention module and the self-attention module in parallel respectively, to obtain local features and global features, wherein the local features are the output of the spatial attention module, and the global features are the output of the self-attention module;
[0106] Specifically, in one embodiment, the spatial attention module includes a maximum pooling layer, an average pooling layer, an activation function layer, a convolution layer and a sigmiod layer, the self-attention module includes a first branch, a second branch, a third branch, an activation normalization layer, a second convolution layer and a second activation layer, the first branch, the second branch and the third branch all include a third convolution layer, the second intermediate feature is input into the spatial attention module and the self-attention module respectively, and the steps of obtaining local features and global features include but are not limited to the following steps:
[0107] The second intermediate feature is input into the maximum pooling layer and the average pooling layer of the spatial attention module respectively, and the output result of the maximum pooling layer is concatenated with the output result of the average pooling layer to obtain the concatenated feature;
[0108] The concatenated features are passed through the activation function layer, convolution layer and sigmiod layer to obtain the second sub-feature;
[0109] Perform dot multiplication of the concatenated feature and the second sub-feature to obtain the local feature;
[0110] Input the second intermediate feature into the third convolutional layer corresponding to the first branch, the second branch, and the third branch respectively to obtain the fourth intermediate feature, the fifth intermediate feature, and the sixth intermediate feature;
[0111] Performing a cross product of the fourth intermediate feature and the fifth intermediate feature to obtain a first product result, and inputting the first product result to an activation normalization layer to obtain a seventh intermediate feature;
[0112] multiplying the seventh intermediate characteristic by the sixth intermediate characteristic to obtain a second product result;
[0113] The second product result is input into the second convolutional layer and the second activation layer connected in sequence to obtain the global feature.
[0114] It can be understood that the second intermediate feature is input into the maximum pooling layer and the average pooling layer of the spatial attention module respectively, and the output result of the maximum pooling layer is spliced with the output result of the average pooling layer to obtain the spliced feature; the spliced feature is input into the first activation layer and the first convolution layer with a convolution size of 1×1 connected in sequence to obtain the local feature The second intermediate feature is input into the third convolution layer with a convolution size of 1×1 corresponding to the first branch, the second branch and the third branch respectively, so that the number of channels C is divided by 2 to obtain F i C′×H×W (i=1,2,3) that is, the fourth intermediate feature, the fifth intermediate feature and the sixth intermediate feature are obtained; the fourth intermediate feature and the fifth intermediate feature are cross-producted to obtain the first product result, and the first product result is input into the activation normalization layer to obtain the seventh intermediate feature; the seventh intermediate feature is multiplied by the sixth intermediate feature to obtain the second product result; the second product result is input into the second convolution layer and the second activation layer with a convolution size of 1×1 connected in sequence to obtain the global feature. This provides an effective data foundation for subsequent input into the channel attention module for deeper feature mining.
[0115] Specifically, The calculation formula is as follows:
[0116]
[0117] Among them, F C×H×W To concatenate features, C×H×W are the number of feature channels, height, and width respectively, and the concat algorithm concatenates from the channel dimension.
[0118] Specifically, The calculation formula is as follows:
[0119]
[0120] in, The fourth intermediate feature F 1 C′×HW and the fifth intermediate feature F 1 HW×C′ The first product result obtained by cross product, F 3 C′×H×W is the sixth intermediate feature outputted by the third convolutional layer corresponding to the third branch, C′=C / 2, that is, the number of channels is divided by two, Conv 1×1 Represented as a convolution layer with a convolution kernel of 1×1.
[0121] Step S532, the seventh intermediate feature obtained by adding the local feature and the global feature is input into the channel attention module for feature fusion to obtain the third intermediate feature.
[0122] It can be understood that the local features extracted from the spatial attention and the global features extracted from the self-attention block obtain more important feature information in the process of using channel attention fusion, which provides effective support for obtaining accurate ECG signal classification results.
[0123] Specifically, in one embodiment, the step of inputting the local features and the global features into the channel attention module for feature fusion to obtain the third intermediate features includes but is not limited to the following steps:
[0124] The seventh intermediate feature is sequentially passed through a global maximum pooling layer, a first one-dimensional convolutional layer, an activation layer, a second one-dimensional convolutional layer and a sigmiod layer to obtain an eighth intermediate feature, and the seventh intermediate feature is dot-multiplied with the eighth intermediate feature to obtain the third intermediate feature.
[0125] Specifically, the third intermediate feature is obtained according to the following formula:
[0126]
[0127] Among them, F t C×H×W is the third intermediate feature, For the seventh intermediate feature, By the global feature F z C ×H×W With local features F k C×H×W Add together, C is the number of channels of the corresponding feature, H is the height of the corresponding feature, and W is the width of the corresponding feature.
[0128] Step S54, inputting the second intermediate feature into the discard layer, dimension reduction layer and full connection layer connected in sequence to obtain the target ECG signal classification result.
[0129] In addition, after determining the target ECG signal classification result, the method of this embodiment also includes verifying the accuracy of the target ECG signal classification result, specifically evaluating it based on the Acc value and AUC value (ie, the area under the macro ROC curve).
[0130] Specifically, the Acc value is calculated according to the following formula:
[0131]
[0132] Among them, TP, FP, TN and FN respectively represent the number of true positive samples, false positive samples, true negative samples and false negative samples determined by the classification results of each target ECG signal obtained based on the second multi-lead ECG signal in the test set and the classification results of the real target ECG signal. The number of true positive samples is the number of samples that are actually positive and judged as positive by the ECG signal classification model; the number of false positive samples is the number of samples that are actually negative but judged as positive by the ECG signal classification model; the number of true negative samples is the number of samples that are actually negative and judged as negative by the ECG signal classification model; the number of false negative samples is the number of samples that are actually positive and judged as negative by the ECG signal classification model. The accuracy of the target ECG signal classification result is determined by judging the Acc value and the preset accuracy threshold.
[0133] In addition, this embodiment also calculates the following parameters when evaluating the accuracy of the target ECG signal classification result:
[0134]
[0135] Since the positive predictive value and sensitivity are usually negatively correlated, it is incomplete to use these two evaluation indicators alone. The AUC value is the measurement of the area under the ROC curve, and the ROC curve is determined by calculating the TFP value and the FPR value. The false positive rate describes the x-axis of the coordinate system, while the true positive rate describes the y-axis of the coordinate system. When the AUC value is 0.5, it means that the ECG signal classification model does not have any category separation ability. When the AUC value is 1, it means that the ECG signal classification model has excellent category separation ability, that is, the larger the AUC value, the better the classification effect of the ECG signal classification model.
[0136] like Figure 3 As shown, Figure 3 3 is a structural diagram of an electronic device provided by an embodiment of the present application. The present invention also provides an electronic device 300, including:
[0137] The processor 310 may be implemented by a general-purpose central processing unit (CPU), a microprocessor, an application-specific integrated circuit (ASIC), or one or more integrated circuits, and is used to execute relevant programs to implement the technical solutions provided in the embodiments of the present application;
[0138] The memory 320 can be implemented in the form of a read-only memory (ROM), a static storage device, a dynamic storage device, or a random access memory (RAM). The memory 320 can store an operating system and other applications. When the technical solution provided in the embodiment of this specification is implemented by software or firmware, the relevant program code is stored in the memory 320, and the processor 310 calls and executes the electrocardiogram signal classification method based on multi-branch weighted attention in the embodiment of the present application;
[0139] Input / output interface 330, used to implement information input and output;
[0140] Communication interface 340, used to realize communication interaction between the apparatus and other devices, which can be realized by wired means (such as USB, network cable, etc.) or wireless means (such as mobile network, WIFI, Bluetooth, etc.);
[0141] bus 350 , which transmits information between the various components of the device (e.g., processor 310 , memory 320 , input / output interface 330 , and communication interface 340 );
[0142] The processor 310 , the memory 320 , the input / output interface 330 and the communication interface 340 are connected to each other in communication within the device via the bus 350 .
[0143] In addition, an embodiment of the present application also provides a storage medium, which is a computer-readable storage medium. The storage medium stores a computer program, and when the computer program is executed by a processor, it implements the above-mentioned electrocardiogram signal classification method based on multi-branch weighted attention.
[0144] As a non-transient computer-readable storage medium, the memory can be used to store non-transient software programs and non-transient computer executable programs. In addition, the memory may include a high-speed random access memory, and may also include a non-transient memory, such as at least one disk storage device, a flash memory device, or other non-transient solid-state storage devices. In some embodiments, the memory may optionally include a memory remotely arranged relative to the processor, and these remote memories may be connected to the processor via a network. Examples of the above-mentioned networks include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and a combination thereof. The device embodiments described above are merely schematic, wherein the units described as separate components may or may not be physically separated, and are implemented to be located in one place, or may also be distributed to multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the present embodiment.
[0145] It will be appreciated by those skilled in the art that all or some of the steps and systems in the disclosed method above may be implemented as software, firmware, hardware and appropriate combinations thereof. Some physical components or all physical components may be implemented as software executed by a processor, such as a central processing unit, a digital signal processor or a microprocessor, or may be implemented as hardware, or may be implemented as an integrated circuit, such as an application specific integrated circuit. Such software may be distributed on a computer-readable medium, which may include a computer storage medium (or a non-transitory medium) and a communication medium (or a temporary medium). As known to those skilled in the art, the term computer storage medium includes volatile and non-volatile, removable and non-removable media implemented in any method or technology for storing information (such as computer-readable instructions, data structures, program modules or other data). Computer storage media include, but are not limited to, RAM, ROM, EEPROM, flash memory or other memory technologies, CD-ROM, digital versatile disks (DVD) or other optical disk storage, magnetic cassettes, magnetic tapes, disk storage or other magnetic storage devices, or any other medium that may be used to store desired information and may be accessed by a computer. Furthermore, it is well known to those skilled in the art that communication media typically include computer readable instructions, data structures, program modules, or other data in a modulated data signal such as a carrier wave or other transport mechanism, and may include any information delivery media.
[0146] The above is a specific description of the preferred implementation of the present invention, but the present invention is not limited to the above-mentioned implementation mode. Technical personnel familiar with the field can also make various equivalent deformations or substitutions under the shared conditions without violating the spirit of the present invention. These equivalent deformations or substitutions are all included in the scope defined by the claims of the present invention.
Claims
1. A method for classifying electrocardiogram signals based on multi-branch weighted attention, characterized in that: include: Acquire multiple groups of ECG data, each group of the ECG data includes multiple first ECG signals, the classification labels corresponding to the first ECG signals in the same group of the ECG data are the same, and the classification labels corresponding to the first ECG signals belonging to different groups of the ECG data are different from each other; Performing denoising processing on all of the first multi-lead ECG signals based on a preset denoising algorithm to obtain a second multi-lead ECG signal; Dividing all of the second multi-lead ECG signals to obtain a training set and a test set; Using the training set to train a preset multi-branch weighted attention network to obtain a trained ECG signal classification model, wherein the ECG signal classification model includes a multi-branch automatic weighted splicing module, a triple attention feature fusion module and a plurality of convolutional networks, and the number of the convolutional networks is equal to the number of leads of the second multi-lead ECG signal in the test set; The test set is input into the ECG signal classification model to obtain the corresponding target ECG signal classification result.
2. The ECG signal classification method based on multi-branch weighted attention according to claim 1 is characterized in that: Performing denoising processing on all of the first multi-lead ECG signals based on a preset denoising algorithm to obtain a second multi-lead ECG signal, including: Performing multi-level decomposition on the first multi-lead ECG signal to obtain multiple signal components; Calculating detail coefficients and approximate coefficients corresponding to each of the signal components, and obtaining corresponding wavelet components and detail components based on the detail coefficients and the approximate coefficients, wherein the wavelet components are used to indicate high-frequency components of the first multi-lead ECG signal, and the detail components are used to indicate low-frequency components of the first multi-lead ECG signal; The wavelet component and the detail component are subjected to inverse wavelet transformation and reorganized to obtain the second multi-lead electrocardiogram signal.
3. The ECG signal classification method based on multi-branch weighted attention according to claim 1, characterized in that: Each of the second multi-lead ECG signals also corresponds to a user label, and all of the second multi-lead ECG signals are divided to obtain a training set and a test set, including: Randomly shuffle all of the second multi-lead ECG signals to obtain shuffled second multi-lead ECG signals; The shuffled second multi-lead ECG signal is divided into the training set and the test set according to a preset ratio, wherein the user label corresponding to the second multi-lead ECG signal in the test set is different from the user label of the second multi-lead ECG signal in the training set.
4. The ECG signal classification method based on multi-branch weighted attention according to claim 1, characterized in that: The ECG signal classification model further includes a discard layer, a dimensionality reduction layer and a fully connected layer, each of the convolutional networks includes a preset number of one-dimensional deep neural network convolutional blocks, and the test set is input into the ECG signal classification model to obtain the corresponding target ECG signal classification result, including: Inputting each lead signal in the second multi-lead ECG signal of the test set into each convolutional network for feature extraction to obtain a plurality of first intermediate features; Inputting all the first intermediate features into the multi-branch automatic weighted splicing module for splicing processing to obtain second intermediate features; Inputting the second intermediate feature into the triple attention feature fusion module to obtain a third intermediate feature; The second intermediate feature is input into the discard layer, the dimension reduction layer and the fully connected layer connected in sequence to obtain the target electrocardiogram signal classification result.
5. The ECG signal classification method based on multi-branch weighted attention according to claim 4 is characterized in that: Inputting all the first intermediate features into the multi-branch automatic weighted splicing module for splicing processing to obtain the second intermediate features, including: Each of the first intermediate features is subjected to a dilated convolution branch to obtain the first sub-features corresponding to each of them; Performing a superposition process on each of the first intermediate features, and performing a global pooling process on the superposition result to obtain a ninth intermediate feature; The ninth intermediate feature is sequentially subjected to full connection layer dimensionality reduction, batch one processing, activation layer activation, and full connection layer dimensionality increase to obtain a tenth intermediate feature; Inputting the tenth intermediate feature into a softmax layer to obtain a plurality of block weighted information, wherein the number of the block weighted information is the same as the number of the first intermediate features; Multiplying each of the block weighted information with the corresponding first sub-feature to obtain corresponding eleventh intermediate features; All of the eleventh intermediate features are passed through a convolutional layer to complete weighted feature branch splicing to obtain the second intermediate features.
6. The ECG signal classification method based on multi-branch weighted attention according to claim 4, characterized in that: The triple attention feature fusion module includes a self-attention module, a spatial attention module and a channel attention module, and the second intermediate feature is input into the triple attention feature fusion module to obtain a third intermediate feature, including: Inputting the second intermediate features into the spatial attention module and the self-attention module in parallel respectively, to obtain local features and global features, wherein the local features are outputs of the spatial attention module, and the global features are outputs of the self-attention module; The seventh intermediate feature obtained by adding the local feature and the global feature is input into the channel attention module for feature fusion to obtain the third intermediate feature.
7. The ECG signal classification method based on multi-branch weighted attention according to claim 6, characterized in that: The spatial attention module includes a maximum pooling layer, an average pooling layer, an activation function layer, a convolution layer and a sigmiod layer, the self-attention module includes a first branch, a second branch, a third branch, an activation normalization layer, a second convolution layer and a second activation layer, the first branch, the second branch and the third branch all include a third convolution layer, the second intermediate feature is input to the spatial attention module and the self-attention module in parallel, respectively, to obtain local features and global features, including: Inputting the second intermediate features into the maximum pooling layer and the average pooling layer of the spatial attention module respectively, and concatenating the output result of the maximum pooling layer with the output result of the average pooling layer to obtain a concatenated feature; The concatenated features are passed through an activation function layer, a convolution layer, and a sigmiod layer to obtain a second sub-feature; Performing a dot product of the concatenated feature and the second sub-feature to obtain the local feature; Input the second intermediate feature into the third convolutional layer corresponding to the first branch, the second branch, and the third branch respectively, to obtain a fourth intermediate feature, a fifth intermediate feature, and a sixth intermediate feature; Performing a cross product on the fourth intermediate feature and the fifth intermediate feature to obtain a first product result, and inputting the first product result to the activation normalization layer to obtain a seventh intermediate feature; multiplying the seventh intermediate feature by the sixth intermediate feature to obtain a second product result; The second product result is input into the second convolutional layer and the second activation layer connected in sequence to obtain the global feature.
8. The ECG signal classification method based on multi-branch weighted attention according to claim 6, characterized in that: The channel attention module includes a global maximum pooling layer, a first one-dimensional convolution layer, an activation layer, a second one-dimensional convolution layer and a sigmiod layer, and the seventh intermediate feature obtained by adding the local feature and the global feature is input into the channel attention module for feature fusion to obtain the third intermediate feature, including: The seventh intermediate feature is sequentially passed through a global maximum pooling layer, a first one-dimensional convolutional layer, an activation layer, a second one-dimensional convolutional layer and a sigmiod layer to obtain an eighth intermediate feature; The third intermediate feature is obtained by performing a dot product between the seventh intermediate feature and the eighth intermediate feature.
9. An electronic device, characterized in that: It includes at least one control processor and a memory for communicating with the at least one control processor; the memory stores instructions that can be executed by the at least one control processor, and the instructions are executed by the at least one control processor so that the at least one control processor can execute the electrocardiogram signal classification method based on multi-branch weighted attention as described in any one of claims 1 to 8.
10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores computer-executable instructions, and the computer-executable instructions are used to enable a computer to execute the electrocardiogram signal classification method based on multi-branch weighted attention as described in any one of claims 1 to 8.
Citation Information
Cited By
Electrocardiosignal classification method based on lead feature fusion and particle swarm optimization
CN121705847A