Magnetocardiogram classification method based on deep learning
Technical Field
The invention relates to a magnetocardiogram grading method.
Background
Since the change of the magnetic permeability of human tissues is small and can be considered as a constant, the propagation of magnetic signals in the body is hardly influenced, so that the detection of the biological phenomenon by the MCG is more reliable, and the accuracy of diagnosis of various heart diseases can be improved.
The classification of the current density vector diagram of the magnetocardiogram is an important index for clinical magnetocardiogram diagnosis. At present, related researches on the current density vector diagram of the magnetocardiogram are few, most of the known methods are classified by using traditional machine learning, although the methods have effects, researchers need to design experiments to extract the characteristics of the current density vector diagram of the magnetocardiogram, and are time-consuming and labor-consuming, so that a new method needs to be developed for simply and efficiently classifying the current density vector diagram of the magnetocardiogram.
Disclosure of Invention
The invention overcomes the defects in the prior art and provides a high-efficiency and high-accuracy grading method for a current density vector diagram of a small sample magnetocardiogram. Has great practical significance for clinical auxiliary diagnosis of heart diseases.
The invention provides a novel and noninvasive heart disease detection technology, wherein the classification of a current density vector diagram of a magnetocardiogram is an important evaluation index, and the invention provides a classification method of the current density vector diagram of the magnetocardiogram based on ResNet18 and transfer learning in view of the characteristics that a convolutional neural network has excellent performance in the aspect of image classification and transfer learning is suitable for small sample classification.
The invention discloses a magnetocardiogram grading method based on deep learning, which comprises the following steps:
step 1, collecting magnetocardiogram data of a subject, generating a current density vector diagram after processing, then sending all samples to experts for labeling, and finally obtaining 5 types (0 level, 1 level, 2 level, 3 level and 4 level) of labeled data.
And 2, expanding the samples marked in the step 1 (changing contrast, changing chroma, changing brightness, adding random noise and sharpening).
And 3, mixing the expanded data set with the original data set, and dividing the data set into a training set, a verification set and a test set according to the ratio of 6:2: 2.
Step 4, loading a ResNet18 network pre-trained on the ImageNet data set, removing the softmax output layer with the final node of 1000, and adding an output layer with 5 nodes according to the magnetocardiogram classification task; inputting the divided training set and verification set into a network for training to obtain a better network model and storing network weight for subsequent identification and classification; because the bottom layer features of the pictures extracted by the convolutional neural network are all the same and different, the first layers of ResNet are frozen during training, and the images are not subjected to back propagation of errors.
And 5, randomly extracting pictures in the test set by using the trained network model, inputting the pictures into the network model, outputting the prediction labels and the corresponding probabilities corresponding to the pictures by the network model, and outputting the evaluation indexes of the evaluation model.
The invention utilizes the convolutional neural network to automatically extract the characteristic of the image, does not need a large amount of training images for transfer learning, combines the convolutional neural network and the training images, only needs to put a small amount of samples with labels into the network for training, then adjusts related parameters, and obtains good grading accuracy when the network achieves better effect.
The invention has the advantages that: the implementation is simple, and the high grading accuracy rate can be achieved only by training the network by a small amount of current density vector diagrams of the magnetocardiogram.
Drawings
FIG. 1 is an overall flow chart of the method of the present invention.
Fig. 2 is a network structure diagram of the method of the present invention.
FIG. 3 is a loss curve for the network training of the present invention.
FIG. 4 is a graph of network training accuracy and validation accuracy in accordance with the present invention.
Detailed Description
The technical scheme of the invention is further explained by combining the attached drawings.
The invention discloses a magnetocardiogram grading method based on deep learning, which comprises the following steps as shown in figure 1:
step 1, collecting magnetocardiogram data of a subject on a pumping type Rb atom magnetometer, carrying out a series of operations on the magnetocardiogram data to generate a current density vector diagram, then sending all samples to experts for labeling, and finally obtaining 5 types (0 level, 1 level, 2 level, 3 level and 4 level) of labeled data.
And 2, expanding each type of the samples with the labels in the step 1 by 5 times by using a plurality of data enhancement methods to improve the generalization capability of the model, namely changing the chroma, the contrast, the brightness, sharpening and adding random noise of the picture.
And 3, mixing the expanded data set with the original data set, and performing data conversion according to the ratio of 6:2:2, dividing the training set, the verification set and the test set.
And 4, loading a ResNet18 network pre-trained on the ImageNet data set, removing the softmax output layer with the final node of 1000, and adding an output layer with 5 nodes according to the magnetocardiogram classification task, wherein the network structure is shown in FIG. 2. And then inputting the divided samples into a network for training, wherein the bottom layer characteristics of the picture extracted by the convolutional neural network are different, so that the first layers of ResNet are frozen during training, and the ResNet is not allowed to participate in the back propagation of errors.
The input image size was set to 224 x 224, the learning rate of the network was set to 0.0001, the batch _ size was 8, the cross entropy loss function (CrossEntropyLoss) was defined as the loss function of the network, and 200 epochs were trained on the training set and the validation set using the Adam optimizer until the model converged, see fig. 3 and 4.
And 5, randomly extracting pictures in the test set by using the trained network model, inputting the pictures into the network model, outputting the pictures and the probabilities corresponding to the prediction labels by using the network model, and finally outputting evaluation indexes to evaluate the quality of the network model.
The evaluation indexes in step 5 include accuracy (accuracycacy) of the model, precision (precision) of each type, specificity (specificity), recall (call) and confusion matrix.
The embodiments described in this specification are merely illustrative of implementations of the inventive concept and the scope of the present invention should not be considered limited to the specific forms set forth in the embodiments but rather by the equivalents thereof as would occur to those skilled in the art upon consideration of the present inventive concept.