Small sample medical image classification method, system and device and storage medium

The medical images are converted into long sequence representations through semantic sequence construction module and Mamba state space model. Combined with the distribution-aware prototype calculation module, the problem of small and medium-sized samples learning in traditional methods is solved, and efficient and accurate medical image classification is achieved.

CN120088580AActive Publication Date: 2025-06-03JIANGNAN UNIV

Patent Information

Application Number
CN202510546352.5
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-04-28
Publication Date
2025-06-03
Estimated Expiration
2045-04-28

AI Technical Summary

Technical Problem

Traditional deep learning models require a large amount of labeled data in medical image classification, and existing small sample learning methods are difficult to effectively capture the intra-class distribution complexity and local-global features of medical images, with high computational complexity and large parameters, which are easy to overfit.

Method used

The medical image is segmented into overlapping slice sequences through the semantic sequence building block, combining learnable position coding and Mamba state space model to capture long-distance dependencies. The Distribution-Aware Prototype Computing Module uses Mahayana distance to build a category prototype, considering the mean vector and covariance matrix.

Benefits of technology

It improves the efficiency of medical imaging feature modeling, improves classification efficiency and accuracy, significantly reduces the computational complexity, and enhances the adaptability and generalization ability of the model.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120088580A_ABST
    Figure CN120088580A_ABST
Patent Text Reader

Abstract

The invention discloses a small sample medical image classification method, system and device and a storage medium, and belongs to the field of medical image processing and artificial intelligence. The method comprises the following steps: segmenting an input medical image into an overlapped slice sequence with spatial context information through a semantic sequence construction module; extracting the feature representation of each slice and adding a position code; processing the feature sequence through a sequence enhancement module, and capturing a long-distance dependency relationship; constructing a category prototype considering feature distribution by using a distribution perception prototype calculation module; and calculating the distance between the query sample and each type of prototype by using the mahalanobis distance, and performing classification decision. According to an end-to-end architecture specially designed for Mamba characteristics, the fundamental problem that a traditional few-sample learning method is insufficient in adaptability in the field of medical images is solved in a breakthrough mode, and an efficient and robust technical path with practical value is provided for a medical diagnosis auxiliary system.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to a small-sample medical image classification method, system, device and storage medium, belonging to the fields of medical image processing and artificial intelligence. Background Art

[0002] In recent years, deep learning technology has made remarkable progress in the field of medical image processing and demonstrated great potential in tasks such as tumor detection, organ segmentation, and disease diagnosis. Compared with traditional manual diagnosis, medical image analysis based on deep learning has advantages such as high efficiency, stability, and strong consistency. However, deep learning models usually require a large amount of labeled data for training, and the medical image field faces challenges such as high professional annotation costs, strict data privacy protection, and scarcity of rare disease samples. These factors constitute the main bottleneck for the application of deep learning in the medical image field.

[0003] Few-shot Learning, as a technology that can effectively classify using limited labeled samples, provides a possibility to solve the problem of scarce medical image data. Among them, Prototypical Networks have become an important method for small-sample medical image classification due to their simple structure and easy implementation. However, traditional prototypical networks have obvious deficiencies in processing medical images: only using mean features cannot represent the complexity of the within-class distribution; global features are difficult to capture key local structures; simple Euclidean distance metrics are difficult to handle the large internal differences and blurred boundaries of medical image categories.

[0004] Existing improvement methods mainly focus on two directions: one is to enhance the feature representation ability by introducing sequence processing architectures such as Transformer, but its computational complexity is relatively high, the number of parameters is huge, and it is prone to overfitting in small-sample scenarios; the other is to design multi-prototype or prototype representation methods considering covariance, but often ignore the spatial continuity of medical images and the integration of local-global features. Therefore, there is an urgent need for a solution that can efficiently model medical image features, adapt to small-sample learning scenarios, and balance computational efficiency and model expression ability. Summary of the Invention

[0005] In order to improve the efficiency of medical image feature modeling and the classification efficiency and accuracy, the present invention provides a small-sample medical image classification method, system, device and storage medium, and the technical solutions are as follows: The first object of the present invention is to provide a small-sample medical image classification method, including the following steps: Step 1: Use a semantic sequence construction module to segment the input medical image into an overlapping slice sequence with spatial context information; The processing process of the semantic sequence construction module includes: Given an input image , slice it using a window of size and an overlap ratio :

[0006] where and are the step sizes in the height and width directions respectively, i and j represent the position indices in the height and width directions respectively; Step 2: Use an encoder to extract the feature representation of each slice and add positional encoding; Step 3: Process the feature sequence through a sequence enhancement module to capture long-range dependencies, where the sequence enhancement module uses a Mamba state space model to process the feature sequence; Step 4: Use a distribution-aware prototype calculation module to construct class prototypes considering the feature distribution, where the distribution-aware prototype calculation module constructs a prototype representation containing a mean vector and a covariance matrix for each class; Step 5: Calculate the distance between the query sample and each class prototype using the Mahalanobis distance and make a classification decision.

[0007] Optionally, step 2 further includes: Introduce learnable positional encoding , where L represents the total number of slices, D represents the dimension of the slice features (i.e., the length of the feature vector of each slice after passing through the encoder); Add the positional encoding to the features of each slice, denoted as:

[0008] where represents the enhanced feature containing spatial information, represents the feature of the slice, represents the learnable positional encoding vector of the ( i , j )-th slice; Assign a score to each slice reflecting its importance for the classification decision:

[0009] where represents the importance evaluation network, represents the spatial enhanced feature of the -th slice; Calculate the attention weights:

[0010] Among them, represents constructing a spatial relationship matrix based on the distance from the center point of the slice, which is used to control the influence of importance, and respectively represent the i th slice enhancement feature and the j th slice enhancement feature, represents the semantic similarity of the slice features, represents the i slice k and the element of the spatial relationship matrix of the slice Finally, an enhanced feature sequence is obtained through weighted aggregation:

[0011] Among them, represents the enhanced feature sequence after weighted aggregation, represents, B represents the batch size.

[0012] Optionally, step 3 includes: Step 31: Input the aggregated feature sequence into layer normalization processing; Step 32: Separate the main path feature and the residual path feature through linear projection; Step 33: Use one-dimensional convolution to extract local feature patterns; Step 34: Apply SSM parameter generation and selective scanning to process sequence data; Step 35: Integrate the two-way features through a gating mechanism to obtain an enhanced sequence representation.

[0013] Optionally, the calculation method of the Mahalanobis distance is:

[0014] Among them, represents the query sample, represents the class prototype, represents the class c the mean of all sample features, represents the class c the covariance matrix of all sample features.

[0015] Optionally, it also includes adding a regularization term to the covariance matrix: , where is the regularization coefficient, and I represents the identity matrix.

[0016] Optionally, the method uses a cross-entropy loss function with a temperature parameter to train the model in a meta-learning framework. The cross-entropy loss function is expressed as:

[0017] where is a learnable temperature parameter that controls the smoothness of the class probability distribution; represents the support set, that is, the set of labeled samples used for prototype calculation, represents the samples and their labels in the support set in the support set, N represents the support set and

[0018] Optionally, an L2 regularization term is added to the cross-entropy loss function:

[0019] where represents the L2 regularization coefficient, which is used to control the weight of the parameter norm penalty term, represents the set of all trainable parameters of the model; The final total loss is: .

[0020] The second object of the present invention is to provide a few-shot medical image classification system, which is used to implement the medical image classification method described in any one of the above, including: An image acquisition module, which is used to acquire the medical image to be classified; A semantic sequence construction module, which is used to segment the medical image into an overlapping slice sequence with spatial context information; The processing process of the semantic sequence construction module includes: Given an input image , use a window of size and an overlap ratio to slice:

[0021] where and are the step sizes in the height and width directions respectively, i and j represent the position indices in the height and width directions respectively; A feature extraction module, which is used to extract the feature representation of each slice using an encoder and add position encoding; A sequence enhancement module for processing feature sequences and capturing long-range dependencies, where the sequence enhancement module uses a Mamba state space model to process the feature sequences; A distribution-aware prototype calculation module for constructing class prototypes considering feature distributions, where the distribution-aware prototype calculation module constructs a prototype representation including a mean vector and a covariance matrix for each class; A classification decision module that calculates the distance between a query sample and class prototypes using Mahalanobis distance and makes a classification decision.

[0022] The third object of the present invention is to provide a few-shot medical image classification device, including a memory and a processor; The memory is used to store computer programs; The processor is used to implement the few-shot medical image classification method as described in any one of the above when executing the computer program.

[0023] The fourth object of the present invention is to provide a computer-readable storage medium, characterized in that a computer program is stored on the storage medium, and when the computer program is executed by a processor, the few-shot medical image classification method as described in any one of the above is implemented.

[0024] The beneficial effects of the present invention are: Through the innovative overlapping slice strategy and learnable position encoding, the present invention converts medical images into long sequence representations that retain spatial continuity, perfectly adapting to the sequence processing characteristics of the Mamba model, and solving the problem that it is difficult to construct effective sequence inputs with traditional methods; and based on the selective state space model of Mamba, it models long-range dependencies with linear computational complexity, effectively capturing the pathological feature associations scattered in various regions of the image, and significantly improving the computational efficiency compared with the prior art.

[0025] The distribution-aware prototype calculation module (DAPC) comprehensively captures the distribution information of the Mamba output features by introducing a prototype representation method based on Mahalanobis distance and considering both the mean vector and the covariance matrix, enabling the model to more accurately distinguish complex classes in medical images. This distribution-aware prototype representation method forms a perfect match with the rich feature sequences generated by Mamba, providing a more accurate decision boundary for few-shot medical image classification.

[0026] The end-to-end architecture specifically designed for Mamba characteristics in the present invention breaks through the fundamental problem of insufficient adaptability of traditional few-shot learning methods in the field of medical images, providing an efficient, robust and practical technical path for medical diagnosis assistance systems. Description of the Drawings

[0027] To more clearly illustrate the technical solutions in the embodiments of the present invention, the following will briefly introduce the accompanying drawings required for the description of the embodiments. Obviously, the accompanying drawings in the following description are only some embodiments of the present invention. For those of ordinary skill in the art, without creative efforts, other accompanying drawings can be obtained based on these drawings.

[0028] Figure 1 It is the overall structure diagram of the MSMPN model of the present invention.

[0029] Figure 2 It is the processing flow chart of the Semantic Sequence Construction Module (SSCM) of the present invention.

[0030] Figure 3 It is a partial code screenshot of the Sequence Enhancement Module (MSEM) of the present invention.

[0031] Figure 4 It is the construction and experimental flow chart of the MSMPN model of the present invention.

[0032] Figure 5 It is the architecture diagram of the ResNet-12 model. Detailed implementation manners

[0033] To make the objectives, technical solutions, and advantages of the present invention clearer, the following will further describe the embodiments of the present invention in detail with reference to the accompanying drawings.

[0034] Embodiment 1: This embodiment provides a small-sample medical image classification method, including the following steps: Step 1: Segment the input medical image into an overlapping slice sequence with spatial context information through the Semantic Sequence Construction Module; The processing process of the Semantic Sequence Construction Module includes: Given an input image , use a window of size and an overlapping ratio to slice:

[0035] Among them, and are the step sizes in the height and width directions respectively, and i and j represent the position indices in the height and width directions respectively; Step 2: Use the encoder to extract the feature representation of each slice and add position encoding; Step 3: Process the feature sequence through the Sequence Enhancement Module to capture long-range dependencies. The Sequence Enhancement Module uses the Mamba state space model to process the feature sequence; Step 4: Use the distribution-aware prototype calculation module to construct class prototypes considering feature distributions. The distribution-aware prototype calculation module constructs a prototype representation containing a mean vector and a covariance matrix for each class. Step 5: Calculate the distances between the query samples and the class prototypes using the Mahalanobis distance and make classification decisions.

[0036] Embodiment 2: This embodiment provides the construction, training, and verification processes of the MSMPN framework.

[0037] As Figure 1 shown, the MSMPN framework consists of three main functional modules, namely the semantic sequence construction module (SSCM), the Mamba-based sequence enhancement module (MSEM), and the distribution-aware prototype calculation (DAPC). Among them, the SSCM module generates long sequence inputs suitable for Mamba processing, the MSEM module efficiently processes these sequences and extracts complex feature representations, and the DAPC module accurately characterizes the distribution characteristics of these complex features for classification decisions.

[0038] The following provides a detailed introduction to these three modules.

[0039] 1. Semantic sequence construction module (SSCM).

[0040] Medical image pathological features usually span multiple regions, and traditional grid segmentation methods may damage key anatomical structures. To address this limitation, this embodiment proposes the SSCM module, and its structure is as Figure 2 shown.

[0041] This module uses an overlapping slice strategy that preserves spatial context information to segment medical images into local regions and uses an encoder to extract the feature representation of each slice. The specific processing process is as follows: Given an input image , use a window of size and an overlap ratio to slice:

[0042] where and are the step sizes in the height and width directions respectively, and i and j represent the position indices in the height and width directions respectively; To retain the spatial position information of the slices in the original image, this embodiment introduces learnable position encoding , where L is the total number of slices, and is the slice feature dimension.

[0043]

[0044] Among them, H and W represent the height and width of the input image respectively, w h and w w represent the height and width of the slice window respectively, s h and s w represent the step sizes in the height and width directions during the slicing process respectively, represents rounding up.

[0045] Each slice feature is added with its corresponding position encoding to obtain enhanced features containing spatial information:

[0046] Among them, represents the enhanced features containing spatial information, represents the features of the slice, represents the learnable position encoding vector of the ([[]] i , j )-th slice.

[0047] Considering that there are significant differences in the contribution degrees of different regions to the diagnosis, this implementation refers to the self-attention mechanism of the Transformer architecture and designs an importance evaluation network, which adopts a fully connected layer + non-linear activation structure to output an importance score for each spatial enhanced feature , and assigns a score reflecting its importance degree for the classification decision to each slice:

[0048] Among them, represents the importance evaluation network, represents the spatial enhanced feature of the -th slice; Subsequently, a spatial-aware attention aggregation mechanism is designed, considering three key factors: (1) The semantic similarity of the slice features; (2) The spatial distance relationship of the slices in the original image; (3) The importance scores of the slices.

[0049] The attention weight calculation formula is:

[0050] Among them, Represents the spatial relationship matrix constructed based on the distance from the center point of the slice, which is used to control the influence of importance, and respectively represent the i th slice enhancement feature and the j th slice enhancement feature, represents the semantic similarity of slice features, represents the i spatial relationship matrix element between slice k and slice Finally, an enhanced feature sequence is obtained through weighted aggregation:

[0051] Among them, represents the enhanced feature sequence after weighted aggregation, B represents the batch size.

[0052] 2. Mamba-based Sequence Enhancement Module (MSEM).

[0053] This module combines positional encoding and spatial-aware attention mechanism to capture the spatial relationship between slices, and uses the Mamba state space model to process sequence features, effectively simulating long-range dependencies.

[0054] In the MSMPN framework, MSEM uses the Mamba state space model to efficiently process sequence data. The core of Mamba is its selective SSM mechanism, which defines four input-dependent parameters ( , , , ) and converts them to:

[0055] The sequence transformation can be expressed as:

[0056] Where represents the time step, is the input, is the hidden state, is the output. The hidden state serves as a fixed-size storage unit to save historical information.

[0057] In this embodiment, a dedicated processing architecture is designed for medical image features. The pseudocode of the core processing flow of the MSEM module is as Figure 3 shown. Among them, the MambaSSM function encapsulates the core processing logic of the Mamba state space model, including dynamic parameter calculation and sequence transformation process.

[0058] The calculation process of the MSEM module is as follows: In this embodiment, let the input be a batch of spatially enhanced feature sequences . First, layer normalization is performed on it to enhance the stability of the feature distribution. Subsequently, the features are divided into main-path features and residual-path features through a linear transformation. The main-path features , after one-dimensional convolution and SiLU activation, are input into the Mamba selective state space module to recursively model the long-range dependencies of the sequence. The residual-path features generate gating weights after non-linear transformation, which are used to control the fusion ratio of the main-path information and the original input. The final output sequence is:

[0059] where is a learnable scaling parameter, , is the Sigmoid function, represents element-wise multiplication, represents the output of the Mamba state space module for the main-path features. The internal recursive evolution of the Mamba state space module is as follows:

[0060] where is the hidden state at time , and are the state transition parameter and input mapping parameter dynamically generated according to the input, is the th step of the main-path features. Finally, the output of the main path is mapped back to the original feature dimension through a linear transformation and fused with the gating weights to obtain the enhanced sequence output for subsequent prototype calculation or classification.

[0061] The meanings of each variable are as follows: is the input spatially enhanced feature sequence, is the main-path branch feature, is the residual-branch feature, represents the Mamba selective state space processing module, is the gating weight, is the learnable scaling coefficient, is the Sigmoid function, is the Hadamard product (element-wise multiplication), is the hidden state, is the dynamically generated state space parameter.

[0062] 3. Distribution-Aware Prototype Computation Module (DAPC) To more accurately represent the class feature distribution, this embodiment proposes a distribution-aware prototype computation method based on Mahalanobis distance, which not only considers the class center but also captures the within-class distribution characteristics. For each class in the support set , a prototype representation consisting of a mean vector and a covariance matrix is constructed:

[0063] where the mean vector is the average of all sample features of class :

[0064] The covariance matrix then captures the shape of the feature distribution:

[0065] For the single-sample case, the identity matrix is used as the default covariance.

[0066] The query sample is calculated with the class c using Mahalanobis distance, which takes into account the non-uniformity of the feature space:

[0067] Meanwhile, to improve numerical stability, we add a regularization term to the covariance matrix: , where is the regularization coefficient.

[0068] MSMPN adopts a cross-entropy loss function with a temperature parameter to train the model in the meta-learning framework:

[0069] where, is the learnable temperature parameter that controls the smoothness of the class probability distribution. A smaller produces a steeper distribution, enhancing the discriminative ability of the model; a larger produces a smoother distribution, improving the generalization of the model; represents the support set, i.e., the set of labeled samples used for prototype computation, represents the samples and their labels in the support set, and N represents the number of samples in the support set .

[0070] To prevent overfitting, this embodiment adds an L2 regularization term:

[0071] The final total loss is: 。

[0072] The specific implementation process of constructing, training, and validating the MSMPN framework is as Figure 4 shown, and specifically includes the following steps: Step 1: Experimental data preparation and preprocessing.

[0073] In this embodiment, a dataset for few-shot medical image classification is constructed using the latest version of MedMNIST+. MedMNIST+ contains 18 sub-datasets, each of which covers images of different categories and modalities, and all images are uniformly resized to 128 × 128 pixels. This embodiment selects 6 representative sub-datasets, including PathMNIST (histopathology), DermaMNIST (skin lesions), BreastMNIST (breast ultrasound), OCTMNIST (optical coherence tomography of the retina), PneumoniaMNIST (chest X-ray), and OrganCMNIST (organ CT). These sub-datasets have highly diverse modalities, can comprehensively cover the characteristics of medical imaging tasks, and provide a basis for reliable evaluation of the model in actual clinical scenarios.

[0074] To evaluate the generalization ability of the model on unseen categories, this embodiment designs a cross-dataset meta-learning strategy with non-overlapping category partitions. This strategy aims to test the knowledge transfer ability of the model in different medical image processing fields to meet the actual needs of generalization ability in clinical practice. Specifically, the meta-learning framework of this experiment is divided into the following three stages: (1) Meta-training stage: In this stage, 9 categories are selected from PathMNIST, including adipose tissue, background, and debris, etc. In addition, two categories of basal cell carcinoma and benign keratotic lesions are selected from DermaMNIST. Through the training of these categories, this stage provides a rich basis for the model to learn medical image features.

[0075] (2) Meta-validation phase: In this phase, two categories of melanoma and melanocytic nevus were selected from DermaMNIST, the normal category was selected from BreastMNIST, four categories such as choroidal neovascularization and diabetic macular edema were selected from OCTMNIST, two categories of normal and pneumonia were selected from PneumoniaMNIST, and the bladder category was selected from OrganCMNIST. Through this verification step, the performance of the model was further evaluated and adjusted.

[0076] (3) Meta-testing phase: This phase focuses on the evaluation of a brand-new domain, using only 10 categories in OrganCMNIST, including left / right femur, heart, left / right kidneys, liver, left / right lungs, pancreas, and spleen. These categories do not overlap with the training and validation phases at all, aiming to test the knowledge transfer ability of the model in a brand-new domain.

[0077] In the test set, this embodiment only uses the categories from OrganCMNIST, focusing on evaluating whether the model can transfer the knowledge learned from multiple medical imaging modalities to a completely unfamiliar domain. Through this cross-domain evaluation, this embodiment simulates a real clinical scenario, verifies the generalization ability of the model on unseen categories, and further proves its practical application value in medical image analysis.

[0078] Step 2: Model initialization and configuration.

[0079] In this experiment, ResNet-12 was used as the basic feature encoder, and the network structure of ResNet-12 is as Figure 5 shown. In this embodiment, it was first widely trained on a public dataset to obtain better pre-trained weights, which is convenient for providing high-dimensional feature inputs for MSMPN.

[0080] To construct a complete MSMPN model, this embodiment implements the following module configurations: SSCM: The input image is segmented using a four-window slicing strategy, with a 25% overlap rate between slices, and a learnable position encoding is designed to incorporate spatial position information into the feature representation; MSEM: Configure a Mamba model with a state dimension of 16 and an internal feature dimension of 128 for efficiently processing feature sequences; DAPC: Implement a prototype calculation method based on Mahalanobis distance, and add a regularization coefficient of 0.1 to ensure numerical calculation stability.

[0081] Step 3: Implement the training process.

[0082] The training adopted the Adam optimizer with an initial learning rate set to 3e-4, and a cosine annealing strategy was used for learning rate scheduling. To enhance the model's generalization ability, data augmentation techniques such as random rotation (±30°), scaling (0.85 - 1.15), and brightness and contrast adjustment (±30%) were applied to the support set samples.

[0083] The training batch size was set to 4, and the cumulative gradient update strategy was used to stabilize the training process. To prevent overfitting, weight decay (1e-4) and label smoothing (0.1) techniques were applied. The training process was carried out on a high-performance computing platform equipped with NVIDIA GPUs, and mixed-precision training technology was used to improve the computational efficiency.

[0084] The training adopted the meta-learning paradigm. In each training epoch, multiple 5-way tasks were randomly constructed and alternately trained under the 1-shot and 5-shot settings to enhance the model's adaptability under different sample numbers.

[0085] Step 4: Sequence construction and feature enhancement.

[0086] During the experiment, the detailed implementation steps for the overlapping slicing strategy of the SSCM module were as follows: (1) Overlapping slices were made for each input image using the sliding window technique with a window size of 32×32 pixels and an overlap rate of 25%; (2) Feature representations were extracted for each slice using a pre-trained feature encoder; (3) Learnable position encoding was added to fuse the spatial position information; (4) An importance evaluation network was used to assign weight scores to each slice; (5) A space-aware attention mechanism was applied, considering semantic similarity, spatial distance, and importance scores comprehensively; (6) An enhanced feature sequence was obtained through weighted aggregation.

[0087] For the MSEM module, a sequence processing flow based on Mamba was implemented: (1) The aggregated feature sequence was input for layer normalization; (2) The main path features and residual path features were separated through linear projection; (3) One-dimensional convolution was used to extract local feature patterns; (4) SSM parameter generation and selective scanning were applied to process the sequence data; (5) The two-way features were integrated through a gating mechanism to obtain an enhanced sequence representation.

[0088] Step 5: Prototype representation and classification decision.

[0089] In the DAPC module, the following steps are implemented to construct a distribution-aware prototype representation: (1) For the support set samples of each category, calculate the feature mean vector; (2) Calculate the covariance matrix of the intra-class features to capture the distribution shape; (3) Add a regularization term to the covariance matrix to ensure numerical stability; (4) For the query samples, calculate the Mahalanobis distance to the prototypes of each category; (5) Apply the Softmax function with a temperature parameter to obtain the class probability distribution; (6) Select the category with the highest probability as the final classification result.

[0090] Step 6: Performance evaluation and ablation experiments.

[0091] In the evaluation stage, a 5-way task is used to test the model performance under the 1-shot and 5-shot settings respectively, and the number of query samples for each category is 8. To ensure the reliability of the evaluation results, 600 tasks are randomly generated under each test setting, and the average classification accuracy and its 95% confidence interval are reported.

[0092] To deeply analyze the contributions of each component, this embodiment designs two groups of key ablation experiments: 1. Analysis of the influence of feature dimension: Test the model performance under the 128, 256, and 512-dimensional feature representations respectively; 2. Analysis of component contributions: Evaluate the importance of each component by removing or replacing the SSCM, MSEM, and DAPC modules.

[0093] In addition, this embodiment comprehensively compares MSMPN with traditional few-shot learning methods (such as prototype network, relation network, matching network, MetaOpt, etc.) to verify its advantages in the few-shot medical image classification task.

[0094] The multi-slice Mamba prototype network (MSMPN) proposed by the present invention has achieved multiple technological innovations in the field of few-shot medical image classification, which are mainly reflected in the following key aspects: First, the Semantic Sequence Construction Module (SSCM) is an innovative module specifically designed for the key features of the Mamba state space model. For the Mamba model to fully leverage its advantages, it requires long sequences with rich semantic information as input, which is difficult to provide using traditional medical image processing methods. SSCM addresses this core issue through an innovative overlapping slicing strategy, dividing medical images into local regions that maintain spatial continuity to generate long sequence representations suitable for Mamba processing. This module uses an overlap rate of 25% to ensure feature continuity in the boundary regions, introduces learnable positional encoding to retain spatial information, and designs a spatially aware attention aggregation mechanism that takes into account semantic similarity, spatial distance relationships, and regional importance scores between slices, effectively converting 2D medical images into 1D long sequence features that can be efficiently processed by Mamba.

[0095] Second, the Mamba-based Sequence Enhancement Module (MSEM) makes full use of the selective state space model characteristics of Mamba to process the long sequences generated by SSCM. The core advantage of Mamba lies in its linear computational complexity and data-dependent selection mechanism, enabling it to efficiently process the long sequence features generated by SSCM. This module fuses the features of the main path and the residual path through a selective scanning process and a gating mechanism, effectively capturing long-range dependencies in medical images while maintaining computational efficiency, which is crucial for understanding relevant pathological features scattered in different regions of the image.

[0096] Third, the Distribution-Aware Prototype Computation Module (DAPC) addresses the problem of the complex feature sequence representation output by Mamba. Since the feature sequences generated by Mamba have complex distribution characteristics, traditional prototype networks using only the mean representation method cannot fully characterize this complexity. DAPC introduces a prototype representation method based on Mahalanobis distance, considering both the mean vector and the covariance matrix, to comprehensively capture the distribution information of the Mamba output features, enabling the model to more accurately distinguish complex classes in medical images. This distribution-aware prototype representation method forms a perfect match with the rich feature sequences generated by Mamba, providing a more accurate decision boundary for few-shot medical image classification.

[0097] Through the organic combination of the above innovative technologies, the present invention forms a complete technical chain: SSCM generates long sequence inputs suitable for Mamba processing, MSEM efficiently processes these sequences and extracts complex feature representations, and DAPC precisely characterizes the distribution characteristics of these complex features for classification decisions. This end-to-end architecture specifically designed for Mamba characteristics breaks through the fundamental problem of the insufficient adaptability of traditional few-shot learning methods in the field of medical images, providing an efficient, robust, and practical technical path for medical diagnosis assistance systems.

[0098] To further illustrate the technical effects of the present invention, the following experimental results are provided.

[0099] First, the experimental environment is shown in Table 1: Table 1 Detailed parameters for network model training

[0100] Table 2 shows the 5-way classification results of the method of the present invention and baseline methods such as the prototype network and the relation network on mini-MedMNIST.

[0101] Table 2 Experimental comparison and evaluation between the present invention and baseline methods

[0102] As can be seen from Table 2, the method of the present invention achieves an accuracy of 53.92% in the 1-shot test, showing a small gap compared with MetaOpt, but reaches an accuracy of 68.73% in the 5-shot test, significantly exceeding all comparison methods.

[0103] In terms of the performance improvement from 1-shot to 5-shot, the accuracy of the method of the present invention increases by 14.81%, much higher than other methods such as the prototype network and MetaOpt. This phenomenon indicates that the Mamba architecture design of the present invention shows greater advantages when the number of samples increases. The MSEM module of the present invention can more comprehensively capture the relationship patterns between samples in the case of multiple samples through its efficient linear complexity sequence processing ability, making the performance improvement more significant when the samples increase.

[0104] Although the performance of the present invention is comparable to that of other methods in the 1-shot test, the significant advantage in the 5-shot results proves the practical value of the architecture of the present invention in actual medical application scenarios. In most real medical applications, multiple samples per class can usually be obtained, rather than a strictly single-sample situation. The excellent performance of the model of the present invention under such actual conditions confirms the effectiveness of MSMPN in capturing complex relationships between samples and integrating multi-source information.

[0105] The results of the ablation experiment are shown in Table 3: Table 3 Comparison of input feature dimensions of MSMPN

[0106] The ablation experiment results show that the model achieves the best performance (53.19%) when the feature dimension is 256, rather than 512 (50.85%) with a higher dimension or 128 (49.55%) with a lower dimension. This indicates that the model performance does not always improve with the increase of the representation dimension, but there is an optimal point. In the few-shot learning scenario, a feature dimension of 256 provides a balance between representation ability and generalization. When the dimension is too low (128), the model lacks sufficient representation ability to capture complex feature relationships; while when the dimension is too high (512), the model is prone to overfitting in the case of extremely few samples, resulting in performance degradation.

[0107] The ablation comparison results of the MSMPN components are shown in Table 4: Table 4 Ablation Comparison of MSMPN Components

[0108] The ablation experiments on different component combinations further reveal the contributions of each module. When all three core modules of SSCM, MSEM, and DAPC are used, the model of the present invention performs best in the 5-shot task. Notably, when Mamba is replaced by Transformer, the model achieves the highest accuracy (55.49%) in the 1-shot task, indicating that in the case of extremely few samples, the global self-attention mechanism of Transformer can provide certain advantages. However, as the number of support set samples increases from 1 to 5, the model needs to handle more complex intra-class distributions and variabilities. At this time, the efficient sequence processing ability of Mamba enables it to show advantages in integrating multi-sample information.

[0109] Comprehensive analysis shows that the MSMPN framework of the present invention not only outperforms existing methods in terms of performance, but more importantly, it exhibits the characteristic of significant performance improvement with the increase in the number of samples, which has important practical value for the field of medical image analysis. This advantage stems from the collaborative work of three key components in the MSMPN architecture: SSCM retains spatial continuity through the overlapping slice strategy, MSEM utilizes the efficient sequence processing ability of Mamba to capture long-range dependencies, and DAPC improves the classification accuracy by considering the intra-class distribution characteristics.

[0110] Some steps in the embodiments of the present invention can be implemented by software, and the corresponding software program can be stored in a readable storage medium, such as an optical disc or a hard disk, etc.

[0111] The above are only the preferred embodiments of the present invention and are not intended to limit the present invention. Any modifications, equivalent replacements, improvements, etc. made within the spirit and principles of the present invention shall be included in the protection scope of the present invention.

Claims

1. A small sample medical image classification method, characterized in that: The following steps are involved: Step 1: Segment the input medical image into a sequence of overlapping slices with spatial context information through a semantic sequence building module; The processing process of the semantic sequence building module includes: Given an input image , using a size of The window and overlap ratio To slice: in, and are the steps in height and width respectively, i and j Respectively represent the height and width position index; Step 2: Use the encoder to extract the feature representation of each slice and add the positional encoding; Step 3: Processing the feature sequence through a sequence enhancement module to capture long-range dependencies, wherein the sequence enhancement module uses a Mamba state space model to process the feature sequence; Step 4: constructing a category prototype that takes feature distribution into consideration using a distribution-aware prototype calculation module, wherein the distribution-aware prototype calculation module constructs a prototype representation including a mean vector and a covariance matrix for each category; Step 5: Use Mahalanobis distance to calculate the distance between the query sample and the prototype of each category and make a classification decision.

2. The small sample medical image classification method according to claim 1, characterized in that: The step 2 also includes: Introducing learnable positional encodings ,in L Indicates the total number of slices, is the slice feature dimension; The position code is added to the features of each slice, expressed as: in, represents the enhanced features containing spatial information, Represents the characteristics of the slice, Indicates the i , j ) slice position codes; Assign each slice a score reflecting its importance to the classification decision: in, represents the importance evaluation network, Indicates Spatial enhancement features of slices; Calculate the attention weights: in, Indicates the construction of a spatial relationship matrix based on the distance between slice center points. Used to control the influence of importance, Respectively represent i The slice enhancement features and j Slice enhancement features, represents the semantic similarity of slice features, Representing slices i With slices k The spatial relationship matrix elements of; Finally, the enhanced feature sequence is obtained through weighted aggregation: in, represents the enhanced feature sequence after weighted aggregation, express, B Indicates the batch size.

3. The small sample medical image classification method according to claim 2, characterized in that: The step 3 comprises: Step 31: normalize the aggregate feature sequence input layer; Step 32: Separate the main path features and the residual path features through linear projection; Step 33: Use one-dimensional convolution to extract local feature patterns; Step 34: Apply SSM parameters to generate and selectively scan the processed sequence data; Step 35: Integrate the two-way features through a gating mechanism to obtain an enhanced sequence representation.

4. The small sample medical image classification method according to claim 1, characterized in that: The calculation method of the Mahalanobis distance is: in, represents a query sample, Represents the category prototype, Indicates category c The mean of all sample features, Indicates category c The covariance matrix of all sample features.

5. The small sample medical image classification method according to claim 4, characterized in that: It also includes adding a regularization term to the covariance matrix: ,in, is the regularization coefficient and I represents the identity matrix.

6. The small sample medical image classification method according to claim 1, characterized in that: The method adopts a cross entropy loss function with a temperature parameter to train the model under a meta-learning framework. The cross entropy loss function is expressed as: in, is a learnable temperature parameter that controls the smoothness of the class probability distribution; represents the support set, i.e., the set of labeled samples used for prototype calculation, Support set The samples and their labels in N Support set The number of samples in .

7. The small sample medical image classification method according to claim 6, characterized in that: Add an L2 regularization term to the cross entropy loss function: in, represents the L2 regularization coefficient, which is used to control the weight of the parameter norm penalty term. Represents the set of all trainable parameters of the model; The final total loss is: 。 8. A small sample medical image classification system, characterized in that: The system is used to implement the small sample medical image classification method according to any one of claims 1 to 7, comprising: An image acquisition module, used for acquiring medical images to be classified; A semantic sequence building module for segmenting medical images into overlapping slice sequences with spatial context information; The processing process of the semantic sequence building module includes: Given an input image , using a size of The window and overlap ratio To slice: in, and are the steps in height and width respectively, i and j Respectively represent the height and width position index; A feature extraction module is used to extract feature representations of each slice using an encoder and add positional encoding; A sequence enhancement module, used for processing feature sequences and capturing long-distance dependencies, wherein the sequence enhancement module uses a Mamba state space model to process the feature sequences; A distribution-aware prototype calculation module, used to construct a category prototype that takes feature distribution into consideration, wherein the distribution-aware prototype calculation module constructs a prototype representation including a mean vector and a covariance matrix for each category; The classification decision module uses the Mahalanobis distance to calculate the distance between the query sample and the prototype of each category and make a classification decision.

9. A small sample medical image classification device, characterized in that: including memory and processor; The memory is used to store computer programs; The processor is used to implement the small sample medical image classification method according to any one of claims 1 to 7 when executing the computer program.

10. A computer-readable storage medium, characterized in that: The storage medium stores a computer program, and when the computer program is executed by the processor, the small sample medical image classification method according to any one of claims 1 to 7 is implemented.

Citation Information

Patent Citations

  • Pathological image classification method based on prototype consistency pseudo packet division

    CN117710722A

  • Deep hash media search method of double-branch attention mechanism

    CN118035483A

  • Small sample medical image classification method and system and storage medium

    CN118429724A

  • Multi-class welding spot defect classification method, system and equipment based on Transform and channel interaction and medium

    CN119851043A

  • Machine learning based generation of ontology for structural and functional mapping

    US20200401938A1

Cited By

  • Ultrasonic image classification method, device and equipment and readable storage medium

    CN121121315A

  • An ultrasonic image classification method, device, equipment and readable storage medium

    CN121121315B

  • Structure and semantics double-aligned few-sample graph prompt learning method and device

    CN122389990A