Disclosure of Invention
The invention aims to solve the problem that the detection accuracy of the traditional image histology method on the novel coronaries is low in the prior art, and provides a novel method, a system and a storage medium for imaging and analyzing the ground glass focus of the coronaries.
The invention is realized by the following technical scheme:
a new method for resolving a glass focus of a coronal pneumonia by grinding, comprising the following steps:
s1, glass grinding shadow sketching based on image histology:
s11, restoring a CT picture by using a DICOM file to obtain a real CT value, and selecting a CT value of a lung field target area;
s12, generating a lung profile mask;
s13, repairing the generated lung profile mask;
s14, performing logical AND operation on the CT value of the target area of S11 and the mask corresponding to S12 to obtain a double-lung field picture;
s15, dividing and grinding glass shadows;
s16, removing false positive;
s2, predicting new coronatine pneumonia disease probability based on deep learning:
s21, preprocessing the ground glass shadow obtained in the step S1, and improving the convergence speed and the prediction speed of the convolutional neural network;
s22, building a neural network based on the WRN and the mixed domain attention module;
s23, stacking the ground glass photo pictures after the pretreatment of S21 as input, and putting the stack of ground glass photo pictures into a neural network of S22 to obtain the probability of suffering from new coronaries pneumonia.
Preferably, the step S11 is to restore the CT picture by using a DICOM file to obtain a real CT value, and the specific process is as follows:
step one: reading pixel matrix values in the DICOM file; setting the CT value equal to-2000 as 0, and removing the out-of-limit CT value;
step two: restoring a real CT value according to the two attributes of the scaling intercept and the scaling slope in the DICOM file;
step three: CT values remaining in the interval [ -1000,400] with CT values below-1000 set at-1000 and CT values above 400 set at 400;
step four: and finally, carrying out normalization processing on the picture, and storing the picture in a png format.
Preferably, the specific process of generating the lung profile mask in S12 is as follows:
step one: dividing the CT value matrix by using one value in the interval [ -400, -320] as a threshold value to generate a binary matrix, setting the pixel value larger than the threshold value as 2, and setting the pixel value smaller than the threshold value as 1;
step two: carrying out three-dimensional connected domain marking on the binary matrix to generate a label matrix, and respectively taking the sampling points at the left upper corner and the right lower corner of the CT cube matrix as background labels;
step three: setting the value of the label equal to the background label to 2 in the binary matrix;
step four: then filling the pixel value in the maximum connected domain into each pixel value-1 in the binary matrix;
step five: inverting the binary matrix, and reserving the maximum connected domain, wherein the region with the pixel value of 1 is a lung region;
step six: multiplying 255 by the binary matrix, and storing the binary matrix layer by layer as png format picture output.
Preferably, the repairing of the generated lung profile mask in S13 is performed by a rolling ball method, which specifically includes the following steps:
step one: selecting a contour point, wherein N pixel values extending outwards from the lung in a section [15,60] in the normal direction of the current point are used as the positions of the sphere center of the rolling sphere, and N pixel values are used as tangent spheres with the radius as the current point; preferably, 30 pixel values are extended outwards from the lung and serve as the positions of the sphere center of the rolling sphere, and 30 pixel values are tangential spheres with the radius serving as the current point;
step two: if more than one intersection point exists between the tangent ball and the subsequent lung contour point, selecting a point which is closest to the current point in the intersection points, and deleting the contour point before the current point and the closest point; otherwise, returning to process the next contour point.
Preferably, S14 extracts the two lung fields, performs a logical and operation on the picture processed in the first step and the mask corresponding to the second step, and saves the result in png format.
Preferably, the specific process of the S15 division glass grinding shadow is as follows:
step one: the double-lung field picture generated in the step S14 is subjected to median blurring, and the kernel size is within the interval [3, 20] so as to remove noise scattered points with too high and too low calcification degree in the double-lung field;
step two: further using Gaussian blur to the result of the step 1, taking a square with a side length of K as a core, wherein the size of K is in a section [3, 10] so as to ensure that the variance of pixel values in the same-tissue region is as small as possible and the change is as gentle as possible;
step three: performing double-threshold segmentation on the result of the step 2, so that the pixel value in the interval [49, 116] is set to 255, and the rest pixel values are set to 0;
step four: and (3) performing hole filling treatment on the result in the step (3) to obtain a mask for grinding the glass shadow, and storing the mask in a png format.
Preferably, the specific process of removing false positives in S16 is as follows:
step one: a convolutional neural network with input of 12 times 12 and output of two classifications of whether glass shadow is ground or not is used for learning the picture segments of the glass shadow and the blood vessel;
step two: putting a square area with the side length of 12 into the network of the first step and carrying out 10-crop prediction on the glass shadow grinding area of the original image by taking the area center as the center, and judging the original glass shadow grinding candidate area as a real glass shadow grinding area if the maximum probability exceeds 50%;
step three: and (3) removing the candidate region which is not the ground glass shadow in the step (2) in the original image, and carrying out edging on the ground glass shadow region by using an opencv library, and storing in a png format.
Preferably, the step S21 of glass grinding is performed to improve the convergence rate and the prediction rate of the convolutional neural network, and the specific process is as follows:
step one: cutting the picture with a minimum rectangular tangent frame in the double-lung field picture containing the ground glass shadow, and unifying the sizes of the cut pictures into length 416 and width 320;
step two: the cut-out picture is filled with 48 except for the areas of the double lung field.
Preferably, S22, constructing a neural network based on the WRN and the mixed domain attention module; the network backbone network is based on a pre-activated ResNet-34 structure, and the amplification ratio is 2; the branching part is based on a residual attention network. The input is the picture after the first step pretreatment during training, and the confidence degree of the new coronaries is output.
Preferably, the specific process of predicting the probability of S23 being diseased is as follows:
step one: taking the stack of the pictures preprocessed in the S21 as input, and putting the stack of the pictures into a network trained in the S22 for prediction;
step two: sequencing the prediction results and storing the prediction results in a list;
step three: if there is no value in the list, the probability of new crown disease is 0; if the number of the values in the list is less than 7, the average number of the list is recorded as the probability of the new crown disease; if the number of values in the list is 7, the highest score is removed, the lowest score is removed, and the average number of the rest values is recorded as the probability of new crown illness.
A novel crown pneumonia glass focus grinding contrast analysis system comprises a preprocessing module of a DICOM file, a generation module of a lung contour mask, a repair module of the lung contour mask, an extraction module of double lung fields, a glass focus grinding segmentation module, a false positive removal module, a data preprocessing module, a neural network based on a WRN and a mixed domain attention module and a prediction module of the illness probability;
the preprocessing module of the DICOM file is used for restoring the CT picture to obtain a real CT value, and selecting the CT value of a lung field target area;
the generation module of the lung contour mask is used for generating the lung contour mask;
the repair module of the lung outline mask is used for repairing the generated lung outline mask;
the extraction module of the double lung fields is used for performing logical AND operation on the CT value of the target area and the corresponding mask to obtain a double lung field picture;
the glass grinding focus segmentation module is used for segmenting the glass grinding shadow;
the false positive removing module is used for removing false positive;
the data preprocessing module is used for preprocessing the obtained ground glass shadow and improving the convergence speed and the prediction speed of the convolutional neural network;
the neural network based on the WRN and the mixed domain attention module is used for training the convolutional neural network based on the WRN and the mixed domain attention module;
the prediction module of the disease probability is used for calculating the probability of suffering from new coronaries.
A storage medium having a program stored therein, the program executing the method for analyzing a new coronal pneumonitis glass lesion.
Compared with the prior art, the invention has the following technical effects:
compared with DenseNet, the neural network structure based on WRN and the mixed domain attention module in the novel crown pneumonia ground glass focus radiography analysis method provided by the invention has the advantages that ResNet occupies less memory, so that ResNet is friendly to the condition of larger input data, the size of a single photo of the input data of the network is 320 times 416, the situation of larger data is considered, memory overflow during training can be avoided by using a ResNet-based model, and meanwhile, training period can be shortened by using ResNet. WRN can achieve higher classification accuracy than a thin, high-quality network, and also has a faster training speed. In the network structure, the backbone network uses a Wide ResNet34 model with an amplification factor K of 2, so that the contradiction between training effect and memory expense can be balanced. Because the total image of the lung field in the input is less than 50% and the total image of the diseased ground glass focus is less than 10%, the branched network of the invention uses the attention module of the mixed domain, thereby improving the training speed and the prediction accuracy.
Because the new crown mill glass shadow focus is distributed along the peripheral band, the lung contour is lost due to the fact that the lower pleura contour is easy to be stained by using a traditional threshold segmentation algorithm, and aiming at the situation, the method is used for repairing the lower pleura contour instead of the whole lung contour by using a rolling ball method, and is more beneficial to improving the accuracy of prediction.
The invention uses the median blur to remove the noise point with high calcification degree in the glass grinding shadow, uses Gaussian blur removal to make the pixel variance in the region as small as possible, and uses the dual-threshold segmentation to sketch the glass grinding shadow. The method can rapidly, practically and without omission delineate the ground glass shadow.
The traditional method utilizes texture features and morphological features of the ground glass shadow, has large calculated amount, is complex and has higher false positive. The invention utilizes the small convolutional neural network, inputs a small square frame with the side length of 12 by taking the center of the ground glass shadow candidate area as the center, and has the advantages of short training period, high accuracy and short prediction time.
The traditional neural network directly places the whole picture into training, and useless features are too huge, so that the model can be slowly converged, and the training period is long. The invention extracts the minimum rectangular tangent frame of the lung field, uniformly inputs the minimum rectangular tangent frame into 320 times 416, fills the non-lung field area with 48, and can furthest reduce the size of the picture and reduce the variance among pixels of the picture on the premise of ensuring the division of the ground glass shadow.
After obtaining the new crown disease probability list, the invention uses 7 as a threshold value, selects the highest 7 probabilities, removes the highest score and the lowest score, and the remaining average is used as the final disease probability of the patient. However, the traditional method only averages all the illness probabilities and outputs the average illness probability, and the illness probability of a new crown patient with a single-shot ground glass shadow is reduced, so that missed judgment is caused.
Detailed Description
In order to make the objects, technical solutions and advantages of the present invention more apparent, the technical solutions of the present invention will be described in detail with reference to specific examples and comparative examples. It will be apparent that the described embodiments are only some, but not all, embodiments of the invention. All other embodiments, based on the examples herein, which are within the scope of the invention as defined by the claims, will be within the scope of the invention as defined by the claims.
Examples
The invention is realized by the following technical scheme:
a new method for analyzing the contrast of the ground glass focus of the coronal pneumonia is shown in figure 1, S1, a ground glass shadow sketch based on image group science; s2, predicting the new coronatine pneumonia disease probability based on deep learning.
As shown in fig. 2, the specific procedure of S1 is as follows:
s11, restoring a CT picture by using a DICOM file to obtain a real CT value, and selecting a CT value of a lung field target area;
s12, generating a lung profile mask;
s13, repairing the generated lung profile mask;
s14, performing logical AND operation on the CT value of the target area of S11 and the mask corresponding to S12 to obtain a double-lung field picture;
s15, dividing and grinding glass shadows;
s16, removing false positive.
As shown in fig. 3, the specific procedure of S3 is as follows:
s21, preprocessing the ground glass shadow obtained in the step S1, and improving the convergence speed and the prediction speed of the convolutional neural network;
s22, building a neural network based on the WRN and the mixed domain attention module;
s23, stacking the ground glass photo pictures after the pretreatment of S21 as input, and putting the stack of ground glass photo pictures into a neural network of S22 to obtain the probability of suffering from new coronaries pneumonia.
Preferably, the step S11 is to restore the CT picture by using a DICOM file to obtain a real CT value, and the specific process is as follows:
step one: reading pixel matrix values in the DICOM file; setting the CT value equal to-2000 as 0, and removing the out-of-limit CT value;
step two: restoring a real CT value according to the two attributes of the scaling intercept and the scaling slope in the DICOM file;
step three: CT values remaining in the interval [ -1000,400] with CT values below-1000 set at-1000 and CT values above 400 set at 400;
step four: and finally, carrying out normalization processing on the picture, and storing the picture in a png format.
Preferably, the specific process of generating the lung profile mask in S12 is as follows:
step one: dividing the CT value matrix by using one value in the interval [ -400, -320] as a threshold value to generate a binary matrix, setting the pixel value larger than the threshold value as 2, and setting the pixel value smaller than the threshold value as 1;
step two: carrying out three-dimensional connected domain marking on the binary matrix to generate a label matrix, and respectively taking the sampling points at the left upper corner and the right lower corner of the CT cube matrix as background labels;
step three: setting the value of the label equal to the background label to 2 in the binary matrix;
step four: then filling the pixel value in the maximum connected domain into each pixel value-1 in the binary matrix;
step five: inverting the binary matrix, and reserving the maximum connected domain, wherein the region with the pixel value of 1 is a lung region;
step six: multiplying 255 by the binary matrix, and storing the binary matrix layer by layer as png format picture output.
Preferably, the repairing of the generated lung profile mask in S13 is performed by a rolling ball method, which specifically includes the following steps:
step one: selecting a contour point, and extending 30 pixel values to the lung in the normal direction of the current point to serve as the sphere center position of the rolling sphere, wherein the 30 pixel values serve as tangent spheres with the radius serving as the current point;
step two: if more than one intersection point exists between the tangent ball and the subsequent lung contour point, selecting a point which is closest to the current point in the intersection points, and deleting the contour point before the current point and the closest point; otherwise, returning to process the next contour point.
Preferably, S14 extracts the two lung fields, performs a logical and operation on the picture processed in the first step and the mask corresponding to the second step, and saves the result in png format.
Preferably, the specific process of the S15 division glass grinding shadow is as follows:
step one: the double-lung field picture generated in the step S14 is subjected to median blurring, and the kernel size is within the interval [3, 20] so as to remove noise scattered points with too high and too low calcification degree in the double-lung field;
step two: further using Gaussian blur to the result of the step 1, taking a square with a side length of K as a core, wherein the size of K is in a section [3, 10] so as to ensure that the variance of pixel values in the same-tissue region is as small as possible and the change is as gentle as possible;
step three: performing double-threshold segmentation on the result of the step 2, so that the pixel value in the interval [49, 116] is set to 255, and the rest pixel values are set to 0;
step 4: and (3) performing hole filling treatment on the result in the step (3) to obtain a mask for grinding the glass shadow, and storing the mask in a png format.
Preferably, the specific process of removing false positives in S16 is as follows:
step one: a convolutional neural network with input of 12 times 12 and output of two classifications of whether glass shadow is ground or not is used for learning the picture segments of the glass shadow and the blood vessel;
step two: the glass shadow grinding area of the original image is centered on the area center, as shown in table 1, a square area with the side length of 12 is put into the network of the first step and 10-crop prediction is carried out, and if the maximum probability exceeds 50%, the original glass shadow grinding candidate area is judged to be a real glass shadow grinding area;
step three: and (3) removing the candidate region which is not the ground glass shadow in the step (2) in the original image, and carrying out edging on the ground glass shadow region by using an opencv library, and storing in a png format.
Table 1:
preferably, the step S21 of glass grinding is performed to improve the convergence rate and the prediction rate of the convolutional neural network, and the specific process is as follows:
step one: cutting the picture with a minimum rectangular tangent frame in the double-lung field picture containing the ground glass shadow, and unifying the sizes of the cut pictures into length 416 and width 320;
step two: the cut-out picture is filled with 48 except for the areas of the double lung field.
Preferably, S22, constructing a neural network based on the WRN and the mixed domain attention module; the network structure is shown in fig. 4, and the identity_ Block, attention _block_v1, the identity_block_v2 and the identity_block_v3 are shown in fig. 5,6, 7 and 8. The network backbone network is based on a pre-activated ResNet-34 structure, and the amplification ratio is 2; the branching part is based on a residual attention network. The input is the picture after the first step pretreatment during training, and the confidence degree of the new coronaries is output.
Preferably, the specific process of predicting the probability of S23 being diseased is as follows:
step one: taking the stack of the pictures preprocessed in the S21 as input, and putting the stack of the pictures into a network trained in the S22 for prediction;
step two: sequencing the prediction results and storing the prediction results in a list;
step three: if there is no value in the list, the probability of new crown disease is 0; if the number of the values in the list is less than 7, the average number of the list is recorded as the probability of the new crown disease; if the number of values in the list is 7, the highest score is removed, the lowest score is removed, and the average number of the rest values is recorded as the probability of new crown illness.
Finally, it should be noted that the above embodiments are only for illustrating the technical solution of the present invention, and not for limiting the scope of the present invention, and although the present invention has been described in detail with reference to the preferred embodiments, it should be understood by those skilled in the art that modifications or equivalent substitutions can be made to the technical solution of the present invention without departing from the spirit and scope of the technical solution of the present invention.