Pathological image analysis method based on cross-scale spatial constraint fusion and local perception

By combining cross-scale spatial constraint fusion with local perception, and utilizing techniques such as bidirectional cross attention and Hadamard product, the problem of insufficient utilization of multi-resolution information in pathological image analysis is solved, the stability and accuracy of feature representation are improved, and the workload and error rate of manual inspection are reduced.

CN120656169AActive Publication Date: 2025-09-16NANJING UNIV OF INFORMATION SCI & TECH

Patent Information

Application Number
CN202511174076.0
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-08-21
Publication Date
2025-09-16
Estimated Expiration
2045-08-21

AI Technical Summary

Technical Problem

Existing pathology image analysis methods fail to fully utilize the instance connections between different spatial scales and ignore multi-resolution information, resulting in insufficient feature aggregation and lack of local information fusion, making manual inspection labor-intensive, time-consuming and error-prone.

Method used

A cross-scale spatial constraint fusion and local perception method is adopted to extract features through a self-supervised pathology basic model, and feature fusion is performed using bidirectional cross attention and Hadamard product. Combined with residual connection and local perception enhancement modules, high-order semantic information is captured and local information is introduced to improve feature representation capabilities.

Benefits of technology

It improves the stability, accuracy and efficiency of pathology image processing, effectively integrates features of different scales, and reduces the workload and error rate of manual inspection.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120656169A_ABST
    Figure CN120656169A_ABST
Patent Text Reader

Abstract

The invention provides a pathological image analysis method based on cross-scale spatial constraint fusion and local perception. The method comprises the steps of 1, data preprocessing and feature extraction; step 2, executing a two-way fusion strategy based on spatial constraint to obtain fused enhanced features; step 3, capturing high-order semantic information between scales by using a bilinear fusion mode based on a Hadamard product; 4, performing residual connection on the enhanced features and the fused features to serve as input of a 10-time branch and a 20-time branch; 5, remodeling the features after residual connection into a two-dimensional shape, and inputting three convolutional layers which are arranged in a layered manner and expanded layer by layer; and 6, further performing gating adaptive fusion on the global semantic features obtained after the 10-time branches and the 20-time branches are subjected to the step 5. On the basis of easy deployment, feature representation with high expression ability is obtained, information between branches of different scales is fully utilized, and better performance is obtained in downstream tasks.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention belongs to the field of image processing technology, and in particular relates to a pathological image analysis method based on cross-scale spatial constraint fusion and local perception. Background Art

[0002] Pathological examination is widely considered the "gold standard" for clinical tumor diagnosis. Advances in whole-slide imaging technology have enabled pathologists to manually inspect tumors using whole-slide images (WSIs). However, because each WSI typically contains billions of pixels (e.g., 50,000 x 50,000), manual inspection is labor-intensive, time-consuming, costly, and error-prone. With the rapid development of whole-slide imaging and deep learning technologies, the potential for computer-assisted clinical diagnosis and digital pathology is rapidly growing. This development has made digital pathology a promising research field. However, using deep learning for WSI biopsy diagnosis faces numerous challenges, primarily due to the large amount of data and the lack of pixel-level annotations. To address this challenge, WSI analysis is formulated as a weakly supervised learning problem. However, existing methods typically focus solely on WSIs at a single resolution, neglecting important multi-resolution information. Multi-resolution WSI analysis has garnered increasing attention in recent years, but these methods fail to fully exploit the inherent connections between instances at different spatial scales, suffer from insufficient directionality, and fail to fully utilize local information in feature aggregation. Summary of the Invention

[0003] Purpose of the invention: The technical problem to be solved by the present invention is to address the deficiencies of the existing technology and provide a pathological image analysis method based on cross-scale spatial constraint fusion and local perception, which fully integrates the features between different scales and further introduces local information at the aggregation level for enhancement, thereby obtaining a more expressive feature representation and improving the stability, accuracy and efficiency of pathological image processing.

[0004] The method comprises the following steps: Step 1: Data preprocessing and feature extraction: A universal self-supervised pathology basic model is used to perform non-overlapping sliding window feature extraction on pathology images at low and high resolutions, obtaining features and corresponding spatial indices. The area of ​​the high-resolution image unit is 1 / 4 of the low-resolution unit, satisfying the spatial mapping relationship. The low resolution refers to 10x magnification, approximately 1.0 μm / pixel, for evaluating the range of tumor infiltration; the high resolution refers to 20x magnification, approximately 0.5 μm / pixel, for evaluating cellular heterogeneity.

[0005] Step 2: Execute a bidirectional fusion strategy based on spatial constraints. Construct feature groups based on the spatial index mapping relationship between 10x and 20x. Each feature group contains 10x original features and corresponding 20x original features. Perform bidirectional asymmetric fusion on the 10x original features and corresponding 20x original features after spatial constraints. In each feature group, perform bidirectional cross attention to simulate top-down and bottom-up feature interactions. First, perform an attention operation from 10x features to 20x features. The 10x features are used as queries and the 20x features are used as keys and values ​​to obtain the fused enhanced features X. S* ; Then the attention operation from 20 times the feature to 10 times the feature is performed, the 20 times the feature is used as the query, and the 10 times the feature is used as the key and value to obtain the fused enhanced feature X L* Since the number of 20-fold features in the feature group is 4 times that of 10-fold features, in order to ensure the consistency of feature dimensions in subsequent calculations, the fused enhanced features X L* Perform average pooling; Step 3: For the fused enhanced feature X S* and X L* , a bilinear fusion method based on Hadamard product is used to further capture the high-order semantic information between scales. First, the fused enhanced features X S* and X L* Use a learnable linear layer to perform linear projection, and then multiply the two linearly projected features by Hadamard product to obtain 10 times and 20 times fused features; Step 4: In order to fully fuse the multi-resolution semantic information while maintaining the unique semantic information of a single resolution, the 10x enhanced features and 20x enhanced features are residually connected with the 10x and 20x fused features respectively. The two residually connected features are used as the input of the 10x branch and the 20x branch respectively for subsequent feature aggregation; Step 5: Reshape the features after the two residual connections obtained in step 4 from a one-dimensional shape to a two-dimensional shape, and input three hierarchically arranged convolution layers. The first layer is point-by-point convolution, and the second and third layers are depth-separable convolutions. Due to the increase in the size of the convolution kernel, the receptive field is gradually expanded. Each layer of convolution outputs information from a different receptive field. Then, the query Q, key K, and value V output by each layer are rearranged to form the final query Q, key K, and value V containing multi-scale local prior knowledge, thereby introducing local information into the global information obtained by self-attention. In step 6, the global semantic features obtained by the 10x branch and the 20x branch in step 5 are further gated and adaptively fused, which further enhances the semantic features of the WSI at different scales at the global level.

[0006] In step 1, pathology images are obtained from the public dataset CAMELYON 16, the BRACS dataset, and the private dataset CBCGA. The public dataset CAMELYON16 is constructed based on in-depth analysis of a large number of digital pathology slides. This dataset was jointly developed by the European Organization for Research and Treatment of Cancer (EORTC) and the Netherlands Cancer Institute (NKI) to provide a standardized training and testing platform for computer-aided diagnosis systems. Each pathology image is annotated with the tumor area to ensure high data quality and accuracy; The BRACS dataset contains annotated hematoxylin and eosin (H&E)-stained histopathology images. The dataset was created under an agreement between the Institute for High Performance Computing and Networking (ICAR) of the Italian National Research Council (CNR) and IBM Research Zurich. Each full-length slide and its corresponding region of interest were annotated by three expert pathologists. The private dataset CBCGA was collected by the Shanghai Cancer Center of Fudan University and annotated by professional pathologists.

[0007] Adaptive threshold segmentation (Otsu method) is used to obtain the initial binary mask of the pathological image, and morphological post-processing such as inversion, hole filling, closing operation, and area threshold filtering is performed in sequence to achieve effective area segmentation of the pathological tissue image. Subsequently, a sliding window is used to extract non-overlapping fixed-size image blocks in the effective area, and the image blocks are input into the public pre-trained pathology basic model UNI for feature extraction to obtain low-resolution feature X S and high-resolution features X L , save the features and the spatial index of the features; For the low-resolution feature X S Spatial index C S and high-resolution features X L Spatial index C L , the feature group is constructed by the following mapping function: , Among them, Group x Represents the feature group after mapping. Mapping is the mapping function. By L Scaled by the scaling factor γ, it is similar to the low-resolution spatial index C S Align, so that each set of low-resolution features X S Strictly aligned to a specific high-resolution feature X L .

[0008] In step 2, a bidirectional cross attention (CA) operation is used within the feature group to simulate top-down and bottom-up feature interactions; Low-resolution features present coarse-grained semantic information at the tissue scale (such as blood vessels and glands), and find the high-resolution features it focuses on to integrate fine-grained spatial semantic information.

[0009] The low-resolution feature is used as the query Q, the high-resolution feature is used as the key K and the value V to perform the cross-attention operation, which is expressed as: , Where softmax is a normalized exponential function; T represents transposition, X S represents the original 10-fold features, K Li Indicates that the ith 20-fold feature is used as a key, V Li represents the i-th 20-fold feature as the value; Q S Indicates that 10 times the features are used as queries, and d represents the dimension of each attention head of the query vector and key vector; High-resolution features present fine-grained features at the cellular scale (e.g., nucleus and microenvironment). Within a feature group, it only focuses on the corresponding low-resolution features and uses high-resolution features as anchors to integrate coarse-grained spatial semantic information. The high-resolution feature is used as the query Q, and the low-resolution feature is used as the key K and value V to perform the cross-attention operation. Due to the spatial index relationship between low-resolution and high-resolution features, the low-resolution features and high-resolution features have a one-to-many relationship. Specifically, a 10x feature corresponds to four 20x features. In each feature group, the following operation is repeated four times: after each low-resolution feature is fused with the corresponding high-resolution feature, it is residually connected with the original feature to preserve the semantic information of the original feature. Then, the four enhanced features obtained are average pooled to obtain the final high-resolution enhanced feature in the group, which is expressed as: , , where X Li represents the i-th 20-fold feature, the value range of i is {1,2,3,4}, Q Li Indicates that the 20th feature of i is used as the query, K S Indicates that 10 times the feature is used as the key, V S Indicates that 10 times the features are used as values.

[0010] In step 3, the obtained low-resolution enhanced feature X S* and high-resolution enhancement features X L* , processed using two learnable linear layers: , , Among them, and are two learnable linear functions, and the low-resolution enhanced features X are obtained by learning two linear layers. S* The projection feature h S and high-resolution enhancement features X L* The projection feature h L ; The Hadamard product between projected features is calculated using the following formula: , in represents an element-wise multiplication operation, Indicates fusion features.

[0011] In step 4, in order to retain the semantic information of the enhanced features of each scale on the basis of introducing the fusion feature, the residual connection is introduced to With 10 times enhanced feature X S* and 20 times enhanced feature X L* Add together, the formula is: , , in represents 10-fold branch features, Indicates 20-fold branch features.

[0012] In step 5, the 10-fold branch feature Z obtained in step 4 is S and 20-fold branch feature Z L Perform Transformer-based aggregation and establish a local perception enhancement module, which is used to explicitly model local spatial prior knowledge before global aggregation. The local perception enhancement module uses three layered convolution kernels. The first layer uses point-by-point convolution with minimum receptive field, and the second and third layers use depthwise separable convolution. The second layer consists of depthwise convolution with a kernel of 3×3 and point-by-point convolution, and the third layer consists of depthwise convolution with a kernel of 5×5 and point-by-point convolution. The output features of each layer represent local information collected from different receptive fields. The features obtained in each layer are then rearranged to obtain the final query Q, key K, and value V. Due to the variation in slide and tissue area, the number of patch tokens in the corresponding sequence is X p_token The number will also change, and the absolute position information is provided to the convolution by zero padding; then the patch token X in the sequence p_token ∈R N×D Rearrange into , where N represents the sequence length, represents the side length of the rearranged two-dimensional rectangle, D represents the feature dimension, X p represents the rearranged patch tokens; R represents the real number space; X p Through three layers of convolutional layers with gradually increasing receptive fields: , , , , , Among them, PWConv1, PWConv2, and PWConv3 represent point-by-point convolutions in three layers respectively, DWConv2 represents a depth convolution with a kernel of 3×3, and DWConv3 represents a depth convolution with a kernel of 5×5. Represents the features after the first layer of point-by-point convolution, Indicates F p1 Features after the second layer of deep convolution; Indicates F p2 After the second layer of point-by-point convolution, the features represents F* p2 After the third layer of deep convolution, the features Indicates F p3 Features after the third layer of point-by-point convolution; F p1 、F* p2 and F* p3 Represents the local features of three different scales obtained. The features are divided into three parts in the feature dimension and rearranged to form the query Q p , key K p Sum : , , , , in represents the output feature of the i-th convolutional layer, The query Q represents the features output by the i-th convolutional layer, The key K represents the feature output of the i-th convolutional layer, Represents the value V of the feature output of the i-th convolutional layer; Concat represents the connection operation; Then, query Q p , key K p Sum Expand in the spatial dimension to form the final Qp ,K p ,V p ∈R N×D ; The local perception enhancement module can process various auxiliary tokens, including class tokens or distilled tokens, and convert class tokens X c ∈R 1×D After three layers of point-by-point convolution, local information at multiple scales is obtained. The formula is: , , , Among them F c1 ,F c2 ,F c3 ∈R 1×D Represents X c After the linear projection of the output of the first layer of point-by-point convolution layer, the linear projection of the output of the second layer of point-by-point convolution layer, and the linear projection of the output of the third layer of point-by-point convolution layer, the output F c1 ,F c2 ,F c3 The feature dimension is divided into three parts and rearranged. The formula is: , , , , in represents the linear projection of the output of the i-th point-by-point convolutional layer, The query Q represents the features output by the i-th point-wise convolutional layer, The key K representing the feature output of the i-th point-by-point convolutional layer, The value V representing the feature output by the i-th point-by-point convolutional layer; Then, rearrange to form query Q c , key K c Sum V c ∈R 1×D .

[0013] Step 5 also includes: P ,K P ,V P ∈R N×D and Q C ,K C V C ∈R 1×D By making connections and constructing the complete input of the attention mechanism, including local features from different receptive fields, the final Q, K, V becomes: , , , where Q,K,V∈R (N+1)×D ; 10-fold branch and 20-fold branch respectively obtained highly expressive class token C 10 and C 20 , C 10 ∈R 1×D , C 20 ∈R 1×D .

[0014] Step 6 includes: using gated adaptive fusion mechanism to combine C 10 、C 20 Integrate into the final decision representation: First, C 10 、C 20 Connect into a joint representation C concat ∈R 1×2D , will jointly represent C concat Feed it to a linear gating function GatedNet to generate a fusion weight vector g=[g1,g2], where g1 and g2 are the gating weights output by the linear gating function GatedNet, which are used to adjust the 10-fold branch features in the final fusion feature C final The ratio and 20 times branch features in the final fusion feature C final The final fusion feature is obtained by weighted summation, and then the prediction result is obtained by multi-layer perceptron MLP and softmax activation function. The formula is: , , , , Using the cross entropy loss function L, the formula is: , where Y ij It is a label at the pathological tissue section level. is the corresponding prediction result, M is the number of patients, and C is the number of categories.

[0015] The present invention also provides an electronic device, comprising a processor and a memory, wherein the memory stores program code, and when the program code is executed by the processor, the processor executes the steps of the method.

[0016] The present invention also provides a storage medium storing a computer program or instruction, which executes the steps of the method when the computer program or instruction is run on a computer.

[0017] Compared with the existing technology, the present invention has the following beneficial effects: (1) The present invention utilizes a spatially constrained bidirectional fusion strategy to enhance the directionality and sensitivity of feature fusion, avoids spatial confusion of features, effectively fuses features at different scales, and removes interference from other features.

[0018] (2) By further performing bilinear Hadamard product fusion on the bidirectionally fused features, high-order semantic information at two scales is further captured to guide the aggregation of subsequent features.

[0019] (3) By introducing the local perception enhancement module, a multi-layer lightweight convolutional structure is used to obtain local information under different receptive fields, and the global aggregation of the Transformer is integrated to obtain a feature representation that combines local and global information.

[0020] (4) The proposed method achieves competitive performance on camelyon16, BRACS, and CBCGA. BRIEF DESCRIPTION OF THE DRAWINGS

[0021] Figure 1 This is the overall framework diagram of the method of the present invention.

[0022] Figure 2 This is a diagram of the spatially constrained bidirectional cross-attention structure of the method of the present invention.

[0023] Figure 3 This is a structural diagram of the local perception enhancement module of the method of the present invention.

[0024] Figure 4 Visualization of attention between multi-scale features in the spatially constrained bidirectional cross-attention of our method.

[0025] Figure 5 This is the prediction heat map of the method of the present invention. DETAILED DESCRIPTION

[0026] The present invention will be further described below in conjunction with the accompanying drawings and specific embodiments, and the above and / or other advantages of the present invention will become more apparent.

[0027] An embodiment of the present invention provides a pathological image analysis method based on cross-scale spatial constraint fusion and local perception, comprising the following steps: Step 1: Data preprocessing and feature extraction: A universal self-supervised pathology basic model is used to perform non-overlapping sliding window feature extraction on pathology images at low and high resolutions, obtaining features and corresponding spatial indices. The area of ​​the high-resolution image unit is 1 / 4 of the low-resolution unit, satisfying the spatial mapping relationship. The low resolution refers to 10x magnification, approximately 1.0 μm / pixel, for evaluating the range of tumor infiltration; the high resolution refers to 20x magnification, approximately 0.5 μm / pixel, for evaluating cellular heterogeneity.

[0028] Step 2: Execute a bidirectional fusion strategy based on spatial constraints. Construct feature groups based on the spatial index mapping relationship between 10x and 20x. Each feature group contains 10x original features and corresponding 20x original features. Perform bidirectional asymmetric fusion on the 10x original features and corresponding 20x original features after spatial constraints. In each feature group, perform bidirectional cross attention to simulate top-down and bottom-up feature interactions. First, perform an attention operation from 10x features to 20x features. The 10x features are used as queries and the 20x features are used as keys and values ​​to obtain the fused enhanced features X. S* ; Then the attention operation from 20 times the feature to 10 times the feature is performed, the 20 times the feature is used as the query, and the 10 times the feature is used as the key and value to obtain the fused enhanced feature X L* Since the number of 20-fold features in the feature group is 4 times that of 10-fold features, in order to ensure the consistency of feature dimensions in subsequent calculations, the fused enhanced features X L* Perform average pooling; Step 3: For the fused enhanced feature X S* and X L* , a bilinear fusion method based on Hadamard product is used to further capture the high-order semantic information between scales. First, the fused enhanced features X S* and X L* Use a learnable linear layer to perform linear projection, and then multiply the two linearly projected features by Hadamard product to obtain 10 times and 20 times fused features; Step 4: In order to fully fuse the multi-resolution semantic information while maintaining the unique semantic information of a single resolution, the 10x enhanced features and 20x enhanced features are residually connected with the 10x and 20x fused features respectively. The two residually connected features are used as the input of the 10x branch and the 20x branch respectively for subsequent feature aggregation; Step 5: Reshape the features after the two residual connections obtained in step 4 from a one-dimensional shape to a two-dimensional shape, and input three hierarchically arranged convolution layers. The first layer is point-by-point convolution, and the second and third layers are depth-separable convolutions. Due to the increase in the size of the convolution kernel, the receptive field is gradually expanded. Each layer of convolution outputs information from a different receptive field. Then, the query Q, key K, and value V output by each layer are rearranged to form the final query Q, key K, and value V containing multi-scale local prior knowledge, thereby introducing local information into the global information obtained by self-attention. In step 6, the global semantic features obtained by the 10x branch and the 20x branch in step 5 are further gated and adaptively fused, which further enhances the semantic features of the WSI at different scales at the global level.

[0029] In step 1, pathology images are obtained from the public dataset CAMELYON 16, the BRACS dataset, and the private dataset CBCGA. The public dataset CAMELYON16 is constructed based on in-depth analysis of a large number of digital pathology slides. This dataset was jointly developed by the European Organization for Research and Treatment of Cancer (EORTC) and the Netherlands Cancer Institute (NKI) to provide a standardized training and testing platform for computer-aided diagnosis systems. Each pathology image is annotated with the tumor area to ensure high data quality and accuracy; The BRACS dataset contains annotated hematoxylin and eosin (H&E)-stained histopathology images. The dataset was created under an agreement between the Institute for High Performance Computing and Networking (ICAR) of the Italian National Research Council (CNR) and IBM Research Zurich. Each full-length slide and its corresponding region of interest were annotated by three expert pathologists. The private dataset CBCGA was collected by the Shanghai Cancer Center of Fudan University and annotated by professional pathologists.

[0030] Adaptive threshold segmentation (Otsu method) is used to obtain the initial binary mask of the pathological image, and morphological post-processing such as inversion, hole filling, closing operation, and area threshold filtering is performed in sequence to achieve effective area segmentation of the pathological tissue image. Subsequently, a sliding window is used to extract non-overlapping fixed-size image blocks in the effective area, and the image blocks are input into the public pre-trained pathology basic model UNI for feature extraction to obtain low-resolution feature X S and high-resolution features X L , save the features and the spatial index of the features; For the low-resolution feature X S Spatial index C S and high-resolution features X L Spatial index C L, the feature group is constructed by the following mapping function: , Among them, Group x Represents the feature group after mapping. Mapping is the mapping function. By L Scaled by the scaling factor γ, it is similar to the low-resolution spatial index C S Align, so that each set of low-resolution features X S Strictly aligned to a specific high-resolution feature X L .

[0031] In step 2, a bidirectional cross attention (CA) operation is used within the feature group to simulate top-down and bottom-up feature interactions; Low-resolution features present coarse-grained semantic information at the tissue scale (such as blood vessels and glands), and find the high-resolution features it focuses on to integrate fine-grained spatial semantic information.

[0032] The low-resolution feature is used as the query Q, the high-resolution feature is used as the key K and the value V to perform the cross-attention operation, which is expressed as: , Where softmax is a normalized exponential function; T represents transposition, X S represents the original 10-fold features, K Li Indicates that the ith 20-fold feature is used as a key, V Li represents the i-th 20-fold feature as the value; Q S Indicates that 10 times the features are used as queries, and d represents the dimension of each attention head of the query vector and key vector; High-resolution features present fine-grained features at the cellular scale (e.g., nucleus and microenvironment). Within a feature group, it only focuses on the corresponding low-resolution features and uses high-resolution features as anchors to integrate coarse-grained spatial semantic information. The high-resolution feature is used as the query Q, and the low-resolution feature is used as the key K and value V to perform the cross-attention operation. Due to the spatial index relationship between low-resolution and high-resolution features, the low-resolution features and high-resolution features have a one-to-many relationship. Specifically, a 10x feature corresponds to four 20x features. In each feature group, the following operation is repeated four times: after each low-resolution feature is fused with the corresponding high-resolution feature, it is residually connected with the original feature to preserve the semantic information of the original feature. Then, the four enhanced features obtained are average pooled to obtain the final high-resolution enhanced feature in the group, which is expressed as: , , where X Li represents the i-th 20-fold feature, the value range of i is {1,2,3,4}, Q Li Indicates that the 20th feature of i is used as the query, K S Indicates that 10 times the feature is used as the key, V S Indicates that 10 times the features are used as values.

[0033] In step 3, the obtained low-resolution enhanced feature X S* and high-resolution enhancement features X L* , processed using two learnable linear layers: , , Among them, and are two learnable linear functions, and the low-resolution enhanced features X are obtained by learning two linear layers. S* The projection feature h S and high-resolution enhancement features X L* The projection feature h L ; The Hadamard product between projected features is calculated using the following formula: , in represents an element-wise multiplication operation, Indicates fusion features.

[0034] In step 4, in order to retain the semantic information of the enhanced features of each scale on the basis of introducing the fusion feature, the residual connection is introduced to With 10 times enhanced feature X S* and 20 times enhanced feature X L* Add together, the formula is: , , in represents 10-fold branch features, Indicates 20-fold branch features.

[0035] In step 5, the 10-fold branch feature Z obtained in step 4 is S and 20-fold branch feature Z LPerform Transformer-based aggregation and establish a local perception enhancement module, which is used to explicitly model local spatial prior knowledge before global aggregation. The local perception enhancement module uses three layered convolution kernels. The first layer uses point-by-point convolution with minimum receptive field, and the second and third layers use depthwise separable convolution. The second layer consists of depthwise convolution with a kernel of 3×3 and point-by-point convolution, and the third layer consists of depthwise convolution with a kernel of 5×5 and point-by-point convolution. The output features of each layer represent local information collected from different receptive fields. The features obtained in each layer are then rearranged to obtain the final query Q, key K, and value V. Due to the variation in slide and tissue area, the number of patch tokens in the corresponding sequence is X p_token The number will also change, and the absolute position information is provided to the convolution by zero padding; then the patch token X in the sequence p_token ∈R N×D Rearrange into , where N represents the sequence length, represents the side length of the rearranged two-dimensional rectangle, D represents the feature dimension, X p represents the rearranged patch tokens; R represents the real number space; X p Through three layers of convolutional layers with gradually increasing receptive fields: , , , , , Among them, PWConv1, PWConv2, and PWConv3 represent point-by-point convolutions in three layers respectively, DWConv2 represents a depth convolution with a kernel of 3×3, and DWConv3 represents a depth convolution with a kernel of 5×5. Represents the features after the first layer of point-by-point convolution, Indicates F p1 Features after the second layer of deep convolution; Indicates F p2 After the second layer of point-by-point convolution, the features represents F* p2 After the third layer of deep convolution, the features Indicates F p3 Features after the third layer of point-by-point convolution; F p1 、F* p2 and F* p3 Represents the local features of three different scales obtained. The features are divided into three parts in the feature dimension and rearranged to form the query Qp , key K p Sum : , , , , in represents the output feature of the i-th convolutional layer, The query Q represents the features output by the i-th convolutional layer, The key K represents the feature output of the i-th convolutional layer, Represents the value V of the feature output of the i-th convolutional layer; Concat represents the connection operation; Then, query Q p , key K p Sum Expand in the spatial dimension to form the final Q p ,K p ,V p ∈R N×D ; The local perception enhancement module can process various auxiliary tokens, including class tokens or distilled tokens, and convert class tokens X c ∈R 1×D After three layers of point-by-point convolution, local information at multiple scales is obtained. The formula is: , , , Among them F c1 ,F c2 ,F c3 ∈R 1×D Represents X c After the linear projection of the output of the first layer of point-by-point convolution layer, the linear projection of the output of the second layer of point-by-point convolution layer, and the linear projection of the output of the third layer of point-by-point convolution layer, the output F c1 ,F c2 ,F c3 The feature dimension is divided into three parts and rearranged. The formula is: , , , , in represents the linear projection of the output of the i-th point-by-point convolutional layer, The query Q represents the features output by the i-th point-wise convolutional layer, The key K representing the feature output of the i-th point-by-point convolutional layer, The value V representing the feature output by the i-th point-by-point convolutional layer; Then, rearrange to form query Q c , key K c Sum V c ∈R 1×D .

[0036] Step 5 also includes: P ,K P ,V P ∈R N×D and Q C ,K C V C ∈R 1×D By making connections and constructing the complete input of the attention mechanism, including local features from different receptive fields, the final Q, K, V becomes: , , , where Q,K,V∈R (N+1)×D ; 10-fold branch and 20-fold branch respectively obtained highly expressive class token C 10 and C 20 , C 10 ∈R 1×D , C 20 ∈R 1×D .

[0037] Step 6 includes: using gated adaptive fusion mechanism to combine C 10 、C 20 Integrate into the final decision representation: First, C 10 、C 20 Connect into a joint representation C concat ∈R 1×2D , will jointly represent C concat Feed it to a linear gating function GatedNet to generate a fusion weight vector g=[g1,g2], where g1 and g2 are the gating weights output by the linear gating function GatedNet, which are used to adjust the 10-fold branch features in the final fusion feature C final The ratio and 20 times branch features in the final fusion feature C final The final fusion feature is obtained by weighted summation, and then the prediction result is obtained by multi-layer perceptron MLP and softmax activation function. The formula is: , , , , Using the cross entropy loss function L, the formula is: , where Y ij It is a label at the pathological tissue section level. is the corresponding prediction result, M is the number of patients, and C is the number of categories.

[0038] In a specific embodiment of the present invention, the method comprises the following steps: Step 1: This invention utilizes three datasets: the public dataset CAMELYON 16, the BRACS dataset, and the private dataset CBCGA. The CAMELYON 16 dataset, jointly developed by the European Organization for Research and Treatment of Cancer (EORTC) and the Netherlands Cancer Institute (NKI), is constructed based on an in-depth analysis of a large number of digitized pathology slides. The dataset aims to provide a standardized training and testing platform for computer-aided diagnosis systems. Tumor regions are annotated in each image to ensure high data quality and accuracy. The BRACS dataset contains annotated hematoxylin and eosin (H&E)-stained histopathology images. BRACS was developed under an agreement between the Institute for High Performance Computing and Networking (ICAR) under the Italian National Research Council (CNR) and IBM Research Zurich. Each full-length slide and its corresponding region of interest were annotated by three professional pathologists. The CBCGA dataset was collected by the Shanghai Cancer Center of Fudan University and annotated by professional pathologists. CAMELYON 16 contains 399 slides, BRACS contains 547 slides, and CBCGA contains 682 slides.

[0039] like Figure 1 As shown in the data preprocessing and feature extraction in

[15] , the data is preprocessed. First, adaptive threshold segmentation (Otsu method) is used to obtain the initial binary mask. Then, morphological post-processing is performed through inversion, hole filling, closing operation, and area threshold filtering to achieve effective area segmentation of the pathological tissue image. Subsequently, non-overlapping image blocks of a fixed size of 512×512 pixels are extracted in the effective area using 10x (approximately 1.0μm per pixel) and 20x (approximately 0.5μm per pixel) sliding windows, respectively. At the same time, corresponding indexes are formulated to meet the spatial constraints between 10x and 20x. The image blocks are input into the pre-trained pathology basic model UNI to extract deep features. The features and corresponding indexes are saved, and the index relationship is used for feature alignment for subsequent feature fusion. The spatial index relationship is as follows: , Among them, X S Indicates 10-fold features, C S Represents the spatial index of the corresponding feature, X L Indicates 20 times the feature, C L Indicates the spatial index of the corresponding feature, Group x It represents the feature group after index relationship mapping, and Mapping represents the mapping function.

[0040] Step 2: The present invention designs a two-way fusion strategy based on spatial constraints, such as Figure 1 In each feature group, spatially constrained bidirectional cross attention is used for feature fusion. The specific fusion process is as follows: Figure 2 As shown. The 10-fold feature f S and 20 times the feature f L1 ,f L2 ,f L3 ,f L4 As query q, another scale feature as key k and query v, the fused 10x enhanced feature f is obtained L->S and 20 times enhanced feature f S->L1 ,f S->L2 ,f S->L3 ,f S->L4 .

[0041] Step 3: For the enhanced features obtained in step 2, Figure 1 As shown in FIG, the 20 times enhanced features are average pooled to align them with the 10 times enhanced features in dimension for subsequent further fusion operations.

[0042] Step 4: For the 10-fold and 20-fold enhanced features obtained in step 3, two learnable linear layers con1×1 are used for projection respectively, and the projections are further subjected to high-order semantic interaction using Hadamard product to obtain high-order fusion features f fusion In order to retain the semantic information of 10 times and 20 times, the high-order fusion features and enhanced features are residually connected to obtain Z S and Z L , as features for further aggregation.

[0043] Step 5: For the 10-fold branch feature Z obtained in step 4 S and 20-fold branch feature Z L ,like Figure 1 As shown in FIG, a local perception enhancement module LPGM proposed in the present invention is used to perform aggregation based on the Transformer model. Figure 3As shown in the figure, a global learning parameter classification token cls is introduced to reshape the features from one-dimensional features into two-dimensional features. Three consecutive convolutional layers are used on the obtained two-dimensional features. conv1 is the first convolutional layer, which contains a 1×1 point-by-point convolution and outputs the first-layer query q1, key k1, and value v1; conv2 is the second convolutional layer, which is a depth-wise separable convolution and contains a 3×3 depth-wise convolution and a 1×1 point-by-point convolution. The output is the first-layer query q2, key k2, and value v2; conv3 is the third convolutional layer, also a depth-wise separable convolution, which contains a 5×5 depth-wise convolution and a 1×1 point-by-point convolution. The output is the first-layer query q3, key k3, and value v3. The query, key, and value obtained at each layer are rearranged to obtain the final query Q, key K, and value V. Then, the global features are obtained through multi-head attention MSA and multi-layer perceptron MLP. The global features of the 10-fold branch and the global features of the 20-fold branch are gated and adaptively fused to obtain the final representation.

[0044] The learning rate used during training is 2×10 −4 Adam optimizer with weight decay of 1×10 −5 The cosine annealing scheduler is used. The cross entropy loss function is used to evaluate the model and calculate the model loss. The model network parameters are optimized to obtain the trained case image processing model.

[0045] In order to evaluate the robustness of the model, 5-fold cross validation was used to evaluate the model effect. The present invention uses the following models as baselines to compare the model performance.

[0046] (1) ABMIL: This baseline uses an attention mechanism to calculate the attention score of each image patch and uses a simple weighted pooling operation to generate bag-level representations. (2) CLAM_SB: It enhances the local important areas of the image by introducing a class activation map (CAM) and strengthens the information interaction between image patches of different resolutions through a selective branching mechanism. (3) CLAM_MB: Based on CLAM_SB, it adds a multi-branch mechanism to process image patches from different resolutions in parallel, and optimizes the fusion of cross-scale features through a multi-branch approach. (4) Trans-MIL: It uses the self-attention mechanism of the Transformer architecture to capture the long-range dependencies between image patches. In this way, it can effectively model complex spatial relationships and adapt to the diversity and heterogeneity in pathological images. (5) DTFT-MIL: It extracts features from image patches of different resolutions through a two-layer feature distillation mechanism and fuses high- and low-level features to optimize the discriminative ability of the model. (6) IBMIL: A multi-instance learning framework based on causal intervention aims to eliminate contextual bias in pathological images through backdoor adjustment and achieve more robust and de-obfuscated bag-level classification. (7) MHIM-MIL: A multi-instance learning method that improves model robustness through a multi-head instance masking mechanism. (8) DS-MIL: A two-stream architecture is used, in which one stream uses maximum pooling to identify key instances, and the other stream calculates the distance between each instance and the key instance to evaluate the attention score.

[0047] Table 1

[0048] As shown in Table 1, the model performance is evaluated using three indicators: accuracy (acc), area under the receiver operating characteristic curve (auc), and F1 score. The method proposed in this invention outperforms all the compared baseline models on the three datasets, thus verifying the effectiveness of the present invention.

[0049] Step 6, in order to provide interpretability of the spatially constrained bidirectional cross-attention module, as Figure 4 As shown, two image patches were selected from the boundary region between tumor and non-tumor areas, as well as two image patches from the interior of the tumor. For the boundary region, the attention distribution between the 10x and 20x magnification image patches is more uneven. Attention values ​​are higher for larger tumor areas, and lower for larger tumor areas. This indicates that the fusion module prioritizes tumor areas within the boundary region, effectively capturing key information. For the interior region, the attention values ​​between the 10x and 20x magnifications are more evenly distributed, indicating that each 10x magnification feature fully utilizes the 20x magnification feature information. This demonstrates that the fusion module effectively learns information between the two scales.

[0050] Step 7, in order to provide the interpretability of the overall model, such as Figure 5Shown are two tumor histopathology images annotated by pathologists, along with their corresponding heatmaps and high-attention patches. The heatmaps show a high degree of consistency between the model's focus and the pathologists' detailed annotations, consistently focusing on key areas and enhancing its diagnostic capabilities.

[0051] The present invention provides a pathological image analysis method based on cross-scale spatial constraint fusion and local perception. There are many methods and approaches to implement this technical solution. The above is only a preferred embodiment of the present invention. It should be noted that those skilled in the art can make various improvements and modifications without departing from the principles of the present invention. Such improvements and modifications should also be considered within the scope of protection of the present invention. Any components not specified in this embodiment may be implemented using existing technologies.

Claims

1. A pathological image analysis method based on cross-scale spatial constraint fusion and local perception, characterized in that: The following steps are involved: Step 1: Data preprocessing and feature extraction: Using a self-supervised pathology foundation model, non-overlapping sliding window feature extraction is performed on pathology images at both low and high resolutions to obtain features and corresponding spatial indices. The area of ​​a high-resolution image unit is 1 / 4 of that of a low-resolution unit, satisfying the spatial mapping relationship. The low resolution refers to a 10x magnification for assessing the extent of tumor infiltration; the high resolution refers to a 20x magnification for assessing cellular heterogeneity. Step 2: Execute a bidirectional fusion strategy based on spatial constraints. Construct feature groups based on the spatial index mapping relationship between 10x and 20x. Each feature group contains 10x original features and corresponding 20x original features. Perform bidirectional asymmetric fusion on the 10x original features and corresponding 20x original features after spatial constraints. In each feature group, perform bidirectional cross attention to simulate top-down and bottom-up feature interactions. First, perform an attention operation from 10x features to 20x features. The 10x features are used as queries and the 20x features are used as keys and values ​​to obtain the fused enhanced features X. S* ; Then the attention operation from 20 times the feature to 10 times the feature is performed, the 20 times the feature is used as the query, and the 10 times the feature is used as the key and value to obtain the fused enhanced feature X L* , the fused enhanced features X L* Perform average pooling; Step 3: For the fused enhanced feature X S* and X L* , a bilinear fusion method based on Hadamard product is used to further capture the high-order semantic information between scales. First, the fused enhanced features X S* and X L* Use a learnable linear layer to perform linear projection, and then multiply the two linearly projected features by Hadamard product to obtain 10 times and 20 times fused features; Step 4: Perform residual connections on the 10-fold enhanced features and the 20-fold enhanced features with the 10-fold and 20-fold fusion features, respectively. The two residual-connected features are used as the input of the 10-fold branch and the 20-fold branch, respectively, for subsequent feature aggregation. Step 5: Reshape the features after the two residual connections obtained in step 4 from a one-dimensional shape to a two-dimensional shape, and input three hierarchical convolution layers. The first layer is point-by-point convolution, and the second and third layers are depth-separable convolution. Each convolution layer outputs information from different receptive fields. Then, the query Q, key K, and value V output by each layer are rearranged to form the final query Q, key K, and value V containing multi-scale local prior knowledge, thereby introducing local information into the global information obtained through self-attention. In step 6, the global semantic features obtained by the 10-fold branch and the 20-fold branch in step 5 are further gated and adaptively fused.

2. The method according to claim 1, characterized in that In step 1, pathological images are obtained from the public dataset CAMELYON 16, BRACS dataset, and private dataset CBCGA; Each pathology image was annotated with the tumor area; Adaptive threshold segmentation is used to obtain the initial binary mask of the pathological image, and morphological post-processing such as inversion, hole filling, closing operation, and area threshold filtering is performed in sequence to achieve effective area segmentation of the pathological tissue image. Subsequently, a sliding window is used to extract non-overlapping fixed-size image blocks in the effective area, and the image blocks are input into the pre-trained pathology basic model UNI for feature extraction to obtain low-resolution feature X S and high-resolution features X L , save the features and the spatial index of the features; For the low-resolution feature X S Spatial index C S and high-resolution features X L Spatial index C L , the feature group is constructed by the following mapping function: , Among them, Group x Represents the feature group after mapping. Mapping is the mapping function. By L Scaled by the scaling factor γ, it is similar to the low-resolution spatial index C S Align.

3. The method according to claim 2, characterized in that In step 2, a bidirectional cross attention operation is used within the feature group to simulate top-down and bottom-up feature interactions; The low-resolution feature is used as the query Q, the high-resolution feature is used as the key K and the value V to perform the cross-attention operation, which is expressed as: , Where softmax is a normalized exponential function; T represents transposition, X S represents the original 10-fold features, K Li Indicates that the ith 20-fold feature is used as a key, V Li represents the i-th 20-fold feature as the value; Q S Indicates that 10 times the features are used as queries, and d represents the dimension of each attention head of the query vector and key vector; Use high-resolution features as query Q, low-resolution features as key K and value V to perform cross-attention operation. The low-resolution features and high-resolution features have a one-to-many relationship, specifically: 10x features correspond to 4 20x features; In each feature group, the following operation is repeated four times: after each low-resolution feature is fused with the corresponding high-resolution feature, it is residually connected with the original feature to preserve the semantic information of the original feature. Then, the four enhanced features obtained are average pooled to obtain the final high-resolution enhanced feature in the group, which is expressed as: , , where X Li represents the i-th 20-fold feature, the value range of i is {1,2,3,4}, Q Li Indicates that the 20th feature of i is used as the query, K S Indicates that 10 times the feature is used as the key, V S Indicates that 10 times the features are used as values.

4. The method according to claim 3, characterized in that In step 3, the obtained low-resolution enhanced feature X S* and high-resolution enhancement features X L* , processed using two learnable linear layers: , , Among them, and are two learnable linear functions, and the low-resolution enhanced features X are obtained by learning two linear layers. S* The projection feature h S and high-resolution enhancement features X L* The projection feature h L ; The Hadamard product between projected features is calculated using the following formula: , in represents an element-wise multiplication operation, Indicates fusion features.

5. The method according to claim 4, characterized in that In step 4, residual connection is introduced to fuse features With 10 times enhanced feature X S* and 20 times enhanced feature X L* Add together, the formula is: , , in represents 10-fold branch features, Indicates 20-fold branch features.

6. The method according to claim 5, characterized in that In step 5, the 10-fold branch feature Z obtained in step 4 is S and 20-fold branch feature Z L Perform Transformer-based aggregation and establish a local perception enhancement module, which is used to explicitly model local spatial prior knowledge before global aggregation. The local perception enhancement module uses three layered convolution kernels. The first layer uses point-by-point convolution with minimum receptive field, and the second and third layers use depthwise separable convolution. The second layer consists of depthwise convolution with a kernel of 3×3 and point-by-point convolution, and the third layer consists of depthwise convolution with a kernel of 5×5 and point-by-point convolution. The output features of each layer represent local information collected from different receptive fields. The features obtained in each layer are then rearranged to obtain the final query Q, key K, and value V. The patch token X in the sequence p_token ∈R N×D Rearrange into , where N represents the sequence length, represents the side length of the rearranged two-dimensional rectangle, D represents the feature dimension, X p represents the rearranged patch tokens; R represents the real number space; X p Through three layers of convolutional layers with gradually increasing receptive fields: , , , , , Among them, PWConv1, PWConv2, and PWConv3 represent point-by-point convolutions in three layers respectively, DWConv2 represents a depth convolution with a kernel of 3×3, and DWConv3 represents a depth convolution with a kernel of 5×5. Represents the features after the first layer of point-by-point convolution, Indicates F p1 Features after the second layer of deep convolution; Indicates F p2 After the second layer of point-by-point convolution, the features represents F* p2 After the third layer of deep convolution, the features Indicates F p3 Features after the third layer of point-by-point convolution; F p1 、F* p2 and F* p3 Represents the local features of three different scales obtained. The features are divided into three parts in the feature dimension and rearranged to form the query Q p , key K p Sum : , , , , in represents the output feature of the i-th convolutional layer, The query Q represents the features output by the i-th convolutional layer, The key K represents the feature output of the i-th convolutional layer, Represents the value V of the feature output of the i-th convolutional layer; Concat represents the connection operation; Then, query Q p , key K p Sum Expand in the spatial dimension to form the final Q p ,K p ,V p ∈R N×D ; The local perception enhancement module can process various auxiliary tokens, including class tokens or distilled tokens, and convert class tokens X c ∈R 1×D After three layers of point-by-point convolution, local information at multiple scales is obtained. The formula is: , , , Among them F c1 ,F c2 ,F c3 ∈R 1×D Represents X c After the linear projection of the output of the first layer of point-by-point convolution layer, the linear projection of the output of the second layer of point-by-point convolution layer, and the linear projection of the output of the third layer of point-by-point convolution layer, the output F c1 ,F c2 ,F c3 The feature dimension is divided into three parts and rearranged. The formula is: , , , , in represents the linear projection of the output of the i-th point-by-point convolutional layer, The query Q represents the features output by the i-th point-wise convolutional layer, The key K representing the feature output of the i-th point-by-point convolutional layer, The value V representing the feature output by the i-th point-by-point convolutional layer; Then, rearrange to form query Q c , key K c Sum V c ∈R 1×D .

7. The method according to claim 6, characterized in that Step 5 also includes: P ,K P ,V P ∈R N×D and Q C ,K C V C ∈R 1×D By making connections and constructing the complete input of the attention mechanism, including local features from different receptive fields, the final Q, K, V becomes: , , , where Q,K,V∈R (N+1)×D ; 10-fold branch and 20-fold branch respectively obtained highly expressive class token C 10 and C 20 , C 10 ∈R 1×D , C 20 ∈R 1×D .

8. The method according to claim 7, characterized in that Step 6 includes: using gated adaptive fusion mechanism to combine C 10 、C 20 Integrate into the final decision representation: First, C 10 、C 20 Connect into a joint representation C concat ∈R 1×2D , will jointly represent C concat Feed it to a linear gating function GatedNet to generate a fusion weight vector g=[g1,g2], where g1 and g2 are the gating weights output by the linear gating function GatedNet, which are used to adjust the 10-fold branch features in the final fusion feature C final The ratio and 20 times branch features in the final fusion feature C final The final fusion feature is obtained by weighted summation, and then the prediction result is obtained by multi-layer perceptron MLP and softmax activation function. The formula is: , , , , Using the cross entropy loss function L, the formula is: , where Y ij It is a label at the pathological tissue section level. is the corresponding prediction result, M is the number of patients, and C is the number of categories.

9. An electronic device, characterized in that: The method comprises a processor and a memory, wherein the memory stores program codes, and when the program codes are executed by the processor, the processor is caused to perform the steps of the method according to any one of claims 1 to 8.

10. A storage medium, characterized in that: A computer program or instruction is stored, and when the computer program or instruction is run on a computer, the steps of the method according to any one of claims 1 to 8 are executed.

Citation Information

Patent Citations

  • WSI classification method and system based on key information extraction and feature fusion

    CN118470445A

  • Steel surface flaw detection method and system based on local overall context perception

    CN118864453A

  • Medical image segmentation method based on residual axial attention

    CN119229127A

  • Rapid pathological image analysis method and apparatus based on magnification-aligned transformer

    WO2025065803A1

Cited By

  • Medical image classification method and system of structure perception state space model

    CN121505366A