Magnetic resonance image segmentation method based on artificial intelligence and linear attention

By combining convolutional neural networks and linear attention modules, a magnetic resonance image segmentation method is developed, which solves the problems of high computational resources and overfitting in Transformer-CNN for complex magnetic resonance image segmentation, and achieves efficient and accurate image segmentation results.

CN119625317BActive Publication Date: 2026-02-24INNOVATION ACAD FOR PRECISION MEASUREMENT SCI & TECH CAS
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202411804821.0
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-12-10
Publication Date
2026-02-24
Estimated Expiration
2044-12-10

AI Technical Summary

Technical Problem

Existing Transformer-CNN-based magnetic resonance image segmentation methods have high computational resource requirements when processing complex magnetic resonance images. The complexity of the model increases the risk of overfitting, and the methods perform poorly when computational resources are insufficient, lacking efficient and accurate segmentation capabilities.

Method used

A magnetic resonance image segmentation method based on linear attention is adopted, which combines convolutional neural networks and linear attention modules. Taylor expansion is used to reduce computational complexity, and a linear multi-head self-attention module is used to preserve long-distance dependencies. An encoder and decoder are constructed to achieve efficient and accurate image segmentation.

Benefits of technology

It reduces computational complexity, memory usage, and the number of parameters, improving the accuracy and efficiency of segmentation, especially performing exceptionally well in high-resolution image segmentation tasks, and reducing the risk of overfitting.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119625317B_ABST
    Figure CN119625317B_ABST
Patent Text Reader

Abstract

The application discloses a magnetic resonance image segmentation method based on artificial intelligence and linear attention, acquires a magnetic resonance image and a corresponding real label, generates a training set and a test set, constructs a magnetic resonance image segmentation network model, trains the magnetic resonance image segmentation network model by using the data set, takes minimizing a total loss function as an objective, acquires optimal weights of the magnetic resonance image segmentation network model, and segments a magnetic resonance image to be segmented by using the magnetic resonance image segmentation network model with the optimal weights and outputs a segmentation graph. The application proposes a linear multi-head self-attention module based on Taylor expansion, retains the ability of modeling long-distance dependence between data, and can realize efficient and accurate segmentation by using less memory and parameter quantity.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of image analysis, recognition and segmentation, and more specifically, to a magnetic resonance image segmentation method based on artificial intelligence and linear attention. Background Technology

[0002] Accurate segmentation of the target region in magnetic resonance (MR) images enables the localization, quantization, and monitoring of this region, allowing for precise analysis. The introduction of deep learning technology provides an end-to-end solution for MR image segmentation. Convolutional Neural Networks (CNNs), as a representative of deep learning models, can achieve accurate segmentation through multi-level feature extraction and combination. However, CNN-based methods inherently focus too much on local details, neglecting meaningful global information, and lack the ability to model long-range dependencies. In recent years, with the significant progress of Transformer models in natural language processing and computer vision, their application to MR image segmentation has been explored. As a deep learning model based on a self-attention mechanism, the Transformer model excels at capturing long-range dependencies in sequential data, making it highly promising for MR image segmentation, especially for MR images with complex spatial structures.

[0003] However, Transformer-based magnetic resonance image segmentation methods are still in their early stages and face several challenges. First, transformers designed for sequence-to-sequence prediction are not sensitive enough to low-level detail features and lack some of the inductive biases inherent in convolutional neural networks, thus requiring extensive training data to achieve better performance. Therefore, combining Transformers and CNNs can leverage the advantages of Transformers in capturing long-range dependencies and global information, and CNNs in local feature extraction and spatial information capture, to achieve more comprehensive and efficient magnetic resonance image segmentation. However, this approach still presents challenges. Transformer-CNN hybrid models typically require larger model sizes to handle the complexity and diversity of magnetic resonance image data, which often have high resolution and dimensionality. This means that more computational resources are needed to process these large-scale datasets during data preprocessing and input processing. When dealing with complex magnetic resonance images or when computational resources are insufficient, Transformer-CNN performance may be poor, and the model's complexity and large number of parameters may increase the risk of overfitting on the training set, thus affecting its generalization performance. Summary of the Invention

[0004] The purpose of this invention is to address the aforementioned problems in the existing technology by proposing a magnetic resonance image segmentation method based on artificial intelligence and linear attention.

[0005] The above-mentioned objective of the present invention is achieved through the following technical solution:

[0006] A magnetic resonance imaging segmentation method based on artificial intelligence and linear attention includes the following steps:

[0007] Step 1: Obtain magnetic resonance (MR) images and their corresponding ground truth labels, divide the MR images, and generate training and testing sets;

[0008] Step 2: Construct a magnetic resonance image segmentation network model based on Convolutional Neural Networks (CNN) and linear attention;

[0009] Step 3: Train the magnetic resonance image segmentation network model using the dataset, aiming to minimize the total loss function and obtain the optimal weights of the magnetic resonance image segmentation network model;

[0010] Step 4: Use the optimal weighted magnetic resonance image segmentation network model to segment the magnetic resonance image to be segmented and output the segmentation map.

[0011] As described in step 1 above, the magnetic resonance image is a preprocessed magnetic resonance image. The preprocessing includes: cropping the center of the magnetic resonance image to a set size, randomly enhancing the cropped magnetic resonance image and the real label, and normalizing each enhanced magnetic resonance image to zero mean and unit variance.

[0012] Random augmentations include random rotation, random flipping, and random translation.

[0013] As described above, the magnetic resonance image segmentation network model includes an encoder and a decoder.

[0014] The encoder consists of a residual-based CNN basic downsampling network module and a linear attention module.

[0015] The decoder is a cascaded upsampling module.

[0016] The basic downsampling network module of a CNN consists of three residual blocks.

[0017] The linear attention module consists of multiple linear attention layers. Each linear attention layer includes: a first-layer normalization module (Layer Norm), a linear multi-head self-attention module (T-MSA), a second-layer normalization module (Layer Norm), and a multilayer perceptron (MLP).

[0018] The cascaded upsampling module consists of multiple cascaded Conv2dReLU upsampling modules. The number of Conv2dReLU upsampling modules is equal to the number of residual blocks in the basic downsampling network module of the CNN plus one.

[0019] As described above, the CNN basic downsampling network module is used to input the magnetic resonance image into the encoder. The feature maps output by the CNN basic downsampling network module are then serialized to obtain a two-dimensional feature map sequence. in It is a one-dimensional vector representation of the nth slice, where N is the total number of slices.

[0020] For the two-dimensional feature map sequence x p Linear projection is performed to obtain the corresponding linear projection encoded feature Z0. The linear projection encoded feature Z0 is input to the linear attention module of the encoder, and the encoded feature Z0 is output by the linear attention module. 12 The encoded features restored to slice size are processed sequentially through each Conv2dReLU upsampling module of the cascaded upsampling module, and then through a 1×1 convolution to generate a segmentation map. The Conv2dReLU upsampling module of the decoder is skip-connected to the residual blocks of the same size in the encoder's CNN basic downsampling network module.

[0021] The two-dimensional feature map sequence described above is based on the following steps:

[0022] The feature map output by the basic downsampling network module of the CNN is segmented using slices of length × width P × P. Each slice is converted into a two-dimensional sequence. The two-dimensional sequence is flattened into a one-dimensional vector in row or column order. The one-dimensional vectors corresponding to the slices of the same feature map are recombined and connected to obtain a two-dimensional feature map sequence.

[0023] As described above, linear projection is based on the following formula:

[0024]

[0025] Where Z0 is the two-dimensional feature map sequence x p The linear projection encoded features after linear projection, E is the slice embedding projection code, E pos This indicates the position code.

[0026] As described above, the linear multi-head self-attention module is based on the following formula:

[0027]

[0028] LineAttention(Q n ,K j V j The result is calculated by a linear multi-head self-attention module.

[0029] Q n The magnetic resonance image x represents the output of the first-level normalization module. i The query vector of the feature corresponding to the nth slice, K j and V j The magnetic resonance image x represents the output of the first-level normalization module. i The key vector and value vector of the feature corresponding to the j-th slice.

[0030] As described above, the linear attention module is based on the following formula:

[0031] Z l =T-MSA(LN1(Z) l-1 ))+Z l-1

[0032] Z l =MLP(LN2(Z) l ′))+Z l ′

[0033] Where LN1() represents the first-layer normalization module, LN2() represents the second-layer normalization module, T-MSA(·) represents the linear multi-head self-attention module, MLP(·) represents the multilayer perceptron, and Z l Z' is an intermediate encoded feature of the l-th linear attention layer. l and Z l-1 These are the encoded features output by the l-th and (l-1)-th linear attention layers of the linear attention module, respectively.

[0034] As mentioned above, the total loss function is Loss total Based on the following formula:

[0035] Loss total =L CE +αL Dice

[0036]

[0037] Among them, L CE For cross-entropy loss, L Dice The loss function is Dice, where α is the balancing weight coefficient and y represents the manually drawn true labels. This represents the probability distribution of the segmentation map output by each Conv2dReLU upsampling module of the magnetic resonance image segmentation network model. "smooth" represents the smoothing coefficient. "||" represents the number of elements that are 1.

[0038] A computer device includes a memory and a processor, the memory storing a computer program, and the processor executing the computer program to implement the steps of the above-described segmentation method.

[0039] Compared with the prior art, the present invention has the following advantages:

[0040] This invention proposes a linear attention Transformer based on Taylor expansion on the basic Transformer-CNN framework, which reduces the quadratic computational complexity of softmax-attention to linear complexity, and successfully solves the problem that the Transformer-CNN network based on softmax-attention performs poorly or even cannot perform segmentation in long sequence, especially high-resolution image segmentation tasks.

[0041] This invention proposes a linear multi-head self-attention module based on Taylor expansion, which retains the ability to model long-distance dependencies between data and can achieve efficient and accurate segmentation with less memory and fewer parameters. Attached Figure Description

[0042] Figure 1 This is a schematic diagram of the magnetic resonance image segmentation network model of the present invention;

[0043] Figure 2 This is a comparison of the visualization results of the present invention, the magnetic resonance image segmentation method based on softmax-attention (Trans-Unet), and the present invention. (a) is the original magnetic resonance image, (b) is the ground truth label (GT), (c) is the segmentation map obtained by Trans-Unet, and (d) is the segmentation map obtained by the method of the present invention.

[0044] Table 1 is a comparison table of the magnetic resonance image segmentation method of the present invention with other methods. In the table: V-Net represents the basic segmentation baseline method; Trans-UNet represents a segmentation method based on softmax-attention that combines Transformer and Unet; Swin-UNet represents a magnetic resonance image segmentation method based on pure Transformer structure. Detailed Implementation

[0045] To facilitate understanding and implementation of the present invention by those skilled in the art, the present invention will be further described in detail below with reference to embodiments. It should be understood that the embodiments described herein are for illustration and explanation only and are not intended to limit the present invention.

[0046] Example 1:

[0047] like Figure 1As shown, the magnetic resonance image segmentation method based on artificial intelligence and linear attention specifically includes the following steps:

[0048] Step 1: Obtain the magnetic resonance images and corresponding ground truth labels used for magnetic resonance (MR) image segmentation, divide the magnetic resonance images, and generate training and testing sets;

[0049] This embodiment preprocesses the publicly available left atrial segmentation challenge dataset as a magnetic resonance imaging set:

[0050] Step 1.1: Collect a total of 100 magnetic resonance images and preprocess the magnetic resonance images and their corresponding real labels. The preprocessing is as follows: center-crop to a size of 256×256, then randomly enhance the cropped magnetic resonance images and real labels. Random enhancement includes random rotation, random flipping and random translation. Normalize each enhanced magnetic resonance image to zero mean and unit variance.

[0051] Step 1.2: Divide the randomly enhanced magnetic resonance images into a training set and a test set according to an 80:20 ratio. The training set is denoted as... x i ∈R H×W×C , where x i y represents the magnetic resonance images in the training set. i Represents magnetic resonance image x i Corresponding to the real labels drawn by humans, y i ∈{0,1} H×W M = 80 represents the number of magnetic resonance images in the training set, with image indices i ∈ {1, 2, 3, ..., M}. R H×W×C Let x represent the dimension of the magnetic resonance image, C represent the number of channels in the magnetic resonance image, H represent the length of the magnetic resonance image, and W represent the width of the magnetic resonance image. In this example, x i The image is grayscale, H = W = 256, C = 1;

[0052] Step 2: Construct a magnetic resonance image segmentation network model based on Convolutional Neural Networks (CNN) and linear attention. This magnetic resonance image segmentation network model includes an encoder and a decoder. The encoder includes a residual-based CNN basic downsampling network module and a linear attention module. The decoder is a cascaded upsampling module.

[0053] Step 2.1: Select the three residual blocks of the ResNet-50 module as the basic downsampling network module of the CNN;

[0054] Step 2.2: Construct the linear attention module, which includes 12 linear attention layers (Transform Layers). Each linear attention layer includes the following structure: a first-layer normalization module (Layer Norm), a linear multi-head self-attention module (T-MSA), a second-layer normalization module (Layer Norm), and a multilayer perceptron (MLP). The first-layer normalization module, the second-layer normalization module, and the multilayer perceptron are directly built based on the conventional linear attention layer Transformer Layer structure.

[0055] Step 2.3: Based on the conventional linear attention layer Transformer Layer's multi-head self-attention (MSA), design a linear multi-head self-attention module (T-MSA) based on Taylor expansion. In the basic multi-head self-attention MSA, the attention calculation formula is expressed as:

[0056]

[0057] Right now

[0058] Where Q, K, and V represent the query vector, key vector, and value vector, respectively. n K n The images x and x represent the magnetic resonance images output by the first-level normalization module, respectively. i The query vector and key vector of the feature corresponding to the nth slice, K j and V j The magnetic resonance image x represents the output of the first-level normalization module. i The key vector and value vector of the feature corresponding to the j-th slice. N represents each magnetic resonance image x output by the first-layer normalization module. i Number of slices included, Attention(Q) n ,K n V j () represents the attention calculation result of the nth slice, and T is the transpose. In attention, f(x) = e x From f(x) = e x Taylor expansion e x ≈1+x gives the expression for linear multi-head self-attention:

[0059]

[0060] Furthermore, using the associative law of matrix multiplication, we obtain the T-MSA calculation formula with linear computational complexity:

[0061]

[0062] Among them, LineAttention(Q n ,K j V j The result is the calculation result of the linear multi-head self-attention module (T-MSA). This linear multi-head self-attention module, together with the other structures in step 2.2 above, forms a linear attention layer. The 12 linear attention layers then constitute the linear attention module.

[0063] Step 2.4: Construct cascaded upsampling modules, including four cascaded Conv2dReLU upsampling modules. Each Conv2dReLU upsampling module includes a 2× upsampling operator, a 3×3 convolutional layer, and a ReLU layer.

[0064] In the encoder:

[0065] Magnetic resonance image x i The input encoder is a basic CNN downsampling network module, and the input is a magnetic resonance image x with dimensions of 256×256. i The feature map sizes (length × width) obtained after passing through the three residual blocks of the CNN basic downsampling network module are 128×128, 64×64, and 32×32, respectively.

[0066] The feature map output from the last residual block of the CNN basic downsampling network module is serialized. In this embodiment, the final 32×32 feature map output from the CNN basic downsampling network module is segmented using slices of length × width P × P (P = 16), and each feature map yields... There are four slices. Each slice has a size of P×P×C, which is 16×16×1. Each slice is converted into a (16×16)×1 two-dimensional sequence, and the two-dimensional sequence is flattened into a one-dimensional vector by row or column order. The one-dimensional vectors corresponding to the four slices are recombined and concatenated to obtain a two-dimensional feature map sequence of size 4×(16×16×C). in It is a one-dimensional vector representation of the nth slice;

[0067] For the two-dimensional feature map sequence x p Perform linear projection to map to the latent D-dimensional embedding space to obtain a two-dimensional feature map sequence x. p The encoded features (i.e., the encoded feature sequence). In this embodiment, D = 512. Two-dimensional feature map sequence x p The encoded features obtained through linear projection are represented as follows:

[0068]

[0069] Where Z0 is the two-dimensional feature map sequence xp The linear projection encoded features after linear projection, E∈R (P×P×C)×D It is slice embedding projection coding, E pos ∈R N×D This indicates the position code.

[0070] Linear projection coding features Z0 include magnetic resonance image x i The linear projection coding features corresponding to the 1st to Nth slices.

[0071] Two-dimensional feature map sequence x p The linear projection encoded feature Z0 is input to the first normalization module of the first linear attention layer of the encoder, and then passes through 12 linear attention layers. In each linear attention layer, the encoded feature Z0 is output from the previous linear attention layer. l-1 The encoding continues sequentially through the linear multi-head self-attention (T-MSA) module and the multilayer perceptron (MLP) in the current linear attention layer. The encoded features output by the l-th layer (i.e., the 12-layer linear attention layer) can be represented as:

[0072] Z l =T-MSA(LN1(Z) l-1 ))+Z l-1

[0073] Z l =MLP(LN2(Z) l ′))+Z l ′

[0074] Where LN1() represents the first-layer normalization module, LN2() represents the second-layer normalization module, T-MSA(·) represents the linear multi-head self-attention module, MLP(·) represents the multilayer perceptron, and Z l Z' is an intermediate encoded feature of the l-th linear attention layer. l and Z l-1 These are the encoded features output by the l-th and (l-1)-th linear attention layers of the linear attention module, respectively. l Z l ′∈R (16×16)×D That is, the length of the encoded feature is 256.

[0075] In the decoder:

[0076] The encoded features Z output by the linear attention module 12The input size is successively upsampled through a cascaded upsampling module, and finally passed through a 1×1 convolution to generate a segmentation map of size 256×256. At the same time, the encoded features of each upsampling step are combined with the output features of the residual blocks of the same size corresponding to the basic downsampling network module of the CNN in the encoder through skip connections (there are three skip connections in total) to ensure that no features are lost and to guarantee the performance of the network.

[0077] The encoded feature Z of the 12th linear attention layer at the end of the linear attention module has a sequence length of 256. 12 Recombining, that is, encoding feature Z 12 Encoding features restored to a 16×16 (P×P) slice size.

[0078] The encoded features, restored to a slice size of 16×16, are upsampled four times by four cascaded Conv2dReLU upsampling modules. This restores the 16×16 slice-sized encoded features to the full resolution of H×W. In this embodiment, the input image size is 256×256, and the downsampled size is 16×16. After four upsampling operations, the sizes of the encoded features are restored to: 32×32, 64×64, 128×128, and 256×256, respectively. The first three Conv2dReLU upsampling modules of the decoder are skipped to the three residual blocks corresponding to the basic CNN downsampling network module of the encoder. Specifically, the first residual block is connected to the third Conv2dReLU upsampling module (at this time, the size of the magnetic resonance image and the corresponding encoded feature is 128×128), the second residual block is connected to the second Conv2dReLU upsampling module (at this time, the size of the magnetic resonance image and the corresponding encoded feature is 64×64), and the third residual block is connected to the first Conv2dReLU upsampling module (at this time, the size of the magnetic resonance image and the corresponding encoded feature is 32×32), thus realizing feature aggregation. The upsampled encoded features output by the fourth Conv2dReLU upsampling module (i.e., the probability distribution of the segmentation map) are processed by a 1×1 convolution to generate a segmentation map of size 256×256.

[0079] Step 3: Initialize the magnetic resonance image segmentation network model, train the magnetic resonance image segmentation network model using the preprocessed dataset, and obtain the optimal weights of the magnetic resonance image segmentation network model.

[0080] The magnetic resonance image segmentation network model built in step 2 is trained multiple times using the training set. In this embodiment, epoch = 10000. The classification loss and Dice loss are calculated to obtain the total loss function value and optimize the model parameter weights. The classification loss uses cross-entropy loss L. CE :

[0081]

[0082] Where y represents the manually drawn real label. In a binary classification task, the target region to be segmented is represented as y = 1, and other regions as y = 0. This represents the probability distribution of the segmentation map output by each Conv2dReLU upsampling module of the magnetic resonance image segmentation network model. Dice loss L Dice Represented as:

[0083]

[0084] Where || represents the number of elements equal to 1, and smooth represents the smoothing coefficient. In this embodiment, smooth is set to 1 to prevent the denominator from being 0. The total loss function is expressed as:

[0085] Loss total =L CE +αL Dice

[0086] Where α is the balancing weight coefficient, α = 0.5.

[0087] Choose the total loss function value Loss total The weights of the magnetic resonance image segmentation network model with the smallest value are taken as the optimal weights.

[0088] Step 4: Use the optimal weighted magnetic resonance image segmentation network model to segment the magnetic resonance image to be segmented and output the segmentation map.

[0089] In this embodiment, the magnetic resonance image segmentation network model with optimal weights is tested using a test set to obtain the target segmentation result.

[0090] This embodiment uses the SGD optimizer to update network parameters (weight decay = 0.0001). The initial learning rate is set to 0.01, and the learning rate is decayed by dividing by 10 every 2500 iterations, for a total of 10000 iterations.

[0091] Table 1 shows the performance of the method of this invention. In the left atrial segmentation experiment, the present invention achieved the best results in both Dice (Dice similarity coefficient) and ASD (mean surface distance). Compared with the softmax-attention-based transformer-CNN combination method (TransUnet), the strategy of this invention improves Dice by approximately 1.36% and reduces ASD by approximately 30.10%. It also shows a certain performance improvement compared with other methods. Furthermore, apart from the most basic and simplest magnetic resonance image segmentation network V-Net, this method significantly reduces the number of parameters, i.e., memory consumption, with only half the number of parameters required by the softmax-attention-based TransUnet, greatly improving the efficiency and applicability of the network.

[0092] Table 1

[0093]

[0094] Figure 2 The diagram shows a comparison of the segmentation results of this invention with those of the softmax-attention-based magnetic resonance image segmentation method (Trans-Unet), where GT represents the real segmentation label. It can be clearly seen that the target region segmented by the proposed method is closer to the real result than that segmented by the Trans-Unet method.

[0095] Those skilled in the art will understand that all or part of the processes in the above embodiments can be implemented by a computer program instructing related hardware. The computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above methods.

[0096] Example 2:

[0097] In one embodiment, a computer device is also provided, including a memory and a processor, wherein the memory stores a computer program, and the processor executes the computer program to implement the steps in the above method embodiments.

[0098] Example 3:

[0099] In one embodiment, a computer-readable storage medium is provided having a computer program stored thereon that, when executed by a processor, implements the steps in the above method embodiments.

[0100] Example 4:

[0101] In one embodiment, a computer program product is provided, including a computer program that, when executed by a processor, implements the steps in the above method embodiments.

[0102] It should be noted that the specific embodiments described in this invention are merely illustrative of the spirit of the invention. Those skilled in the art to which this invention pertains can make various modifications or additions to the described specific embodiments or use similar methods to substitute them, without departing from the spirit of the invention or exceeding the scope defined by the appended claims.

Claims

1. A magnetic resonance image segmentation method based on artificial intelligence and linear attention, characterized in that, Includes the following steps: Step 1: Obtain magnetic resonance images and corresponding ground truth labels, divide the magnetic resonance images, and generate training and testing sets; Step 2: Construct a magnetic resonance image segmentation network model based on convolutional neural networks and linear attention; Step 3: Train the magnetic resonance image segmentation network model using the dataset, aiming to minimize the total loss function and obtain the optimal weights of the magnetic resonance image segmentation network model; Step 4: Use the optimal weighted magnetic resonance image segmentation network model to segment the magnetic resonance image to be segmented and output a segmentation map. The magnetic resonance image segmentation network model includes an encoder and a decoder. The encoder consists of a residual-based CNN basic downsampling network module and a linear attention module. The decoder is a cascaded upsampling module. The basic downsampling network module of a CNN consists of three residual blocks. The linear attention module consists of multiple linear attention layers. Each linear attention layer includes: a first-layer normalization module (Layer Norm), a linear multi-head self-attention module (T-MSA), a second-layer normalization module (Layer Norm), and a multilayer perceptron (MLP). The cascaded upsampling module consists of multiple cascaded Conv2dReLU upsampling modules. The number of Conv2dReLU upsampling modules is equal to the number of residual blocks in the basic CNN downsampling network module plus one. The CNN basic downsampling network module of the magnetic resonance image input encoder is used to serialize the feature maps output by the CNN basic downsampling network module to obtain a two-dimensional feature map sequence. in It is a one-dimensional vector representation of the nth slice, where N is the total number of slices. For the two-dimensional feature map sequence x p Linear projection is performed to obtain the corresponding linear projection encoded feature Z0. The linear projection encoded feature Z0 is input to the linear attention module of the encoder, and the encoded feature Z0 is output by the linear attention module. 12 The encoded features, restored to slice size, are processed sequentially through each Conv2dReLU upsampling module in the cascaded upsampling module, and then subjected to a 1×1 convolution to generate a segmentation map. The decoder's Conv2dReLU upsampling module and the encoder's CNN basic downsampling network module make skip connections to residual blocks of the same size. The two-dimensional feature map sequence is based on the following steps: The feature map output by the basic downsampling network module of the CNN is segmented using slices of length × width P × P. Each slice is converted into a two-dimensional sequence. The two-dimensional sequence is flattened into a one-dimensional vector in row or column order. The one-dimensional vectors corresponding to the slices of the same feature map are recombined and concatenated to obtain a two-dimensional feature map sequence. The linear projection is based on the following formula: Where Z0 is the two-dimensional feature map sequence x p The linear projection encoded features after linear projection, E is the slice embedding projection code, E pos Indicates position code, The linear multi-head self-attention module is based on the following formula: LineAttention(Q n ,K j V j The result is calculated by a linear multi-head self-attention module. Q n The magnetic resonance image x represents the output of the first-level normalization module. i The query vector of the feature corresponding to the nth slice, K j and V j The magnetic resonance image x represents the output of the first-level normalization module. i The key vector and value vector of the feature corresponding to the j-th slice. The linear attention module is based on the following formula: With l ′=T-MSA(LN1(Z l-1 ))+Z l-1 WITH l =MLP(LN2(Z l ′))+Z l ′ Where LN1() represents the first-layer normalization module, LN2() represents the second-layer normalization module, T-MSA(·) represents the linear multi-head self-attention module, MLP(·) represents the multilayer perceptron, and Z l Z' is an intermediate encoded feature of the l-th linear attention layer. l and Z l-1 These are the encoded features output by the l-th and (l-1)-th linear attention layers of the linear attention module, respectively.

2. The magnetic resonance image segmentation method based on artificial intelligence and linear attention according to claim 1, characterized in that, The magnetic resonance image mentioned in step 1 is a preprocessed magnetic resonance image. The preprocessing includes: cropping the center of the magnetic resonance image to a set size, randomly enhancing the cropped magnetic resonance image and the real label, and normalizing each enhanced magnetic resonance image to zero mean and unit variance. Random augmentations include random rotation, random flipping, and random translation.

3. The magnetic resonance image segmentation method based on artificial intelligence and linear attention according to claim 1, characterized in that, The total loss function Loss total Based on the following formula: Loss total =L CE +αL Dice Among them, L CE For cross-entropy loss, L Dice The loss function is Dice, where α is the balancing weight coefficient and y represents the manually drawn true labels. This represents the probability distribution of the segmentation map output by each Conv2dReLU upsampling module of the magnetic resonance image segmentation network model. "smooth" represents the smoothing coefficient, and "||" represents the number of elements with a value of 1.

4. A computer device comprising a memory and a processor, wherein the memory stores a computer program, characterized in that, When the processor executes the computer program, it implements the steps of the segmentation method according to any one of claims 1 to 3.

Citation Information

Patent Citations

  • Coding and decoding network glioma fusion segmentation system and method based on attention enhancement

    CN115661165A

  • Remote sensing image accurate segmentation method

    CN118504427A