Gastrointestinal tumor lymph node detection method and system based on state space model

CN123015362APending Publication Date: 2026-10-30ZHONGSHAN HOSPITAL AFFILIATED TO FUDAN UNIV XIAMEN HOSPITAL
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202610891228.7
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2026-06-18
Publication Date
2026-10-30

AI Technical Summary

Technical Problem

传统算法对图像染色差异和背景噪声敏感,难以适应淋巴结形态与大小的多样性;深度学习模型则受限于卷积操作的局部感受野特性,无法有效捕捉淋巴结与远距离粘连组织之间的长程空间依赖关系,导致对不规则形态和弱边界区域的表征能力不足,难以兼顾全局语义信息与局部细节特征的提取

Benefits of technology

(1)本发明通过状态空间模块对病理图像进行长程依赖建模,能够有效捕捉淋巴结与周围粘连组织之间的全局空间关系,克服了传统卷积网络感受野受限的问题,从而在淋巴结边界模糊、与脂肪组织融合的场景下实现更精确的分割。

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN123015362A_ABST
    Figure CN123015362A_ABST
Patent Text Reader

Abstract

The application discloses a kind of based on state space model's gastrointestinal tumor lymph node detection method and system, by obtaining gastrointestinal tumor postoperative lymph node staining pathology image, the following processing is executed to pathology image: using the encoder comprising multistage state space module encodes pathology image, extracts different scale deep pathological features, executes pathological feature screening convolution to the obtained encoding feature map, the feature map after screening is flattened into one-dimensional sequence, by at least including multi-direction scanning strategy of bidirectional snake shape traversal path and cross diagonal traversal path, generate multiple direction feature sequence and carry out splicing and aggregation, output aggregated feature sequence;Using the decoder comprising multistage state space module decodes aggregated feature sequence, outputs lymph node segmentation result, realizes automatically, accurately and efficiently segmented gastrointestinal tumor postoperative lymph node HE staining pathology image, enhances the segmentation robustness in boundary fuzzy and background interference scene.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of medical image processing and digital pathology analysis technology, and more specifically, to a method and system for detecting lymph nodes in gastrointestinal tumors based on a state-space model. Background Technology

[0002] In postoperative pathological evaluation of gastrointestinal tumors, including esophageal cancer, gallbladder cancer, gastric cancer, pancreatic cancer, and colorectal cancer, accurate determination of lymph node metastasis is crucial for tumor staging, prognostic assessment, and treatment planning. This evaluation process consists of two interdependent steps: the primary step is the precise identification and segmentation of lymph nodes in the pathological sections, while subsequent steps involve the detection and qualitative analysis of metastatic lesions based on the segmentation results. The accuracy of lymph node segmentation directly determines the reliability of the entire evaluation process and is a fundamental prerequisite for achieving automated and quantitative pathological analysis.

[0003] Current clinical practice primarily relies on pathologists manually segmenting hematoxylin and eosin (H&E) stained sections under a microscope, requiring them to manually delineate lymph node boundaries based on their personal experience. This manual method faces significant challenges: a single postoperative specimen from a gastrointestinal tumor typically contains numerous lymph nodes, making the segmentation process time-consuming and laborious, severely slowing down diagnostic efficiency; simultaneously, postoperative lymph nodes often adhere to surrounding fat and fibrous tissue, resulting in indistinct boundaries. The segmentation results are highly dependent on the physician's subjective experience, with significant differences in segmentation between different physicians or even within the same physician at different times, compromising the objectivity and consistency of diagnostic results.

[0004] Although attempts have been made to automate segmentation using traditional image processing algorithms such as the watershed method or level set method, as well as general deep learning models such as the U-Net architecture, these methods have inherent limitations when processing postoperative lymph node images of gastrointestinal tumors: Traditional algorithms are sensitive to differences in image staining and background noise, making it difficult to adapt to the diversity of lymph node morphology and size. Deep learning models, on the other hand, are limited by the local receptive field characteristics of convolution operations, making it difficult to effectively capture the long-range spatial dependence between lymph nodes and distant adhesions. This results in insufficient representation capabilities for irregular shapes and weak boundary regions, making it difficult to extract both global semantic information and local detailed features.

[0005] Therefore, existing methods frequently suffer from segmentation boundary errors, region omissions, or over-segmentation in complex pathological scenarios, and their segmentation accuracy fails to meet clinical requirements. There is an urgent need to develop a technical solution capable of automatically, accurately, and efficiently segmenting HE-stained pathological images of lymph nodes after gastrointestinal tumor surgery. This would overcome the efficiency bottlenecks and subjective limitations of manual segmentation, enhance segmentation robustness in scenarios with blurred boundaries and background interference, and provide reliable data support for subsequent lymph node metastasis assessment. Summary of the Invention

[0006] The purpose of this invention is to provide a method and system for detecting lymph nodes in gastrointestinal tumors based on a state-space model. This method can automatically, accurately and efficiently segment HE-stained pathological images of lymph nodes after gastrointestinal tumor surgery, overcoming the efficiency bottleneck and subjective limitations of manual segmentation, and enhancing the segmentation robustness in scenarios with blurred boundaries and background interference.

[0007] To address this, the present invention provides a method for detecting lymph nodes in gastrointestinal tumors based on a state-space model, comprising the following steps: Obtain stained pathological images of lymph nodes after surgery for gastrointestinal tumors; The pathological image is input into an automatic segmentation and detection model based on a state-space model, which outputs pixel-level lymph node segmentation results. The automatic segmentation and detection model performs the following processing on the pathological image: The pathological image is encoded using an encoder containing a multi-stage state space module to extract deep pathological features at different scales and obtain an encoded feature map. Perform pathological feature screening convolution processing on the encoded feature map and output the screened feature map; The filtered feature map is flattened into a one-dimensional sequence. A multi-directional scanning strategy, including at least bidirectional serpentine traversal path and diagonal traversal path, is used to generate feature sequences in multiple directions. The feature sequences in multiple directions are then spliced ​​and aggregated to output an aggregated feature sequence. The aggregated feature sequence is decoded using a decoder containing a multi-stage state space module to gradually restore the resolution and output the lymph node segmentation result.

[0008] Preferably, the pathological feature screening convolution processing performed on the encoded feature map specifically includes the following steps: The encoded feature map is input into the first bottleneck structure for channel-dimensional compression to obtain compressed features; The compressed features are then subjected to group normalization and ReLU activation sequentially to obtain the activated features; The activation features are input into the second bottleneck structure and the third bottleneck structure respectively to obtain the first intermediate feature and the second intermediate feature; The first intermediate feature and the second intermediate feature are multiplied element by element to obtain the gated weighted feature; The gated weighted features are input into the fourth bottleneck structure for processing to obtain the transformed features; The transformed features are added element by element to the encoded feature map to output the filtered feature map.

[0009] Preferably, in the multi-directional scanning strategy, the bidirectional serpentine traversal path is generated as follows: traversing the sequence in a serpentine order along the first spatial direction, and reversing direction at the end of each row; the diagonal traversal path is generated as follows: alternating traversal of the sequence along the spatial diagonal direction; the calculation process of the aggregated feature sequence includes: The filtered feature map Flattened into a one-dimensional sequence : ; in, For the feature map input to this strategy, Flatten represents the feature flattening operation; Concatenate feature sequences from multiple directions: ; in, , This is a bidirectional serpentine path traversal sequence. , This represents a diagonal path traversal sequence, with Concat being a feature concatenation operation. The concatenated feature sequence; The spliced ​​feature sequence Perform aggregation processing: ; Here, Agg represents feature aggregation, which uses element-wise summation. This is the output aggregated feature sequence.

[0010] Preferably, the multi-directional scanning strategy further includes an adaptive weight allocation step: Extract morphological response parameters from the filtered feature map, wherein the morphological response parameters include at least one of edge continuity, orientation consistency, and local dispersion. The fusion weights of the bidirectional serpentine path and the diagonally intersecting path are calculated based on the morphological response parameters. The feature sequences generated by each path are weighted and summed according to the fusion weights to obtain the aggregated feature sequence. Specifically, when the edge continuity is higher than the first threshold, the weight of the bidirectional serpentine path is increased; when the local dispersion is higher than the second threshold, the weight of the diagonal path is increased. The morphological response parameters also include the degree of regional dispersion; when the degree of regional dispersion is higher than the third threshold, the weight of the diagonal paths is increased.

[0011] Preferably, the automatic segmentation and detection model further includes a feature fusion unit located between the encoder and the decoder, the feature fusion unit performing the following operations: Receive encoded feature maps output from at least two different stages of the encoder; The encoded feature maps are subjected to scale unification and channel alignment respectively; Attention weights are calculated using the channel attention module and the spatial attention module, respectively. The attention weights are weighted and fused with the encoded feature map to output the fused feature map; The fused feature map is then skipped and connected to the feature map of the corresponding stage in the decoder.

[0012] Preferably, the feature fusion unit further includes an attention gate module, which performs the following operations: The feature maps from the encoder and the decoder are respectively input into two parallel 1×1 convolutional branches, and each branch is sequentially processed by batch normalization and ReLU activation; The outputs of the two branches are summed element by element, and then passed through ReLU activation, pointwise convolution and Sigmoid function in sequence to generate an attention weight map; The attention weight map is multiplied element-wise with the feature map from the encoder to output the gated enhanced feature map.

[0013] Preferably, the automatic segmentation and detection model is trained using an adaptive attention segmentation loss function AALouss, which is calculated according to the following formula: AALoss DiceLoss Boundary Loss ; in: DiceLoss P represents the segmentation result predicted by the model, and G represents the true label. Boundary Loss , This is the gradient operator, used to extract edge information; The spatial mean or voxel-level value of the attention weight map output by the attention module in the automatic segmentation and detection model; α, β, and γ are preset balance coefficients.

[0014] Preferably, the multi-stage state space module in the encoder has the same network structure as the multi-stage state space module in the decoder. The state space module includes a multi-directional sensing state space network and a hybrid feedforward network. The hybrid feedforward network includes fully connected layers, depthwise separable convolutional layers, and activation function layers.

[0015] Preferably, the digestive tract tumor includes one or more of esophageal cancer, gallbladder cancer, gastric cancer, pancreatic cancer, and colorectal cancer.

[0016] Meanwhile, corresponding to the aforementioned detection method, the present invention also provides a digestive tract tumor lymph node detection system based on a state-space model, comprising: The image acquisition module is used to acquire stained pathological images of lymph nodes after gastrointestinal tumor surgery; The model storage module is used to store trained automatic segmentation and detection models based on state-space models. The segmentation and detection module is used to input the pathological image into the automatic segmentation and detection model and output pixel-level lymph node segmentation results; The automatic segmentation and detection model includes corresponding processing units for performing each step of the method described above.

[0017] As can be seen from the above, this invention effectively solves the problems of low efficiency and strong subjectivity of manual segmentation, as well as the inability of existing methods to handle blurred boundaries and background interference, by using an encoder and decoder containing multi-stage state space modules to extract deep pathological features and combining a multi-directional scanning strategy to capture long-range spatial dependencies. It has the ability to automatically, accurately and efficiently segment HE-stained pathological images of lymph nodes after gastrointestinal tumor surgery, breaking through the efficiency bottleneck and subjective limitations of manual segmentation, and enhancing the segmentation robustness in scenarios with blurred boundaries and background interference.

[0018] Specifically, compared with the prior art, the present invention has the following beneficial effects: (1) This invention performs long-range dependency modeling on pathological images through a state space module, which can effectively capture the global spatial relationship between lymph nodes and surrounding adhesion tissues, overcome the problem of limited receptive field of traditional convolutional networks, and thus achieve more accurate segmentation in scenarios where lymph node boundaries are blurred and fused with adipose tissue.

[0019] (2) The present invention performs pathological feature screening and convolution processing on the encoded feature map, and performs dynamic weighted screening of the encoded features through a gating mechanism, which can specifically enhance the morphological and texture response of the lymph node region, while suppressing background interference such as uneven staining and interstitial tissue, thereby improving the feature discrimination ability of the model under complex pathological background and reducing false positive areas.

[0020] (3) The present invention uses multi-directional scanning to perform global modeling of the flattened feature sequence. Through a multi-directional scanning strategy including at least bidirectional serpentine traversal path and cross-diagonal traversal path, feature sequences in multiple directions are generated. The feature sequences in multiple directions are spliced ​​and aggregated, which can simultaneously cover the continuous curved edges of lymph nodes (bidirectional serpentine path) and scattered satellite lesions or adhesion structures (cross-diagonal path), thereby enhancing the perception of irregular shapes and cross-regional lesions and effectively reducing segmentation omissions.

[0021] (4) The present invention further realizes the adaptive selection of scanning path. When the edge continuity is higher than the first threshold, the weight of the bidirectional serpentine path is increased. When the local dispersion is higher than the second threshold, the weight of the diagonal path is increased. This enables the model to dynamically adjust the feature extraction strategy according to the actual morphology of the lymph nodes in the input image. It not only preserves the integrity of continuous edges, but also enhances the ability to capture discrete lesions. Compared with the fixed scanning path, it has higher robustness and generalization ability.

[0022] (5) The present invention establishes an efficient cross-layer bridge between the encoder and the decoder. Through channel attention, spatial attention and attention gate mechanism, multi-scale features are selected and enhanced, so that the decoding stage can obtain deep semantic information and shallow detail information at the same time, which significantly improves the segmentation accuracy of small lymph nodes and weak boundary regions.

[0023] (6) In training the automatic segmentation and detection model, this invention employs an adaptive attention segmentation loss function AALoss, which simultaneously constrains the consistency of segmented regions (DiceLoss), the accuracy of boundaries (BoundaryLoss), and the focus of model attention during the training process. This forms a closed-loop optimization, enabling the model to actively focus on lymph node boundaries and small lesion areas, thereby obtaining clearer segmentation contours and higher recall rates during the testing phase.

[0024] In summary, through the synergistic effect of the above-mentioned technical features, this invention achieves end-to-end, high-precision, and high-efficiency automatic segmentation of postoperative hematologic malignancy (HE) pathological images of lymph nodes in gastrointestinal tumors without the need for manual intervention. This significantly reduces the workload of pathologists, improves diagnostic consistency, and provides a reliable technical foundation for subsequent automatic assessment of lymph node metastasis. Attached Figure Description

[0025] Figure 1 This is an overall architecture diagram of the automatic segmentation and detection model in an embodiment of the present invention; Figure 2 This is a schematic diagram of the hybrid feedforward network in an embodiment of the present invention; Figure 3This is a schematic diagram of the structure of the multi-directional sensing state space network in an embodiment of the present invention; Figure 4 This is a schematic diagram of the pathological feature screening and control convolution structure in an embodiment of the present invention; Figure 5 This is a schematic diagram of the path of the multi-directional sensing scanning strategy in an embodiment of the present invention; Figure 6 This is a schematic diagram of the gate module in an embodiment of the present invention; Figure 7 This is a comparison diagram of segmentation effects in an embodiment of the present invention; Figure 8 This is a visual comparison of the feature maps of pathological feature screening convolution and ordinary convolution in an embodiment of the present invention. Detailed Implementation

[0026] The technical solutions of this invention will now be clearly and completely described with reference to the accompanying drawings. Obviously, the described embodiments are merely some, not all, of the embodiments of this invention. Therefore, the following detailed description of the embodiments of the invention provided in the accompanying drawings is not intended to limit the scope of the claimed invention, but merely to illustrate selected embodiments of the invention. All other embodiments obtained by those skilled in the art based on the embodiments of this invention without inventive effort are within the scope of protection of this invention.

[0027] In the postoperative pathological evaluation of gastrointestinal tumors, accurate segmentation of lymph nodes is a crucial step in determining tumor staging and guiding adjuvant therapy, but its technical implementation faces significant challenges. Existing automated segmentation methods, when processing HE-stained pathological images of lymph nodes after gastrointestinal tumor surgery, suffer from limitations. These limitations stem from the diversity of lymph node morphology, size variations, uneven staining intensity, and blurred boundaries caused by adhesion to surrounding fat and fibrous tissue. These methods cannot effectively model the long-range spatial dependencies between lymph nodes and adhering tissues, lack the ability to represent irregular shapes and weak boundaries, and struggle to simultaneously integrate global semantic information with local details. This problem directly leads to segmentation boundary localization errors, omissions of target regions, or over-inclusion of non-target regions, thus affecting the accuracy and completeness of the segmentation results and ultimately limiting the reliability of subsequent lymph node metastasis detection and qualitative analysis.

[0028] For example, in the pathological evaluation of post-gastric cancer specimens, pathologists need to process a large number of lymph node samples. Some of these lymph nodes are highly adherent to the surrounding adipose tissue, and their boundaries appear as low-contrast, discontinuous microstructural features in HE-stained sections. Furthermore, traditional watershed algorithms, unable to distinguish the gray-scale gradations of adherent regions, result in over-segmentation. General-purpose deep learning models such as U-Net, limited by their local receptive field, struggle to capture the overall topological structure of the lymph nodes, leading to jagged boundaries or missing key areas in the segmentation results. Consequently, this segmentation defect forces physicians to repeatedly correct the segmentation boundaries when assessing lymph node metastasis, prolonging the diagnostic cycle, introducing subjective judgment bias, and affecting the consistency and traceability of pathology reports.

[0029] If the aforementioned technical issues are not resolved, inaccurate lymph node segmentation will directly lead to inaccurate tumor staging, thereby affecting the objective basis for patient prognosis assessment and potentially causing adjuvant therapy to deviate from the optimal path. Furthermore, the subjective variability and non-reproducibility of segmentation results will weaken the reliability of pathological diagnosis, hinder the standardized implementation of automated assessment processes, and ultimately limit the efficiency improvement and clinical application of postoperative pathological analysis for gastrointestinal tumors.

[0030] Example 1 (Method) This embodiment proposes a state-space model-based method for detecting lymph nodes in gastrointestinal tumors. Addressing the challenges of irregular morphology, significant scale variations, blurred boundaries, and severe adhesion to surrounding tissues in postoperative hematoxylin and eosin (HE) stained pathological sections of gastrointestinal tumor-related lymph nodes, this method constructs a multi-stage state-space feature modeling network to achieve accurate identification and pixel-level segmentation of lymph node regions in complex pathological contexts. While ensuring model feasibility, this approach focuses on enhancing the ability to screen for long-range spatial dependencies, cross-regional lesion associations, and key pathological features, making it suitable for real-world clinical digital pathology scenarios.

[0031] Specifically, the following steps are included: Obtain HE-stained pathological images of lymph nodes after gastrointestinal tumor surgery; The pathological image is input into an automatic segmentation and detection model based on a state-space model, which outputs pixel-level lymph node segmentation results. The automatic segmentation and detection model performs the following processing on the pathological image: An encoder containing a multi-stage state space module was used to encode the pathological image, extract deep pathological features at different scales, and obtain an encoded feature map. Perform pathological feature screening convolution processing on the encoded feature map and output the filtered feature map; The filtered feature map is flattened into a one-dimensional sequence. A multi-directional scanning strategy, including at least bidirectional serpentine traversal paths and diagonal traversal paths, is used to generate feature sequences in multiple directions. These feature sequences in multiple directions are then spliced ​​and aggregated to output an aggregated feature sequence. A decoder containing a multi-stage state space module is used to decode the aggregated feature sequence, gradually restore the resolution, and output the lymph node segmentation result.

[0032] For ease of understanding, the following explains some key terms in this embodiment: HE-stained pathological images of lymph nodes from gastrointestinal tumors refer to images obtained digitally through microscopic observation of lymph nodes from surgically removed tissue after gastrointestinal tumor surgery, processed using the hematoxylin-eosin (HE) staining technique. These images typically show cell nuclei stained blue or purplish-blue by hematoxylin, while the cytoplasm and extracellular matrix are stained pink or red by eosin. This type of image is commonly used in pathological diagnosis.

[0033] State-space models are models capable of capturing long-range dependencies in sequential data. They efficiently process long sequence information by mapping the input sequence to a latent state space and evolving within that space. In image processing, state-space models can be applied to convert two-dimensional image data into one-dimensional sequences and model long-range relationships between pixels on these sequences to capture global contextual information.

[0034] An automatic segmentation and detection model refers to a computer model built based on deep learning technology that can automatically identify and accurately delineate the boundaries of specific target regions (such as lymph nodes) in an image. This model is typically trained on a large amount of labeled data to learn the visual features and spatial distribution patterns of the target object, thereby achieving automated, pixel-level segmentation on new images.

[0035] In deep learning models, the encoder is typically responsible for feature extraction and dimensionality compression of the input data. It transforms the original input image into a feature representation with higher semantic information and lower spatial resolution, i.e., an encoded feature map, through a series of convolutional layers, pooling layers, or other feature extraction modules.

[0036] A multi-stage state-space module refers to a state-space processing unit integrated in the encoder or decoder in a hierarchical or multi-scale manner. Each stage's state-space module can process feature information at different scales, thereby capturing rich feature representations from local details to global context throughout the network.

[0037] Pathological feature screening convolution processing refers to a specific convolution operation performed on the encoded feature map, designed to screen, enhance, or suppress certain pathologically relevant features. This processing helps the model focus more on visual patterns related to the target (e.g., lymph nodes), reduces background noise interference, and thus improves segmentation accuracy.

[0038] A bidirectional serpentine traversal path is a scanning method that flattens a two-dimensional feature map into a one-dimensional sequence. It scans along a spatial direction (e.g., horizontally) and reverses direction at the end of each row, traversing the entire feature map in a serpentine manner. This path helps capture local correlations between adjacent rows.

[0039] Cross-diagonal traversal is another scanning method that flattens a two-dimensional feature map into a one-dimensional sequence. It alternately traverses along the diagonal direction of the feature map, thereby capturing diagonal correlation information at different spatial locations.

[0040] Multi-directional scanning strategy refers to a method that combines multiple different traversal paths (such as bidirectional serpentine traversal paths and diagonal traversal paths) to generate feature sequences. By scanning the feature map from multiple directions, spatial dependencies and structural information in different directions of the image can be captured more comprehensively.

[0041] A feature sequence is a one-dimensional data sequence obtained by flattening a two-dimensional feature map using a certain scanning strategy. This serialization operation enables state-space models to process it in order to model long-range dependencies.

[0042] Concatenation and aggregation refer to connecting (concatenating) multiple feature sequences generated through different scanning paths in a certain dimension, and then fusing (aggregating) them in a certain way (such as weighted summation, averaging, etc.) to form a unified feature representation containing multi-directional information.

[0043] The aggregated feature sequence is the final feature sequence obtained after concatenation and aggregation operations. This sequence integrates feature information from different scanning directions, providing the decoder with richer and more comprehensive context.

[0044] In deep learning models, the decoder is typically responsible for restoring the abstract features extracted by the encoder to the spatial resolution of the original input data. It gradually recovers the spatial details of the feature map through a series of upsampling layers, convolutional layers, or other feature reconstruction modules, ultimately outputting pixel-level segmentation results.

[0045] Pixel-level lymph node segmentation results refer to the image output by the model, where each pixel is classified as belonging to or not belonging to a lymph node. This result is typically presented as a binary mask that precisely delineates the boundaries of lymph nodes in the image.

[0046] This method first obtains HE-stained pathological images of lymph nodes after surgery for gastrointestinal tumors. These images can be obtained in various ways; for example, in this embodiment, a dataset of digestive system lymph node images is acquired. In this dataset, 70% of the digestive system lymph node images are used for training, and 30% of the cases are used for testing. All images are resized to 512 × 512 pixels. The original images are then read using OpenCV and converted into pixel matrices.

[0047] Subsequently, the acquired pathological images are input into an automatic segmentation and detection model based on a state-space model to output pixel-level lymph node segmentation results. This automatic segmentation and detection model can be deployed on a high-performance computing server or integrated into the software system of a pathology workstation. The model receives digital pathological images as input, and after internal processing, generates a binary mask of the same size as the original image, in which pixel values ​​marking lymph node regions are one, and pixel values ​​marking background regions are zero.

[0048] This automatic segmentation and detection model performs a series of processes on pathological images. Specifically, the model employs an encoder containing a multi-stage state space module to encode the pathological images. The encoder can consist of multiple convolutional and pooling layers, with each stage followed by a state space module to capture features at different scales. For example, the encoder can first use standard convolutional layers to extract low-level features, and then input these features into the state space module to model long-range dependencies in the feature maps. As encoding progresses, the resolution of the feature maps gradually decreases, but the semantic information gradually becomes richer, ultimately resulting in encoded feature maps.

[0049] Next, a pathological feature screening convolution process is performed on the encoded feature map, outputting a filtered feature map. This process can be implemented using one or more convolutional layers; for example, a 1x1 convolutional layer can be used to adjust the channel dimensions, or a 3x3 convolutional layer can be used to extract local spatial features. This process aims to refine the information in the encoded feature map to highlight lymph node-related features and suppress irrelevant background noise.

[0050] Then, the filtered feature maps are flattened into a one-dimensional sequence. The flattening operation converts a two-dimensional feature map into a one-dimensional vector. For example, the pixels of the feature map can be scanned row by row from left to right and top to bottom, arranging them into a long sequence. Based on this, a multi-directional feature sequence is generated using a multi-directional scanning strategy that includes at least bidirectional serpentine traversal paths and diagonal traversal paths. The bidirectional serpentine traversal path scans along the horizontal direction and reverses direction at the end of each row, capturing horizontal continuity. The diagonal traversal path scans along the diagonal of the image to capture diagonal associations at different spatial locations. These different scanning paths capture spatial information from multiple angles in the feature map. Subsequently, these multi-directional feature sequences are concatenated and aggregated to output an aggregated feature sequence. The concatenation operation connects sequences from different directions along the channel dimension, while the aggregation operation fuses these concatenated features, for example, by integrating multi-directional information through a fully connected layer or an attention mechanism.

[0051] Finally, a decoder incorporating a multi-stage state-space module decodes the aggregated feature sequence, progressively restoring the resolution and outputting the lymph node segmentation result. The decoder typically consists of a series of upsampling and convolutional layers, with a structure symmetrical to the encoder. For example, the decoder can first restore the aggregated feature sequence to the shape of a two-dimensional feature map through a fully connected layer, and then progressively increase the spatial resolution of the feature map through a series of upsampling operations (such as transposed convolution or bilinear interpolation). At each upsampling stage, a state-space module can also be integrated to continue modeling and utilizing long-range dependencies while restoring the resolution, ultimately generating pixel-level lymph node segmentation results with the same resolution as the original pathological image.

[0052] Compared to existing methods that rely on traditional image processing algorithms or general deep learning models (such as U-Net), this method, by introducing a state-space model, demonstrates a stronger advantage in processing complex pathological images.

[0053] Specifically, existing technologies often struggle to effectively model the long-range spatial dependencies between lymph nodes and surrounding adhesions in postoperative lymph node images of gastrointestinal tumors, which vary in shape, size, staining intensity, and background complexity. They also lack the ability to represent irregular shapes and weak boundaries. For example, while the traditional U-Net model performs well in medical image segmentation, its convolutional operations have limited receptive fields, requiring multiple layers of convolutions to capture long-range information, which can lead to information loss or increased computational cost.

[0054] This method integrates multi-stage state-space modules into the encoder and decoder, enabling direct and efficient modeling of long-range dependencies in images. State-space models have a natural advantage in processing sequential data; once image feature maps are serialized, the state-space module can capture the association between any two locations in the sequence, which is crucial for identifying lymph nodes with blurred boundaries and varied morphologies.

[0055] Furthermore, the pathological feature screening convolution process introduced in this method can specifically optimize the features extracted by the encoder, selecting features more relevant to lymph node identification and effectively suppressing background noise. This allows the model to focus more on key pathological information and improves the discriminative power of the features.

[0056] Furthermore, the multi-directional scanning strategy, particularly the combination of bidirectional serpentine traversal paths and diagonal traversal paths, enables the model to understand the spatial structure of the feature map from multiple dimensions. This overcomes the limitation of a single scanning direction potentially missing key spatial information. Especially for irregularly shaped lymph nodes, the splicing and aggregation of multi-directional feature sequences can provide more comprehensive contextual information, thereby significantly improving the ability to represent irregular shapes and weak boundaries.

[0057] In summary, this method, through effective modeling of long-range dependencies using a state-space model, refined processing of pathological feature screening, and comprehensive capture of complex spatial information using a multi-directional scanning strategy, jointly solves the problems of low efficiency, strong subjectivity, poor repeatability, and insufficient ability to process complex pathological images in the automatic detection of lymph nodes in gastrointestinal tumors of existing technologies. It provides a more accurate and efficient auxiliary tool for clinical pathological diagnosis.

[0058] like Figure 4 As shown, this embodiment further proposes the following steps for performing pathological feature screening and control convolution processing on the encoded feature map: The encoded feature map is input into the first bottleneck structure for channel-dimensional compression to obtain compressed features; The compressed features are then subjected to group normalization and ReLU activation sequentially to obtain the activated features; The activation features are input into the second bottleneck structure and the third bottleneck structure respectively to obtain the first intermediate feature and the second intermediate feature; The first intermediate feature and the second intermediate feature are multiplied element by element to obtain the gated weighted feature; The gated weighted features are input into the fourth bottleneck structure for processing to obtain the transformed features; The transformed features are added element by element to the encoded feature map to output the filtered feature map.

[0059] The calculation process can be expressed as follows: ; ; ; ; ; in, For input features, For the output features, LBS represents the bottleneck structure, GN represents the group normalization operation, ReLU represents the linear rectified activation function, and ⊙ represents the element-wise multiplication operation.

[0060] The first bottleneck structure effectively compresses the channel dimension of the feature map through a series of convolutional operations, thereby reducing computational cost and enabling the network to learn more compact and representative feature representations. Channel dimension compression refers to reducing the number of channels in the feature map, which can be achieved by using 1×1 convolutional layers, where the number of output channels is less than the number of input channels, or through other forms of projection operations. Compressed features are feature maps after channel dimension compression, containing the key information of the original feature map but with lower dimensionality. Group normalization is a normalization technique that divides feature channels into several groups and calculates the mean and variance independently within each group for normalization, which helps stabilize the training process, especially during mini-batch training. ReLU activation (Rectified Linear Unit) is a non-linear activation function that introduces a non-linear transformation, enabling the network to learn and express more complex patterns. Activated features are feature maps that have undergone normalization and non-linear activation processing, possessing better stability and expressive power.

[0061] The second and third bottleneck structures are similar to the first bottleneck structure; they process activation features in parallel, aiming to extract features from different angles or through different transformation paths to capture richer information. The first and second intermediate features are the outputs of these two parallel bottleneck structures, representing the results of the activation features processed through different paths. Element-wise multiplication is an operation that multiplies corresponding elements of two tensors of the same size. In neural networks, it is often used to implement gating or attention mechanisms, where one feature map can be used as a weight to modulate the other. Gated weighted features are the feature maps after element-wise multiplication; they fuse information from two parallel paths and are weighted and filtered through a gating mechanism.

[0062] The fourth bottleneck structure further processes the gated weighted features, including channel dimension recovery or deeper feature transformations, in preparation for fusion with the original encoded feature map. The transformed features are the output of the fourth bottleneck structure, containing finely filtered and enhanced feature information. Element-wise addition is a residual connection method that adds corresponding elements of the transformed features to the original encoded feature map. This helps preserve the contextual information of the original features and allows the network to learn residual mappings, thereby mitigating the vanishing gradient problem and accelerating training. The filtered feature map is the final output feature map, which, through the aforementioned fine filtering mechanism, effectively removes redundant information and enhances key pathological features.

[0063] In this embodiment, the first bottleneck structure, the second bottleneck structure, the third bottleneck structure, and the fourth bottleneck structure each independently include, in sequence, a 1×1 convolutional layer, a depthwise separable convolutional layer, and another 1×1 convolutional layer; wherein, the 1×1 convolutional layer is used for channel dimension compression or restoration, and the depthwise separable convolutional layer is used for extracting local spatial features. This effectively solves the problem of excessive model parameters and high computational complexity that may result from traditional convolutional layer stacking.

[0064] This embodiment employs a sophisticated gated weighting mechanism combined with residual connections to perform pathological feature screening convolution processing on the encoded feature map. The encoded feature map is input into a first bottleneck structure for channel dimension compression to reduce feature redundancy and focus on core information. Group normalization and ReLU activation are applied to the compressed features to ensure feature stability and non-linear expressive power. Activated features are fed in parallel into a second and third bottleneck structure, aiming to extract features from different dimensions or with different emphases. For example, one path focuses on extracting semantic information from the features, while another path generates a gating signal for feature selection. Dynamic weighting and gating of features are achieved by element-wise multiplying the first and second intermediate features, enabling the model to adaptively enhance features beneficial for lymph node detection while suppressing background noise or irrelevant information. This gated weighted feature is then further refined and transformed through a fourth bottleneck structure to ensure its dimensionality matches the original encoded feature map. Finally, the transformed features are added element-wise to the original encoded feature map to form residual connections. This not only helps preserve the rich contextual information of the original features but also enables the network to learn incremental improvements to the feature map, thus outputting a finely filtered and enhanced feature map. This processing flow allows the automatic segmentation and detection model to more effectively extract features crucial for lymph node segmentation from complex pathological images, significantly improving the discriminative power of the features.

[0065] As a specific implementation, the above-described pathological feature screening convolution processing on the encoded feature map can be implemented as follows: Assume the encoded feature map output by the encoder has C channels. First, the encoded feature map is input into a first bottleneck structure, which can compress the number of channels from C to C / 4 using a 1×1 convolutional layer, followed by a depthwise separable convolutional layer to extract local spatial features, and then another 1×1 convolutional layer to keep the number of channels at C / 4, thus obtaining compressed features. Subsequently, the compressed features are subjected to group normalization, for example, 32 groups can be set, and then the ReLU activation function is applied to generate activation features. This activation feature is simultaneously fed into a second bottleneck structure and a third bottleneck structure. These two bottleneck structures can have similar internal structures to the first bottleneck structure, i.e., each contains a 1×1 convolutional layer, a depthwise separable convolutional layer, and another 1×1 convolutional layer, all of which keep the number of channels at C / 4, outputting a first intermediate feature and a second intermediate feature, respectively. Then, the first intermediate feature and the second intermediate feature are multiplied element-wise to generate gated weighted features. This gated weighted feature is then fed into a fourth bottleneck structure, which also restores the number of channels from C / 4 to C using a 1×1 convolutional layer, followed by a depthwise separable convolutional layer, and then another 1×1 convolutional layer to keep the number of channels at C, thus obtaining the transformed feature. Finally, the transformed feature is added element-wise to the original encoded feature map to obtain the filtered feature map.

[0066] Through the above technical solution, this embodiment can perform refined pathological feature screening and convolution processing on the encoded feature map. This processing mechanism can effectively distinguish and screen out subtle pathological features that are crucial for lymph node detection, while suppressing background noise and redundant information in the image. This adaptive feature weighting and residual learning strategy enables the model to obtain more discriminative and robust feature representations, thereby significantly improving the detection accuracy and segmentation effect of the automatic segmentation and detection model for lymph nodes in complex gastrointestinal tumor pathological images, overcoming the limitations that traditional convolution processing may have when processing complex medical image features.

[0067] like Figure 5As shown in the figure, this embodiment further proposes that in the multi-directional scanning strategy, the bidirectional serpentine traversal path is generated as follows: traversing the sequence in a serpentine order along the first spatial direction, and reversing at the end of each row; the diagonal traversal path is generated as follows: alternating traversal of the sequence along the diagonal spatial direction. Addressing the characteristics of "irregular shape and scattered distribution" of lesions in digestive system lymph node pathological images, the input feature map is first flattened into a one-dimensional sequence, and then the hybrid path traversal sequence of "bidirectional serpentine + diagonal" is used to adapt to the continuous edge texture of the lymph nodes, covering the cross-regional association of adherent lesions; the multi-path features after traversal are enhanced by a pixel association fusion module to strengthen the semantic connection of the lesion region, and finally, the multi-path information is integrated into a unified feature sequence through a feature aggregation layer, realizing long-range dependency modeling between different lymph node instances and small lesions, while improving the feature capture capability for lesions with weak boundaries and low contrast.

[0068] A bidirectional serpentine traversal path is designed to efficiently capture local and row-level contextual information in an image or feature map. By scanning along a primary spatial direction (e.g., horizontal) and reversing direction at the end of each row, feature information is continuously collected without skipping any pixels, while reducing unnecessary jumps and maintaining the coherence of the data flow.

[0069] Cross-diagonal traversal paths are designed to capture spatial dependencies along the diagonal direction in an image or feature map, which is particularly important for identifying structures with specific orientations or irregular shapes (such as the edges or internal texture of lymph nodes). By alternating traversals along different diagonal directions, features can be extracted from multiple perspectives, thereby enhancing the model's ability to perceive complex spatial patterns.

[0070] Through these two complementary traversal paths, the model can comprehensively perceive spatial information in the feature map from multiple dimensions, including horizontal, vertical (through the reverse of the serpentine path), and diagonal, thereby generating richer and more discriminative feature sequences. These multi-directional feature sequences are then concatenated and aggregated to obtain aggregated feature sequences.

[0071] In this embodiment, the calculation process of the aggregated feature sequence includes: The filtered feature map Flattened into a one-dimensional sequence : ; in, For the feature map input to this strategy, Flatten represents the feature flattening operation; Concatenate feature sequences from multiple directions: ; in, , This is a bidirectional serpentine path traversal sequence. , This represents a diagonal path traversal sequence, with Concat being a feature concatenation operation. The concatenated feature sequence; The spliced ​​feature sequence Perform aggregation processing: ; Here, Agg represents feature aggregation, which uses element-wise summation. This is the output aggregated feature sequence.

[0072] The multi-directional sensing scanning strategy is used not only for global spatial modeling but also for establishing correspondences with pathological morphological features of lymph nodes. For common continuous curved boundaries, spiky edges, and cord-like extensional structures in lymph node regions, the bidirectional serpentine traversal path can continuously propagate features along the local contour, enhancing the ability to characterize edge continuity and morphological irregularities. For satellite lesions, scattered small lesions, obliquely distributed micro-metastatic regions, and cross-regional adhesion structures, the diagonally intersecting traversal path can more effectively establish oblique dependencies between non-adjacent regions, improving the ability to perceive scattered lesions and cross-regional semantic connections.

[0073] This embodiment further proposes that the aforementioned multi-directional scanning strategy also includes an adaptive weight allocation step. Based on the morphological response information extracted from the preceding features, the model assigns adaptive weights to different traversal paths. This step aims to dynamically adjust the contribution of the feature sequences generated by different scanning paths according to the local morphological characteristics in the filtered feature maps.

[0074] Specifically, the adaptive weight allocation step includes: (1) Extract morphological response parameters from the filtered feature map. The morphological response parameters include at least one of edge continuity, orientation consistency, and local dispersion. These morphological response parameters are quantitative indicators describing the structural characteristics of local regions in pathological images. Their role is to provide key information about the image content so that the system can determine which scanning path is more suitable for feature extraction in the current region. For example, edge continuity can measure the smoothness and connectivity of the edges of local regions in an image. It can be obtained by calculating the consistency of local gradient directions or by analyzing the connectivity of edge pixels after using an edge detection operator. Orientation consistency can measure the directionality of the texture or structure of local regions in an image. It can be evaluated by the response intensity of Gabor filter banks in different directions. Local dispersion can measure the degree of dispersion of pixel values ​​or feature distribution in local regions of an image. It can be obtained by calculating the pixel variance or entropy value of local regions.

[0075] (2) Based on the morphological response parameters, the system calculates the fusion weights of the bidirectional serpentine path and the diagonally intersecting path. The purpose of this calculation process is to provide a basis for the subsequent weighted summation, ensuring that the features of different paths are given appropriate consideration according to their applicability to the current image region.

[0076] (3) The feature sequences generated by each path are weighted and summed according to the fusion weights to obtain an aggregated feature sequence. This weighted summation is a key step in feature fusion. It can combine feature sequences from different directions according to the calculated fusion weights to generate a more representative and informative aggregated feature sequence.

[0077] This embodiment further refines the rules for weight allocation: When the edge continuity is higher than a first threshold, the weight of the bidirectional serpentine path is increased. That is, when the image region exhibits obvious linear or boundary structures, the system assigns a higher weight to the bidirectional serpentine path because this path is good at capturing features that are continuous along a specific direction and can provide more effective feature representations for structures with high edge continuity.

[0078] When the local dispersion exceeds the second threshold, the weight of the diagonal paths is increased. That is, when the image region exhibits a scattered or irregular distribution, the system assigns higher weights to the diagonal paths to better capture these non-axial or diffuse features by utilizing their multi-angle scanning capabilities.

[0079] Furthermore, the morphological response parameters may also include the degree of regional dispersion; when the degree of regional dispersion is higher than a third threshold, the weight of the diagonal paths is increased. The degree of regional dispersion measures the density of the target distribution within a region. When it is high, the weight of the diagonal paths is further enhanced, which can better capture and associate feature points scattered in different locations, and has advantages for identifying diffuse lesions or dispersed cell populations.

[0080] This embodiment introduces an adaptive weight allocation mechanism based on a multi-directional scanning strategy. This mechanism dynamically adjusts the fusion weights of the bidirectional serpentine traversal path and the diagonal traversal path based on the morphological characteristics of different regions in HE-stained pathological images of lymph nodes from gastrointestinal tumors. First, the mechanism extracts morphological response parameters from the filtered feature maps. These parameters provide key information about the local structure of the image. Based on these parameters, the system intelligently calculates the fusion weights of each path. For example, when an image region has high edge continuity, the weight of the bidirectional serpentine traversal path is increased to better capture linear or well-defined structures; conversely, when an image region exhibits high local dispersion or regional dispersion, the weight of the diagonal traversal path is increased to better capture scattered or diffuse features using its multi-angle scanning capabilities. In this way, the feature sequences generated by each path are no longer simply spliced ​​or aggregated at a fixed ratio, but rather weighted and summed in a targeted manner based on the actual morphological characteristics of the image content. This ensures that the final aggregated feature sequence more accurately and comprehensively reflects the local structural information of the pathological image, providing higher-quality input for subsequent decoding and lymph node segmentation.

[0081] This embodiment further proposes that the automatic segmentation and detection model also includes a feature fusion unit located between the encoder and the decoder, and the feature fusion unit performs the following operations: Receive encoded feature maps output from at least two different stages of the encoder; The encoded feature maps are subjected to scale unification and channel alignment respectively; Attention weights are calculated using the channel attention module and the spatial attention module, respectively. The attention weights are weighted and fused with the encoded feature map to output the fused feature map; The fused feature map is then skipped and connected to the feature map of the corresponding stage in the decoder.

[0082] Receiving encoded feature maps from at least two different stages of the encoder means that when processing pathological images, the encoder typically extracts features of different abstraction levels and receptive field sizes stepwise through multiple convolutional layers or modules. The output feature maps from different stages represent features at different scales, from shallow texture details to deep semantic information. Scale unification and channel alignment of the encoded feature maps refer to scale unification adjusting feature maps of different sizes to the same spatial resolution so that they can be fused in subsequent operations. Channel alignment refers to adjusting the number of channels in different feature maps to maintain consistency, which can be achieved through a 1×1 convolutional layer. This convolutional layer can change the number of channels in a feature map without changing its spatial size, thus providing a unified channel dimension for subsequent feature fusion operations. Attention weights are calculated through a channel attention module and a spatial attention module, aiming to assign different weights to each channel based on the importance of the feature map in different channels. The spatial attention module focuses on the importance of different regions of the feature map in the spatial dimension, assigning weights to each spatial location. Weighted fusion applies calculated attention weights to the original encoded feature map to enhance or suppress information from different channels or spatial locations within the feature map. This is achieved through element-wise multiplication, where the attention weight map and the feature map are multiplied element-wise. The fused feature map contains key information filtered and enhanced by the attention mechanism. Skip connections directly pass the feature map from a specific stage in the encoder to the corresponding resolution stage in the decoder. This helps the decoder utilize the detailed information retained in the encoder when restoring resolution, avoiding the loss of important spatial information during downsampling. For example, the fused feature map can be concatenated along the channel dimension with feature maps of the same spatial resolution in the decoder, or element-wise added.

[0083] Reference Figure 1 As shown, the automatic detection model for digestive system lymph nodes in this embodiment includes: an encoder module, a latent space module, a decoder module, and a high-efficiency feature fusion module. The encoder comprises a four-stage state space module, each including a multi-directional sensing state space network and a hybrid feedforward network. The decoder also comprises a four-stage state space module with a symmetrical structure. The latent space module has the same structure as the state space module in the encoder, including a multi-directional sensing state space network and a hybrid feedforward network.

[0084] like Figure 2As shown, the hybrid feedforward network includes fully connected layers, depthwise separable convolutional layers, and activation function layers. The fully connected layers are used to expand the feature dimension and establish cross-channel feature associations. The depthwise separable convolutional layers are used to extract local spatial structure information to enhance the model's ability to represent nonlinear lymph node lesion areas. The activation function layers are used to introduce nonlinear features and suppress invalid responses, enabling the network to distinguish target areas from background areas in complex backgrounds, thereby improving the model's segmentation performance.

[0085] like Figure 3 As shown, the multi-directional sensing state space network includes a designed pathological feature screening convolution and a multi-directional sensing scanning strategy, which are used to model global information of pathological images of lymph nodes in the digestive system, realize feature dimensionality reduction and effective screening, establish remote dependencies between different instances, and improve the feature perception capability of key areas.

[0086] like Figure 6 As shown, this embodiment further proposes that the above-mentioned feature fusion unit also includes an attention gate module, which performs the following operations: The feature maps from the encoder and the decoder are respectively input into two parallel 1×1 convolutional branches, and each branch is sequentially processed by batch normalization and ReLU activation; The outputs of the two branches are summed element by element, and then passed through ReLU activation, pointwise convolution and Sigmoid function in sequence to generate an attention weight map; The attention weight map is multiplied element-wise with the feature map from the encoder to output the gated enhanced feature map.

[0087] The attention gate module is a mechanism for dynamically adjusting the importance of feature maps in a neural network. It learns the salient regions of the input feature map, generates an attention weight map, and then uses this weight map to weight the original feature map, highlighting important information and suppressing irrelevant information. This module can be implemented using convolutional layers, fully connected layers, or more complex gating units. Its core lies in its ability to adaptively generate spatial or channel weights based on the contextual information of the input features. The 1×1 convolutional layers in the two parallel 1×1 group convolution branches are mainly used for channel dimension transformation and cross-channel information fusion, while the group convolution divides the input channels into several groups, each group being convolved independently to reduce the number of parameters and computational cost while maintaining a certain feature extraction capability. The two parallel branches independently process feature maps from the encoder and decoder, preparing for subsequent interactions. Batch normalization, performed sequentially by each branch, normalizes each batch of input, accelerating training and improving model stability, while the ReLU activation function introduces non-linearity, enhancing the model's expressive power. Batch normalization can be a standard BN layer, layer normalization, or instance normalization; ReLU can be standard ReLU, or variants such as Leaky ReLU or PReLU. Element-wise addition is achieved by adding the output feature maps of the two branches at corresponding positions. After ReLU activation, pointwise convolution, and the sigmoid function, the output values ​​are compressed to between 0 and 1, generating a probability map that can be used as attention weights. The number of output channels for pointwise convolution is typically set to 1 to generate a single-channel attention weight map. The generated attention weight map is a tensor with the same (or broadcastable) spatial dimension as the feature map, where each element's value is between 0 and 1, representing the importance of the feature at the corresponding position. This weight map can be a spatial attention map, a channel attention map, or a combination of both. Element-wise multiplication with the feature map from the encoder is a gating operation; larger values ​​in the weight map preserve or enhance more feature information at the corresponding position, while smaller values ​​suppress more. The final output gated enhanced feature map is a feature map weighted by the attention weight map, in which important information is highlighted and unimportant information is suppressed.

[0088] This embodiment further proposes using an adaptive attention segmentation loss function AALouss when training the automatic segmentation and detection model, wherein AALouss is calculated according to the following formula: AALoss DiceLoss Boundary Loss ; in: DiceLoss P represents the segmentation result predicted by the model, and G represents the true label. Boundary Loss , This is the gradient operator, used to extract edge information; α, β, and γ are the spatial mean or voxel-level values ​​of the attention weight map output by the attention module in the automatic segmentation and detection model; α, β, and γ are preset balance coefficients.

[0089] The Adaptive Attention Segmentation Loss Function (AALoss) is a composite loss function designed to comprehensively consider the accuracy of segmented regions, the precision of boundaries, and the effectiveness of the model's internal attention mechanism. By combining DiceLoss, BoundaryLoss, and attention-based weights, it guides the model during training to focus not only on pixel-level classification accuracy but also on refining segmentation boundaries, and encourages the model to effectively utilize its internal attention mechanism, thereby improving the detection and segmentation performance of lymph nodes in complex pathological images.

[0090] DiceLoss measures the degree of overlap between the predicted and ground truth regions. A DiceLoss of 0 indicates perfect segmentation when P and G completely overlap, and a DiceLoss of 1 indicates no overlap. DiceLoss can be calculated at the pixel level, i.e., for each pixel in the image, the intersection and union of its predicted and ground truth categories are calculated; or it can be calculated at the region level, for example, for each lymph node instance, the Dice coefficients of its predicted and ground truth regions are calculated, and then the Dice coefficients of all instances are averaged.

[0091] Boundary loss is used to penalize the difference between the predicted boundary and the true boundary, aiming to optimize the boundary accuracy of the segmentation result; it calculates the gradient of the predicted segmentation result P. The gradient of Pi with respect to the true label G ( The gradient operation penalizes inaccurate boundary predictions by minimizing the difference between the gradients (G1 and G2). Gradient operations highlight edge information in images, so minimizing the gradient difference helps make the model's predicted boundaries closer to the true boundaries, which is especially important for targets like lymph nodes that may have complex or blurred boundaries. Gradient operators Classical image processing operators, such as the Sobel or Prewitt operators, can be used to perform edge detection on the predicted and ground truth label maps, and then the L2 norm difference between these edge maps can be calculated. In deep learning frameworks, gradients can be directly calculated via automatic differentiation, i.e., the spatial gradient of the probability map output by the model is calculated and compared with the gradient of the ground truth label. The attention term guides the model to focus on important regions in the image. By incorporating Aattn into the loss function in the form of (1 - Aattn), the loss function encourages the attention weight map Aattn to have a value as large as possible (close to 1). This means that the model will more actively activate its attention mechanism during training, thereby more effectively focusing on lymph node regions, suppressing background noise, and improving the targeting of feature extraction.

[0092] The balancing coefficients α, β, and γ are used to adjust the relative importance of DiceLoss, BoundaryLoss, and the attention term in the total loss function. By adjusting these coefficients, the optimization priorities of the model between overall accuracy, boundary accuracy, and attention utilization efficiency can be balanced according to specific task requirements and dataset characteristics. For example, if boundary accuracy is critical, the value of β can be appropriately increased. These coefficients can also be dynamically adjusted based on the number of training epochs, performance metrics on the validation set, or the relative magnitudes of different parts of the loss function to achieve finer optimization.

[0093] In this embodiment, the multi-stage state space module in the encoder and the multi-stage state space module in the decoder have the same network structure, and the state space module includes a multi-directional sensing state space network (such as...). Figure 3 (as shown) and hybrid feedforward networks (such as) Figure 2 (As shown in the figure). The hybrid feedforward network includes fully connected layers, depthwise separable convolutional layers, and activation function layers. The method also includes a step of training the automatic segmentation and detection model. The training step includes: constructing a training dataset containing multiple HE-stained pathological images of lymph nodes after gastrointestinal tumor surgery with labeled lymph node contours; inputting the training images into the automatic segmentation and detection model, calculating the adaptive attention segmentation loss function value between the model output and the labels; and backpropagating to update the model parameters until the loss function converges.

[0094] The multi-stage state space module in the encoder and the multi-stage state space module in the decoder share the same network structure. This ensures consistency and stability during feature extraction and reconstruction, reducing information loss or mismatch that may result from structural differences. This can be achieved by defining a unified state space module class or function for both the encoder and decoder during model design, or by sharing weights to enable them to learn the same feature transformation patterns during training. The state space module is a core component in the model for processing sequential information and capturing long-range dependencies. It comprises a multi-directional sensing state space network and a hybrid feedforward network, designed to enhance the module's ability to perceive input features and perform nonlinear transformations. The multi-directional sensing state space network can be designed to contain multiple parallel or sequential state space layers, each responsible for processing information flows of different directions or scales. For example, convolutional kernels with different kernel sizes or dilation rates can be used to simulate multi-directional sensing. The hybrid feedforward network is responsible for further nonlinear transformations and feature extraction of the features output by the multi-directional sensing state space network. This network, by combining fully connected layers, depthwise separable convolutional layers, and activation function layers, effectively handles inter-channel relationships and local spatial relationships of features, as well as introducing nonlinearities, thereby enhancing the model's expressive power. Fully connected layers can be used to adjust the channel dimension of features or integrate global information, depthwise separable convolutional layers can efficiently extract local spatial features and reduce the number of parameters, while activation function layers (such as ReLU, GELU, Swish, etc.) introduce nonlinearities, enabling the network to learn more complex patterns.

[0095] Gastrointestinal tumors are a broad concept, and different types of gastrointestinal tumors can vary significantly in pathological features, lymph node metastasis patterns, and imaging appearance. In this embodiment, the gastrointestinal tumors include one or more of esophageal cancer, gallbladder cancer, gastric cancer, pancreatic cancer, and colorectal cancer. These tumors differ in histological morphology, biological behavior, lymph node metastasis patterns, and response to treatment. In pathological images, the cell morphology, tissue structure, stromal reaction, and metastatic lesions within lymph nodes may vary among different types of tumors.

[0096] Esophageal cancer is a malignant tumor that occurs in the epithelial tissue of the esophagus, and its lymph node metastasis pattern exhibits certain regional and skipping characteristics. In HE-stained pathological images, the morphological features of metastatic lymph nodes in esophageal cancer may be related to the histological type of the primary lesion.

[0097] Gallbladder cancer is a highly malignant digestive tract tumor, and its lymph node metastasis often involves areas surrounding the gallbladder and the hepatoduodenal ligament. In pathological images, the cellular atypia and disordered glandular structure of metastatic lesions in gallbladder cancer are quite prominent.

[0098] Gastric cancer is a malignant tumor originating from the gastric mucosal epithelium, and lymph node metastasis is an important prognostic factor. Gastric cancer has diverse pathological types, such as adenocarcinoma and signet ring cell carcinoma, and the manifestations of different types within the lymph nodes vary, potentially presenting as glandular structures, diffuse infiltration, or mucus lakes.

[0099] Pancreatic cancer is a malignant tumor with an extremely poor prognosis, and lymph node metastasis is a common route of spread. In pathological images, metastatic lymph nodes of pancreatic cancer often appear as glandular structures or solid cancer nests, possibly accompanied by abundant fibrous stromal reaction.

[0100] Colorectal cancer is a common malignant tumor of the digestive tract, and lymph node metastasis is an important basis for its staging. In pathological images, metastatic lymph nodes of colorectal cancer usually appear as glandular structures with deeply stained nuclei, an imbalanced nucleus-cytoplasmic ratio, and sometimes necrosis.

[0101] This embodiment defines the digestive tract tumors as one or more of esophageal cancer, gallbladder cancer, gastric cancer, pancreatic cancer, and colorectal cancer, allowing the automatic segmentation and detection method based on a state-space model to specifically optimize its performance. When training the automatic segmentation and detection model, pathological image data of these specific tumor types can be used for training or fine-tuning. Since the pathological features and lymph node metastasis patterns of different digestive tract tumors differ, by focusing on these specific types, the model can learn more representative and discriminative features when the encoder extracts deep pathological features, performs pathological feature screening and convolution processing, and generates feature sequences using multi-directional scanning strategies. For example, for esophageal cancer, the model can more effectively identify its unique squamous cell carcinoma or adenocarcinoma metastatic morphology; for colorectal cancer, it can better capture its glandular structure features. This targeted training and feature learning allows the model to significantly improve the accuracy and specificity of identifying lymph node metastases of these specific tumor types when the decoder restores the resolution and outputs lymph node segmentation results, thereby overcoming the potential problems of insufficient generalization and low specificity in general models.

[0102] Example 2 (System) This embodiment proposes a gastrointestinal tumor lymph node detection system based on a state-space model. The system includes an image acquisition module for acquiring HE-stained pathological images of lymph nodes after gastrointestinal tumor surgery; a model storage module for storing a trained automatic segmentation and detection model based on the state-space model; and a segmentation and detection module for inputting the pathological image into the automatic segmentation and detection model and outputting pixel-level lymph node segmentation results. The automatic segmentation and detection model includes corresponding processing units for executing each step of the above method.

[0103] The core innovation of this embodiment lies in combining an automatic segmentation and detection model based on a state-space model with a dedicated system architecture. This effectively models the long-range spatial dependency between lymph nodes and surrounding adhesions, enhancing the representation of irregular shapes and weak boundaries. This significantly improves segmentation accuracy, reduces manual intervention, and enhances the objectivity and reliability of diagnostic results. Specifically, the image acquisition module first acquires high-resolution HE-stained pathological images of lymph nodes after gastrointestinal tumor surgery. These images typically exhibit the characteristic of cell nuclei stained blue by hematoxylin and cytoplasm stained pink by eosin, and often contain complex adhesion areas between lymph nodes with blurred boundaries and surrounding adipose or fibrous tissue. The pre-stored automatic segmentation and detection model in the model storage module is specially trained and optimized for the characteristics of such pathological images. When the segmentation and detection module inputs pathological images into the model, the model performs key steps including multi-stage state space module encoding, pathological feature screening and convolution processing, multi-directional scanning strategy, and decoding: the encoder extracts deep pathological features at different scales through multi-stage state space modules, the pathological feature screening and convolution processing refines the encoded feature map to highlight lymph node-related features, the multi-directional scanning strategy comprehensively captures spatial dependencies through bidirectional serpentine traversal paths and cross-diagonal traversal paths, and finally the decoder gradually restores the resolution and outputs pixel-level segmentation results.

[0104] The specific processing procedure of this system embodiment is similar to that of the method embodiment, and will not be described in detail here.

[0105] In summary, this invention addresses the challenges of complex morphological features, large scale differences, weak boundaries, complex background tissue, and adhesion interference in HE pathological images of lymph nodes from digestive system tumors. It proposes an end-to-end automatic segmentation and detection method based on a state-space model. Through pathological feature screening and convolution, multi-directional sensing scanning strategies, and attention-driven multi-scale feature fusion with adaptive attention loss (AALoss), this approach improves segmentation accuracy, boundary quality, robustness, and processing efficiency. The segmentation results are shown in the image below. Figure 7 and Figure 8 As shown.

[0106] On the internal test set, with reference to control method A: U-Net and control method B: UNet++, the embodiments of the present invention achieve improvements in main metrics such as Dice and IoU; at the same time, the decrease in boundary metrics such as HD95 and ASSD is more significant, indicating that the contour reconstruction of weak boundaries and adhesion regions is more accurate.

[0107] Comparison method Dice(%)↑ IoU (%)↑ Precision (%)↑ Recall (%)↑ HD95 (%)↓ ASSD(px)↓ U-Net 79.2 77.4 82.0 82.7 18.6 3.10 UNet++ 81.3 80.4 84.7 83.6 16.2 2.72 Improvement magnitude (relative to the strongest comparison) +3.5 +5.8 +3.3 +3.7 -3.8 -0.77 Table 1. Segmentation performance comparison results This invention enables end-to-end automatic segmentation output, significantly reducing the time cost of manual segmentation. Using an NVIDIA RTX 4090 as the operating platform and an input patch size of 512×512, this invention achieves a single-frame inference time of approximately 0.18 seconds per frame and a throughput of approximately 330 frames per minute. Compared to the minute-level time required for manual segmentation, the overall efficiency is improved by hundreds of times.

[0108] Way Time per page Swallowing Human interaction Peak memory Remark Manual drawing 3.5 min / sheet -- yes -- Pathologists circled each slide Automatic segmentation in embodiments of the present invention 0.18s / page 330 frames / min no 3.4GB / GPU End-to-end inference output Efficiency improvement factor 1167× -- -- -- Calculated in 3.5 min vs 0.18 s Table 2 Comparison of Efficiency and Resource Consumption To verify the contribution and synergistic effect of each key module in this invention to segmentation performance, an ablation experiment was conducted in this embodiment. The experiment used the baseline model as a control, employing ordinary convolution, a single-scan strategy, ordinary skip connections, and the Dice loss function. Based on this, pathological feature screening convolution (A), a multi-directional sensing scanning strategy (B), an efficient feature fusion module (C), and an adaptive attention loss function AALouss (D) were introduced, and comparative experiments were conducted under the same dataset, the same training parameters, and the same evaluation metrics.

[0109] The experimental results are shown in Table 3. As can be seen from Table 3, the Dice index of the model improved compared to the baseline after introducing any single module, indicating that pathological feature screening convolution, multi-directional sensing scanning strategy, efficient feature fusion module, and AALouss can all independently improve the segmentation effect of lymph node regions. Among them, the Dice index improvement was most significant when the efficient feature fusion module was introduced alone, indicating that multi-scale feature bridging and semantic enhancement between the encoder and decoder play an important role in lymph node detection.

[0110] serial number A. Screened Convolution B scanning strategy C Fusion Module D AALoss Dice (%) Baseline × × × × 84.21 1 √ × × × 85.37 2 × √ × × 85.92 3 × × √ × 86.11 4 × × × √ 85.48 5 √ √ × × 87.02 6 √ √ √ × 88.31 7 √ √ √ √ 89.76 Table 3 Experimental Results Building upon this foundation, the model's performance continued to improve with the gradual integration of multiple modules. When modules A, B, C, and D were introduced simultaneously, the complete model achieved a Dice score of 89.76%, a 5.55 percentage point improvement compared to the baseline of 84.21%. This result demonstrates that the modules of this invention are not isolated from each other, but rather exhibit a strong synergistic effect in areas such as local pathological feature selection, global spatial dependency modeling, cross-layer feature bridging, and loss constraint optimization, thereby collectively enhancing the model's ability to detect and segment lymph node regions in complex contexts.

[0111] The above description is merely an embodiment of the present invention and is not intended to limit the scope of protection of the present invention. For those skilled in the art, the present invention can have various modifications and variations. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of the present invention should be included within the scope of protection of the present invention.

Claims

1. A method for detecting lymph nodes in gastrointestinal tumors based on a state-space model, characterized in that, Includes the following steps: Obtain stained pathological images of lymph nodes after surgery for gastrointestinal tumors; The pathological image is input into an automatic segmentation and detection model based on a state-space model, which outputs pixel-level lymph node segmentation results. The automatic segmentation and detection model performs the following processing on the pathological image: The pathological image is encoded using an encoder containing a multi-stage state space module to extract deep pathological features at different scales and obtain an encoded feature map. Perform pathological feature screening convolution processing on the encoded feature map and output the screened feature map; The filtered feature map is flattened into a one-dimensional sequence. A multi-directional scanning strategy, including at least bidirectional serpentine traversal path and diagonal traversal path, is used to generate feature sequences in multiple directions. The feature sequences in multiple directions are then spliced ​​and aggregated to output an aggregated feature sequence. The aggregated feature sequence is decoded using a decoder containing a multi-stage state space module to gradually restore the resolution and output the lymph node segmentation result.

2. The method according to claim 1, characterized in that, The pathological feature screening convolution process performed on the encoded feature map specifically includes the following steps: The encoded feature map is input into the first bottleneck structure for channel-dimensional compression to obtain compressed features; The compressed features are then subjected to group normalization and ReLU activation sequentially to obtain the activated features; The activation features are input into the second bottleneck structure and the third bottleneck structure respectively to obtain the first intermediate feature and the second intermediate feature; The first intermediate feature and the second intermediate feature are multiplied element by element to obtain the gated weighted feature; The gated weighted features are input into the fourth bottleneck structure for processing to obtain the transformed features; The transformed features are added element by element to the encoded feature map to output the filtered feature map.

3. The method according to claim 1, characterized in that, In the multi-directional scanning strategy, the bidirectional serpentine traversal path is generated as follows: traversing the sequence in a serpentine order along the first spatial direction, and reversing direction at the end of each row; the diagonal traversal path is generated as follows: alternating traversal of the sequence along the spatial diagonal direction; the calculation process of the aggregated feature sequence includes: The filtered feature map Flattened into a one-dimensional sequence : ; in, For the feature map input to this strategy, Flatten represents the feature flattening operation; Concatenate feature sequences from multiple directions: ; in, , This is a bidirectional serpentine path traversal sequence. , This represents a diagonal path traversal sequence, with Concat being a feature concatenation operation. The concatenated feature sequence; The spliced ​​feature sequence Perform aggregation processing: ; Here, Agg represents feature aggregation, which uses element-wise summation. This is the output aggregated feature sequence.

4. The method according to claim 1 or 3, characterized in that, The multi-directional scanning strategy also includes an adaptive weight allocation step: Extract morphological response parameters from the filtered feature map, wherein the morphological response parameters include at least one of edge continuity, orientation consistency, and local dispersion. The fusion weights of the bidirectional serpentine path and the diagonally intersecting path are calculated based on the morphological response parameters. The feature sequences generated by each path are weighted and summed according to the fusion weights to obtain the aggregated feature sequence. Specifically, when the edge continuity is higher than the first threshold, the weight of the bidirectional serpentine path is increased; when the local dispersion is higher than the second threshold, the weight of the diagonal path is increased. The morphological response parameters also include the degree of regional dispersion; when the degree of regional dispersion is higher than the third threshold, the weight of the diagonal paths is increased.

5. The method according to claim 1, characterized in that, The automatic segmentation and detection model further includes a feature fusion unit located between the encoder and the decoder, the feature fusion unit performing the following operations: Receive encoded feature maps output from at least two different stages of the encoder; The encoded feature maps are subjected to scale unification and channel alignment respectively; Attention weights are calculated using the channel attention module and the spatial attention module, respectively. The attention weights are weighted and fused with the encoded feature map to output the fused feature map; The fused feature map is then skipped and connected to the feature map of the corresponding stage in the decoder.

6. The method according to claim 5, characterized in that, The feature fusion unit further includes an attention gate module, which performs the following operations: The feature maps from the encoder and the decoder are respectively input into two parallel 1×1 convolutional branches, and each branch is sequentially processed by batch normalization and ReLU activation; The outputs of the two branches are summed element by element, and then passed through ReLU activation, pointwise convolution and Sigmoid function in sequence to generate an attention weight map; The attention weight map is multiplied element-wise with the feature map from the encoder to output the gated enhanced feature map.

7. The method according to claim 1, characterized in that, The automatic segmentation and detection model is trained using an adaptive attention segmentation loss function AALouss, which is calculated according to the following formula: AALoss DiceLoss BoundaryLoss ; in: DiceLoss P represents the segmentation result predicted by the model, and G represents the true label. Boundary Loss , This is the gradient operator, used to extract edge information; α, β, and γ are the spatial mean or voxel-level values ​​of the attention weight map output by the attention module in the automatic segmentation and detection model; α, β, and γ are preset balance coefficients.

8. The method according to claim 1, characterized in that, The multi-stage state space module in the encoder has the same network structure as the multi-stage state space module in the decoder. The state space module includes a multi-directional sensing state space network and a hybrid feedforward network. The hybrid feedforward network includes fully connected layers, depthwise separable convolutional layers, and activation function layers.

9. The method according to claim 1, characterized in that, The digestive tract tumors include one or more of the following: esophageal cancer, gallbladder cancer, gastric cancer, pancreatic cancer, and colorectal cancer.

10. A digestive tract tumor lymph node detection system based on a state-space model, characterized in that, include: The image acquisition module is used to acquire stained pathological images of lymph nodes after gastrointestinal tumor surgery; The model storage module is used to store trained automatic segmentation and detection models based on state-space models. The segmentation and detection module is used to input the pathological image into the automatic segmentation and detection model and output pixel-level lymph node segmentation results; The automatic segmentation and detection model includes corresponding processing units for performing each step of the method according to any one of claims 1 to 10.