Prostate segmentation algorithm based on window multi-head self-attention and deep convolution
By adopting the parallel design of windowed multi-head self-attention and deep convolution in prostate MRI image segmentation, the channel and spatial modeling capabilities are enhanced, and the problems of weak feature extraction ability and insufficient generalization ability in the existing technology are solved, achieving Higher segmentation accuracy and stability.
Patent Information
- Application Number
- CN202410767548.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-06-14
- Publication Date
- 2024-10-01
- Estimated Expiration
- Not applicable · inactive patent
AI Technical Summary
Existing technologies in prostate MRI image segmentation have problems such as insufficient local feature extraction capabilities, limited ability to capture long-range dependencies, and weak generalization ability to different data sets, resulting in insufficient segmentation accuracy and stability.
The EnhancedMixFormer module based on window multi-head self-attention and deep convolution is used to enhance the channel and spatial modeling capabilities of the module through parallel design and two-way interaction mechanism. Combined with the U-Net codec structure, it replaces the traditional convolution module and improves prostate health. Global feature extraction ability and generalization ability of segmentation network.
It significantly improves the segmentation accuracy of prostate PZ and TZ regions, enhances the network's modeling ability of long-range dependencies, improves the adaptability to different data sets and the stability of segmentation results.
Smart Images

Figure CN118735941A_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the technical field of medical image recognition, and in particular relates to a prostate segmentation algorithm based on window multi-head self-attention and deep convolution. Background Art
[0002] Prostate cancer is one of the major malignant tumors that threaten men's health. Its early detection and accurate diagnosis are crucial to improving patients' survival rate and treatment effect. Magnetic resonance imaging (MRI), as the main imaging diagnostic method in the current medical field, can provide high-resolution prostate anatomical structure information, and therefore plays an indispensable role in the diagnosis and grading of prostate cancer.
[0003] In MRI images, the peripheral zone (PZ) and transition zone (TZ) of the prostate are common areas where prostate cancer occurs. Accurate segmentation of these two areas is of great significance for subsequent cancer grading, formulation of treatment plans, and efficacy evaluation. However, the complexity of the prostate structure and the inhomogeneity of MRI images themselves pose great challenges to the accurate segmentation of these two areas.
[0004] Traditional machine vision technologies, such as rule-based threshold processing and edge detection, have many limitations in prostate MRI image segmentation. These methods are sensitive to small changes in image content, have problems such as low efficiency and low accuracy, and are difficult to adapt to image variability between different MRI devices and individual patients, resulting in unstable and unreliable segmentation results. In addition, these methods usually require manual participation, which is not only time-consuming and labor-intensive, but also the consistency and repeatability of segmentation results are also affected by the physician's personal experience and subjective judgment;
[0005] In recent years, with the rapid development of deep learning technology, the automatic segmentation method based on convolutional neural network (CNN) has made significant progress in prostate MRI image segmentation. CNN can automatically learn the hierarchical features of images through multi-layer convolution and pooling operations without manually designing feature extractors. Therefore, it has stronger generalization ability and higher segmentation accuracy. However, the existing segmentation methods based on CNN still have certain limitations.
[0006] First, CNN mainly relies on the local receptive field of the convolution kernel to extract features, and has limited ability to capture long-range dependencies in images, which is particularly important in the accurate segmentation of the prostate PZ and TZ regions. Second, CNN may not be able to fully capture the details of the image when dealing with tiny structures and fuzzy boundaries, resulting in limited accuracy of the segmentation results. In addition, although CNN performs well on specific data sets, its generalization ability still needs to be improved, especially when facing new and unseen data sets.
[0007] Therefore, developing a prostate MRI image segmentation method that can integrate global and local feature extraction capabilities, establish long-range dependencies, and improve network generalization capabilities has important clinical value and practical application significance. Summary of the invention
[0008] The purpose of the present invention is to provide a prostate segmentation algorithm based on window multi-head self-attention and deep convolution, which can improve the global feature extraction ability of the prostate segmentation network, effectively establish long-range dependencies, and overcome the problems of poor global feature extraction ability and weak context extraction ability of the traditional codec structure network on the encoder.
[0009] The technical solution adopted by the present invention is as follows:
[0010] The prostate segmentation algorithm based on window multi-head self-attention and deep convolution includes the following steps:
[0011] Step 1: Build the EnhancedMixFormer module;
[0012] Step 2: Design the encoder of the prostate segmentation network and connect the encoder to the EnhancedMixFormer module;
[0013] Step 3: Design the decoder and skip connection of the prostate segmentation network, and transfer the multiple features of different resolutions obtained by the encoder to the decoder through skip connections for information restoration;
[0014] Step 4: Collect and organize public prostate MRI segmentation datasets, train the prostate segmentation network, and perform prostate segmentation prediction.
[0015] The technical effects achieved by the present invention are:
[0016] The present invention is firstly based on window multi-head self-attention and deep convolution, aiming to provide a module that integrates the global feature capture capability of window multi-head self-attention and the local feature extraction capability of deep convolution to improve the segmentation accuracy of prostate PZ and TZ. Then, by designing a parallel structure of window multi-head self-attention and deep convolution, the self-attention mechanism of window multi-head self-attention is fully utilized to improve the generalization ability of the prostate segmentation network. Finally, the module integrating window multi-head self-attention and deep convolution replaces the convolution module in the encoder, improves the global feature extraction capability of the prostate segmentation network, effectively establishes long-range dependency, and overcomes the problems of poor global feature extraction capability and weak context extraction capability of the traditional codec structure network on the encoder. BRIEF DESCRIPTION OF THE DRAWINGS
[0017] Figure 1 is a flow chart of the EnhancedMixFormer module of the present invention;
[0018] Figure 2 It is a diagram of the segmentation network structure in the present invention;
[0019] Figure 3 It is a flow chart of network training in the present invention. DETAILED DESCRIPTION
[0020] In order to make the purpose and advantages of the present invention more clearly understood, the present invention is specifically described below in conjunction with embodiments. It should be understood that the following text is only used to describe one or several specific embodiments of the present invention, and does not strictly limit the scope of protection of the specific claims of the present invention.
[0021] like Figure 1-3 As shown, the prostate segmentation algorithm based on window multi-head self-attention and deep convolution includes the following steps:
[0022] S1: Build the EnhancedMixFormer module;
[0023] Enhanced MixFormer module such as Figure 1 As shown, two key designs are adopted:
[0024] S11: adopts a parallel design, sets up Window Multi-Head Self-Attention (W-MSA) and deep convolution modules, and combines the Window Multi-Head Self-Attention and deep convolution modules to jointly extract features from images to achieve better feature representation learning;
[0025] S12: Introducing cross-branch bidirectional interactions, namely channel interaction and spatial interaction, to enhance the modeling capabilities of window multi-head self-attention and deep convolution in the channel and spatial dimensions respectively, to solve the problems of limited receptive field and weak modeling capability of window multi-head self-attention;
[0026] Channel interaction is applied to the output branch of the deep convolution, which includes a global average pooling layer followed by two consecutive 1×1 convolutional layers, normalized and activated between them, and then the Sigmoid function is used to generate attention in the channel dimension. However, in order to enhance the channel modeling capability of the original MixFormer, we fuse the channel attention with the query and key on the basis of fusing the attention output of the channel interaction with the value of W-MSA. Through this fusion method, we can make full use of the association between channel attention and query and key to further improve the module's modeling capability of channel information. This measure enhances the channel modeling capability of W-MSA without increasing network parameters, effectively establishes long-range dependencies, and lays a solid foundation for improving prostate segmentation performance;
[0027] Among them, MixFormer is an architecture based on Vision Transformer. Its core design is to transform Windowed Multi-Head Self-Attention It is combined with deep convolution in a parallel design to simulate cross-window connections to expand the receptive field; and a bidirectional interaction is introduced between parallel branches to provide complementary cues in channel and spatial dimensions to enhance Windowed Multi-Head Self-Attention and modeling capabilities of deep convolutions;
[0028] The query represents the information that the currently processed element wants to "query" or "pay attention to". In the self-attention mechanism, it is compared with the key to determine how much information should be obtained from the value;
[0029] The key is the element that is compared with the query to determine the relevance of each value to the current query. If a key is similar or relevant to the query, then its corresponding value will have a greater weight in the final output;
[0030] The value contains the actual data or features associated with each key. When the key matches the query, the corresponding value will be taken into account in the final output calculation.
[0031] Spatial interaction is applied to the output branch of the windowed multi-head self-attention, which consists of two 1×1 convolutional layers and subsequent BN and GELU. These two layers reduce the number of channels to 1. A sigmoid layer is used to generate a spatial attention map, which is applied to the deep convolution module to improve the spatial modeling capability of the deep convolution and thus expand the module receptive field.
[0032] S2: Design the encoder of the prostate segmentation network and connect the encoder to the EnhancedMixFormer module;
[0033] The encoder mainly includes a Patch Partition layer, a Linear EmBed layer, four Mixing Layer layers and a corresponding DownSampling layer, and each Mixing Layer layer is stacked with two Mixing Block layers;
[0034] For the three-dimensional features input to the encoder Its resolution is (H, W, D) and dimension is C. First, input the feature map for patchpartition and linear embedding. Set the convolution kernel size to 2×2×2, the step size to 2, and the number of output channels to embedding dim. The resolution is obtained. 3Dtoken with dimension embedding dim;
[0035] There are 4 stages in the following structure, corresponding to the 4 stages of the U-Net structure. Each stage has a Mixing layer, which includes two Mixing Blocks. Therefore, the number of Mixing Blocks of the encoder is L=8.
[0036] In the next L layers of the encoder, the input is calculated as:
[0037]
[0038] Among them, X l and X l+1 They represent the input of L layer and L+1 layer respectively, MIX represents the feature function between the window multi-head self-attention branch and the CNN branch, LN represents the Layer Norm layer, and MLP consists of a linear layer and GELU;
[0039] The self-attention calculation of the window multi-head self-attention branch is:
[0040]
[0041] Among them, Q, K and V represent the matrices of query, key and value respectively;
[0042] At the end of each stage, a 2×2×2 patch is used in the DownSampling layer to reduce the output feature dimension by a factor of two, and the norm layer and the linear layer are used to increase the channel dimension to 2C. In stage2, stage3, and stage4, the same structure is used as in stage1, and the output resolutions are
[0043] S3: Design the decoder and skip connection of the prostate segmentation network, and transfer the multiple features of different resolutions obtained by the encoder to the decoder through skip connections for information recovery;
[0044] In each stage i (i∈{0,1,2,3,4}) of the encoder and the last stage (i=5), the output features are reconstructed into dimensions The features are input into a residual block consisting of two 3×3×3 convolutional layers and normalized by the Layer Norm layer;
[0045] Then, the deconvolution layer is used to increase the resolution of the feature map by 2 times, and the output is cascaded with the output of the previous stage. The concatenated features are sent to another residual block, and the above steps are repeated. Finally, the segmentation output result is calculated by using a 1×1×1 convolution layer and a Sigmoid function. The prostate segmentation network structure is shown in the figure. Figure 2 .
[0046] S4: Collect and organize public prostate MRI segmentation datasets, train prostate segmentation networks, and perform prostate segmentation prediction.
[0047] After collecting prostate MRI segmentation datasets from public databases and preprocessing them, we designed the DiceCE loss function, adam optimizer, and initialized the learning rate, and input the preprocessed data into the prostate segmentation network for training;
[0048] After training, obtain the trained model weight file, use the model weight file to segment the PZ and TZ of the prostate MRI image to be predicted, and obtain the final prediction mask of PZ and TZ. The specific process is as follows: Figure 3 .
[0049] Aiming at the problem of low accuracy of segmenting PZ and TZ in prostate MRI segmentation network based on CNN, the present invention proposes channel interaction and spatial interaction;
[0050] It first uses the feature information of the deep convolution through global average pooling and 1x1 convolution in channel interaction to generate an attention map. Then it is used on the query, key and value of W-MSA respectively, providing sufficient global channel information for the subsequent self-attention calculation of W-MSA, significantly improving the module's modeling ability of channel information, thereby more effectively establishing long-range dependencies. The self-attention of W-MSA is then input into the spatial interaction module, and then the spatial attention map is generated through the 1x1 convolution and activation function, and applied to the deep convolution, which expands the receptive field of the deep convolution and improves the module's modeling ability in the spatial dimension. Through channel interaction and spatial interaction, the channel modeling ability and spatial modeling ability of CNN are effectively improved, the receptive field of the module is expanded, and the modeling of long-range dependencies is enhanced, thereby improving the segmentation accuracy of the prostate segmentation network for PZ and TZ;
[0051] To address the problem of insufficient generalization of CNN on other data sets, the present invention proposes a parallel design that integrates W-MSA and deep convolution.
[0052] It first splits the input feature map into two parts, one part will be processed by W-MSA, and the other part will be extracted through the deep convolution module. W-MSA uses the self-attention mechanism to capture long-range dependencies in the feature map. By calculating the association between query, key and value, W-MSA can aggregate information from different positions, thereby enhancing the module's understanding of the global context; while the deep convolution module parallel to W-MSA focuses on extracting local features in the feature map. By stacking multiple convolutional layers, deep convolution can capture the hierarchy and detail information of the image. Through the parallel results of W-MSA and deep convolution, the global and local feature capture of the module is effectively enhanced, providing a richer feature representation for feature restoration, enabling the prostate segmentation network to better generalize to different data sets and clinical scenarios, and improving the practicality of the prostate segmentation network;
[0053] To address the problem that the CNN-based prostate segmentation method has weak feature extraction capability in the encoder, the present invention integrates the EnhancedMixFormer module in the encoder.
[0054] Its use U-Net The encoder-decoder structure network replaces the traditional convolution module in the encoder with the Enhanced MixFormer module, and then transmits the extracted feature information about the prostate to the next stage module and decoder respectively through downsampling and skip connections, thereby improving the global feature extraction capability of the prostate segmentation network and overcoming the problems of poor feature extraction capability and weak context extraction capability in the encoder part of the traditional encoder-decoder structure network.
[0055] Compared with the prior art, the present invention effectively improves the channel modeling ability and spatial modeling ability of CNN by proposing channel interaction and spatial interaction with W-MSA and deep convolution, expands the receptive field of the module, and enhances the modeling of long-range dependencies, thereby improving the segmentation accuracy of the prostate segmentation network for PZ and TZ, and overcoming the problem of low segmentation accuracy of CNN due to insufficient receptive field and lack of global feature information.
[0056] The present invention effectively enhances the capture of global and local features of the module through the parallel design of W-MSA and deep convolution, provides richer feature representation for feature restoration, enables the prostate segmentation network to be better generalized to different data sets and clinical scenarios, improves the practicality of the prostate segmentation network, and overcomes the problem of weak generalization of CNN on unknown data sets.
[0057] By integrating the Enhanced MixFormer module into the encoder of the prostate segmentation network, the present invention can fully utilize context information in the encoder to perform multi-scale global and local feature extraction, improve the global feature extraction capability of the prostate segmentation network, and effectively establish long-range dependencies, thereby overcoming the problems of poor global feature extraction capability and weak context extraction capability of the traditional codec structure network in the encoder.
[0058] The above is only a preferred embodiment of the present invention. It should be noted that, for those skilled in the art, several improvements and modifications can be made without departing from the principles of the present invention, and these improvements and modifications should also be considered as the protection scope of the present invention. The structures, devices and operating methods not specifically described and explained in the present invention shall be implemented according to the conventional means in the art unless otherwise specified and limited.
Claims
1. A prostate segmentation algorithm based on window multi-head self-attention and deep convolution, characterized by: The following steps are involved: S1: Build the Enhanced MixFormer module; S2: Design the encoder of the prostate segmentation network and connect the encoder to the Enhanced MixFormer module; S3: Design the decoder and skip connection of the prostate segmentation network, and transfer the multiple features of different resolutions obtained by the encoder to the decoder through skip connections for information recovery; S4: Collect and organize public prostate MRI segmentation datasets, train prostate segmentation networks, and perform prostate segmentation prediction.
2. The prostate segmentation algorithm according to claim 1, characterized in that: The S1 adopts two key designs: S11: A parallel design is adopted to set up window multi-head self-attention and deep convolution modules, and the window multi-head self-attention and deep convolution modules are combined to jointly extract features from the image; S12: Introduce cross-branch bidirectional interactions, namely channel interaction and spatial interaction, to enhance the modeling capabilities of window multi-head self-attention and deep convolution in the channel and spatial dimensions respectively.
3. The prostate segmentation algorithm according to claim 2, characterized in that: In S12, channel interaction is applied to the output branch of the deep convolution, which includes a global average pooling layer, followed by two consecutive 1×1 convolution layers, normalization and activation are performed between them, and then the sigmoid function is used to generate attention in the channel dimension, and the attention output of the channel interaction is fused with the value of the window multi-head self-attention, and the channel attention is fused with the query and key; The spatial interaction is applied to the output branch of the windowed multi-head self-attention, which consists of two 1×1 convolutional layers followed by BN and GELU. These two layers reduce the number of channels to 1. A sigmoid layer is used to generate the spatial attention map, which is applied to the deep convolution module.
4. The prostate segmentation algorithm according to claim 1, characterized in that: In S2, an encoder of a prostate segmentation network is designed, and the encoder is connected to an Enhanced MixFormer module; The encoder mainly includes a Patch Partition layer, a Linear EmBed layer, four Mixing Layer layers and a corresponding DownSampling layer, and each Mixing Layer layer is stacked with two Mixing Block layers; For the three-dimensional features input to the encoder Its resolution is (H, W, D) and dimension is C. First, input the feature map for patchpartition and linear embedding. Set the convolution kernel size to 2×2×2, the step size to 2, and the number of output channels to embedding dim. The resolution is obtained. 3D token with dimension embedding dim; There are 4 stages in the following structure, corresponding to the 4 stages of the U-Net structure. Each stage has a Mixing layer, which includes two Mixing Blocks. Therefore, the number of Mixing Blocks of the encoder is L=8.
5. The prostate segmentation algorithm according to claim 4, characterized in that: In the next L layers of the encoder, the input is calculated as: Among them, X l and X l+1 They represent the input of L layer and L+1 layer respectively, MIX represents the feature function between the window multi-head self-attention branch and the CNN branch, LN represents the LayerNorm layer, and MLP consists of a linear layer and GELU; The self-attention calculation of the window multi-head self-attention branch is: Among them, Q, K and V represent the matrices of query, key and value respectively; At the end of each stage, a 2×2×2 patch is used in the DownSampling layer to reduce the output feature dimension by a factor of two, and the norm layer and the linear layer are used to increase the channel dimension to 2C. In stage2, stage3, and stage4, the same structure is used as in stage1, and the output resolutions are 6. The prostate segmentation algorithm according to claim 1, characterized in that: In S3, in each stage i (i∈{0,1,2,3,4}) of the encoder and the last stage (i=5), the output features are reconstructed into dimensions The features are input into a residual block consisting of two 3×3×3 convolutional layers and normalized by the LayerNorm layer; Then, the deconvolution layer is used to increase the resolution of the feature map by 2 times, and the output is cascaded with the output of the previous stage. The concatenated features are fed into another residual block and the above steps are repeated. Finally, the convolutional layer is used to generate the feature vector of the residual. Sigmoid function is used to calculate the output of the segmentation.
7. The prostate segmentation algorithm according to claim 1, characterized in that: In S4, public prostate MRI segmentation datasets are collected and preprocessed, and then the DiceCE loss function, adam optimizer and initial learning rate are designed, and the preprocessed data are input into the prostate segmentation network for training.
8. The prostate segmentation algorithm according to claim 7, characterized in that: After the training is completed, the trained model weight file is obtained, and the model weight file is used to segment the PZ and TZ of the prostate MRI image to be predicted to obtain the final prediction mask of the PZ and TZ.
Citation Information
Patent Citations
Prostate MRI (Magnetic Resonance Imaging) image segmentation method and system based on adaptive multi-scale Transform optimization
CN115272170A
Abdomen multi-organ segmentation method based on double-attention ViT
CN117788819A
Pancreas CT image segmentation method based on Unet and U2net cascade convolutional neural network
CN117853505A
CT pancreatic tumor automatic segmentation method and system, terminal and storage medium
WO2024000161A1
Cited By
Prostate transrectal ultrasound image intelligent segmentation method and system
CN120198447A
