A Transformer diffusion segmentation method and system for brain lesion MRI images based on symmetry prior

By combining symmetry priors with the Transformer diffusion segmentation method for brain lesion MRI images, this method addresses the issues of wasted computational resources in convolutional neural networks and lack of lesion information in denoising diffusion models, achieving higher accuracy and more stable brain lesion segmentation.

CN119723074BActive Publication Date: 2025-10-28WUHAN UNIV
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202411612605.6
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-11-13
Publication Date
2025-10-28
Estimated Expiration
2044-11-13

AI Technical Summary

Technical Problem

In the medical image segmentation of brain lesions, existing technologies suffer from computational resource waste in convolutional neural networks and induction bias introduced by pooling, which limits the ability to perceive anatomical structures. Furthermore, the denoising diffusion model lacks conditional information related to lesions, resulting in insufficient segmentation accuracy.

Method used

A Transformer diffusion segmentation method for brain lesion MRI images based on symmetry priors is adopted. By combining symmetry prior modules, modality prior modules, and feature conditional coding modules with denoising coding and decoding processing, the diffusion model is used to recover lesion features from noise, and stable segmentation results are generated by fusing features through cross-frequency domain attention.

Benefits of technology

It improves the segmentation accuracy of brain lesions, reduces the waste of computing resources, and enhances the stability and accuracy of segmentation through long-distance coding and frequency domain filtering.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119723074B_ABST
    Figure CN119723074B_ABST
Patent Text Reader

Abstract

This invention discloses a Transformer diffusion segmentation method and system for MRI images of brain lesions based on symmetry priors. The invention proposes a novel prior-guided diffusion-denoised Transformer model for brain lesion segmentation, extracting long-range encoded features from the images, supplemented by local information related to prior medical image characteristics, and further introducing frequency domain filtering and fusion encoding components. A U-shaped denoising model is designed based on the Transformer network structure. To maintain accurate semantic details related to the lesions, a prior feature encoding branch is introduced. This prior feature encoding branch considers the modality-related voxel distribution characteristics and intramodal spatial symmetry, thereby learning a prior-guided attention mask and dynamically adjusting the attention weights at the pixel and patch levels. To eliminate image noise and low-contrast effects, a three-branch wavelet spectral hybrid attention module is designed in the decoding part to fuse and filter spectral feature embeddings, further generating stable segmentation results.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention belongs to the field of artificial intelligence technology, and in particular relates to a Transformer diffusion segmentation method for MRI images of brain lesions based on symmetry priors, which can be used for automatic segmentation of various brain lesions. Background Technology

[0002] The disease spectrum has changed in modern society, and brain health has become an important part of technological innovation and the forefront of medicine. The brain has a complex structure with different regions functioning differently. Many brain diseases (such as dementia, brain tumors, and stroke) affect specific brain regions, and often the lesions have already developed in the brain before clinical symptoms appear. Therefore, early diagnosis and precise localization of the lesion area are crucial for effective treatment. Brain medical image segmentation highlights key tissue structures and lesions, serving as a key intermediate step in computer-aided diagnosis. It involves processing medical images (such as MRI images) to highlight key tissue structures and lesions, making it a crucial intermediate step in computer-aided diagnosis. With the advancement of imaging technology, obtaining high-resolution brain images has become possible. However, in clinical practice, the amount of image data is enormous, and manual analysis is time-consuming and prone to errors. Therefore, automated image segmentation technology has emerged. With the rapid development of artificial intelligence and deep learning, deep learning-based automatic segmentation technology has been gradually realized, becoming a research hotspot and an important direction for further development in medical image processing.

[0003] With the development of deep learning, neural networks have achieved dominant performance in medical image segmentation. U-Net, evolved from fully convolutional networks, provides the idea of ​​encoder-decoder networks and skip connections. Its superior performance in various medical segmentation tasks has made the U-shaped network structure the most representative method in the field of medical image segmentation. In CNN-based U-shaped networks, the convolutional modules in the U-Net network are typically studied by referencing the module construction ideas of mature general network models. Although convolutional modules have significant advantages in local feature extraction, the inherent limitations of convolution require stacking convolutions of different kernel sizes to expand the receptive field, which undoubtedly wastes computational resources. Moreover, the inductive bias introduced by pooling limits the CNN module's ability to perceive complex anatomical structures. In contrast, the visual Transformer, by dividing the image into non-overlapping patches and computing self-attention at this level, achieves long-distance dependency modeling and realizes global-scale semantic information perception. This has given new inspiration to medical image segmentation tasks. In recent studies, Transformer modules have been flexibly integrated into encoders, decoders, and skip connections in various forms, achieving competitive performance. However, these works often focus on improving model structure design and feature representation capabilities, while paying little attention to the nature of medical images themselves, and have shortcomings in low-level detail perception and accurate regional localization.

[0004] In the field of image generation, denoising diffusion models have developed rapidly. Compared with previous generative models, denoising diffusion probabilistic models can generate high-quality, clear data samples with detailed features and have advantages in training stability. The idea of ​​recovering semantic distribution information from noise has attracted interest in the field of medical segmentation. However, it is necessary to introduce lesion-related conditional information into the diffusion model to better recover the segmentation target from noise. At the same time, there is a domain adaptation problem between the features of the denoising module and the conditional module, which needs to be addressed. Summary of the Invention

[0005] To address the shortcomings of existing technologies, this invention provides a Transformer diffusion segmentation method and system for MRI images of brain lesions based on symmetry priors.

[0006] The technical solution of this invention is a Transformer diffusion segmentation method for MRI images of brain lesions based on symmetry prior, comprising the following steps:

[0007] Step 1: Input images related to the diagnosis of the lesion and perform preprocessing;

[0008] Step 2: Perform conditional coding on the processed image to generate conditional coded features;

[0009] Step 3: During the training phase, the labeled images are progressively denoised using a diffusion model to obtain denoised images;

[0010] Step 4: Combine the generated conditional coding features to perform denoising coding processing on the noisy image and generate denoising coding features;

[0011] Step 5: Combine the generated conditional coding features with the generated denoising coding features and perform denoising decoding processing to generate various segmentation label images;

[0012] Step 6: Train the segmentation network constructed in Steps 2-5 using the loss function;

[0013] Step 7: Test the trained segmentation network to generate the most stable segmentation result.

[0014] Furthermore, the conditional encoding process includes a symmetric prior module, a modal prior module, and a feature conditional encoding module;

[0015] The processing procedure of the symmetric prior module is as follows:

[0016] First, both the original and inverted images are divided into fixed-size, non-overlapping regions, or image patches, in the same manner. A similarity matrix is ​​calculated for symmetrical patch regions using cosine similarity. This similarity matrix is ​​then flattened into a one-dimensional vector, and a value vector v is generated through linear layer projection. s Key vector k s and query vector q s d is the vector dimension, and the weights are calculated using the softmax function to determine symmetric similarity and attention. for:

[0017]

[0018] The calculated attention weights are copied so that the same attention weights are in a patch. Then, after being restored to the original size through geometric transformation, they are multiplied with the input image to obtain the symmetric prior weighted image features.

[0019] The modal prior module models the image manifestation of the lesion parenchyma under a specific modality. For white matter lesions, the white matter parenchyma appears as a high signal in T2FLAIR images, while it appears as a low signal in T1 images. By calculating the difference between the original images of the two modalities, the modal prior of the i-th layer is defined as follows. The first modal prior is the difference between the T2FLAIR modal images and the T1 modal images:

[0020]

[0021] x t1 For the T1 modal image, xt2 T2FLAIR modal image;

[0022] The subsequent three modal prior features are obtained through a downsampling convolutional layer, ConvBlock:

[0023]

[0024] The processing procedure of the feature conditional coding module is as follows:

[0025] Symmetrically weighted prior image features are input into a feature conditional coding module to obtain conditionally encoded features. The feature conditional coding module consists of four consecutive Transformer layers, each containing two Transformer modules. Downsampled features are generated layer by layer from the input multimodal image, with features at each resolution and modal prior features at the same resolution. Multiplication yields modal prior weighted multi-level features. Finally, the weighted conditional features after multiplication at each level, i.e., conditional coding features, are input into the denoising coding and denoising decoding processes and fused with the corresponding scale features. In the denoising coding process, the conditional coding features and denoising coding features are fused by addition. In the denoising decoding process, the conditional coding features, denoising coding features, and denoising decoding features are fused by cross-attention.

[0026] Furthermore, the process of adding noise to the labeled image is as follows:

[0027] For single-class lesion labels, noise enhancement is applied directly. For multi-class labels, one-hot encoding is used to convert the segmentation labels into multi-channel labels, and t-step noise ε is applied during the forward pass. t The image labeled with time step t is y. t Then the image x at time step t t The relationship can be represented as:

[0028]

[0029]

[0030] Where ε t ~N(0,1), α t With β t α represents the noise figure, controlling the amount of noise added to the data points at each time step, and α t =1-β t q(·) represents the probability distribution. Let y represent a normal distribution, and I be the identity matrix. 1:T This represents the final state of diffusion and noise addition. T For the final time step;

[0031] Depend on The derivation yields:

[0032]

[0033] in y0 represents the initial state of the diffusion and noise addition process. During training, it represents the labeled image, and during testing, it represents the noise image. ∈ represents the error term or random perturbation, which reflects the noise from one time point to another.

[0034] Furthermore, the denoising encoding process is performed by a denoising encoding module, which consists of a temporal encoding embedding module and four consecutive Transformer downsampling modules. In the downsampling module, the denoising encoding features are combined with the temporal encoding embedding step by step to fuse the current time step information. At the same time, the conditional encoder features that are downsampled step by step by the four Transformer layers are added and fused with the denoising encoder of the same resolution at the corresponding layer, so that the denoising encoding features contain event information.

[0035] Furthermore, the denoising encoding process specifically includes the following sub-steps:

[0036] Step 4.1: First, time-encoded embedding is performed on the time step. The time-encoded embedding concatenates the sine / cosine components of the time step information after exponential decay. The concatenated time feature embedding is then passed through a linear layer and a sigmoid layer to form the final time-encoded embedding t. emb ;

[0037] Step 4.2, Patch embedding operation, adding noise to the labeled image x at time step t. t Fill in the blanks for x t Perform linear projection on the time-coded embedding t generated in step 4.1. emb Perform nonlinear transformation and linear projection and add to x t In this process, the summed vectors are subjected to a second projection transformation and then normalized.

[0038] Step 4.3: Layer by layer, the four Transformer layers in the denoising coding module process the input features to generate denoised coded features. The four Transformer coded features in the denoising coding module are added to the conditional codes of the corresponding scale to supplement the denoised features with prior conditional information.

[0039] Furthermore, the denoising decoding process is performed by a denoising decoding module, which consists of a temporal coding embedding module and four consecutive upsampling modules. The first three layers of the upsampling module are Transformer upsampling, and the last layer is convolutional upsampling. The features after denoising decoding are restored to their original resolution step by step, and various segmentation label images are generated through the final convolution operation. During the decoding process, the coded features of the same resolution at the corresponding level of denoising coding and conditional coding are fused with the decoded features of the same resolution through cross-attention, and the spectral components are filtered through frequency domain processing to remove unwanted noise components and make up for the differences in the neighborhood distribution of the three types of features.

[0040] Furthermore, the specific implementation of the noise reduction and decoding process includes the following sub-steps:

[0041] Step 5.1: First, perform time-encoded embedding on the time step. The time-encoded embedding concatenates the sine / cosine components of the time step information after exponential decay. The concatenated time feature embedding is then passed through a linear layer and a sigmoid layer to form the final time-encoded embedding t. emb ;

[0042] Step 5.2: The three-layer upsampling Transformer layer in the denoising decoder processes the denoised coding input features and uses a self-attention mechanism based on wavelet transform to calculate the improved frequency domain component filtering capability. The lower layer decoding features are combined with the conditional coding features and denoised coding features after being upsized.

[0043] Each scale-level upsampling Transformer layer consists of two transformer blocks. The first transformer block is a three-branch attention fusion decoding, which calculates the flattened linear projections of the denoised decoding upsampling features, denoised coding jump features, and conditional coding jump features as the query q. b , key k b AND value vector v b In this process, the denoising decoding upsampling features are generated by the upsampling Transformer layer, the denoising coding skip features are generated by the same-scale denoising coding module, and the conditional coding skip features are generated by the same-scale conditional coding module. Both types of skip features are connected to the denoising decoding module via skip connections. Then, relative position encoding and three-branch multi-head self-attention MSA calculation are performed, assuming d... b B represents the dimension of the input feature. b Encoding for relative positions:

[0044]

[0045] Subsequently, the second transformer module performs wavelet transform on the three-branch attention fusion features. The three-dimensional features are sequentially decomposed into eight-channel feature vectors, representing different frequency domain signals. The frequency-domain separated signal features are further processed by convolutional layers and encoded into key-value embeddings. These embeddings, together with the query embeddings calculated from the three-branch attention fusion features, are used to calculate self-attention. Finally, they are added to the overall inverse transform signal. Let... Features of three-branch attention fusion:

[0046]

[0047]

[0048] DWT represents Discrete Wavelet Transform, and IDWT represents Inverse Discrete Wavelet Transform.

[0049] Wave-MSA represents wavelet self-attention transform, which performs a projection transform on the three-branch attention fusion features to obtain the query q. f , key k f AND value vector v f Let d f B represents the dimension of the input feature. f Encoding for relative positions:

[0050]

[0051] After filtering the frequency domain components using wavelet transform, the features after layer normalization (Norm) are input into the feedforward network FF and added to the original features:

[0052]

[0053] Step 5.3: The decoder effectively utilizes cross-attention to integrate multi-scale features from multiple branches and flexibly captures sparse multi-scale detail features through wavelet attention. The decoded features are gradually upsampled after being fused by three-branch cross-attention and filtered by spectral components, and then restored to the original resolution through the final convolutional layer.

[0054] Furthermore, the loss functions include the Dice loss function, the BCE loss function, and the MSE loss function. Let y0 be the labeled image. To predict the image, the final loss function is calculated as follows:

[0055]

[0056] Furthermore, in step 7, during the testing process, the noisy label image is replaced with a completely noisy image, and the implicit denoising diffusion model method is used to generate labels. The testing process is regarded as an inverse denoising process. Each iteration generates a segmentation result, and after multiple iterations, the most stable segmentation result is generated.

[0057] This invention also provides a Transformer diffusion segmentation system for MRI images of brain lesions based on symmetry priors, comprising:

[0058] The processor and memory are used to store program instructions, and the processor is used to call the stored instructions in the memory to execute the Transformer diffusion segmentation method for MRI images of brain lesions based on symmetry prior, as described in the above technical solution.

[0059] This invention utilizes a diffusion denoising model, combined with relevant prior medical knowledge of brain lesions, to construct a Transformer-based medical image segmentation model for brain lesions. It uses the depth features of the original image and prior features to perform long-distance conditional dependency coding, gradually recovering the label distribution from the noise distribution. Furthermore, it fully integrates features through cross-frequency domain attention, filters spectral components, forms a more stable segmentation result, and improves the accuracy of lesion segmentation. Attached Figure Description

[0060] Figure 1 This is a flowchart of the training process according to an embodiment of the present invention.

[0061] Figure 2 This is a flowchart of the testing process according to an embodiment of the present invention.

[0062] Figure 3 This is a flowchart of the symmetric prior module in an embodiment of the present invention.

[0063] Figure 4 This is a schematic diagram of the modal prior module in an embodiment of the present invention.

[0064] Figure 5 This is a schematic diagram of the diffusion encoding / decoding module according to an embodiment of the present invention. Detailed Implementation

[0065] This invention is based on prior medical knowledge related to brain lesions, as shown in the appendix. Figure 1This paper proposes a novel prior-guided diffusion-based Transformer model for brain lesion segmentation. It extracts long-range encoded features from images, supplements them with local information related to prior medical image characteristics, and further introduces frequency domain filtering and fusion encoding components. A U-shaped denoising model is designed based on the Transformer network structure. To maintain accurate semantic details related to lesions, a prior feature encoding branch is introduced. This branch explicitly considers the modality-related voxel distribution characteristics and intramodal spatial symmetry through a multi-level modality difference module and a symmetric similarity attention module, thereby learning a prior-guided attention mask and dynamically adjusting the attention weights at the pixel and patch levels. To eliminate image noise and low-contrast effects, a three-branch wavelet spectral hybrid attention module is designed in the decoding part to fuse and filter spectral feature embeddings, further generating stable segmentation results.

[0066] The method provided by this invention can be implemented using computer software technology. See also... Figure 1 The following is a specific illustration of the process of the present invention, using bimodal MRI (T1, T2 FLAIR) input white matter high signal segmentation as an example:

[0067] Step 1, Image Preprocessing. Input images relevant to lesion diagnosis. Clinical diagnosis of white matter hyperintensity mainly relies on T1 and T2 FLAIR modal images. Define T1 modal image as x t1 Define the T2FLAIR modal image as x t2 Since clinical white matter hyperintensity assessment primarily utilizes T2FLAIR modality images, a registration algorithm was first employed to register the T1 modality to the T2FLAIR modality images. The voxel spacing of the T1 modality, T2FLAIR modality, and label images was then aligned, and the voxel spacing was uniformly resampled to (1.0, 1.0, 1.0). The data was then divided into training, validation, and test sets in a 7:1:2 ratio.

[0068] Step 2, process the input original image {x 0 ,…,x m Perform conditional encoding (in this example, {x}). t1 ,x t2 The condition encoder generates conditionally encoded features. The condition encoder consists of a symmetric prior module, a modal prior module, and a feature condition encoding part.

[0069] Step 2.1: Model symmetry prior conditions using the symmetry prior module. The symmetry prior module queries abnormal lesion regions based on the symmetrical distribution of brain anatomical structures and the asymmetrical distribution of lesion parenchyma, and calculates salient lesion regions at the plaque level using an attention mechanism. Specifically, the original image and the inverted image are first divided into fixed-size non-overlapping regions, i.e., image patches, in the same way. The similarity matrix corresponding to the symmetrical patch regions is calculated using cosine similarity. The similarity matrix is ​​flattened into a one-dimensional vector, and a value vector v is generated through linear layer projection. s Key vector k s and query vector q s d is the vector dimension, and the weights are calculated using the softmax function to determine symmetric similarity and attention. for:

[0070]

[0071] The calculated attention weights are copied so that each patch has the same attention weight. Then, after being restored to the original size through geometric transformation, they are multiplied with the input image to obtain the symmetric prior weighted image features.

[0072] Step 2.2: The modal prior module constructs modal prior conditions. The modal prior module models the image manifestation of the lesion parenchyma under a specific modality. Taking white matter lesions as an example, the white matter parenchyma appears as a high signal in T2FLAIR images, while it typically appears as a low signal in T1 images. By calculating the difference between the original images of the two modalities, the modal prior of the i-th layer is defined as follows: The first modal prior is the difference between the T2FLAIR modal images and the T1 modal images:

[0073]

[0074] The subsequent three modal prior features are obtained through a downsampling convolutional layer, ConvBlock:

[0075]

[0076] Step 2.3, Feature Conditional Encoding. The image features, after symmetric prior weighting, are input into the feature conditional encoding part to obtain conditionally encoded features. The feature conditional encoding part consists of four consecutive Transformer layers, each containing two Transformer modules. Downsampled features are generated layer by layer from the input multimodal image, with features at each resolution and modal prior features at the same resolution. Multiplication yields multi-level features weighted by modality priors. Finally, the weighted conditional features resulting from each layer's multiplication (i.e., the final generated conditional encoded features) are input into the denoising encoder and decoder, and fused with the corresponding scale features. In the denoising encoder, conditional features and denoised encoded features are fused by addition; in the denoising decoder, conditional features, denoised encoded features, and denoised decoded features are fused through cross-attention.

[0077] Step 3: During the training phase, the labeled images are progressively subjected to a forward noise addition process using the diffusion model. Single-class lesion labeled images can be directly noise-added. For multi-class labels, one-hot encoding is used to convert the segmented labels into multi-channel labels, and t-step noise ε is added during the forward process. t The image labeled with time step t is y. t Then the image x at time step t t The relationship can be represented as:

[0078]

[0079]

[0080] Where ε t ~N(0,1), α t With β t α represents the noise figure, controlling the amount of noise added to the data points at each time step, and α t =1-β t q(·) represents the probability distribution. Let y represent a normal distribution, and I be the identity matrix. 1:T This represents the final state of diffusion and noise addition. T This is the final time step.

[0081] Depend on

[0082] The derivation yields:

[0083]

[0084] in y0 represents the initial state of the diffusion and noise addition process; during training, it represents the labeled image, and during testing, it represents the noisy image. ∈ represents the error term or random perturbation, which reflects the noise from one time point to another.

[0085] Step 4 involves denoising the noisy image using a denoising encoding module. This module constructs deep features for the noisy labels, helping the model learn the lesion label distribution from the noise distribution. The denoised label image from Step 3 is input into the denoising encoding module, which consists of a temporal encoding embedding module and four consecutive Transformer downsampling modules. In the downsampling modules, the denoising encoded features are progressively combined with the temporal encoding embedding, fusing information from the current time step. Simultaneously, the conditional encoder features, downsampled through four Transformer layers, are added and fused with the corresponding denoising encoder at the same resolution, ensuring that the denoising encoded features contain event information.

[0086] Step 4.1: First, time-encoded embedding is performed on the time step. The time-encoded embedding concatenates the sine / cosine components of the time step information after exponential decay. The concatenated time feature embedding is then passed through a linear layer and a sigmoid layer to form the final time-encoded embedding t. emb .

[0087] Step 4.2, Patch embedding operation, adding noise to the labeled image x at time step t. t Fill in the blanks for x t Perform linear projection on the time-coded embedding t generated in step 4.1. emb Perform nonlinear transformation and linear projection and add to x t In this process, the summed vectors undergo a second projection transformation and are then normalized.

[0088] Step 4.3: Layer by layer, the four Transformer layers in the denoising encoder process the input features to generate denoised encoded features. The four Transformer encoded features in the denoising encoder are added to the conditional encoding of the corresponding scale to supplement the denoised features with prior conditional information.

[0089] Step 5 involves denoising and decoding the generated denoised encoded features. This denoising and decoding process is performed by the denoising and decoding module. The module consists of a temporal encoding embedding module and four consecutive upsampling modules. The first three layers use Transformer upsampling, and the last layer uses convolutional upsampling. The features processed by the denoising decoder are progressively restored to their original resolution, and various segmentation label images are generated through the final convolution operation. During decoding, the denoised encoder and conditional encoder's corresponding layer encoded features at the same resolution are fused with the decoded features at the same resolution using cross-attention. Frequency domain processing is then used to filter spectral components, removing unwanted noise components and compensating for differences in the neighborhood distribution of the three feature types.

[0090] Step 5.1, similar to step 4.1, firstly performs time-encoded embedding on the time step. The time-encoded embedding concatenates the sine / cosine components of the time step information after exponential decay. The concatenated time feature embedding is then passed through a linear layer and a sigmoid layer to form the final time-encoded embedding t. emb .

[0091] Step 5.2: The three-layer upsampling Transformer layer in the denoising decoder processes the denoised coding input features and uses a self-attention mechanism based on wavelet transform to calculate the improved frequency domain component filtering capability. The lower layer decoding features are combined with the conditional coding features and denoised coding features after dimensionality upsampling.

[0092] Each scale-level upsampling Transformer layer consists of two transformer blocks. The first transformer block is a three-branch attention fusion decoding, which calculates the flattened linear projections of the denoised decoding upsampling features, denoised coding jump features, and conditional coding jump features as the query q. b , key k b AND value vector v b The denoising decoding upsampling features are generated by the upsampling Transformer layer, the denoising coding skip features are generated by the same-scale denoising coding module, and the conditional coding skip features are generated by the same-scale conditional coding module. Both types of skip features are connected to the denoising decoder via skip connections. Then, relative position encoding and three-branch multi-head self-attention MSA calculation are performed, let d b B represents the dimension of the input feature. b Encoding for relative positions:

[0093]

[0094] Subsequently, the second transformer module performs wavelet transform on the three-branch attention fusion features. The three-dimensional features are sequentially decomposed into eight-channel feature vectors, representing different frequency domain signals. The frequency-domain separated signal features are further processed by convolutional layers and encoded into key-value embeddings. These embeddings, together with the query embeddings calculated from the three-branch attention fusion features, are used to calculate self-attention. Finally, they are added to the overall inverse transform signal. Let... Features of three-branch attention fusion:

[0095]

[0096]

[0097] DWT represents Discrete Wavelet Transform, and IDWT represents Inverse Discrete Wavelet Transform.

[0098] Wave-MSA represents wavelet self-attention transform, which performs a projection transform on the three-branch attention fusion features to obtain the query q. f , key k f AND value vector v f Let d f B represents the dimension of the input feature. f Encoding for relative positions:

[0099]

[0100] After filtering the frequency domain components using wavelet transform, the features after layer normalization (Norm) are input into the feedforward network FF and added to the original features:

[0101]

[0102] In step 5.3, the decoder effectively integrates multi-scale features from multiple branches using cross-attention and flexibly captures sparse multi-scale detail features through wavelet attention. The decoded features are progressively upsampled after being fused by three-branch cross-attention and filtered by spectral components, and then restored to the original resolution through the final convolutional layer.

[0103] Step 6: Perform forward propagation on the data, use the loss function to supervise the network output, update the network parameters through backpropagation, and validate the results using the validation set to obtain the optimized network parameters. During training, the model is trained for 300 epochs. Specifically, the AdamW optimizer is used, and the initial learning rate is set to 1.0 × e^(-1 / 2). -4 The weight decay is 0.001, and the remaining parameters are at their default values. Here, to enable faster network convergence, the learning rate decays by a factor of gamma = 0.5 every 20 epochs. The trained model can save computational resources while maintaining network performance.

[0104] The loss functions include the Dice loss function, the BCE loss function, and the MSE loss function. Let y0 be the labeled image. For predicting images:

[0105]

[0106] Step 7: Test the trained segmentation network. In the testing step, replace the noisy label image with a completely noisy image and use the Implicit Denoising Diffusion Model (DDIM) method to generate labels. The testing process is regarded as an inverse denoising process. Each iteration generates a segmentation result. After multiple iterations, the most stable segmentation result is generated.

[0107] To verify the effectiveness of this invention, comparative experimental data on the white matter high signal segmentation dataset WMH are shown in Table 1. The Dice and HD metrics were used as evaluation standards. A higher Dice metric indicates better segmentation performance, and a lower HD metric indicates better segmentation performance.

[0108] Table 1 Performance Comparison of White Matter High Signal Segmentation Algorithms

[0109]

[0110] It can be seen that, for the task of segmenting high-signal lesions in brain white matter, among the three most commonly used methods (CNN-based methods, Transformer-based methods, and diffusion-based methods), the method of this invention has advantages over other advanced methods in terms of Dice and HD metrics, verifying the effectiveness of the algorithm.

[0111] This invention utilizes a diffusion denoising model, combined with relevant prior medical knowledge of brain lesions, to construct a Transformer-based medical image segmentation model for brain lesions. It uses the depth features of the original image and prior features to perform long-distance conditional dependency coding, gradually recovering the label distribution from the noise distribution. Furthermore, it fully integrates features through cross-frequency domain attention, filters spectral components, forms a more stable segmentation result, and improves the accuracy of lesion segmentation.

[0112] The method provided by this invention can be implemented using computer software technology. System devices for implementing the method of this invention should also be within the scope of protection of this invention.

[0113] This invention also provides a Transformer diffusion segmentation system for MRI images of brain lesions based on symmetry priors, comprising:

[0114] The processor and memory are used to store program instructions, and the processor is used to call the stored instructions in the memory to execute the Transformer diffusion segmentation method for MRI images of brain lesions based on symmetry prior, as described in the above technical solution.

[0115] The specific embodiments described herein are merely illustrative of the spirit of the invention. Those skilled in the art to which this invention pertains may 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 Transformer diffusion segmentation method for MRI images of brain lesions based on symmetry priors, characterized in that, Includes the following steps: Step 1: Input images related to the diagnosis of the lesion and perform preprocessing; Step 2: Perform conditional coding on the preprocessed image to generate conditional coded features; The conditional coding process includes a symmetric prior module, a modal prior module, and a feature conditional coding module; The processing procedure of the symmetric prior module is as follows: First, both the original and inverted images are divided into fixed-size, non-overlapping regions, or image patches, in the same manner. A similarity matrix is ​​calculated for symmetrical patch regions using cosine similarity. This similarity matrix is ​​then flattened into a one-dimensional vector, and a value vector v is generated through linear layer projection. s Key vector k s and query vector q s d is the vector dimension, and the weights are calculated using the softmax function to determine symmetric similarity and attention. for: The calculated attention weights are copied so that the same attention weights are in a patch. Then, after being restored to the original size through geometric transformation, they are multiplied with the input image to obtain the symmetric prior weighted image features. The modal prior module models the image manifestations of lesions in the T2FLAIR and T1 modalities. For white matter lesions, the lesion material appears as high signal in T2FLAIR images and as low signal in T1 images. By calculating the difference between the original images of the two modalities, the modal prior of the i-th layer is defined as follows. The first modal prior is the difference between the T2FLAIR modal images and the T1 modal images: x t1 For T1 modal image, x t2 T2FLAIR modal image; The subsequent three modal prior features are obtained through a downsampling convolutional layer, ConvBlock: The processing procedure of the feature conditional coding module is as follows: Symmetrically weighted prior image features are input into a feature conditional coding module to obtain conditionally encoded features. The feature conditional coding module consists of four consecutive Transformer layers, each containing two Transformer modules. Downsampled features are generated layer by layer from the input multimodal image, with features at each resolution and modal prior features at the same resolution. Multiplication yields modal prior weighted multi-level features. Finally, the weighted conditional features resulting from each multiplication layer, i.e., conditional encoded features, are input into the denoising encoding and denoising decoding processes and fused with the corresponding scale features. In the denoising encoding process, the conditional encoded features and denoising encoded features are fused by addition. In the denoising decoding process, the conditional encoded features, denoising encoded features, and denoising decoded features are fused by cross-attention. Step 3: During the training phase, the labeled images are progressively denoised using a diffusion model to obtain denoised images; Step 4: Combine the generated conditional coding features to perform denoising coding processing on the noisy image and generate denoising coding features; Step 5: Combine the generated conditional coding features with the generated denoising coding features and perform denoising decoding processing to generate various segmentation label images; The denoising and decoding process is performed by the denoising and decoding module, which consists of a temporal coding embedding module and four consecutive upsampling modules. The first three layers of the upsampling module are Transformer upsampling, and the last layer is convolutional upsampling. The features after denoising and decoding are restored to the original resolution step by step, and various segmentation label images are generated through the final convolution operation. During the decoding process, the coded features of the same resolution at the corresponding level of denoising coding and conditional coding are fused with the decoded features of the same resolution through cross-attention. The spectral components are filtered through frequency domain processing to remove unwanted noise components and make up for the differences in the neighborhood distribution of the three types of features. The specific implementation of noise reduction and decoding includes the following sub-steps: Step 5.1: First, perform time-encoded embedding on the time step. The time-encoded embedding concatenates the sine / cosine components of the time step information after exponential decay. The concatenated time feature embedding is then passed through a linear layer and a sigmoid layer to form the final time-encoded embedding t. emb ; Step 5.2: The three-layer upsampling Transformer layer in the denoising decoder processes the denoised coding input features and uses a self-attention mechanism based on wavelet transform to calculate the improved frequency domain component filtering capability. The lower layer decoding features are combined with the conditional coding features and denoised coding features after being upsized. Each scale-level upsampling Transformer layer consists of two transformer blocks. The first transformer block is a three-branch attention fusion decoding, which calculates the flattened linear projections of the denoised decoding upsampling features, denoised coding jump features, and conditional coding jump features as the query q. b , key k b AND value vector v b In this process, the denoising decoding upsampling features are generated by the upsampling Transformer layer, the denoising coding skip features are generated by the same-scale denoising coding module, and the conditional coding skip features are generated by the same-scale conditional coding module. Both types of skip features are connected to the denoising decoding module via skip connections. Then, relative position encoding and three-branch multi-head self-attention MSA calculation are performed, assuming d... b B is the dimension of the input feature. b Encoding for relative positions: Subsequently, the second transformer module performs wavelet transform on the three-branch attention fusion features. The three-dimensional features are sequentially decomposed into eight-channel feature vectors, representing different frequency domain signals. The frequency-domain separated signal features are further processed by convolutional layers and encoded into key-value embeddings. These embeddings, together with the query embeddings calculated from the three-branch attention fusion features, are used to calculate self-attention. Finally, they are added to the overall inverse transform signal. Let... Features of three-branch attention fusion: DWT represents Discrete Wavelet Transform, and IDWT represents Inverse Discrete Wavelet Transform. Wave-MSA represents wavelet self-attention transform, which performs a projection transform on the three-branch attention fusion features to obtain the query q. f , key k f AND value vector v f Let d f B is the dimension of the input feature. f Encoding for relative positions: After filtering the frequency domain components using wavelet transform, the features after layer normalization (Norm) are input into the feedforward network FF and added to the original features: Step 5.3: The decoder effectively utilizes cross-attention to integrate multi-scale features from multiple branches and flexibly captures sparse multi-scale detail features through wavelet attention. The decoded features are gradually upsampled after being fused by three-branch cross-attention and filtered by spectral components, and then restored to the original resolution through the final convolutional layer. Step 6: Train the segmentation network constructed in Steps 2-5 using the loss function; Step 7: Test the trained segmentation network to generate the most stable segmentation result.

2. The Transformer diffusion segmentation method for MRI images of brain lesions based on symmetry prior as described in claim 1, characterized in that: The process of adding noise to the labeled image is as follows: For single-class lesion labels, noise enhancement is applied directly. For multi-class labels, one-hot encoding is used to convert the segmentation labels into multi-channel labels, and t-step noise ε is applied during the forward pass. t The image labeled with time step t is y. t Then the image x at time step t t The relationship can be represented as: Where ε t ~N(0,1), α t With β t α represents the noise figure, controlling the amount of noise added to the data points at each time step, and α t =1-β t q(·) represents the probability distribution. Represents a normal distribution, where I is the identity matrix; Depend on The derivation yields: Among them, y 1:T This represents the final state of diffusion and noise addition. T For the final time step; y0 represents the initial state of the diffusion and noise addition process. During training, it represents the labeled image, and during testing, it represents the noise image. ∈ represents the error term or random perturbation, which reflects the noise from one time point to another.

3. The Transformer diffusion segmentation method for brain lesion MRI images based on symmetry prior as described in claim 1, characterized in that: The denoising encoding process is performed by the denoising encoding module, which consists of a temporal encoding embedding module and four consecutive Transformer downsampling modules. In the downsampling module, the denoising encoding features are combined with the temporal encoding embedding step by step to fuse the information of the current time step. At the same time, the conditional encoder features that are downsampled step by step by the four Transformer layers are added and fused with the denoising encoder of the same resolution at the corresponding level, so that the denoising encoding features contain event information.

4. The Transformer diffusion segmentation method for brain lesion MRI images based on symmetry prior as described in claim 3, characterized in that: The denoising encoding process specifically includes the following sub-steps: Step 4.1: First, time-encoded embedding is performed on the time step. The time-encoded embedding concatenates the sine / cosine components of the time step information after exponential decay. The concatenated time feature embedding is then passed through a linear layer and a sigmoid layer to form the final time-encoded embedding t. emb ; Step 4.2, Patch embedding operation, adding noise to the labeled image x at time step t. t Fill in the blanks for x. t Perform linear projection on the time-coded embedding t generated in step 4.

1. emb Perform nonlinear transformation and linear projection and add to x t In this process, the summed vectors are subjected to a second projection transformation and then normalized. Step 4.3: Layer by layer, the four Transformer layers in the denoising coding module process the input features to generate denoised coded features. The four Transformer coded features in the denoising coding module are added to the conditional codes of the corresponding scale to supplement the denoised features with prior conditional information.

5. The Transformer diffusion segmentation method for MRI images of brain lesions based on symmetry prior as described in claim 1, characterized in that: The loss functions include the Dice loss function, the BCE loss function, and the MSE loss function. Let y0 be the labeled image. To predict the image, the final loss function is calculated as follows:

6. The Transformer diffusion segmentation method for MRI images of brain lesions based on symmetry prior as described in claim 1, characterized in that: Step 7: During the testing process, the noisy label image is replaced with a completely noisy image, and the implicit denoising diffusion model method is used to generate labels. The testing process is regarded as an inverse denoising process. Each iteration generates a segmentation result, and after multiple iterations, the most stable segmentation result is generated.

7. A Transformer diffusion segmentation system for MRI images of brain lesions based on symmetry priors, characterized in that, include: The processor and memory, wherein the memory is used to store program instructions, and the processor is used to call the stored instructions in the memory to execute the Transformer diffusion segmentation method for MRI images of brain lesions based on symmetry prior as described in any one of claims 1-6.

Citation Information

Patent Citations

  • Breast cancer image segmentation method and system based on parameter sharing and prior guidance

    CN117593313A

  • Medical image segmentation method based on dynamic multi-scale conditional diffusion model

    CN118247509A