A subarachnoid hemorrhage lesion segmentation method based on UDT

By introducing single- and multi-scale variable attention modules and cross-variable skip connection modules into the Res-U-Net model, the problem of low segmentation accuracy of subarachnoid hemorrhage lesions in the existing technology is solved and a higher accuracy is achieved. Segmentation accuracy and fine-grained segmentation effect.

CN115131312BActive Publication Date: 2024-10-29HUAZHONG NORMAL UNIV
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202210742303.5
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-06-27
Publication Date
2024-10-29
Estimated Expiration
2042-06-27

AI Technical Summary

Technical Problem

It is difficult to accurately segment subarachnoid hemorrhage lesions with existing technology, especially the low segmentation accuracy due to its diffuse type and morphological diversity.

Method used

Single-scale, multi-scale variable attention modules and cross-variable attention-based skip connection modules are introduced into the Res-U-Net model to enhance the model's ability to express the characteristics of SAH lesion data and improve segmentation accuracy.

Benefits of technology

It significantly improves the segmentation accuracy of subarachnoid hemorrhage lesions, enables more precise extraction and segmentation of diffuse lesions, and improves the model's ability to identify small lesions and lesion edges.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115131312B_ABST
    Figure CN115131312B_ABST
Patent Text Reader

Abstract

The present invention discloses a subarachnoid hemorrhage lesion segmentation method based on UDT, wherein the method is improved on the basis of the Res‑U‑Net model and applied to the subarachnoid hemorrhage lesion segmentation task. In view of the data characteristics that most subarachnoid hemorrhage lesions are diffusely distributed and have various shapes, a single-scale variable attention module is introduced into the encoder to achieve accurate expression of the data characteristics of subarachnoid hemorrhage lesions. On the basis of the single-scale variable attention module, a multi-scale variable attention module is designed and introduced into the encoder, which can fuse the different scale features output by each encoding layer, so that the model can extract more robust data features. In addition, in order to further fuse the position information of the encoding layer and the semantic information of the decoding layer, a cross-variable attention module is introduced into the structure, so that the model can more accurately segment some fine-grained structures of subarachnoid hemorrhage lesions, such as: micro-lesions, lesion areas, etc.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention belongs to the technical field of medical image processing, and specifically relates to a UDT-based subarachnoid hemorrhage lesion segmentation algorithm, which can be migrated and applied to lesion segmentation tasks in other types of medical images. Background Art

[0002] Subarachnoid hemorrhage (SAH) refers to a clinical syndrome caused by rupture of diseased blood vessels at the base or surface of the brain, with blood flowing directly into the subarachnoid space. It is a type of intracranial hemorrhage (ICH). The other four types of hemorrhage are subdural hemorrhage, epidural hemorrhage, intraventricular hemorrhage and intraparenchymal hemorrhage. If this type of disease does not receive timely diagnosis and treatment, it is very likely to cause paralysis or even death of the patient. Clinically, radiologists usually analyze the patient's condition based on non-contrast cranial CT scans and make corresponding diagnosis and treatment plans. Due to the large number of such patients, doctors usually need to read a large number of related CT images continuously. In the later stage of reading the film, excessive fatigue may cause doctors to make wrong judgments on the patient's condition, resulting in missed diagnosis, misdiagnosis, etc., which will endanger the patient's life safety. Therefore, the computer-aided diagnosis system based on medical CT image segmentation has certain application prospects and clinical value in this field.

[0003] With the continuous development of deep learning technology, derivative models based on fully convolutional neural networks (FCN) and U-net have been successfully applied to the task of intracranial hemorrhage lesion segmentation. Subarachnoid hemorrhage lesions have data characteristics different from the other four types of hemorrhage lesions: in general, the distribution positions of the other four types of lesions are fixed, the morphology is stable, and the number is small. However, subarachnoid hemorrhage lesions are mostly diffuse, with diverse locations, large morphological differences, and large numbers. Accurate segmentation of subarachnoid hemorrhage lesions is a challenging task. At present, only a small number of literatures specifically study the lesion segmentation of subarachnoid hemorrhage CT images, and most of the literature focuses on the task of lesion segmentation of intracranial hemorrhage CT images.

[0004] Existing methods can be roughly divided into two categories:

[0005] One is the traditional segmentation algorithm based on threshold, region or boundary. This type of algorithm only needs to rely on a small amount of data set or even no training data, and can be applied to the task of intracranial hemorrhage lesion segmentation. Bhanu et al. proposed an improved algorithm based on the distance regularized level set evolution model for the task of intracranial hemorrhage lesion segmentation in the document "Prakash, Knb, et al. "Segmentation and quantification of intra-ventricular / cerebral hemorrhage in CT scans by modified distance regularized level set evolution technique." International Journal of Computer Assisted Radiology and Surgery 7.5 (2012): 785-798." This algorithm will filter out areas with a small number of pixels, making it difficult to effectively segment small lesions of subarachnoid hemorrhage. Anjali et al. improved the fuzzy C-means algorithm in the document "Gautam, A.; Raman, B. "Automatic Segmentation of Intracerebral Hemorrhage from Brain CT Images." In Machine Intelligence and Signal Analysis; Springer, 2019; pp. 753–764." to remove the skull and extract the brain parenchyma area, and then segmented the intracranial hemorrhage lesions using the wavelet threshold method. Since most subarachnoid hemorrhage lesions are diffuse, a considerable number of pixels are slightly different from the surrounding brain medium pixels, resulting in low segmentation accuracy of this algorithm for such lesions.

[0006] The second is the deep learning segmentation algorithm based on FCN and U-Net. FCN is the earliest deep learning model proposed for semantic segmentation of natural images. U-Net is designed based on FCN for the data characteristics of medical images with simple semantics and fixed structure. It can make good use of the extracted high-level semantic information and low-level features. Cho et al. designed a cascaded FCN model in the paper “Cho, J., et al. "Improving Sensitivity on Identification and Delineation of Intracranial Hemorrhage Lesion Using Cascaded Deep Learning Models." Journal of Digital Imaging (2019)" to segment lesions contained in intracranial hemorrhage CT images with different window widths and window positions; Kuang et al. modified the U-Net model in the paper “Kuang, H., BK Menon, and W. Qiu." Segmenting Hemorrhagic and Ischemic Infarct Simultaneously From Follow-Up Non-Contrast CT Images in Patients With Acute Ischemic Stroke." IEEE Access 7 (2019)”, introduced artificially specified data features, and integrated multiple models into a comprehensive framework. However, the basic components of these derived models are still convolution kernels, whose receptive fields are fixed squares, making it difficult to accurately extract the data features of subarachnoid hemorrhage lesions, resulting in the above models often performing poorly in the segmentation tasks of diffuse lesions such as subarachnoid hemorrhage. Summary of the invention

[0007] The present invention discloses a subarachnoid hemorrhage lesion segmentation method based on UDT, which mainly introduces a single-scale and multi-scale variable attention module and a jump connection module based on cross-variable attention into the encoder of the Res-U-Net model to alleviate the problem that the existing method is difficult to accurately express the SAH lesion data features, resulting in low segmentation accuracy. Specifically, the present invention aims to improve the following two aspects:

[0008] 1. The lesion area determination rules relied on by traditional segmentation algorithms based on thresholds, regions or boundaries are all set for the data characteristics of ICH lesions, and it is difficult to accurately model the diffuse data characteristics of SAH lesions.

[0009] 2. The basic building blocks of the FCN and U-Net deep learning segmentation algorithm models are traditional convolutions. However, since the receptive field of the convolution kernel is a fixed square, it is difficult to effectively and accurately express the data features of SAH hemorrhagic lesions.

[0010] The present invention designs a subarachnoid hemorrhage lesion segmentation algorithm based on UDT, introduces single-scale and multi-scale variable attention modules and a jump connection module based on cross-variable attention into the encoder of the Res-U-Net model, so as to alleviate the problem that the existing methods are difficult to accurately express the characteristics of SAH lesion data, resulting in low segmentation accuracy. The technical solution is as follows:

[0011] 1. In view of the data characteristics of subarachnoid hemorrhage lesions, which are mostly diffusely distributed and have various shapes, a single-scale deformable attention module (SSDA) is embedded after the second layer of the Res-U-Net encoder. This module can adaptively determine the attention domain of each element according to the content of the input data, while reducing computational redundancy and achieving accurate expression of SAH lesion data characteristics.

[0012] 2. In view of the fact that the area of ​​subarachnoid hemorrhage lesions in a CT slice image varies greatly, that is, the size is different, based on the SSDA module, a multiple scales deformable attention module (MSDA) is embedded after the third, fourth, and fifth layers of the Res-U-Net encoder. This module can fuse the different scale features output by each encoding layer, making the data features extracted by the model more robust and representative.

[0013] 3. Design a Cross Deformable Attention–Skip Connection (CDA-SC) module based on cross-deformable attention. This module can use the encoded feature information to restore the fine-grained information lost in the upsampling operation of the decoded features by calculating the cross-deformable attention, so that the model can accurately segment the small lesions, lesion edges and other parts of the SAH lesions.

[0014] 4. The SSDA, MSDA, and CDA-SC modules designed above are introduced into the Res-U-Net model to form the UDT model. Compared with other segmentation methods, this model can extract the data features of SAH lesions more precisely, thereby improving the segmentation accuracy of the model for such lesions.

[0015] In general, according to the data characteristics of subarachnoid hemorrhage lesions, the present invention proposes a subarachnoid hemorrhage lesion segmentation method based on UDT. This method can accurately extract the data characteristics of subarachnoid hemorrhage lesions, thereby improving the segmentation accuracy of the model for such lesions. The specific implementation process is as follows:

[0016] Step 1: collect and convert CT image data of subarachnoid hemorrhage lesions to construct training sets and test sets;

[0017] First, each CT slice image was converted into PNG format, and the subarachnoid hemorrhage lesion area was manually annotated using an annotation tool. Then, the images and the corresponding labeled data were randomly divided into a training set and a test set, which were used for the subsequent update of the model's internal parameters and the quantitative evaluation of the model's segmentation performance.

[0018] Step 2, construct a single-scale variable attention module SSDA, the SSDA module adaptively determines the attention domain corresponding to each element in the feature according to the input data, and then assigns weights to the elements corresponding to all sampling points in its attention domain; after linearly mapping the input data, a weighted sum operation is performed on multiple sampling elements corresponding to each element of its mapped feature to complete the calculation of the single-scale variable attention;

[0019] Step 3, construct a multi-scale variable attention module MSDA, which is an extension of the single-scale variable attention module, receives multiple features of different sizes, calculates the relative position of the sampling point in the multi-scale features, and estimates the reference position of the sampling point on the multi-scale features to determine the attention domain corresponding to the query element in each size feature; after linearly mapping the multi-scale features respectively, perform a weighted sum operation on the multiple sampling elements corresponding to each query element in these mapped features to complete the calculation of the multi-scale variable attention;

[0020] Step 4, construct a jump connection structure CDA-SC based on cross-variable attention, and the CDA-SC enhances the ability of the jump connection to restore the fine-grained features of the decoding features through the information in the encoding features; specifically: first, by performing multiple independent 1×1 convolution operations on the encoding features, the attention domain corresponding to the decoding feature elements is determined, and the weights of the feature elements corresponding to all sampling points in the attention domain are assigned; after linearly mapping the decoding features, a weighted sum operation is performed on multiple sampling elements corresponding to each element of the mapping features to complete the calculation of the cross-variable attention and output; then the output features are spliced ​​with the encoding features in the channel direction to realize the construction of the jump connection structure based on cross-variable attention.

[0021] Step 5: Build the UDT model and output the lesion probability map

[0022] Based on Res-U-Net, the three modules constructed above are introduced into some of its structures. The details are as follows: an SSDA module is set after the residual double convolution module of the second coding layer; an MSDA module is set after the residual double convolution module of the third, fourth and fifth layers respectively; except for the jump connection between the first coding layer and the decoding layer, the jump connection structure between other layers is set to CDA-SC;

[0023] Step 6, train the UDT model on the subarachnoid hemorrhage training set until the model converges;

[0024] Step 7, test the UDT model on the subarachnoid hemorrhage test set, input the images in the test set into the trained UDT model respectively, obtain the lesion probability map, and convert it into a lesion segmentation mask map; then, compare these mask maps with the label data on the test set, calculate each evaluation index, and find the average value as the evaluation standard of the model's subarachnoid hemorrhage lesion segmentation performance.

[0025] Furthermore, the specific implementation of step 2 includes the following sub-steps:

[0026] Step 2.1, calculate the relative position of the sampling point in the single-scale feature

[0027] The single-scale variable attention module adopts a multi-head attention calculation mode, and the input feature of the module is recorded as X∈R H×W×C , where H, W, and C represent the length, width, and dimension of the feature respectively. This module divides the input feature X into M features according to the channel dimension. m∈[1,M],C m =C / M, where M represents the number of single-head attention modules, q mij Indicated in feature X m The element in row i and column j above, Record element q mij location information, Indicates q mij The corresponding eigenvector;

[0028] Feature X m After K independent 1×1 convolution operations, K groups of 2D bias Δp are output mqk ∈R H×W×2 , record K sampling elements in q mij The relative position of the attention module, where m and k represent the serial number and q of a single attention module respectively. mij The corresponding sampling point number, K represents the number of sampling points;

[0029] Step 2.2, calculate the weight matrix and linear mapping

[0030] The feature X m Input into two 1×1 convolutional layers respectively to obtain linear mapping With the weight matrix A mqk ∈R H×W×K , in the weight matrix A mqk In each channel S mij ∈R 1×K Storage element q mij The weight w corresponding to K sampling points mijk ,in:

[0031] Step 2.3, calculate the single-scale variable attention feature

[0032] According to the K groups of 2D bias Δp calculated in step 2.1 mqk , the attention weight matrix A calculated in step 2.2 mqk With feature X m The linear map V m , calculate the single-scale attention feature, the specific formula is as follows:

[0033]

[0034] In formula (1), Represents the output features of the mth single-head single-scale attention module is an updateable parameter matrix used to update the feature X' m Assign appropriate weights to perform information aggregation operations.

[0035] Furthermore, the specific implementation of step 3 includes the following sub-steps:

[0036] Step 3.1, calculate the relative position of the sampling point in the multi-scale feature

[0037] The multi-scale variable attention module can receive N multi-scale features Among them, H n , W n , C n Respectively represent the length, width and dimension of the nth feature, n∈{1,2,3,...,N}, specifically: H n =2 (n-1) *H1, W n =2 (n-1) *W1, C n =C1 / 2 (n-1) ;

[0038] Feature X1 represents the output feature of the convolutional module of the coding layer where this module is located, and the remaining features represent the output features of the previous N-1 coding layers;

[0039] The multi-scale variable attention module adopts a multi-head attention calculation mode; the module will input feature X respectively according to the dimension direction n Divided into M features m∈[1,M],C m = C / M, as the input of the single-head multi-scale variable attention module; q nmij Indicated in feature X nm The element in row i and column j above, Record element q nmij location information, Then it means q nmij The eigenvector represented by

[0040] Feature X 1m After N*K independent 1×1 convolution operations, NK groups of 2D bias are output. For N multi-scale features X nm Record K sampling elements in q respectively 1mij The relative position of n, m, and k represent the serial number of the multi-scale feature, the serial number of the single attention module, and q 1mij The sampling point numbers corresponding to different features, K represents the number of sampling points;

[0041] Step 3.2: Estimate the reference position of feature elements on multi-scale features

[0042] Since the input feature X nm The size of the output features is different The size of the fixed feature X 1m Remain consistent so that reference positions on features of different sizes Need to be relative to the position is estimated; the detailed idea is: feature X 1m Reference point position on Mapped to the upper left corner of the area corresponding to other large-scale features (2 (n-1) *i1,2 (n-1) *j1), and then randomly assign positive biases within the region to the horizontal and vertical coordinates, respectively. The formula is as follows:

[0043] i n =2 (n-1) *i1+rand_int(0,2 (n-1) -1) (2)

[0044] j n =2 (n-1) *j1+rand_int(0,2 (n-1) -1) (3)

[0045] In the above formula, rand_int(0,2 (n-1 )-1) Randomly generate an integer in the range [0,2 (n-1) -1];

[0046] Step 3.3, calculate the weight matrix and linear mapping

[0047] The feature X 1m Input into a 1×1 convolutional layer and output the weight matrix In the weight matrix A nmqk In each channel S nmij ∈R 1×(N*K) Storage element q 1mij The weight w corresponding to N*K sampling points nmijk ,in:

[0048] Feature X nm Input into N 1×1 convolutional layers respectively, and each convolutional layer outputs a linear mapping

[0049] Step 3.4, calculate multi-scale variable attention features

[0050] The N K groups of 2D bias Δp calculated according to steps 3.1, 3.2 and 3.3 respectively nmqk , the reference position of feature elements on multi-scale features With the weight matrix A nmqk , N groups of linear mappings V nm , calculate the multi-scale variable attention features, the specific formula is as follows:

[0051]

[0052] In the above formula, Represents the output features of the mth single-head multi-scale attention module is an updateable parameter matrix used to update the feature X' nm Assign appropriate weights to perform information aggregation operations.

[0053] Furthermore, the specific implementation of step 4 includes the following sub-steps:

[0054] Step 4.1, calculate the relative position of the sampling point in the encoding feature

[0055] Remember decoding features Encoding features Among them, H d =H e , W d =W e , C d =C e;

[0056] The cross-variable attention module adopts a multi-head attention calculation mode; this module will input feature X separately according to the dimension direction d , X e Divided into M features and m∈[1,M],C m =C / M, where M is the number of single-head cross-variable attention modules; q dmij Indicates that in the encoding feature X dm The i-th row and j-th column element on Record element q dmij location information, Then it means q dmij The eigenvector represented by

[0057] In order to use the encoding feature X em Recover the decoded feature X dm The fine-grained features lost during upsampling will be encoded as features X em After K independent 1×1 convolution operations, K groups of 2D biases are output Record K sample elements in q dmij The relative position of , where d, m, and k represent the feature from the encoder, the sequence number of a single attention module, and q dmij The sampling point number corresponding to the decoded feature, K represents the number of sampling points;

[0058] Step 4.2, calculate the weight matrix and linear mapping

[0059] Through a 1×1 convolution layer, using the encoded feature X em , calculate the weight matrix In the weight matrix A emqk In each channel S emij ∈R 1×K Storage element q dmij The weight w corresponding to K sampling points emijk ,in:

[0060] Feature X dm Input to a 1×1 convolutional layer, outputting a linear mapping of the encoded features

[0061] Step 4.3, calculate the cross-variable attention features

[0062] The K groups of 2D bias Δp calculated according to the above steps emqk , weight matrix A emqk With the encoding feature X dm The linear map Vdm , calculate the cross-variable attention feature, the specific formula is as follows:

[0063]

[0064] In the above formula, Represents the output features of the mth single-head cross attention module is an updateable parameter matrix used to update the feature X' dm Assign appropriate weights to perform information aggregation operations;

[0065] Step 4.4, stitching features

[0066] The output feature X' of the cross-variable attention module d With the encoding feature X e Splice in the dimension direction to get the features The symbols are as follows:

[0067] X ed =Concat(X e ,X' d , dim=1) (6)

[0068] Concat(·) in the above formula represents the feature concatenation function, and dim=1 indicates that the feature concatenation direction is the dimension direction.

[0069] Furthermore, the specific implementation of step 5 includes the following sub-steps:

[0070] Step 5.1, build the encoder

[0071] The UDT encoder has 5 layers, denoted as E a ,a∈[1,2,3,4,5];

[0072] The first encoding layer E1 consists of two double convolutional modules with residual connections, denoted as Input Data First pass Module, output features Afterwards Module, output features Among them, C1>C0; Finally, the feature Input to the maximum pooling layer, downsample the output features H1=H0 / 2, W1=W0 / 2; the specific symbolic expression of the above module is as follows:

[0073] BRC(·)=Conv(ReLU(BN(·))) (7)

[0074]

[0075] In the first formula above, BN represents the data normalization layer, ReLU represents the rectified linear activation function, Conv represents a convolutional layer with a step size and padding of 1 and a size of 3×3, the symbol “·” represents the feature, and BRC(·) represents the comprehensive convolutional processing layer; in the second formula, t represents the structure of the convolution module, which is the encoder e or the decoder d, l represents the level it is in, and u represents the arrangement number of the level it is in; Respectively refer to The first and second comprehensive convolutional processing layers of the module, Refers to the comprehensive convolution processing layer used in the residual connection;

[0076] In addition to setting up two double convolutional modules with residual connections in E1, the remaining coding layers There is only one module in each; in the second coding layer E2 The module is followed by a single variable attention module Then, the third, fourth and fifth coding layers E (3,4,5) In Each module is followed by a multi-scale variable attention module A maximum pooling module is set between each encoding layer. So far, the UDT encoder part is constructed.

[0077] Step 5.2: Construct a skip connection structure based on a cross-variable attention module

[0078] The decoder of UDT has 4 layers, denoted as D b ,b∈[4,3,2,1];

[0079] At each level of coding a With the decoding layer D b Between them, a=b=4,3,2, all are equipped with a skip connection structure based on a cross-variable attention module. Considering the computational complexity, a common skip connection structure is set between E1 and D1;

[0080] The processing process is as follows: The output feature of the fifth encoding layer E5 First, the output features are obtained by upsampling with bilinear interpolation and 1×1 convolution. H3=2*H4,W3=2*W4,C4=C5 / 2; then the features Input to the cross-variable attention module In the output feature Then, the feature and Splice them together in the dimension direction and output features As the input of the encoding layer D4; the rest of the jump connection structure based on the cross-variable attention module and The calculation process and Stay consistent;

[0081] Step 5.3, build the decoder

[0082] Between the fourth coding layer E4 and the fourth decoding layer D4 Module output characteristics Input to D4 for further processing; D (4,3,2) The layers are composed of only one double convolutional module with residual connection, which can be written as In the D1 decoding layer, there are two residual connected dual convolution modules, which can be respectively denoted as exist The module is followed by a 1×1 convolutional layer whose output dimension is the number of segmentation targets, and finally the probability distribution in the dimensional direction is performed through a softmax layer. In the segmentation task of subarachnoid hemorrhage lesions, the segmentation target is only one type of hemorrhagic lesions, so the sigmoid layer is used to calculate the probability that the element is a lesion point. Between each decoding layer, a bilinear interpolation upsampling module and a 1×1 convolutional module are set.

[0083] Furthermore, the loss function used in the training in step 6 is the binary cross entropy loss function, and its specific formula is as follows:

[0084] bceloss(x ij ,y ij )=-[y ij ·log(x ij )+(1-y ij )·log(1-x ij )] (9)

[0085]

[0086] Formula (9) calculates the element x in the i-th row and j-th column of the probability map ij ∈{p|p∈[0,1], p is a decimal} and its corresponding single label y ij ∈{0,1}, the binary cross entropy loss is calculated by H×W bceloss(x ij ,y ij) to obtain the binary cross entropy loss between the UDT output probability map and its corresponding label, H and W represent the height and width of the label image respectively, and HxW refers to the total number of elements in the label image; according to BCELoss(x,y), the back propagation algorithm is used to update the internal parameters of the model.

[0087] Furthermore, the specific implementation of step 1 includes the following sub-steps:

[0088] Step 1.1, using ITK-SNAP software, set the window width and window level to 80Hu and 50Hu respectively, select the CT slice containing the subarachnoid hemorrhage lesion in the z-axis direction, convert it into PNG format images for export;

[0089] Step 1.2: Under the guidance of experts, use the labeling tool Labelme to manually label the subarachnoid hemorrhage lesion area in the CT image, obtain the label data, and complete the construction of the subarachnoid hemorrhage dataset; the size of each CT image is 3x512x512, and the size of the label data is 512x512; subsequently, the dataset is randomly divided into a training set and a test set, with a size of 210 and 80 images respectively.

[0090] Furthermore, the specific implementation of step 7 includes the following sub-steps:

[0091] Step 7.1: Convert the probability map output by UDT into a mask map

[0092] UDT model receiving characteristics After the input, the output probability map C out is the number of categories of the segmentation target. In the SAH lesion segmentation task, C out =1, the probability map X out Convert to mask image mask to facilitate the intuitive display of arachnoid hemorrhage lesions; the specific conversion formula is as follows:

[0093]

[0094] In the above formula, p ij Represents the probability graph X out The probability value of the bleeding lesion in the i-th row and j-th column, r ij Represents the pixel value of the i-th row and j-th column of the mask image mask;

[0095] Step 7.2: Calculate segmentation evaluation index using mask image and labeled data

[0096] All the data test-X in the test set i, i∈[1,2,3,...,N], N is the size of the test set, which is input into the trained UDT model and the corresponding probability maps are output respectively These probability maps are then transformed into Convert to mask i ;

[0097] By comparing the mask i And the corresponding label label i The relevant information is used to calculate the segmentation evaluation index index-k i , k∈[1,2,...,K], K is the number of categories of indicators, and then find the average value of these evaluation indicators index-k i-avg As the final result, the segmentation performance of the UDT model is evaluated.

[0098] Furthermore, Dice and Iou were selected as evaluation indicators of the model on the subarachnoid hemorrhage test set. The calculation formulas of each evaluation indicator are as follows:

[0099]

[0100]

[0101] In the above formula, TP means true positive, that is, the predicted value and the true value are both 1; TF means true negative, that is, the predicted value and the true value are both 0; FP means false positive, that is, the predicted value is 1, but the true value is 0; FN means false negative, that is, the predicted value is 0, but the true value is 1.

[0102] Compared with the existing subarachnoid hemorrhage segmentation algorithm, the present invention has the following advantages:

[0103] 1. The proposed SSDA module can dynamically adjust the attention field of each element according to the input data, so as to better aggregate the information between elements and alleviate the problem that the convolution kernel with fixed shape and size is difficult to accurately express the characteristics of SAH lesion data;

[0104] 2. The proposed MSDA module can fuse the information of different scale features output by each coding layer to adapt to the data characteristics of SAH lesions of different scales in CT images, making the data features extracted by the model more robust.

[0105] 3. The proposed CDA-SC module further integrates the position information of the encoding layer and the semantic information of the decoding layer, so that the model can more accurately segment some fine-grained structures of subarachnoid hemorrhage lesions, such as tiny lesions, lesion areas, etc. BRIEF DESCRIPTION OF THE DRAWINGS

[0106] Figure 1The overall architecture of the UDT model proposed by the present invention is adopted.

[0107] Figure 2 Comparison of the output mask images of UDT and other models on some images in the test set. DETAILED DESCRIPTION

[0108] The technical solution of the present invention is further described below in conjunction with the accompanying drawings and embodiments.

[0109] The UDT-based subarachnoid hemorrhage lesion segmentation algorithm of the present invention mainly implements the following steps:

[0110] (1) Acquisition and conversion of CT image data of subarachnoid hemorrhage lesions

[0111] First, each CT slice image was converted into PNG format, and under the guidance of experts, the subarachnoid hemorrhage lesion area was manually annotated using annotation tools. Subsequently, the images and the corresponding labeled data were randomly divided into training sets and test sets, which were used for the subsequent update of the internal parameters of the model and the quantitative evaluation of the model segmentation performance.

[0112] (2) Constructing a single-scale variable attention module (SSDA)

[0113] A single-scale variable attention module is constructed to adaptively select a fixed number of sampling points as the attention domain of each element according to the content of the input image, rather than the entire domain specified in the traditional attention mechanism. This reduces computational redundancy while accurately expressing the characteristics of SAH lesion data.

[0114] (3) Constructing a multi-scale variable attention module (MSDA)

[0115] Based on the above-mentioned single-scale variable attention module, a multi-scale variable attention module is extended and constructed, which can fuse the information of different scale features output by each encoding layer, making the data features extracted by the model more robust.

[0116] (4) Constructing a skip connection structure based on cross-variable attention (CDA-SC)

[0117] A skip connection structure based on cross-variable attention is constructed to enhance the ability of the skip connection to restore the fine-grained features of the decoded features through the information in the encoded features, so that the model can more finely segment the details of the subarachnoid hemorrhage lesions, such as tiny lesions and the edges of the lesion area.

[0118] (5) Constructing UDT model

[0119] Based on Res-U-Net, the three modules constructed above are introduced into some of its structures. The details are as follows: an SSDA module is set behind the residual double convolution module of the second coding layer; an MSDA module is set behind the residual double convolution modules of the third, fourth and fifth layers respectively; except for the jump connection between the first encoding and decoding layers, the jump connection structures between other layers are set to CDA-SC.

[0120] (6) Training the UDT model on the subarachnoid hemorrhage training set

[0121] Using the training set created in step (1), the model is trained using stochastic gradient descent until the model converges.

[0122] (7) Testing the UDT model on the subarachnoid hemorrhage test set

[0123] The model is tested using the test set created in step (1). The images in the test set are input into the trained UDT model to obtain lesion segmentation masks. Then, these masks are compared with the label data on the test set, and after calculating each evaluation index, the average value is calculated as the evaluation standard of the model's performance in segmenting subarachnoid hemorrhage lesions.

[0124] The following is combined with Figure 1 , the specific segmentation and test verification of the present invention are further described in detail.

[0125] Step 1: Collect and convert CT image data of subarachnoid hemorrhage lesions

[0126] Step 1.1, using ITK-SNAP software, set the window width and window level to 80Hu and 50Hu respectively, select the CT slice containing the subarachnoid hemorrhage lesion in the z-axis direction, convert it into PNG format images for export;

[0127] Step 1.2, under the guidance of experts, use the labeling tool Labelme to manually label the subarachnoid hemorrhage lesion area in the CT image, obtain label data, and complete the construction of the subarachnoid hemorrhage dataset. The size of each CT image is 3x512x512, and the size of the label data is 512x512. The dataset is then randomly divided into a training set and a test set, with a size of 210 and 80 images respectively.

[0128] Step 2: Construct a single-scale variable attention module

[0129] This module can adaptively determine the attention domain corresponding to each element in the feature based on the input data, and then assign weights to the elements corresponding to all sampling points in its attention domain. After linearly mapping the input data, a weighted sum operation is performed on multiple sampling elements corresponding to each element of its mapped feature to complete the calculation of single-scale variable attention.

[0130] Step 2.1, calculate the relative position of the sampling point in the single-scale feature

[0131] The single-scale variable attention module adopts a multi-head attention calculation mode. The input feature of this module is X∈R H×W×C (H, W, C represent the length, width and dimension of the feature respectively). This module divides the input feature X into M features according to the channel dimension. M represents the number of single-head attention modules, q mij Indicated in feature X m The element in row i and column j above, Record element q mij location information, Indicates q mij The corresponding feature vector.

[0132] Feature X m After K independent 1×1 convolution operations (K represents the number of sampling points), K groups of 2D bias Δp are output mqk ∈R H×W×2 , record K sampling elements in q mij The relative position of the attention module, where m and k represent the serial number and q of a single attention module respectively. mij The corresponding sampling point number.

[0133] Step 2.2, calculate the weight matrix and linear mapping

[0134] The feature X m Input into two 1×1 convolutional layers respectively to obtain linear mapping With the weight matrix A mqk ∈R H×W×K In the weight matrix A mqk In each channel S mij ∈R 1×K Storage element q mij The weight w corresponding to K sampling points mijk ,in:

[0135] Step 2.3, calculate the single-scale variable attention feature

[0136] According to the K groups of 2D bias Δp calculated in step 2.1 mqk , the attention weight matrix A calculated in step 2.2 mqkWith feature X m The linear map V m , calculate the single-scale attention feature, the specific formula is as follows:

[0137]

[0138] In formula (1), Represents the output features of the mth single-head single-scale attention module is an updateable parameter matrix used to update the feature X' m Assign appropriate weights to perform information aggregation operations.

[0139] Step 3: Construct a multi-scale variable attention module

[0140] This module is an extension of the single-scale variable attention module and can receive features of multiple different sizes. Due to the different sizes, in addition to calculating the relative position of the sampling point in the multi-scale features, it is also necessary to estimate the reference position of the sampling point on the multi-scale features to determine the attention domain corresponding to the query element in each size feature. After linearly mapping the multi-scale features, a weighted sum operation is performed on the multiple sampling elements corresponding to each query element in these mapped features to complete the calculation of the multi-scale variable attention.

[0141] Step 3.1: Calculate the relative position of the sampling point in the multi-scale feature

[0142] The multi-scale variable attention module can receive N multi-scale features Among them, H n , W n , C n Respectively represent the length, width and dimension of the nth feature (n∈{1,2,3,...,N}), specifically: H n =2 (n-1) *H1, W n =2 (n-1) *W1, C n =C1 / 2 (n-1) .

[0143] The multi-scale variable attention module adopts a multi-head attention calculation mode. This module will input feature X respectively according to the dimension direction n Divided into M features As the input of the single-head multi-scale deformable attention module. nmij Indicated in feature X nm The element in row i and column j above, Record element q nmij location information, Then it means qnmij The eigenvector represented by .

[0144] Feature X 1m After N*K independent 1×1 convolution operations (K represents the number of sampling points), NK groups of 2D bias are output. For N multi-scale features X nm Record K sampling elements in q respectively 1mij The relative position of n, m, and k represent the serial number of the multi-scale feature, the serial number of the single attention module, and q 1mij The sampling point numbers corresponding to different features.

[0145] Step 3.2, estimate the reference position of the feature element on the multi-scale feature due to the input feature X nm The size of the output features is different The size of the fixed feature X 1m Remain consistent so that reference positions on features of different sizes Need to be relative to the position The detailed idea is: feature X 1m Reference point position on Mapped to the upper left corner of the area corresponding to other large-scale features (2 (n-1) *i1,2 (n-1) *j1), and then randomly assign positive biases within the region to the horizontal and vertical coordinates, respectively. The formula is as follows:

[0146] i n =2 (n-1) *i1+rand_int(0,2 (n-1) -1) (2)

[0147] j n =2 (n-1) *j1+rand_int(0,2 (n-1) -1) (3)

[0148] In the above formula, rand_int(0,2 (n-1) -1) Randomly generate an integer in the range [0,2 (n-1) -1].

[0149] Step 3.3, calculate the weight matrix and linear mapping

[0150] The feature X 1m Input into a 1×1 convolutional layer and output the weight matrix In the weight matrix A nmqk In each channel S nmij ∈R 1×(N*K) Storage element q 1mijThe weight w corresponding to N*K sampling points nmijk ,in:

[0151] Feature X nm Input into N 1×1 convolutional layers respectively, and each convolutional layer outputs a linear mapping

[0152] Step 3.4, calculate multi-scale variable attention features

[0153] The N K groups of 2D bias Δp calculated according to steps 3.1, 3.2 and 3.3 respectively nmqk , the reference position of feature elements on multi-scale features With the weight matrix A nmqk , N groups of linear mappings V nm , calculate the multi-scale variable attention features, the specific formula is as follows:

[0154]

[0155] In the above formula, Represents the output features of the mth single-head multi-scale attention module is an updateable parameter matrix used to update the feature X' nm Assign appropriate weights to perform information aggregation operations.

[0156] Step 4: Construct a jump connection structure based on cross-variable attention. This module receives two features of the same size, which come from the encoder and decoder respectively. First, by performing multiple independent 1×1 convolution operations on the encoded features, the attention domain corresponding to the decoded feature elements is determined, and the weights of the feature elements corresponding to all sampling points in the attention domain are assigned. After linearly mapping the decoded features, a weighted sum operation is performed on multiple sampling elements corresponding to each element of the mapped features to complete the calculation of the cross-variable attention. Then the output feature is spliced ​​with the encoded feature in the channel direction to realize the construction of a jump connection structure based on cross-variable attention.

[0157] Step 4.1, calculate the relative position of the sampling point in the encoding feature

[0158] Remember decoding features Encoding features Among them, H d =H e , W d =W e , C d =C e .

[0159] The cross-variable attention module uses a multi-head attention calculation mode. This module will input feature X separately according to the dimension direction d , X e Divided into M features and M is the number of single-head cross-variable attention modules. dmij Indicates that in the encoding feature X dm The i-th row and j-th column element on Record element q dmij location information, Then it means q dmij The eigenvector represented by .

[0160] In order to use the encoding feature X em Recover the decoded feature X dm The fine-grained features lost during upsampling will be encoded as features X em After K independent 1×1 convolution operations (K represents the number of sampling points), K groups of 2D biases are output. Record K sample elements in q dmij The relative position of , where d, m, and k represent the feature from the encoder, the sequence number of a single attention module, and q dmij The corresponding sampling point number in the decoded feature.

[0161] Step 4.2, calculate the weight matrix and linear mapping

[0162] Through a 1×1 convolution layer, using the encoded feature X em , calculate the weight matrix In the weight matrix A emqk In each channel S emij ∈R 1×K Storage element q dmij The weight w corresponding to K sampling points emijk ,in:

[0163] Feature X dm Input to a 1×1 convolutional layer, outputting a linear mapping of the encoded features

[0164] Step 4.3, calculate the cross-variable attention features

[0165] The K groups of 2D bias Δp calculated according to the above steps emqk , weight matrix A emqk With the encoding feature X dm The linear map V dm , calculate the cross-variable attention feature, the specific formula is as follows:

[0166]

[0167] In the above formula, Represents the output features of the mth single-head cross attention module is an updateable parameter matrix used to update the feature X' dm Assign appropriate weights to perform information aggregation operations.

[0168] Step 4.4, stitching features

[0169] The output feature X' of the cross-variable attention module d With the encoding feature X e Splice in the dimension direction to get the features The symbols are as follows:

[0170] X ed =Concat(X e ,X' d , dim=1) (6)

[0171] Concat(·) in the above formula represents the feature concatenation function, and dim=1 indicates that the feature concatenation direction is the dimension direction.

[0172] Step 5, construct the UDT model and output the lesion probability map, where each pixel value is between 0 and 1;

[0173] Step 5.1, build the encoder

[0174] The UDT encoder has 5 layers, denoted as E a ,a∈[1,2,3,4,5].

[0175] The first encoding layer E1 consists of two double convolutional modules with residual connections, denoted as Input Data First pass Module, output features Afterwards Module, output features Among them, C1>C0. Finally, the feature (Also known as ) is input into the maximum pooling layer and the output features are downsampled The specific symbolic expression of the above modules is as follows:

[0176] BRC(·)=Conv(ReLU(BN(·))) (7)

[0177]

[0178] In the first formula above, BN represents the data normalization layer, ReLU represents the rectified linear activation function, Conv represents a convolutional layer with a step size and padding of 1 and a size of 3×3, the symbol “·” represents the feature, and BRC(·) represents the comprehensive convolutional processing layer. In the second formula, t represents the structure of the convolutional module (encoder e or decoder d), l represents the level it is in, and u represents the sequence number of the level it is in. Respectively refer to The first and second comprehensive convolutional processing layers of the module, Refers to the comprehensive convolution processing layer used in the residual connection.

[0179] In addition to setting up two double convolutional modules with residual connections in E1, the remaining coding layers There is only one module. In the second coding layer E2 The module is followed by a single variable attention module Then, the third, fourth and fifth coding layers E (3,4,5) In Each module is followed by a multi-scale variable attention module A maximum pooling module is set between each encoding layer. At this point, the UDT encoder part is completed.

[0180] Step 5.2: Construct a skip connection structure based on a cross-variable attention module

[0181] The decoder of UDT has 4 layers, denoted as D b ,b∈[4,3,2,1].

[0182] At each level of coding a With the decoding layer D b A skip connection structure based on a cross-variable attention module is set between (a=b=4,3,2). Considering the computational complexity, an ordinary skip connection structure is set between E1 and D1.

[0183] The output features of the fifth encoding layer E5 First, the output features are obtained by upsampling with bilinear interpolation and 1×1 convolution. The following features Input to the cross-variable attention module In the output feature Then, the feature and Splice them together in the dimension direction and output features As the input of the coding layer D4. The rest of the connection jump structure is based on the cross-variable attention module. and The calculation process is consistent with the above.

[0184] Step 5.3, build the decoder

[0185] Between the fourth coding layer E4 and the fourth decoding layer D4 Module output characteristics The input is sent to D4 for further processing. (4,3,2) The layers are composed of only one double convolutional module with residual connection, which can be written as In the D1 decoding layer, there are two residual connected dual convolution modules, which can be respectively denoted as exist The module is followed by a 1×1 convolutional layer whose output dimension is the number of segmentation targets, and finally the probability distribution in the dimension direction is calculated through the softmax layer. In the task of segmenting subarachnoid hemorrhage lesions, the segmentation target is only the hemorrhage lesion, so in the experiment, the sigmoid layer is used to calculate the probability that the element is a lesion point. Between each decoding layer, a bilinear interpolation upsampling module and a 1×1 convolutional module are set.

[0186] Step 6: Train the UDT model on the subarachnoid hemorrhage training set

[0187] The loss function used in training is the binary cross entropy loss function (BCE), and its specific formula is as follows:

[0188] bceloss(x ij ,y ij )=-[y ij ·log(x ij )+(1-y ij )·log(1-x ij )] (9)

[0189]

[0190] Formula (9) calculates the element x in the i-th row and j-th column of the probability map ij ∈{p|p∈[0,1], p is a decimal} and its corresponding single label y ij ∈{0,1}, the binary cross entropy loss is calculated by H×W bceloss(x ij ,y ij) to obtain the binary cross entropy loss between the UDT output probability map and its corresponding label. H and W represent the height and width of the label image, respectively, and HxW refers to the total number of elements in the label image. According to BCELoss(x,y), the back propagation algorithm (BP) is used to update the internal parameters of the model.

[0191] Step 7: Test the UDT model on the subarachnoid hemorrhage test set

[0192] Step 7.1: Convert the probability map output by UDT into a mask map

[0193] UDT model receiving characteristics After the input, the output probability map C out is the number of categories of the segmentation target. In the SAH lesion segmentation task, C out =1. Later, we need to convert the probability map X out Convert to mask image mask to facilitate the intuitive display of arachnoid hemorrhage lesions. The specific conversion formula is as follows:

[0194]

[0195] In the above formula, p ij Represents the probability graph X out The probability value of the bleeding lesion in the i-th row and j-th column, r ij Represents the pixel value of the i-th row and j-th column of the mask image mask.

[0196] Step 7.2: Calculate segmentation evaluation index using mask image and labeled data

[0197] All the data test-X in the test set i (i∈[1,2,3,...,N], N is the size of the test set) is input into the trained UDT model and its corresponding probability map is output respectively. These probability maps are then transformed into Convert to mask i .

[0198] By comparing the mask i And the corresponding label label i The relevant information is used to calculate the segmentation evaluation index index-k i (k∈[1,2,...,K], K is the number of categories of indicators), and then calculate the average value of these evaluation indicators index-k i-avg As the final result, the segmentation performance of the UDT model is evaluated.

[0199] The effect of the present invention can be further illustrated by the following experiments.

[0200] 1. Experimental conditions

[0201] The training and testing of the model in the present invention are carried out on an NVIDIA A40 GPU device with a video memory of 48G, the operating system used is Ubuntu 20, and the deep learning framework adopted is PyTorch.

[0202] 2. Experimental content

[0203] We selected Dice and Iou as the evaluation indicators of the model on the subarachnoid hemorrhage test set. The calculation formulas of each evaluation indicator are as follows:

[0204]

[0205]

[0206] In the above formula, TP means true positive, that is, the predicted value and the true value are both 1; TF means true negative, that is, the predicted value and the true value are both 0; FP means false positive, that is, the predicted value is 1, but the true value is 0; FN means false negative, that is, the predicted value is 0, but the true value is 1.

[0207] In order to prove that the UDT model proposed in this invention can segment the lesions of subarachnoid hemorrhage more accurately than other segmentation models, multiple models were selected in the experiment, and the unified training parameters were set. Comparative experiments were performed on the same data set. The comparative algorithms were from the following literatures:

[0208] 1. "Long J., E. Shelhamer and T. Darrell. "Fully Convolutional Networks for Semantic Segmentation" IEEE Transactions on Pattern Analysis and MachineIntelligence 39.4 (2015): 640-651."

[0209] 2. "O.Ronneberger, P.Fischer and T.Brox, "U-net: Convolutional networks for biomedical image segmentation" in International Conference on MedicalImage Computing and Computer-Assisted Intervention.Springer, 2015, pp.234–24"

[0210] 3. "Chen J, Lu Y, Yu Q, et al. "TransUNet: Transformers Make StrongEncoders for Medical Image Segmentation".arXiv.2102.04306(2021)"

[0211] The comparative experimental results of the UDT model proposed in this invention and other segmentation models are as follows:

[0212] Table 1: Comparison of different deep learning models on various segmentation indicators

[0213]

[0214] From Table 1, we can see that the UDT-based subarachnoid hemorrhage lesion segmentation method proposed in the present invention achieves the highest values ​​in both Iou and Dice segmentation indicators. This is because we introduced single- and multi-scale variable attention modules and a jump connection structure based on cross-variable attention into the Res-U-Net model, which enables the model to more accurately model the data characteristics of diffuse, diverse shapes, and different scales of subarachnoid hemorrhage lesions, thereby improving the segmentation accuracy of the model for such lesions. The above experimental results further prove the advanced nature of this method.

[0215] The specific embodiments described herein are merely examples of the spirit of the present invention. Those skilled in the art may make various modifications or additions to the specific embodiments described or replace them in similar ways, but they will not deviate from the spirit of the present invention or exceed the scope defined by the appended claims.

Claims

1. A subarachnoid hemorrhage lesion segmentation method based on UDT, characterized in that: The steps include: Step 1: collect and convert CT image data of subarachnoid hemorrhage lesions to construct training sets and test sets; First, each CT slice image was converted into PNG format, and the subarachnoid hemorrhage lesion area was manually annotated using annotation tools; Subsequently, the images and the corresponding labeled data are randomly divided into a training set and a test set, which are used for updating the subsequent model internal parameters and quantitative evaluation of the model segmentation performance, respectively; Step 2, construct a single-scale variable attention module SSDA, wherein the SSDA module adaptively determines the attention domain corresponding to each element in the feature according to the input data, and then assigns weights to the elements corresponding to all sampling points in its attention domain; After linearly mapping the input data, a weighted sum operation is performed on multiple sampling elements corresponding to each element of its mapping feature to complete the calculation of single-scale variable attention; Step 3, construct a multi-scale variable attention module MSDA, which is an extension of the single-scale variable attention module, receives multiple features of different sizes, calculates the relative position of the sampling point in the multi-scale features, and estimates the reference position of the sampling point on the multi-scale features to determine the attention domain corresponding to the query element in each size feature; after linearly mapping the multi-scale features respectively, perform a weighted sum operation on the multiple sampling elements corresponding to each query element in these mapped features to complete the calculation of the multi-scale variable attention; Step 4, construct a jump connection structure CDA-SC based on cross-variable attention, and the CDA-SC strengthens the ability of the jump connection to restore the fine-grained features of the decoding features through the information in the encoding features; specifically: first, by performing multiple independent 1×1 convolution operations on the encoding features, the attention domain corresponding to the decoding feature elements is determined, and the weights of the feature elements corresponding to all sampling points in the attention domain are assigned; after linearly mapping the decoding features, a weighted sum operation is performed on multiple sampling elements corresponding to each element of the mapping features to complete the calculation of the cross-variable attention and output; then the output features are spliced ​​with the encoding features in the channel direction to realize the construction of the jump connection structure based on the cross-variable attention; Step 5: Build the UDT model and output the lesion probability map Based on Res-U-Net, the three modules constructed above are introduced into some of its structures. The details are as follows: an SSDA module is set after the residual double convolution module of the second coding layer; an MSDA module is set after the residual double convolution module of the third, fourth and fifth layers respectively; except for the jump connection between the first coding layer and the decoding layer, the jump connection structure between other layers is set to CDA-SC; Step 6, train the UDT model on the subarachnoid hemorrhage training set until the model converges; Step 7, test the UDT model on the subarachnoid hemorrhage test set, input the images in the test set into the trained UDT model respectively, obtain the lesion probability map, and convert it into a lesion segmentation mask map; then, compare these mask maps with the label data on the test set, calculate each evaluation index, and find the average value as the evaluation standard of the model's subarachnoid hemorrhage lesion segmentation performance.

2. The method for segmenting subarachnoid hemorrhage lesions based on UDT as claimed in claim 1, characterized in that: The specific implementation of step 2 includes the following sub-steps: Step 2.1, calculate the relative position of the sampling point in the single-scale feature The single-scale variable attention module adopts a multi-head attention calculation mode, and the input feature of the module is recorded as X∈R H ×W×C , where H, W, and C represent the length, width, and dimension of the feature respectively. This module divides the input feature X into M features according to the channel dimension. m∈[1,M],C m =C / M, where M represents the number of single-head attention modules, q mij Indicated in feature X m The element in row i and column j above, Record element q mij location information, Indicates q mij The corresponding eigenvector; Feature X m After K independent 1×1 convolution operations, K groups of 2D bias Δp are output mqk ∈R H×W×2 , record K sampling elements in q mij The relative position of the attention module, where m and k represent the serial number and q of a single attention module respectively. mij The corresponding sampling point number, K represents the number of sampling points; Step 2.2, calculate the weight matrix and linear mapping The feature X m Input into two 1×1 convolutional layers respectively to obtain linear mapping With the weight matrix A mqk ∈R H×W×K , in the weight matrix A mqk In each channel S mij ∈R 1×K Storage element q mij The weight w corresponding to K sampling points mijk ,in: Step 2.3, calculate the single-scale variable attention feature According to the K groups of 2D bias Δp calculated in step 2.1 mqk , the attention weight matrix A calculated in step 2.2 mqk With feature X m The linear map V m , calculate the single-scale attention feature, the specific formula is as follows: In formula (1), Represents the output features of the mth single-head single-scale attention module is an updateable parameter matrix used to update the feature X' m Assign appropriate weights to perform information aggregation operations.

3. The method for segmenting subarachnoid hemorrhage lesions based on UDT as claimed in claim 1, characterized in that: The specific implementation of step 3 includes the following sub-steps: Step 3.1: Calculate the relative position of the sampling point in the multi-scale feature The multi-scale variable attention module can receive N multi-scale features Among them, H n , W n , C n Respectively represent the length, width and dimension of the nth feature, n∈{1,2,3,...,N}, specifically: H n =2 (n-1) *H1, W n =2 (n-1) *W1, C n =C1 / 2 (n-1) ; Feature X1 represents the output feature of the convolutional module of the coding layer where this module is located, and the remaining features represent the output features of the previous N-1 coding layers respectively; The multi-scale variable attention module adopts a multi-head attention calculation mode; the module will input feature X respectively according to the dimension direction n Divided into M features m∈[1,M],C m = C / M, as the input of the single-head multi-scale deformable attention module; Remember q nmij Indicated in feature X nm The element in row i and column j above, Record element q nmij location information, Then it means q nmij The eigenvector represented by Feature X 1m After N*K independent 1×1 convolution operations, NK groups of 2D bias are output. For N multi-scale features X nm Record K sampling elements in q respectively 1mij The relative position of n, m, and k represent the serial number of the multi-scale feature, the serial number of the single attention module, and q 1mij The sampling point numbers corresponding to different features, K represents the number of sampling points; Step 3.2: Estimate the reference position of feature elements on multi-scale features Since the input feature X nm The size of the output feature is different The size of the fixed feature X 1m Remain consistent so that reference positions on features of different sizes Need to be relative to the position be estimated; The detailed idea is: feature X 1m Reference point position on Mapped to the upper left corner of the area corresponding to other large-scale features (2 (n-1) *i1,2 (n -1) *j1), and then randomly assign positive biases within the region to the horizontal and vertical coordinates, respectively. The formula is as follows: i n =2 (n-1) *i1+rand_int(0,2 (n-1) -1) (2) j n =2 (n-1) *j1+rand_int(0,2 (n-1) -1) (3) In the above formula, rand_int(0,2 (n-1) -1) Randomly generate an integer in the range [0,2 (n-1) -1]; Step 3.3, calculate the weight matrix and linear mapping The feature X 1m Input into a 1×1 convolutional layer and output the weight matrix In the weight matrix A nmqk In each channel S nmij ∈R 1×(N*K) Storage element q 1mij The weight w corresponding to N*K sampling points nmijk ,in: Feature X nm Input into N 1×1 convolutional layers respectively, and each convolutional layer outputs a linear mapping Step 3.4, calculate multi-scale variable attention features The N K groups of 2D bias Δp calculated according to steps 3.1, 3.2 and 3.3 respectively nmqk , the reference position p of the feature element on the multi-scale feature qnmij With the weight matrix A nmqk , N groups of linear mappings V nm , calculate the multi-scale variable attention features, the specific formula is as follows: In the above formula, Represents the output features of the m-th single-head multi-scale attention module is an updateable parameter matrix used to update the feature X' nm Assign appropriate weights to perform information aggregation operations.

4. The method for segmenting subarachnoid hemorrhage lesions based on UDT as claimed in claim 1, characterized in that: The specific implementation of step 4 includes the following sub-steps: Step 4.1, calculate the relative position of the sampling point in the encoding feature Remember decoding features Encoding features Among them, H d =H e , W d =W e , C d =C e ; The cross-variable attention module adopts a multi-head attention calculation mode; this module will input feature X separately according to the dimension direction d , X e Divided into M features and m∈[1,M],C m =C / M, where M is the number of single-head cross-variable attention modules; Remember q dmij Indicates that in the encoding feature X dm The i-th row and j-th column element on Record element q dmij location information, Then it means q dmij The eigenvector represented by In order to use the encoding feature X em Recover the decoded feature X dm The fine-grained features lost during upsampling will be encoded as features X em After K independent 1×1 convolution operations, K groups of 2D biases are output Record K sample elements in q dmij The relative position of , where d, m, and k represent the feature from the encoder, the sequence number of a single attention module, and q dmij The sampling point number corresponding to the decoded feature, K represents the number of sampling points; Step 4.2, calculate the weight matrix and linear mapping Through a 1×1 convolution layer, using the encoded feature X em , calculate the weight matrix In the weight matrix A emqk In each channel S emij ∈R 1×K Storage element q dmij The weight w corresponding to K sampling points emijk ,in: Feature X dm Input to a 1×1 convolutional layer, outputting a linear mapping of the encoded features Step 4.3, calculate the cross-variable attention features The K groups of 2D bias Δp calculated according to the above steps emqk , weight matrix A emqk With the encoding feature X dm The linear map V dm , calculate the cross-variable attention feature, the specific formula is as follows: In the above formula, Represents the output features of the mth single-head cross attention module is an updateable parameter matrix used to update the feature X' dm Assign appropriate weights to perform information aggregation operations; Step 4.4, stitching features The output feature X' of the cross-variable attention module d With the encoding feature X e Splice in the dimension direction to get the features The symbols are as follows: X ed =Concat(X e ,X' d ,dim=1) (6) Concat(·) in the above formula represents the feature concatenation function, and dim=1 indicates that the feature concatenation direction is the dimension direction.

5. The method for segmenting subarachnoid hemorrhage lesions based on UDT as claimed in claim 1, characterized in that: The specific implementation of step 5 includes the following sub-steps: Step 5.1, build the encoder The UDT encoder has 5 layers, denoted as E a ,a∈[1,2,3,4,5]; The first encoding layer E1 consists of two double convolutional modules with residual connections, denoted as Input Data First pass Module, output features Afterwards Module, output features Among them, C1>C0; Finally, the feature Input to the maximum pooling layer, downsample the output features H1=H0 / 2, W1=W0 / 2; the specific symbolic expression of the above module is as follows: BRC(·)=Conv(ReLU(BN(·))) (7) In the first formula above, BN represents the data normalization layer, ReLU represents the rectified linear activation function, Conv represents the convolutional layer with a step size and padding of 1 and a size of 3×3, the symbol "·" represents the feature, and BRC(·) represents the comprehensive convolutional processing layer; in the second formula, t represents the structure of the convolutional module, which is the encoder e or the decoder d, l represents the level it is in, and u represents the arrangement number of the level it is in; Respectively refer to The first and second comprehensive convolutional processing layers of the module, Refers to the comprehensive convolution processing layer used in the residual connection; In addition to setting up two double convolutional modules with residual connections in E1, the remaining coding layers There is only one module in each; in the second coding layer E2 The module is followed by a single variable attention module Then, the third, fourth and fifth coding layers E (3,4,5) In Each module is followed by a multi-scale variable attention module A maximum pooling module is set between each encoding layer. So far, the UDT encoder part is constructed. Step 5.2: Construct a skip connection structure based on a cross-variable attention module The decoder of UDT has 4 layers, denoted as D b ,b∈[4,3,2,1]; At each level of coding a With the decoding layer D b Between them, a=b=4,3,2, all are equipped with a skip connection structure based on a cross-variable attention module. Considering the computational complexity, a common skip connection structure is set between E1 and D1; The processing process is as follows: The output feature of the fifth encoding layer E5 First, the output features are obtained by upsampling with bilinear interpolation and 1×1 convolution. H3=2*H4,W3=2*W4,C4=C5 / 2; then the features Input to the cross-variable attention module In the output feature Then, the feature and Splice them together in the dimension direction and output features As the input of the encoding layer D4; the rest of the jump connection structure based on the cross-variable attention module and The calculation process and Stay consistent; Step 5.3, build the decoder Between the fourth coding layer E4 and the fourth decoding layer D4 Module output characteristics Input to D4 for further processing; D (4,3,2) The layers are composed of only one double convolutional module with residual connection, which can be written as In the D1 decoding layer, there are two residual connected dual convolution modules, which can be respectively denoted as exist The module is followed by a 1×1 convolutional layer whose output dimension is the number of segmentation targets, and finally the probability distribution in the dimensional direction is performed through a softmax layer. In the segmentation task of subarachnoid hemorrhage lesions, the segmentation target is only one type of hemorrhagic lesions, so the sigmoid layer is used to calculate the probability that the element is a lesion point. Between each decoding layer, a bilinear interpolation upsampling module and a 1×1 convolutional module are set.

6. The method for segmenting subarachnoid hemorrhage lesions based on UDT according to claim 1, characterized in that: The loss function used in training in step 6 is the binary cross entropy loss function, and its specific formula is as follows: bceloss(x ij ,y ij )=-[y ij ·log(x ij )+(1-y ij )·log(1-x ij )] (9) Formula (9) calculates the element x in the i-th row and j-th column of the probability map ij ∈{p|p∈[0,1], p is a decimal} and its corresponding single label y ij ∈{0,1}, the binary cross entropy loss is calculated by H×W bceloss(x ij ,y ij ) to obtain the binary cross entropy loss between the UDT output probability map and its corresponding label, H and W represent the height and width of the label image respectively, and HxW refers to the total number of elements in the label image; according to BCELoss(x,y), the back propagation algorithm is used to update the internal parameters of the model.

7. The method for segmenting subarachnoid hemorrhage lesions based on UDT as claimed in claim 1, characterized in that: The specific implementation of step 1 includes the following sub-steps: Step 1.1, using ITK-SNAP software, set the window width and window level to 80Hu and 50Hu respectively, select the CT slice containing the subarachnoid hemorrhage lesion in the z-axis direction, convert it into PNG format images for export; Step 1.2: Under the guidance of experts, the labeling tool Labelme was used to manually label the subarachnoid hemorrhage lesion areas in the CT images to obtain label data and complete the construction of the subarachnoid hemorrhage dataset. The size of each CT image is 3 x 512 x 512, and the size of the label data is 512 x 512. Subsequently, the dataset was randomly divided into a training set and a test set, with a size of 210 and 80 images, respectively.

8. The method for segmenting subarachnoid hemorrhage lesions based on UDT as claimed in claim 1, characterized in that: The specific implementation of step 7 includes the following sub-steps: Step 7.1: Convert the probability map output by UDT into a mask map UDT model receiving characteristics After the input, the output probability map C out is the number of categories of the segmented target. In the SAH lesion segmentation task, C out =1, the probability map X out Convert to mask image mask to facilitate the intuitive display of arachnoid hemorrhage lesions; the specific conversion formula is as follows: In the above formula, p ij Represents the probability graph X out The probability value of the bleeding lesion in the i-th row and j-th column, r ij Represents the pixel value of the i-th row and j-th column of the mask image mask; Step 7.2: Calculate segmentation evaluation index using mask image and labeled data All the data test-X in the test set i , i∈[1,2,3,...,N], N is the size of the test set, which is input into the trained UDT model and the corresponding probability maps are output respectively These probability maps are then transformed into Convert to mask i ; By comparing the mask i And the corresponding label label i The relevant information is used to calculate the segmentation evaluation index index-k i , k∈[1,2,...,K], K is the number of categories of indicators, and then find the average value of these evaluation indicators index-k i-avg As the final result, the segmentation performance of the UDT model is evaluated.

9. The method for segmenting subarachnoid hemorrhage lesions based on UDT as claimed in claim 1, characterized in that: Dice and Iou are selected as the evaluation indicators of the model on the subarachnoid hemorrhage test set. The calculation formulas of each evaluation indicator are as follows: In the above formula, TP means true positive, that is, the predicted value and the true value are both 1; TF means true negative, that is, the predicted value and the true value are both 0; FP means false positive, that is, the predicted value is 1, but the true value is 0; FN means false negative, that is, the predicted value is 0, but the true value is 1.

Citation Information

Patent Citations

  • MU-Net-based intracranial hemorrhage focus segmentation algorithm applied to CT image

    CN113160232A

  • Tumor focus area semantic segmentation method and system based on deep learning

    CN114549394A