A stroke CT counterfactual consistency identification method, device and medium

By applying structure-preserving perturbations to stroke CT slices, extracting content and domain features, and performing dual-gated modulation and consistency loss, the global representation is decomposed into lesion-related and confounding components. This solves the output instability and non-lesion cue dependence problems of stroke CT classification methods under cross-center and cross-device conditions, achieving more stable recognition and reducing data annotation costs.

CN122066698BActive Publication Date: 2026-06-26嘉兴市中医医院 +1

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
嘉兴市中医医院
Filing Date
2026-04-20
Publication Date
2026-06-26

AI Technical Summary

Technical Problem

Existing deep learning-based stroke CT classification methods are unstable in output under cross-center and cross-device conditions, are prone to relying on non-lesion clues leading to misjudgment, and are difficult to maintain prediction consistency under in-domain perturbation.

Method used

By applying structure-preserving perturbations to cranial CT slices, content features and domain features are extracted, and dual-gated modulation and global average pooling are performed to construct consistency loss and counterfactual constraints. The global representation is decomposed into lesion-related components and confounding components, and controllable intervention is implemented to generate counterfactual representations.

Benefits of technology

This method improves the output stability of stroke CT identification under co-domain perturbation, reduces reliance on non-lesion confounding clues, enhances generalization reliability under cross-center and cross-device conditions, reduces the risk of misjudgment, and lowers data annotation costs.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122066698B_ABST
    Figure CN122066698B_ABST
Patent Text Reader

Abstract

The application discloses a stroke CT counterfactual consistency identification method, device and medium, and belongs to the field of medical image intelligent analysis. The method comprises the following steps: acquiring a non-enhanced head CT plain scan slice and performing pretreatment; constructing two structure-preserving disturbance views for the same slice; extracting content features and domain features through a shared encoder, performing interactive fusion and double-gate modulation to obtain a stable shared representation, and constructing a consistency loss of a probability layer and a representation layer; decomposing a global representation into a lesion-related component and a mixed component, implementing controllable gate intervention and neutral prototype replacement on the mixed component to obtain a counterfactual representation, and calculating a counterfactual constraint loss; and optimizing network parameters in combination with a supervised cross-entropy loss, a consistency loss and a counterfactual constraint loss. The application improves the generalization reliability under cross-center and cross-device conditions, does not require pixel-level lesion segmentation annotation, and is suitable for rapid engineering landing.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of intelligent medical image analysis, and in particular to a method, device and medium for recognizing counterfactual consistency in stroke CT scans. Background Technology

[0002] Stroke is characterized by its rapid onset, high rates of disability and mortality, and head CT scans are frequently used as an important diagnostic tool for clinical emergency triage and early assessment. In practice, the appearance of similar lesions can vary significantly between different hospitals, with different equipment models, and under different scanning and reconstruction conditions. Even within the same hospital, similar slices from the same patient can show differences due to factors such as window width and level settings, noise levels, slight blurring, and contrast variations. Furthermore, head CT scans commonly exhibit high-density edges of the skull, fasciculations, and textures related to the scanning equipment. These factors may have accidental correlations with class labels in the training data and can easily be mistaken for shortcuts by the model.

[0003] Existing deep learning-based CT classification methods for stroke typically output class probabilities directly from images using end-to-end supervised learning, offering the advantage of convenient deployment. However, they are prone to two types of problems in practical applications. The first problem is insufficient stability; the output of the same slice fluctuates significantly under common perturbations such as window width and level adjustments, noise, and mild blurring, affecting clinical usability. The second problem is unreliable reliance on non-lesion clues to make shortcut decisions, such as relying on information from skull edges, artifact textures, or differences in image appearance caused by different equipment and reconstruction procedures. This can lead to high-confidence misclassifications under cross-center, cross-device, or complex imaging conditions. While data augmentation or consistency regularization can reduce perturbation sensitivity, it is often difficult to ensure that the model's stability is based solely on lesion evidence. Furthermore, the lack of bias removal or counterfactual methods that coordinate with the backbone representation may result in insufficient suppression, misclassification of effective features, or training instability.

[0004] Therefore, there is an urgent need for a stroke CT identification method that can simultaneously improve output stability under in-domain perturbations and explicitly suppress dependence on non-lesion confounding cues, thereby enhancing cross-condition robustness. Summary of the Invention

[0005] The purpose of this application is to provide a method, device and medium for recognizing counterfactual consistency in stroke CT, which aims to solve the problems of output instability and shortcut dependence in the three-class classification task of stroke in cranial CT. Specifically, it includes maintaining prediction consistency under in-domain perturbations such as window width and window level, noise, and mild blurring, and reducing the model's dependence on non-lesion confounding clues such as skull edges, artifact textures and image appearance differences caused by different devices at the shared representation level, thereby improving the generalization reliability under cross-center and cross-device conditions.

[0006] To achieve the above objectives, this application provides the following solution:

[0007] In a first aspect, this application provides a method for identifying counterfactual consistency in stroke CT scans, including:

[0008] Unenhanced head CT plain scan slices were acquired and a training sample set was formed. Each slice was standardized to obtain standardized input.

[0009] Based on the standardized input, two structural preservation perturbations are applied to the same slice to obtain two structural preservation perturbation views.

[0010] The two perturbated structural views are input into a shared encoder to extract content features and domain features, respectively.

[0011] Channel vector normalization is performed on the content features and domain features to generate an interaction graph;

[0012] Based on the interaction graph, content gating and domain gating are generated and dual-gated modulation is performed to obtain modulated content features and modulated domain features.

[0013] The modulated content features and modulated domain features are subjected to global average pooling and then concatenated to form a shared representation;

[0014] The shared representation is input into the prediction head to obtain the category score vector and output the category probability distribution;

[0015] Based on the aforementioned category probability distribution and shared representation, a probability layer consistency loss and a representation layer consistency loss are constructed, and a consistency regularization term is obtained by combining them.

[0016] The standardized input is processed by a backbone encoder to extract a global representation vector. The global representation vector is then mapped to two subspaces using a learnable projection matrix to obtain lesion-related components and confounding components.

[0017] The hybrid components are gated and suppressed, and the suppressed parts are replaced with neutral prototype vectors to obtain the hybrid components after intervention.

[0018] The lesion-related components are combined with the confounding components after intervention to obtain a counterfactual representation;

[0019] The original representation and the counterfactual representation are classified and predicted separately, and a counterfactual constraint loss is constructed.

[0020] The original global representation and the counterfactual representation are fused to output the final category probability distribution;

[0021] A unified objective function is constructed, which includes supervised cross-entropy loss, the consistency regularization term, and the counterfactual constraint loss. The optimal parameters are obtained by minimizing the unified objective function on the training set.

[0022] During the inference phase, a single slice is input, and the network corresponding to the optimal parameters outputs a three-class probability distribution to obtain the recognition result.

[0023] Optionally, the two structure-preserving perturbation views are input into a shared encoder to extract content features and domain features, respectively, including:

[0024] The two perturbed structural views are input into a shared encoder to obtain content features;

[0025] A domain perturbation operator is applied to the two perturbation views of the structure to obtain a domain view;

[0026] The domain features are obtained by encoding the domain view.

[0027] Optionally, channel vector normalization is performed on the content features and domain features to generate an interaction graph, specifically including:

[0028] In each spatial location The channel vector is taken at the specified location, and the channel vector of the content feature is... The channel vector of the domain feature is ;

[0029] The content feature channel vector and the domain feature channel vector are normalized using the second norm.

[0030] The interaction graph is obtained by performing element-wise multiplication on the normalized content feature channel vector and the domain feature channel vector.

[0031] Optionally, based on the interaction graph, content gating and domain gating are generated for dual-gating modulation to obtain the modulated content features and modulated domain features, specifically using the following formulas:

[0032] ;

[0033] ;

[0034] ;

[0035] ;

[0036] in, This represents a content-gated tensor, whose elements range from 0 to 1, used to adjust the normalized content features. The degree of preservation in each spatial location and each passageway; This represents a convolution operator that gates the generated content. Represents the Sigmoid function; An interaction graph is used to represent the degree of co-activation of content features and domain features at corresponding positions and channels. This indicates the content characteristics after content gating modulation; This represents the content characteristics after normalization. The representation domain-gated tensor, whose elements range from 0 to 1, is used to adjust the normalized domain features. The degree of preservation; This represents the convolution operator used for generation domain gating; This represents the domain characteristics modulated jointly by domain gating and neutral proxy; This represents the normalized domain characteristics; express and All sheets of the same size; Represents a domain-neutral surrogate vector; This represents element-wise multiplication; This means to put the length of vector Copy expansion to Tensors of the same size.

[0037] Optionally, the expression for the probability layer consistency loss is as follows:

[0038] ;

[0039] in, This represents the probability layer consistency loss. express divergence, This represents the predicted probability distribution of the first perturbation view. This represents the predicted probability distribution of the second perturbation view;

[0040] The expression for the representation layer consistency loss is as follows:

[0041] ;

[0042] in, For the presentation layer consistency loss, This indicates that the first structural view retains a shared representation of the perturbation. This indicates that the second structure maintains a shared representation of the perturbation view. Represents the numerical stability constant;

[0043] The expression for the consistency regularization term is as follows:

[0044] ;

[0045] in, This represents a consistency regularization term. This represents the weighting coefficient.

[0046] Optionally, the expression for the unified objective function is as follows:

[0047] ;

[0048] in, Represents a unified objective function. This represents the supervised cross-entropy loss. This represents a consistency regularization term. Indicates counterfactual constraint loss, and All of these represent weighting coefficients.

[0049] Optionally, the expression for the optimal parameter is as follows:

[0050] ;

[0051] in, This represents the complete set of learnable parameters of the model. This represents the optimal parameters after training convergence. Indicates the training dataset The expectation operation of a sample pair (x,y) in the middle. Represents the training dataset. Let x represent a training sample pair, where x is the input slice and y is the class label corresponding to the slice.

[0052] Optionally, during the inference phase, a single slice is input, and the network outputting the three-class probability distribution using the optimal parameters is employed to obtain the recognition result, specifically using the following formula:

[0053] ;

[0054] in, This represents a three-class probability distribution. Indicates the final classification header, This represents a fusion mapping function or fusion network used for nonlinear reintegration of the concatenated vectors of the original global representation and the counterfactual representation. This represents the global representation extracted by the backbone encoder from the input slice x. This represents the counterfactual representation obtained by reconstructing the hybrid components after gating suppression and neutral prototype replacement.

[0055] In a second aspect, this application provides a computer device, including: a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the computer program to implement the steps of the above-described method for identifying counterfactual consistency in CT scans of stroke.

[0056] Thirdly, this application provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the steps of the above-described method for identifying counterfactual consistency in stroke CT scans.

[0057] According to the specific embodiments provided in this application, this application has the following technical effects:

[0058] This application provides a method, device, and medium for identifying counterfactual consistency in CT scans of stroke patients, which has the following beneficial effects:

[0059] Improve output stability under co-domain perturbation: By applying two structure-preserving perturbations to the same slice based on standardized input, two structure-preserving perturbation views are obtained, and a consistency loss between the probability layer and the representation layer is constructed. Since the same slice is forced to be semantically equivalent under different display and imaging perturbations, and the model is constrained to maintain consistency at both the probability output and feature representation levels, the model can reduce its sensitivity to common perturbations such as window width and window level, and noise, thus achieving output stability.

[0060] Reduce dependence on non-lesion confounding cues: By decomposing the global representation into lesion-related components and confounding components, and implementing controllable gating intervention and neutral prototype replacement on the confounding components, the model is constrained to maintain consistent predictions before and after suppressing confounding cues (invariance constraint). If the model originally depended on confounding cues, the predictions will change after the intervention, resulting in loss. This forces the model to shift its discrimination criteria to lesion evidence. Therefore, the model can reduce its dependence on shortcut cues such as skull edges and artifact textures.

[0061] Enhancing feature decoupling and intervention controllability: By explicitly separating content features and domain features and using dual-gated modulation, and introducing decoupling constraints in counterfactual branches, since content features emphasize structural semantics and domain features emphasize appearance differences, and the two are constrained to be orthogonal and independent, intervention measures can more accurately target mixed information, reduce the probability of falsely damaging effective lesion evidence, and improve training stability.

[0062] Reduced data annotation costs and deployment complexity: This application does not rely on pixel-level lesion segmentation annotation; it only requires slice-level three-class labels for training, and the inference phase only requires a single slice for forward computation. Therefore, this method is suitable for rapid engineering deployment and can be embedded in emergency imaging workstations to support rapid triage. Attached Figure Description

[0063] To more clearly illustrate the technical solutions in the embodiments of this application or the prior art, the drawings used in the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0064] Figure 1 A flowchart illustrating a method for identifying counterfactual consistency in CT scans of stroke, provided as an embodiment of this application;

[0065] Figure 2 This is a schematic diagram of the structure of a computer device provided in an embodiment of this application. Detailed Implementation

[0066] The technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, and not all embodiments. Based on the embodiments of this application, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this application.

[0067] To make the above-mentioned objectives, features and advantages of this application more apparent and understandable, the application will be further described in detail below with reference to the accompanying drawings and specific embodiments.

[0068] This application proposes a dual-path joint constraint recognition method during the training phase. The first path constructs two perturbation views for the same slice, obtaining a stable shared representation through shared coding and gated modulation, and achieving stable output insensitive to in-domain perturbations through probability consistency and representation consistency losses. The second path constructs a counterfactual representation based on the shared representation, decomposing the global representation into lesion-related components and confounding components. Controllable gating intervention and neutral prototype replacement are applied to the confounding components, and prediction invariance before and after intervention and component decoupling constraints guide the model to shift its discrimination criteria from appearance shortcuts to more stable lesion evidence. During the inference phase, only a single slice needs to be input to output three probability distributions and the final category.

[0069] In one exemplary embodiment, such as Figure 1As shown, a method for counterfactual consistency recognition of stroke CT scans is provided. This method is executed by a computer device, specifically a terminal or server, or both. In this embodiment, the method includes two processing paths: a consistency constraint branch and a counterfactual suppression branch. Steps 101 to 108 are the consistency constraint branch, used to model the perturbation view and construct a consistency loss; steps 109 to 112 are the counterfactual suppression branch, used to generate counterfactual representations and construct counterfactual losses. After both branches are completed, the original representation and the counterfactual representation are fused to output the final three-class classification probability, and the total loss is constructed by combining the supervised loss, consistency loss, and counterfactual loss. Steps 113 to 114 are used to iteratively optimize the model parameters based on the total loss, thereby completing model training; step 115 is used to output the final recognition result during the inference stage.

[0070] The following is a detailed explanation of each step:

[0071] Consistency constraint branch:

[0072] Step 101: Obtain unenhanced head CT plain scan slices and form a training sample set. Standardize each slice to obtain standardized input.

[0073] The training dataset is defined as follows:

[0074] (1)

[0075] in, The number of samples; For the first Single-channel image of a CT slice; and These are the image height and width, respectively; Slice-level category labels; For the number of categories, when classifying stroke into three categories These correspond to normal stroke, ischemic stroke, and hemorrhagic stroke, respectively. The goal of preprocessing is to map images from different sources, with different grayscale ranges, and under different window settings to a unified numerical scale, making subsequent perturbation construction, consistency comparison, and loss optimization comparable and numerically stable. Step 102: Based on the standardized input, apply two structure-preserving perturbations to the same slice to obtain two structure-preserving perturbation views.

[0076] After obtaining standardized input Subsequently, to explicitly learn the target that should remain consistent under co-domain perturbations, two structural preservation perturbations are applied to the same slice, resulting in two perturbation views:

[0077] (2)

[0078] in, and A structure-preserving perturbation operator is used to simulate common clinical display and acquisition differences, including minor shifts in window width / level or grayscale mapping, brightness and contrast perturbations, noise injection, mild blurring, and slight geometric jitter. Structure preservation means that the perturbation does not change the main intracranial anatomical topology and lesion semantics, only altering the appearance or slightly improving image quality. This step explicitly transforms unavoidable appearance differences in real-world clinical settings into a pair of semantically equivalent inputs for training, facilitating subsequent constraint of model output stability using consistency loss.

[0079] Step 103: Input the two structure-preserving perturbation views into the shared encoder to extract content features and domain features respectively.

[0080] Step 104: Normalize the channel vectors of the content features and domain features and generate an interaction graph.

[0081] Step 105: Based on the interaction graph, generate content gating and domain gating and perform dual-gating modulation to obtain modulated content features and modulated domain features.

[0082] Step 106: Perform global average pooling on the modulated content features and the modulated domain features respectively, and then concatenate them to form a shared representation.

[0083] Based on the disturbance view obtained in step 102 and For each view, a shared-parameter encoder extracts features, which are then further distinguished into content features and domain features before interactive fusion and dual-gated modulation to obtain a more stable shared representation. Content features express key information related to anatomical structure and lesion evidence, while domain features express information related to in-domain differences such as appearance style, noise morphology, and texture rendering. The purpose of explicitly separating and gating these two types of features is to enable the model to retain a structurally stable response across perturbations while suppressing appearance responses that easily change with device and window settings, reducing the risk of using appearance texture as a basis for discrimination. The following describes the process for any view. Perform the same process, where The following sections will provide a detailed introduction to each part:

[0084] Extracting content features and domain features:

[0085] View Content features are obtained by inputting a shared encoder. And then Applying domain perturbation to obtain the domain view And encode the domain features :

[0086] (3)

[0087] in, For shared encoders; For domain perturbation operators, used to introduce appearance differences within the same domain without changing the structural semantics; The tensor represents content (structural / lesion semantics) features, emphasizing "structural and lesion evidence directly related to category discrimination"; For the domain (imaging conditions / equipment style / appearance texture) feature tensor, emphasizing "the appearance difference of the same structure under different observation conditions", both have the same size. The difference lies in the input view. For content view, (This is a domain perturbation view), therefore the activation focus extracted by the encoder is different. and For the height and width of the feature map, This represents the number of channels. The above extraction of content and domain features can be understood as the different expressions of the same structure under different appearance conditions. Subsequent steps will utilize the co-activation patterns of content and domain to screen for more stable representational components.

[0088] Channel vector normalization and generation of interaction graph:

[0089] In each spatial location Extract the channel vector. The channel vector refers to the feature tensor at position. The length taken out along the channel dimension is The one-dimensional vector, the channel vector of the content features is The channel vector of the domain feature is Therefore, there is a one-to-one correspondence between the channel vectors and the content features and domain features in the "Extracting Content Features and Domain Features" section; they are simply the channel-dimensional representation of the three-dimensional feature tensor at a certain spatial location "extracted" for computation. To eliminate amplitude scale differences, the channel vectors are normalized using the L2 norm:

[0090] (4)

[0091] in, Representation of characteristic tensor In spatial location The channel vector extracted along the channel dimension. Representation of characteristic tensor In spatial location The channel vector extracted along the channel dimension. In the formula... and These represent the position indices of the feature map in the height and width spatial dimensions, respectively. The colon ":" indicates that all components in the channel dimension are taken at that spatial position, i.e., all channels. Therefore, and All are of length It is a one-dimensional vector, not a single scalar. It is a numerical stability constant to avoid the denominator being zero; This refers to the L2 norm. Normalization aims to compress the amplitudes at different locations and from different channels into a comparable range, allowing subsequent interactive calculations to focus more on the directional consistency and relative relationship of the two features, rather than their absolute magnitude. Specifically, the subscript... Indicates the spatial location in the feature map All components are extracted along the channel dimension, and then element-wise multiplication is performed on the normalized two-way features to obtain the interaction graph:

[0092] (5)

[0093] in, For element-wise multiplication, the interaction graph Characterizing the co-activation level of content and domain at each location and channel can be understood as a stable cue that maintains a consistent response even when appearance changes occur. Subsequent gating will prioritize retaining the stronger components of the interaction graph, thereby improving stability across perturbations.

[0094] Dual-gated modulation:

[0095] Content gating and domain gating are generated based on interaction graphs. Content gating is used to selectively retain more stable responses in content branches, preventing unstable components such as noise and texture from being directly used for classification; domain gating is used to smooth domain branches, preventing them from overfitting random textures and using appearance differences as the basis for discrimination. First, content gating is generated and content features are modulated:

[0096] (6)

[0097] in, This represents a convolution operator used for content gating, whose input is an interaction graph. Its function is to synthesize the local neighborhood information of the interaction graph and output the corresponding information. Content-gated tensors of the same size; The Sigmoid function is used to compress the output to the range of 0 to 1, forming the gating coefficient. The closer to 1, the more stable the response is and the more likely it is to be preserved; the closer to 0, the more likely it is to come from unstable textures, noise, or random structures and the more likely it is to be suppressed. This represents the modulated content features. To further reduce overfitting of domain branches to accidental textures, a domain-neutral surrogate vector is introduced. As a reference benchmark, the domain response converges to this benchmark when the domain gate is small:

[0098] (7)

[0099] in, To represent the convolution operator used for generative domain gating, its input is also an interaction graph. Its function is to synthesize the local neighborhood information of the interaction graph and output the corresponding information. Domain-gated tensors of the same size; A full-size tensor of the same size as the feature; This means to put the length of vector Copy expansion to Tensors of the same size are used for element-wise operations. This represents the modulated domain features. Through this structure, when a small domain gating indicates unreliable responses in certain domains, a neutral surrogate is used for substitution or smoothing, thereby reducing the probability of domain texture directly participating in discrimination. Domain Neutral Surrogate Vector It can be used as a learnable parameter or obtained by statistical updates during the training process to provide a relatively stable reference point.

[0100] Shared representation and view-level probability output:

[0101] In obtaining and Then, both are subjected to global average pooling and concatenated to form a shared representation:

[0102] (8)

[0103] in, For global average pooling, the average value is taken for each channel in the spatial dimension. The feature tensor is compressed into a length of The vector is used to obtain a global description of the entire slice; This involves concatenating vectors. This shared representation incorporates both content and domain information into a single global vector, facilitating the subsequent unified output of category scores and their application to consistency constraints.

[0104] The shared representation is used to input the prediction head to obtain the class score vector and output the class probability distribution of the view:

[0105] (9)

[0106] in, For prediction, multilayer perceptrons (MLPs) are commonly used in engineering implementations. MLP stands for feedforward mapping, which consists of a cascade of multilayer fully connected linear transformations and nonlinear activation functions, and is used to map the input vector to the category score space. Let be the category score vector, where each dimension corresponds to the unnormalized score of a category, often referred to as logits in engineering. Softmax normalizes the logits to a probability distribution that sums to 1, making it easier to interpret as a three-class probability distribution, where the... The class probability is:

[0107] (10)

[0108] in, For probability distribution The Class probability; For the score vector The Dimensional components; For summation indexing. Thus far, steps 103-106 output a shared representation of the two perturbation views. and probability distribution These outputs will serve as direct input to the consistency loss in the next step. Step 107: Input the shared representation into the prediction head to obtain the class score vector and output the class probability distribution.

[0109] Step 108: Based on the category probability distribution and shared representation, construct the probability layer consistency loss and the representation layer consistency loss, and synthesize them to obtain the consistency regularization term.

[0110] Based on step 106 as well as A consistency loss is constructed between the probability layer and the representation layer to ensure stable output for the same slice under structural perturbation. The KL divergence is defined as:

[0111] (11)

[0112] in, Represents distribution Relative to distribution KL divergence, and It is a probability distribution; and The first Class probability. KL divergence characterizes the distribution. To distribution The smaller the value of the difference, the closer the two distributions are. The symbol " "" is the standard directional notation for the KL divergence, used to indicate that this measure of difference has a directionality, i.e., it follows the previous probability distribution. For reference, measure the latter probability distribution The magnitude of the difference between them, specifically, is the divergence of the former probability distribution relative to the latter probability distribution.

[0113] Probabilistic consistency uses a symmetric KL algorithm to avoid bias caused by one-way metrics:

[0114] (12)

[0115] in, It is a measure of the difference between two perturbation views of the same slice at the probability output layer, used to constrain the stability of the model's probability output. The smaller the value, the more consistent the probability outputs of the two perturbation views. This represents the predicted probability distribution of the first perturbation view. This represents the predicted probability distribution of the second perturbation view. This represents the predicted distribution based on the first perturbation view. For reference, measure the predicted distribution of the second perturbation view. The differences between them, This represents the predicted distribution in reverse, as shown in the second perturbation view. For reference, the predicted distribution of the first perturbation view is then re-evaluated. The differences between them.

[0116] The reason for writing both directions simultaneously is that the KL divergence is generally asymmetric, that is: If only a single direction is used, the consistency measurement result will be affected by the selection order of the reference distribution, resulting in a one-way comparison bias. To avoid this bias, this application uses a two-way KL divergence summation method to construct the probability layer consistency loss, so as to more comprehensively and symmetrically constrain the predicted probability distribution of the same slice to remain consistent under two structurally perturbation views.

[0117] Representation consistency constrains feature-level stability by comparing the distance between normalized shared representations:

[0118] (13)

[0119] in, It is a representation consistency loss, which directly constrains the global representation obtained from two perturbed views. The distance should be smaller after normalization. The smaller the value, the closer the two views are at the shared representation level. Essentially, it requires that "the same slice should be mapped to similar semantic representations before and after the perturbation" in the feature space, thereby improving the stability of the feature layer, rather than just "looking consistent" at the probability level.

[0120] The resulting consistency regularization term is:

[0121] (14)

[0122] in, These are weighting coefficients used to balance the contributions of probabilistic consistency and representational consistency. Through backpropagation, Constraints are imposed on the shared encoder, interactive fusion and gating modulation modules, and prediction head to enable them to learn perturbation-stable representations and stable outputs. It should be noted that consistency constraints alone may still result in stability relying on erroneous cues; therefore, the next step introduces a counterfactual suppression branch to ensure that stability is derived primarily from lesion evidence.

[0123] Counterfactual suppression branch:

[0124] Step 109: Extract the global representation vector from the standardized input using the backbone encoder, and map the global representation vector to two subspaces using a learnable projection matrix to obtain the lesion-related component and the mixed component.

[0125] Step 110: Gated suppression is applied to the hybrid component and the suppressed part is replaced with a neutral prototype vector to obtain the intervened hybrid component.

[0126] Step 111: Combine the lesion-related components with the mixed components after intervention to obtain a counterfactual representation.

[0127] Step 112: Classify and predict the original representation and counterfactual representation respectively, and construct the counterfactual constraint loss.

[0128] Steps 109-112 above extract global representations from the same input slice and perform subspace separation. Controllable gating intervention is applied to the confounding components to generate counterfactual representations, and the predictions before and after the intervention are required to remain as consistent as possible, thereby reducing the model's dependence on non-lesion confounding cues. Here, confounding cues can be understood as cues related to imaging conditions, device style, skull edges, or artifact textures.

[0129] Detailed introduction is as follows:

[0130] Global representation extraction:

[0131] Standardize input Global representation vector extracted via backbone encoder:

[0132] (15)

[0133] in, For the backbone encoder or its global output branch; This is the global representation vector; It represents the vector dimension. This global representation can be seen as a compressed description of the entire slice by the model, and it forms the basis for subsequent decomposition and intervention.

[0134] Decomposed into lesion-related components and confounding components:

[0135] Using two sets of learnable projection matrices Mapping to two subspaces yields lesion-related components and confounding components:

[0136] (16)

[0137] in, and For learnable projection matrix; Used to carry information that is more likely to be related to stroke evidence; It is used to carry information that is more likely to be related to appearance texture, artifacts, or skull edges. This decomposition does not rely on pixel-level segmentation annotation, but is guided by subsequent prediction invariance constraints and decoupling constraints, making the hybrid intervention controllable and targeted.

[0138] Relevance measurement of decoupling constraints:

[0139] To avoid severe coupling between lesion information and confounding information, which could lead to ineffective intervention or misinterpretation of valuable information, the correlation between the two components is measured and penalized in the loss. First, the two components are normalized using L2 norm.

[0140] (17)

[0141] Recalculate the correlation index:

[0142] (18)

[0143] in, It is a scalar; T denotes transpose; The closer the value is to 0, the more orthogonal and independent the two components are, and the less information leakage occurs. Including loss penalties can make the decomposition clearer, enabling subsequent actions... Interventions are more likely to target only mixed evidence with little impact on lesions.

[0144] Hybrid Gated Intervention and Neutral Prototype Replacement

[0145] To achieve controllable suppression of confounding cues, we first base ourselves on... Calculate the retained vector:

[0146] (19)

[0147] in, and These are learnable parameters; To preserve vectors, Each dimension represents the proportion of mixed information retained.

[0148] Subsequently, gated suppression of the hybrid components was performed, and a neutral prototype vector was used. Replace the suppressed part:

[0149] (20)

[0150] in, It is a vector consisting entirely of 1s; The mixed components after intervention; This is a neutral prototype vector used to provide a statistically neutral alternative. The reason for using a neutral prototype instead of setting it to zero is that setting it to zero directly would significantly change the feature distribution, potentially introducing unnecessary distribution drift, leading to unstable training or unnatural counterfactual representations; the neutral prototype can suppress confounding while keeping the features within a reasonable range.

[0151] The neutral prototype is updated using an exponential moving average:

[0152] (twenty one)

[0153] in, The moving average coefficient; This indicates the current mini-batch of samples. The mean is taken. A mini-batch refers to a set of samples that are simultaneously fed into the network and participate in a single parameter update during a training iteration, used to balance computational efficiency and statistical stability. A moving average is used. It can slowly follow the overall distribution changes of the hybrid components during training, maintaining the representativeness and stability of the neutral substitute.

[0154] Reconstructing counterfactual representations:

[0155] Mixed components after intervention Then, the lesion-related component is combined with the confounding component after intervention to obtain the counterfactual representation:

[0156] (twenty two)

[0157] in, , where is the fusion coefficient, is used to control the proportion of lesion-related information in the counterfactual representation. This counterfactual representation can be understood as the internal representation state that the model should form for the same slice after confounding cues are partially suppressed or replaced. If the model originally relied excessively on confounding cues, the representation after intervention will change significantly and lead to changes in prediction; training will use the invariance constraints in the next subsection to suppress this dependence, causing the model to shift its discrimination criteria to more stable lesion-related cues.

[0158] Original forecasts and counterfactual forecasts and invariance constraints:

[0159] Classify and predict the original representation and the counterfactual representation separately, requiring that the predicted distributions of the two be as consistent as possible. Let the auxiliary classifier be... ,but:

[0160] (twenty three)

[0161] in, and All are of length The probability distributions correspond to the predictions before and after the intervention, respectively; This can also be achieved using an MLP, where the output logits are processed by Softmax to obtain the probabilities. The significance of using the same auxiliary classifier head here is to make the results before and after the intervention directly comparable in the same discriminant space.

[0162] Construct a counterfactual constraint loss to make predictions as consistent as possible before and after the intervention, while simultaneously penalizing correlation. :

[0163] (twenty four)

[0164] in, For relevance penalty weights, Indicates the original predicted distribution For reference, measure the distribution of counterfactual predictions The differences between them, This indicates that the distribution is predicted in reverse, using counterfactual methods. For reference, re-evaluate the original predicted distribution. The difference lies in the following: The first part of the formula represents the prediction invariance constraint. If the model primarily relies on lesion evidence, suppressing confounding cues will not significantly alter the prediction, and this part is relatively small. However, if the model relies on confounding shortcuts, intervention will lead to a significant change in the prediction, thus this part becomes larger and drives the network to reduce its dependence on confounding cues. The second part is the decoupling penalty, used to make the lesion component and the confounding component more independent, enhancing the effectiveness and controllability of the invariance constraint.

[0165] Step 113: Fuse the original global representation with the counterfactual representation to output the final category probability distribution.

[0166] In obtaining counterfactual representation Subsequently, to balance discriminative power and decontamination robustness, the original global representation and counterfactual representation are fused, and the final class probability distribution is output:

[0167] (25)

[0168] in, This is a fusion mapping network used to reassemble concatenated vectors, enabling the network to automatically learn the appropriate weight allocation between the original information and the decontamination information; For the final classification head; This is the intermediate representation after fusion; For the final logits; This represents the final probability distribution. This fusion structure allows the model to retain the rich information of the original representation while introducing decontamination constraints provided by counterfactual branches, thereby improving robustness under different imaging and display conditions.

[0169] Step 114: Construct a unified objective function, which includes supervised cross-entropy loss, the consistency regularization term, and the counterfactual constraint loss. Minimize the unified objective function on the training set to obtain the optimal parameters.

[0170] The supervised cross-entropy loss is:

[0171] (26)

[0172] in, This is the true label for the sample; For the final output probability distribution The Class probability; This is an indicator function, taking the value 1 if the condition is true and 0 otherwise. Cross-entropy loss measures the deviation between the model's prediction and the true label, and is a fundamental training objective of supervised learning.

[0173] The total loss function is:

[0174] (27)

[0175] in, and , which is a weighting coefficient used to balance the contributions of consistency constraints and counterfactual constraints.

[0176] The training objective is to minimize the total loss on the training set to obtain the optimal solution for the parameters.

[0177] (28)

[0178] in, This represents the complete set of learnable parameters of the model, including the shared encoder. Backbone encoder Two types of convolutional gating and Projection matrix and Gating mapping parameters and Predicting Head Auxiliary classification head Fusion mapping And the final classification head Parameters; These are the optimal parameters after training convergence. For the expected computation, the mini-batch average loss is typically used as an approximation in engineering implementations. Training employs a mini-batch iterative optimization approach, where a small batch of samples is selected in each iteration to sequentially complete the forward computation and loss calculation from steps S102 to S114. Then, the... Calculate the gradient and update it, iterating repeatedly until convergence.

[0179] Step 115: In the inference stage, a single slice is input, and the network corresponding to the optimal parameters is used to output a three-class probability distribution and obtain the recognition result.

[0180] The inference phase only requires a single slice as input and outputs a three-class probability distribution:

[0181] (29)

[0182] in, Obtain global representation ; Calculated from formulas (16) to (22); finally, take The category with the highest probability is used as the identification result, and three probabilities can be output simultaneously for clinical display and subsequent process integration.

[0183] By implementing steps 101 to 115 above, this application, through structural preservation perturbation and consistency regularization, makes the output of the same slice more stable under common conditions such as window width and level fine-tuning, noise injection, and mild blurring, reducing result fluctuations in clinical use and improving engineering usability. This application implements controllable intervention on confounding components through a counterfactual suppression mechanism and guides the model to reduce its reliance on non-lesion shortcut clues such as skull edges, scanner textures, and artifacts with prediction invariance constraints, thereby reducing the risk of misjudgment under cross-center and cross-device conditions. This application improves the controllability of intervention through decoupling constraints between lesion-related components and confounding components, reducing the probability of mistakenly identifying valid lesion evidence when suppressing confounding, and improving training stability and final discrimination performance. This application does not rely on pixel-level lesion segmentation annotation; it only requires slice-level three-class labels for training, reducing data production costs and making it suitable for applications with rapid engineering deployment and limited data annotation resources. The inference phase only requires a single slice as input and one forward computation to output three probability distributions. The deployment process is simple and can be embedded into emergency imaging workstations or backend services to support rapid triage and assisted diagnosis.

[0184] The following section provides further explanation of the steps outlined in this application, using specific data:

[0185] The example uses a three-class classification: Class 1 is normal, Class 2 ischemic stroke, and Class 3 ischemic stroke. The truth label is taken as... .

[0186] To facilitate manual calculation and demonstration, a local image region (ROI) near the suspected lesion in the actual CT slice was selected for focused analysis, and the ROI was heavily downsampled. The average grayscale matrix of the block region. The matrix does not represent that the entire slice has only four pixels, but rather that the ROI is divided into four larger sub-regions, with each element being the average intensity value of the corresponding sub-region. This is used to visually represent the low-density trend commonly seen in ischemic lesions. Let the average HU value of the ROI be... The brain window values ​​from 0 to 80 HU are linearly normalized to 0 to 1 to obtain the standardized input. HU stands for Huntsfield Unit, used to describe the density distribution characteristics within a Region of Interest (ROI).

[0187] Two perturbation views are constructed according to formula (2) to simulate the overall brightness and slight noise perturbation caused by slight changes in window width and window level, respectively:

[0188] .

[0189] To demonstrate the computational chain, example values ​​of the network output from a single training iteration are provided. It should be noted that the intermediate feature values ​​below are derived from the output under the influence of network parameters, and are automatically learned during training in real-world engineering. The specific values ​​provided here are merely to correlate each formula with a calculable result, facilitating comparison and understanding. Let... The domain neutral proxy vector is taken For small batches, the size is 1.

[0190] Take the encoder output as:

[0191] .

[0192] Normalize using formula (4) and obtain the interaction graph using formula (5), resulting in the example result:

[0193] , .

[0194] Gating and modulation are obtained using formulas (6) and (7), and example results are obtained:

[0195] ;

[0196] ;

[0197] The shared representation is obtained according to formula (8):

[0198] .

[0199] The view-level logits and probabilities are obtained using formulas (9) and (10). Example output is provided:

[0200] ;

[0201] .

[0202] The probability consistency loss is calculated using formula (12). The consistency loss is calculated according to formula (13). The consistency regularization term is obtained according to formula (14). .

[0203] Take the global representation example value according to formula (15):

[0204] .

[0205] Example values ​​of the decomposed components are obtained according to formula (16):

[0206] .

[0207] The correlation was calculated using formulas (17) and (18). .

[0208] The example value of the retained vector is obtained according to formula (19). Let there be a neutral prototype before the iteration begins. According to formula (20): .

[0209] Update the neutral prototype according to formula (21), since the mini-batch size is 1. After being updated .

[0210] According to formula (22) and take Obtaining a counterfactual representation:

[0211] .

[0212] The example probabilities of the original prediction and the counterfactual prediction are obtained according to formula (23):

[0213] .

[0214] According to formula (24) and take Obtaining counterfactual constraint loss .

[0215] Example values ​​of the final probability distribution obtained by fusion and classification:

[0216] Of these, the second type has the highest probability and matches the true value. The settings.

[0217] The supervised cross-entropy loss is obtained according to formula (26):

[0218] .

[0219] The total loss is obtained using formula (27):

[0220] .

[0221] According to formula (28), the training objective is to minimize the total loss on the training set to obtain... During the inference phase, the three-class probability distribution is output according to formula (29). The system selects the category with the highest probability as the recognition result. In this embodiment, the output is ischemic stroke.

[0222] In one exemplary embodiment, a computer device is provided, which may be a server or a terminal, and its internal structure diagram may be as follows. Figure 2 As shown, the computer device includes a processor, memory, input / output (I / O) interfaces, and a communication interface. The processor, memory, and I / O interfaces are connected via a system bus, and the communication interface is also connected to the system bus via the I / O interfaces. The processor provides computational and control capabilities. The memory includes non-volatile storage media and internal memory. The non-volatile storage media stores the operating system, computer programs, and a database. The internal memory provides the environment for the operation of the operating system and computer programs stored in the non-volatile storage media. The database stores counterfactual consistency identification data from stroke CT scans. The I / O interfaces are used for exchanging information between the processor and external devices. The communication interface is used for communication with external terminals via a network connection. When the computer program is executed by the processor, it implements a method for counterfactual consistency identification of stroke CT scans.

[0223] Those skilled in the art will understand that Figure 2The structures shown are merely block diagrams of some structures related to the present application and do not constitute a limitation on the computer device to which the present application is applied. Specific computer devices may include more or fewer components than shown in the figures, or combine certain components, or have different component arrangements. In an exemplary embodiment, a computer device is provided, including a memory and a processor. The memory stores a computer program, and the processor executes the computer program to implement the steps in the above-described method embodiments.

[0224] In one exemplary embodiment, a computer-readable storage medium is provided storing a computer program that, when executed by a processor, implements the steps in the above-described method embodiments.

[0225] It should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, data stored, data displayed, etc.) involved in this application are all information and data authorized by the user or fully authorized by all parties, and the collection, use and processing of the relevant data must comply with relevant regulations.

[0226] Those skilled in the art will understand that all or part of the processes in the above embodiments can be implemented by a computer program instructing related hardware. The computer program can be stored in a non-volatile computer-readable storage medium. When executed, the computer program can include the processes of the embodiments described above. Any references to memory, databases, or other media used in the embodiments provided in this application can include at least one of non-volatile and volatile memory. Non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory, optical memory, high-density embedded non-volatile memory, resistive random access memory (ReRAM), magnetic random access memory (MRAM), ferroelectric random access memory (FRAM), phase change memory (PCM), graphene memory, etc. Volatile memory can include random access memory (RAM) or external cache memory, etc. By way of illustration and not limitation, RAM can take many forms, such as Static Random Access Memory (SRAM) or Dynamic Random Access Memory (DRAM).

[0227] The databases involved in the embodiments provided in this application may include at least one type of relational database and non-relational database. Non-relational databases may include, but are not limited to, blockchain-based distributed databases. The processors involved in the embodiments provided in this application may be general-purpose processors, central processing units, graphics processing units, digital signal processors, programmable logic devices, quantum computing-based data processing logic devices, etc., and are not limited to these.

[0228] The technical features of the above embodiments can be combined in any way. For the sake of brevity, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.

[0229] This document uses specific examples to illustrate the principles and implementation methods of this application. The descriptions of the above embodiments are only for the purpose of helping to understand the methods and core ideas of this application. Furthermore, those skilled in the art will recognize that, based on the ideas of this application, there will be changes in the specific implementation methods and application scope. Therefore, the content of this specification should not be construed as a limitation of this application.

Claims

1. A method for identifying counterfactual consistency in CT scans of stroke patients, characterized in that, The method for identifying counterfactual consistency in stroke CT scans includes: Unenhanced head CT plain scan slices were obtained and a training sample set was formed. Each slice was standardized to obtain standardized input. Based on the standardized input, two structural preservation perturbations are applied to the same slice to obtain two structural preservation perturbation views. The two perturbated structural views are input into a shared encoder to extract content features and domain features, respectively. Channel vector normalization is performed on the content features and domain features to generate an interaction graph; Based on the interaction graph, content gating and domain gating are generated and dual-gated modulation is performed to obtain modulated content features and modulated domain features. The modulated content features and modulated domain features are subjected to global average pooling and then concatenated to form a shared representation; The shared representation is input into the prediction head to obtain the category score vector and output the category probability distribution; Based on the category probability distribution and shared representation, a probability layer consistency loss and a representation layer consistency loss are constructed, and a consistency regularization term is obtained by combining them. The standardized input is processed by a backbone encoder to extract a global representation vector. The global representation vector is then mapped to two subspaces using a learnable projection matrix to obtain lesion-related components and confounding components. The hybrid components are gated and suppressed, and the suppressed parts are replaced with neutral prototype vectors to obtain the hybrid components after intervention. The lesion-related components are combined with the confounding components after intervention to obtain a counterfactual representation; The original representation and the counterfactual representation are classified and predicted separately, and a counterfactual constraint loss is constructed. The original global representation and the counterfactual representation are fused to output the final category probability distribution; A unified objective function is constructed, which includes supervised cross-entropy loss, the consistency regularization term, and the counterfactual constraint loss. The optimal parameters are obtained by minimizing the unified objective function on the training set. During the inference phase, a single slice is input, and the network corresponding to the optimal parameters outputs a three-class probability distribution to obtain the recognition result.

2. The method for recognizing counterfactual consistency in stroke CT scans according to claim 1, characterized in that, The two perturbation-preserving structural views are input into a shared encoder to extract content features and domain features, respectively, including: The two perturbed structural views are input into a shared encoder to obtain content features; A domain perturbation operator is applied to the two perturbation views of the structure to obtain a domain view; The domain features are obtained by encoding the domain view.

3. The method for recognizing counterfactual consistency in stroke CT scans according to claim 1, characterized in that, The content features and domain features are normalized using channel vectors, and an interaction graph is generated. Specifically, this includes: In each spatial location The channel vector is taken at the specified location, and the channel vector of the content feature is... The channel vector of the domain feature is ; The content feature channel vector and the domain feature channel vector are normalized using the second norm. The interaction graph is obtained by performing element-wise multiplication on the normalized content feature channel vector and the domain feature channel vector.

4. The method for identifying counterfactual consistency in stroke CT scans according to claim 1, characterized in that, Based on the interaction graph, content gating and domain gating are generated and dual-gated modulation is performed to obtain the modulated content features and modulated domain features using the following formulas: ; ; ; ; in, This represents a content gating tensor, whose elements range from 0 to 1, used to adjust the normalized content features. The degree of preservation in each spatial location and each passageway; This represents a convolution operator that gates the generated content. Represents the Sigmoid function; An interaction graph is used to represent the degree of co-activation of content features and domain features at corresponding positions and channels. This indicates the content characteristics after content gating modulation; This represents the content characteristics after normalization. The representation domain-gated tensor, whose elements range from 0 to 1, is used to adjust the normalized domain features. The degree of preservation; This represents the convolution operator used for generation domain gating; This represents the domain characteristics modulated jointly by domain gating and neutral proxy; This represents the normalized domain characteristics; express and All sheets of the same size; Represents a domain-neutral surrogate vector; This represents element-wise multiplication; This means to put the length of vector Copy expansion to Tensors of the same size.

5. The method for recognizing counterfactual consistency in stroke CT scans according to claim 1, characterized in that, The expression for the probability layer consistency loss is as follows: ; in, This represents the probability layer consistency loss. express divergence, This represents the predicted probability distribution of the first perturbation view. This represents the predicted probability distribution of the second perturbation view; The expression for the representation layer consistency loss is as follows: ; in, For the presentation layer consistency loss, This indicates that the first structural view retains a shared representation of the perturbation. This indicates that the second structure maintains a shared representation of the perturbation view. Represents the numerical stability constant; The expression for the consistency regularization term is as follows: ; in, This represents a consistency regularization term. This represents the weighting coefficient.

6. The method for identifying counterfactual consistency in stroke CT scans according to claim 1, characterized in that, The expression for the unified objective function is as follows: ; in, Represents a unified objective function. This represents the supervised cross-entropy loss. This represents a consistency regularization term. Indicates counterfactual constraint loss, and All of these represent weighting coefficients.

7. The method for identifying counterfactual consistency in stroke CT scans according to claim 6, characterized in that, The expression for the optimal parameter is as follows: ; in, This represents the complete set of learnable parameters of the model. This represents the optimal parameters after training convergence. Indicates the training dataset The expectation operation of a sample pair (x,y) in the middle. Represents the training dataset. Let x represent a training sample pair, where x is the input slice and y is the class label corresponding to the slice.

8. The method for identifying counterfactual consistency in stroke CT scans according to claim 1, characterized in that, During the inference phase, a single slice is input, and the network corresponding to the optimal parameters outputs a three-class probability distribution to obtain the recognition result. The specific formula used is as follows: ; in, This represents a three-class probability distribution. Indicates the final classification header, This represents a fusion mapping function or fusion network used for nonlinear reintegration of the concatenated vectors of the original global representation and the counterfactual representation. This represents the global representation extracted by the backbone encoder from the input slice x. This represents the counterfactual representation obtained by reconstructing the hybrid components after gating suppression and neutral prototype replacement.

9. A computer device, comprising: A memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that the processor executes the computer program to implement the stroke CT counterfactual consistency identification method according to any one of claims 1-8.

10. A computer-readable storage medium having a computer program stored thereon, characterized in that, When executed by a processor, the computer program implements the method for identifying counterfactual consistency in CT scans of stroke, as described in any one of claims 1-8.