MRI image segmentation method based on BGSPA-Unet

By using an MRI image segmentation method based on BGSPA-Unet, combined with the UNet model of SHC and BCGA modules, the problems of time-consuming and laborious traditional MRI image interpretation and noise interference are solved, achieving efficient and accurate segmentation of MRI fat infiltration regions.

CN120852344APending Publication Date: 2025-10-28GUILIN UNIV OF ELECTRONIC TECH
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202510959643.7
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-07-11
Publication Date
2025-10-28

AI Technical Summary

Technical Problem

Traditional MRI image interpretation is time-consuming and laborious, relies on doctors' experience, and existing deep learning models suffer from background noise interference in the segmentation of MRI fat infiltration areas, making it difficult to accurately capture edge and texture information.

Method used

An MRI image segmentation method based on BGSPA-Unet is adopted. Through dataset construction, preprocessing, data augmentation and model building, combined with the UNet model of SHC and BCGA modules, efficient segmentation of MRI images is achieved.

Benefits of technology

It effectively suppresses background noise interference, accurately captures edge and texture information in MRI images, improves the recognition accuracy of fat infiltration areas in MRI images, and simplifies the diagnostic process.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120852344A_ABST
    Figure CN120852344A_ABST
Patent Text Reader

Abstract

The invention discloses an MRI (Magnetic Resonance Imaging) image segmentation method based on BGSPA-Unet, which is characterized by comprising the following steps: 1) constructing a data set; the method comprises the steps of (1) data acquisition, (2) data preprocessing, (3) data enhancement, (4) model construction, (5) encoder construction and (6) decoder construction.By means of the method, interference of background noise can be effectively restrained, edge and texture information of an MRI image can be accurately captured, and the method is especially excellent in recognition of a fat infiltration area of the MRI image.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to image processing technology, specifically an MRI image segmentation method based on BGSPA-Unet. Background Technology

[0002] Lumbar disc herniation (LDH) is a common spinal disease. Studies have shown that multifidus fat infiltration in LDH patients is closely related to loss of spinal stability and worsening of low back pain. Early detection of multifidus fat infiltration is crucial for the diagnosis and treatment of LDH. The diagnosis of LDH mainly relies on physical examination and imaging examinations. Physical examination, through methods such as the straight leg raise test and femoral nerve traction test, initially assesses nerve root compression. These methods are simple but highly subjective, dependent on physician experience, and cannot quantify the details of the lesion, serving only as a preliminary screening method. Imaging examinations are the main diagnostic tools, including X-rays, CT scans, and MRI. X-rays are inexpensive but have insufficient resolution and are difficult to visualize soft tissues; CT can reconstruct three-dimensional images, but its soft tissue resolution is limited and it involves radiation; MRI, due to its high resolution and lack of radiation, has become the gold standard, clearly displaying details such as disc herniation, nerve root compression, and multifidus fat infiltration. However, traditional MRI interpretation is time-consuming and laborious, dependent on physician experience, and becomes inefficient with increasing numbers of patients requiring manual image interpretation. Deep learning methods have demonstrated high accuracy and efficiency in MRI fat infiltration region segmentation, simplifying the diagnostic process. Researching efficient and accurate deep learning models will provide reliable assistance for clinical practice. Summary of the Invention

[0003] The purpose of this invention is to address the shortcomings of existing technologies by providing an MRI image segmentation method based on BGSPA-Unet (Bidirectional-gate-Spatial-Atte, or BGSPA-Unet for short). This method effectively suppresses background noise interference and accurately captures edge and texture information in MRI images, especially excelling in the identification of fat infiltration regions in MRI images.

[0004] The technical solution to achieve the objective of this invention is:

[0005] An MRI image segmentation method based on BGSPA-Unet includes the following steps:

[0006] 1) Dataset Construction: Standard transverse lumbar MRI images were collected from the hospital. These images had clear structures and completely covered the multifidus muscle region. The LabelImg data annotation tool was used to read the dataset of 533 MRI images. After manual screening, images with obvious artifacts or lacking effective annotations were removed. The images were resampled into binary raster data. Each MRI image was manually bounded with polygons to generate a binary mask. The multifidus muscle target area label in the MRI image was used to indicate the location and boundary of the multifidus muscle; the unbound areas were used as background. The multifidus muscle target area in the MRI image was then transformed... The raster data corresponding to the multifidus muscle was replaced, and the style was resampled to binary raster data, that is, the pixel value of the multifidus muscle target area was 255, and the background area was set to 0. Each MRI image and its corresponding raster data were segmented and cropped according to the set size to obtain the original dataset. Finally, 300 samples suitable for training were retained. To make up for the lack of original data, various data augmentation techniques were used to expand the dataset, including size scaling, random rotation, random adjustment of gamma value with a 50% probability, and random adjustment of brightness. The expanded samples were divided into training set, validation set and test set in a ratio of 7:2:1.

[0007] 2) Data Preprocessing: The filtered images are normalized. First, the pixel values ​​are scaled to a specific range of 224x224. By selecting either max-min or mean-variance normalization, the statistics of the input image, i.e., maximum, minimum, mean, or standard deviation, are calculated. The calculation results are applied to process each pixel value. The NumPy functions numpy.min(), numpy.max(), numpy.mean(), and numpy.std() are used to calculate the statistics and perform pixel value normalization. Subsequently, to simulate MRI images in a noisy environment, high-resolution images are added to the MRI images. Gaussian noise is simulated in MRI images under noisy conditions. Specifically, random numbers that conform to a Gaussian distribution are generated using the NumPy function numpy.random.normal(), and these random values ​​are superimposed on each pixel value of the image. Finally, in order to enhance the image contrast and highlight key structures and abnormal areas, histogram equalization is used to adjust the pixel value distribution. This method redistributes gray values, mapping the gray range of the original image to a new, more uniform range, thereby making the gray histogram of the output image flatter. Histogram equalization is particularly suitable for global contrast enhancement, especially when the image is dark or lacks depth.

[0008] 3) Data Augmentation: Data augmentation methods for MRI images employ operations such as scaling, random rotation, random adjustment of gamma values ​​with a 50% probability, and random adjustment of brightness to expand the dataset and overcome data size limitations. Specifically:

[0009] Size scaling adjusts the image size to simulate the changes in MRI images at different distances or viewpoints, helping the model learn features at different scales. This scaling can change the size ratio of targets in the image, enabling the model to adapt to feature representation under various resolutions or imaging conditions. The cv2.resize function is used to adjust the image size to 224x224 to generate the adjusted image.

[0010] Random rotation simulates the slight rotation of a patient during an MRI scan by rotating the image by a random angle, increasing data diversity. This rotation can change the angular position of edge parts in the image, allowing the model to learn the characteristics of the target in different directions. The cv2.warpAffine() function of OpenCV is used to generate random rotation angles from -15° to 15° and the transformation is applied to the image.

[0011] Randomly adjusting the gamma value simulates MRI images under different exposure conditions by changing the brightness distribution of the image. This transformation is applied with a 50% probability to enhance the model's adaptability to brightness changes. This operation allows the model to better handle brightness changes caused by differences in imaging equipment or ambient lighting. Using NumPy and OpenCV, np.random.choice([True, False], p=[0.5, 0.5]) is used to determine whether to apply the transformation. If applied, a gamma value of 0.5 to 1.5 is randomly generated, and cv2.LUT() is used to adjust the image gamma value.

[0012] Random brightness adjustment simulates differences in scanning equipment or ambient lighting by adding or subtracting a random value from the pixel values ​​of the image, thus improving the robustness of the model. This adjustment can help the model adapt to possible brightness unevenness or noise interference in MRI images. A random brightness offset of -30 to 30 is generated using NumPy, and the image pixel values ​​are added to the offset using np.clip() and then limited to the range of 0 to 255 to generate the adjusted image.

[0013] Scaling, random rotation, and other operations generate more samples, effectively compensating for insufficient data volume. Randomly adjusting gamma values ​​and brightness simulates changes in real-world scenes, making the dataset more representative. Through the above data augmentation methods, the quality of MRI image datasets and model performance can be significantly improved, the risk of overfitting can be reduced, and it can adapt to various transformations. Targets in MRI images may exhibit changes in angle, brightness, or scale. Data augmentation helps the model better identify these features.

[0014] 4) Model Construction: The BGSPA-Unet model adopted in this technical solution is based on the UNet model. The UNet model is a deep learning architecture widely used in the field of image segmentation, especially suitable for handling high-precision tasks such as MRI medical image segmentation. With its unique U-shaped structure design, combined with encoder and decoder paths, UNet can effectively capture multi-scale features of images and achieve pixel-level segmentation. Its encoder gradually extracts deep semantic features of the image through convolution and pooling operations, compressing spatial information to capture global context; while the decoder fuses high-level features with low-level details through upsampling and skip connections, accurately restoring spatial resolution. This skip connection mechanism effectively alleviates the information loss problem in deep networks, ensuring that the segmentation results retain fine edge and texture information. SHC (Spatial Highlight Convolution) is introduced in the encoder and decoder parts. In SHC, Spatial Guided Convolution... Convolution is used as the core module, employing simplified geometric prior guidance to enhance the model's ability to perceive spatial structure. It integrates spatial information with image features, guiding attention to geometrically related regions, such as object edges, contours, or structural features. This mechanism significantly enhances the model's understanding of geometric information. Furthermore, the BCGA module is introduced in the skip connections, significantly improving the flexible perception of spatial features by introducing a bidirectional attention modeling path and a dynamic weight fusion mechanism. Compared to the traditional coordinate attention mechanism, BCGA not only enhances the model's stability in recognizing salient regions in complex image backgrounds but also further improves its adaptability. This design enables the model to process diverse spatial information more efficiently, thereby achieving comprehensive performance optimization.

[0015] 5) Encoder Construction: The traditional UNet encoder, also known as the shrinking path, extracts deep features from an image step-by-step through a series of convolutions and pooling operations. The process begins with multiple convolutional blocks, each containing two convolutional layers (typically 3x3). Each convolutional layer is followed by a ReLU activation function to introduce non-linearity. This is followed by 2x2 max-pooling layers with a stride of 2 to reduce the spatial size of the feature maps while increasing the number of channels to capture more abstract features. As the encoder depth increases, the feature map resolution gradually decreases while the number of channels gradually doubles, thereby extracting multi-scale semantic information and capturing the global context of the image. The feature maps from each stage are saved and fused with the decoder through skip connections, ultimately helping to restore spatial details and enabling UNet to perform well in segmentation tasks. This approach effectively combines high-level semantic information with low-level spatial details to achieve accurate pixel-level segmentation. Based on the traditional UET encoder, an SHC module is introduced. First, a 3x224x224 input image is processed through convolutional blocks to extract features. These convolutional blocks include BatchNorm, activation functions, and dropout operations. The output features after feature extraction are 3x224x224. BatchNorm stabilizes the distribution of the input data, effectively solving the vanishing and exploding gradient problems, thus accelerating model training. It also provides a slight regularization effect, helping to reduce the model's dependence on specific training samples and enhancing its generalization performance. Pooling operations gradually extract deeper features from the image, and ReLU... This non-linear capability is endowed to the network. Dropout, by randomly discarding a portion of neurons, effectively reduces the cooperative adaptation between neurons and lowers the risk of overfitting. Then, the network passes through the SHC module, which effectively reduces computational complexity through bottleneck convolution and gating mechanisms, while enhancing the model's ability to handle complex backgrounds and diverse image shapes. The output feature size is 64x224x224. Following this, a 2x2 max-pooling layer with a stride of 2 halves the spatial size of the feature map, while doubling the number of channels to capture more abstract features. As the encoder depth increases, the resolution of the feature map gradually decreases, while the number of channels gradually doubles. This allows for the extraction of multi-scale semantic information and the capture of the global context of the image. The encoding layer undergoes four convolution-SHC-downsampling steps, continuously extracting features from the feature map. The final feature outputs of each layer of the encoder are (64, 224, 224), (128, 112, 112), (256, 56, 56), and (512, 28, 224), respectively. 28) In this process, the feature maps generated at each stage are properly saved and passed to the decoder for fusion through skip connections. This mechanism ultimately helps the decoder recover the spatial details of the image, enabling UNet to effectively combine high-level semantic information with low-level spatial details in the segmentation task, thereby achieving accurate pixel-level segmentation.

[0016] 6) Decoder Construction: In the traditional UNet architecture, the decoder, also known as the extended path, starts from the lowest level of the encoder. It receives feature maps containing high-level semantic information but with low resolution, and gradually restores the spatial resolution of the feature maps by employing a series of upsampling and convolution operations, fusing low-level features from the encoder to achieve accurate pixel-level segmentation. Specifically, the decoder first uses upsampling operations (such as deconvolution or interpolation) to double the spatial size of the feature maps while reducing the number of channels to balance computational load. Then, it concatenates the feature maps of the corresponding levels in the encoder with the upsampled feature maps along the channel dimension through skip connections, fusing low-level spatial details and high-level semantic information. The input image is processed through multiple convolutional layers, including two 3x3 convolutional layers. Each convolution is followed by ReLU activation to fuse and optimize the concatenated feature map, generating a more refined feature representation. This process is repeated in each layer of the decoder. Finally, the last layer outputs a feature map with the same resolution as the original input image. Pixel-level segmentation predictions are then generated through 1x1 convolutions and the Softmax activation function. Skip connections are crucial in this process, directly passing feature maps from different levels of the encoder to the decoder. This compensates for the spatial information loss caused by pooling operations, ensuring that the model retains the details and edge information of the original image when recovering high-resolution feature maps, thereby improving segmentation accuracy. This is achieved in the improved UNet. In this architecture, the decoder, or extended path, gradually restores the spatial resolution of the feature map through a series of upsampling and convolution operations, and fuses low-level features from the encoder to achieve accurate pixel-level segmentation. The BCGA module added to the skip connections further optimizes this process. Specifically, the decoder first upsamples the feature map to double its spatial size while reducing the number of channels to lower computational complexity. The feature map from the encoder is then processed by the BCGA module. The BCGA module first employs dual-path coordinate attention modeling, extracting horizontal and vertical spatial features through average pooling and max pooling respectively, encoding them into position-sensitive attention maps. This significantly enhances the model's responsiveness to structural edges and salient regions. Next, the BCGA module utilizes a learnable gating fusion mechanism, adaptively adjusting the importance of the average pooling and max pooling branches through a lightweight gating structure, dynamically fusing the two types of attention information. This effectively mitigates the representation bias caused by fixed fusion methods and improves feature discriminability. Furthermore, the BCGA module introduces a channel recalibration mechanism, similar to SE. The module-based approach adjusts the response of the fused features to further enhance the representation of useful feature channels. Residual connections are used to stabilize the network training process and improve adaptability. The encoder feature map processed by the BCGA module is concatenated with the upsampled decoder feature map along the channel dimension, fusing low-level spatial details and high-level semantic information. This is then followed by multiple convolutional layers, specifically a 3x3 convolutional layer.Each convolution is followed by ReLU activation, and the SHC module optimizes the concatenated features to generate a more refined feature representation. This process is repeated in each layer of the decoder, ultimately outputting a feature map with the same resolution as the input image in the last layer. Pixel-level segmentation predictions are then generated through 1x1 convolutions and the Softmax activation function. By incorporating the BCGA module in the skip connections, the improved UNet better preserves and utilizes spatial details and semantic information from the encoder when recovering high-resolution feature maps, thus significantly improving segmentation accuracy, especially when handling complex backgrounds and fine structures.

[0017] The SHC module works as follows: First, the input feature map x0 is fed into two PBNC feature extraction blocks, block1 and block3, to obtain detailed texture features of x1, x2, x1, and x2 respectively. The PBNC feature extraction blocks consist of PPConv convolutions, BatchNorm, and ReLU activation functions. Since ordinary convolutions consume a large number of parameters, the PBNC module, considering a lightweight design, uses PPConv convolutions. PPConv convolutions combine 1x1 convolutions and 3x3 depthwise convolutions, significantly reducing the number of parameters. The 1x1 convolution reduces the number of input channels from C to C / 8 (e.g., 32 → 4), reducing computation. The 3x3 depthwise convolution uses grouped convolutions (groups = mid_channels) to extract local spatial features. Finally, the 1x1 convolution restores the number of channels to C (e.g., 4 → 1). 32. Feature fusion is performed, and the final normalization layer stabilizes the feature distribution. The activation function introduces non-linearity. Through a bottleneck structure, dimensionality reduction, extraction, and upscaling are used to efficiently extract low-level spatial features of the image, such as edges, textures, or local geometric structures. The obtained feature x1 is then input into PBNC (block 2) again to further improve the continuity and clarity of the extracted feature edges. X1 passes through two PBNC feature extraction blocks (block 1 and block 2) to extract low-level spatial features. The input feature map passes through block 3 to capture inter-channel semantic information. Further input x1 from the spatial features of block 2 is processed by SWM to generate an attention map highlighting circular edges, while the background region has lower weights. The shape is (1, 32, 64, 64). SWM contains two 3x3 convolutional layers with ReLU in between. The first convolution extracts spatial features, and ReLU... Introducing nonlinearity, a second convolution generates an attention map, which, after passing through SWM, generates a spatial attention map. This highlights key regions in the image (such as the geometric contours of multifidus muscles), guiding the network to focus on important features and suppressing irrelevant regions. Further, the input from low-level spatial features in block 2, the input x2 from semantic features in block 3, and the input S (spatial attention weights) are multiplied element-wise to fuse these three tensors, outputting a fused feature x with the shape (1, 32, 64, 64). This step integrates spatial features, semantic information, and attention weights, enhancing the modeling ability of key image regions. Through multiplication, the attention map amplifies the features of key regions and suppresses noise. The fused feature is then input into block 4, which, similar to block 3, uses a 1x1 convolution, including dimensionality reduction, dimensionality increase, normalization, and ReLU. The input fused feature x passes through block 4, outputting an optimized feature with the shape still (1, 32, 64).64) This step further refines and optimizes the fused features to make them more suitable for segmentation tasks. Since the fused features may contain redundant information, block 4 adjusts the relationships between channels using 1x1 convolutions, making the features more compact and meaningful. Finally, residual connections are used to add the original input x to the processed features, preserving the original feature information and ensuring that information is not lost due to deep processing. This stabilizes the training process and alleviates the vanishing gradient problem, as the original input contains subtle texture information that may be lost after multiple layers of processing. Residual connections add this information back to the output, maintaining feature integrity.

[0018] The BCGA module comprises the following steps: dual-path pooling (capturing spatial information), gated fusion (dynamically adjusting weights), channel attention (enhancing key channels), and residual connection (preserving original information). The input features are the features output by the encoder: (64, 224, 224), (128, 112, 112), (256, 56, 56), (512, 28, 28). Assume the input x is a shape of (1, 64, 224, 224). The tensor represents the feature map from the previous convolutional network layer. The input feature map contains spatial information of the image, namely the height and width directions, as well as channel information, namely the diversity of features. The goal of BCGA is to enhance these features through an attention mechanism, highlighting key regions and channels. The model extracts spatial features in the horizontal and vertical directions through two parallel paths: average pooling and max pooling, respectively. This step is the core and is divided into two sub-paths: First is the average pooling path, which includes horizontal pooling and vertical pooling. Horizontal pooling uses adaptive average pooling to compress the width dimension to 1, and the output shape is (B, C, H, 1), i.e., (1, 64, 224, 1). Vertical pooling compresses the height dimension to 1, outputting (1, 64, 1, 224), and then adjusts it to (1, 64, 224, 1) through .permute(0, 1, 3, 2). The horizontal and vertical features are then concatenated along the height dimension, outputting (1, 64, 448, 1) (224 + 224 = ...). 448), further using 1x1 convolution to reduce the number of channels from C(64) to mip (mip = max(8, C / / groups), assuming groups=64, then mip = max(8, 64 / / 64) = 8), output (1, 8, 512, 1), then after batch normalization of self.shared_b and activation of self.relu, the shape remains unchanged, next separation is performed, the tensor is divided into (1, 8, 224, 1) that is horizontal and (1, 8, 224, 1) that is vertical, the vertical part is then adjusted to (1, 8, 1, 224) through .permute(0,1, 3, 2), finally the channels are restored and attention is generated, the number of horizontal feature channels is restored to C(64), output (1, 64, 224, 1), the vertical features are restored to (1, 64, 1, 224), multiply using a broadcast mechanism to generate an attention map of attn_mean (1, 64, 224, 224), extract spatial features in the horizontal and vertical directions through average pooling to generate the attention map, enhancing the response to image structures (such as edges or continuous regions);

[0019] Secondly, there is the max pooling path, which is similar to the average pooling path, but uses max pooling. The pooling operation retains the maximum value rather than the average value. It concatenates, reduces dimensions, separates, and restores channels, and finally generates attn_max with the shape (1, 64, 224, 224). The max pooling path can capture salient features in the image (such as high response regions), supplement the information of average pooling, and improve the ability to perceive details.

[0020] Furthermore, a learnable gating fusion mechanism is used in parallel to process the input features. The gating module performs global average pooling on the original input, outputting (1, 64, 1, 1). Then, through dimensionality reduction (64 / / reduction, assuming reduction=8, then it becomes 8), activation, and dimensionality increase to two channels, the output is (1, 2, 1, 1). The two weights are normalized to obtain mean_weight ([1, 1, 1, 1]) and max_weight ([1, 1, 1, 1]). Finally, these are fused with attn_max and attn_mean respectively, outputting the attention weight attn (1, 64, 224, 224). The importance of the average pooling and max pooling paths is adaptively adjusted through learnable weights, dynamically fusing the two attention information to improve the discriminativeness of the features. The formula is as follows:

[0021] ,

[0022] in, Spatial attention map representing average pooling; Represents the learned weights, controlling Contributions; Represents the spatial attention map for max pooling; Represents the learned weights, controlling Contributions; Indicates fusion and Final spatial attention map;

[0023] The attention weights attn obtained after fusion are then applied to the original input to obtain the attention-applied output out (1, 64, 224, 224), as shown in the following formula:

[0024] ,

[0025] in, Indicates fusion and Final spatial attention map; This represents the input feature map, used for residual connections and generation of gated weights; This represents the output feature map after spatial and channel attention enhancement;

[0026] Finally, channel attention enhancement is employed. Through the channel attention mechanism, the response of each channel in the feature map is further adjusted, highlighting the feature channels that are more important to the task and suppressing the unimportant channels, thereby improving the specificity of the features. This is because different channels focus on different features, such as texture features or color information. Channel attention can enhance the channels that are relevant to the task. The channel attention module performs global pooling on the feature map, outputting (1, 64, 1, 1), reducing the dimensionality to (1, 8, 1, 1) (64 / / 8), and then increasing the dimensionality to (1, 64, 1, 1) after activation. The sigmoid output weights are used, and the output feature map is weighted by channel, with the shape still being out (1, 64, 224, 224). Furthermore, the original input features and the out processed by channel attention are residually connected to retain the original features, prevent information loss, and stabilize the training process.

[0027] By employing steps such as dual-path pooling (capturing spatial information), gated fusion (dynamically adjusting weights), channel attention (enhancing key channels), and residual connections (preserving original information), the spatial and channel dimensions of the feature map are optimized. This design adaptively focuses on key regions and channels in the image. For example, in medical image segmentation tasks, this module can more accurately identify lesion regions, improving model performance and diagnostic accuracy.

[0028] This method can effectively suppress background noise interference and accurately capture edge and texture information in MRI images, especially excelling in the identification of fat infiltration areas in MRI images. Attached Figure Description

[0029] Figure 1 This is a schematic diagram of the method flow in the embodiment;

[0030] Figure 2 This is a schematic diagram of the SHC structure in the embodiment;

[0031] Figure 3 This is a schematic diagram of the BCGA structure in the embodiment;

[0032] Figure 4 This is a schematic diagram of the segmentation results in the embodiment. Detailed Implementation

[0033] The present invention will be further described below with reference to the accompanying drawings and embodiments, but this is not intended to limit the scope of the invention.

[0034] Example:

[0035] Reference Figure 1An MRI image segmentation method based on BGSPA-Unet includes the following steps:

[0036] 1) Dataset Construction: Standard transverse lumbar MRI images were collected from the hospital. These images had clear structures and completely covered the multifidus muscle region. The LabelImg data annotation tool was used to read the dataset of 533 MRI images. After manual screening, images with obvious artifacts or lacking effective annotations were removed. The images were resampled into binary raster data. Each MRI image was manually bounded with polygons to generate a binary mask. The multifidus muscle target area label in the MRI image was used to indicate the location and boundary of the multifidus muscle; the unbound areas were used as background. The multifidus muscle target area in the MRI image was then transformed... The raster data corresponding to the multifidus muscle was replaced, and the style was resampled to binary raster data, that is, the pixel value of the multifidus muscle target area was 255, and the background area was set to 0. Each MRI image and its corresponding raster data were segmented and cropped according to the set size to obtain the original dataset. Finally, 300 samples suitable for training were retained. To make up for the lack of original data, various data augmentation techniques were used to expand the dataset, including size scaling, random rotation, random adjustment of gamma value with a 50% probability, and random adjustment of brightness. The expanded samples were divided into training set, validation set and test set in a ratio of 7:2:1.

[0037] 2) Data Preprocessing: The filtered images are normalized. First, the pixel values ​​are scaled to a specific range of 224x224. By selecting either max-min or mean-variance normalization, the statistics of the input image, i.e., maximum, minimum, mean, or standard deviation, are calculated. The calculation results are applied to process each pixel value. The NumPy functions numpy.min(), numpy.max(), numpy.mean(), and numpy.std() are used to calculate the statistics and perform pixel value normalization. Subsequently, to simulate MRI images in a noisy environment, high-resolution images are added to the MRI images. Gaussian noise is simulated in MRI images under noisy conditions. Specifically, random numbers that conform to a Gaussian distribution are generated using the NumPy function numpy.random.normal(), and these random values ​​are superimposed on each pixel value of the image. Finally, in order to enhance the image contrast and highlight key structures and abnormal areas, histogram equalization is used to adjust the pixel value distribution. This method redistributes gray values, mapping the gray range of the original image to a new, more uniform range, thereby making the gray histogram of the output image flatter. Histogram equalization is particularly suitable for global contrast enhancement, especially when the image is dark or lacks depth.

[0038] 3) Data Augmentation: Data augmentation methods for MRI images employ operations such as scaling, random rotation, random adjustment of gamma values ​​with a 50% probability, and random adjustment of brightness to expand the dataset and overcome data size limitations. Specifically:

[0039] Size scaling adjusts the image size to simulate the changes in MRI images at different distances or viewpoints, helping the model learn features at different scales. This scaling can change the size ratio of targets in the image, enabling the model to adapt to feature representation under various resolutions or imaging conditions. The cv2.resize function is used to adjust the image size to 224x224 to generate the adjusted image.

[0040] Random rotation simulates the slight rotation of a patient during an MRI scan by rotating the image by a random angle, increasing data diversity. This rotation can change the angular position of edge parts in the image, allowing the model to learn the characteristics of the target in different directions. The cv2.warpAffine() function of OpenCV is used to generate random rotation angles from -15° to 15° and the transformation is applied to the image.

[0041] Randomly adjusting the gamma value simulates MRI images under different exposure conditions by changing the brightness distribution of the image. This transformation is applied with a 50% probability to enhance the model's adaptability to brightness changes. This operation allows the model to better handle brightness changes caused by differences in imaging equipment or ambient lighting. Using NumPy and OpenCV, np.random.choice([True, False], p=[0.5, 0.5]) is used to determine whether to apply the transformation. If applied, a gamma value of 0.5 to 1.5 is randomly generated, and cv2.LUT() is used to adjust the image gamma value.

[0042] Random brightness adjustment simulates differences in scanning equipment or ambient lighting by adding or subtracting a random value from the pixel values ​​of the image, thus improving the robustness of the model. This adjustment can help the model adapt to possible brightness unevenness or noise interference in MRI images. A random brightness offset of -30 to 30 is generated using NumPy, and the image pixel values ​​are added to the offset using np.clip() and then limited to the range of 0 to 255 to generate the adjusted image.

[0043] Scaling, random rotation, and other operations generate more samples, effectively compensating for insufficient data volume. Randomly adjusting gamma values ​​and brightness simulates changes in real-world scenes, making the dataset more representative. Through the above data augmentation methods, the quality of MRI image datasets and model performance can be significantly improved, the risk of overfitting can be reduced, and it can adapt to various transformations. Targets in MRI images may exhibit changes in angle, brightness, or scale. Data augmentation helps the model better identify these features.

[0044] 4) Model Construction: The BGSPA-Unet model adopted is based on the UNet model. The UNet model is a deep learning architecture widely used in image segmentation, especially suitable for high-precision tasks such as MRI medical image segmentation. With its unique U-shaped structure design, combined with encoder and decoder paths, UNet can effectively capture multi-scale features of images and achieve pixel-level segmentation. Its encoder gradually extracts deep semantic features of the image through convolution and pooling operations, compressing spatial information to capture global context; while the decoder fuses high-level features with low-level details through upsampling and skip connections, accurately restoring spatial resolution. This skip connection mechanism effectively alleviates the information loss problem in deep networks, ensuring that the segmentation results retain fine edge and texture information. SHC (Spatial Highlight Convolution) is introduced in the encoder and decoder parts. In SHC, Spatial Guided Convolution... Convolution is used as the core module, employing simplified geometric prior guidance to enhance the model's ability to perceive spatial structure. It integrates spatial information with image features, guiding attention to geometrically related regions, such as object edges, contours, or structural features. This mechanism significantly enhances the model's understanding of geometric information. Furthermore, the BCGA module is introduced in the skip connections, significantly improving the flexible perception of spatial features by introducing a bidirectional attention modeling path and a dynamic weight fusion mechanism. Compared to the traditional coordinate attention mechanism, BCGA not only enhances the model's stability in recognizing salient regions in complex image backgrounds but also further improves its adaptability. This design enables the model to process diverse spatial information more efficiently, thereby achieving comprehensive performance optimization.

[0045] 5) Encoder Construction: The traditional UNet encoder, also known as the shrinking path, extracts deep features from an image step-by-step through a series of convolutions and pooling operations. The process begins with multiple convolutional blocks, each containing two convolutional layers (typically 3x3). Each convolutional layer is followed by a ReLU activation function to introduce non-linearity. This is followed by 2x2 max-pooling layers with a stride of 2 to reduce the spatial size of the feature maps while increasing the number of channels to capture more abstract features. As the encoder depth increases, the feature map resolution gradually decreases while the number of channels gradually doubles, thereby extracting multi-scale semantic information and capturing the global context of the image. The feature maps from each stage are saved and fused with the decoder through skip connections, ultimately helping to restore spatial details and enabling UNet to perform well in segmentation tasks. This approach effectively combines high-level semantic information with low-level spatial details to achieve accurate pixel-level segmentation. Based on the traditional UET encoder, an SHC module is introduced. First, a 3x224x224 input image is processed through convolutional blocks to extract features. These convolutional blocks include BatchNorm, activation functions, and dropout operations. The output features after feature extraction are 3x224x224. BatchNorm stabilizes the distribution of the input data, effectively solving the vanishing and exploding gradient problems, thus accelerating model training. It also provides a slight regularization effect, helping to reduce the model's dependence on specific training samples and enhancing its generalization performance. Pooling operations gradually extract deeper features from the image, and ReLU... This non-linear capability is endowed to the network. Dropout, by randomly discarding a portion of neurons, effectively reduces the cooperative adaptation between neurons and lowers the risk of overfitting. Then, the network passes through the SHC module, which effectively reduces computational complexity through bottleneck convolution and gating mechanisms, while enhancing the model's ability to handle complex backgrounds and diverse image shapes. The output feature size is 64x224x224. Following this, a 2x2 max-pooling layer with a stride of 2 halves the spatial size of the feature map, while doubling the number of channels to capture more abstract features. As the encoder depth increases, the resolution of the feature map gradually decreases, while the number of channels gradually doubles. This allows for the extraction of multi-scale semantic information and the capture of the global context of the image. The encoding layer undergoes four convolution-SHC-downsampling steps, continuously extracting features from the feature map. The final feature outputs of each layer of the encoder are (64, 224, 224), (128, 112, 112), (256, 56, 56), and (512, 28, 224), respectively. 28) In this process, the feature maps generated at each stage are properly saved and passed to the decoder for fusion through skip connections. This mechanism ultimately helps the decoder recover the spatial details of the image, enabling UNet to effectively combine high-level semantic information with low-level spatial details in the segmentation task, thereby achieving accurate pixel-level segmentation.

[0046] 6) Decoder Construction: In the traditional UNet architecture, the decoder, also known as the extended path, starts from the lowest level of the encoder. It receives feature maps containing high-level semantic information but with low resolution, and gradually restores the spatial resolution of the feature maps by employing a series of upsampling and convolution operations, fusing low-level features from the encoder to achieve accurate pixel-level segmentation. Specifically, the decoder first uses upsampling operations (such as deconvolution or interpolation) to double the spatial size of the feature maps while reducing the number of channels to balance computational load. Then, it concatenates the feature maps of the corresponding levels in the encoder with the upsampled feature maps along the channel dimension through skip connections, fusing low-level spatial details and high-level semantic information. The input image is processed through multiple convolutional layers, including two 3x3 convolutional layers. Each convolution is followed by ReLU activation to fuse and optimize the concatenated feature map, generating a more refined feature representation. This process is repeated in each layer of the decoder. Finally, the last layer outputs a feature map with the same resolution as the original input image. Pixel-level segmentation predictions are then generated through 1x1 convolutions and the Softmax activation function. Skip connections are crucial in this process, directly passing feature maps from different levels of the encoder to the decoder. This compensates for the spatial information loss caused by pooling operations, ensuring that the model retains the details and edge information of the original image when recovering high-resolution feature maps, thereby improving segmentation accuracy. This is achieved in the improved UNet. In this architecture, the decoder, or extended path, gradually restores the spatial resolution of the feature map through a series of upsampling and convolution operations, and fuses low-level features from the encoder to achieve accurate pixel-level segmentation. The BCGA module added to the skip connections further optimizes this process. Specifically, the decoder first upsamples the feature map to double its spatial size while reducing the number of channels to lower computational complexity. The feature map from the encoder is then processed by the BCGA module. The BCGA module first employs dual-path coordinate attention modeling, extracting horizontal and vertical spatial features through average pooling and max pooling respectively, encoding them into position-sensitive attention maps. This significantly enhances the model's responsiveness to structural edges and salient regions. Next, the BCGA module utilizes a learnable gating fusion mechanism, adaptively adjusting the importance of the average pooling and max pooling branches through a lightweight gating structure, dynamically fusing the two types of attention information. This effectively mitigates the representation bias caused by fixed fusion methods and improves feature discriminability. Furthermore, the BCGA module introduces a channel recalibration mechanism, similar to SE. The module-based approach adjusts the response of the fused features to further enhance the representation of useful feature channels. Residual connections are used to stabilize the network training process and improve adaptability. The encoder feature map processed by the BCGA module is concatenated with the upsampled decoder feature map along the channel dimension, fusing low-level spatial details and high-level semantic information. This is then followed by multiple convolutional layers, specifically a 3x3 convolutional layer.Each convolution is followed by ReLU activation, and the SHC module optimizes the concatenated features to generate a more refined feature representation. This process is repeated in each layer of the decoder, ultimately outputting a feature map with the same resolution as the input image in the last layer. Pixel-level segmentation predictions are then generated through 1x1 convolutions and the Softmax activation function. By incorporating the BCGA module in the skip connections, the improved UNet better preserves and utilizes spatial details and semantic information from the encoder when recovering high-resolution feature maps, thus significantly improving segmentation accuracy, especially when handling complex backgrounds and fine structures.

[0047] like Figure 2As shown, the SHC module works as follows: First, the input feature map x0 is fed into two PBNC feature extraction blocks, block1 and block3, respectively, to obtain detailed texture features of x1, x2, x1, and x2. The PBNC feature extraction blocks consist of PPConv convolution, BatchNorm, and ReLU activation functions. Since ordinary convolutions consume a large number of parameters, the PBNC module, considering a lightweight design, uses PPConv convolution. PPConv convolution is a combination of 1x1 convolution and 3x3 depthwise convolution, which significantly reduces the number of parameters. The 1x1 convolution reduces the number of input channels from C to C / 8 (e.g., 32 → 4), reducing computation. The 3x3 depthwise convolution uses grouped convolution (groups = mid_channels) to extract local spatial features. Finally, the 1x1 convolution restores the number of channels to C (e.g., 4 → 1). 32. Feature fusion is performed, and the final normalization layer stabilizes the feature distribution. The activation function introduces non-linearity. Through a bottleneck structure, dimensionality reduction, extraction, and upscaling are used to efficiently extract low-level spatial features of the image, such as edges, textures, or local geometric structures. The obtained feature x1 is then input into PBNC (block 2) again to further improve the continuity and clarity of the extracted feature edges. X1 passes through two PBNC feature extraction blocks (block 1 and block 2) to extract low-level spatial features. The input feature map passes through block 3 to capture inter-channel semantic information. Further input x1 from the spatial features of block 2 is processed by SWM to generate an attention map highlighting circular edges, while the background region has lower weights. The shape is (1, 32, 64, 64). SWM contains two 3x3 convolutional layers with ReLU in between. The first convolution extracts spatial features, and ReLU... Introducing nonlinearity, a second convolution generates an attention map, which, after passing through SWM, generates a spatial attention map. This highlights key regions in the image (such as the geometric contours of multifidus muscles), guiding the network to focus on important features and suppressing irrelevant regions. Further, the input from low-level spatial features in block 2, the input x2 from semantic features in block 3, and the input S (spatial attention weights) are multiplied element-wise to fuse these three tensors, outputting a fused feature x with the shape (1, 32, 64, 64). This step integrates spatial features, semantic information, and attention weights, enhancing the modeling ability of key image regions. Through multiplication, the attention map amplifies the features of key regions and suppresses noise. The fused feature is then input into block 4, which, similar to block 3, uses a 1x1 convolution, including dimensionality reduction, dimensionality increase, normalization, and ReLU. The input fused feature x passes through block 4, outputting an optimized feature with the shape still (1, 32, 64).64) This step further refines and optimizes the fused features to make them more suitable for segmentation tasks. Since the fused features may contain redundant information, block 4 adjusts the relationships between channels using 1x1 convolutions, making the features more compact and meaningful. Finally, residual connections are used to add the original input x to the processed features, preserving the original feature information and ensuring that information is not lost due to deep processing. This stabilizes the training process and alleviates the vanishing gradient problem, as the original input contains subtle texture information that may be lost after multiple layers of processing. Residual connections add this information back to the output, maintaining feature integrity.

[0048] like Figure 3As shown, the BCGA module includes the following steps: dual-path pooling (capturing spatial information), gated fusion (dynamically adjusting weights), channel attention (enhancing key channels), and residual connection (preserving original information). The input features are the features output by the encoder: (64, 224, 224), (128, 112, 112), (256, 56, 56), (512, 28, 28). Assume the input x is a shape of (1, 64, 224, 224). The tensor represents the feature map from the previous convolutional network layer. The input feature map contains spatial information of the image, namely the height and width directions, as well as channel information, i.e., feature diversity. The goal of BCGA is to enhance these features through an attention mechanism, highlighting key regions and channels. The model extracts spatial features in the horizontal and vertical directions through two parallel paths: average pooling and max pooling, respectively. This step is the core and is divided into two sub-paths: First is the average pooling path, which includes horizontal pooling and vertical pooling. Horizontal pooling uses adaptive average pooling, compressing the width dimension to 1, and the output shape is (B, C, H, 1), i.e., (1, 64, 224, 1). Vertical pooling compresses the height dimension to 1, outputting (1, 64, 1, 224), and then adjusts it to (1, 64, 224, 1) using .permute(0, 1, 3, 2). The horizontal and vertical features are then concatenated along the height dimension, outputting (1, 64, 448, 1) (224 + 224 = ...). 448), further using 1x1 convolution to reduce the number of channels from C(64) to mip (mip = max(8, C / / groups), assuming groups=64, then mip = max(8, 64 / / 64) = 8), output (1, 8, 512, 1), then after batch normalization self.shared_b and activation self.relu, the shape remains unchanged, next separation is performed, the tensor is divided into (1, 8, 224, 1) that is horizontal and (1, 8, 224, 1) that is vertical, the vertical part is then adjusted to (1, 8, 1, 224) through .permute(0, 1, 3, 2), finally the channels are restored and attention is generated, the number of horizontal feature channels is restored to C(64), output (1, 64, 224, 1), the vertical features are restored to (1, 64, 1, 224), multiply using a broadcast mechanism to generate an attention map of attn_mean (1, 64, 224, 224), extract spatial features in the horizontal and vertical directions through average pooling to generate the attention map, enhancing the response to image structures (such as edges or continuous regions);

[0049] Secondly, there is the max pooling path, which is similar to the average pooling path, but uses max pooling. The pooling operation retains the maximum value rather than the average value. It concatenates, reduces dimensions, separates, and restores channels, and finally generates attn_max with the shape (1, 64, 224, 224). The max pooling path can capture salient features in the image (such as high response regions), supplement the information of average pooling, and improve the ability to perceive details.

[0050] Furthermore, a learnable gating fusion mechanism is used in parallel to process the input features. The gating module performs global average pooling on the original input, outputting (1, 64, 1, 1). Then, through dimensionality reduction (64 / / reduction, assuming reduction=8, then it becomes 8), activation, and dimensionality increase to two channels, the output is (1, 2, 1, 1). The two weights are normalized to obtain mean_weight ([1, 1, 1, 1]) and max_weight ([1, 1, 1, 1]). Finally, these are fused with attn_max and attn_mean respectively, outputting the attention weight attn (1, 64, 224, 224). The importance of the average pooling and max pooling paths is adaptively adjusted through learnable weights, dynamically fusing the two attention information to improve the discriminativeness of the features. The formula is as follows:

[0051] ,

[0052] in, Spatial attention map representing average pooling; Represents the learned weights, controlling Contributions; Represents the spatial attention map for max pooling; Represents the learned weights, controlling Contributions; Indicates fusion and Final spatial attention map;

[0053] The attention weights attn obtained after fusion are then applied to the original input to obtain the attention-applied output out (1, 64, 224, 224), as shown in the following formula:

[0054] ,

[0055] in, Indicates fusion and Final spatial attention map; This represents the input feature map, used for residual connections and generation of gated weights; This represents the output feature map after spatial and channel attention enhancement;

[0056] Finally, channel attention enhancement is employed. Through the channel attention mechanism, the response of each channel in the feature map is further adjusted, highlighting the feature channels that are more important to the task and suppressing the unimportant channels, thereby improving the specificity of the features. This is because different channels focus on different features, such as texture features or color information. Channel attention can enhance the channels that are relevant to the task. The channel attention module performs global pooling on the feature map, outputting (1, 64, 1, 1), reducing the dimensionality to (1, 8, 1, 1) (64 / / 8), and then increasing the dimensionality to (1, 64, 1, 1) after activation. The sigmoid output weights are used, and the output feature map is weighted by channel, with the shape still being out (1, 64, 224, 224). Furthermore, the original input features and the out processed by channel attention are residually connected to retain the original features, prevent information loss, and stabilize the training process.

[0057] Training and Testing:

[0058] This experiment was conducted on an Ubuntu 22.04.4 LTS operating system platform. The hardware configuration included an AMD EPYC9124 sixteen-core processor, 64GB of RAM, and an NVIDIA GeForce RTX 4090 graphics card. For the software environment, Python 3.8.20 was used as the development language, and PyTorch 1.13.1 was used as the deep learning framework, with GPU acceleration achieved through CUDA 11.7. In terms of model training, the number of training epochs was set to 100, using the Adam optimizer. The initial learning rate was set to 1e-4, and the learning rate was automatically and dynamically adjusted during training. When the validation set loss did not decrease for three consecutive epochs, the learning rate was automatically reduced to 0.5 times its original value. Early stopping and model saving mechanisms were employed during training to avoid overfitting and ensure the preservation of the optimal model. The batch size was set to 8, and the loss functions used were Binary Cross-Entropy and Dice. The weighted combination of Loss values, with both weights set to 1, was used. During training, validation set performance was continuously monitored, and the model parameters with the lowest validation loss and the highest Dice coefficient were saved to ensure optimal final model performance. In the performance evaluation stage of the final model on the fat infiltration region segmentation task of multifidus MRI images, this example uses three metrics for evaluation and comparison: Dice similarity coefficient (DSC), Jaccard similarity coefficient (JAC), and Hausdorff distance (HD). All experiments were validated through multiple independent experiments to ensure the reliability and consistency of the results. When evaluating the segmentation performance of different models, this example introduces multiple metrics to comprehensively measure model performance. These metrics include the Dice coefficient, Jaccard index (also known as the similarity coefficient or intersection-over-union ratio IoU), and Hausdorff distance (HD). Each metric analyzes the degree of agreement between the predicted results and the ground truth labels from a unique perspective. The Dice coefficient reflects the similarity between the predicted segmented region and the actual labeled region by quantifying the degree of overlap, and its value ranges from 0 to 1. Between 0 and 1, the closer the value is to 1, the closer the model's segmentation result is to the real situation; the Jaccard index (IoU) assesses the overlap between samples by calculating the ratio of the overlapping region to the overall region, and its value is also between 0 and 1, with a larger value indicating a more significant overlap; while the Hausdorff distance (HD) judges the accuracy of segmentation by measuring the maximum distance between the ground truth boundary and the predicted segmentation boundary. This indicator is particularly sensitive to the accuracy of the boundary, with a smaller value indicating a smaller deviation between the segmentation boundary and the ground truth boundary. These indicators are calculated in different ways, but they collectively provide a comprehensive and scientific evaluation framework to objectively measure the model's performance in segmentation tasks. The specific calculation methods for these evaluation indicators are as follows:

[0059] The calculation formula is as follows:

[0060]

[0061] The calculation formula is as follows:

[0062]

[0063] The calculation formula is as follows:

[0064]

[0065]

[0066]

[0067] in To predict the pixel set for segmentation, This is the pixel set of the Ground Truth.

[0068] Experimental results:

[0069] This example verifies the segmentation effect in the experiment as follows: Figure 4 As shown in Table 1, the experimental results provide detailed quantitative data for DSC, JAC, and HD metrics, and compare and analyze the FCN and U-Net models. Compared with FCN, the proposed method improves the DSC accuracy from 70.1% to 78.4%, an increase of 8.3 percentage points, and the JAC accuracy from 59.3% to 66.3%, an increase of 7 percentage points. In terms of HD, it decreases from 4.149 to 3.851, a reduction of 0.298 mm. Compared with U-Net, the proposed method improves DSC by 3.7 percentage points and JAC by 2.1 percentage points, while reducing the HD value by 0.246 mm. The experimental data show that the proposed method surpasses conventional methods in accuracy. Compared with other existing segmentation algorithms, the proposed method exhibits superior semantic segmentation capabilities in object edge detail regions, especially achieving significant improvements in evaluation metrics such as DSC and JAC.

[0070] Table 1 model DSC / % JAC / % HD / mm FCN 70.1 59.3 4.149 U-Net 73.8 64.2 4.097 BGSPA-Unet 78.4 66.3 3.851

[0071] .

Claims

1. An MRI image segmentation method based on BGSPA-Unet, characterized in that, The steps include: 1) Dataset Construction: Standard transverse lumbar MRI images were collected from hospitals. These images have clear structures and completely cover the multifidus muscle region. The LabelImg data annotation tool was used to read 533 MRI images. After manual screening, images with obvious artifacts or lacking effective annotations were removed. The images were resampled into binary raster data. Each MRI image was manually bounded with polygons to generate a binary mask. The multifidus muscle target area label in the MRI image was used to indicate the location and boundary of the multifidus muscle; the unbound areas were used as background. The multifidus muscle target areas in the MRI images were converted into corresponding multifidus muscle raster data and resampled into binary raster data, i.e., the multifidus muscle target area pixel value was 255, and the background area was set to 0. Each MRI image and its corresponding raster data were segmented and cropped according to a set size to obtain the original dataset. Finally, 300 samples suitable for training were retained. The dataset was expanded using various data augmentation techniques, including size scaling, random rotation, random adjustment of gamma values ​​with a 50% probability, and random adjustment of brightness. The expanded samples were divided into training, validation, and test sets in a 7:2:1 ratio. 2) Data Preprocessing: The filtered images are normalized. First, the pixel values ​​are scaled to a specific range of 224x224. By selecting the maximum-minimum normalization or mean-variance normalization method, the statistics of the input image, namely the maximum value, minimum value, mean, or standard deviation, are calculated. The calculation results are applied to process each pixel value. The NumPy functions numpy.min(), numpy.max(), numpy.mean(), and numpy.std() are used to calculate the statistics and perform pixel value normalization. Subsequently, in order to simulate MRI images under noisy conditions, Gaussian noise is added to the MRI images. Specifically, random numbers conforming to a Gaussian distribution are generated using the NumPy function numpy.random.normal(), and these random values ​​are superimposed on each pixel value of the image. Finally, the pixel value distribution is adjusted by histogram equalization. 3) Data Augmentation: For MRI images, data augmentation methods include scaling, random rotation, random adjustment of gamma values ​​with a 50% probability, and random adjustment of brightness. The specific operations are as follows: Size scaling is achieved by adjusting the image size to simulate the changes in MRI images at different distances or viewpoints. The cv2.resize function is used to resize the image to 224x224 to generate the adjusted image. Random rotation is achieved by rotating the image by a random angle using OpenCV's cv2.warpAffine() function, generating random rotation angles from -15° to 15°, and then applying the transformation to the image. Randomly adjusting the gamma value simulates MRI images under different exposure conditions by changing the brightness distribution of the image. This transformation is applied with a 50% probability. NumPy and OpenCV are used. The method np.random.choice([True, False], p=[0.5,0.5]) is used to determine whether to apply the transformation. If applied, a gamma value of 0.5 to 1.5 is randomly generated and the image gamma value is adjusted using cv2.LUT(). Random brightness adjustment simulates differences in scanning equipment or ambient lighting by adding or subtracting a random value from the pixel values ​​of the image. NumPy is used to generate random brightness offsets from -30 to 30, and np.clip() is used to add the image pixel values ​​to the offsets and limit them to the range of 0 to 255 to generate the adjusted image. 4) Model Construction: The BGSPA-Unet model adopted is based on the UNet model. The UNet model is a deep learning architecture widely used in the field of image segmentation. UNet's unique U-shaped structure design, combined with the encoder and decoder paths, captures multi-scale features of the image and achieves pixel-level segmentation. Its encoder gradually extracts deep semantic features of the image through convolution and pooling operations, compressing spatial information to capture global context; while the decoder fuses high-level features with low-level details through upsampling and skip connections to accurately restore spatial resolution. SHC (Spatial Highlight Convolution) is introduced in the encoder and decoder parts. In SHC, Spatial Guided Convolution is used as the core module, which adopts simplified geometric prior guidance to improve the model's ability to perceive spatial structure. The BCGA module is introduced in the skip connections. 5) Encoder Construction: The traditional UNet encoder, also known as the shrinking path, extracts deep features from an image step-by-step through a series of convolutions and pooling operations. This process begins with multiple convolutional blocks, each containing two convolutional layers (typically 3x3). Each convolutional layer is followed by a ReLU activation function to introduce non-linearity, followed by a 2x2 max-pooling layer with a stride of 2. Feature maps from each stage are saved and fused with the decoder via skip connections, ultimately helping to recover spatial details. This allows UNet to effectively combine high-level semantic information with low-level spatial details in segmentation tasks, achieving accurate pixel-level segmentation. Based on the traditional UNet encoder, an SHC module is introduced. The input image is initially a 3x224x224 image, which is processed through convolutional blocks to extract features. These blocks include BatchNorm, activation functions, and dropout operations. After feature extraction, the output features are 3x224x224. BatchNorm stabilizes the distribution of the input data. Dropout randomly discards a portion of neurons, then passes through the SHC module, outputting a feature map of 64x224x224. This is followed by a 2x2 max-pooling layer with a stride of 2, which halves the spatial size of the feature map while doubling the number of channels. The encoding layer undergoes four convolution-SHC-downsampling steps, continuously extracting features from the feature map. The final feature outputs for each layer of the encoder are (64, 224, 224), (128, 112, 112), (256, 56, 56), and (512, 28, 28). Throughout this process, the feature maps generated at each stage are carefully preserved and passed to the decoder for fusion via skip connections. 6) Decoder Construction: In the traditional UNet architecture, the decoder, also known as the extended path, starts from the lowest level of the encoder, receiving feature maps containing high-level semantic information but with low resolution. It uses a series of upsampling and convolutional operations to gradually restore the spatial resolution of the feature maps and fuse low-level features from the encoder. Specifically, the decoder first uses upsampling to double the spatial size of the feature maps while reducing the number of channels. Then, through skip connections, it concatenates the corresponding level feature maps from the encoder with the upsampled feature maps along the channel dimension, fusing low-level spatial details and high-level semantic information. After multiple convolutional layers, including two 3x3 convolutional layers, each followed by ReLU activation, the concatenated feature maps are fused and optimized to generate a more refined feature representation. This process is repeated in each layer of the decoder. Finally, the last layer outputs a feature map with the same resolution as the original input image, and pixel-level segmentation predictions are generated through 1x1 convolutions and the Softmax activation function. Skip connections directly pass feature maps from different levels of the encoder to the decoder, compensating for the spatial information loss caused by pooling operations. In the improved UNet... In this structure, the decoder, or extended path, gradually restores the spatial resolution of the feature map through a series of upsampling and convolution operations, and fuses low-level features from the encoder to achieve accurate pixel-level segmentation. The BCGA module added to the skip connections works as follows: the decoder first upsamples the feature map to double its spatial size while reducing the number of channels to lower computational complexity. Then, the feature map from the encoder is processed by the BCGA module. The BCGA module first uses dual-path coordinate attention modeling, extracting horizontal and vertical spatial features through average pooling and max pooling respectively, encoding them into position-sensitive attention maps. Next, the BCGA module utilizes a learnable gating fusion mechanism, adaptively adjusting the importance of the average pooling and max pooling branches through a lightweight gating structure, dynamically fusing the two types of attention information. Furthermore, the BCGA module introduces a channel recalibration mechanism, similar to the SE module, to adjust the response of the fused features. The encoder feature map after module processing and the decoder feature map after upsampling are concatenated along the channel dimension to fuse low-level spatial details and high-level semantic information. Then, multiple convolutional layers, namely a 3x3 convolutional layer, are passed through each convolution followed by ReLU activation, and the SHC module optimizes the concatenated features to generate a more refined feature representation. This process is repeated in each layer of the decoder. Finally, the last layer outputs a feature map with the same resolution as the input image, and pixel-level segmentation prediction is generated through 1x1 convolution and the Softmax activation function.

2. The MRI image segmentation method based on BGSPA-Unet according to claim 1, characterized in that, The SHC module works as follows: First, the input feature map x0 is fed into two PBNC feature extraction blocks, block1 and block3, respectively, to obtain detailed texture features of x1, x2, x1, and x2. The PBNC feature extraction blocks consist of PPConv convolutions, BatchNorm, and ReLU activation functions. The PBNC module uses PPConv convolutions, which are a combination of 1x1 and 3x3 depthwise convolutions, significantly reducing the number of parameters. The 1x1 convolution reduces the number of input channels from C to C / 8 (e.g., 32 → 4), reducing computation. The 3x3 depthwise convolution uses grouped convolutions (groups = mid_channels) to extract local spatial features. Finally, the 1x1 convolution restores the number of channels to C (e.g., 4 → 1).

32. Feature fusion: The final normalization layer stabilizes the feature distribution. The activation function introduces non-linearity. Through a bottleneck structure, dimensionality reduction, extraction, and upscaling are used to extract low-level spatial features of the image, such as edges, textures, or local geometric structures. The obtained feature x1 is then input into PBNC (block 2) to extract the continuity and sharpness of feature edges. X1 passes through two PBNC feature extraction blocks (block 1 and block 2) to extract low-level spatial features. The input feature map passes through block 3 to capture inter-channel semantic information. The spatial features of x1 from block 2 are then processed by SWM to generate an attention map highlighting circular edges, while the background region has lower weights. The shape is (1, 32, 64, 64). SWM contains two 3x3 convolutional layers with ReLU in between. The first convolution extracts spatial features, and ReLU introduces non-linearity. The second convolution generates an attention map. The input low-level spatial features from block 2, the semantic features from block 3, and the spatial attention weights S are then fused element-wise to output the fused feature x, with the shape (1, 32, 64, 64). The input features are 32, 64, 64), and then the fused features are input into block4. Similar to block3, 1x1 convolution is used, which includes dimensionality reduction, dimensionality increase, normalization and ReLU. The input fused features x are processed by block4, and the output optimized features are output. The shape is still (1, 32, 64, 64). Finally, residual connection is performed to add the original input x to the processed features, and the original feature information is preserved.

3. The MRI image segmentation method based on BGSPA-Unet according to claim 1, characterized in that, The BCGA module consists of two-path pooling, gated fusion, channel attention (enhancing key channels), and residual connection steps. The input features are the features output by the encoder: (64, 224, 224), (128, 112, 112), (256, 56, 56), (512, 28, 28). Assuming the input x is a tensor of shape (1, 64, 224, 224), representing the feature map from the previous convolutional network, the input feature map contains spatial information (height and width) and channel information (feature diversity). The model extracts spatial features in the horizontal and vertical directions through two parallel paths: average pooling and max pooling. This is divided into two sub-paths: the first is the average pooling path, which includes horizontal and vertical pooling. The horizontal pooling uses adaptive average pooling to compress the width dimension to 1, resulting in an output shape of (B, C, H, 1), i.e., (1, 64, 224, 224). Vertical pooling compresses the height dimension to 1, outputting (1, 64, 1, 224). Then, it is adjusted to (1, 64, 224, 1) using .permute(0, 1, 3, 2). The horizontal and vertical features are concatenated along the height dimension, outputting (1, 64, 448, 1) (224 + 224 = 448). A 1x1 convolution is used to reduce the number of channels from C(64) to mip (mip = max(8, C / / groups), assuming groups = 64, then mip = max(8, 64 / / 64) = 8), outputting (1, 8, 512, 1). After batch normalization of self.shared_b and activation of self.relu, the shape remains unchanged. Next, the tensor is split into (1, 8, 224, 1), i.e., the horizontal and vertical features are (1, 8, 224, 1). 1) That is, vertical. The vertical part is then adjusted to (1, 8, 1, 224) using .permute(0, 1, 3, 2). Finally, the channels are restored and attention is generated. The number of horizontal feature channels is restored to C (64), and the output is (1, 64, 224, 1). The vertical features are restored to (1, 64, 1, 224). The broadcast mechanism is used to multiply them and generate an attention map of attn_mean (1, 64, 224, 224). The second approach is the max pooling path, which is similar to the average pooling path but uses max pooling. The pooling operation retains the maximum value instead of the average value. The process involves concatenation, dimensionality reduction, separation, and channel recovery to finally generate attn_max, which has the shape (1, 64, 224, 224). Furthermore, a learnable gating fusion mechanism is used in parallel to process the input features. The gating module performs global average pooling on the original input, outputting (1, 64, 1, 1). Then, through dimensionality reduction, activation, and dimensionality increase, it is reduced to two channels, outputting (1, 2, 1, 1). The two weights are normalized to obtain mean_weight ([1, 1, 1, 1]) and max_weight ([1, 1, 1, 1]). Finally, these are fused with attn_max and attn_mean respectively, outputting the attention weight attn (1, 64, 224, 224), as shown in the following formula: , in, Spatial attention map representing average pooling; Represents the learned weights, controlling Contributions; Represents the spatial attention map for max pooling; Represents the learned weights, controlling Contributions; Indicates fusion and Final spatial attention map; The attention weights attn obtained after fusion are then applied to the original input to obtain the attention-applied output out (1, 64, 224, 224), as shown in the following formula: , in, Indicates fusion and Final spatial attention map; This represents the input feature map, used for residual connections and generation of gated weights; This represents the output feature map after spatial and channel attention enhancement; Finally, channel attention enhancement is employed. Through the channel attention mechanism, the response of each channel of the feature map is further adjusted to highlight the feature channels that are more important to the task. The channel attention module performs global pooling on the feature map, outputting (1, 64, 1, 1), which is reduced to (1, 8, 1, 1) (64 / / 8). After activation, it is increased to (1, 64, 1, 1). The sigmoid output weights are used to weight the output feature map by channel, and the shape is still out (1, 64, 224, 224). Furthermore, the original input features and the out processed by channel attention are residually connected to retain the original features.