An explainable MRI image analysis method and system based on anatomical constraint attention
By constructing an anatomically constrained attention-based MRI image analysis method, and combining it with modified ResNet50 and CBAM modules, the problems of channel redundancy and attention failure in MRI image analysis were solved, achieving high-precision and high-reliability NIID and hydrocephalus diagnosis, and providing visualized anatomical consistency and a transparent diagnostic process.
Patent Information
- Application Number
- CN202611250088.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Priority Date
- 2026-03-18
- Filing Date
- 2026-08-18
- Publication Date
- 2026-11-06
AI Technical Summary
Existing technologies in MRI image analysis suffer from problems such as channel redundancy, attention failure, and random missed diagnoses. In particular, in the automatic differentiation of MRI images between NIID and hydrocephalus, there is a lack of effective model architecture adaptability, fineness of attention mechanisms, and visualization of decision-making strategies, resulting in insufficient diagnostic accuracy and reliability.
An interpretable MRI image analysis method based on anatomical constraint attention is adopted. By constructing an anatomical constraint attention module modified by CBAM, combined with the ResNet50 backbone network, anatomical region mask and spatial attention map are introduced for MRI image preprocessing and deep learning model training. Channel weights are corrected using anatomical priors and candidate regions to generate structured diagnostic results and provide visualized heatmaps.
It improves the diagnostic accuracy and reliability of MRI image analysis, reduces background interference, enhances the anatomical consistency and interpretability of the model, improves the utilization efficiency of multi-slice diagnostic information, and enhances the transparency of clinical diagnosis.
Smart Images

Figure CN123051884A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of intelligent medical image analysis and computer-aided diagnosis, specifically to an interpretable MRI image analysis method and system based on anatomical constraint attention. Background Technology
[0002] Currently, deep learning-based MRI image analysis systems have been preliminarily applied in the diagnosis of various diseases. In particular, due to the characteristics of ResNet networks, classification and recognition applications using this framework are widespread. However, existing technologies still face numerous technical bottlenecks and limitations, including channel redundancy, attention failure, and random missed diagnoses. Furthermore, no technological breakthroughs have been achieved in the specific clinical scenario of automatic differentiation of NIID and hydrocephalus using MRI images. Therefore, there is an urgent need for an innovative solution that can systematically address the aforementioned technical bottlenecks in terms of model architecture adaptability, the effectiveness of attention mechanisms, the precision of decision-making strategies, and the targeted nature of training methods, in order to achieve high-precision and high-reliability automatic differentiation and diagnosis of neurological diseases such as NIID and hydrocephalus.
[0003] Patent application CN114897866A proposes a liver cancer MRI image classification method based on the ResNet model. This method discloses a technical solution combining the ResNet101 model with the CBAM attention mechanism for the differential diagnosis of hepatocellular carcinoma and intrahepatic cholangiocarcinoma. This technique enhances the model's ability to focus on lesion regions by introducing channel attention and spatial attention mechanisms, and adds a normalization layer and activation function to the residual structure to improve network stability. However, this solution has the following significant shortcomings: First, the introduction of its attention mechanism is relatively fixed, only placed before the first convolutional layer, failing to fully exploit the discriminative information in deep features; second, the solution lacks a visual explanation of the diagnostic decision-making process, making it difficult for physicians to intuitively understand the model's judgment basis; finally, this technique targets two-dimensional static image analysis and fails to fully consider the multi-slice and multi-temporal characteristics common in medical imaging.
[0004] Patent application CN115272218A proposes a medical image-assisted detection method based on a residual network using the CBAM mechanism. This method embeds the CBAM attention mechanism into a Res2Net residual network for chest X-ray detection and uses the Grad-CAM++ algorithm to generate heatmaps for lesion visualization. While this technology achieves some progress in interpretability, its integration method of the attention module is relatively traditional, simply inserting it into the last layer of each residual block, failing to achieve a deep adaptive fusion of the attention mechanism and the network architecture. Furthermore, the heatmap generation method in this scheme is still based on a traditional gradient-weighted mechanism, which has limited accuracy in locating subtle lesions in complex brain diseases.
[0005] Patent application CN117788954A proposes a lung CT nodule classification method based on a dual-channel convolutional neural network with an attention mechanism. This method uses a patient-level decision-making approach of "randomly selecting several layers + mean probability". This method is prone to losing diagnostic information in key slices, and the weight allocation is completely disconnected from the model training process. For diseases such as NIID and hydrocephalus, which may only show characteristic changes in certain key layers in multiple MRI slices, this crude decision-making strategy may lead to a high rate of missed diagnoses in clinical practice.
[0006] Current technologies lack dedicated training strategies tailored to the characteristics of medical imaging data. Most methods fail to adequately consider the unique attributes of medical images, such as patient-level data segmentation and automatic key slice selection mechanisms, thus limiting the model's generalization ability in real-world clinical scenarios. Furthermore, heatmaps generated by existing interpretable methods are often poorly localized, significantly deviating from the clinical focus of physicians and reducing the clinical acceptance of assisted diagnostic systems.
[0007] Furthermore, existing standard channel attention mechanisms such as CBAM, SE, and ECA typically rely on global pooling and parameter mapping to generate channel weights. They lack joint constraints from lesion candidate regions and anatomical priors, making it difficult to quantify the matching relationship between the spatial distribution of channel activation and disease-related candidate regions, and are easily affected by background region responses. Therefore, a channel weight correction scheme that incorporates lesion candidate regions and anatomical prior constraints is needed to improve the selection of disease-related feature channels and the spatial consistency of model attention. Summary of the Invention
[0008] To address this, the present invention provides an interpretable MRI image analysis method and system based on anatomically constrained attention, aiming to solve the dual dilemmas currently faced in the field of intelligent MRI image analysis, and is particularly applicable to the image discrimination of NIID and hydrocephalus.
[0009] To achieve the above objectives, the present invention provides the following technical solution: an interpretable MRI image analysis method based on anatomical constraint attention, comprising the following steps:
[0010] After the patient's slices are input, the original MRI images in multiple image formats are read and parsed, and converted into a standard three-channel RGB format that meets the input requirements of the pre-trained model. The standard three-channel RGB is then used as the input of the U²-Net deep network to predict the whole-brain mask and label the probability map of the whole-brain tissue regions.
[0011] The probability map is dynamically adjusted to the skull segmentation threshold through sequential adaptive thresholding to obtain a fine binary mask. After three-channel expansion, it is ANDed with the original MRI image to obtain a single-channel grayscale image that retains only the intracranial region, which is recorded as the stripped slice.
[0012] The image data after skull dissection was enhanced on a single-channel grayscale image, and patient isolation sampling was performed to obtain preprocessed MRI slice images.
[0013] The preprocessed MRI slice images are input into a deep learning model, which uses ResNet50 as the backbone network. The first-layer convolutional kernel is changed to a single channel and initialized with the average value of the original three-channel pre-trained weights. An anatomical constraint attention module based on CBAM is constructed. This module generates an anatomical region mask corresponding to the current two-dimensional slice through template registration, DICOM slice location information mapping, or a two-dimensional anatomical locator. The mask is then scaled to match the input slice, feature map, or heatmap. Figure 1 To achieve the desired spatial scale, after the third convolutional layer of ResNet50 at the Bottleneck layer, the spatial attention map is fused with the anatomical region mask to guide the spatial response to focus on the disease-related anatomical region;
[0014] The channel attention employs a two-level weight structure: a CBAM global pooling-MLP branch generates basic channel weights, while a spatial matching correction branch generates channel-corrected weights. The correction branch acquires a candidate region mask adapted to the MRI sequence, scales the activation feature maps of each channel to the spatial size of the candidate region mask, calculates the spatial matching degree between the two, and generates cropped or normalized channel-corrected weights based on the spatial matching degree. These weights are then fused with the basic channel weights to obtain the final channel weights.
[0015] For FLAIR sequences, high-signal candidate region masks are extracted using grayscale histograms or quantile thresholds, and then fused with the registered anatomical region masks to obtain the target candidate regions. For DWI, T1, and T2 sequences, corresponding sequence-specific candidate region rules can be used. If no corresponding rules are configured, the correction weights are set to neutral values and the correction branch is turned off. An additional anatomical region alignment loss is used during the training phase to constrain the attention response outside the anatomical region mask. This global constraint during training is independent of the local channel weight correction during the feature extraction phase.
[0016] By employing a layered unfreezing training approach, all parameters from layer 1 to layer 3 are frozen in the first stage, and only layer 4 and the fully connected layer are trained to ensure the quality of the basic features of the attention mechanism. In the second stage, all network parameters are unfrozen and combined with a low learning rate to achieve feature optimization dominated by the attention mechanism.
[0017] The patient ID list is divided into 5 folds to ensure that the same patient slice belongs only to the training set / validation set. Each fold is used to train an independent copy of the model. The optimal model is selected and saved as the core inference engine for subsequent patient-level analysis and testing.
[0018] The optimal model is used to automatically infer all MRI slices of a single patient. Through key slice screening and probability fusion strategies, and by introducing a dynamic weighting and voting hybrid mechanism, a structured patient-level diagnostic result dictionary for the patient is generated to achieve patient-level judgment and decision-making.
[0019] A visual heatmap is generated by using the key slice discriminant features of patients in a structured patient-level diagnostic results dictionary, and finally a structured diagnostic report is generated as an interpretation of the heatmap.
[0020] Preferably, the process of dynamically adjusting the sequence adaptive threshold is as follows:
[0021] Based on the original MRI images, a grayscale statistical feature library for each MRI sequence type is pre-generated, including pixel intensity quantiles, distribution skewness, and kurtosis. Pixel intensity quantiles use the median to characterize the signal central tendency, resisting interference from anomalous pixels. Distribution skewness describes the asymmetry of grayscale distribution; different sequences exhibit distinct skewness due to differences in tissue contrast. Kurtosis reflects the concentration or dispersion of signal distribution, helping to distinguish between uniform backgrounds and structured tissue regions. Current grayscale statistical features are extracted from the input patient-scanned MRI slices, and the most similar sequence type is matched using a Mahalanobis distance algorithm. Based on the matching results, a skull segmentation threshold is dynamically assigned: 0.20-0.30 for DWI sequences, 0.45-0.55 for T1 sequences, and 0.35-0.45 for FLAIR and T2 sequences.
[0022] Preferably, the lightweight EfficientNetV3-Small is used as the classification backbone. The stripped slices are fine-tuned through transfer learning to adapt to the three-class classification task in order to achieve artifact recognition. The three-class classification task includes normal slices, slightly acceptable artifacts and severely interfering artifacts. During training, the severely interfering artifact category adopts a weighted loss.
[0023] Preferably, during the automatic inference stage, the slices after skull dissection are input into the network. If the prediction probability of a severe interference artifact category is greater than 0.7, the slice is stored in an isolated directory and the file name is marked with the artifact type. At the same time, a structured quality control log containing patient ID, sequence type, slice path and confidence level is generated. Slices with minor artifacts are retained but marked with reduced weight. Finally, a three-level directory structure of patient-sequence-slice is output for retrieval.
[0024] Preferably, the stripped slice directory is read, and a batch data file list is created so that duplicate filenames under the same patient and the same sequence are kept only once; all images are pre-opened through the PIL library for integrity verification: images that cannot be opened, have a file size of 0, or have single-pixel abnormalities are automatically removed and logged to ensure that the subsequent training process is not interrupted by damaged images.
[0025] Preferably, the PatientAwareSampler sampler is used for isolated sampling of patients: a two-level index mapping between patients and slices is established, and the patient list and the slice index of each patient are randomly rearranged; when constructing training batches, slices are extracted sequentially from the index lists of different patients in a round-robin manner, and the next batch is entered after the preset batch size is reached; when the number of remaining patients is insufficient, the sampling is repeated, thereby reducing the occurrence of slices of the same patient in a single training batch.
[0026] Preferably, after the third convolutional layer of the ResNet50 Bottleneck, disease-specific prior knowledge is embedded into the attention mechanism, as shown in the following formula:
[0027] ;
[0028] in It is the final channel weight after fusion, including the basic channel weight and the channel correction weight; It is a spatial attention map; It is an anatomical region mask; It is the final output attention-weighted feature map; This is the output feature map of the third convolutional layer in Bottleneck; This represents the Hadamard product; for FLAIR sequences, the candidate region mask is the fusion result of the high-signal candidate region mask and the anatomical region mask; when the candidate region area is below a preset lower limit, the mask is all 0s or all 1s, the channel activation variance is 0, or the spatial matching degree cannot be calculated, the correction weight is set to a neutral value or the correction is skipped; for DWI, T1, or T2 sequences, candidate region generation rules can be configured according to sequence characteristics; if no corresponding rules are configured, the channel correction weight is set to a neutral value and the spatial matching degree correction branch is turned off.
[0029] Among them, the final channel weight after fusion The specific acquisition process is as follows:
[0030] This represents the output feature map of Bottleneck's third convolutional layer. Indicates the basic channel weights of CBAM. This represents the candidate region mask for the sequence. Indicates the anatomical region mask. This represents the target candidate region mask. Indicates the first One channel activation diagram, Indicates spatial matching degree, Indicates the first Channel adjustment weight, This represents the final channel weights after fusion;
[0031] The basic channel weights of CBAM are:
[0032] ;
[0033] For FLAIR sequences, the target candidate region mask is:
[0034] ;
[0035] in, For high-signal candidate region mask, For anatomical regions scaled to the same spatial scale;
[0036] For the The activation maps of each channel are standardized in size and flattened:
[0037] ;
[0038] Spatial matching degree is expressed using the Pearson correlation coefficient:
[0039] ;
[0040] in, To prevent constants with a denominator of 0;
[0041] The channel correction weights are generated using the following executable rules:
[0042] ;
[0043] in, This is the spatial matching threshold. To enhance the coefficients, the spatial matching degree threshold and enhancement coefficient Determined through validation sets or cross-validation; and These are the lower and upper limits for adjusting the weights, respectively.
[0044] The final channel weights are:
[0045] .
[0046] Preferably, an anatomical region alignment loss term is added to the loss function, and the attention weights of the deep learning model are concentrated on the target anatomical region by L2 regularization, thus reducing the total loss. The formula is:
[0047] ;
[0048] in, It is the NIID / Hydrocephalus binary classification cross-entropy loss. It is a loss of alignment of anatomical regions. It is the regularization coefficient; the alignment loss of the anatomical region. Global constraints used in the training phase, distinct from spatial matching degree channel correction in the feature extraction phase;
[0049] ;
[0050] in, Indicates the first The NIID positive predictive probability of a single slice; Indicates the total number of samples in the batch; Indicates the first Real patient profiles;
[0051] Anatomical region alignment loss Using spatial attention maps Anatomical region mask of the same scale calculate:
[0052] ;
[0053] in, This indicates the area outside the mask.
[0054] Preferably, the process for generating a structured patient-level diagnostic dictionary is as follows:
[0055] Slice-level inference involves loading the optimal model, iterating through all preprocessed MRI slice images of a specified patient and inputting them into the optimal model to obtain the raw probability value of each slice belonging to NIID. The value range is [0,1].
[0056] Automatic key slice selection: By invoking a custom key slice identification method, the system automatically selects the most crucial slices for the final diagnosis from all MRI slices of a single patient. The custom key slice identification method is as follows:
[0057] The prob_niid list is used to store all of the patient's prob_niids in slice order. The NIID prediction probability value of a slice, i.e., the original probability value. Create an index list that is independent of the prob_niid list. This is used to store the indices of the top_k key slices in the prob_niid list;
[0058] Using decision confidence The slices are sorted, with 0.5 being the critical threshold for binary classification; when the screening target is a key slice positive for NIID, the NIID prediction probability is used. Sort in descending order; when hour, ,otherwise ,in Indicates rounding down;
[0059] Integrating anatomical and patient-level clinical information: At the anatomical level, the Dice coefficient between the candidate region or high-response region of the heatmap and the target anatomical region mask is calculated to obtain the anatomical matching degree. The obtained anatomical matching degree and slice decision confidence degree jointly determine the dynamic weight. , and This is the weighting adjustment coefficient; β is the influencing factor for dissection, with a value range of [0,1]; β is the decision confidence adjustment coefficient, with a value range of [0,2]. The term incorporates anatomical priors for gain correction.
[0060] From a clinical perspective, patient age and history of hypertension are used as patient-level fusion correction factors, not directly as spatial weights for individual slides; the number of slides is adjusted based on the lesion distribution type, and the total number of slides for patients with single lesions is increased. Round down and compare with 1, taking the larger value as the number of key slices. For patients with multiple lesions, the total number of slides will be... Round down and compare with 3, taking the larger value as the number of key slices. When the total number of slices Less than the number of key slices Take all slices at that time;
[0061] Patient-level fusion decision-making involves calling a custom decision fusion method to generate predictive results, employing a hybrid fusion mode: key slices are weighted. Non-critical slice weights Calculate the weighted average probability :
[0062] set up The number of key slices, The number of non-critical slices is then the weighted average probability. If in the end If yes, the patient-level predictive label is NIID; otherwise, it is hydrocephalus.
[0063] For cases with advanced lesions or multiple lesions, the NIID label is output when the proportion of the NIID label in the key section prediction results is ≥80%; otherwise, the weighted average probability is used for judgment. The final output is a structured patient-level diagnostic result dictionary containing the prediction label, weighted average probability, and key section index.
[0064] Preferably, the heatmap interpretation process is as follows:
[0065] Multi-scale Grad-CAM is constructed by specifying one or more target layers in the network. For the same key slice, category-related heatmaps are generated with NIID category and hydrocephalus category as the target respectively. The original spatial size of the heatmaps of each target layer is based on the actual output of the model during runtime. After being unified to the input image size by bilinear interpolation, they are fused to obtain a normalized category heatmap.
[0066] Two-dimensional anatomical priors are introduced for spatial constraints: an anatomical region probability map of the current slice is generated based on the DICOM slice location information mapping or a two-dimensional anatomical locator, scaled to the same spatial scale as the category heatmap, and fused pixel by pixel to guide the heatmap response to mainly focus on clinically relevant anatomical locations; after fusion, the heatmap is normalized to the range of [0,1].
[0067] The spatial overlap rate between high-response regions in the heatmap and the target anatomical structure, the area ratio of high-response pixels, and the average normalized category heatmap response value are calculated to form quantitative parameters such as anatomical location, area ratio, and category response intensity. The category heatmap response value is used to represent the spatial response intensity of the model to the corresponding category and is not used as a pixel-by-pixel diagnostic probability.
[0068] High-response regions are color-coded based on the normalized thermal map responses of NIID and hydrocephalus categories, and then overlaid on the original grayscale image. Structural outlines from the two-dimensional anatomical prior image are overlaid on the color thermal map, and the corresponding anatomical structure names are labeled in the high-response regions to generate a visualization and legend. Color coding represents the thermal map response of the corresponding category, not the pixel-by-pixel diagnostic probability.
[0069] Preferably, the structured diagnostic report generation process is as follows:
[0070] The report data collection and integration process involves packaging raw image information, patient-level assessment and decision-making output classification diagnostic information, heatmaps with interpretable output, and file storage path lists into a structured report data object. Then, the report template is populated using a predefined HTML report template engine. This dynamically populates the corresponding positions in the HTML template with data objects such as patient basic information, imaging examination overview, AI diagnostic conclusions, heatmaps with overlaid raw images, and other report notes. Finally, the populated HTML report is rendered as a PDF document and automatically saved to a directory using the patient ID and date naming convention. A corresponding data upload interface is provided based on archiving requirements.
[0071] This invention also discloses an interpretable MRI image analysis system based on anatomical constraint attention. Based on the above method, the system includes:
[0072] The data preprocessing module automatically identifies and preprocesses the multimodal files of the input MRI slice images, which are then used as input data for the model.
[0073] The model training and optimization module accepts input data from the data preprocessing module and outputs the best-performing model weight file, providing an inference engine for the patient-level assessment and decision-making module.
[0074] The patient-level assessment and decision-making module uses a trained model to automatically infer the results from all MRI slices of a single patient and generates a structured patient-level diagnostic result dictionary for that patient through key slice screening and probability fusion strategies.
[0075] The heatmap interpretation module generates a visual heatmap based on the key slice discrimination features of a single patient, intuitively displaying the image regions that the model's decision-making focuses on.
[0076] The report generation module automatically outputs a structured diagnostic report that includes patient information, AI diagnostic conclusions, quantitative indicators, and visual heatmap evidence. It also supports PDF export and standardized medical record archiving.
[0077] This invention addresses potential issues in medical image analysis, such as channel redundancy, insufficient attention to subtle abnormal areas, inadequate utilization of multi-slice information, and lack of transparency in the decision-making process, and provides the following technical advantages:
[0078] First, a single-channel adapted CBAM-ResNet50 model is adopted, and attention weights are corrected by candidate region spatial matching degree and anatomical prior, which can reduce the interference of irrelevant channels and background regions on feature extraction.
[0079] Secondly, by using key slice screening and patient-level weighted fusion strategies, we can improve the utilization efficiency of multi-slice diagnostic information and reduce the dilution of key information caused by simple averaging.
[0080] Finally, by fusing category heatmaps with anatomical priors, the model’s areas of interest are displayed, improving the anatomical consistency and interpretability of the analysis results and providing a reference for the auxiliary differentiation between NIID and hydrocephalus. Attached Figure Description
[0081] Figure 1 This is a flowchart of the data preprocessing process of the present invention;
[0082] Figure 2 This is a flowchart of the model training and patient diagnosis decision-making process of the present invention;
[0083] Figure 3 This is a flowchart of the heatmap generation process of the present invention;
[0084] Figure 4 This is a flowchart of the overall method of the present invention;
[0085] Figure 5 This is a system module block diagram of the present invention;
[0086] Figure 6 This is an interpretable thermogram of NIID obtained from the analysis and discrimination results of this invention;
[0087] Figure 7 This invention provides an interpretable thermogram for hydrocephalus based on the analytical results. Detailed Implementation
[0088] The following specific embodiments illustrate the implementation of the present invention. Those skilled in the art can easily understand other advantages and effects of the present invention from the content disclosed in this specification. Obviously, the described embodiments are only some, not all, of the embodiments of the present invention. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.
[0089] The system of this invention is based on an interpretable MRI image analysis method using anatomically constrained attention, such as... Figures 4-5 As shown, the system includes the following modules:
[0090] 1. Data Preprocessing Module:
[0091] like Figure 1 As shown, a one-stop conversion is completed from the patient's original MRI slices to a clean, uniform, patient-isolated training set. Then, the skull is peeled off to remove extracranial noise, realizing the standardization of input data processing, obtaining standardized images, and improving data quality and model generalization ability.
[0092] First, the slice format is normalized. The system automatically recognizes multimodal file formats such as DICOM / NIfTI / PNG of the input images and parses patient ID, sequence type (DWI / FLAIR / T1 / T2), and device metadata, converting them into a unified three-channel, 8-bit deep RGB format matrix to adapt to the input format required by the pre-trained model. Then, the skull is dissected using U²-Net, and a pre-trained U²-Net deep network model outputs a whole-brain probability map. Finally, labeling and data partitioning are performed, and a sequence adaptive threshold adjustment submodule is constructed: a lightweight 3D-CNN classifier identifies the MRI sequence type, dynamically adjusts the skull segmentation threshold based on sequence signal characteristics, generates a fine brain tissue mask, expands it to three channels, performs pixel-by-pixel logical operations with the original image, and removes extracranial regions. Based on this, an artifact recognition submodule is constructed to perform a three-class quality assessment on the dissected slices, isolating and marking slices with severe motion artifacts, magnetic susceptibility artifacts, or folding artifacts from the training queue and generating a quality control log for physician review.
[0093] Data deduplication and integrity verification are performed by generating a unique key based on "patient ID + sequence name + file name" to ensure that the same slice from the same patient appears only once in the training set. Simultaneously, damaged or invalid image files are removed through file size verification and pixel anomaly detection. Finally, the verified image pixel values are converted into tensors conforming to a specific uniform distribution, encapsulated into standard data objects, and input into the inference and decision-making model.
[0094] 2. Model Training and Optimization Module:
[0095] like Figure 2 As shown, it receives images processed by the standard data preprocessing module, is responsible for training and optimizing the deep learning model for NIID and hydrocephalus classification, and outputs the best-performing model weight file for subsequent judgment and interpretation modules to use.
[0096] First, the model is initialized by loading pre-trained ResNet50 weights and changing its first-layer convolutional kernel from three-channel to single-channel, initialized with the mean of the original three-channel weights. Then, an anatomical constraint attention module based on a modified CBAM is constructed. Anatomical region masks are generated through template registration, DICOM slice location information mapping, or a two-dimensional anatomical locator, and scaled to match the slices or features. Figure 1 The spatial scale is as follows: the target anatomical region corresponding to NIID includes the subcortical white matter and basal ganglia, while the target anatomical region corresponding to hydrocephalus includes the lateral ventricle, the third ventricle, and the periventricular region.
[0097] The channel attention layer includes a CBAM global pooling-MLP basic weight branch and a candidate region spatial matching degree correction branch. The correction branch calculates the spatial matching degree between the channel activation map and the target candidate region mask, generates channel correction weights accordingly, and fuses them with the basic channel weights. The target candidate region for FLAIR sequences can be obtained by fusing a high-signal candidate region mask and an anatomical region mask; other sequences use corresponding sequence-specific candidate rules, and the correction branch is turned off when no corresponding rules are configured. The spatial matching degree preferably uses the Pearson correlation coefficient. When the candidate region area is too small, the mask is all 0s or all 1s, or the channel activation variance is 0, a neutral correction weight is used or the correction is skipped.
[0098] The attention module is inserted after the third convolutional layer of the residual block, and the spatial attention map and the anatomical region mask are fused by Hadamard product to guide the attention response to focus mainly on the target anatomical region; during the training phase, an anatomical region alignment loss is added to apply L2 constraints to abnormal attention responses outside the anatomical region mask.
[0099] Training cycle cross-validation includes:
[0100] 1. Layered unfreezing training: In the first stage, all parameters of layer 1 to layer 3 are frozen, and only layer 4 and the fully connected layer are trained. The Adam optimizer is used, the initial learning rate is set to 1e-4, and training is carried out for 10 epochs. In the second stage, all network parameters are unfrozen, the learning rate is reduced to 5e-5 and training continues until the early stopping condition is triggered.
[0101] 2. Five-fold patient-level cross-validation: The patient ID list is divided into five folds using the built-in K-fold cross-validation tool sklearn.model_selection.KFold in scikit-learn. This ensures that all slices of the same patient belong to only one of the training or validation sets. Each fold is used to train an independent copy of the model. After training, the AUC is calculated on the validation set. After the five-fold training is completed, the validation set AUC of each fold is compared and the best model is selected and saved. An early stopping mechanism is set to monitor the validation set AUC. If there is no improvement for 5 consecutive rounds, training is stopped and the model is automatically rolled back to the state with the highest validation set AUC. This module outputs the core inference engine of the patient-level judgment decision module and the test evaluation module.
[0102] 3. Patient-level assessment and decision-making module:
[0103] Using a trained model (i.e., the optimal model), automatic reasoning is performed on all MRI slices of a single patient to identify key slices for patients in the test set. Through key slice screening and probability fusion strategies, the final diagnostic label and confidence level of the patient are generated, realizing a higher-dimensional decision-making process from "slice-level prediction" to "patient-level diagnosis".
[0104] First, perform slice-level reasoning to obtain all information about the patient. The NIID prediction probability p_i of each slice is stored in the prob_niid list; the list of key slice indices is saved separately after filtering. Subscript. Decision confidence level. Screening for binary differential diagnostic sections; if specifically screening for NIID-positive key sections, then proceed as follows: Sort in descending order. hour, ,otherwise The anatomical dimension is determined by the anatomical matching degree between the candidate region or the high-response region of the heatmap and the target anatomical region mask. Adjust the screening weights; patient age, history of hypertension, and other information are used as patient-level fusion correction factors. For patients with single lesions, the total number of slides will be adjusted. Round down and compare with 1, taking the larger value as the number of key slices. Patients with multiple lesions will have a total number of slides. Round down and compare with 3, taking the larger value as the number of key slices.
[0105] Then, patient-level fusion decision-making is performed: Basic weights are first set for key and non-key slices, and then dynamically adjusted based on slice decision confidence and anatomical matching. For advanced lesions or multifocal cases, the NIID label is output when the proportion of NIID in the key slice prediction label is ≥80%; otherwise, a weighted average probability is used with a threshold of 0.5 to determine the patient-level label. Finally, the predicted label, weighted average probability, and key slice index are output.
[0106] 4. Heatmap Interpretation Module:
[0107] like Figure 3 As shown, a visual heatmap is generated for the key slice discriminative features of a single patient, intuitively displaying the image regions that the model focuses on in its decision-making, thus enhancing the transparency and interpretability of the diagnostic process.
[0108] First, a multi-scale Grad-CAM is constructed by specifying one or more target layers in the network, and category-related heatmaps are generated for NIID category and hydrocephalus category respectively. The original size of each target layer heatmap is based on the actual output of the model during runtime, and is unified to the input image size by bilinear interpolation before fusion. It is not pre-fixed to 7×7, 14×14 or 28×28.
[0109] Building upon this foundation, a two-dimensional anatomical structure prior is introduced for spatial constraints: An anatomical region probability map of the current slice is generated based on DICOM slice location information mapping or a two-dimensional anatomical locator. This map is then scaled to the same scale and fused pixel-by-pixel with the category heatmap to guide high-response regions to primarily concentrate at relevant anatomical locations. Furthermore, the spatial overlap rate between high-response regions and the target anatomical structure, the proportion of high-response pixel area, and the average normalized category heatmap response value are statistically analyzed. The response value represents the model's spatial response intensity to the target category and is not used as a pixel-by-pixel diagnostic probability.
[0110] Linear blending of the original heatmap: High-response regions are color-coded based on the normalized heatmap responses of NIID and hydrocephalus categories. Structural outlines from the two-dimensional anatomical prior image are overlaid on the color heatmap, and the corresponding anatomical structure names are labeled in the high-response regions. Finally, the color heatmap is overlaid onto the original grayscale image with a preset transparency to generate a legend. The color coding represents the category heatmap response, not the pixel-by-pixel diagnostic probability.
[0111] 5. Automatic report generation module:
[0112] The system's final output interface automatically generates a structured diagnostic report that includes patient information, AI diagnostic conclusions, quantitative indicators, and visual heatmap evidence, and supports PDF format export and standardized medical record archiving.
[0113] First, the report data is collected and integrated, packaging the original image information, the classification and diagnostic information output by the analysis module, and the heatmap and file storage path list output by the heatmap interpretability module into a structured report data object. Next, the report template is populated using a predefined HTML report template engine, dynamically filling the corresponding positions in the HTML template with data objects such as patient basic information, an overview of the imaging examination, AI diagnostic conclusions, overlaid heatmap interpretability images of the original images, and other report notes. Finally, the populated HTML report is rendered as a PDF document, automatically saved to a directory according to the patient ID and date naming convention, and a corresponding data upload interface is provided based on archiving requirements.
[0114] Based on the present invention, the corresponding embodiments are provided as follows:
[0115] Step 1: Data Preprocessing
[0116] 1.1 Data Acquisition:
[0117] This embodiment collected medical imaging information from 129 real NIID and hydrocephalus patients in a hospital, totaling 14,493 MRI images, including 4,155 DWI images, 2,469 FLAIR images, 5,371 T1 images, and 2,498 T2 images. The hardware environment for this embodiment was an NVIDIA RTX 3090 GPU, an Intel Xeon Gold 6230 CPU, and 64GB of RAM. The software environment consisted of Python 3.8, PyTorch 1.9, OpenCV 4.5, and scikit-learn 1.0.
[0118] 1.2 Skull dissection:
[0119] The file extension is used to determine whether to use OpenCV or PyDICOM to read the image. 16-bit DICOM data is directly divided by 256 to convert it to 8-bit, and then the three channels are copied for use by U²-Net. Simultaneously, a sequence adaptive threshold adjustment submodule is constructed: a lightweight 3D-CNN classifier (input is 8 consecutive slices of the same sequence from the patient, output is 4-class sequence probability distribution) automatically identifies the MRI sequence type and dynamically adjusts the skull segmentation threshold based on the sequence signal characteristics. Specifically, the DWI sequence threshold is reduced from a fixed 0.40 to 0.25, the T1 sequence threshold is increased to 0.50, and FLAIR and T2 sequences remain at 0.40. The single-channel probability map output by U²-Net is then binarized and expanded using dynamic thresholding. The image is divided into three channels, and bitwise operations are performed with the original image to remove extracranial regions. Based on this, an artifact recognition submodule is built using EfficientNetV3-Small to perform a three-class quality assessment on the stripped slices (normal slice / minor acceptable artifacts / severe interference artifacts). When the predicted probability of motion artifacts, magnetic susceptibility artifacts, or folding artifacts is greater than 0.7, it is judged as a severe interference artifact. The system automatically isolates the slice to the quarantine directory and records the patient ID, slice path, and artifact type in the quality_control.log log for physician review. The final processing results are uniformly saved in PNG format, and the directory structure maintains a three-level structure of "patient / sequence / image".
[0120] 1.3 File deduplication and integrity checks:
[0121] In the build_file_list phase, a dictionary is built using "patient ID + sequence name + lowercase file name" as the key. Only the first record with the same key is kept to remove duplicates. Then, PIL.Image.open() is used to try to load the image. If an exception is thrown or os.path.getsize returns 0, the file is removed and the skipped path is printed. The remaining files proceed to the next step.
[0122] 1.4 Data Augmentation and Patient Isolation Sampling:
[0123] During the training phase, images are randomly horizontally flipped, rotated ±10 degrees, and centered to 224×224 pixels, then normalized according to preset mean and standard deviation. During the validation and testing phases, scaling, centered cropping, and the same normalization are performed. The patient isolation sampler establishes a patient-slice index mapping, randomly rearranges patients and intra-patient slices, and sequentially extracts slices from different patients using a round-robin approach when constructing each training batch to reduce the clustering of consecutive slices from the same patient within the same batch.
[0124] Step 2: Model Training and Optimization
[0125] 2.1 Network skeleton adjustment:
[0126] Let the original pre-trained first-layer convolution kernel be... Single-channel convolution kernel ,in, middle This represents the original first-layer convolutional weight tensor of the ImageNet pre-training; 64 represents the real number space; 64 represents the number of convolution output channels; 3 represents the original input channels of the RGB image. This represents the first layer of the standard ResNet50. kernel size; middle This indicates a new convolution kernel for a single-channel MRI grayscale image; 1 indicates a single input channel for the MRI grayscale image.
[0127] ;
[0128] in, Indicates the output channel index, with a value range of [0, 63]; 1 indicates a fixed input channel number representing a single-channel convolution. This represents the original three-channel input channel index. Corresponds to RGB three channels; Represents the row and column coordinates of pixels inside the convolution kernel. ,correspond Convolution kernel; This represents the summation of the weights of the three original RGB input channels;
[0129] Single-channel MRI input image , This indicates the input of a single-channel MRI grayscale slice image; Indicates the number of pixels in the image height; Indicates the number of pixels in the image width; convolution outputs a feature map:
[0130] ;
[0131] in, This represents the feature map output by the first convolutional operation. This represents the spatial coordinates of the target pixel on the output feature map; This indicates traversing all positions of the 7×7 convolution kernel; This represents the pixel grayscale value corresponding to the convolution sliding window on the input MRI image; Indicates the first The bias parameters corresponding to each output channel; This represents the activation function. Setting negative features to zero introduces nonlinearity;
[0132] First convolutional layer output feature map The original image is mapped from pixel space to feature space to extract low-level basic visual features such as image edges and textures. At the same time, the output is a standardized feature tensor that matches the input requirements of the residual block, which serves as the input of the first residual block. Subsequent residual blocks learn incremental features based on this low-level basic visual feature and extract mid-to-high-level semantic information step by step.
[0133] Constructing an anatomically constrained attention module based on CBAM: Predefined neuroimaging anatomical region masks (NIID focuses on the subcortical white matter and basal ganglia, while hydrocephalus focuses on the lateral and third ventricles), embedding disease-specific prior knowledge into the attention mechanism, specifically:
[0134] The channel branching adopts a two-level weight structure: the standard CBAM pooling-MLP branch generates the basic channel weights, and the candidate region spatial matching degree correction branch generates the channel correction weights. In this preferred embodiment, the FLAIR high-signal candidate region and the anatomical region mask are fused to form the target candidate region, and the Pearson correlation coefficient is used to quantify the spatial matching degree between each channel activation map and the target candidate region, specifically:
[0135] This represents the output feature map of Bottleneck's third convolutional layer. Indicates the basic channel weights of CBAM. This represents the candidate region mask for the sequence. Indicates the anatomical region mask. This represents the target candidate region mask. Indicates the first One channel activation diagram, Indicates spatial matching degree, Indicates the first Channel adjustment weight, This represents the final channel weights after fusion.
[0136] The basic channel weights of CBAM are:
[0137] ;
[0138] For FLAIR sequences, the target candidate region mask is:
[0139] ;
[0140] in, For high-signal candidate region mask, A mask for anatomical regions scaled to the same spatial scale.
[0141] For the The activation maps of each channel are standardized in size and flattened:
[0142] ;
[0143] The Pearson correlation coefficient is preferred for spatial matching.
[0144] ;
[0145] in, To prevent constants with a denominator of 0.
[0146] The channel correction weights are generated using the following executable rules:
[0147] ;
[0148] in, This is the spatial matching threshold. To enhance the coefficients, the spatial matching degree threshold and enhancement coefficient This can be determined through validation sets or cross-validation. and These are the lower and upper limits for adjusting the weights, respectively.
[0149] The final channel weights are:
[0150] ;
[0151] The final attention-weighted feature map is as follows:
[0152] ;
[0153] When the area of the target candidate region is lower than the preset lower limit, the candidate region mask is all 0s or all 1s, the variance of the channel activation vector is 0, or the spatial matching degree cannot be calculated, Set to a neutral value of 1, or disable the correction branch for this slice.
[0154] The aforementioned channel weight correction can improve the feature channel weights that match the FLAIR high signal candidate regions; the channel compression ratio can be set to 16, the spatial attention convolution kernel can be set to 7, and the output and input should be kept at the same size to reduce the interference of background response on the feature extraction of the target region.
[0155] 2.2 Layered thawing and early stopping:
[0156] Set all model parameters `requires_grad` to `False`, then set `layer4` and `fc` to `True`; the optimizer only accepts trainable parameters, with a learning rate of 0.0001, specifically:
[0157] Parameter set partitioning:
[0158] Basic backbone freezing parameter set ;
[0159] Set of parameters to be trained ;
[0160] constraint: Update only ;
[0161] = ; This represents the learning rate in the first stage;
[0162] All parameters participate in gradient update; learning rate in the second stage: Compared to the first stage, this is reduced to prevent damage to the underlying features of the pre-trained model;
[0163] ;
[0164] ;
[0165] Introduce an anatomical region alignment loss term into the loss function. By using L2 regularization to constrain the model, the attention weights are concentrated on the target anatomical region, and the regularization coefficient is... The value was determined to be 0.01 after five-fold cross-validation, which was used to adjust the weight between classification loss and anatomical constraints;
[0166] Total loss ,in It is the NIID / Hydrocephalus binary classification cross-entropy loss. It is a loss of alignment of anatomical regions; The regularization coefficient is used.
[0167] ;
[0168] in, Indicates the first The NIID positive predictive probability of a single slice; Indicates the total number of samples in the batch; Indicates the first Real patient profiles;
[0169] Anatomical region alignment loss Using spatial attention maps Anatomical region mask of the same scale calculate:
[0170] ;
[0171] in, This indicates the area outside the mask.
[0172] If the EarlyStopping monitoring validation set AUC fails to improve for 5 consecutive rounds, it stops and saves the best model state to the path file specified during construction. After stopping, the file is automatically loaded and rolled back.
[0173] 2.3 50% patient-level cross-validation:
[0174] K-fold cross-validation was used to partition the patient list, with n_splits=5, shuffle=True, and random_state=42. This means the entire dataset was split into 5 equal parts, i.e., 5-fold cross-validation. Each fold was fine-tuned using stratified unfreezing, and the training was repeated for a total of 5 rounds. In each round, one fold was used as the validation set, and the remaining 4 folds were used as the training set. Before formal training, the order of all data was randomly shuffled. The random seed was fixed at 42, and the training and validation sets were isolated by patient ID. A model, optimizer, and EarlyStopping instance were created independently for each fold, and the optimal model was selected based on the validation set AUC.
[0175] Step 3: Patient-level diagnostic decision:
[0176] 3.1 Automatic selection of key slices:
[0177] A custom key slice identification method is invoked to automatically filter out the most crucial slices for the final diagnosis from all MRI slices of a single patient. The specific details of the custom key slice identification method are as follows:
[0178] The prob_niid list is used to store all of the patient's prob_niids in slice order. The NIID prediction probability value of a slice, i.e., the original probability value. Create an index list that is independent of the prob_niid list. Used to store the filtered results The index of the key slice in the prob_niid list;
[0179] Using decision confidence The slices are sorted, with 0.5 being the critical threshold for binary classification; when the screening target is a key slice positive for NIID, the NIID prediction probability is used. Sort in descending order; when hour, ,otherwise ,in This indicates rounding down to the nearest integer.
[0180] 3.2 Integrated Decision Making:
[0181] Integrating anatomical and patient-level clinical information: At the anatomical level, the Dice coefficient between the candidate region or high-response region of the heatmap and the target anatomical region mask is calculated to obtain the anatomical matching degree. The obtained anatomical matching degree and slice decision confidence degree jointly determine the dynamic weight. , and This is the weighting adjustment coefficient. The anatomical influence factor has a value range of [0,1] and has undergone cross-validation. Set to 0.5; β is the decision confidence adjustment coefficient, with a value range of [0,2], preferably 1.0; and Determined through validation set or five-fold cross-validation; Anatomical priors are introduced for gain correction; in the clinical dimension, patient age and history of hypertension are used as patient-level fusion correction terms, not directly as spatial weights for individual slides; the number of slides is adjusted according to the lesion distribution type, and the total number of slides for patients with single lesions is increased. Round down and compare with 1, taking the larger value as the number of key slices. For patients with multiple lesions, the total number of slides will be... Round down and compare with 3, taking the larger value as the number of key slices. When the total number of slices Less than the number of key slices Take all slices at that time;
[0182] The patient-level comprehensive assessment function `evaluate_by_patient` provides three fusion strategies:
[0183] 'weighted' simply averages the probabilities of all slices;
[0184] 'key_slice' only performs majority voting within the key slice;
[0185] 'hybrid' is enabled by default, with a key slice weight of 2.0 and the rest of the weights of 1.0. The patient-weighted average probability is calculated as follows. , It was determined to be NIID; and the fixed weights were optimized to a dynamic weighting mechanism:
[0186] For complex cases such as advanced lesions or multiple lesions, the NIID label is output when the proportion of NIID in the key section prediction label is greater than or equal to 80%; otherwise, a weighted average is used, forming a hybrid mode of "voting mechanism + weighted fusion".
[0187] Assign weights to key slices Non-critical slice weights Calculate the weighted average probability :
[0188] set up The number of key slices, The number of non-critical slices is then the weighted average probability. If in the end If yes, the patient-level predictive label is NIID; otherwise, it is hydrocephalus.
[0189] The final output is a structured patient-level diagnostic dictionary containing predicted labels, weighted average probabilities, and key slice indices. Lesion distribution types can be determined based on the number of connected components in candidate regions or high-response regions of the heatmap, or by physician annotation results.
[0190] Patient's final diagnosis label:
[0191] ;
[0192] The final output includes a dictionary of patient-level labels, probabilities, and metrics calculated by sklearn. Optional outputs include the true label, weighted probability, total number of slices, and number of key slices for each patient.
[0193] Step 4: Test Set Evaluation and Heatmap Interpretation
[0194] 4.1 Final Test:
[0195] This embodiment uses 14,493 MRI images from 129 patients with NIID and hydrocephalus to complete training, validation, and reserved testing. 20% of the patients are reserved as the test set. The optimal fold model is evaluated using the same hybrid fusion strategy. The evaluation function returns patient-level metrics and a confusion matrix, which are then plotted using seaborn.heatmap and saved as PNGs. Simultaneously, the results directory generates confusion matrix images of the optimal fold model selected from K-fold cross-validation, plotted on the independent test set. The final test set results are shown in Table 1.
[0196] Table 1
[0197] Evaluation indicators DWI sequence FLAIR sequence T1 sequence T2 sequence accuracy 0.9760 ± 0.0196 0.9385 ± 0.0188 0.9538 ± 0.0154 0.9692 ± 0.0154 AUC 0.9987 ± 0.0026 0.9571 ± 0.0239 0.9845 ± 0.0123 1.0000 ± 0.0000 Accuracy 0.9777 ± 0.0182 0.9395 ± 0.0201 0.9562 ± 0.0166 0.9714 ± 0.0143 Recall rate 0.9760 ± 0.0196 0.9385 ± 0.0188 0.9538 ± 0.0154 0.9692 ± 0.0154 F1 score 0.9759 ± 0.0197 0.9384 ± 0.0188 0.9539 ± 0.0154 0.9691 ± 0.0154 Sensitivity 0.9857 ± 0.0286 0.9571 ± 0.0350 0.9286 ± 0.0000 0.9857 ± 0.0286 Specificity 0.9636 ± 0.0445 0.9167 ± 0.0000 0.9833 ± 0.0333 0.9500 ± 0.0408
[0198] During the training, validation, and reserved testing of the 129 datasets described in this embodiment, the system obtained the evaluation metrics listed in the table above; the results listed are used to illustrate the running results of this embodiment under the corresponding data partitioning conditions.
[0199] 4.2 Heatmap Generation:
[0200] Multi-scale Grad-CAM was constructed for test set slices: Category-related heatmaps were generated at one or more target layers, targeting NIID and hydrocephalus categories respectively. The size of each target layer heatmap was based on the actual output during model runtime, and was unified to 224×224 pixels via bilinear interpolation before fusion. Anatomical region probability maps were generated based on DICOM slice location information mapping or a 2D anatomical locator, and fused pixel-by-pixel with the category heatmaps. The spatial overlap rate between high-response regions and target anatomical structures, the area ratio of high-response pixels, and the average normalized category heatmap response value were statistically analyzed. Color coding was performed based on the responses of the two types of heatmaps, and anatomical contours and structure names were overlaid. The color represents the category heatmap response rather than the pixel-by-pixel diagnostic probability.
[0201] Step 5: Automatic Report Generation Module:
[0202] 5.1 Data Extraction: The patient_details dictionary returned by evaluate_by_patient is called to extract the true patient labels, predicted probabilities, and key slice indices.
[0203] 5.2 Heatmap Embedding: Based on the heatmap file generated by the code, read the NIID-Red / Hydrocephalus-Blue overlay image from the directory, embed it in the report evidence section and attach the heatmap legend.
[0204] 5.3 Metrics Filling: Extract values such as accuracy, AUC, sensitivity, and specificity from the test set; during cross-validation, call avg_val_metrics and std_val_metrics to generate mean ± standard deviation format.
[0205] 5.4 PDF Export: Click the Report Generation button, file the file in the format "Patient ID_Examination Date_AI Diagnosis Report.pdf", archive it to the reports_archive / year / month / directory and support uploading to multiple system interfaces.
[0206] This invention employs a single-channel adapted CBAM-ResNet50 model, introducing channel weight correction based on candidate region spatial matching degree in the CBAM channel branches, and combining anatomical region masking to constrain spatial attention, which can reduce interference from irrelevant channels and background regions; improve the utilization efficiency of multi-slice diagnostic information through key slice screening and patient-level fusion; and improve the anatomical consistency and interpretability of the results by fusing category heatmaps with anatomical priors to display the model's focus areas, providing a reference for the auxiliary differentiation between NIID and hydrocephalus.
[0207] Although the present invention has been described in detail above with general descriptions and specific embodiments, modifications or improvements can be made to it, which will be obvious to those skilled in the art. Therefore, all such modifications or improvements made without departing from the spirit of the present invention fall within the scope of protection claimed by the present invention.
Claims
1. An interpretable MRI image analysis method based on anatomically constrained attention, characterized in that: Includes the following steps: The preprocessed MRI slice images are input into the deep learning model; The deep learning model uses the ResNet50 backbone network, changes the first-layer convolutional kernel to a single channel, and initializes it using the average value of the three-channel pre-trained weights; it constructs an anatomical constraint attention module based on CBAM modification, which scales the anatomical region mask corresponding to the input slice to the same spatial scale as the input slice, feature map, or heatmap. The channel attention mechanism includes a basic channel weight generation branch and a spatial matching degree correction branch. The basic channel weight generation branch generates basic channel weights through the global pooling-MLP structure of CBAM. The spatial matching degree correction branch obtains a candidate region mask that is compatible with the MRI sequence, calculates the spatial matching degree between the activation feature map of each channel and the candidate region mask, generates channel correction weights based on the spatial matching degree, and fuses the channel correction weights with the basic channel weights to obtain the final channel weights. After the third convolutional layer of ResNet50's Bottleneck, the spatial attention map is fused with the anatomical region mask to guide the spatial response to focus on the target anatomical region; during the training phase, an anatomical region alignment loss term is added to the loss function to apply L2 constraints to the attention response outside the anatomical region mask; By employing a layered unfreezing training approach, all parameters from layer 1 to layer 3 are frozen in the first stage, and only layer 4 and the fully connected layer are trained to ensure the quality of the basic features of the attention mechanism. In the second stage, all network parameters are unfrozen and combined with a low learning rate to achieve feature optimization dominated by the attention mechanism. A two-stage, stratified thawing training method was adopted. The dataset was divided into five parts according to patient ID and the optimal model of the validation set was selected. After inference on all patient image slices, the patient-level diagnostic results were obtained through slice screening and probability-weighted voting, generating heatmaps and structured diagnostic reports.
2. The interpretable MRI image analysis method based on anatomical constraint attention according to claim 1, characterized in that: After the patient's slices are input, the original MRI images in multiple image formats are read and parsed, and converted into a standard three-channel RGB format that meets the input requirements of the pre-trained model. The standard three-channel RGB is then used as the input of the U²-Net deep network to predict the whole-brain mask and label the probability map of the whole-brain tissue regions. The probability map is dynamically adjusted to the skull segmentation threshold through sequential adaptive thresholding to obtain a fine binary mask. After three-channel expansion, it is ANDed with the original MRI image to obtain a single-channel grayscale image that retains only the intracranial region, which is recorded as the stripped slice. The image data after skull dissection was enhanced on a single-channel grayscale image, and patient isolation sampling was performed to obtain preprocessed MRI slice images.
3. The interpretable MRI image analysis method based on anatomical constraint attention according to claim 2, characterized in that: The process of dynamic adjustment of the sequence adaptive threshold is as follows: Based on the original MRI images, a gray-scale statistical feature library for each MRI sequence type is pre-generated. The current gray-scale statistical features are extracted from the input patient slices of the same sequence, and the most similar sequence type is matched using the Mahalanobis distance algorithm. The skull segmentation threshold is dynamically assigned based on the matching results, with the threshold range for DWI sequence set to 0.20-0.30, the threshold range for T1 sequence set to 0.45-0.55, and the threshold range for FLAIR and T2 sequences set to 0.35-0.
45.
4. The interpretable MRI image analysis method based on anatomical constraint attention according to claim 3, characterized in that: [The following is a partial translation of the original text, which is not directly related to the preceding paragraph.] Original pre-trained first-layer convolutional kernel Single-channel convolution kernel ,in, middle This represents the original first-layer convolutional weight tensor of the ImageNet pre-training; 64 represents the real number space; 64 represents the number of convolution output channels; 3 represents the original input channels of the RGB image. This represents the first layer of the standard ResNet50. kernel size; middle This indicates a new convolution kernel for a single-channel MRI grayscale image; 1 indicates a single input channel for the MRI grayscale image. ; in, Indicates the output channel index, with a value range of [0, 63]; 1 indicates a fixed input channel number representing a single-channel convolution. This represents the original three-channel input channel index. Corresponds to RGB three channels; Represents the row and column coordinates of pixels inside the convolution kernel. ,correspond Convolution kernel; This represents the summation of the weights of the three original RGB input channels; Single-channel MRI input image , This indicates the input of a single-channel MRI grayscale slice image; Indicates the number of pixels in the image height; Indicates the number of pixels in the image width; convolution outputs a feature map: ; in, This represents the feature map output by the first convolutional operation. This represents the spatial coordinates of the target pixel on the output feature map; This indicates traversing all positions of the 7×7 convolution kernel; This represents the pixel grayscale value corresponding to the convolution sliding window on the input MRI image; Indicates the first The bias parameters corresponding to each output channel; This represents the activation function. Setting negative features to zero introduces nonlinearity; First convolutional layer output feature map The original image is mapped from pixel space to feature space to extract the basic visual features of the image at the bottom level. At the same time, the output is a standardized feature tensor that matches the input requirements of the residual block. This tensor is used as the input of the first residual block. Subsequent residual blocks learn incremental features based on this basic visual feature and extract mid-to-high-level semantic information step by step.
5. The interpretable MRI image analysis method based on anatomical constraint attention according to claim 4, characterized in that: After the third convolutional layer of the Bottleneck layer in ResNet50, disease-specific prior knowledge is embedded into the attention mechanism, as shown in the following formula: ; in It is the final channel weight after fusion, including the basic channel weight and the channel correction weight; It is a spatial attention map; It is an anatomical region mask; It is the final output attention-weighted feature map; This is the output feature map of the third convolutional layer in Bottleneck; This represents the Hadamard product; for FLAIR sequences, the candidate region mask is the fusion result of the high-signal candidate region mask and the anatomical region mask; when the candidate region area is lower than the preset lower limit, the mask is all 0 or all 1, the channel activation variance is 0, or the spatial matching degree cannot be calculated, the correction weight is set to a neutral value or the correction is skipped. Among them, the final channel weight after fusion The specific acquisition process is as follows: This represents the output feature map of Bottleneck's third convolutional layer. Indicates the basic channel weights of CBAM. This represents the candidate region mask for the sequence. Indicates the anatomical region mask. This represents the target candidate region mask. Indicates the first One channel activation diagram, Indicates spatial matching degree, Indicates the first Channel adjustment weight, This represents the final channel weights after fusion; The basic channel weights of CBAM are: ; For FLAIR sequences, the target candidate region mask is: ; in, For high-signal candidate region mask, For anatomical regions scaled to the same spatial scale; For the The activation maps of each channel are standardized in size and flattened: ; Spatial matching degree is expressed using the Pearson correlation coefficient: ; in, To prevent constants with a denominator of 0; The channel correction weights are generated using the following executable rules: ; in, This is the spatial matching threshold. To enhance the coefficients, the spatial matching degree threshold and enhancement coefficient Determined through validation sets or cross-validation; and These are the lower and upper limits for adjusting the weights, respectively. The final channel weights are: 。 6. The interpretable MRI image analysis method based on anatomical constraint attention according to claim 5, characterized in that: A new anatomical region alignment loss term is added to the loss function. L2 regularization is used to constrain the deep learning model's attention weights to focus on the target anatomical region. The total loss... The formula is: ; in, It is the NIID / Hydrocephalus binary classification cross-entropy loss. It is a loss of alignment of anatomical regions. It is the regularization coefficient; the alignment loss of the anatomical region. Global constraints used in the training phase, distinct from spatial matching degree channel correction in the feature extraction phase; ; in, Indicates the first The NIID positive predictive probability of a single slice; Indicates the total number of samples in the batch; Indicates the first Real patient profiles; Anatomical region alignment loss Using spatial attention maps Anatomical region mask of the same scale calculate: ; in, This indicates the area outside the mask.
7. The interpretable MRI image analysis method based on anatomical constraint attention according to claim 6, characterized in that: The process of generating a structured patient-level diagnostic dictionary for patients is as follows: Slice-level inference involves loading the optimal model, iterating through all preprocessed MRI slice images of a specified patient and inputting them into the optimal model to obtain the raw probability value of each slice belonging to NIID. The value range is [0,1]. Automatic key slice selection: By invoking a custom key slice identification method, the system automatically selects the most crucial slices for the final diagnosis from all MRI slices of a single patient. The custom key slice identification method is as follows: The prob_niid list is used to store all of the patient's prob_niids in slice order. The NIID prediction probability value of a slice, i.e., the original probability value. Create an index list that is independent of the prob_niid list. Used to store the filtered results The index of the key slice in the prob_niid list; Using decision confidence The slices are sorted, with 0.5 being the critical threshold for binary classification; when the screening target is a key slice positive for NIID, the NIID prediction probability is used. Sort in descending order; when hour, ,otherwise ,in Indicates rounding down; Integrating anatomical and patient-level clinical information: In terms of anatomical dimensions, the Dice coefficient between the candidate region or high-response region of the heatmap and the target anatomical region mask is calculated to obtain the anatomical matching degree. The obtained anatomical matching degree and slice decision confidence degree jointly determine the dynamic weight. , and This is the weighting adjustment coefficient; β is the influencing factor for dissection, with a value range of [0,1]; β is the decision confidence adjustment coefficient, with a value range of [0,2]. The term incorporates anatomical priors for gain correction. In the clinical dimension, patient age and history of hypertension are used as patient-level fusion correction terms, and are not directly used as spatial weights of individual slices; The screening quantity was adjusted based on the lesion distribution type; the total number of slides was increased for patients with single lesions. Round down and compare with 1, taking the larger value as the number of key slices. For patients with multiple lesions, the total number of slides will be... Round down and compare with 3, taking the larger value as the number of key slices. When the total number of slices Less than the number of key slices Take all slices at that time; Patient-level fusion decision-making involves calling a custom decision fusion method to generate predictive results, employing a hybrid fusion mode: key slices are weighted. Non-critical slice weights ; Calculate the weighted average probability : set up The number of key slices, The number of non-critical slices is then the weighted average probability. If in the end If yes, the patient-level predictive label is NIID; otherwise, it is hydrocephalus. For cases with advanced lesions or multiple lesions, the NIID label is output when the proportion of the NIID label in the key section prediction results is ≥80%; otherwise, the weighted average probability is used for judgment. The final output is a structured patient-level diagnostic result dictionary containing the prediction label, weighted average probability, and key section index.
8. An interpretable MRI image analysis system based on anatomical constraint attention, characterized in that: The system comprises, based on the method according to any one of claims 1-7, the system including: The data preprocessing module automatically identifies and preprocesses the multimodal files of the input MRI slice images, which are then used as input data for the model. The model training and optimization module accepts input data from the data preprocessing module and outputs the best-performing model weight file, providing an inference engine for the patient-level assessment and decision-making module. The patient-level assessment and decision-making module uses a trained model to automatically infer the results from all MRI slices of a single patient and generates a structured patient-level diagnostic result dictionary for that patient through key slice screening and probability fusion strategies. The heatmap interpretation module generates a visual heatmap based on the key slice discrimination features of a single patient, intuitively displaying the image regions that the model's decision-making focuses on. The report generation module automatically outputs a structured diagnostic report that includes patient information, AI diagnostic conclusions, quantitative indicators, and visual heatmap evidence. It also supports PDF export and standardized medical record archiving.
Citation Information
Patent Citations
ResNet model-based liver cancer nuclear magnetic image classification method
CN114897866A
Medical image auxiliary detection method of residual network based on CBAM mechanism
CN115272218A
Lung CT nodule classification method based on attention mechanism double-channel convolutional neural network
CN117788954A
