Medical image segmentation method based on channel attention and multi-head attention mechanism

By combining channel attention and convolutional multi-head attention mechanisms, the CasTransNet network solves the problems of global feature capture and detail preservation in medical image segmentation, achieving higher segmentation accuracy and detail representation, which is superior to existing methods.

CN118537350BActive Publication Date: 2026-11-20CHONGQING UNIV OF TECH
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202410491641.5
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-04-23
Publication Date
2026-11-20
Estimated Expiration
2044-04-23

Smart Images

  • Figure CN118537350B_ABST
    Figure CN118537350B_ABST
Patent Text Reader

Abstract

The application discloses a medical image segmentation method based on channel attention and multi-head attention mechanism, and relates to the technical field of medical image segmentation.The application at least comprises the following steps: S1: data preprocessing, in order to better utilize the relationship between the pictures in the data set and adapt to the input of the network, 2D slices are obtained after preprocessing; S2: feature extraction; S3: feature recovery, the extracted features are recovered by using an encoder.The application uses a channel attention and convolution multi-head attention hybrid mechanism for feature extraction in the encoder, can make up for respective defects, simultaneously capture channel features and global information, and in order to suppress irrelevant information from the encoder, effectively utilize high and low layer features, and introduce a cascaded decoder with a BiFusion fusion module, through experimental results, the performance of the proposed method on the ACDC and Synapse data sets is better than that of the most advanced method, and the future potential research direction is highlighted, so that the accuracy of medical image segmentation is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of medical image segmentation technology, specifically to a medical image segmentation method based on channel attention and multi-head attention mechanisms. Background Technology

[0002] Medical image segmentation is widely considered one of the most promising remedies for improving diagnostic accuracy and treatment outcomes. In this regard, medical image segmentation plays a crucial role as the foundation of medical image analysis, particularly in guiding lesion localization, lesion region analysis, and surgical planning.

[0003] Significant progress has been made in the field of medical image segmentation, primarily focusing on methods based on convolutional neural networks (CNNs) and fully convolutional networks (FCNs). These methods preserve channel details by using symmetric encoder-decoder structures and skip connections, and have become the mainstream architecture for medical image segmentation. Some improved U-Net variants, such as U-Net3+ and Cascade Decoder, attempt to further improve image segmentation performance by bridging the semantic gap between the encoder and decoder.

[0004] Currently, Transformer-based frameworks perform exceptionally well in computer vision tasks. These methods benefit from Transformer's multi-head attention (MHSA) mechanism, which models global spatial context features, replacing traditional convolutional operations.

[0005] Researchers have begun combining CNNs and multi-head attention mechanisms, proposing hybrid architectures such as the UNETR and CASCADE models. These models utilize a hybrid CNN and Transformer mechanism for feature extraction in the encoder, which further suppresses irrelevant information by introducing attention gating mechanisms in the cascaded decoder, thereby improving the accuracy and efficiency of medical image segmentation.

[0006] The shortcomings of existing technology:

[0007] 1. Convolutional Neural Network (CNN)-based methods are limited by their finite receptive field, causing the network to focus more on local features and making it difficult to accurately capture global spatial context features. This bias in generalizing local features limits the modeling of long-range dependencies. For medical image segmentation, which requires dense prediction, the lack of global information may lead to inaccurate final segmentation results.

[0008] 2. Although the Transformer utilizes multi-head attention (MHSA) to model long-range dependencies, its lack of low-level detail may limit its localization capabilities in medical image segmentation. This means that the Transformer may not be able to effectively distinguish and localize subtle structures and features in medical images, thus affecting the accuracy and detail preservation of the segmentation results.

[0009] 3. While current hybrid CNN and Transformer methods can compensate for the shortcomings of each, simply concatenating high- and low-level features in the decoder network fails to effectively suppress irrelevant information from the encoder. This simplistic fusion approach may create insurmountable semantic gaps, thus affecting the accuracy and detail representation of the segmentation results.

[0010] Therefore, a new solution is needed to address the above problems. Summary of the Invention

[0011] The purpose of this invention is to provide a medical image segmentation method based on channel attention and multi-head attention mechanisms to solve the problems mentioned in the background art.

[0012] To achieve the above objectives, the present invention provides the following technical solution: a medical image segmentation method based on channel attention and multi-head attention mechanisms, comprising at least the following steps:

[0013] S1: Data preprocessing: In order to better utilize the relationships between images in the dataset and adapt to the network input, 2D slices were obtained after preprocessing.

[0014] S2: Feature extraction. The encoder of the CasTransNet network is used to extract features layer by layer. The core of this process is three modules: channel attention, convolutional multi-head attention, and multi-scale feedforward network. The channel attention and convolutional multi-head attention mechanisms are connected in series to capture channel and spatial features, and the multi-scale feedforward network is used to fuse the two.

[0015] S3: Feature recovery, using an encoder to recover the extracted features.

[0016] Furthermore, S1 includes at least the following steps:

[0017] The dataset images are first randomly rotated by a certain angle to increase the model's robustness to rotation transformations;

[0018] The image is then randomly scaled and translated to simulate images at different scales and locations.

[0019] Next, elastic deformation and Gamma transformation are performed on the image to simulate the deformation and adjust the image contrast, respectively.

[0020] Finally, Gaussian noise was added to the image, and the image brightness and contrast were adjusted to increase the model's robustness to noise and the image's diversity, respectively.

[0021] Furthermore, the channel attention module dynamically adjusts the weights of different channels by introducing a channel attention mechanism to increase the attention to specific features;

[0022] The channel attention module application includes at least the following steps:

[0023] For the input intermediate feature map After max pooling and average pooling operations, two tensors of size 1×1×C are generated. After sigmoid normalization and summation, the channel attention weight map W is obtained. c Where C represents the number of channels;

[0024] Then, the result after Sigmoid normalization and summation is normalized again to obtain the channel attention weight map;

[0025] Finally, the output F of the channel attention module is obtained through weighted multiplication. C ;

[0026] This process can be defined as:

[0027] W c =σ(σ(MaxPool(F))+σ(AvgPool(F)))

[0028]

[0029] Where σ represents the Sigmoid activation function, This indicates element-wise multiplication.

[0030] Furthermore, the application of the convolutional multi-head attention module includes at least the following steps:

[0031] For intermediate feature maps from the channel attention module The Q, K, and V tensors are generated by performing three sets of convolution operations.

[0032] Then, the attention weights are calculated using the multi-head attention mechanism (MHSA).

[0033] Finally, a reshape operation is performed to map it to a suitable dimension, resulting in the final multi-head attention output tensor F. S ;

[0034] This process can be defined as:

[0035] F Q / K / V=Flatten(Conv(Reshape(LN(x)))

[0036] F S =MHSA(F Q ,F K ,F V )+LN(x)

[0037]

[0038] Where LN represents the layer normalization operation and T represents the transpose operation.

[0039] Furthermore, the multi-scale feedforward network is used to process features at different scales. The multi-scale feedforward network includes multiple parallel convolutional layers, each of which has a different receptive field or output scale.

[0040] Compared with the prior art, the beneficial effects of the present invention are:

[0041] This invention employs a hybrid mechanism of channel attention and convolutional multi-head attention in the encoder for feature extraction, which can compensate for the shortcomings of each and capture both channel features and global information. In order to suppress irrelevant information from the encoder, it effectively utilizes high and low layer features and introduces a cascaded decoder with a BiFusion fusion module. Experimental results show that the proposed method outperforms state-of-the-art methods on the ACDC and Synapse datasets, highlighting potential future research directions to improve the accuracy of medical image segmentation. Attached Figure Description

[0042] To more clearly illustrate the technical solutions of the embodiments of the present invention, the accompanying drawings used in the description of the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0043] Figure 1 This is a diagram of the overall framework of the CasTransNet network of this invention;

[0044] Figure 2 This is a schematic diagram of the channel attention module of the present invention;

[0045] Figure 3 This is a schematic diagram of the convolutional multi-head attention module of the present invention;

[0046] Figure 4 This is a schematic diagram of the multi-scale feedforward network module of the present invention;

[0047] Figure 5This is a schematic diagram of the segmentation results on the Synapse data of the present invention. Detailed Implementation

[0048] The technical solutions of the present invention will be clearly and completely described below with reference to the accompanying drawings of the embodiments of the present invention. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments.

[0049] This medical image segmentation method, based on channel attention and multi-head attention mechanisms, consists of three stages: data preprocessing, feature extraction, and feature restoration. In the data preprocessing stage, the 3D images in the dataset are preprocessed to obtain corresponding 2D images, and data augmentation operations such as cropping, rotation, and scaling are performed. In the feature extraction stage, the preprocessed images are input into the CasTransNet network, where features are extracted through the hybrid attention module in the encoder stage, and then fused using a multi-scale feedforward neural network module. In the feature restoration stage, features from skip connections and the upsampled upper-level decoder are fused through a feature fusion module, and finally, the hybrid attention module produces the final output. The overall process is as follows: Figure 1 As shown.

[0050] Medical image segmentation methods based on channel attention and multi-head attention mechanisms:

[0051] Data preprocessing: In order to better utilize the relationships between images in the dataset and adapt to the network input, 2D slices were obtained after preprocessing.

[0052] The dataset images are first randomly rotated by a certain angle to increase the model's robustness to rotation transformations; then the images are randomly scaled and translated to simulate images at different scales and positions; next, elastic deformation and Gamma transformation are performed on the images to simulate image deformation and adjust image contrast, respectively; finally, Gaussian noise is added to the images and image brightness and contrast are adjusted to increase the model's robustness to noise and the diversity of images, respectively.

[0053] Feature extraction: The encoder of the CasTransNet network is used to extract features layer by layer. The core of this process consists of three modules: channel attention, convolutional multi-head attention, and multi-scale feedforward network. The channel attention and convolutional multi-head attention mechanisms are connected in series to capture channel and spatial features, and the multi-scale feedforward network is used to fuse the two.

[0054] Channel Attention Module. This module dynamically adjusts the weights of different channels to increase attention to specific features by introducing a channel attention mechanism. For each channel, the network performs average pooling (AvgPool) and max pooling (MaxPool) operations on the entire feature map, with each channel representing the average and maximum values ​​for that channel, respectively. This is then used for feature mapping via a multilayer perceptron (MLP), followed by separate sigmoid activation functions. The two are then combined and passed through a sigmoid function to generate the attention weights for each channel. Finally, the channel attention weights are element-wise multiplied with the original feature map to obtain a weighted feature map. This process is as follows: Figure 2 As shown.

[0055] Specifically, for the input intermediate feature map After the MaxPool and AvgPool operations, two tensors W of size 1×1×C will be generated. c Where C represents the number of channels. The result of sigmoid normalization and summation is then normalized again to obtain the channel attention weight map. Finally, the output F of the channel attention module is obtained through weighted multiplication. C This process can be defined as:

[0056] W c =σ(σ(MaxPool(F))+σ(AvgPool(F)))

[0057]

[0058] Where σ represents the Sigmoid activation function, This indicates element-wise multiplication.

[0059] Convolutional Multi-Head Attention Module. Research has found that almost all multi-head attention mechanisms use linear projection for self-attention computation, which suffers from the loss of spatial context representation during imaging. Therefore, we use an improved convolutional multi-head attention mechanism to replace linear projection in generating query (Q), key (K), and value (V) embeddings; this process can be called convolutional projection. Finally, a spatial attention weight map is obtained through multi-head attention computation, and the final output is obtained after reshaping. The entire process is as follows: Figure 3 As shown.

[0060] Specifically, for the intermediate feature maps from the channel attention module The tensors are generated as Q, K, and V through three sets of convolution operations; then, a multi-head attention mechanism (MHSA) is applied to calculate the attention weights; finally, a reshape operation is performed to map them to a suitable dimension, resulting in the final multi-head attention output tensor F. S This process can be defined as:

[0061] F Q / K / V =Flatten(Conv(Reshape(LN(x)))

[0062] F S =MHSA(F Q ,F K ,F V )+LN(x)

[0063]

[0064] Where LN represents the layer normalization operation and T represents the transpose operation.

[0065] Multi-scale feedforward networks. They can process features at different scales, including multiple parallel convolutional layers, each with a different receptive field or output scale. This design enables the network to capture feature information at different scales, thereby improving the model's ability to perceive multi-scale information. For input from the convolutional multi-head attention module, it can fuse features. The fused features will contain feature information from different scales and have been adjusted through channel attention and spatial attention, resulting in better representational capabilities. The entire process is as follows... Figure 4 As shown.

[0066] Feature recovery involves using an encoder to recover the extracted features, such as... Figure 1 The right half is the CascadedDecoder section. This stage employs a cascaded structure to progressively restore the image resolution and refine the features. For features from skip connections and upsampled upper-level encoders, a BiFusion module is introduced to simultaneously fuse both channel and spatial information while suppressing irrelevant information. For the fused features, we apply Channel Attention (CA) and Spatial Attention (SA) modules. CA adjusts the importance of different channels to increase attention to key features; while SA captures the relationships and dependencies between different locations in the feature map. After processing, the final target segmentation output is obtained.

[0067] The CA module is identical to the channel attention module in the encoder stage. The SA module uses depthwise separable convolution operations to replace the multi-head convolutional attention operations of the encoder. Experiments show that the model reduces computational complexity while preserving channel relationships.

[0068] In conclusion:

[0069] Among them, the feature extraction method based on channel attention and convolutional multi-head attention, and the cascaded decoder based on the BiFusion fusion module are the key technologies of this invention.

[0070] 1) Feature extraction methods based on channel attention and convolutional multi-head attention

[0071] The overall operation flow of feature extraction methods based on channel attention and convolutional multi-head attention (e.g.) Figure 2 and Figure 3 As shown): The channel attention module uses max pooling and average pooling operations to generate full channel attention values, and finally obtains the final channel attention feature map through element-wise multiplication; the convolutional multi-head attention module generates Q, K and V through three parallel convolution operations, and generates spatial attention weights using the multi-head attention mechanism, and finally reshapes them into a spatial attention feature map.

[0072] 2) Cascaded decoder based on BiFusion fusion module

[0073] To effectively aggregate multi-scale features from skip connections and upsampled upper-level decoders, BiFusion employs a feature fusion module that fully utilizes both high- and low-level features while suppressing interference from background-irrelevant information. Furthermore, to enhance feature robustness, we replace the multi-head convolutional attention in the encoder with convolutional spatial attention, employing a modified hybrid attention mechanism to obtain the final multi-stage output. Experiments show that this improvement reduces computational complexity without sacrificing segmentation accuracy.

[0074] Based on the above embodiments, the following evaluation of technical effects is proposed:

[0075] 1) Performance Evaluation

[0076] This invention was experimentally evaluated using preprocessed MR image slices on the ACDC dataset and preprocessed CT image slices on the Synapse dataset.

[0077] The ACDC dataset requires us to segment three ventricles: the right ventricle (RV), myocardium (Myo), and left ventricle (LV). The final segmentation results are evaluated using the Dice coefficient. Since the true values ​​for the test set are unavailable, we follow existing work by splitting the original training set, resulting in 1290 training slices, 196 validation slices, and 416 test slices. This invention also follows previous work, reporting the results for the three segmentation targets on the validation set, as well as the average results.

[0078] This invention compares the proposed method with state-of-the-art methods combining convolution and multi-head attention, as well as cascaded decoders. Table 1 shows the segmentation results on the ACDC validation set.

[0079] Table 1. Comparative experimental results on the ACDC dataset.

[0080]

[0081] As shown in Table 1, overall, while TransUNet, SwinUNet, MissFormer, and nnFormer, which use only convolution and traditional multi-head attention hybrids, can extract fine features at the encoder stage, our results outperform all of these models compared to our method, which introduces improved convolutional multi-head attention and a cascaded decoder. Compared to the state-of-the-art nnFormer, our segmentation results on average Dice score, RV, Myo, and LV are improved by 0.7%, 1.38%, 0.9%, and 0.47%, respectively. Compared to TransCASCADE and Cascaded MERIT, which employ cascaded decoders, our method can more fully integrate high- and low-level features at the decoder stage, effectively bridging the semantic gap between the encoder and decoder. Compared to the state-of-the-art CascadedMERIT, our segmentation results are improved by 0.91%, 2.09%, 0.61%, and 0.03%, respectively. Except for the final segmentation result of myocardium, which is second only to TransCASCADE, our segmentation results reach the state-of-the-art level.

[0082] The Synapse dataset contains 13 labeled organs. We ultimately selected seven organs for multi-organ segmentation: the aorta, gallbladder, left kidney, right kidney, liver, pancreas, spleen, and stomach. The final segmentation results were evaluated using the Dice coefficient and the 95% Hausdorff distance (HD95). Similarly, we split the original dataset into slices, obtaining 2211 training slices and 1568 validation slices. Following previous work, this invention reports the results for eight segmentation targets on the validation set, along with the average results. Table 2 shows the segmentation results on the Synapse validation set.

[0083] Table 2 shows the comparative experimental results on the Synapse dataset.

[0084]

[0085] We compared our results with hybrid CNN and multi-head attention models such as ST-Unet, UNETR, and nnUNet. Among the hybrid models, nnUNet performed best, showing significant improvements in all but two organs (Aorta and Stomach) except for the Aorta and Stomach organs, with an average Dice score improvement of 3.73%. Compared to the state-of-the-art cascaded architectures TransCASCADE and Parallel MERIT, our segmentation results outperformed both, with an average Dice score improvement of 1.87% compared to Parallel MERIT.

[0086] We visualized the segmentation results of CasTransNet on the Synapse dataset and compared the results with other partial models, such as... Figure 5 As shown, for test images with relatively clear semantic information, our model and other comparison models achieve accurate segmentation results. However, for semantically indistinct images such as organ boundaries, our CasTransNet model significantly outperforms other models. The red boxes indicate the areas where the segmentation results differ.

[0087] It will be apparent to those skilled in the art that the present invention is not limited to the details of the exemplary embodiments described above, and that the invention can be implemented in other specific forms without departing from its spirit or essential characteristics. Therefore, the embodiments should be considered in all respects as exemplary and non-limiting, and the scope of the invention is defined by the appended claims rather than the foregoing description. Thus, all variations falling within the meaning and scope of equivalents of the claims are intended to be included within the present invention. No reference numerals in the claims should be construed as limiting the scope of the claims.

Claims

1. A medical image segmentation method based on channel attention and multi-head attention mechanisms, characterized in that: At least the following steps are included: S1: Data preprocessing: In order to better utilize the relationships between images in the dataset and adapt to the network input, 2D slices were obtained after preprocessing. S2: Feature extraction. The encoder of the CasTransNet network is used to extract features layer by layer. The core of this process is three modules: channel attention, convolutional multi-head attention mechanism, and multi-scale feedforward network. The channel attention and convolutional multi-head attention mechanism modules are connected in series to capture channel features and global spatial features in sequence. The multi-scale feedforward network is used to extract multi-scale features from the concatenated output. Multi-scale spatial context and channel dependency are modeled simultaneously through multiple parallel convolutional layers with different receptive fields. S3: Feature recovery. A cascaded decoder is used to restore the resolution of the extracted features step by step. In each step, the BiFusion module fuses the low-level features from the skip connections with the upsampled features from the upper-level decoder, and simultaneously fuses the channel information and spatial information of both. The BiFusion module includes a channel attention branch, a spatial attention branch, and element-wise multiplication and concatenation of the features from the two branches. The fused features are then processed by the channel attention module CA and the spatial attention module SA in sequence, and the segmentation result is obtained through multiple outputs. The channel attention module dynamically adjusts the weights of different channels by introducing a channel attention mechanism to increase the attention to specific features. The application of the channel attention module includes at least the following steps: For the input intermediate feature map After max pooling and average pooling operations, two pools of size will be generated. The tensor, after sigmoid normalization and summation, yields the channel attention weight map. ,in This represents the number of channels; Finally, the output of the channel attention module is obtained through weighted multiplication. ; This process can be defined as: in, express Activation function This represents element-wise multiplication; The application of the convolutional multi-head attention mechanism module includes at least the following steps: For intermediate feature maps from the channel attention module The Q, K, and V tensors are generated by performing three sets of convolution operations on them. Then, a multi-head attention mechanism is applied to calculate the attention weights; Finally, after a reshaping operation, it is mapped to a suitable dimension to obtain the final multi-head attention output tensor. ; This process can be defined as: Where LN represents the layer normalization operation, This represents the transpose operation.

2. The medical image segmentation method based on channel attention and multi-head attention mechanisms according to claim 1, characterized in that: S1 includes at least the following steps: The dataset images are first randomly rotated by a certain angle to increase the model's robustness to rotation transformations; The image is then randomly scaled and translated to simulate images at different scales and locations. Next, elastic deformation and Gamma transformation are performed on the image to simulate the deformation and adjust the image contrast, respectively. Finally, Gaussian noise was added to the image, and the image brightness and contrast were adjusted to increase the model's robustness to noise and the image's diversity, respectively.

3. The medical image segmentation method based on channel attention and multi-head attention mechanisms according to claim 1, characterized in that: The multi-scale feedforward network is used to process features at different scales. The multi-scale feedforward network includes multiple parallel convolutional layers, each of which has a different receptive field or output scale.