Improved 3D medical image segmentation method based on SwinUnet
By introducing axial attention and SCConv3D modules in SwinUnet, the limitations of traditional 3D convolutional neural networks in capturing long-distance dependency information and the difficulty of local dependency information capture when data is insufficient, achieving more efficient medical image segmentation performance.
Patent Information
- Application Number
- CN202411695249.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-25
- Publication Date
- 2025-02-18
AI Technical Summary
Traditional 3D convolutional neural networks have limitations in capturing long-distance dependency information in medical images, while visual Transformers are difficult to effectively capture local dependency information when there is insufficient data, resulting in insufficient performance of the model in medical image segmentation tasks.
An improved 3D medical image segmentation method based on SwinUnet is adopted, combining Axial-Attention and SCConv3D modules. Axial-Attention reduces computational complexity and introduces relative position coding to enhance position sensitivity by decomposing the self-attention mechanism into axial attention. The SCConv3D module optimizes feature learning efficiency by reducing spatial and channel redundancy in convolutional neural networks.
It significantly improves the accuracy and computing efficiency of medical image segmentation, can capture local and global features in the image at the same time, and improves the model's segmentation performance and global context understanding ability.
Smart Images

Figure CN119478416A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of medical segmentation, and in particular to an improved 3D medical image segmentation method based on SwinUnet. Background Art
[0002] In the past, 3D convolutional neural networks (CNNs) have dominated the automatic segmentation of 3D medical images and achieved remarkable results. However, in order to control the number of network parameters, traditional convolution usually limits the size of the 3D convolution kernel to no more than 7×7×7, which makes CNN convolution show certain limitations in capturing long-distance dependency information. In contrast, the Visual Transformer (ViT) is effective in learning long-distance dependency information in images, but its parameters are large. What is more disadvantageous is that in the case of insufficient data, ViT has difficulty in effectively capturing local dependency information, and this ability is crucial to improving model performance at early levels, especially in image segmentation tasks.
[0003] The fusion of CNN and ViT features can give full play to the advantages of both: CNN is good at capturing local features and spatial correlations, while ViT excels in learning long-distance dependent information. This combination can capture both local and global features in medical image segmentation, thereby improving the segmentation performance of the model. In addition, ViT's self-attention mechanism can enhance the model's global context understanding. However, combining the two also brings some disadvantages, such as a significant increase in computational complexity and the number of parameters, resulting in higher requirements for hardware resources during training and inference. In addition, ViT's demand for large-scale data still exists, and when data is insufficient, the model may find it difficult to give full play to its advantages.
[0004] Although convolutional neural networks (CNNs) have shown excellent performance in various computer vision tasks, their high computational resource requirements are a significant bottleneck, partly due to the large amount of spatial and channel redundancy in the feature extraction process of the convolutional layers. To address this problem, recent research efforts have focused on compressing large, well-trained models on the one hand, and designing more lightweight models on the other. On this basis, a new type of efficient convolutional module, SCConv, is adopted. Its core purpose is to reduce the amount of computation and promote the learning of representative features by compressing the spatial and channel redundancy between features. The SCConv module consists of two key units: the spatial reconstruction unit (SRU) and the channel reconstruction unit (CRU), which use the separation reconstruction method to suppress spatial redundancy and the split transform fusion method to eliminate channel redundancy. It is worth noting that SCConv has the plug-and-play feature and can directly replace the standard convolutional layers in various convolutional neural networks. In this method, the model embedded with the SCConv module not only effectively reduces redundant features and significantly reduces the computational complexity and cost, but also achieves better performance in various visual tasks. However, the SCConv module is generally used for processing 2D images, so the SCConv3D module obtained by improving the original SCConv can be better used in models for 3D medical images. Summary of the invention
[0005] According to the technical problems mentioned in the above background technology, an improved 3D medical image segmentation method based on SwinUnet is provided. In order to reduce the complexity of calculating attention, the Axial-Attention adopted by the present invention decomposes the self-attention mechanism into two independent modules. The first module performs the self-attention operation in the height direction of the feature map, and the second module operates in the width direction. This method is called axial attention. By applying axial attention in the height and width directions respectively, the original self-attention mechanism can be effectively simulated and the calculation efficiency can be significantly improved. In order to make the attention calculation more sensitive to position information, a position bias term is also introduced, which is called relative position encoding. These bias terms are learned through training and can effectively encode the spatial structure of the image. And compared with the traditional self-attention mechanism, axial attention has a more obvious advantage in capturing the features of medical 3D images. At the same time, the present invention uses the SCConv3D module, which has a better effect in performance compared with the traditional CNN convolution module.
[0006] The technical means adopted by the present invention are as follows:
[0007] The improved 3D medical image segmentation method based on SwinUnet includes the following steps:
[0008] Step 1: Obtain n medical image images and label images corresponding to the medical image images to obtain a medical image set K and a label image set J;
[0009] Step 2: Merge the medical images and the corresponding labeled images in pairs to obtain an image data pair set P having medical images and labeled images;
[0010] Step 3: performing a preprocessing operation on the image data pair set P to obtain a preprocessed image data pair set T;
[0011] Step 4: Divide the preprocessed image data set T into a training set T1 and a validation set T2;
[0012] Step 5: Establish a segmentation model M; the segmentation model M includes: an AxialSc3D module, a SwinUnet downsampling module and a SwinUnet upsampling module;
[0013] Step 6: Input the image t2 after image preprocessing in the training set T1 into the segmentation model M, and obtain the final output feature map D1 after being processed by the PatchMerging module, the AxialSc3D module and the PatchExpand module;
[0014] Step 7: Obtain an optimized segmentation model M' after training with the training set T1;
[0015] Step 8: Preprocess the image in the test set T2 to obtain image t, input the image t into the segmentation model M' to obtain the segmentation result feature map D2, calculate the segmentation result feature map through the formula, and compare it with the annotated label image to obtain the current accuracy DICE coefficient after segmentation.
[0016] Furthermore, in step 5, the training set samples are input into the AxialSc3D module, the input is copied into two identical parts and respectively input into the SCConv3D module and the AxialAttention module for image feature extraction, the output results are combined and passed into the SwinUnet downsampling module, the same steps are repeated until the feature extraction is completed, the output is completed with the same feature extraction module, and it is upsampled in the SwinUnet upsampling module, the completed output result model is returned and the loss function and Dice function are calculated.
[0017] Furthermore, the AxialSc3D module includes: an AxialAttention module of axial attention and a SCConv3D module.
[0018] Furthermore, the AxialAttention module adopts the axial attention mechanism based on VIT; taking an image as an example, assuming that the size of the image is H×W, and the color channel is not considered; in self-attention, the working principle of Self-Attention is:
[0019]
[0020] Among them, Q represents the query matrix Query; K represents the key matrix Key; V represents the value matrix Value; d k Indicates the dimension of the key vector, used for scaling.
[0021] Furthermore, the AxialAttention module of the axial attention calculates attention along rows and columns respectively, decomposing the two-dimensional attention operation into two one-dimensional processes. The working principle is:
[0022] Perform attention along the row height direction:
[0023]
[0024] Where Q h , K h , V h are the queries, keys and values along the row direction;
[0025] Perform attention along the column width direction:
[0026]
[0027] Among them, Q w , K w , V w Represents queries, keys, and values along the columns.
[0028] Furthermore, the step 8 comprises the following steps:
[0029] Step 81: Using the Dice coefficient formula Calculate the Dice loss function;
[0030] Step 82: Use the Adam optimizer to train the segmentation model using the total loss function loss. Compared with the prior art, the present invention has the following advantages:
[0031] This paper proposes a medical image segmentation method that combines the features of the SCConv3D module and the AxialAttention module. AxialAttention significantly reduces the computational complexity by performing self-attention operations in the vertical and horizontal directions of the image, reducing the amount of calculation from O((H×W) 2 ) is reduced to O(H×W), thereby effectively reducing the consumption of computing resources. At the same time, the SCConv3D module further optimizes the feature learning efficiency and reduces the computational overhead by reducing the spatial and channel redundancy in the convolutional neural network.
[0032] On this basis, combining the characteristics of SCConv3D and AxialAttention, it is possible to capture local and global features in the image at the same time, retaining the convolution's accurate capture of local features, and giving full play to the Transformer's advantages in long-distance dependent information, significantly improving the effect of medical image segmentation and enhancing the model's global context understanding ability. BRIEF DESCRIPTION OF THE DRAWINGS
[0033] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative labor.
[0034] Figure 1 This is a structural diagram of the medical image segmentation model of the present invention.
[0035] Figure 2 This is the AxialAttention module diagram of the present invention.
[0036] Figure 3 This is the SCConv3D structure diagram of the present invention. DETAILED DESCRIPTION
[0037] In order to enable those skilled in the art to better understand the scheme of the present invention, the technical scheme in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work should fall within the scope of protection of the present invention.
[0038] It should be noted that the terms "first", "second", etc. in the specification and claims of the present invention and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchanged where appropriate, so that the embodiments of the present invention described herein can be implemented in an order other than those illustrated or described herein. In addition, the terms "including" and "having" and any variations thereof are intended to cover non-exclusive inclusions, for example, a process, method, system, product or device that includes a series of steps or units is not necessarily limited to those steps or units that are clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.
[0039] like Figure 1-3 As shown, the present invention provides an improved 3D medical image segmentation method based on SwinUnet, which combines the SCConv3D module and the AxialAttention module to improve the segmentation accuracy of 3D medical image segmentation.
[0040] The specific steps of this method are as follows: Medical image preprocessing:
[0041] Input medical imaging data in 3D format, such as nii, nii.gz, etc., and preprocess the images to make them more robust during training.
[0042] Image segmentation network training; the segmentation network includes the AxialSc3D feature extraction module, the PatchMerging downsampling module and the PatchExpend upsampling module, taking the five-dimensional data of the 3D image as input. The specific operations are as follows:
[0043] The preprocessed 3D images are divided into a training set and a validation set. The training set samples are input into the AxialSc3D feature extraction module. The input is copied into two identical parts and input into the SCConv3D module and the AxialAttention module for image feature extraction. The output results are combined and continuously passed into the SwinUnet downsampling module. The same steps are repeated until the feature extraction is completed. The output is completed with the same feature extraction module and upsampled in the SwinUnet upsampling module. The completed output result model is passed back to calculate the loss function and Dice function.
[0044] Identification and judgment of the segmentation network; input the verification set into the obtained output result model and calculate the loss function and Dice function; including:
[0045] Axial3D feature extraction module
[0046] The AxialSc3D feature extraction module consists of two parts, the first part is the AxialAttention module of axial attention, and the second part is the SCConv3D module.
[0047] The AxialAttention module uses the axial attention mechanism based on VIT. AxialAttention can be divided into row-attention and column-attention, which are usually used in combination.
[0048] The self-attention mechanism performs very well in performance, but one of its obvious drawbacks is that it causes a sharp increase in the number of parameters and computations. This problem is particularly serious when dealing with long sequence tasks and pixel points of images in NLP.
[0049] Take an image as an example, assuming that the size of the image is H×W (not considering the color channel). In self-attention, each pixel needs to calculate attention with all other pixels in the image, which means that each pixel will interact with H×W other pixels. Therefore, the total amount of calculation is O((H×W) 2 ). When the image resolution increases, the amount of calculation increases quadratically and becomes unbearable.
[0050] The working principle of Self-Attention is:
[0051]
[0052] Among them, Q is the query matrix (Query); K is the key matrix (Key); V is the value matrix (Value); d k is the dimension of the key vector, used for scaling.
[0053] Axial Attention reduces this computational burden by performing self-attention in the vertical and horizontal directions of the image. This reduces the amount of computation from O((H×W) 2 ) is reduced to O(H×W) because only one attention calculation needs to be processed in each direction. However, using row or column attention alone cannot capture the global information of the image. Only by combining the two can we achieve an effect similar to full attention, thus balancing performance and computational efficiency.
[0054] AxialAttention calculates attention along rows and columns respectively, decomposing the two-dimensional attention operation into two one-dimensional processes. Its working principle is:
[0055] Perform attention along the row (height) direction:
[0056]
[0057] Where Q h , K h , V h are queries, keys, and values along the row direction.
[0058] Perform attention along the column (width) direction:
[0059]
[0060] Where Q w , K w , V w are queries, keys and values along the column direction.
[0061] That is, the complete process is: first apply self-attention on one dimension of the image (such as height), then apply self-attention on another dimension (such as width), and finally combine the two to achieve an effect similar to global attention, but with higher computational efficiency.
[0062] This can be achieved in three different ways:
[0063] Method 1: out = RowAtten(x) + ColAtten(x)
[0064] Method 2: x1 = RowAtten(x), out = ColAtten(x1)
[0065] Method 3: x1 = ColAtten(x), out = RowAtten(x1)
[0066] SCConv3D is based on the SCConv module and has been adjusted to be more suitable for the calculation of 3D images.
[0067] Convolutional neural networks (CNNs) perform well in computer vision tasks, but their high performance is often accompanied by huge computing resource consumption, mainly because the convolutional layer extracts a large number of redundant features. To optimize this, current research either reduces resource consumption by compressing large models after training, or designs lighter models.
[0068] SCConv3D is an efficient convolution module designed to reduce redundant computations in convolutional neural networks and facilitate more efficient feature learning. It achieves this goal through two key units:
[0069] SRU3D (Spatial Reconstruction Unit): It uses the separation reconstruction method to suppress spatial redundancy and reduce unnecessary spatial information processing.
[0070] The core goal of the separation operation is to distinguish feature maps that contain rich information from feature maps with less spatial information. We use the scaling factor in the group normalization (GN) layer to judge and evaluate the amount of information carried by each feature map, thereby achieving effective feature separation.
[0071]
[0072] where μ and σ are the mean and standard deviation of X, ε is a small positive constant added for division stability, and γ and β are trainable affine transformations.
[0073] The trainable parameter γ∈Rc in the group normalization (GN) layer is used here as a means to measure the spatial pixel variance of each batch and channel. Higher γ values indicate greater spatial pixel variations, and therefore reflect richer spatial information in the feature map. The normalized correlation weight γ∈Rc is calculated by Equation 2 to represent the importance of different feature maps. This method effectively utilizes the γ parameter in the GN layer as a weight to help distinguish which feature maps contain more spatial information.
[0074]
[0075] After obtaining the normalized correlation weight, it is remapped to the range of (0, 1) through the sigmoid function, and then the gate operation is performed. Specifically, a threshold is set (usually 0.5 in the experiment), and the weights exceeding the threshold are set to 1 to obtain the information weight W1, and the weights below the threshold are set to 0 to obtain the non-information weight W2. The entire process of obtaining the weight W can be expressed as the following formula 3:
[0076] W=Gate(Sigmoid(W γ (GN(X)));
[0077] In the last step, the input feature X is multiplied by weights W1 and W2 respectively to generate two weighted features: informative and less information Through this operation, the input features are separated into two parts: Contains meaningful and expressive spatial information, while Considered as redundant or low-information features.
[0078] In order to further reduce spatial redundancy, a cross-reconstruction operation is proposed. Instead of directly adding the two parts of features, the weighted different information features are fused through cross-combination to enhance the information flow between them. This reconstruction operation generates a feature map with richer information. Finally, by and Connect them to get the spatially refined feature map X w The whole process of reconstruction can be expressed as:
[0079]
[0080] in is element-wise multiplication, is the element-wise summation and ∪ is the concatenation. After applying SRU to the intermediate input features X, we not only separate the informative features from the less informative features, but also reconstruct them to enhance the representative features and suppress the redundant features in the spatial dimension.
[0081] CRU3D (Channel Reconstruction Unit): Reduces redundancy between channels through separation transformation and fusion strategies, improving the efficiency of the model in the channel dimension.
[0082] In order to solve the channel redundancy problem of features, a channel reconstruction unit (CRU3D) is introduced, which adopts the segmentation, transformation and fusion strategy. When the traditional k×k×k convolution is used to extract features, it usually leads to the generation of redundant feature maps along the channel dimension. Let M k ∈R c×k×k×k represents a k×k×k convolution kernel, X, Y∈R c×d×h×w Represent the input features and convolution output features respectively. Standard convolution can be defined as Y = M k X. On this basis, CRU3D replaces the standard convolution and reduces channel redundancy through three operations: split, transform, and fuse.
[0083] Split: Given a spatially refined feature X w ∈R c×d×h×w , first divide the channel of into two parts, occupying αC channels and (1-α)C channels respectively, where 0≤α≤1 is the split ratio. Then, 1×1×1 convolution is used to compress the channels of the feature map to improve the computational efficiency, and the compression ratio r is introduced to control the number of feature channels to balance the computational cost (r=2 is often used in experiments). After the segmentation and compression operations, the spatial refinement feature X w Divided into upper X up and lower X low .
[0084] Transform: X up Enter the upper transformation stage as a "rich feature extractor". Use more efficient convolution operations (such as GWC and PWC) to replace the expensive standard k×k×k convolution to extract high-level features and reduce computational costs. Due to the sparse convolution connection of GWC, the number of parameters and the amount of computation are reduced, but the information flow between channel groups is cut off, while PWC makes up for this information loss and promotes the flow of information across channels. Therefore, k×k×kGWC is performed on the same feature (the group size and 1×1×1PWC operation are set in the experiment, and finally the output results are added to form a fused feature map Y1. The upper transformation stage can be expressed as:
[0085]
[0086]
[0087] in:
[0088] M G and is the learnable weight matrix of GWC and PWC
[0089] and Y1∈R c×d×h×w They are the upper layer input and output feature maps respectively.
[0090] The upper transformation stage passes through the same feature map X up The GWC and PWC operations are combined to extract rich representative features Y1 at a lower computational cost.
[0091] The lower transformation stage converts X low Input, and apply a cheap 1×1×1 PWC operation to generate a feature map containing shallow details as a complement to the rich features of the upper layer. In addition, X low Features are reused to obtain more feature maps without additional computational cost. Finally, the generated features and reused features are concatenated to form the lower layer output Y2.
[0092]
[0093] in is the learnable weight matrix of PWC, ∪ is the concatenation operation, and Y2∈R c×d×h×w They are the lower layer input and output feature maps respectively.
[0094] Fuse: After performing the transformation, instead of directly connecting or adding the two types of features, the simplified SKNet method is used to adaptively merge the output features Y1 and Y2 from the up-conversion stage and the down-conversion stage. The Fuse part first applies global average pooling to collect global spatial information S with channel statistics. m ∈R c×1×1×1 , the calculation formula is:
[0095]
[0096] Next, we stack the upper and lower global channel descriptors S1, S2 together and use the channel soft attention operation to generate the feature importance vector β1, β2∈R c , as shown below:
[0097]
[0098] Finally, under the guidance of the feature importance vectors β1 and β2, the channel-refined feature Y can be obtained by merging the upper-layer feature Y1 and the lower-layer feature Y2 in a channel-wise manner, as shown below:
[0099] Y = β1Y1 + β2Y2 (8);
[0100] Using CRU3D, segmentation transformation and fusion strategy, further reduce the spatial refinement feature map X w Redundancy along the channel dimension. In addition, CRU3D extracts rich representative features through lightweight convolution operations, while handling redundant features through cheap operations and feature reuse schemes.
[0101] Compared with convolution, SCConv3D helps the model improve performance while reducing redundant features and significantly reduces computational complexity and resource consumption.
[0102] Example:
[0103] The present invention comprises an improved 3D medical image segmentation method based on SwinUnet, comprising the following steps:
[0104] Step 1: Obtain n medical image images and their corresponding label images to obtain a medical image set K and a label image set J;
[0105] Step 2: Merge the medical images and the labeled images in pairs in the corresponding order to obtain an image data pair set P having the medical images and the labeled images;
[0106] Step 3: Perform preprocessing operations on the image data pair set P to obtain a preprocessed image data pair set T;
[0107] Step 4: Divide the preprocessed image data set T into a training set T1 and a validation set T2;
[0108] Step 5: Establish the segmentation model M in this method. The model is divided into AxialSc3D module, SwinUnet downsampling module, and SwinUnet upsampling module.
[0109] Step 6: Input the image t2 after image preprocessing in the training set T1 into the segmentation model M, and finally obtain the output feature map D1 through the following modules:
[0110] Step 61: Input data t2 = (B, D, H, W1), pass through the first PatchMerging module, and output
[0111] Step 62: Input Data After the first AxialSc3D
[0112] The module extracts model features and outputs
[0113] Step 63: Input Data After the second PatchMerging module, the output
[0114] Step 64: Input Data The second AxialSc3D module extracts the model features and outputs
[0115] Step 65: Input Data After the third PatchMerging module, the output
[0116] Step 66: Enter Data The third AxialSc3D module extracts the model features and outputs
[0117] Step 67: Enter Data After the third PatchMerging module, the output
[0118] Step 68: Enter Data The fourth AxialSc3D module extracts model features and outputs
[0119] Step 69: Enter Data After the first PatchExpand module, the output
[0120] Step 610: Input Data The fifth AxialSc3D module extracts model features and outputs
[0121] Step 611: Input Data After the second PatchExpand module, the output
[0122] Step 612: Input Data The sixth AxialSc3D module extracts model features and outputs
[0123] Step 613: Input Data After the third PatchExpand module, the output
[0124] Step 614: Input Data The seventh AxialSc3D module extracts model features and outputs
[0125] Step 615: Input Data The fourth PatchExpand module extracts model features and outputs up4 = (B, D, H, W, Class), where Class refers to the number of segmentation categories;
[0126] Step 7: After training with the training set T1, the optimized segmentation model M' is obtained;
[0127] Step 8: Input the preprocessed image t in the test set T2 into the optimized segmentation model M' to obtain the segmentation result feature map D2, calculate the result effect through the formula, and compare it with the label influence.
[0128] Step 81: Using the Dice coefficient formula Calculate the Dice loss function.
[0129] Step 82: Use the Adam optimizer to train the segmentation model using the total loss function loss to adjust the training strategy.
[0130] The serial numbers of the above embodiments of the present invention are only for description and do not represent the advantages or disadvantages of the embodiments.
[0131] In the above embodiments of the present invention, the description of each embodiment has its own emphasis. For parts that are not described in detail in a certain embodiment, reference can be made to the relevant descriptions of other embodiments.
[0132] In the several embodiments provided in this application, it should be understood that the disclosed technical content can be implemented in other ways. Among them, the device embodiments described above are only schematic. For example, the division of the units can be a logical function division. There may be other division methods in actual implementation. For example, multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of units or modules, which can be electrical or other forms.
[0133] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple units. Some or all of the units may be selected according to actual needs to achieve the purpose of the present embodiment.
[0134] In addition, each functional unit in each embodiment of the present invention may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of software functional units.
[0135] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention is essentially or the part that contributes to the prior art or all or part of the technical solution can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including a number of instructions to enable a computer device (which can be a personal computer, server or network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present invention. The aforementioned storage medium includes: U disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), mobile hard disk, disk or optical disk and other media that can store program codes.
[0136] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit it. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or replace some or all of the technical features therein with equivalents. However, these modifications or replacements do not cause the essence of the corresponding technical solutions to deviate from the scope of the technical solutions of the embodiments of the present invention.
Claims
1. An improved 3D medical image segmentation method based on SwinUnet, characterized in that: The following steps are involved: Step 1: Obtain n medical image images and label images corresponding to the medical image images to obtain a medical image set K and a label image set J; Step 2: Merge the medical images and the corresponding labeled images in pairs to obtain an image data pair set P having medical images and labeled images; Step 3: performing a preprocessing operation on the image data pair set P to obtain a preprocessed image data pair set T; Step 4: Divide the preprocessed image data set T into a training set T1 and a validation set T2; Step 5: Establish a segmentation model M; the segmentation model M includes: an AxialSc3D module, a SwinUnet downsampling module and a SwinUnet upsampling module; Step 6: Input the image t2 after image preprocessing in the training set T1 into the segmentation model M, and obtain the final output feature map D1 after being processed by the PatchMerging module, the AxialSc3D module and the PatchExpand module; Step 7: Obtain an optimized segmentation model M' after training with the training set T1; Step 8: Preprocess the image in the test set T2 to obtain image t, input the image t into the segmentation model M' to obtain the segmentation result feature map D2, calculate the segmentation result feature map through the formula, and compare it with the annotated label image to obtain the current accuracy DICE coefficient after segmentation.
2. The improved 3D medical image segmentation method based on SwinUnet according to claim 1, characterized in that: In step 5, the training set samples are input into the AxialSc3D module, the input is copied into two identical parts and respectively input into the SCConv3D module and the AxialAttention module for image feature extraction, the output results are combined and input into the SwinUnet downsampling module, the same steps are repeated until the feature extraction is completed, the output is completed with the same feature extraction module, and it is upsampled in the SwinUnet upsampling module, the completed output result model is returned and the loss function and Dice function are calculated.
3. The improved 3D medical image segmentation method based on SwinUnet according to claim 1, characterized in that: The AxialSc3D module includes: an AxialAttention module of axial attention and a SCConv3D module.
4. The improved 3D medical image segmentation method based on SwinUnet according to claim 3, characterized in that: The AxialAttention module adopts the axial attention mechanism based on VIT. Taking an image as an example, assuming that the size of the image is H×W and the color channel is not considered, in self-attention, the working principle of Self-Attention is: Among them, Q represents the query matrix Query; K represents the key matrix Key; V represents the value matrix Value; d k Indicates the dimension of the key vector, used for scaling.
5. The improved 3D medical image segmentation method based on SwinUnet according to claim 3, characterized in that: The AxialAttention module of the axial attention calculates attention along rows and columns respectively, decomposing the two-dimensional attention operation into two one-dimensional processes. Its working principle is: Perform attention along the row height direction: Among them, Q h , K h , V h Represents query,keys and values along the row direction; Perform attention along the column width direction: Where Q w , K w , V w are queries, keys and values along the column direction.
6. The improved 3D medical image segmentation method based on SwinUnet according to claim 1, characterized in that: The step 8 comprises the following steps: Step 81: Using the Dice Coefficient Formula Calculate the Dice loss function; Step 82: Use the Adam optimizer to train the segmentation model using the total loss function loss.