Disclosure of Invention
The application provides a classification method, a classification device and a storage medium for an ultrasonic breast lesion, which can solve the problem of low efficiency of manually analyzing an ultrasonic breast image. The application provides the following technical scheme:
in a first aspect, there is provided a method of classifying an ultrasound breast lesion, the method comprising:
acquiring target ultrasonic breast information to be classified, wherein the target ultrasonic breast information is a target ultrasonic breast image or a target ultrasonic breast video, and the target ultrasonic breast video comprises at least two frames of target ultrasonic breast images;
for each frame of the target ultrasound breast image,
segmenting the target ultrasound breast image into n1*n2A data block; wherein n is1Number of data blocks divided for image height direction, n2Number of data blocks divided for image width direction, n1,n2Is a positive integer;
converting each data block into p1*p2Vector data in the c dimension; wherein n is1=H/p1,n2=W/p2(ii) a H is the height of the input image, W is the width of the input image, p1For the height of the divided data block, p2The width of the divided data block;
n is to be1*n2Vector data set corresponding to each data blockAnd, obtaining n1n2×p1p2c two-dimensional data matrix;
generating a position coding vector corresponding to the position according to the position of each data block in the target ultrasonic breast image, and adding the position coding vector into the two-dimensional data matrix to obtain a data matrix to be processed; segmentation and division
And inputting the data matrix to be processed into a pre-trained image classification network to obtain the focus property classification corresponding to the target ultrasonic mammary gland image.
Optionally, the image classification network includes a multi-head attention module, a feed-forward neural module, and a multi-layer fully-connected classification module;
the multi-head attention module comprises three fully-connected networks, an activation function layer and a multi-dimensional logistic regression layer, wherein the input of each fully-connected network is the data matrix to be processed, and the output of each fully-connected network is characteristic data with preset dimensionality; after the multiplication of characteristic data output by two preset fully-connected networks and the division by a preset scale factor, a logistic regression result is obtained through calculation of a multidimensional logistic regression layer; multiplying the logistic regression result with the characteristic data of the other fully-connected network to obtain an output result of the multi-head attention module; the other fully connected network is a fully connected network different from the preset two fully connected networks in the three network branches;
the feedforward neural module comprises a fully-connected network, a linear rectification activation function connected with the fully-connected network and layer normalization; the output result of the multi-head attention module is subjected to full-connection network, linear rectification activation function connected with the full-connection network and layer normalization to obtain the output result of the feedforward neural module;
the multilayer fully-connected classification module receives the output result of the feedforward neural module and then performs fully-connected layer processing; and carrying out layer normalization processing on the processed data to obtain the lesion property classification.
Optionally, if the target ultrasound breast image is an image in the target ultrasound breast video, the method further includes:
after lesion property classification is obtained according to each frame of target ultrasonic breast image, lesion property classification corresponding to the target ultrasonic breast video is determined and obtained according to lesion property classification obtained from each frame of target ultrasonic breast image in the target ultrasonic breast video.
Optionally, the determining, according to the lesion property classification obtained from each frame of target ultrasound breast image in the target ultrasound breast video, a lesion property classification corresponding to the target ultrasound breast video includes:
if no image with the focus property classification as malignant exists in each frame of target ultrasonic breast image of the target ultrasonic breast video, counting the focus property classification with the largest number in the focus property classifications corresponding to each frame of target ultrasonic breast image, and determining the focus property classification obtained through counting as the focus property classification corresponding to the target ultrasonic breast video;
and if the focus property classification is a malignant image in each frame of target ultrasonic breast image of the target ultrasonic breast video, determining the focus property classification corresponding to the target ultrasonic breast video as malignant.
Optionally, the lesion property classification comprises: benign type and malignant type; alternatively, the cancer includes at least one of benign type, malignant type, inflammatory type, adenopathy type, proliferative type, ductal ectasia type, early stage invasive cancer, non-invasive cancer, lobular adenocarcinoma, ductal adenocarcinoma, medullary carcinoma, hard cancer, simple cancer, carcinoma in situ, early stage cancer, invasive cancer, undifferentiated cancer, poorly differentiated cancer, and highly differentiated cancer.
Optionally, the number of the multi-head attention module and the feedforward neural module is plural.
Optionally, the target ultrasound breast image is a whole ultrasound breast image or a breast lesion region image.
Optionally, the image classification network is obtained by random activation training based on weights.
In a second aspect, there is provided an apparatus for classifying an ultrasound breast lesion, the apparatus comprising:
the information acquisition unit is used for acquiring target ultrasonic breast information to be classified, wherein the target ultrasonic breast information is a target ultrasonic breast image or a target ultrasonic breast video, and the target ultrasonic breast video comprises at least two frames of target ultrasonic breast images;
an image segmentation unit for segmenting the target ultrasound breast image into n for each frame of the target ultrasound breast image1*n2A data block; wherein n is1Number of data blocks divided for image height direction, n2Number of data blocks divided for image width direction, n1,n2Is a positive integer;
a data conversion unit for converting each data block into p1*p2Vector data in the c dimension; wherein n is1=H/p1,n2=W/p2(ii) a H is the height of the input image, W is the width of the input image, p1For the height of the divided data block, p2The width of the divided data block;
a vector merging unit for merging n1*n2Merging the vector data corresponding to each data block to obtain n1n2×p1p2c two-dimensional data matrix;
the matrix generating unit is used for generating a position coding vector corresponding to the position according to the position of each data block in the target ultrasonic breast image, and adding the position coding vector into the two-dimensional data matrix to obtain a data matrix to be processed;
and the focus classification unit is used for inputting the data matrix to be processed into a pre-trained image classification network to obtain focus property classification segmentation corresponding to the target ultrasonic mammary gland image.
Optionally, the image classification network includes a multi-head attention module, a feed-forward neural module, and a multi-layer fully-connected classification module;
the multi-head attention module comprises three fully-connected networks, an activation function layer and a multi-dimensional logistic regression layer, wherein the input of each fully-connected network is the data matrix to be processed, and the output of each fully-connected network is characteristic data with preset dimensionality; after multiplying the characteristic data output by two preset fully-connected networks and dividing the multiplied characteristic data by a preset scale factor, obtaining a logistic regression result through multilayer logistic regression calculation; multiplying the logistic regression result with the characteristic data of the other fully-connected network to obtain an output result of the multi-head attention module; the other fully connected network is a fully connected network different from the preset two fully connected networks in the three network branches;
the output of the multi-head attention module is as follows:
wherein Q, K and V are results of full connection of the input data blocks respectively, and d is a scale factor.
The feedforward neural module comprises a fully-connected network, a linear rectification activation function connected with the fully-connected network and layer normalization; the output result of the multi-head attention module is subjected to full-connection network, linear rectification activation function connected with the full-connection network and layer normalization to obtain the output result of the feedforward neural module;
the output of the feedforward neural network is as follows:
zout=LN(RELU(MLP(RELU(MLP(zin) ))) wherein, z) isinIs the input of a feedforward neural network, zoutFor the output of the feedforward neural network, LN is the layer normalization operation, RELU is the linear rectification activation function, and MLP is the full-link layer.
The multilayer fully-connected classification module receives the output result of the feedforward neural module and then performs fully-connected layer processing; and carrying out layer normalization processing on the processed data to obtain the lesion property classification.
In a third aspect, there is provided an apparatus for ultrasound classification of breast lesions, the apparatus comprising a processor and a memory; the memory has stored therein a program that is loaded and executed by the processor to implement the method of classifying an ultrasound breast lesion provided by the first aspect.
In a fourth aspect, a computer-readable storage medium is provided, in which a program is stored which, when being executed by a processor, is adapted to carry out the method for classifying an ultrasound breast lesion provided by the first aspect.
The beneficial effects of this application include at least: by segmenting the target ultrasound breast image into n for each frame of the target ultrasound breast image1*n2A data block; converting each data block into p1*p2Vector data in the c dimension; n is to be1*n2Merging the vector data corresponding to each data block to obtain n1n2×p1p2c two-dimensional data matrix; generating a position coding vector corresponding to the position according to the position of each data block in the target ultrasonic mammary gland image, and adding the position coding vector into a two-dimensional data matrix to obtain a data matrix to be processed; inputting a data matrix to be processed into a pre-trained image classification network to obtain focus property classification corresponding to the target ultrasonic mammary gland image; the problem of low classification efficiency when the ultrasonic breast images are classified manually can be solved; because automatic classification can be realized through the image classification model, the accuracy and the efficiency of classifying the ultrasonic breast image can be improved.
In addition, the image classification is realized by combining a full-connection network with other calculation modes instead of convolution operation by setting the image classification network, so that the calculation amount and difficulty of the model can be reduced, and the calculation efficiency of the model is improved.
In addition, after the image is divided into a plurality of data blocks, each data block is converted into vector data and combined to be input into the image classification network, so that the calculation amount of the input image classification network can be reduced, and the model calculation efficiency can be further improved.
In addition, the generalization capability of the image classification network can be improved by setting the number of the multi-head attention module and the feedforward neural module to be a plurality.
In addition, the generalization capability of the image classification network can be improved by obtaining the image classification network based on weight random activation training.
The foregoing description is only an overview of the technical solutions of the present application, and in order to make the technical solutions of the present application more clear and clear, and to implement the technical solutions according to the content of the description, the following detailed description is made with reference to the preferred embodiments of the present application and the accompanying drawings.
Detailed Description
The following detailed description of embodiments of the present application will be described in conjunction with the accompanying drawings and examples. The following examples are intended to illustrate the present application but are not intended to limit the scope of the present application.
Optionally, in the present application, an execution subject of each embodiment is taken as an example of an electronic device with computing capability, where the electronic device may be a terminal or a server, and the terminal may be an ultrasound imaging device, a computer, a mobile phone, a tablet computer, and the like, and the embodiment does not limit the type of the electronic device.
The classification method of the ultrasound breast lesion provided by the present application is described below.
Fig. 1 is a flowchart of a classification method of an ultrasound breast lesion provided in an embodiment of the present application. The method at least comprises the following steps:
step 101, target ultrasonic breast information to be classified is obtained, wherein the target ultrasonic breast information is a target ultrasonic breast image or a target ultrasonic breast video, and the target ultrasonic breast video comprises at least two frames of target ultrasonic breast images.
Optionally, the target ultrasound breast image is a whole ultrasound breast image or a breast lesion region image.
Step 102, for each frame of target ultrasonic breast image, dividing the target ultrasonic breast image into n1*n2A data block; wherein n is1Number of data blocks divided for image height direction, n2Number of data blocks divided for image width direction, n1,n2Is a positive integer.
In one example, by a preset dimension p1×p2And segmenting the target ultrasonic mammary gland image. P corresponding to different data blocks1And p2The same or different. p is a radical of1And p2Can be set by a user or set by default in the electronic equipment, and the embodiment does not adopt p1And p2The value of (A) is defined.
Step 103, converting each data block into p1*p2Vector data of dimension c, p1,p2For the size of each data block.
Wherein n is1=H/p1,n2=W/p2(ii) a H is the height of the input image, W is the width of the input image, p1For the height of the divided data block, p2The width of the divided data block; n is1Number of data blocks divided for image height direction, n2The number of data blocks divided in the image width direction.
In the embodiment, one target ultrasonic breast image is divided into a plurality of data blocks, and each data block is converted into vector data, so that the data volume of the input image classification model can be compressed, and the calculation efficiency is improved.
Optionally, each data block is converted to p1*p2The way of vector data of dimension c includes but is not limited to: converting the data blocks into corresponding characteristic vectors by using a neural network to obtain vector data; or, each pixel value in the data block is taken as vector data, and the embodiment does not limit the manner of obtaining the vector data.
Step 104, adding n1*n2Data of a personMerging vector data corresponding to the blocks to obtain n1n2×p1p2c two-dimensional data matrix.
And 105, generating a position coding vector corresponding to the position according to the position of each data block in the target ultrasonic breast image, and adding the position coding vector into the two-dimensional data matrix to obtain a to-be-processed data matrix.
The position-encoding vector is used to indicate the position of the data block in the target ultrasound breast image.
And 106, inputting the data matrix to be processed into a pre-trained image classification network to obtain the focus property classification corresponding to the target ultrasonic mammary gland image.
Wherein, the lesion property classification is used for indicating the corresponding pathological property of the target ultrasonic breast image.
Referring to fig. 2, the image classification network includes a multi-headed attention module 21, a feed-forward neural module 22, and a multi-layered fully-connected classification module 23.
The multi-headed attention module 21 includes three fully connected networks, an activation function layer and a multidimensional logistic regression layer. Of course, the multi-head attention module 21 may also include other network structures, and the embodiment is not listed here. The input of each full-connection network is a data matrix to be processed, and the output is characteristic data with preset dimensionality; multiplying feature data output by two preset fully-connected networks, dividing the multiplied feature data by a preset scale factor, and then obtaining a logistic regression result through multi-dimensional logistic regression calculation; multiplying the logistic regression result with the characteristic data of the other fully-connected network to obtain an output result of the multi-head attention module; the other full-connection network is a full-connection network which is different from the preset two full-connection networks in the three network branches;
in one example, the output of the multi-head attention module is:
wherein Q, K and V are results of full connection of the input data blocks respectively, and d is a scale factor.
The feedforward neural module 22 includes a fully connected network, a linear rectification activation function connected to the fully connected network, and layer normalization; the output result of the multi-head attention module is subjected to full-connection network, linear rectification activation function connected with the full-connection network and layer normalization to obtain the output result of the feedforward neural module.
In one example, the output of the feedforward neural module 22 is:
zout=LN(RELU(MLP(RELU(MLP(zin) ))) wherein, z) isinIs the input of a feedforward neural network, zoutFor the output of the feedforward neural network, LN is the layer normalization operation, RELU is the linear rectification activation function, and MLP is the full-link layer.
The multi-layer full-connection classification module 23 receives the output result of the feedforward neural module and then performs full-connection layer processing; and carrying out layer normalization processing on the processed data to obtain focus property classification.
Wherein the logistic regression calculation can be implemented by softmax in the multi-head attention module 21.
In the feedforward neural module 22, the number of network units formed by the fully-connected network and the linear rectification and activation function is one or more, and the number of the network units is illustrated as two in fig. 2.
Optionally, the lesion property classification comprises: benign type and malignant type; alternatively, the cancer includes at least one of benign type, malignant type, inflammatory type, adenopathy type, proliferative type, ductal ectasia type, early stage invasive cancer, non-invasive cancer, lobular adenocarcinoma, ductal adenocarcinoma, medullary carcinoma, hard cancer, simple cancer, carcinoma in situ, early stage cancer, invasive cancer, undifferentiated cancer, poorly differentiated cancer, and highly differentiated cancer. In other embodiments, the lesion property classification may be classified into other types, and the classification manner of the lesion property classification is not limited in this embodiment.
Optionally, the number of the multi-head attention module and the feedforward neural module is multiple, so that the generalization of the model can be improved.
In this embodiment, the image classification network is obtained by training the initial neural network model using training data. The training data comprises a sample data matrix corresponding to the sample ultrasound mammary gland image and a classification label corresponding to the sample data matrix. In the training process, the sample data matrix is input into the initial neural network model to obtain a model result; and calculating the difference between the model result and the classification label by using a preset loss function, and performing iterative training on the initial neural network model according to the calculation result to finally obtain the image classification network. Illustratively, the image classification network is obtained by randomly activating training based on the weights, so that the generalization of the model can be further improved.
The type of the classification label corresponds to the output type of the image classification network, and the network structure of the image classification network is the same as that of the initial neural network model.
Optionally, if the target ultrasound breast image is an image in the target ultrasound breast video, the method further includes: after lesion property classification is obtained according to each frame of target ultrasonic breast image, the property classification corresponding to the target ultrasonic breast video is determined according to the lesion property classification obtained from each frame of target ultrasonic breast image in the target ultrasonic breast video.
The method for determining the lesion property classification corresponding to the target ultrasonic breast video according to the lesion property classification obtained from each frame of target ultrasonic breast image in the target ultrasonic breast video comprises the following steps: if no image with the focus property classification as malignant exists in each frame of target ultrasonic breast image of the target ultrasonic breast video, counting the focus property classification with the largest number in the focus property classifications corresponding to each frame of target ultrasonic breast image, and determining the focus property classification obtained through counting as the focus property classification corresponding to the target ultrasonic breast video; and if the focus property classification is a malignant image in each frame of target ultrasonic breast image of the target ultrasonic breast video, determining the focus property classification corresponding to the target ultrasonic breast video as malignant.
In summary, the classification method of the ultrasound breast lesion provided in this embodiment is implemented by performing ultrasound on the breast for each frame of the targetImage, segmenting the target ultrasound breast image into n1*n2A data block; converting each data block into p1*p2Vector data in the c dimension; n is to be1*n2Merging the vector data corresponding to each data block to obtain n1n2×p1p2c two-dimensional data matrix; generating a position coding vector corresponding to the position according to the position of each data block in the target ultrasonic mammary gland image, and adding the position coding vector into a two-dimensional data matrix to obtain a data matrix to be processed; inputting a data matrix to be processed into a pre-trained image classification network to obtain focus property classification corresponding to the target ultrasonic mammary gland image; the problem of low classification efficiency when the ultrasonic breast images are classified manually can be solved; because automatic classification can be realized through the image classification model, the accuracy and the efficiency of classifying the ultrasonic breast image can be improved.
In addition, the image classification is realized by combining a full-connection network with other calculation modes instead of convolution operation by setting the image classification network, so that the calculation amount and difficulty of the model can be reduced, and the calculation efficiency of the model is improved.
In addition, after the image is divided into a plurality of data blocks, each data block is converted into vector data and combined to be input into the image classification network, so that the calculation amount of the input image classification network can be reduced, and the model calculation efficiency can be further improved.
In addition, the generalization capability of the image classification network can be improved by setting the number of the multi-head attention module and the feedforward neural module to be a plurality.
In addition, the generalization capability of the image classification network can be improved by obtaining the image classification network based on weight random activation training.
Fig. 3 is a block diagram of an ultrasound breast lesion classification apparatus according to an embodiment of the present application. The device at least comprises the following modules: an information acquisition unit 310, an image segmentation unit 320, a data conversion unit 330, a vector merging unit 340, a matrix generation unit 350, and a lesion classification unit 360.
The information acquiring unit 310 is configured to acquire target ultrasound breast information to be classified, where the target ultrasound breast information is a target ultrasound breast image or a target ultrasound breast video, and the target ultrasound breast video includes at least two frames of target ultrasound breast images;
an image segmentation unit 320 for segmenting each frame of the target ultrasound breast image into n1*n2A data block; wherein n is1Number of data blocks divided for image height direction, n2Number of data blocks divided for image width direction, n1,n2Is a positive integer;
a data conversion unit 330 for converting each data block into p1*p2Vector data of dimension c, said p1,p2For each data block size; wherein n is1=H/p1,n2=W/p2(ii) a H is the height of the input image, W is the width of the input image, p1For the height of the divided data block, p2The width of the divided data block; n is1Number of data blocks divided for image height direction, n2The number of data blocks divided in the image width direction;
a vector merging unit 340 for merging n1*n2Merging the vector data corresponding to each data block to obtain n1n2×p1p2c two-dimensional data matrix;
a matrix generating unit 350, configured to generate a position coding vector corresponding to the position according to the position of each data block in the target ultrasound breast image, and add the position coding vector to the two-dimensional data matrix to obtain a to-be-processed data matrix;
and the lesion classification unit 360 is configured to input the data matrix to be processed into a pre-trained image classification network, so as to obtain a lesion property classification corresponding to the target ultrasound breast image.
For relevant details reference is made to the above-described method embodiments.
It should be noted that: the classification device for an ultrasound breast lesion provided in the above embodiment is only exemplified by the division of the above functional modules when classifying the ultrasound breast lesion, and in practical applications, the above function distribution may be completed by different functional modules according to needs, that is, the internal structure of the classification device for an ultrasound breast lesion is divided into different functional modules, so as to complete all or part of the above described functions. In addition, the ultrasound breast lesion classification device provided in the above embodiments and the ultrasound breast lesion classification method embodiment belong to the same concept, and specific implementation processes thereof are described in detail in the method embodiment and are not described herein again.
Fig. 4 is a block diagram of an ultrasound breast lesion classification apparatus according to an embodiment of the present application. The apparatus comprises at least a processor 401 and a memory 402.
Processor 401 may include one or more processing cores such as: 4 core processors, 8 core processors, etc. The processor 401 may be implemented in at least one hardware form of a DSP (Digital Signal Processing), an FPGA (Field-Programmable Gate Array), and a PLA (Programmable Logic Array). The processor 401 may also include a main processor and a coprocessor, where the main processor is a processor for Processing data in an awake state, and is also called a Central Processing Unit (CPU); a coprocessor is a low power processor for processing data in a standby state. In some embodiments, the processor 401 may be integrated with a GPU (Graphics Processing Unit), which is responsible for rendering and drawing the content required to be displayed by the display screen. In some embodiments, the processor 401 may further include an AI (Artificial Intelligence) processor for processing computing operations related to machine learning.
Memory 402 may include one or more computer-readable storage media, which may be non-transitory. Memory 402 may also include high speed random access memory, as well as non-volatile memory, such as one or more magnetic disk storage devices, flash memory storage devices. In some embodiments, a non-transitory computer readable storage medium in memory 402 is used to store at least one instruction for execution by processor 401 to implement the method of classifying an ultrasound breast lesion provided by the method embodiments herein.
In some embodiments, the ultrasound breast lesion classification device may further include: a peripheral interface and at least one peripheral. The processor 401, memory 402 and peripheral interface may be connected by bus or signal lines. Each peripheral may be connected to the peripheral interface via a bus, signal line, or circuit board. Illustratively, peripheral devices include, but are not limited to: radio frequency circuit, touch display screen, audio circuit, power supply, etc.
Of course, the classification device for the ultrasound breast lesion may also include fewer or more components, which is not limited in this embodiment.
Optionally, the present application further provides a computer readable storage medium, in which a program is stored, the program being loaded and executed by a processor to implement the method for classifying an ultrasound breast lesion of the above-mentioned method embodiment.
Optionally, the present application further provides a computer product comprising a computer readable storage medium, in which a program is stored, the program being loaded and executed by a processor to implement the method for classifying an ultrasound breast lesion of the above-mentioned method embodiment.
The technical features of the embodiments described above may be arbitrarily combined, and for the sake of brevity, all possible combinations of the technical features in the embodiments described above are not described, but should be considered as being within the scope of the present specification as long as there is no contradiction between the combinations of the technical features.
The above-mentioned embodiments only express several embodiments of the present application, and the description thereof is more specific and detailed, but not construed as limiting the scope of the invention. It should be noted that, for a person skilled in the art, several variations and modifications can be made without departing from the concept of the present application, which falls within the scope of protection of the present application. Therefore, the protection scope of the present patent shall be subject to the appended claims.