Disclosure of Invention
The invention aims to solve the problem that the existing premature beat recognition method cannot accurately reflect pathological information of ECG (electrocardiogram) by adopting a manual feature extraction mode so as to influence subsequent classification performance, and provides the premature beat recognition method based on an improved convolutional neural network.
In order to solve the problems, the invention is realized by the following technical scheme:
The premature beat identification method based on the improved convolutional neural network comprises the following steps:
Step 1, constructing a premature beat recognition model;
The premature beat recognition model consists of 1 convolution layer, 1 maximum pooling layer, 4 residual unit blocks and 1 global average pooling layer; the input of the convolution layer is used as the input of the premature beat identification model, the output of the convolution layer is connected with the input of the maximum pooling layer, the output of the maximum pooling layer is connected with the input of the first residual error unit block, the output of the first residual error unit block is connected with the input of the second residual error unit block, the output of the second residual error unit block is connected with the input of the third residual error unit block, the output of the third residual error unit block is connected with the input of the fourth residual error unit block, the output of the fourth residual error unit block is connected with the input of the global average pooling layer, and the output of the global average pooling layer is used as the output of the premature beat identification model;
step 2, preprocessing the electrocardiogram marked with the classification as a training sample, and training the premature beat recognition model constructed in the step1 by using the training sample to obtain a trained premature beat recognition model;
And step 3, preprocessing the electrocardiogram to be classified to obtain a prediction sample, and sending the prediction sample into the premature beat recognition model trained in the step 2 to realize classification of the electrocardiogram to be classified.
In the above scheme, the first residual error unit block is respectively composed of 2 direct jump residual error modules; the input of the first direct jump residual error module is used as the input of the first residual error unit block, the output of the first direct jump residual error module is connected with the input of the second direct jump residual error module, and the output of the second direct jump residual error module is used as the output of the first residual error unit block; the second residual unit block consists of 1 convolution jump residual module and 1 direct jump residual module respectively; the input of the first convolution jump residual error module is used as the input of the second residual error unit block, the output of the first convolution jump residual error module is connected with the input of the third direct jump residual error module, and the output of the third direct jump residual error module is used as the output of the second residual error unit block; the third residual error unit block consists of 1 convolution jump residual error module and 2 direct jump residual error modules respectively; the input of the second convolution jump residual error module is used as the input of the third residual error unit block, the output of the second convolution jump residual error module is connected with the input of the fourth direct jump residual error module, the output of the fourth direct jump residual error module is connected with the input of the fifth direct jump residual error module, and the output of the fifth direct jump residual error module is used as the output of the third residual error unit block; the fourth residual error unit block is respectively composed of 1 convolution jump residual error module and 1 direct jump residual error module; the input of the third convolution jump residual error module is used as the input of the fourth residual error unit block, the output of the third convolution jump residual error module is connected with the input of the sixth direct jump residual error module, and the output of the sixth direct jump residual error module is used as the output of the fourth residual error unit block.
In the scheme, the direct jump residual error module consists of 2 convolution layers, 1 SimAM attention mechanism layers and 1 direct jump branch; the input of the first convolution layer and the direct jump branch are used as the input of the direct jump residual error module, the output of the first convolution layer is connected with the input of the second convolution layer, the output of the second convolution layer is connected with the input of the first SimAM attention mechanism layer, and the output of the first SimAM attention mechanism layer and the output of the direct jump branch are added to be used as the output of the direct jump residual error module.
In the scheme, the convolution jump residual error module consists of 2 convolution layers, 1 SimAM attention mechanism layers and 1 convolution jump branch; the input of the third convolution layer and the convolution jump branch are used as the input of the convolution jump residual error module, the output of the third convolution layer is connected with the input of the fourth convolution layer, the output of the fourth convolution layer is connected with the input of the second SimAM attention mechanism layer, and the output of the second SimAM attention mechanism layer and the output of the convolution jump branch are added to be used as the output of the convolution jump residual error module.
Compared with the prior art, the invention improves the original ResNet model from two aspects of depth and width of the model, and then blends the SimAM attention mechanism into the improved ResNet model, so that the accuracy of premature beat identification is improved by the model.
Detailed Description
The present invention will be further described in detail with reference to specific examples in order to make the objects, technical solutions and advantages of the present invention more apparent.
A premature beat identification method based on an improved convolutional neural network, comprising the steps of:
And 1, constructing a premature beat recognition model.
The deep neural network is an end-to-end learning model which can automatically learn signal features from original input data, and avoids the manual feature extraction of the traditional method. Considering that the deep learning network layer number is too deep, the network model can generate serious overfitting, so the invention reduces the layer number of ResNet and the number of characteristic diagrams of each convolution module. In addition, considering SimAM (Parameter-Free Attention Module) is a simple and very effective attention mechanism without additional parameters, which can infer the weight value of 3D from the current neuron, the problems that the existing attention mechanism can only refine the characteristics in one dimension of a channel or a space and the space which changes simultaneously in the channel and the space lacks flexibility are solved, and the like, and therefore, the invention integrates the SimAM attention mechanism into an improved ResNet model.
Based on the above analysis, the premature beat recognition model NEWRESNET constructed by the present invention improves on the original ResNet model from the depth and width of the model, and then fuses the SimAM attention mechanism into the improved ResNet model. As shown in fig. 1, the premature beat recognition model NEWRESNET consists of 1 convolutional layer (conv), 1 max pooling layer (max pool), 4 residual unit blocks, and 1 global average pooling layer (avg pool). The input of the convolution layer is used as the input of the premature beat identification model, the output of the convolution layer is connected with the input of the maximum pooling layer, the output of the maximum pooling layer is connected with the input of the first residual error unit block, the output of the first residual error unit block is connected with the input of the second residual error unit block, the output of the second residual error unit block is connected with the input of the third residual error unit block, the output of the third residual error unit block is connected with the input of the fourth residual error unit block, the output of the fourth residual error unit block is connected with the input of the global average pooling layer, and the output of the global average pooling layer is used as the output of the premature beat identification model.
The 4 residual unit blocks are formed by respectively connecting 2,3 and 2 residual modules in series. The first residual error unit block consists of 2 direct jump residual error modules respectively; wherein the input of the first direct jump residual module is used as the input of the first residual unit block, the output of the first direct jump residual module is connected with the input of the second direct jump residual module, and the output of the second direct jump residual module is used as the output of the first residual unit block. The second residual unit block consists of 1 convolution jump residual module and 1 direct jump residual module respectively; the input of the first convolution jump residual error module is used as the input of the second residual error unit block, the output of the first convolution jump residual error module is connected with the input of the third direct jump residual error module, and the output of the third direct jump residual error module is used as the output of the second residual error unit block. The third residual error unit block consists of 1 convolution jump residual error module and 2 direct jump residual error modules respectively; the input of the second convolution jump residual error module is used as the input of the third residual error unit block, the output of the second convolution jump residual error module is connected with the input of the fourth direct jump residual error module, the output of the fourth direct jump residual error module is connected with the input of the fifth direct jump residual error module, and the output of the fifth direct jump residual error module is used as the output of the third residual error unit block. The fourth residual error unit block is respectively composed of 1 convolution jump residual error module and 1 direct jump residual error module; the input of the third convolution jump residual error module is used as the input of the fourth residual error unit block, the output of the third convolution jump residual error module is connected with the input of the sixth direct jump residual error module, and the output of the sixth direct jump residual error module is used as the output of the fourth residual error unit block.
Each residual module consists of 2 convolutional layers (conv), 1 SimAM attention mechanism layers, and 1 skip branch. SimAM the attention mechanism layer is shown in figure 2. The input vector x of SimAM attentiveness mechanism layer is subjected to SimAM attentiveness mechanism to obtain a weight value e t of each neuron in the output input vector x, and then the weight value e t is multiplied by the input vector x to obtain the output y of SimAM attentiveness mechanism layer. The jump branch comprises 2 types: the jump branch is represented by a solid line, is a direct jump branch, and the input and the output of the direct jump branch are identical mappings, and the jump branch is formed by a direct jump residual error module; a jump branch is indicated by a dashed line, and is a convolution jump branch, the input of the convolution jump branch obtains the output of the convolution jump branch through a 1*1 convolution layer, and the convolution jump residual error module is formed.
The direct jump residual error module consists of 2 convolution layers, 1 SimAM attention mechanism layers and 1 direct jump branch; the input of the first convolution layer and the direct jump branch are used as the input of the direct jump residual error module, the output of the first convolution layer is connected with the input of the second convolution layer, the output of the second convolution layer is connected with the input of the first SimAM attention mechanism layer, and the output of the first SimAM attention mechanism layer and the output of the direct jump branch are added to be used as the output of the direct jump residual error module.
The convolution jump residual error module consists of 2 convolution layers, 1 SimAM attention mechanism layers and 1 convolution jump branch; the input of the third convolution layer and the convolution jump branch are used as the input of the convolution jump residual error module, the output of the third convolution layer is connected with the input of the fourth convolution layer, the output of the fourth convolution layer is connected with the input of the second SimAM attention mechanism layer, and the output of the second SimAM attention mechanism layer and the output of the convolution jump branch are added to be used as the output of the convolution jump residual error module.
In all the convolution layers and the maximum pooling layer, "1*7" or "1*3" represents the size of the convolution kernel of the convolution layer, "36", "60", "80" or "128" represents the number of feature maps of the convolution layer, and "/1" or "/2" represents the movement step size of the convolution layer.
And 2, preprocessing the classified electrocardiograms to be used as training samples, and training the premature beat recognition model constructed in the step1 by using the training samples to obtain a trained premature beat recognition model.
The preprocessing process of the ECG mainly uses a filter to remove noise such as baseline drift, power frequency interference and the like in the ECG. Classification as labeled in the electrocardiogram is either premature or non-premature.
And step 3, preprocessing the electrocardiogram to be classified to obtain a prediction sample, and sending the prediction sample into the premature beat recognition model trained in the step 2 to realize classification of the electrocardiogram to be classified.
The way of preprocessing the electrocardiogram to be classified is the same as the way of preprocessing the electrocardiogram marked with classification. The output of the predicted sample obtained by the model is a record of premature beat or non-premature beat.
The performance of the invention is illustrated by the following example:
based on Chinese cardiovascular disease database (CCDD database, http://58.210.56.164/ccdd /), the ECG record in the database is subjected to band-pass filtering of 0.5-40 Hz for denoising.
Since the premature beat of the present invention is classified into a classification problem (premature beat or non-premature beat), sensitivity (Se), specificity (Sp), accuracy (Acc) can be used to measure the quality of the classification effect. The two-class confusion matrix is shown in table 1 below.
TABLE 1 confusion matrix
The definition of each index is as follows:
Sensitivity (Se):
Se=TP/(TP+FN)
Specificity (Sp):
Sp=TN/(TN+FP)
accuracy (Acc):
Acc=(TP+TN)/(TP+TN+FP+FN)
1) Identification of ventricular premature beat (PVC)
35840 Pre-processed ECG recordings were used as training samples, containing 3112 PVC recordings. 141046 pre-processed ECG recordings were used as test samples, which contained 2148 PVC recordings. After training the NEWRESNET model with the training sample, the results obtained by the trained model on the test sample are shown in table 2 below, where NPVC represents non-ventricular premature beat record, PVC is ventricular premature beat record, se is sensitivity, sp is specificity, acc is accuracy.
Table 2 PVC identification results
2) Identification of atrial premature beat (PAB)
Taking 44800 preprocessed ECG records as training samples, wherein the training samples comprise more than 4 thousand PAB records; 132087 pre-processed ECG recordings were used as test samples, containing 4172 PAB recordings. After the improved training of NEWRESNET model using training sample pair NEWRESNET, the results obtained by the trained model on the test sample are shown in table 2 below, where NAPB represents non-atrial premature beat record, APB represents atrial premature beat record, se is sensitivity, sp is specificity, and Acc is accuracy.
Table 3 APB identification results
As can be seen from tables 2 and 3, the sensitivity, specificity and accuracy of classifying the electrocardiogram by the premature beat recognition model ResNet provided by the invention all reach more than 90%.
It should be noted that, although the examples described above are illustrative, this is not a limitation of the present invention, and thus the present invention is not limited to the above-described specific embodiments. Other embodiments, which are apparent to those skilled in the art from consideration of the specification and practice of the invention disclosed herein, are considered to be within the scope of the invention as claimed.