A method and system for pathological classification of pulmonary nodules based on dynamic phenotypic subspace inference
By constructing a dynamic multi-center feature template library and optimizing the joint loss function, the problem of accuracy in identifying pathological subtypes of pulmonary nodules in CT images was solved, achieving accurate diagnosis of pulmonary nodules and reducing the risk of misdiagnosis.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- HUAZHONG UNIV OF SCI & TECH
- Filing Date
- 2026-06-10
- Publication Date
- 2026-07-10
AI Technical Summary
Existing technologies struggle to accurately identify the pathological subtypes of lung nodules in CT images, especially the subtle changes in lung adenocarcinoma, resulting in low diagnostic efficiency and a high misdiagnosis rate, failing to meet the clinical needs for precise diagnosis and treatment of early-stage lung cancer.
A dynamic multi-center feature template library is constructed. Through cosine similarity matching and joint loss function optimization, it explicitly accommodates intra-class phenotypic diversity. Combined with ordinal consistency constraints, the template library is dynamically updated to achieve accurate identification of lung nodules.
It significantly improved the diagnostic accuracy of pathological subtypes of pulmonary nodules, reduced the risk of misdiagnosis, enhanced the clinical interpretability and reliability of the model, and improved its generalization ability to complex pulmonary nodule images.
Smart Images

Figure CN122368069A_ABST
Abstract
Description
Technical Field
[0001] This invention belongs to the field of medical image processing and computer-aided diagnosis technology, specifically relating to a method and system for pathological classification of pulmonary nodules based on dynamic phenotypic subspace inference. Background Technology
[0002] Lung cancer is one of the leading causes of cancer-related deaths worldwide. Non-small cell lung cancer (NSCLC) accounts for approximately 85% of all lung cancers, and lung adenocarcinoma (LUAD), the most common histological subtype of NSCLC, constitutes a major component of early-detected lung cancer. Pathologically, lung adenocarcinoma evolves from glandular progenitor lesions (PGL, including atypical adenomatous hyperplasia (AAH) and carcinoma in situ (AIS),) microinvasive adenocarcinoma (MIA), to invasive adenocarcinoma (IAC). IAC is further subdivided into well-differentiated (IAC)... I) Intermediate Differentiation (IAC) II) and low differentiation (IAC) III) Subtypes: Different pathological subtypes have significant differences in malignancy, timing of intervention, and prognosis. Therefore, non-invasive and accurate identification of pathological subtypes before surgery is of great clinical value for developing individualized surgical plans and prognostic assessments.
[0003] Early-stage lung cancer often presents as small pulmonary nodules, with low detection rates on routine X-ray examinations. Chest CT provides three-dimensional structural, morphological, density, and internal texture information, making it the core imaging tool for pulmonary nodule diagnosis. Clinically, radiologists need to analyze CT images layer by layer, combining nodule size, shape, margins, density, and texture characteristics for qualitative judgment. However, pulmonary nodules exhibit complex morphological variations and overlap with surrounding anatomical structures, making manual image interpretation inefficient, prone to missed diagnoses, and highly dependent on subjective experience, resulting in poor consistency. For fine pathological grades such as AAH, AIS, MIA, and IAC, subtle textural differences in images are difficult to quantify and identify with the naked eye, failing to meet the clinical needs for precise diagnosis and treatment of early-stage lung cancer.
[0004] To improve diagnostic efficiency and objectivity, researchers have proposed various computer-aided diagnostic (CAD) methods based on traditional machine learning. These methods typically begin by defining nodule boundaries using morphological and region growing algorithms, then extract low-level texture and geometric features such as the gray-level co-occurrence matrix (GLCM) and local binary pattern (LBP), and finally input these features into classifiers such as support vector machines (SVM) and random forests to determine benign or malignant nodules. However, these methods heavily rely on the quality of manually designed features, making it difficult to uncover the complex, high-dimensional heterogeneity within nodules, and their generalization ability is limited, hindering the completion of multi-subtype fine-grained classification tasks.
[0005] In recent years, deep learning, especially convolutional neural networks (CNNs), has been widely applied to lung nodule image analysis due to its end-to-end high-dimensional feature self-learning capabilities. However, most existing deep learning methods simply model pathological subtype classification as a direct mapping from images to discrete category labels, implicitly assuming that different subtypes are mutually separated and compact within their respective CT image feature spaces, possessing clear and stable discrimination boundaries. This assumption does not align with clinical reality: pathological subtypes are determined by microscopic histological features such as the degree of cell infiltration, glandular structure, and growth pattern, which cannot be directly observed in macroscopic CT images; in actual clinical data, the phenotypes of different subtypes often highly overlap, and the phenotypes of the same subtype exhibit strong heterogeneity. Forcing the network to learn rigid and compact intra-class features not only violates the objective law of complex and variable nodule morphology but also easily leads to feature confusion, resulting in inaccurate grading, a high risk of misdiagnosis, and difficulty in meeting the stringent requirements of accurate clinical grading and intervention timing. Summary of the Invention
[0006] To address one or more of the above-mentioned deficiencies or improvement needs of existing technologies, this invention provides a method and system for pathological classification of pulmonary nodules based on dynamic phenotypic subspace inference. By constructing a dynamic multi-center feature template library, it explicitly accommodates intra-class phenotypic diversity. Combining ordinal consistency constraints and dynamic template update strategies, it can effectively learn continuous feature representations of the evolution of pathological malignancy, thereby achieving dynamic matching and accurate identification of complex pulmonary nodule phenotypes and assisting in precise clinical diagnosis and treatment.
[0007] To achieve the above objectives, according to one aspect of the present invention, a method for pathological classification of pulmonary nodules based on dynamic phenotypic subspace inference is provided, comprising the following steps: S1. Preprocess the CT images of lung nodules and construct a multicenter feature template library containing multiple gradient-free dynamic prototype templates for each pathological category, which serves as the image representation subspace for each pathological subtype. S2. Input the preprocessed CT image into the feature extractor to extract the query feature, calculate the similarity between the query feature and the templates in the template library, and use the maximum similarity among multiple templates in each category as the similarity score for that category. S3. Based on the similarity score and the true label, construct a joint loss function including cross-entropy loss and hierarchical loss, and update the network parameters of the feature extractor through gradient backpropagation, wherein the hierarchical loss applies a penalty based on the ordinal span between the predicted class and the true class; S4. During training, evaluate the novelty of the samples and the redundancy between templates, and perform gradient-free dynamic replacement of redundant templates in the template library with new samples that meet the preset conditions. S5. Input the CT image to be tested into the trained feature extractor, extract the query features and match them with the template library frozen after training, and output the pathology category prediction result based on the matching result.
[0008] As a further improvement of the present invention, in S1, the method for preprocessing the three-dimensional CT images of lung nodules is as follows: the acquired CT images of lung nodules are resampled to a uniform voxel spacing, a region of interest of a set size is cropped according to the center of the nodules, and the CT values are truncated to the lung window range and normalized.
[0009] As a further improvement of the present invention, in S1, the method for constructing a multi-center feature template library is as follows: assuming there are C pathological categories, k dynamic prototype templates are randomly initialized for each category using a standard Gaussian distribution, and a template library matrix with a total size of C×k is constructed as an image representation subspace that allows phenotypic variations for each pathological subtype.
[0010] As a further improvement of the present invention, S2 specifically includes: The preprocessed CT images are input into the feature encoder and nonlinear mapping head to extract the query feature vectors that have been normalized by L2. Calculate the cosine similarity between the query feature vector and all templates in the template library; A max pooling strategy is adopted, and the maximum cosine similarity between the query feature vector and all k templates in the Nth category is selected as the similarity score for that category.
[0011] As a further improvement of the present invention, S2 further includes a step of post-processing the similarity score, wherein the post-processing includes temperature scaling, constant scaling, or dynamic scaling factor adjustment; or, in S2, an additive cosine interval or angular interval is introduced in the similarity calculation.
[0012] As a further improvement of the present invention, in S3, the construction of the joint loss function including cross-entropy loss and hierarchical loss specifically includes: The similarity scores are processed using the Softmax function to obtain the predicted probability distribution. Let y be the one-hot encoded vector corresponding to the true pathological category label, and calculate the cross-entropy loss using the following formula: (3) in, This represents the probability that a sample belongs to the Nth class. C represents the total number of pathological subtypes of pulmonary nodules; For the Nth component of the one-hot encoded vector y, when the sample truly belongs to the Nth class... ,otherwise ; Calculate the graded loss using the following formula: (4) Where C represents the total number of pathological subtypes of pulmonary nodules; i is the category hierarchy index when calculating the cumulative distribution; and j is the category index variable for internal summation. This represents the probability that the model predicts a sample belongs to the j-th pathological category. This represents the component in the true label one-hot encoded vector corresponding to the j-th pathological category; This represents the cumulative probability of the predicted probability distribution up to and including the i-th class; This represents the cumulative distribution of the true labels in the i-th class and earlier. Calculate the joint loss function using the following formula : (5) in, For cross-entropy loss, For graded loss, This is the balance coefficient.
[0013] As a further improvement of the present invention, S4 specifically includes: For candidate samples that are correctly classified, extract their normalized feature vectors and construct a temporary joint feature set with multiple old template features under the current category; Calculate the full cosine similarity matrix of the temporary joint feature set; The baseline redundancy of the original template library is calculated based on the full cosine similarity matrix, and the maximum redundancy of the corresponding subset after replacing each old template with the candidate sample. Select the replacement scheme that will reduce redundancy the most. If the reduction in redundancy is greater than a preset threshold, then perform the replacement operation.
[0014] As a further improvement of the present invention, S5 specifically includes: Normalized query features of the CT image to be tested are extracted, and the cosine similarity between the image and all templates in the frozen template library is calculated. The maximum similarity of multiple templates under each category is taken as the similarity score of that category. After Softmax processing, the probability distribution is output, and the category corresponding to the highest probability is taken as the prediction result.
[0015] According to another aspect of the present invention, a lung nodule pathological typing system based on dynamic phenotypic subspace inference is provided, applied to the lung nodule pathological typing method based on dynamic phenotypic subspace inference, comprising: The data preprocessing module is used to preprocess the three-dimensional CT images of lung nodules; The subspace construction module, connected to the data preprocessing module, is used to receive preprocessed CT images and construct a multicenter feature template library containing multiple gradient-free dynamic prototype templates for each pathological category, serving as the image representation subspace for each pathological subtype. The feature extraction module, connected to the data preprocessing module, is used to receive the preprocessed CT images and extract the normalized query feature vector. The consistency measurement module is connected to the subspace construction module and the feature extraction module respectively. It is used to calculate the cosine similarity between the query feature vector and all templates in the template library, and for each pathological category, the maximum similarity among all templates is taken as the similarity score of that category. The joint optimization module is connected to both the consistency measurement module and the feature extraction module. It is used to construct a joint loss function based on the similarity score and the true label, and to update the network parameters of the feature extraction module through gradient backpropagation. The joint loss function includes cross-entropy loss and hierarchical loss. The template dynamic update module is connected to the joint optimization module and the subspace construction module respectively. It is used to receive the features of correctly classified samples, evaluate their redundancy with the current template library, and perform gradient-free dynamic replacement operation on highly redundant templates to update the template library in the subspace construction module. The prediction output module is used to output the pathology category prediction result after the similarity score of the CT image to be tested is processed by Softmax based on the trained feature extractor and the frozen template library during the testing phase.
[0016] As a further improvement of the present invention The feature extraction module includes a feature encoder and a nonlinear mapping head; The consistency measurement module includes a similarity calculation unit and a max pooling unit; The template dynamic update module includes a redundancy assessment unit, a replacement decision unit, and a template update unit. The prediction output module includes a probability conversion unit and a decision output unit.
[0017] In summary, the technical solutions conceived by this invention have the following beneficial effects compared with the prior art: (1) This invention abandons the traditional linear classifier's black-box discrete label mapping paradigm, which forces a tight separation of feature spaces and ignores the heterogeneity of real clinical phenotypes, and proposes a non-parametric classification framework based on consistency inference. This method constructs a dynamic multi-center feature template library, learns multiple prototypes for each pathological subtype, and explicitly stores the typical morphology of various nodules. The prototype-based matching mechanism does not require forced compression of variant samples, avoids feature confusion, and effectively solves the problem of highly heterogeneous nodule phenotypes and large intra-class differences in clinical data. At the same time, this mechanism makes the classification basis clearly visible; doctors can not only intuitively view the prototype images that highly match the query samples and their corresponding real case reports, but also trace the common feature distribution of the same type of cases they represent in the feature space; this multi-dimensional evidence presentation enables doctors to thoroughly understand the model's judgment logic, thereby giving the model a high degree of clinical interpretability and trustworthiness.
[0018] (2) Given that the pathological evolution of pulmonary nodules has a continuous ordinal attribute of gradually increasing malignancy, this invention introduces a grading loss for joint optimization. The grading loss applies an adaptive penalty based on the ordinal span between the predicted and true categories: the greater the span, the heavier the penalty; the lighter the penalty, the more confusion between adjacent categories. This design forces the feature space to present a continuous manifold structure that conforms to the pathological evolution law, making the model's misdiagnosis behavior highly consistent with clinical cognition. That is, misdiagnosis mainly occurs between adjacent pathological grades, while serious misdiagnosis spanning multiple grades is greatly suppressed, significantly improving the clinical safety of the model.
[0019] (3) Traditional linear classifiers with hierarchical losses can lead to gradient conflicts and performance degradation. However, this invention provides a unified optimization basis for cross-entropy loss and hierarchical loss by constructing a multi-center metric space based on hyperspherical cosine similarity. The two losses are optimized collaboratively on a shared feature encoder, transforming from conflict and adversarial to collaborative complementarity. This achieves joint optimization of basic classification accuracy and ordinal relation constraints, resulting in a significant leap in accuracy on the test set.
[0020] (4) This invention innovatively decouples the gradient update of network parameters from the diversity update of the template library. The template library does not participate in gradient backpropagation, but instead performs gradient-free dynamic replacement of highly redundant templates by using new samples that bring the maximum diversity gain through redundancy evaluation and novelty discrimination based on the cosine similarity matrix. This strategy actively maximizes the diversity of the metric space, accurately eliminates the most mediocre old templates and selectively absorbs highly specific new samples, completely preventing the problems of template homogenization and pattern collapse in traditional prototype networks, and significantly improving the model's generalization ability to complex and rare lung nodule images.
[0021] (5) This invention underwent extensive ablation experiments and comparative validation on a real pulmonary nodule CT image dataset containing five pathological subtypes (PGL, MIA, IAC-Ⅰ, IAC-Ⅱ, IAC-Ⅲ). Experimental results show that this invention significantly outperforms traditional baseline models and various ablation configurations (Comparative Examples 1-7) in terms of accuracy on both the validation and test sets. Sankey diagram visualization analysis further confirms that this invention effectively converges the vast majority of misjudgment flows to adjacent pathological categories, significantly suppressing severe cross-level misdiagnosis, and the model's predictive behavior highly matches the clinical diagnostic logic of doctors. Based on the comprehensive quantitative indicators and visualization results, this invention can provide a safe and reliable objective basis for the accurate diagnosis and treatment of early-stage lung cancer.
[0022] (6) The present invention also provides a pathological typing system corresponding to the above method, including a data preprocessing module, a subspace construction module, a feature extraction module, a consistency measurement module, a joint optimization module, a template dynamic update module, and a prediction output module. Each module has a clear division of labor and a clear connection relationship. The gradient loop and the template update loop are decoupled, providing stable and scalable feature support for dynamic updates and consistency measurement, which facilitates subsequent technology iteration and clinical deployment. Attached Figure Description
[0023] Figure 1 This is a flowchart illustrating the training phase of the lung nodule pathological classification method based on dynamic phenotypic subspace inference in an embodiment of the present invention. Figure 2 This is a schematic diagram of the consistency inference process during the testing phase of the lung nodule pathological classification method based on dynamic phenotypic subspace in an embodiment of the present invention. Figure 3 This is a schematic diagram of the network architecture of the 3D CNN feature encoder and nonlinear mapping head in an embodiment of the present invention; Figure 4 Sankey diagrams showing the relationship between prediction results from different models and actual pathological label flow in embodiments of the present invention; Figure 5 This is a schematic diagram of the module structure of the lung nodule pathological classification system based on dynamic phenotypic subspace inference in an embodiment of the present invention. Detailed Implementation
[0024] To make the objectives, technical solutions, and advantages of this invention clearer, the invention will be further described in detail below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative and not intended to limit the invention. Furthermore, the technical features involved in the various embodiments of this invention described below can be combined with each other as long as they do not conflict with each other.
[0025] See Figure 1 and Figure 2The lung nodule pathological classification method based on dynamic phenotypic subspace inference according to embodiments of the present invention includes the following steps: Step (1): Data preprocessing and construction of multicenter phenotypic subspace Three-dimensional CT images of pulmonary nodules are preprocessed, and multiple gradient-free dynamic prototype templates are initialized for each pathological category in the feature space. These templates are then used to construct a gradient-free dynamic multicenter feature template library, which serves as an image representation subspace that allows phenotypic variations in each pathological subtype.
[0026] Specifically, the method for preprocessing the three-dimensional CT images of lung nodules is as follows: the acquired CT images of lung nodules are resampled and the voxel spacing is standardized to eliminate sampling differences caused by different devices; a region of interest (VOI) of a set size is cropped according to the marked nodule center to focus on the lung region and exclude irrelevant anatomical structures such as the chest wall and mediastinum; then the image intensity is normalized, the CT value range is truncated to the lung window range and normalized (in this embodiment, it is normalized to the [0,1] interval) to meet the input requirements of the neural network.
[0027] The method for constructing a gradient-free dynamic multicenter feature template library is as follows: Suppose there are C pathological categories. Use a standard Gaussian distribution to randomly initialize k dynamic prototype templates for each category, and construct a template library matrix with a total size of C×k, which serves as the image representation subspace for each pathological subtype that allows phenotypic variation.
[0028] Preferably, the value of k ranges from 3 to 6. If the value of k is too small (e.g., k=1), the template library degenerates into a single-center representation, which cannot effectively characterize the multimodal distribution within the same pathological subtype, leading to underfitting. If the value of k is too large, the template redundancy between categories increases, easily causing blurred inter-class boundaries and overfitting. In this embodiment, k=4, achieving the optimal balance between fully characterizing intra-class heterogeneity and maintaining clear inter-class boundaries.
[0029] To address the issue that pulmonary nodules of the same pathological subtype may exhibit multiple morphological variations (i.e., high intra-class variance) in medical imaging, this invention overcomes the shortcomings of existing technologies that simply model pathological subtype classification as discrete label mapping and force compact separation of feature spaces while ignoring phenotypic overlap and intra-class heterogeneity in real clinical data. It proposes a pulmonary nodule pathological classification method based on dynamic phenotypic subspace inference. This method abandons the rigid boundary discrimination paradigm, constructs a dynamically updatable multi-center feature template library, explicitly stores typical phenotypic features of various nodules, and sets multiple prototypes (typical phenotypic centers) for each subtype. It avoids the need for forced compression of variant samples, thus preventing feature confusion and misclassification. Simultaneously, this mechanism makes the classification criteria clearly visible, allowing doctors to intuitively view the matched prototype images and understand the judgment logic, thereby endowing the model with high interpretability. Furthermore, the template library is decoupled from the network backbone with a gradient-free independent structure, providing stable support for dynamic updates and consistency measurement, significantly improving the model's generalization ability to complex pulmonary nodule images.
[0030] Step (2): Matching based on cosine similarity consistency metric The preprocessed CT images are input into the 3D CNN feature encoder and mapping head to extract the normalized query feature vector and calculate the cosine similarity between the query feature and all templates in the template library. For each pathological category, the maximum pooling strategy is adopted, and the highest similarity among all templates in that category is taken as the similarity score of that category.
[0031] Specifically, based on the dynamic multi-center feature template library constructed in step (1), multi-template similarity matching is used to evaluate the consistency between input features and target subspace, achieving accurate discrimination of pathological subtypes without requiring compact intra-class features. The specific network architecture is as follows: Figure 3 As shown.
[0032] Preprocessed 3D lung nodule CT image blocks (X-groups) are batched and fed into an improved 3D UNet backbone network. The network employs five downsampling stages, each containing stacked 3D convolutions, instance normalization, and the LeakyReLU activation function. The number of channels in the feature map gradually increases with network depth, while the spatial resolution is decreased through pooling with a stride of (2,2,2) or convolution with a stride of (2,2,2), ultimately extracting a deep volumetric feature map that integrates multi-scale spatial information and high-order semantic features.
[0033] To perform prototype matching in the metric space, this invention designs a nonlinear mapping head. First, a rearrangement operation completely flattens the high-dimensional deep feature map output from the backbone network in both spatial and channel dimensions, then inputs it into a multilayer perceptron (MLP). This MLP consists of fully connected layers, ReLU activation layers, Dropout layers, and feature reduction layers, compressing and mapping the high-dimensional features into a high-density embedding vector of a set dimension (128 dimensions in this embodiment). This vector is then L2 normalized and projected onto a unit hypersphere to obtain the query feature vector. The network calculates the query feature vector of the current sample through matrix multiplication. The cosine similarity with all C×k templates in the template library is used to evaluate the degree of consistency between the input phenotype and the representation subspace of each pathological subtype.
[0034] Let the template library of the Nth class be... After the network extracts the similarity scores between the query feature q and all k templates in that category, a max pooling strategy is used to select the maximum value as the similarity score for that sample belonging to category N. : (1) This mechanism ensures that the model only needs to match the most similar typical morphology in the category to respond, effectively overcoming the defect in traditional multi-class classification models where a single weight cannot cover the complex intra-class variations of nodules.
[0035] In a preferred embodiment, since the range of cosine similarity is strictly limited to [-1, 1], directly using it for classification can easily lead to an overly flat cross-entropy probability distribution. Therefore, this invention introduces a set low-temperature coefficient τ to scale the maximum similarity score. The preferred range of the low-temperature coefficient τ is 0.01 to 1.0; more preferably, the range is 0.05 to 0.2; in a specific embodiment of this invention, the low-temperature coefficient τ is specifically set to 0.1.
[0036] Specifically, temperature scaling is performed using the following formula: (2) Where τ is the set low temperature coefficient, The scaled similarity score (i.e., the log odds of classification).
[0037] Optionally, to avoid an overly flat probability distribution caused by direct calculation of cosine similarity, in addition to the low-temperature coefficient scaling used in the preferred embodiment of this invention, conventional post-processing methods such as constant scaling or dynamic scaling factor adjustment can also be used. Alternatively, additive cosine intervals or angular intervals can be introduced in the similarity calculation to improve classification confidence and accuracy. Of course, the similarity score can also be directly used for subsequent processing. The above methods are all conventional variations under the technical concept of this invention and do not depart from the protection scope of this invention.
[0038] Step (3): Joint loss optimization based on ordinal consistency and cross-entropy Based on the similarity score and the real label in step (2), a joint loss function containing cross-entropy loss and hierarchical loss is constructed, and the network parameters of the feature encoder and the mapping head are updated through gradient backpropagation; wherein, the hierarchical loss applies a penalty based on the ordinal distance between the predicted result and the real label.
[0039] Given that the pathological evolution of pulmonary nodules exhibits a continuous ordinal property of progressively increasing malignancy, traditional multi-class cross-entropy loss, by assuming absolute independence and mutual exclusion among categories, forces the network to learn extremely sharp discrete boundaries, thereby completely destroying the continuous topological structure of the underlying feature space. To explicitly model this natural evolutionary relationship during consistency inference, this invention constructs a joint loss function that includes both cross-entropy loss and hierarchical loss.
[0040] Specifically, the similarity score output in step (2) is processed by the Softmax function to obtain the predicted probability distribution. Let y be the unique heat encoding vector corresponding to the actual pathological category label; First, calculate the traditional cross-entropy loss. To ensure the accuracy of basic classification: (3) in, This represents the probability that a sample belongs to the Nth class. C represents the total number of pathological subtypes of pulmonary nodules; For the Nth component of the one-hot encoded vector y, when the sample truly belongs to the Nth class... ,otherwise .
[0041] Secondly, to explicitly model the ordinal relationships among pathological subtypes of pulmonary nodules, this invention introduces a distribution distance constraint. Specifically, the mean square error between the cumulative distribution function (CDF) of the predicted distribution and the step-like CDF of the true label is calculated to obtain the grading loss. : (4) Where C represents the total number of pathological subtypes of pulmonary nodules; i is the category hierarchy index when calculating the cumulative distribution; and j is the category index variable for internal summation. This represents the probability that the model predicts a sample belongs to the j-th pathological category. This represents the component in the true label one-hot encoded vector corresponding to the j-th pathological category. When the true category of the sample is j, ,otherwise ; This represents the cumulative probability of the predicted probability distribution in the i-th class and prior to it, i.e., the cumulative distribution function of the predicted distribution; This represents the cumulative distribution state of the true labels in the i-th class and earlier, i.e., the ladder-like CDF of the true labels.
[0042] The loss function imposes a distance-sensitive penalty on prediction bias: the greater the ordinal span between the predicted class and the true class, the heavier the penalty; if the prediction is only confused with adjacent classes, the penalty is lighter.
[0043] Finally, the balance coefficient is introduced. Construct a joint loss function : (5) Where the balance coefficient The penalty weight for adjusting the graded loss in the joint loss has a value ranging from 0.1 to 10.0; preferably, the balance coefficient... The value range is 1.0 to 8.0; in a specific embodiment of the present invention, the balance coefficient... The specific value is 5.
[0044] like Figure 1 As shown by the red solid line in the diagram, by calculating the joint loss, the gradient is only backpropagated to update the network parameters of the CNN feature encoder and mapping head. This constrains the model to learn the intrinsic evolutionary law of the gradual increase in the malignancy of lung nodules, so that the feature space presents a continuous manifold structure that conforms to the pathological evolution law, thereby significantly reducing the rate of serious misdiagnosis across different levels.
[0045] Step (4): Dynamic template update based on maximizing diversity During training, by evaluating sample novelty and template redundancy, a gradient-free dynamic replacement operation is performed on highly redundant templates in the template library using new samples that bring the greatest diversity gain.
[0046] Specifically, to overcome the problems of single template features and easy collapse in traditional prototype networks, and to effectively capture the complex long-tail phenotypes of lung nodules, this invention proposes a template dynamic update strategy based on maximizing diversity during training. This strategy aims to dynamically maintain a feature template library with high coverage. The implementation process is as follows: (41) Construct a temporary joint feature set For candidate samples correctly classified by the model in the current training batch Extract its normalized feature vector Compare it with the k old template features of the current category. By concatenating the vectors, a temporary joint feature set T containing k+1 vectors is constructed: (6) (42) Calculate the full cosine similarity matrix The full cosine similarity matrix S of the temporary joint feature set T is calculated as follows: (7) matrix elements Represents the i-th eigenvector in the set With the j-th eigenvector Cosine similarity between them This matrix fully quantifies the spatial similarity relationship between all new and old feature vectors after the introduction of new samples.
[0047] (43) Calculate the baseline redundancy Calculate the baseline redundancy of the original template library (without introducing new samples). : (8) The maximum cosine similarity between any two old templates in the current category reflects the current redundancy level of the template library.
[0048] (44) Evaluate the redundancy of each candidate replacement scheme. To determine the optimal template combination, we assume, in turn, the removal of the nth old template from the set (where... ), retain new samples Compute the subset consisting of the remaining k vectors and the remaining k-1 old templates. Maximum redundancy : (9) This value represents the maximum redundancy of the new template library after replacing the nth old template with a new sample.
[0049] (45) Select the optimal replacement scheme and perform the replacement operation. Among all k possible replacement schemes, find the one that maximizes redundancy. Index that reaches the minimum value , ; Set update threshold (In this embodiment, 0.005 is preferred). If the condition is met: (10) Then determine the new sample Its contribution to the feature space is better than that of the first. Using old templates can significantly improve the diversity of the template library. At this point, such as... Figure 1 As shown by the orange dashed line, a gradient-free dynamic replacement operation is performed, replacing the old template with the new feature (yellow circle): (11) Through the above-mentioned redundancy assessment and novelty discrimination based on the cosine similarity matrix, the model can force the template library to automatically evolve and tend to be evenly distributed in the feature space, thereby maximizing the coverage of heterogeneous phenotypes of different pathological subtypes and effectively preventing template feature homogenization.
[0050] Step (5), Testing phase: After preprocessing the CT image of the lung nodule to be tested, input it into the trained feature encoder and mapping head, extract the query features and match them with the frozen template library for consistency measurement, output the probability distribution of each pathological category, and take the category with the highest probability as the prediction result.
[0051] Once the model training is complete and the data has been stored, it enters the testing and inference phase, such as... Figure 2 The consistency inference process is shown in the figure, which specifically includes the following steps: The CT images of the lung nodules to be tested are preprocessed according to the method described in step (1) to obtain preprocessed CT images. The preprocessed CT images are fed into the trained feature encoder and nonlinear mapping head to extract the normalized query feature vector (128-dimensional in this embodiment). The template library frozen after training is called, and the cosine similarity between the query feature vector and all templates in the template library is calculated to generate a cross-category similarity matrix. For each pathological category, the maximum similarity among multiple templates under it is taken as the similarity score of that category. After processing the similarity scores of each category by the Softmax function, the probability distribution of each pathological category is output, and the category with the highest probability is selected as the final pathological subtype prediction result of the lung nodule.
[0052] It is understandable that steps (1) to (4) are the model training phase (e.g. Figure 1 As shown), step (5) is the model testing phase (as shown). Figure 2 (As shown). After the model training is completed, the feature encoder parameters, mapping head parameters, and template library are all fixed. At this point, inputting any CT image of a lung nodule to be tested into the network will automatically output the predicted pathological subtype of the patient.
[0053] Furthermore, such as Figure 5As shown, the present invention also provides a pathological classification system for pulmonary nodules based on dynamic phenotypic subspace inference. This system is used to implement the above method and includes a data preprocessing module, a subspace construction module, a feature extraction module, a consistency measurement module, a joint optimization module, a template dynamic update module, and a prediction output module.
[0054] The data preprocessing module is used to preprocess the 3D CT images of lung nodules. Specifically, the data preprocessing module resamples the acquired CT images to a uniform voxel spacing, crops a region of interest of a set size according to the center of the nodule, truncates the CT values to the lung window range, and performs normalization processing.
[0055] The subspace construction module is connected to the data preprocessing module. It receives preprocessed CT images and constructs a multicenter feature template library containing multiple gradient-free dynamic prototype templates for each pathological category, serving as the image representation subspace for each pathological subtype. Specifically, the subspace construction module randomly initializes k dynamic prototype templates for each pathological category using a standard Gaussian distribution, constructing a template library matrix with a total size of C×k.
[0056] The feature extraction module is connected to the data preprocessing module to receive preprocessed CT images and extract normalized query feature vectors. Specifically, it includes a 3D CNN feature encoder and a nonlinear mapping head. The 3D CNN feature encoder extracts deep volumetric feature maps; the nonlinear mapping head consists of a fully connected layer, a ReLU activation layer, a Dropout layer, and a feature dimensionality reduction layer connected in sequence. This maps the deep volumetric feature maps into embedding vectors of a set dimension, which are then L2 normalized and projected onto a unit hypersphere to obtain the query feature vector.
[0057] The consistency measurement module is connected to both the subspace construction module and the feature extraction module. It calculates the cosine similarity between the query feature vector and all templates in the template library, and for each pathological category, takes the maximum similarity among all templates as the similarity score for that category. Specifically, it includes a similarity calculation unit and a max-pooling unit. The similarity calculation unit calculates the cosine similarity between the query feature vector and all C×k templates in the template library; the max-pooling unit takes the maximum similarity among the k templates for each pathological category as the similarity score for that category. Preferably, the consistency measurement module also includes a temperature scaling unit, used to scale the similarity score using a low temperature coefficient τ.
[0058] The joint optimization module is connected to both the consistency measurement module and the feature extraction module. It is used to construct a joint loss function based on the similarity score and the true label, and to update the network parameters of the feature extraction module through gradient backpropagation.
[0059] The template dynamic update module is connected to both the joint optimization module and the subspace construction module. It receives features of correctly classified samples, evaluates their redundancy with the current template library, and performs a gradient-free dynamic replacement operation on highly redundant templates to update the template library in the subspace construction module. Specifically, it includes a redundancy evaluation unit, a replacement decision unit, and a template update unit. The redundancy evaluation unit calculates the baseline redundancy of the template library under the current category and the maximum redundancy of each candidate subset after introducing candidate samples. The replacement decision unit selects the replacement scheme that maximizes the reduction in redundancy; when the reduction in redundancy exceeds a preset threshold, the replacement operation is performed. The template update unit directly overwrites the selected redundant templates with the feature vectors of the new samples.
[0060] The prediction output module, during the testing phase, uses a trained feature extractor and a frozen template library to process the similarity scores of the CT images under test using a Softmax function and outputs the predicted pathological category. Specifically, the prediction output module includes a probability transformation unit and a decision output unit. The probability transformation unit processes the similarity scores of each category using a Softmax function and outputs the probability distribution of each pathological category. The decision output unit selects the category with the highest probability as the final predicted pathological subtype.
[0061] Test case This invention constructs a complete classification method and system for pathological subtypes of pulmonary nodules. To verify the effectiveness of the above method and system, experiments were conducted on a real pulmonary nodule CT image dataset. The experimental setup and results analysis are as follows: First, a dataset containing five pulmonary nodule subtypes (PGL, MIA, IAC-I, IAC-II, and IAC-III) at different pathological stages was collected and divided into training, validation, and test sets in a ratio of 7:1:2.
[0062] This experiment, conducted with the same dataset and hardware configuration, not only evaluated existing baseline models but also set up ablation comparisons with seven control variables. The evaluation metrics were uniformly validation set accuracy and test set accuracy. Specific experimental configurations and quantification results are shown in Table 1.
[0063] Table 1. Quantitative comparison results of classification accuracy with different model configuration variables.
[0064] The results show that existing baseline models (baseline model 1) mostly employ the traditional classification paradigm of cascaded fully connected layers in convolutional neural networks. This paradigm defines absolutely independent classification hyperplanes in the feature space, implicitly assuming that all categories are mutually exclusive and independent, thus completely severing the continuous manifold features with clearly defined severity progression in the pathological evolution of pulmonary nodules. If a hierarchical loss (baseline model 2) is forcibly superimposed on baseline model 1, the network's accuracy not only fails to improve but also drops significantly. This is because the linear fully connected layers lack the support of underlying geometric metric structures. Cross-entropy loss attempts to make the distributions of each category extremely sharp and mutually exclusive, while hierarchical loss requires the distributions to be smooth and maintain ordinal relationships. Under the paradigm of discrete label mapping, the two produce severe gradient conflicts.
[0065] To overcome the aforementioned technical bottlenecks, this invention completely abandons the traditional paradigm based on rigid boundary discrimination and innovatively constructs a multi-center phenotypic subspace inference architecture based on hyperspherical cosine similarity. However, if the metric network is optimized solely by traditional cross-entropy loss (Comparative Example 1), the network will equally reject templates of all non-true categories, disrupting the topological structure of disease evolution. Therefore, this invention incorporates hierarchical loss, which, by calculating the mean square error between the cumulative distribution function (CDF) of the predicted probability distribution and the true ladder label, applies an adaptive penalty based on the ordinal span between the predicted and true categories. This preserves a reasonable tolerance space for adjacent pathological transition zones, forcing the network to arrange continuous evolutionary manifold trajectories, thereby achieving a significant leap in accuracy on the test set.
[0066] To more intuitively reveal the core technical effect of the aforementioned hierarchical loss in reshaping the topology of the feature space, this experiment plotted Sankey diagrams showing the relationship between the prediction results of different models and the actual label flows on the test set, such as... Figure 4 As shown in the figure, the nodes on the left represent the actual pathological grade of the lung nodules (Class 1 to Class 5, with malignancy increasing progressively), while the nodes on the right represent the predicted grade of the model. Parallel horizontal bands indicate correct classification, while intersecting diagonal lines represent misdiagnosis and its extent.
[0067] like Figure 4 In the traditional baseline model (baseline model 1) shown in (a), multiple erroneous connections spanning multiple levels can be clearly observed (e.g., a large number of true Class 5 nodules are misdiagnosed as Class 1). This serious cross-level misdiagnosis exposes the fact that the traditional model has no regularity in its misjudgments in the feature space, and is very likely to misdiagnose high-risk invasive cancer as low-risk early nodules, posing a very high risk of clinical misrepresentation.
[0068] like Figure 4In the model with missing hierarchical loss constraints shown in (b) (Comparative Example 1), thanks to the strong inclusiveness of the multi-center subspace constructed in this invention for intra-class phenotypic variation, the overall width of the level correct association is increased, i.e., the overall accuracy is improved. However, due to the lack of explicit pathological evolution space constraints, cross-diagonal lines spanning two or more levels still exist, proving that the class arrangement in its metric space is still in a disordered state.
[0069] In comparison, such as Figure 4 The complete embodiment of the invention shown in (c) represents a qualitative leap in predictive behavior. It is clearly observed from the figure that the vast majority of misdiagnosed traffic is effectively converged between adjacent pathology categories (e.g., misdiagnosis of Class 2 is mainly concentrated in Class 3 or Class 1). Although a very small number of subtle connections across non-adjacent categories still exist in the metric space, compared to... Figure 4 (a) and Figure 4 In (b), the large cross lines spanning multiple pathological stages have been significantly suppressed.
[0070] This phenomenon perfectly and intuitively verifies the core value of the consistency inference and ordinal constraints of this invention. Since there is objective phenotypic overlap between adjacent pathological evolution stages in clinical imaging, the main confusion between adjacent categories is a medically tolerable soft error. This invention significantly reduces the probability of serious misdiagnosis across different stages while ensuring that the model's overall predictive behavior highly aligns with doctors' clinical diagnostic logic and tolerance for errors, thus endowing the model with extremely high clinical safety.
[0071] Furthermore, regarding the update mechanism of the metric template, this experiment set up two parallel control groups: random replacement (Comparative Example 2) and momentum smoothing update (EMA, Comparative Example 3). Experimental results show that the random replacement strategy, due to frequent and aimless template replacement, continuously disrupts the already established excellent topology of the network, leading to severe oscillations and difficulty in convergence during training. While the conventional momentum smoothing update (EMA) strategy in the field possesses a certain degree of adaptability, its operation of continuously merging new samples with the most similar template through mean fusion causes the originally dispersed multi-center templates to eventually become homogenized, absorbing into the densest center of the data distribution, resulting in pattern collapse and weakening the tolerance for complex intra-class variations. To overcome these shortcomings, the template dynamic update strategy based on maximizing diversity proposed in this invention, through rigorous calculation of the redundancy matrix, accurately eliminates the most mediocre old templates and directionally absorbs highly specific new samples, actively maximizing the diversity of the metric space and significantly improving the model's generalization ability.
[0072] Regarding the initialization strategy for the metric template, Comparative Example 4 constructed a manual data intervention strategy based on morphological priors, forcibly extracting real samples as the initial template. However, experiments revealed that due to the feature chaos in the early stages of deep neural networks, the real nodule features extracted by the untrained random network are essentially high-dimensional noise with no pathological significance. Using them as topological bias anchors severely hinders the natural manifold evolution of the feature space. This invention abandons complex manual intervention and uses a standard Gaussian distribution to initialize an absolutely unbiased template, achieving better convergence results.
[0073] Regarding the temperature scaling strategy for the metric space, experiments show that the test set accuracy using the dynamic annealing temperature strategy (Comparative Example 5) lags significantly behind. This is because the purely random initialization strategy lacks pathological semantics in the early stages of training. If high temperatures are used for annealing, the smooth probability distribution leads to gradient vanishing in the metric space. Conversely, the embodiments of this invention employ a set low temperature coefficient, forcing the network to generate strong gradient-driven features early on, promoting rapid feature clustering. This low-temperature strategy, combined with the proposed template dynamic update mechanism, forms a perfect closed-loop gain: low temperature promotes rapid feature formation of initial clusters, while the template dynamic update mechanism efficiently eliminates randomly generated erroneous anchor points, significantly accelerating the self-organization and high-quality convergence of the metric space.
[0074] In the architecture design of the multi-center subspace, Comparative Example 6 limits the number of templates for a single class to 1 (k=1), degenerating it into a traditional single-center prototype network. However, similar lung nodules in clinical medical images exhibit significant intra-class variance in size, shape, and texture. A single centroid cannot effectively represent the complex multimodal distribution within the pathological subtype, leading to obvious underfitting. Conversely, configuring too many templates (such as k=8 in Comparative Example 7) may result in blurred inter-class boundaries and overfitting. This invention employs a moderate multi-center architecture (k=4), achieving an optimal balance between fully characterizing intra-class heterogeneity and maintaining clear inter-class boundaries, effectively capturing rare variant nodules in long-tailed distributions.
[0075] In summary, this invention proposes a novel method for classifying pathological subtypes of pulmonary nodules based on dynamic phenotypic subspace inference and ordinal consistency. Experiments show that, compared to traditional classification methods, this invention not only achieves optimal performance across various objective quantitative indicators but also more effectively solves the problem of severe cross-level misdiagnosis caused by phenotypic overlap in clinical data, fully demonstrating the effectiveness and superiority of this invention in handling medical images with high intra-class heterogeneity. Combining the results of various comparative and ablation experiments, this invention highly conforms to the natural evolutionary laws of diseases and can provide a safe and reliable objective basis for the precise diagnosis and treatment of early-stage lung cancer, fully highlighting the irreplaceable nature of the introduced grading loss and dynamic template update strategy.
[0076] Those skilled in the art will readily understand that the above description is merely a preferred embodiment of the present invention and is not intended to limit the present invention. Any modifications, equivalent substitutions, and improvements 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 pathological classification of pulmonary nodules based on dynamic phenotypic subspace inference, characterized in that, Includes the following steps: S1. Preprocess the CT images of lung nodules and construct a multicenter feature template library containing multiple gradient-free dynamic prototype templates for each pathological category, which serves as the image representation subspace for each pathological subtype. S2. Input the preprocessed CT image into the feature extractor to extract the query feature, calculate the similarity between the query feature and the templates in the template library, and use the maximum similarity among multiple templates in each category as the similarity score for that category. S3. Based on the similarity score and the true label, construct a joint loss function including cross-entropy loss and hierarchical loss, and update the network parameters of the feature extractor through gradient backpropagation, wherein the hierarchical loss applies a penalty based on the ordinal span between the predicted class and the true class; S4. During training, evaluate the novelty of the samples and the redundancy between templates, and perform gradient-free dynamic replacement of redundant templates in the template library with new samples that meet the preset conditions. S5. Input the CT image to be tested into the trained feature extractor, extract the query features and match them with the template library frozen after training, and output the pathology category prediction result based on the matching result.
2. The method for pathological classification of pulmonary nodules based on dynamic phenotypic subspace inference according to claim 1, characterized in that, In S1, the method for preprocessing the three-dimensional CT images of lung nodules is as follows: the acquired CT images of lung nodules are resampled to a uniform voxel spacing, a region of interest of a set size is cropped according to the center of the nodules, and the CT values are truncated to the lung window range and normalized.
3. The method for pathological classification of pulmonary nodules based on dynamic phenotypic subspace inference according to claim 1 or 2, characterized in that, In S1, the method for constructing a multicenter feature template library is as follows: Suppose there are C pathological categories. Use a standard Gaussian distribution to randomly initialize k dynamic prototype templates for each category and construct a template library matrix with a total size of C×k, which serves as the image representation subspace for each pathological subtype that allows phenotypic variation.
4. The method for pathological classification of pulmonary nodules based on dynamic phenotypic subspace inference according to claim 3, characterized in that, S2 specifically includes: The preprocessed CT images are input into the feature encoder and nonlinear mapping head to extract the query feature vectors that have been normalized by L2. Calculate the cosine similarity between the query feature vector and all templates in the template library; A max pooling strategy is adopted, and the maximum cosine similarity between the query feature vector and all k templates in the Nth category is selected as the similarity score for that category.
5. The method for pathological classification of pulmonary nodules based on dynamic phenotypic subspace inference according to claim 1, characterized in that, S2 further includes a post-processing step for the similarity score, the post-processing including temperature scaling, constant scaling, or dynamic scaling factor adjustment; or, in S2, an additive cosine interval or angular interval is introduced in the similarity calculation.
6. The method for pathological classification of pulmonary nodules based on dynamic phenotypic subspace inference according to any one of claims 1, 4, and 5, characterized in that, In S3, the construction of the joint loss function, which includes cross-entropy loss and hierarchical loss, specifically includes: The similarity scores are processed using the Softmax function to obtain the predicted probability distribution. Let y be the one-hot encoded vector corresponding to the true pathological category label, and calculate the cross-entropy loss using the following formula: (3) in, This represents the probability that a sample belongs to the Nth class. C represents the total number of pathological subtypes of pulmonary nodules; For the Nth component of the one-hot encoded vector y, when the sample truly belongs to the Nth class... ,otherwise ; Calculate the graded loss using the following formula: (4) Where C represents the total number of pathological subtypes of pulmonary nodules; i is the category hierarchy index when calculating the cumulative distribution; and j is the category index variable for internal summation. This represents the probability that the model predicts a sample belongs to the j-th pathological category. This represents the component in the true label one-hot encoded vector corresponding to the j-th pathological category; This represents the cumulative probability of the predicted probability distribution up to and including the i-th class; This represents the cumulative distribution of the true labels in the i-th class and earlier. Calculate the joint loss function using the following formula : (5) in, For cross-entropy loss, For graded loss, This is the balance coefficient.
7. The method for pathological classification of pulmonary nodules based on dynamic phenotypic subspace inference according to any one of claims 1, 2, 4, and 5, characterized in that, S4 specifically includes: For candidate samples that are correctly classified, extract their normalized feature vectors and construct a temporary joint feature set with multiple old template features under the current category; Calculate the full cosine similarity matrix of the temporary joint feature set; The baseline redundancy of the original template library is calculated based on the full cosine similarity matrix, and the maximum redundancy of the corresponding subset after replacing each old template with the candidate sample. Select the replacement scheme that will reduce redundancy the most. If the reduction in redundancy is greater than a preset threshold, then perform the replacement operation.
8. The method for pathological classification of pulmonary nodules based on dynamic phenotypic subspace inference according to any one of claims 1, 2, 4, and 5, characterized in that, S5 specifically includes: Normalized query features of the CT image to be tested are extracted, and the cosine similarity between the image and all templates in the frozen template library is calculated. The maximum similarity of multiple templates under each category is taken as the similarity score of that category. After Softmax processing, the probability distribution is output, and the category corresponding to the highest probability is taken as the prediction result.
9. A lung nodule pathological classification system based on dynamic phenotypic subspace inference, applied to the lung nodule pathological classification method based on dynamic phenotypic subspace inference as described in any one of claims 1-8, characterized in that, include: The data preprocessing module is used to preprocess the three-dimensional CT images of lung nodules; The subspace construction module, connected to the data preprocessing module, is used to receive preprocessed CT images and construct a multicenter feature template library containing multiple gradient-free dynamic prototype templates for each pathological category, serving as the image representation subspace for each pathological subtype. The feature extraction module, connected to the data preprocessing module, is used to receive the preprocessed CT images and extract the normalized query feature vector. The consistency measurement module is connected to the subspace construction module and the feature extraction module respectively. It is used to calculate the cosine similarity between the query feature vector and all templates in the template library, and for each pathological category, the maximum similarity among all templates is taken as the similarity score of that category. The joint optimization module is connected to both the consistency measurement module and the feature extraction module. It is used to construct a joint loss function based on the similarity score and the true label, and to update the network parameters of the feature extraction module through gradient backpropagation. The joint loss function includes cross-entropy loss and hierarchical loss. The template dynamic update module is connected to the joint optimization module and the subspace construction module respectively. It is used to receive the features of correctly classified samples, evaluate their redundancy with the current template library, and perform gradient-free dynamic replacement operation on highly redundant templates to update the template library in the subspace construction module. The prediction output module is used to output the pathology category prediction result after the similarity score of the CT image to be tested is processed by Softmax based on the trained feature extractor and the frozen template library during the testing phase.
10. The pulmonary nodule pathological classification system based on dynamic phenotypic subspace inference according to claim 9, characterized in that, The feature extraction module includes a feature encoder and a nonlinear mapping head; The consistency measurement module includes a similarity calculation unit and a max pooling unit; The template dynamic update module includes a redundancy assessment unit, a replacement decision unit, and a template update unit. The prediction output module includes a probability conversion unit and a decision output unit.