Asynchronous training self-adaptive preprocessing medical image segmentation method
Through the adaptive preprocessing method of asynchronously training the gated convolution Transformer model, the accuracy and stability problems of Transformer on small-scale, low-quality medical imaging data sets are solved, and the performance improvement and stability in scenarios lacking pre-training are achieved. Computing resource optimization.
Patent Information
- Application Number
- CN202410721861.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-06-05
- Publication Date
- 2024-10-29
AI Technical Summary
The existing Transformer model has poor accuracy and stability on small-scale, low-quality medical imaging data sets, and lacks adaptive preprocessing and bias induction of convolutional networks, resulting in its performance not being fully utilized.
Using asynchronous training gated convolution Transformer model, through adaptive preprocessing steps including data reading, cropping, spatial scaling, data enhancement and block cropping, a U-shaped network architecture is constructed, combined with convolution feature learning, to optimize the training process and balance Convergence of the convolution and Transformer parts.
It improves the accuracy and stability of the model on small-scale, low-quality medical data sets, optimizes the training process, makes full use of computing resources, and effectively couples the features of convolution and Transformer.
Smart Images

Figure CN118864488A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of medical image processing, and in particular to an asynchronously trained adaptive preprocessing medical image segmentation method. Background Art
[0002] With the development of deep learning technology and Transformer models, the accuracy of medical image segmentation tasks using Transformer models has been continuously improved, and the accuracy indicators of some specific image parts have gradually surpassed convolutional networks. However, in order to fully exert the performance of the Transformer model, it is usually necessary to pre-train on a large-scale, high-quality medical image dataset, and then fine-tune it for downstream tasks; however, pre-training usually consumes a lot of time and computing resources, and large-scale, high-quality medical image datasets are very scarce; in the absence of pre-training, the accuracy and stability of the Transformer model on common small-scale, low-quality medical datasets are not as good as convolutional networks. The main reasons include the lack of adaptive pre-processing of the data and the lack of bias induction similar to convolutional networks in the Transformer structure, that is, the sparsity assumption of the neural network pathway;
[0003] In the prior art, the Transformer model is combined with the convolutional network to obtain a method based on the Transformer-convolutional hybrid model, such as CoTr, UNETR, TransUNet, etc., which all follow the three stages of data preprocessing, training, and reasoning; however, there are still the following two problems:
[0004] (1) Preprocessing parameters need to be specified manually, and additional debugging time is required to achieve the highest performance on various data sets;
[0005] (2) The Transformer and convolutional modules are simply cascaded and trained in parallel. Due to the different convergence speeds of the two, the final network tends to converge to the convolutional module, which prevents the Transformer from fully exerting its performance.
[0006] To this end, the present invention provides an adaptive preprocessing medical image segmentation method based on an asynchronously trained gated convolutional Transformer model to improve its accuracy and stability on small-scale, low-quality medical datasets. Summary of the invention
[0007] The purpose of the present invention is to provide an asynchronously trained adaptive preprocessing medical image segmentation method, which improves its accuracy and stability on small-scale, low-quality medical datasets by constructing an adaptive preprocessing-training method and combining the feature learning characteristics of convolution in the absence of pre-training.
[0008] The present invention can be implemented by the following technical solution: An asynchronously trained adaptive preprocessing medical image segmentation method comprises the following steps:
[0009] Step 1: Adaptively preprocess the medical images and build a U-shaped network architecture based on the gated convolutional Transformer model. The adaptive preprocessing steps before building the network include data reading and data set division, image cropping, spatial scaling, data enhancement, normalization, and block cropping.
[0010] Step 2: asynchronously training the preprocessed image data based on the U-shaped network architecture, including determining training parameters, calculating network loss and performing back propagation;
[0011] Step 3: Perform reasoning evaluation on the U-shaped network model, calculate corresponding index values and evaluate the performance of the U-shaped network architecture accordingly.
[0012] A further improvement of the present invention is that in step one, the spatial scaling is performed on the cropped image according to the spatial scale information, and the size of the scaling factor drives the probability value of the data enhancement to change. As the scaling factor increases, the probability value increases linearly to achieve stronger data enhancement.
[0013] A further improvement of the present invention is that data enhancement specifically includes random rotation, scaling, flipping, Gaussian noise addition, Gaussian blurring, contrast adjustment, low resolution simulation, and Gamma transformation according to a certain probability.
[0014] A further improvement of the present invention is that the block cropping in step 1 is based on the GPU memory capacity and network model size of the operating environment, and the cropping size of 128 voxels in the default state is corrected to determine the batch size of the model input and make full use of the GPU memory.
[0015] The further improvement of the present invention is that: the U-shaped network model includes an encoder and a decoder on both sides and three skip connections and a bottleneck layer;
[0016] In each skip connection layer, it passes through an even number of gated convolutional Transformer models and forms a skip connection before the downsampling layer to be transmitted to the decoder. Each downsampling layer uses convolution to halve the feature map in the D, H, and W dimensions, and expands the number of channels to twice that of this layer. In the decoder, the output feature map of each upsampling layer is added to the skip connection layer and cascaded into the gated convolutional Transformer model of the decoder.
[0017] A further improvement of the present invention is that the gated convolutional Transformer model is based on the window shift Transformer, and the Q, K, and V matrices in the window self-attention layer are convolved and the Hadamard product is calculated with the output of the window self-attention.
[0018] A further improvement of the present invention is that the training parameters in step 2 include the number of iterations and the asynchronous training step length, and both are manually set according to the size and distribution of the training data set.
[0019] A further improvement of the present invention is that the network loss only calculates the loss of the final output of the network, and if the asynchronous training step is not reached during back propagation, the learnable parameters of the convolution part are kept frozen, that is, the parameters are not updated; if the asynchronous training step is reached, all network parameters are updated simultaneously; if the maximum training step is reached, the training is terminated and step three is performed; if the maximum training step is not reached, the training is continued.
[0020] A further improvement of the present invention is that the reasoning evaluation process in step 3 includes:
[0021] Generate a Gaussian weight code at the center of the image block with Gaussian distribution;
[0022] Taking half the side length of the image block as the sliding step, sliding sampling is performed on the image to be inferred, the cropped blocks are input into the trained model, and the output values are weighted with Gaussian weight codes. All output channels are calculated by the Softmax function to obtain the predicted mask of the entire image.
[0023] According to the predicted mask of each organ image, the DI CE, mIOU and HD95 indicators are calculated on the true mask of each organ image in the test set.
[0024] Compared with the prior art, the present invention has the following beneficial effects:
[0025] 1. The present invention corrects the probability value of data enhancement by a scaling factor of spatial scaling, so that data anisotropic in spatial scale can obtain stronger data enhancement, thereby optimizing the training process;
[0026] 2. In the block cropping step, the cropping edge length is automatically corrected according to the memory information and model size, which saves the time of manual calculation and enables the training framework to fully utilize the performance of the computing platform;
[0027] 3. An asynchronous training step size is introduced, which is usually an integer greater than 1 and less than 5, so as to balance the convergence of the convolution and Transformer parts in a planned way, so that the network can better exert the performance of the combination of the two;
[0028] 4. A gated convolutional Transformer is proposed. The Q, K, and V matrices in the Transformer's self-attention layer are convolved and then the Hadamard product is calculated with the output of the self-attention layer. Compared with the simple cascade combination, it can more effectively couple the features of the convolution and Transformer, which is conducive to back-propagation. BRIEF DESCRIPTION OF THE DRAWINGS
[0029] In order to facilitate understanding by those skilled in the art, the present invention is further described below with reference to the accompanying drawings.
[0030] Figure 1 It is a schematic diagram of the execution flow of the method of the present invention;
[0031] Figure 2 A schematic diagram of a U-shaped network architecture of the present invention;
[0032] Figure 3 It is a schematic diagram of the structure of the gated convolutional Transformer model of the present invention. DETAILED DESCRIPTION
[0033] In order to further explain the technical means and effects adopted by the present invention to achieve the predetermined invention purpose, the specific implementation methods, structures, features and effects of the present invention are described in detail below in conjunction with the accompanying drawings and preferred embodiments.
[0034] See also Figure 1 As shown, an asynchronous training adaptive preprocessing medical image segmentation method includes the following steps:
[0035] Step 1: Adaptively preprocess the image, specifically:
[0036] S1: Data reading
[0037] Divide the collected medical imaging data (including natural images, CT, MRI, etc.) that need to be trained into training sets, validation sets, and test sets and store them in different folders respectively;
[0038] Read the image data from the above different data sets into memory and automatically generate a json file containing information such as data-label pairs, image modality, segmentation mask number, etc.;
[0039] It should be noted that for the division of the data set, if there is a pre-set division scheme, the division will be carried out according to the scheme; if there is no pre-set one, a five-fold cross-validation division scheme will be automatically generated, and the training set will be randomly divided at a ratio of 20% to obtain the validation set.
[0040] S2: Image Cropping
[0041] Crop the area that does not contain data information in the image data of each data set;
[0042] S3: Spatial Scaling
[0043] Interpolate and scale the cropped image according to the spatial scale information, where the spatial scale information specifically refers to the physical distance between two voxels;
[0044] S4: Data Augmentation
[0045] Random rotation, scaling, flipping, Gaussian noise addition, Gaussian blurring, contrast adjustment, low resolution simulation, and Gamma transformation are performed according to a certain probability; wherein the size of the probability value is modified according to the scaling factor in step S3. If the scaling factor is large, it means that the spatial anisotropy of the image is more significant, and the probability value is linearly increased to introduce stronger data enhancement;
[0046] S5: Normalization
[0047] Normalize the image data to make its distribution more suitable for the convergence of subsequent models;
[0048] S6: Block cropping
[0049] Calculate the GPU memory information and model size of the running environment, make corrections on the default crop size of 128 voxels, and then determine the input batch size so that the model can make full use of the GPU memory as much as possible;
[0050] S7: Build training network and data input
[0051] Construct a U-shaped network model based on parameters such as channel information and block cropping size, and use the processed data as model input;
[0052] Specifically, the input channel input C in the channel information is determined by the image modality of the input image. For example, natural images usually have three channels, RGB, and CT images only contain one channel because they only have grayscale information. The number of channels of MRI images is equal to the number of sequences used during scanning.
[0053] The U-shaped network used in training is as follows Figure 2 As shown, the encoder is on the left and the decoder is on the right. By default, it contains four layers, including three skip connection layers and one bottleneck layer.
[0054] Taking the input image data size of B×C in×D×H×W as an example to illustrate the architecture logic of the U-type network model:
[0055] After convolution downsampling in the embedding layer, a sequence of size B × L × C is formed. By default, C = 96, D = H = W = 128 voxels, and the specific size is determined by the adaptive preprocessing step, so that the model can make full use of the GPU memory of the current running environment as much as possible.
[0056] In each skip connection layer, it passes through 2n (n is a positive integer) gated convolutional Transformer models, and forms a skip connection before the downsampling layer to be transmitted to the decoder. Each downsampling layer uses convolution to halve the feature map in the D, H, and W dimensions (depth, height, and width, respectively), and expands the number of channels to twice that of the current layer. In the decoder, the output feature map of each upsampling layer is added to the skip connection layer and cascaded into the gated convolutional Transformer model of the decoder;
[0057] Among them, the gated convolution Transformer model structure is as follows Figure 3 As shown in the figure, based on the window shift Transformer, the Q, K, and V matrices in the window self-attention layer are convolved and the Hadamard product is calculated with the output of the window self-attention. The main steps include:
[0058] Use convolution instead of fully connected layers to generate Q, K, V matrices;
[0059] Concatenate the Q, K, and V matrices in the channel dimension and input them into the gated convolution block;
[0060] The gated convolution block consists of two convolutional layers and corresponding ReLU activation layers and batch normalization layers. After processing the concatenated features of the Q, K, and V matrices, the Hadamard product is calculated with the output of the window self-attention.
[0061] The feature map is output through the FFN layer (including a layer normalization and a fully connected layer).
[0062] Step 2: Train the preprocessed data based on the U-shaped network model
[0063] (1) Determine training parameters
[0064] Determine the number of iterations and asynchronous training step size. The above parameters can be manually specified according to the size and distribution of the specific data set. If the data set distribution is convenient for optimizing the target loss, the network will converge quickly and the number of iterations will not need to be large.
[0065] (2) Perform asynchronous training
[0066] In each iteration, the network loss of the gated convolution and Transformer parts is forward calculated and back-propagated simultaneously;
[0067] In back propagation, if the asynchronous training step is not reached, the learnable parameters of the convolution part are kept frozen, that is, no parameter update is performed. The learnable parameters include the parameters of the convolution kernel and bias in each convolution layer. If the asynchronous training step is reached, all network parameters are updated at the same time. If the maximum training step is reached, the training is terminated and step three is performed. If the maximum training step is not reached, training is continued.
[0068] It should be noted that the network loss function uses DI CE+CE (cross entropy) loss by default, which only calculates the loss of the final output of the network, that is, no deep supervision method is used;
[0069] The so-called back propagation, also known as error back propagation or loss back propagation, is an algorithm for gradient descent of deep artificial neural networks. It uses the chain rule to calculate the gradient of the loss function with the weight of each layer of the network as a variable, so as to update the weight of the network model to minimize the loss function.
[0070] The so-called deep supervision method refers to adding auxiliary output layers to certain intermediate layers of deep artificial neural networks, which serve as additional network branches during the training process to alleviate problems such as gradient vanishing and slow convergence.
[0071] Step 3: Inference evaluation of the U-shaped network model
[0072] Generate Gaussian weight code: Generate a Gaussian weight code at the center of the image block with Gaussian distribution;
[0073] Block reasoning and combination: Use half the side length of the image block as the sliding step, perform sliding sampling on the image to be reasoned, input the cropped blocks into the trained model, and weight the output values with Gaussian weight codes. All output channels are calculated by the Softmax function to obtain the prediction mask of the entire image. If a five-fold cross-validation partitioning scheme is generated in step 1, the output of the five schemes is averaged to calculate the prediction mask;
[0074] Calculation indicators: According to the predicted masks of each organ, the DI CE, mIOU and HD95 indicators are calculated on the true masks of each organ in the test set to evaluate the performance of the model; among them, DI CE and m IOU are used to measure the regional similarity of the segmentation, and HD95 is used to measure the boundary accuracy of the segmentation.
[0075] The above description is only a preferred embodiment of the present invention and does not limit the present invention in any form. Although the present invention has been disclosed as a preferred embodiment as above, it is not used to limit the present invention. Any technical personnel in this field can make some changes or modify the technical contents disclosed above into equivalent embodiments without departing from the scope of the technical solution of the present invention. However, any simple modification, equivalent change and modification made to the above embodiments according to the technical essence of the present invention without departing from the content of the technical solution of the present invention still fall within the scope of the technical solution of the present invention.
Claims
1. An asynchronously trained adaptive preprocessing medical image segmentation method, characterized in that: The steps include: Step 1: Adaptively preprocess the medical images and build a U-shaped network architecture based on the gated convolutional Transformer model. The adaptive preprocessing steps before building the network include data reading and data set division, image cropping, spatial scaling, data enhancement, normalization, and block cropping. Step 2: asynchronously training the preprocessed image data based on the U-shaped network architecture, including determining training parameters, calculating network loss and performing back propagation; Step 3: Perform reasoning evaluation on the U-shaped network model, calculate corresponding index values and evaluate the performance of the U-shaped network architecture accordingly.
2. The method for adaptive preprocessing of medical images by asynchronous training according to claim 1, characterized in that: The spatial scaling described in step 1 interpolates and scales the cropped image according to the spatial scale information, and the size of the scaling factor drives the probability value of data enhancement to change. As the scaling factor increases, the probability value increases linearly to achieve stronger data enhancement.
3. The method for adaptive preprocessing of medical images by asynchronous training according to claim 2, characterized in that: The data enhancement specifically includes random rotation, scaling, flipping, Gaussian noise addition, Gaussian blur, contrast adjustment, low resolution simulation, and Gamma transformation according to a certain probability.
4. The method for adaptive preprocessing of medical images by asynchronous training according to claim 1, characterized in that: The block cropping described in step 1 is based on the GPU memory capacity and network model size of the operating environment, and the default cropping size of 128 voxels is modified to determine the batch size of the model input and make full use of the GPU memory.
5. The method for adaptive preprocessing of medical images by asynchronous training according to claim 1, characterized in that: The U-shaped network model includes an encoder and a decoder on both sides, three skip connections and a bottleneck layer; In each skip connection layer, it passes through an even number of gated convolutional Transformer models and forms a skip connection before the downsampling layer to be transmitted to the decoder. Each downsampling layer uses convolution to halve the feature map in the D, H, and W dimensions, and expands the number of channels to twice that of this layer. In the decoder, the output feature map of each upsampling layer is added to the skip connection layer and cascaded into the gated convolutional Transformer model of the decoder.
6. The method for adaptive preprocessing of medical images by asynchronous training according to claim 5, characterized in that: The gated convolutional Transformer model is based on the window shift Transformer, and performs Hadamard product calculation on the Q, K, and V matrices in the window self-attention layer after convolution processing and the output of the window self-attention.
7. According to the asynchronous training adaptive preprocessing medical image segmentation method described in claim 1, the training parameters in step 2 include the number of iterations and the asynchronous training step size, and both are manually set according to the size and distribution of the training data set.
8. According to the asynchronous training adaptive preprocessing medical image segmentation method of claim 7, the network loss only calculates the loss of the final output of the network, and if the asynchronous training step is not reached in the back propagation, the learnable parameters of the convolution part are kept frozen, that is, the parameters are not updated; if the asynchronous training step is reached, all network parameters are updated at the same time; if the maximum training step is reached, the training is terminated and step three is performed; if the maximum training step is not reached, the training is continued.
9. According to the method for adaptive preprocessing of asynchronous training for medical image segmentation of claim 1, the reasoning evaluation process in step 3 comprises: Generate a Gaussian weight code at the center of the image block with Gaussian distribution; Taking half the side length of the image block as the sliding step, sliding sampling is performed on the image to be inferred, the cropped blocks are input into the trained model, and the output values are weighted with Gaussian weight codes. All output channels are calculated by the Softmax function to obtain the predicted mask of the entire image. According to the predicted mask of each organ image, the DI CE, m IOU and HD95 indicators are calculated on the true mask of each organ image in the test set.
