{"id":68436,"date":"2025-10-21T08:25:11","date_gmt":"2025-10-21T08:25:11","guid":{"rendered":"https:\/\/biomedpharmajournal.org\/?p=68436"},"modified":"2025-10-22T06:23:12","modified_gmt":"2025-10-22T06:23:12","slug":"an-explainable-ai-based-ensemble-framework-for-brain-tumor-mri-classification-and-automated-clinical-reporting-using-deep-learning-and-llm-integration","status":"publish","type":"post","link":"https:\/\/biomedpharmajournal.org\/staging\/vol18octoberspledition\/an-explainable-ai-based-ensemble-framework-for-brain-tumor-mri-classification-and-automated-clinical-reporting-using-deep-learning-and-llm-integration\/","title":{"rendered":"An Explainable AI-Based Ensemble Framework for Brain Tumor MRI Classification and Automated Clinical Reporting Using Deep Learning and LLM Integration"},"content":{"rendered":"<p><strong>Introduction<\/strong><\/p>\n<p>Cerebral neoplasms are among the most critical and life-threatening of the neurological illnesses, and accurate diagnosis of such tumors is vital for prompt intervention and treatment planning. Magnetic Resonance Imaging (MRI) has been widely regarded as the gold standard for brain tumor diagnosis due to its superior resolution for imaging soft tissue.<sup>1<\/sup> However, interpretation of the MRI scan remains plagued by serious issues heavily dependent on the expertise of radiologists, leading to widespread inconsistency and possible delay in diagnosis.<\/p>\n<p>Over the last several years, the integration of Artificial Intelligence (AI), machine learning,<sup>2,3,<\/sup> and particularly deep learning into medical imaging has seen impressive success in the automation of image-based diagnosis procedures and enhanced clinical effectiveness.<sup>4,5<\/sup> Despite the success, one of the major problems that afflicts AI systems within the health care industry is the black box nature of deep learning models, which may reduce the confidence of health care professionals. Explainable AI (XAI) techniques have emerged as major solutions to address the issue, providing both visual and quantitative explanations of model predictions and enhanced transparency.<sup>6<\/sup><\/p>\n<p>To overcome such limitations, we introduce a better MRI Analysis AI Application that utilizes an ensemble of state-of-the-art Convolutional Neural Networks, including DenseNet121, ResNet50, EfficientNet-B0, and MobileNetV3-Small, to efficiently classify brain MRI scans into four clinically relevant classes: Glioma, Meningioma, No Tumor, and Pituitary Tumor. The ensemble process increases the consistency of the classification process, and preprocessing methods ensure consistency over diverse image inputs.<\/p>\n<p>A distinguishing feature of this study is the use of different explainable artificial intelligence (XAI) techniques like Grad-CAM,<sup>7<\/sup> LIME,<sup>8<\/sup> SHAP,<sup>9,<\/sup> and a specially designed Saliency-based Neural Activation Pattern (SNAP) to facilitate multi-faceted interpretability. Furthermore, integration with a Large Language Model (LLM) utilizing the assistance of LangChain-Groq facilitates the creation of interpretable diagnostic reports, thus bridging the communication gap between artificial intelligence systems and medical professionals. The novelty lies in this end-to-end, interpretable, and deployable system, therefore rendering it suitable for real-time, clinician-led decision support in radiology clinics.<\/p>\n<p>The novelty of this research lies in the development of a comprehensive end-to-end pipeline that not only delivers high classification accuracy through a CNN ensemble but also integrates multiple Explainable AI methods like Grad-CAM, LIME, SHAP, and Edge Detection to ensure clinical transparency. Unlike prior studies that emphasize either accuracy or interpretability, our framework offers both simultaneously, making predictions reliable as well as understandable to radiologists. In addition, the system uniquely incorporates a Large Language Model (via LangChain-Groq) to generate automated, human-readable clinical reports, thereby bridging the gap between AI outputs and clinical workflows. This fusion of ensemble learning, interpretability, and automated reporting represents a distinct contribution, positioning the proposed framework as a deployable and clinician-friendly solution for real-time brain tumor diagnosis.<\/p>\n<p><strong>Literature Review<\/strong><\/p>\n<p>Recent advances in deep learning (DL) have significantly improved the classification of brain tumors using MRI data.<sup>10,11<\/sup> Abdusalomov et al.<sup>12 <\/sup>confirmed the utility of DL for brain tumor detection using multi-sequence MRI, although the lack of interpretability remained a concern.<\/p>\n<p>Explainable AI (XAI) techniques have been increasingly adopted to address this. Sadeghi et al.<sup>13 <\/sup>emphasized the need for transparency in DL predictions, particularly in clinical applications. Xiao et al.<sup>14<\/sup> enhanced Grad-CAM visualizations for medical image segmentation to improve interpretability in clinical imaging tasks. Kun et al.<sup>15<\/sup> proposed an optimized LIME framework tailored for low-light medical images, enhancing local feature attribution. Sun et al<sup>16 <\/sup>utilized SHAP to uncover age-based risk factors in mammography data, supporting personalized diagnostic insights. These techniques enable visualization of decision-making processes, helping radiologists validate AI-generated results. Such tools have been applied in Alzheimer&#8217;s detection,<sup>17<\/sup> dermatology,<sup>18<\/sup> and ophthalmology,<sup>19<\/sup> proving their value in healthcare AI.<\/p>\n<p>Cheng et al.<sup>20 <\/sup>proposed tumor region augmentation techniques for enhancing classification robustness in MRI scans. Public datasets like Figshare, SARTAJ,<sup>21<\/sup> and Br35H <sup>22<\/sup> have become standard benchmarks for training and evaluating brain tumor classification models. Ensemble models combining DenseNet, ResNet, and EfficientNet have shown superior accuracy over single-architecture models,<sup>23, 24<\/sup> and Mustapha et al. <sup>25<\/sup> demonstrated improved performance using hybrid ConvNeXt frameworks for leukemia subtype detection.<\/p>\n<p>Recently, the integration of Large Language Models (LLMs) into medical AI pipelines has opened new dimensions for automated interpretation. LangChain-powered models like BLIP, <sup>26<\/sup> Med-PaLM, <sup>27<\/sup> and ClinicalT5 <sup>28<\/sup> provide human-readable diagnostic summaries from model outputs, bridging the gap between AI reasoning and clinical narratives.<\/p>\n<p>In summary, existing literature underscores the synergy between high-performance DL models, explainability tools, and natural language interfaces. The proposed study contributes to this growing body by offering a unified system integrating CNN ensembles, multiple XAI methods, and LLM-driven report generation.<\/p>\n<p><strong>Materials and Methods<\/strong><\/p>\n<p><strong>Dataset Explanation<\/strong><\/p>\n<p>The dataset employed in this study is an aggregation of three publicly available brain MRI datasets: Figshare, SARTAJ, and Br35H, collectively comprising a total of 7023 images. The images are divided into four categories: Glioma, Meningioma, Pituitary Tumor, and absence of a tumor, covering a broad spectrum of brain abnormalities. The inclusion of diverse data sources ensures greater generalizability across patient populations and imaging conditions. Each image underwent preprocessing, including grayscale conversion, resizing to 224\u00d7224 pixels, and intensity normalization to standardize the inputs across models. The dataset was stratified into an 80:20 ratio for training and testing, maintaining balanced representation across all classes. These datasets have been previously validated in several peer-reviewed studies and are recognized benchmarks for brain tumor classification using deep learning approaches. <sup>20, 21, 22 <\/sup>Fig.1 shows a representative MRI image selected from the curated dataset used in this study, which includes images from Figshare, SARTAJ, and Br35H repositories. The input image undergoes preprocessing steps such as grayscale conversion, resizing, and normalization before being fed into the CNN ensemble model for classification into one of the four tumor categories: Glioma, Meningioma, Pituitary Tumor, or No Tumor. This sample image demonstrates the system\u2019s initial input format prior to analysis and classification.<\/p>\n<table style=\"width: 70%; border-collapse: collapse;\" border=\"1\" cellpadding=\"5\">\n<tbody>\n<tr>\n<td style=\"width: 27.1005%;\"><img decoding=\"async\" class=\"alignnone wp-image-68440 size-thumbnail\" src=\"https:\/\/biomedpharmajournal.org\/wp-content\/uploads\/2025\/10\/Vol18NoOct-Spl_Exp_Kal_Fig1-150x150.jpg\" alt=\"\" width=\"150\" height=\"150\" srcset=\"https:\/\/biomedpharmajournal.org\/staging\/wp-content\/uploads\/2025\/10\/Vol18NoOct-Spl_Exp_Kal_Fig1-150x150.jpg 150w, https:\/\/biomedpharmajournal.org\/staging\/wp-content\/uploads\/2025\/10\/Vol18NoOct-Spl_Exp_Kal_Fig1-250x250.jpg 250w, https:\/\/biomedpharmajournal.org\/staging\/wp-content\/uploads\/2025\/10\/Vol18NoOct-Spl_Exp_Kal_Fig1-256x256.jpg 256w, https:\/\/biomedpharmajournal.org\/staging\/wp-content\/uploads\/2025\/10\/Vol18NoOct-Spl_Exp_Kal_Fig1.jpg 683w\" sizes=\"(max-width: 150px) 100vw, 150px\" \/><\/td>\n<td style=\"width: 72.8995%;\">\n<p><strong>Figure 1: Sample Input Brain MRI Image from the Dataset<\/strong><\/p>\n<p><a href=\"https:\/\/biomedpharmajournal.org\/wp-content\/uploads\/2025\/10\/Vol18NoOct-Spl_Exp_Kal_Fig1.jpg\" target=\"_blank\" rel=\"noopener\">Click here to view Figure<\/a><\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p><strong>Proposed System Workflow Overview<\/strong><\/p>\n<p>Fig. 2 illustrates the overall process flow diagram of the proposed MRI Analysis AI app. The pipeline consists of nine key modules arranged in a systematic and interpretable flow from raw image ingestion to final report generation.<\/p>\n<p>The workflow starts with the Dataset module, containing 7,023 brain MRI scans collected from the Figshare, SARTAJ, and Br35H datasets. These images are first subjected to a Pre-processing phase involving grayscale conversion, resizing (224\u00d7224), normalization, and data augmentation. Following preprocessing, the images are fed into the Training module, where a CNN ensemble is constructed using four well-known architectures: DenseNet121, ResNet50, EfficientNet-B0, and MobileNetV3-Small. To handle class imbalance, these networks are trained independently with stratified data splits and cyclic learning rate optimization. The optimal model is chosen by evaluating its validation accuracy and loss metrics. This model is then used for Prediction, where MRI scans are categorized into one of the four classes: Glioma, Meningioma, No Tumor, or Pituitary Tumor.<\/p>\n<p>To enhance model transparency, the framework includes an Explainability Analysis unit employing multiple techniques: LIME for local explanations, SHAP for feature attributions (not shown in the diagram but included in the manuscript), SNAP for saliency mapping, Grad-CAM for class-specific localization, and Edge Detection for structural enhancement. The insights derived from explainability modules are passed into the LLM Integration component, powered by LangChain-Groq, which translates predictions and visual explanations into human-readable medical reports.<\/p>\n<p>Subsequently, the Result Visualization module organizes outputs, including class labels and saliency maps, in a structured format. Finally, the system executes Report Generation using the FPDF library, embedding clinical summaries and annotated images into a downloadable PDF file.<\/p>\n<table style=\"width: 70%; border-collapse: collapse;\" border=\"1\" cellpadding=\"5\">\n<tbody>\n<tr>\n<td style=\"width: 27.1005%;\"><img decoding=\"async\" class=\"alignnone wp-image-68441 size-thumbnail\" src=\"https:\/\/biomedpharmajournal.org\/wp-content\/uploads\/2025\/10\/Vol18NoOct-Spl_Exp_Kal_Fig2-150x150.jpg\" alt=\"\" width=\"150\" height=\"150\" srcset=\"https:\/\/biomedpharmajournal.org\/staging\/wp-content\/uploads\/2025\/10\/Vol18NoOct-Spl_Exp_Kal_Fig2-150x150.jpg 150w, https:\/\/biomedpharmajournal.org\/staging\/wp-content\/uploads\/2025\/10\/Vol18NoOct-Spl_Exp_Kal_Fig2-250x250.jpg 250w, https:\/\/biomedpharmajournal.org\/staging\/wp-content\/uploads\/2025\/10\/Vol18NoOct-Spl_Exp_Kal_Fig2-256x256.jpg 256w, https:\/\/biomedpharmajournal.org\/staging\/wp-content\/uploads\/2025\/10\/Vol18NoOct-Spl_Exp_Kal_Fig2.jpg 632w\" sizes=\"(max-width: 150px) 100vw, 150px\" \/><\/td>\n<td style=\"width: 72.8995%;\">\n<p><strong>Figure 2:\u00a0 Process Flow Diagram of the Proposed MRI Analysis AI System<\/strong><\/p>\n<p><a href=\"https:\/\/biomedpharmajournal.org\/wp-content\/uploads\/2025\/10\/Vol18NoOct-Spl_Exp_Kal_Fig2.jpg\" target=\"_blank\" rel=\"noopener\">Click here to view Figure<\/a><\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p><strong>Data Preprocessing<\/strong><\/p>\n<p>An end-to-end preprocessing pipeline was employed to provide uniform data to train and test the MRI scans, allowing the model to generalize more effectively. First, all the MRI images were normalized from RGB to grayscale to match the single-channel input layers of the modified convolutional neural networks (CNNs). The images were then resized to the size 224\u00d7224 pixels, the universal input size for deep learning models. To make it more robust, the dataset was exposed to different data augmentation methods, including random flip of the image horizontally, rotation of \u00b115\u00b0, affine transformations (with minor shifts and zoomed-in images), and random cropping of 80%\u2013100 % of the image space. Additionally, color jittering was done to simulate changes in brightness and contrast, even though the images were grayscale. After these augmentation steps, the images were converted to tensors and normalized with a mean of 0.5 and a standard deviation of 0.5 in order to stabilize training dynamics and accelerate convergence. Table 1 shows the order of preprocessing methodologies applied to brain MRI images, including grayscale conversion, resizing, augmentation, and normalization, along with their corresponding technical parameters to provide uniform input to the CNN ensemble model.<\/p>\n<p><strong>Table 1: MRI Image Preprocessing Pipeline and Technical Specifications<\/strong><\/p>\n<table style=\"width: 95%;\" border=\"1\" cellspacing=\"0\" cellpadding=\"4\">\n<tbody>\n<tr>\n<td style=\"text-align: center;\" width=\"240\">\n<p><strong>Step<\/strong><\/p>\n<\/td>\n<td style=\"text-align: center;\" width=\"240\">\n<p><strong>Purpose<\/strong><\/p>\n<\/td>\n<td style=\"text-align: center;\" width=\"240\">\n<p><strong>Technical Detail<\/strong><\/p>\n<\/td>\n<\/tr>\n<tr>\n<td style=\"text-align: center;\" width=\"240\">\n<p>Grayscale Conversion<\/p>\n<\/td>\n<td style=\"text-align: center;\" width=\"240\">\n<p>Convert RGB images to single-channel grayscale<\/p>\n<\/td>\n<td style=\"text-align: center;\" width=\"240\">\n<p>1 output channel (L-mode image)<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td style=\"text-align: center;\" width=\"240\">\n<p>Resizing<\/p>\n<\/td>\n<td style=\"text-align: center;\" width=\"240\">\n<p>Standardize input size to 224\u00d7224 pixels<\/p>\n<\/td>\n<td style=\"text-align: center;\" width=\"240\">\n<p>Resize to (224, 224)<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td style=\"text-align: center;\" width=\"240\">\n<p>Random Horizontal Flip<\/p>\n<\/td>\n<td style=\"text-align: center;\" width=\"240\">\n<p>Introduce left-right variability in training data<\/p>\n<\/td>\n<td style=\"text-align: center;\" width=\"240\">\n<p>Flip probability = 0.5<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td style=\"text-align: center;\" width=\"240\">\n<p>Random Rotation<\/p>\n<\/td>\n<td style=\"text-align: center;\" width=\"240\">\n<p>Add rotational invariance<\/p>\n<\/td>\n<td style=\"text-align: center;\" width=\"240\">\n<p>Max rotation = \u00b115\u00b0<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td style=\"text-align: center;\" width=\"240\">\n<p>Affine Transformation<\/p>\n<\/td>\n<td style=\"text-align: center;\" width=\"240\">\n<p>Simulate minor shifts and zooms<\/p>\n<\/td>\n<td style=\"text-align: center;\" width=\"240\">\n<p>Translate = \u00b110%, Scale = 90\u2013110%<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td style=\"text-align: center;\" width=\"240\">\n<p>Random Resized Crop<\/p>\n<\/td>\n<td style=\"text-align: center;\" width=\"240\">\n<p>Enhance generalization by random cropping<\/p>\n<\/td>\n<td style=\"text-align: center;\" width=\"240\">\n<p>Crop scale = 80%\u2013100% of image area<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td style=\"text-align: center;\" width=\"240\">\n<p>Color Jitter<\/p>\n<\/td>\n<td style=\"text-align: center;\" width=\"240\">\n<p>Improve robustness to brightness\/contrast changes<\/p>\n<\/td>\n<td style=\"text-align: center;\" width=\"240\">\n<p>Brightness &amp; contrast \u00b120%<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td style=\"text-align: center;\" width=\"240\">\n<p>Tensor Conversion<\/p>\n<\/td>\n<td style=\"text-align: center;\" width=\"240\">\n<p>Convert PIL image to PyTorch tensor format<\/p>\n<\/td>\n<td style=\"text-align: center;\" width=\"240\">\n<p>Image converted to float tensor<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td style=\"text-align: center;\" width=\"240\">\n<p>Normalization<\/p>\n<\/td>\n<td style=\"text-align: center;\" width=\"240\">\n<p>Scale pixel values to [-1, 1] for stable training<\/p>\n<\/td>\n<td style=\"text-align: center;\" width=\"240\">\n<p>Mean = 0.5, Std = 0.5<\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p><strong>Model Training<\/strong><\/p>\n<p>The training of the model is designed to efficiently process the classification of brain MRI images by utilizing a convolutional neural network (CNN) ensemble method. Initially, a custom MRIDataset class is created to support the loading of grayscale images and mapping integer labels for four tumor types: Glioma (0), Meningioma (1), No Tumor (2), and Pituitary Tumor (3). The CNN ensemble is comprised of four pre-trained models: DenseNet121, ResNet50, EfficientNet-B0, and MobileNetV3-Small. Each model is adapted to support single-channel input by altering their first convolutional layer.<\/p>\n<p>Model training uses the Adam optimizer along with a cyclic learning rate schedule to enhance convergence. A weighted CrossEntropyLoss function is applied to handle class imbalance. The dataset is divided into training and validation sets in an 80:20 ratio, ensuring balanced class representation through stratified sampling. Performance is assessed using accuracy, precision, recall, and F1-score, while early stopping with a patience of 5 epochs helps reduce the risk of overfitting. The model achieving either the highest validation accuracy or the lowest loss is saved for subsequent evaluation and testing. The complete technical breakdown of each training step is presented in the accompanying Table 2.<\/p>\n<p><strong>Table 2: MRI Model Training Process Technical Summary<\/strong><\/p>\n<table style=\"width: 95%;\" border=\"1\" cellspacing=\"0\" cellpadding=\"4\">\n<tbody>\n<tr>\n<td style=\"text-align: center;\" width=\"200\">\n<p><strong>Step<\/strong><\/p>\n<\/td>\n<td style=\"text-align: center;\" width=\"520\">\n<p><strong>Description<\/strong><\/p>\n<\/td>\n<\/tr>\n<tr>\n<td style=\"text-align: center;\" width=\"200\">\n<p>Dataset Loading<\/p>\n<\/td>\n<td style=\"text-align: center;\" width=\"520\">\n<p>Custom MRIDataset class loads grayscale images and assigns class labels: Glioma (0), Meningioma (1), No Tumor (2), Pituitary Tumor (3).<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td style=\"text-align: center;\" width=\"200\">\n<p>Model Ensemble<\/p>\n<\/td>\n<td style=\"text-align: center;\" width=\"520\">\n<p>Train DenseNet121, ResNet50, EfficientNet-B0, and MobileNetV3-Small with modified first layers for 1-channel inputs.<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td style=\"text-align: center;\" width=\"200\">\n<p>Optimization<\/p>\n<\/td>\n<td style=\"text-align: center;\" width=\"520\">\n<p>Uses Adam optimizer with CyclicLR scheduler and weighted CrossEntropyLoss to handle class imbalance.<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td style=\"text-align: center;\" width=\"200\">\n<p>Validation<\/p>\n<\/td>\n<td style=\"text-align: center;\" width=\"520\">\n<p>Splits dataset 80:20 for training and validation; evaluates using accuracy, precision, recall, and F1 score with early stopping (patience=5).<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td style=\"text-align: center;\" width=\"200\">\n<p>Best Model Selection<\/p>\n<\/td>\n<td style=\"text-align: center;\" width=\"520\">\n<p>Saves the model with either the highest validation accuracy or the lowest loss during training.<\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p><strong>Mathematical Modelling of Core Components<\/strong><\/p>\n<p>Although the present work emphasizes an applied framework for brain tumor classification and automated reporting, the mathematical underpinnings of the main components are outlined here to provide theoretical clarity.<\/p>\n<p>Each convolutional layer applies a set of filters to the input MRI image. The operation is expressed as:<\/p>\n<p><img decoding=\"async\" class=\"alignnone size-full wp-image-68464\" src=\"https:\/\/biomedpharmajournal.org\/wp-content\/uploads\/2025\/10\/Vol18NoOct-Spl_Exp_Kal_Eq1.jpg\" alt=\"\" width=\"457\" height=\"50\" srcset=\"https:\/\/biomedpharmajournal.org\/staging\/wp-content\/uploads\/2025\/10\/Vol18NoOct-Spl_Exp_Kal_Eq1-300x33.jpg 300w, https:\/\/biomedpharmajournal.org\/staging\/wp-content\/uploads\/2025\/10\/Vol18NoOct-Spl_Exp_Kal_Eq1.jpg 457w\" sizes=\"(max-width: 457px) 100vw, 457px\" \/><\/p>\n<p>Where <em>x<\/em> denotes the input image patch, <em>w<sup>(k)<\/sup><\/em>\u00a0is the kernel of the <em>k<sup>th<\/sup><\/em> filter, <em>b<sup>(k)<\/sup><\/em>is the bias term, and \u03c3(.) is the non-linear activation function (ReLU here).<\/p>\n<p>To optimize multi-class tumor classification, we employed a weighted cross-entropy loss:<\/p>\n<p><img decoding=\"async\" class=\"alignnone size-full wp-image-68465\" src=\"https:\/\/biomedpharmajournal.org\/wp-content\/uploads\/2025\/10\/Vol18NoOct-Spl_Exp_Kal_Eq2.jpg\" alt=\"\" width=\"340\" height=\"39\" srcset=\"https:\/\/biomedpharmajournal.org\/staging\/wp-content\/uploads\/2025\/10\/Vol18NoOct-Spl_Exp_Kal_Eq2-300x34.jpg 300w, https:\/\/biomedpharmajournal.org\/staging\/wp-content\/uploads\/2025\/10\/Vol18NoOct-Spl_Exp_Kal_Eq2.jpg 340w\" sizes=\"(max-width: 340px) 100vw, 340px\" \/><\/p>\n<p>where <em>C<\/em> is the total number of classes,<em> \u200by<sub>c<\/sub><\/em> is the ground-truth label, <em>y<sub>c<\/sub><\/em> is the predicted probability, and w<em><sub>c<\/sub><\/em>\u200b is the class-specific weight to mitigate class imbalance.<\/p>\n<p>The model parameters are updated iteratively using the Adam optimizer, defined as:<\/p>\n<p><img decoding=\"async\" class=\"alignnone size-full wp-image-68466\" src=\"https:\/\/biomedpharmajournal.org\/wp-content\/uploads\/2025\/10\/Vol18NoOct-Spl_Exp_Kal_Eq3.jpg\" alt=\"\" width=\"289\" height=\"50\" \/><\/p>\n<p>Where \u03b7 is the learning rate m<sub>t<\/sub>, \u00a0and u<sub>t<\/sub>\u00a0are the bias-corrected first and second moment estimates of the gradients, \u03f5 is a constant for numerical stability.<\/p>\n<p>Although a detailed description of explainability methods is provided later (Section 3.6), the formulation of Grad-CAM is briefly given here. For a target class \u2018c\u2019, the Grad-CAM heatmap is computed as:<\/p>\n<p><img decoding=\"async\" class=\"alignnone size-full wp-image-68468\" src=\"https:\/\/biomedpharmajournal.org\/wp-content\/uploads\/2025\/10\/Vol18NoOct-Spl_Exp_Kal_Eq4.jpg\" alt=\"\" width=\"394\" height=\"48\" srcset=\"https:\/\/biomedpharmajournal.org\/staging\/wp-content\/uploads\/2025\/10\/Vol18NoOct-Spl_Exp_Kal_Eq4-300x37.jpg 300w, https:\/\/biomedpharmajournal.org\/staging\/wp-content\/uploads\/2025\/10\/Vol18NoOct-Spl_Exp_Kal_Eq4.jpg 394w\" sizes=\"(max-width: 394px) 100vw, 394px\" \/><\/p>\n<p>where A<sup>k<\/sup> is the activation<sup>\u00a0<\/sup>map of the <em>k<sup>th<\/sup><\/em> feature channel, and \u200b\u03b1<sub>k<\/sub><sup>c<\/sup> is obtained by global average pooling of the gradients of the score for class ccc with respect to <em>A<sup>k<\/sup><\/em>.<\/p>\n<p>These formulations capture the mathematical intuition behind CNN-based feature learning, optimization during training, and the interpretability mechanism, complementing the practical implementation described in earlier sections.<\/p>\n<p><strong>Explainability Techniques<\/strong><\/p>\n<p>To improve the clarity and trustworthiness of classification outcomes, the system integrates four prominent explainability methods: Grad-CAM, SHAP, LIME, and Edge Detection. Grad-CAM (Gradient-weighted Class Activation Mapping) generates heatmaps specific to each class by utilizing gradients from the final convolutional layers, thereby pinpointing crucial regions in the image influencing the prediction. SHAP (SHapley Additive exPlanations) measures the impact of each input feature by calculating Shapley values, drawing on principles from cooperative game theory. LIME (Local Interpretable Model-agnostic Explanations) sheds light on individual predictions by creating a simplified, interpretable model that approximates the complex model\u2019s behavior in the vicinity of the specific instance. Finally, Canny Edge Detection is used to emphasize structural boundaries within the image, aiding in the visual interpretation of tumor margins and anatomical context. These techniques collectively provide visual and quantitative insights into how the deep learning models arrive at their decisions, thereby improving clinical trust and adoption. The summary of Explainable AI techniques is given in Table 3.<\/p>\n<p><strong>Table 3: Summary of Explainable AI Techniques Used for Model Interpretation<\/strong><\/p>\n<table style=\"width: 95%;\" border=\"1\" cellspacing=\"0\" cellpadding=\"4\">\n<tbody>\n<tr>\n<td style=\"text-align: center;\" width=\"153\">\n<p><strong>Technique<\/strong><\/p>\n<\/td>\n<td style=\"text-align: center;\" width=\"327\">\n<p><strong>Purpose<\/strong><\/p>\n<\/td>\n<td style=\"text-align: center;\" width=\"240\">\n<p><strong>Technical Detail<\/strong><\/p>\n<\/td>\n<\/tr>\n<tr>\n<td style=\"text-align: center;\" width=\"153\">\n<p>Grad-CAM<\/p>\n<\/td>\n<td style=\"text-align: center;\" width=\"327\">\n<p>Generates class-specific heatmaps to highlight the most influential regions in the input image based on gradients.<\/p>\n<\/td>\n<td style=\"text-align: center;\" width=\"240\">\n<p>Uses gradient-based localization from final convolutional layers.<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td style=\"text-align: center;\" width=\"153\">\n<p>SHAP<\/p>\n<\/td>\n<td style=\"text-align: center;\" width=\"327\">\n<p>Computes Shapley values to quantify the contribution of each input feature towards the model&#8217;s output.<\/p>\n<\/td>\n<td style=\"text-align: center;\" width=\"240\">\n<p>Applies Deep SHAP with backpropagation to estimate pixel importance.<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td style=\"text-align: center;\" width=\"153\">\n<p>LIME<\/p>\n<\/td>\n<td style=\"text-align: center;\" width=\"327\">\n<p>Provides local, interpretable explanations by perturbing input and training a surrogate model.<\/p>\n<\/td>\n<td style=\"text-align: center;\" width=\"240\">\n<p>Uses superpixels and perturbation sampling to train an interpretable linear model.<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td style=\"text-align: center;\" width=\"153\">\n<p>Edge Detection<\/p>\n<\/td>\n<td style=\"text-align: center;\" width=\"327\">\n<p>Enhances structural visualization by detecting prominent edges and boundaries in the image.<\/p>\n<\/td>\n<td style=\"text-align: center;\" width=\"240\">\n<p>Implements Canny edge detection with predefined thresholds (e.g., 100, 200).<\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p><strong>Large Language Model (LLM) Integration<\/strong><\/p>\n<p>The system utilizes a Large Language Model (LLM) via LangChain-Groq to bridge the gap between raw model predictions and clinical applications. This module is a medical report generator, converting classification outputs and explainability-related knowledge into understandable, human-readable text. Following the model prediction of the tumor type and the associated confidence score, visualizations are created using methods like Grad-CAM, SHAP, LIME, and Edge Detection. These are then conveyed to the LLM via a systematically structured prompt. LangChain is the orchestrator, managing prompt structuring, token passing, and response interpretation, while the Groq API enables high-speed, contextually aware generation of text. The generated text is a diagnostic summary, interpretative results, and medically suitable language pertaining to the context, making the application much more usable for radiologists and clinicians. Table 4 represents the technical details for LLM to generate the reports.<\/p>\n<p><strong>Table 4: Technical Overview of Large Language Model (LLM) Integration for Diagnostic Report Generation<\/strong><\/p>\n<table style=\"width: 95%;\" border=\"1\" cellspacing=\"0\" cellpadding=\"4\">\n<tbody>\n<tr>\n<td style=\"text-align: center;\" width=\"19%\">\n<p><strong>Component<\/strong><\/p>\n<\/td>\n<td style=\"text-align: center;\" width=\"32%\">\n<p><strong>Purpose<\/strong><\/p>\n<\/td>\n<td style=\"text-align: center;\" width=\"48%\">\n<p><strong>Technical Detail<\/strong><\/p>\n<\/td>\n<\/tr>\n<tr>\n<td style=\"text-align: center;\" width=\"19%\">\n<p>LangChain<\/p>\n<\/td>\n<td style=\"text-align: center;\" width=\"32%\">\n<p>Manages LLM prompt templates and execution flow<\/p>\n<\/td>\n<td style=\"text-align: center;\" width=\"48%\">\n<p>Uses ChatPromptTemplate from langchain_core to define structured prompts<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td style=\"text-align: center;\" width=\"19%\">\n<p>Groq LLM API<\/p>\n<\/td>\n<td style=\"text-align: center;\" width=\"32%\">\n<p>Generates coherent medical narratives based on inputs<\/p>\n<\/td>\n<td style=\"text-align: center;\" width=\"48%\">\n<p>Model used: mixtral-8x7b-32768 accessed via LangChain-Groq interface<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td style=\"text-align: center;\" width=\"19%\">\n<p>Input Data<\/p>\n<\/td>\n<td style=\"text-align: center;\" width=\"32%\">\n<p>Feeds prediction class, confidence score, and explanation types (Grad-CAM, SHAP, etc.)<\/p>\n<\/td>\n<td style=\"text-align: center;\" width=\"48%\">\n<p>Integrated via templated system + key-value formatting<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td style=\"text-align: center;\" width=\"19%\">\n<p>Output Report<\/p>\n<\/td>\n<td style=\"text-align: center;\" width=\"32%\">\n<p>Produces a structured, readable diagnostic summary for clinical users<\/p>\n<\/td>\n<td style=\"text-align: center;\" width=\"48%\">\n<p>Text formatted into PDF using FPDF for final presentation<\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p><strong>Visualization and Report Generation<\/strong><\/p>\n<p>After creating predictions and interpretability visualizations, the system integrates all relevant outputs into a comprehensive diagnostic report using the FPDF library. The report includes metadata like the date and time of generation and model details, the medical interpretation created by the LLM, and embedded explainability visualizations (e.g., Grad-CAM, SHAP, LIME, SNAP, and Edge Detection). Each visualization is succeeded by elaborate captions to ensure clinical readability. The design layout is intentionally minimalist to promote readability and printability, hence making it readily reviewable electronically and storable physically. The generated report is automatically saved as a PDF file (mri_report.pdf) that can be downloaded or stored to be retrieved later. This capability ensures that the insights generated by the AI are presented in an easily readable format that is well integrated into clinical processes.<\/p>\n<p><strong>Results<\/strong><\/p>\n<p><strong>Model Performance<\/strong><\/p>\n<p>The DenseNet121 model presented here is demonstrated to possess good diagnostic ability in classifying brain MRI images into four categories: Glioma, Meningioma, No Tumor, and Pituitary Tumor, tested after training for 12 epochs.<\/p>\n<p><strong>Evaluation Metrics and Diagnostic Performance of the DenseNet121 Model<\/strong><\/p>\n<p>As shown in Table 5 and Fig. 3, DenseNet121 achieves high scores across all primary evaluation metrics. The precision ranges from 0.9749 to 1.0000, while recall spans 0.9712 to 0.9943, reflecting the model\u2019s effectiveness in reducing errors from both false positive and false negative predictions. The resulting F1 scores, which balance precision and recall, are uniformly high, with a macro-average of 0.9850. These results indicate a well-generalized and balanced performance across all tumor classes.<strong>\u00a0<\/strong><\/p>\n<p><strong>Table 5: Classification Metrics (Precision, Recall, F1-Score) for DenseNet121 Across All Tumor Classes<\/strong><\/p>\n<table style=\"width: 95%;\" border=\"1\" cellspacing=\"0\" cellpadding=\"4\">\n<tbody>\n<tr>\n<td style=\"text-align: center;\" width=\"141\">\n<p><strong>Class<\/strong><\/p>\n<\/td>\n<td style=\"text-align: center;\" width=\"90\">\n<p><strong>Precision<\/strong><\/p>\n<\/td>\n<td style=\"text-align: center;\" width=\"80\">\n<p><strong>Recall<\/strong><\/p>\n<\/td>\n<td style=\"text-align: center;\" width=\"95\">\n<p><strong>F1 Score<\/strong><\/p>\n<\/td>\n<td style=\"text-align: center;\" width=\"82\">\n<p><strong>Support<\/strong><\/p>\n<\/td>\n<\/tr>\n<tr>\n<td style=\"text-align: center;\" width=\"141\">\n<p>Glioma<\/p>\n<\/td>\n<td style=\"text-align: center;\" width=\"90\">\n<p>0.976<\/p>\n<\/td>\n<td style=\"text-align: center;\" width=\"80\">\n<p>0.985<\/p>\n<\/td>\n<td style=\"text-align: center;\" width=\"95\">\n<p>0.9805<\/p>\n<\/td>\n<td style=\"text-align: center;\" width=\"82\">\n<p>334<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td style=\"text-align: center;\" width=\"141\">\n<p>Meningioma<\/p>\n<\/td>\n<td style=\"text-align: center;\" width=\"90\">\n<p>0.987<\/p>\n<\/td>\n<td style=\"text-align: center;\" width=\"80\">\n<p>0.9712<\/p>\n<\/td>\n<td style=\"text-align: center;\" width=\"95\">\n<p>0.979<\/p>\n<\/td>\n<td style=\"text-align: center;\" width=\"82\">\n<p>382<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td style=\"text-align: center;\" width=\"141\">\n<p>No Tumor<\/p>\n<\/td>\n<td style=\"text-align: center;\" width=\"90\">\n<p>1<\/p>\n<\/td>\n<td style=\"text-align: center;\" width=\"80\">\n<p>0.9851<\/p>\n<\/td>\n<td style=\"text-align: center;\" width=\"95\">\n<p>0.9925<\/p>\n<\/td>\n<td style=\"text-align: center;\" width=\"82\">\n<p>402<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td style=\"text-align: center;\" width=\"141\">\n<p>Pituitary Tumor<\/p>\n<\/td>\n<td style=\"text-align: center;\" width=\"90\">\n<p>0.9749<\/p>\n<\/td>\n<td style=\"text-align: center;\" width=\"80\">\n<p>0.9943<\/p>\n<\/td>\n<td style=\"text-align: center;\" width=\"95\">\n<p>0.9846<\/p>\n<\/td>\n<td style=\"text-align: center;\" width=\"82\">\n<p>352<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td style=\"text-align: center;\" width=\"141\">\n<p>Macro Average<\/p>\n<\/td>\n<td style=\"text-align: center;\" width=\"90\">\n<p>0.9851<\/p>\n<\/td>\n<td style=\"text-align: center;\" width=\"80\">\n<p>0.985<\/p>\n<\/td>\n<td style=\"text-align: center;\" width=\"95\">\n<p>0.985<\/p>\n<\/td>\n<td style=\"text-align: center;\" width=\"82\">\n<p>1470<\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<table style=\"width: 70%; border-collapse: collapse;\" border=\"1\" cellpadding=\"5\">\n<tbody>\n<tr>\n<td style=\"width: 27.1005%;\"><img decoding=\"async\" class=\"alignnone size-thumbnail wp-image-68442\" src=\"https:\/\/biomedpharmajournal.org\/wp-content\/uploads\/2025\/10\/Vol18NoOct-Spl_Exp_Kal_Fig3-150x150.jpg\" alt=\"\" width=\"150\" height=\"150\" srcset=\"https:\/\/biomedpharmajournal.org\/staging\/wp-content\/uploads\/2025\/10\/Vol18NoOct-Spl_Exp_Kal_Fig3-150x150.jpg 150w, https:\/\/biomedpharmajournal.org\/staging\/wp-content\/uploads\/2025\/10\/Vol18NoOct-Spl_Exp_Kal_Fig3-250x250.jpg 250w, https:\/\/biomedpharmajournal.org\/staging\/wp-content\/uploads\/2025\/10\/Vol18NoOct-Spl_Exp_Kal_Fig3-256x256.jpg 256w, https:\/\/biomedpharmajournal.org\/staging\/wp-content\/uploads\/2025\/10\/Vol18NoOct-Spl_Exp_Kal_Fig3.jpg 703w\" sizes=\"(max-width: 150px) 100vw, 150px\" \/><\/td>\n<td style=\"width: 72.8995%;\">\n<p><strong>Figure 3: Precision, Recall, and F1-Score for Each Tumor Category Using DenseNet121<\/strong><\/p>\n<p><a href=\"https:\/\/biomedpharmajournal.org\/wp-content\/uploads\/2025\/10\/Vol18NoOct-Spl_Exp_Kal_Fig3.jpg\" target=\"_blank\" rel=\"noopener\">Click here to view Figure<\/a><\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p><strong>Confusion Matrix<\/strong><\/p>\n<p>Fig. 4 illustrates the confusion matrix for the DenseNet121 model, demonstrating strong class-wise prediction performance with clear diagonal dominance, where the majority of samples are correctly classified into their respective tumor categories. The matrix reflects minimal off-diagonal values, indicating very few misclassifications across classes. Notably, the model demonstrates strong reliability in differentiating tumors that appear visually alike, including distinguishing between Glioma and Meningioma and separating Pituitary Tumors from cases with no tumor. The balanced distribution of correct predictions across all four categories confirms the model\u2019s robustness and generalization capability, supporting its suitability for clinical deployment.<\/p>\n<table style=\"width: 70%; border-collapse: collapse;\" border=\"1\" cellpadding=\"5\">\n<tbody>\n<tr>\n<td style=\"width: 27.1005%;\"><img decoding=\"async\" class=\"alignnone size-thumbnail wp-image-68443\" src=\"https:\/\/biomedpharmajournal.org\/wp-content\/uploads\/2025\/10\/Vol18NoOct-Spl_Exp_Kal_Fig4-150x150.jpg\" alt=\"\" width=\"150\" height=\"150\" srcset=\"https:\/\/biomedpharmajournal.org\/staging\/wp-content\/uploads\/2025\/10\/Vol18NoOct-Spl_Exp_Kal_Fig4-150x150.jpg 150w, https:\/\/biomedpharmajournal.org\/staging\/wp-content\/uploads\/2025\/10\/Vol18NoOct-Spl_Exp_Kal_Fig4-250x250.jpg 250w, https:\/\/biomedpharmajournal.org\/staging\/wp-content\/uploads\/2025\/10\/Vol18NoOct-Spl_Exp_Kal_Fig4-256x256.jpg 256w, https:\/\/biomedpharmajournal.org\/staging\/wp-content\/uploads\/2025\/10\/Vol18NoOct-Spl_Exp_Kal_Fig4.jpg 646w\" sizes=\"(max-width: 150px) 100vw, 150px\" \/><\/td>\n<td style=\"width: 72.8995%;\">\n<p><strong>Figure 4: Confusion Matrix Showing Class-Wise Prediction Accuracy for DenseNet121<\/strong><\/p>\n<p><a href=\"https:\/\/biomedpharmajournal.org\/wp-content\/uploads\/2025\/10\/Vol18NoOct-Spl_Exp_Kal_Fig4.jpg\" target=\"_blank\" rel=\"noopener\">Click here to view Figure<\/a><\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p><strong>Accuracy Trend<\/strong><\/p>\n<p>Fig. 5 is the training accuracy curve for the DenseNet121 model with a steady rising trend and minimal oscillation. The accuracy shows a consistent rise along the training epochs and eventually levels off at a high value, which indicates successful learning and convergence. The gradual nature of the curve suggests that the model learns well with no signs of overfitting and instability. This steady trend of performance confirms that the selected architecture, training approach, and preprocessing of data methods improve a stable and robust classification model suitable for real diagnostic use.<\/p>\n<table style=\"width: 70%; border-collapse: collapse;\" border=\"1\" cellpadding=\"5\">\n<tbody>\n<tr>\n<td style=\"width: 27.1005%;\"><img decoding=\"async\" class=\"alignnone size-thumbnail wp-image-68444\" src=\"https:\/\/biomedpharmajournal.org\/wp-content\/uploads\/2025\/10\/Vol18NoOct-Spl_Exp_Kal_Fig5-150x150.jpg\" alt=\"\" width=\"150\" height=\"150\" srcset=\"https:\/\/biomedpharmajournal.org\/staging\/wp-content\/uploads\/2025\/10\/Vol18NoOct-Spl_Exp_Kal_Fig5-150x150.jpg 150w, https:\/\/biomedpharmajournal.org\/staging\/wp-content\/uploads\/2025\/10\/Vol18NoOct-Spl_Exp_Kal_Fig5-250x250.jpg 250w, https:\/\/biomedpharmajournal.org\/staging\/wp-content\/uploads\/2025\/10\/Vol18NoOct-Spl_Exp_Kal_Fig5-256x256.jpg 256w, https:\/\/biomedpharmajournal.org\/staging\/wp-content\/uploads\/2025\/10\/Vol18NoOct-Spl_Exp_Kal_Fig5.jpg 657w\" sizes=\"(max-width: 150px) 100vw, 150px\" \/><\/td>\n<td style=\"width: 72.8995%;\">\n<p><strong>Figure 5: Training Accuracy Curve Indicating Model Stability and Convergence<\/strong><\/p>\n<p><a href=\"https:\/\/biomedpharmajournal.org\/wp-content\/uploads\/2025\/10\/Vol18NoOct-Spl_Exp_Kal_Fig5.jpg\" target=\"_blank\" rel=\"noopener\">Click here to view Figure<\/a><\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p><strong>ROC Curve Analysis<\/strong><\/p>\n<p>Fig. 6 demonstrates Receiver Operating Characteristic (ROC) curves of the DenseNet121 model, which indicate excellent discriminative ability for all tumor categories. The curves slope towards the top-left, indicating a high true positive rate with a low false positive rate. The Area Under the Curve (AUC) for all categories is nearly perfect, which supports the high discriminative ability of the model between different types of tumors. This high separability also suggests the robustness of the model in clinical classification tasks; hence, its application in diagnostic decision-making is recommended.<\/p>\n<table style=\"width: 70%; border-collapse: collapse;\" border=\"1\" cellpadding=\"5\">\n<tbody>\n<tr>\n<td style=\"width: 27.1005%;\"><img decoding=\"async\" class=\"alignnone size-thumbnail wp-image-68445\" src=\"https:\/\/biomedpharmajournal.org\/wp-content\/uploads\/2025\/10\/Vol18NoOct-Spl_Exp_Kal_Fig6-150x150.jpg\" alt=\"\" width=\"150\" height=\"150\" srcset=\"https:\/\/biomedpharmajournal.org\/staging\/wp-content\/uploads\/2025\/10\/Vol18NoOct-Spl_Exp_Kal_Fig6-150x150.jpg 150w, https:\/\/biomedpharmajournal.org\/staging\/wp-content\/uploads\/2025\/10\/Vol18NoOct-Spl_Exp_Kal_Fig6-250x250.jpg 250w, https:\/\/biomedpharmajournal.org\/staging\/wp-content\/uploads\/2025\/10\/Vol18NoOct-Spl_Exp_Kal_Fig6-256x256.jpg 256w, https:\/\/biomedpharmajournal.org\/staging\/wp-content\/uploads\/2025\/10\/Vol18NoOct-Spl_Exp_Kal_Fig6.jpg 735w\" sizes=\"(max-width: 150px) 100vw, 150px\" \/><\/td>\n<td style=\"width: 72.8995%;\">\n<p><strong>Figure 6: ROC Curves with AUC Scores for Four Tumor Categories Predicted by DenseNet121<\/strong><\/p>\n<p><a href=\"https:\/\/biomedpharmajournal.org\/wp-content\/uploads\/2025\/10\/Vol18NoOct-Spl_Exp_Kal_Fig6.jpg\" target=\"_blank\" rel=\"noopener\">Click here to view Figure<\/a><\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p><strong>Explainability Analysis<\/strong><\/p>\n<p>To ensure interpretability and strengthen clinician confidence in AI-based decisions, the system incorporates a suite of Explainable AI (XAI) techniques that offer both visual and analytical insights. Fig. 7 presents the original MRI input image containing a contrast-enhanced tumor region used as a test case. This image serves as the baseline for generating multiple interpretability outputs through Grad-CAM, LIME, SHAP, and Edge Detection methods. Upon uploading the image to the deployed application (https:\/\/mrianalysis.streamlit.app\/), the system executes each XAI technique to highlight decision-critical regions, allowing clinicians to visually verify and interpret the model\u2019s predictions. This multimodal approach to explainability ensures transparency, provides deeper insights into model behavior, and facilitates trust in automated clinical decisions.<\/p>\n<table style=\"width: 70%; border-collapse: collapse;\" border=\"1\" cellpadding=\"5\">\n<tbody>\n<tr>\n<td style=\"width: 27.1005%;\"><img decoding=\"async\" class=\"alignnone size-thumbnail wp-image-68446\" src=\"https:\/\/biomedpharmajournal.org\/wp-content\/uploads\/2025\/10\/Vol18NoOct-Spl_Exp_Kal_Fig7-150x150.jpg\" alt=\"\" width=\"150\" height=\"150\" srcset=\"https:\/\/biomedpharmajournal.org\/staging\/wp-content\/uploads\/2025\/10\/Vol18NoOct-Spl_Exp_Kal_Fig7-150x150.jpg 150w, https:\/\/biomedpharmajournal.org\/staging\/wp-content\/uploads\/2025\/10\/Vol18NoOct-Spl_Exp_Kal_Fig7-250x250.jpg 250w, https:\/\/biomedpharmajournal.org\/staging\/wp-content\/uploads\/2025\/10\/Vol18NoOct-Spl_Exp_Kal_Fig7-256x256.jpg 256w, https:\/\/biomedpharmajournal.org\/staging\/wp-content\/uploads\/2025\/10\/Vol18NoOct-Spl_Exp_Kal_Fig7.jpg 744w\" sizes=\"(max-width: 150px) 100vw, 150px\" \/><\/td>\n<td style=\"width: 72.8995%;\">\n<p><strong>Figure 7: Input Brain MRI Image Used for Generating Explainability Visualizations<\/strong><\/p>\n<p><a href=\"https:\/\/biomedpharmajournal.org\/wp-content\/uploads\/2025\/10\/Vol18NoOct-Spl_Exp_Kal_Fig7.jpg\" target=\"_blank\" rel=\"noopener\">Click here to view Figure<\/a><\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p><strong>Grad-CAM Visualization<\/strong><\/p>\n<p>Fig. 8 displays the Grad-CAM output for the input MRI image. This technique generates a heatmap covering the original scan to highlight sections that strongly impact the model&#8217;s prediction. In this case, red and yellow zones are prominently focused on the tumor region, signifying that the DenseNet121 model correctly attends to critical abnormal areas during classification. The visualization confirms that the model\u2019s attention aligns with radiologically relevant features, thereby validating its diagnostic focus and supporting clinical decision-making.<\/p>\n<table style=\"width: 70%; border-collapse: collapse;\" border=\"1\" cellpadding=\"5\">\n<tbody>\n<tr>\n<td style=\"width: 27.1005%;\"><img decoding=\"async\" class=\"alignnone size-thumbnail wp-image-68447\" src=\"https:\/\/biomedpharmajournal.org\/wp-content\/uploads\/2025\/10\/Vol18NoOct-Spl_Exp_Kal_Fig8-150x150.jpg\" alt=\"\" width=\"150\" height=\"150\" srcset=\"https:\/\/biomedpharmajournal.org\/staging\/wp-content\/uploads\/2025\/10\/Vol18NoOct-Spl_Exp_Kal_Fig8-150x150.jpg 150w, https:\/\/biomedpharmajournal.org\/staging\/wp-content\/uploads\/2025\/10\/Vol18NoOct-Spl_Exp_Kal_Fig8-250x250.jpg 250w, https:\/\/biomedpharmajournal.org\/staging\/wp-content\/uploads\/2025\/10\/Vol18NoOct-Spl_Exp_Kal_Fig8-256x256.jpg 256w, https:\/\/biomedpharmajournal.org\/staging\/wp-content\/uploads\/2025\/10\/Vol18NoOct-Spl_Exp_Kal_Fig8.jpg 690w\" sizes=\"(max-width: 150px) 100vw, 150px\" \/><\/td>\n<td style=\"width: 72.8995%;\">\n<p><strong>Figure 8: Grad-CAM Heatmap Highlighting Tumor-Influenced Regions Used for Classification<\/strong><\/p>\n<p><a href=\"https:\/\/biomedpharmajournal.org\/wp-content\/uploads\/2025\/10\/Vol18NoOct-Spl_Exp_Kal_Fig8.jpg\" target=\"_blank\" rel=\"noopener\">Click here to view Figure<\/a><\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p><strong>LIME Interpretation<\/strong><\/p>\n<p>Fig. 9 is the output generated by Local Interpretable Model-agnostic Explanations (LIME) for the same MRI image. The LIME method works by decomposing the image into superpixels and altering them to check their impact on the model&#8217;s performance regarding its prediction. The highlighted regions in the figure indicate the superpixels that positively contributed to the prediction of the tumor class. These local interpretations offer a comprehensive view of which precise parts of the image had the most impact, thus offering radiologists a clear, human-readable explanation of the model&#8217;s decision.<\/p>\n<table style=\"width: 70%; border-collapse: collapse;\" border=\"1\" cellpadding=\"5\">\n<tbody>\n<tr>\n<td style=\"width: 27.1005%;\"><img decoding=\"async\" class=\"alignnone size-thumbnail wp-image-68448\" src=\"https:\/\/biomedpharmajournal.org\/wp-content\/uploads\/2025\/10\/Vol18NoOct-Spl_Exp_Kal_Fig9-150x150.jpg\" alt=\"\" width=\"150\" height=\"150\" srcset=\"https:\/\/biomedpharmajournal.org\/staging\/wp-content\/uploads\/2025\/10\/Vol18NoOct-Spl_Exp_Kal_Fig9-150x150.jpg 150w, https:\/\/biomedpharmajournal.org\/staging\/wp-content\/uploads\/2025\/10\/Vol18NoOct-Spl_Exp_Kal_Fig9-250x250.jpg 250w, https:\/\/biomedpharmajournal.org\/staging\/wp-content\/uploads\/2025\/10\/Vol18NoOct-Spl_Exp_Kal_Fig9-256x256.jpg 256w, https:\/\/biomedpharmajournal.org\/staging\/wp-content\/uploads\/2025\/10\/Vol18NoOct-Spl_Exp_Kal_Fig9.jpg 684w\" sizes=\"(max-width: 150px) 100vw, 150px\" \/><\/td>\n<td style=\"width: 72.8995%;\">\n<p><strong>Figure 9: LIME-Based Superpixel Visualization Indicating Regions Positively Influencing the Tumor Prediction<\/strong><\/p>\n<p><a href=\"https:\/\/biomedpharmajournal.org\/wp-content\/uploads\/2025\/10\/Vol18NoOct-Spl_Exp_Kal_Fig9.jpg\" target=\"_blank\" rel=\"noopener\">Click here to view Figure<\/a><\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p><strong>Edge Detection<\/strong><\/p>\n<p>Fig. 10 illustrates the outcomes using the Canny Edge Detection algorithm applied to the MRI image. This approach highlights the scan&#8217;s structural delineations, particularly the tumor&#8217;s peripheries. Separating meaningful edges allows for the tumor&#8217;s morphology and spatial measurements information that is critical for preoperative planning and diagnostic evaluation. This enhancement serves as a secondary interpretative layer, providing a more delineated anatomical skeleton in addition to those predictions generated using artificial intelligence.<\/p>\n<table style=\"width: 70%; border-collapse: collapse;\" border=\"1\" cellpadding=\"5\">\n<tbody>\n<tr>\n<td style=\"width: 27.1005%;\"><img decoding=\"async\" class=\"alignnone size-thumbnail wp-image-68449\" src=\"https:\/\/biomedpharmajournal.org\/wp-content\/uploads\/2025\/10\/Vol18NoOct-Spl_Exp_Kal_Fig10-150x150.jpg\" alt=\"\" width=\"150\" height=\"150\" srcset=\"https:\/\/biomedpharmajournal.org\/staging\/wp-content\/uploads\/2025\/10\/Vol18NoOct-Spl_Exp_Kal_Fig10-150x150.jpg 150w, https:\/\/biomedpharmajournal.org\/staging\/wp-content\/uploads\/2025\/10\/Vol18NoOct-Spl_Exp_Kal_Fig10-250x250.jpg 250w, https:\/\/biomedpharmajournal.org\/staging\/wp-content\/uploads\/2025\/10\/Vol18NoOct-Spl_Exp_Kal_Fig10-256x256.jpg 256w, https:\/\/biomedpharmajournal.org\/staging\/wp-content\/uploads\/2025\/10\/Vol18NoOct-Spl_Exp_Kal_Fig10.jpg 643w\" sizes=\"(max-width: 150px) 100vw, 150px\" \/><\/td>\n<td style=\"width: 72.8995%;\">\n<p><strong>Figure 10: Canny Edge Detection Output Emphasizing Tumor Boundaries and Anatomical Structures<\/strong><\/p>\n<p><a href=\"https:\/\/biomedpharmajournal.org\/wp-content\/uploads\/2025\/10\/Vol18NoOct-Spl_Exp_Kal_Fig10.jpg\" target=\"_blank\" rel=\"noopener\">Click here to view Figure<\/a><\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p><strong>SHAP Explanations<\/strong><\/p>\n<p>Fig. 11 shows the SHAP visualization that assesses the contribution of a particular pixel region to the model&#8217;s prediction outcome. SHAP assigns positive (red) and negative (blue) values to the areas based on their contribution to the prediction, and it is a class-specific feature importance explanation. In this case, the highlighted regions in the Meningioma class are the most significant regions that impact the final decision. The pixel-level transparency enables clinicians to see not just the predictions of the model but also why the predictions were made, thus building trust and facilitating clinical validation.<\/p>\n<table style=\"width: 70%; border-collapse: collapse;\" border=\"1\" cellpadding=\"5\">\n<tbody>\n<tr>\n<td style=\"width: 27.1005%;\"><img decoding=\"async\" class=\"alignnone size-thumbnail wp-image-68451\" src=\"https:\/\/biomedpharmajournal.org\/wp-content\/uploads\/2025\/10\/Vol18NoOct-Spl_Exp_Kal_Fig11-150x150.jpg\" alt=\"\" width=\"150\" height=\"150\" srcset=\"https:\/\/biomedpharmajournal.org\/staging\/wp-content\/uploads\/2025\/10\/Vol18NoOct-Spl_Exp_Kal_Fig11-150x150.jpg 150w, https:\/\/biomedpharmajournal.org\/staging\/wp-content\/uploads\/2025\/10\/Vol18NoOct-Spl_Exp_Kal_Fig11-250x250.jpg 250w, https:\/\/biomedpharmajournal.org\/staging\/wp-content\/uploads\/2025\/10\/Vol18NoOct-Spl_Exp_Kal_Fig11-256x256.jpg 256w, https:\/\/biomedpharmajournal.org\/staging\/wp-content\/uploads\/2025\/10\/Vol18NoOct-Spl_Exp_Kal_Fig11.jpg 845w\" sizes=\"(max-width: 150px) 100vw, 150px\" \/><\/td>\n<td style=\"width: 72.8995%;\">\n<p><strong>Figure 11: SHAP Visualization Showing Pixel-Level Contributions for Class-Specific Model Predictions<\/strong><\/p>\n<p><a href=\"https:\/\/biomedpharmajournal.org\/wp-content\/uploads\/2025\/10\/Vol18NoOct-Spl_Exp_Kal_Fig11.jpg\" target=\"_blank\" rel=\"noopener\">Click here to view Figure<\/a><\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>These methods combined form an end-to-end interpretability system, localizing tumor areas, measuring feature importance, and allowing clinical inspection of AI-driven decisions. This interpretability pipeline increases model transparency and simplifies clinical integration for real-world deployment.<\/p>\n<p><strong>Prediction and Report Generation<\/strong><\/p>\n<p>Once the training and validation stages were completed, the best-performing model, DenseNet121, was utilized for real-time inference. Fig. 12 presents a test case where an input MRI image was analyzed on June 08, 2025, at 10:58 AM IST. The model predicted the presence of Meningioma with a high confidence score of 0.9986, demonstrating its robust and reliable performance under practical conditions.<\/p>\n<table style=\"width: 70%; border-collapse: collapse;\" border=\"1\" cellpadding=\"5\">\n<tbody>\n<tr>\n<td style=\"width: 27.1005%;\"><img decoding=\"async\" class=\"alignnone size-thumbnail wp-image-68452\" src=\"https:\/\/biomedpharmajournal.org\/wp-content\/uploads\/2025\/10\/Vol18NoOct-Spl_Exp_Kal_Fig12-150x150.jpg\" alt=\"\" width=\"150\" height=\"150\" srcset=\"https:\/\/biomedpharmajournal.org\/staging\/wp-content\/uploads\/2025\/10\/Vol18NoOct-Spl_Exp_Kal_Fig12-150x150.jpg 150w, https:\/\/biomedpharmajournal.org\/staging\/wp-content\/uploads\/2025\/10\/Vol18NoOct-Spl_Exp_Kal_Fig12-250x250.jpg 250w, https:\/\/biomedpharmajournal.org\/staging\/wp-content\/uploads\/2025\/10\/Vol18NoOct-Spl_Exp_Kal_Fig12-256x256.jpg 256w, https:\/\/biomedpharmajournal.org\/staging\/wp-content\/uploads\/2025\/10\/Vol18NoOct-Spl_Exp_Kal_Fig12.jpg 619w\" sizes=\"(max-width: 150px) 100vw, 150px\" \/><\/td>\n<td style=\"width: 72.8995%;\">\n<p><strong>Figure 12: Sample Output of the MRI Classifier Indicating Meningioma with 0.9986 Confidence Score<\/strong><\/p>\n<p><a href=\"https:\/\/biomedpharmajournal.org\/wp-content\/uploads\/2025\/10\/Vol18NoOct-Spl_Exp_Kal_Fig12.jpg\" target=\"_blank\" rel=\"noopener\">Click here to view Figure<\/a><\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>Following the prediction, the system automatically triggers the diagnostic reporting pipeline. As shown in Fig. 13, the LangChain-Groq-powered LLM generates a structured, human-readable report that synthesizes the model\u2019s output and explainability visualizations. This report includes clinical insights such as tumor type, probable location, size characteristics, and MRI signal intensity features mirroring standard radiology reporting formats. The result is formatted as a downloadable PDF, providing an interpretable and clinician-friendly summary suitable for documentation or second opinions.<\/p>\n<p>The report is divided into clinically relevant sections such as Primary Findings, Recommendations, and Clinical Notes, and is formatted as a downloadable PDF using the FPDF library.<\/p>\n<table style=\"width: 70%; border-collapse: collapse;\" border=\"1\" cellpadding=\"5\">\n<tbody>\n<tr>\n<td style=\"width: 27.1005%;\"><img decoding=\"async\" class=\"alignnone size-thumbnail wp-image-68453\" src=\"https:\/\/biomedpharmajournal.org\/wp-content\/uploads\/2025\/10\/Vol18NoOct-Spl_Exp_Kal_Fig13-150x150.jpg\" alt=\"\" width=\"150\" height=\"150\" srcset=\"https:\/\/biomedpharmajournal.org\/staging\/wp-content\/uploads\/2025\/10\/Vol18NoOct-Spl_Exp_Kal_Fig13-150x150.jpg 150w, https:\/\/biomedpharmajournal.org\/staging\/wp-content\/uploads\/2025\/10\/Vol18NoOct-Spl_Exp_Kal_Fig13.jpg 720w\" sizes=\"(max-width: 150px) 100vw, 150px\" \/><\/td>\n<td style=\"width: 72.8995%;\">\n<p><strong>Figure 13: AI-Generated Diagnostic Report Summarizing Prediction, Tumor Characteristics, and Clinical Insights<\/strong><\/p>\n<p><a href=\"https:\/\/biomedpharmajournal.org\/wp-content\/uploads\/2025\/10\/Vol18NoOct-Spl_Exp_Kal_Fig13.jpg\" target=\"_blank\" rel=\"noopener\">Click here to view Figure<\/a><\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p><strong>Discussion<\/strong><\/p>\n<p>This section presents a detailed interpretation of the experimental outcomes by aligning the observed performance with clinical expectations, evaluating model robustness, and considering the relevance of interpretability features for medical applications.<\/p>\n<p><strong>Interpretation of Classification Results<\/strong><\/p>\n<p>The high values observed in precision, recall, and macro-averaged F1-score reflect the model\u2019s effectiveness in accurately identifying brain tumor types while minimizing both false positives and false negatives. This balance is crucial in clinical diagnostics, where misclassification may lead to delayed or inappropriate treatment. The macro-F1 score close to 0.99 confirms that the classifier maintains consistent accuracy across all tumor categories, including those that often present subtle visual differences on MRI scans.<\/p>\n<p>DenseNet121 demonstrated reliable learning behavior with smooth convergence during training, marked by steadily increasing accuracy and minimal performance fluctuation across epochs. The model\u2019s ability to generalize well on unseen data without overfitting can be attributed to both architectural efficiency and a robust training pipeline, including augmentation and balanced stratified sampling. These characteristics suggest that DenseNet121 is well-suited for real-world deployment in clinical environments, offering stable and trustworthy outputs.<\/p>\n<p><strong>Clinical Relevance of Explainability<\/strong><\/p>\n<p>For AI-driven diagnostics to be adopted in routine healthcare practice, clinicians must be able to understand and trust the system\u2019s decisions. This work addresses this challenge through the incorporation of multiple explainable AI (XAI) methods. Grad-CAM provides class-specific heatmaps that visually highlight the regions contributing most to the prediction, helping clinicians confirm if the model\u2019s focus aligns with known tumor structures. SHAP offers numerical insights by quantifying the importance of individual pixels or regions, revealing how each feature influences the model&#8217;s output.<\/p>\n<p>LIME contributes by generating interpretable local approximations around each prediction, offering additional clarity into which superpixels led to a given classification. Meanwhile, edge detection supports anatomical interpretation by emphasizing tumor boundaries and spatial relationships. These visual and analytical tools work collectively to demystify the model\u2019s internal reasoning, making the decision process transparent and fostering confidence among radiologists. This transparency is essential for integrating AI tools into diagnostic routines and ensuring they augment, rather than obscure, clinical judgment.<\/p>\n<p><strong>Comparative Analysis<\/strong><\/p>\n<p>The performance comparison, as demonstrated in Table 6, shows the effectiveness and uniqueness of the proposed brain tumor classification model over several prior works. Umarani et al. [10] used U-Net, VGG-16, and AlexNet on the BraTS dataset with ~94% accuracy, focusing more on segmentation than classification. Abdusalomov et al. [12] achieved ~93% accuracy using CNNs but lacked interpretability, while Sadeghi et al. [13] incorporated LIME with hybrid CNNs, improving explainability but only reaching ~91% accuracy on a limited dataset. Xiao et al. [14] used SegNet with Grad-CAM for visual interpretation without reporting classification accuracy. Other high-performing models like EfficientNet and ConvNeXT [23\u201325] achieved 96\u201397% accuracy but were applied to non-MRI datasets (retinal, skin, blood), limiting their relevance for brain imaging. In contrast, this work combines DenseNet121 with an ensemble approach and integrates Grad-CAM, LIME, SHAP, and edge detection, achieving 97.8% accuracy and a macro F1-score of 0.985 on a diverse dataset (Figshare, SARTAJ, Br35H), while also offering automated report generation through LLMs, demonstrating superior accuracy, interpretability, and clinical utility.<\/p>\n<p><strong>Table 6: Comparative Performance of Brain Tumor Classification Models Across Different Datasets and Architectures<\/strong><\/p>\n<table style=\"width: 95%;\" border=\"1\" cellspacing=\"0\" cellpadding=\"4\">\n<tbody>\n<tr>\n<td style=\"text-align: center;\" width=\"9%\">\n<p><strong>Ref. No.<\/strong><\/p>\n<\/td>\n<td style=\"text-align: center;\" width=\"23%\">\n<p><strong>Model(s) Used<\/strong><\/p>\n<\/td>\n<td style=\"text-align: center;\" width=\"18%\">\n<p><strong>Dataset(s) Used<\/strong><\/p>\n<\/td>\n<td style=\"text-align: center;\" width=\"18%\">\n<p><strong>Accuracy \/ F1-Score<\/strong><\/p>\n<\/td>\n<td style=\"text-align: center;\" width=\"30%\">\n<p><strong>Remarks<\/strong><\/p>\n<\/td>\n<\/tr>\n<tr>\n<td style=\"text-align: center;\" width=\"9%\">\n[10]\n<\/td>\n<td style=\"text-align: center;\" width=\"23%\">\n<p>U-Net, VGG-16, AlexNet<\/p>\n<\/td>\n<td style=\"text-align: center;\" width=\"18%\">\n<p>BraTS<\/p>\n<\/td>\n<td style=\"text-align: center;\" width=\"18%\">\n<p>~94% Accuracy<\/p>\n<\/td>\n<td style=\"text-align: center;\" width=\"30%\">\n<p>Focused on segmentation, not classification<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td style=\"text-align: center;\" width=\"9%\">\n[12]\n<\/td>\n<td style=\"text-align: center;\" width=\"23%\">\n<p>CNN<\/p>\n<\/td>\n<td style=\"text-align: center;\" width=\"18%\">\n<p>Custom MRI dataset<\/p>\n<\/td>\n<td style=\"text-align: center;\" width=\"18%\">\n<p>~93% Accuracy<\/p>\n<\/td>\n<td style=\"text-align: center;\" width=\"30%\">\n<p>Lacks interpretability<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td style=\"text-align: center;\" width=\"9%\">\n[13]\n<\/td>\n<td style=\"text-align: center;\" width=\"23%\">\n<p>Hybrid CNN + LIME<\/p>\n<\/td>\n<td style=\"text-align: center;\" width=\"18%\">\n<p>Private MRI Data<\/p>\n<\/td>\n<td style=\"text-align: center;\" width=\"18%\">\n<p>~91% Accuracy<\/p>\n<\/td>\n<td style=\"text-align: center;\" width=\"30%\">\n<p>Emphasis on interpretability<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td style=\"text-align: center;\" width=\"9%\">\n[14]\n<\/td>\n<td style=\"text-align: center;\" width=\"23%\">\n<p>SegNet + Grad-CAM<\/p>\n<\/td>\n<td style=\"text-align: center;\" width=\"18%\">\n<p>Medical segmentation images<\/p>\n<\/td>\n<td style=\"text-align: center;\" width=\"18%\">\n<p>Not reported<\/p>\n<\/td>\n<td style=\"text-align: center;\" width=\"30%\">\n<p>Grad-CAM used for visualization only<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td style=\"text-align: center;\" width=\"9%\">\n[23]\n<\/td>\n<td style=\"text-align: center;\" width=\"23%\">\n<p>EfficientNet + Ensemble DL<\/p>\n<\/td>\n<td style=\"text-align: center;\" width=\"18%\">\n<p>Retinal Fundus Images<\/p>\n<\/td>\n<td style=\"text-align: center;\" width=\"18%\">\n<p>96.5% Accuracy<\/p>\n<\/td>\n<td style=\"text-align: center;\" width=\"30%\">\n<p>Used in diabetic retinopathy, different modality<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td style=\"text-align: center;\" width=\"9%\">\n[24]\n<\/td>\n<td style=\"text-align: center;\" width=\"23%\">\n<p>EfficientNet + ResNet<\/p>\n<\/td>\n<td style=\"text-align: center;\" width=\"18%\">\n<p>Skin disease dataset<\/p>\n<\/td>\n<td style=\"text-align: center;\" width=\"18%\">\n<p>97.1% Accuracy<\/p>\n<\/td>\n<td style=\"text-align: center;\" width=\"30%\">\n<p>Not focused on MRI<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td style=\"text-align: center;\" width=\"9%\">\n[25]\n<\/td>\n<td style=\"text-align: center;\" width=\"23%\">\n<p>ConvNeXT<\/p>\n<\/td>\n<td style=\"text-align: center;\" width=\"18%\">\n<p>AML Blood Smears<\/p>\n<\/td>\n<td style=\"text-align: center;\" width=\"18%\">\n<p>95.8% Accuracy<\/p>\n<\/td>\n<td style=\"text-align: center;\" width=\"30%\">\n<p>Non-MRI application<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td style=\"text-align: center;\" width=\"9%\">\n<p>This Work<\/p>\n<\/td>\n<td style=\"text-align: center;\" width=\"23%\">\n<p>DenseNet121 + Ensemble + LLM + XAI<\/p>\n<\/td>\n<td style=\"text-align: center;\" width=\"18%\">\n<p>Figshare, SARTAJ, Br35H<\/p>\n<\/td>\n<td style=\"text-align: center;\" width=\"18%\">\n<p>97.8% Accuracy \/ 0.985 F1-score<\/p>\n<\/td>\n<td style=\"text-align: center;\" width=\"30%\">\n<p>High performance + Explainability + Clinical Report<\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<table style=\"width: 70%; border-collapse: collapse;\" border=\"1\" cellpadding=\"5\">\n<tbody>\n<tr>\n<td style=\"width: 27.1005%;\"><img decoding=\"async\" class=\"alignnone size-thumbnail wp-image-68454\" src=\"https:\/\/biomedpharmajournal.org\/wp-content\/uploads\/2025\/10\/Vol18NoOct-Spl_Exp_Kal_Fig14-150x150.jpg\" alt=\"\" width=\"150\" height=\"150\" srcset=\"https:\/\/biomedpharmajournal.org\/staging\/wp-content\/uploads\/2025\/10\/Vol18NoOct-Spl_Exp_Kal_Fig14-150x150.jpg 150w, https:\/\/biomedpharmajournal.org\/staging\/wp-content\/uploads\/2025\/10\/Vol18NoOct-Spl_Exp_Kal_Fig14-250x250.jpg 250w, https:\/\/biomedpharmajournal.org\/staging\/wp-content\/uploads\/2025\/10\/Vol18NoOct-Spl_Exp_Kal_Fig14-256x256.jpg 256w, https:\/\/biomedpharmajournal.org\/staging\/wp-content\/uploads\/2025\/10\/Vol18NoOct-Spl_Exp_Kal_Fig14.jpg 845w\" sizes=\"(max-width: 150px) 100vw, 150px\" \/><\/td>\n<td style=\"width: 72.8995%;\">\n<p><strong>Figure 14: Comparative Accuracy of the Proposed Model Against Existing Brain Tumor and Medical Image Classification Approaches<\/strong><\/p>\n<p><a href=\"https:\/\/biomedpharmajournal.org\/wp-content\/uploads\/2025\/10\/Vol18NoOct-Spl_Exp_Kal_Fig14.jpg\" target=\"_blank\" rel=\"noopener\">Click here to view Figure<\/a><\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>This performance edge is visually represented in Fig. 14, which compares classification accuracies across several existing methods. The proposed system outperforms traditional and non-interpretable models, offering a more deployable and clinician-friendly pipeline through automated report generation and integrated XAI outputs.<\/p>\n<p><strong>Conclusion<\/strong><\/p>\n<p>This study presents an AI-powered MRI Analysis App designed to support brain tumor classification and diagnosis through a robust and interpretable deep learning pipeline. By integrating a CNN ensemble of DenseNet121, ResNet50, EfficientNet-B0, and MobileNetV3-Small, trained on a large and diverse dataset of 7023 MRI images, the system achieves high diagnostic performance across four tumor classes. The best-performing model, DenseNet121, demonstrated impressive classification metrics, with a macro F1-score of 0.9850 and AUC values nearing 0.99 across all classes. To overcome the black-box limitations of deep learning, the system incorporates multiple explainable AI techniques\u2014Grad-CAM, SHAP, LIME, and Edge Detection\u2014offering meaningful visual and analytical justifications for each prediction. Furthermore, the integration of a Large Language Model (LLM) via LangChain-Groq enables the automated generation of clinically formatted diagnostic reports, effectively bridging the gap between AI outputs and radiologist workflows. The final system output, including prediction, explanation, and textual analysis, is packaged into a downloadable PDF, facilitating ease of use in practical settings.<\/p>\n<p>Future work will explore the inclusion of additional imaging modalities, such as CT or PET scans, to support multimodal tumor analysis. The system may also be adapted for mobile or edge deployment to assist diagnosis in resource-constrained environments. Further, the integration of federated learning will be considered to enable privacy-preserving model training across institutions. Finally, clinical trials and collaborations with healthcare institutions will be pursued to validate the system\u2019s real-world utility and improve its generalizability across populations and imaging conditions.<\/p>\n<p><strong>Acknowledgement<\/strong><\/p>\n<p>The authors would like to thank the School of Computer Engineering, KIIT Deemed to be University, Bhubaneswar, for providing the necessary academic support and research infrastructure for carrying out this work. The department\u2019s guidance and resources are sincerely appreciated for facilitating the successful execution of this study.<\/p>\n<p><strong>Funding Source<\/strong><\/p>\n<p>The author(s) received no financial support for the research, authorship, and\/or publication of this article.<\/p>\n<p><strong>Conflict of Interest<\/strong><\/p>\n<p>The author(s) do not have any conflict of interest.<\/p>\n<p><strong>Data Availability Statement<\/strong><\/p>\n<p>This statement does not apply to this article.<\/p>\n<p><strong>Ethics Statement<\/strong><\/p>\n<p>This research did not involve human participants, animal subjects, or any material that requires ethical approval.<\/p>\n<p><strong>Informed Consent Statement<\/strong><\/p>\n<p>This study did not involve human participants, and therefore, informed consent was not required.<\/p>\n<p><strong>Clinical Trial Registration<\/strong><\/p>\n<p>This research does not involve any clinical trials.<\/p>\n<p><strong>Permission to reproduce material from other sources<\/strong><\/p>\n<p>Not Applicable<\/p>\n<p><strong>Authors\u2019 Contribution<\/strong><\/p>\n<ul>\n<li>P. Swain: Conceptualization, Methodology, Writing \u2013 Original Draft, Funding Acquisition.<\/li>\n<li>Soumya Ranjan Nayak: Data Collection, Analysis, Writing \u2013 Review &amp; Editing.<\/li>\n<li>Prabhishek Singh: Resources, Supervision.<\/li>\n<li>Santosh Kumar Swain: Visualization, Supervision, Project Administration.<\/li>\n<\/ul>\n<p><strong>References<\/strong><\/p>\n<ol>\n<li>Martucci M, Russo R, Schimperna F, D\u2019Apolito G, Panfili M, Grimaldi A, et al. Magnetic resonance imaging of primary adult brain tumors: State of the art and future perspectives. 2023;11(2):364.<br \/><a href=\"https:\/\/doi.org\/10.3390\/biomedicines11020364\" target=\"_blank\" rel=\"noopener\">CrossRef<\/a><\/li>\n<li>Swain KP, Nayak RK, Swain A, Nayak SR. The impact of machine learning on chronic kidney disease: Analysis and insights. In: Kumar P, Singh P, Diwakar M, Garg D, eds. <em>Healthcare Industry Assessment: Analyzing Risks, Security, and Reliability.<\/em> Cham: Springer; 2024. https:\/\/doi.org\/10.1007\/978-3-031-65434-3_6<br \/><a href=\"https:\/\/doi.org\/10.1007\/978-3-031-65434-3_6\" target=\"_blank\" rel=\"noopener\">CrossRef<\/a><\/li>\n<li>Swain KP, Samal SR, Ravi V, Nayak SR, Alahmadi TJ, Singh P, et al. Towards early intervention: Detecting Parkinson&#8217;s disease through voice analysis with machine learning. <em>Open Biomed Eng J.<\/em> 2024;18. http:\/\/dx.doi.org\/10.2174\/0118741207294056240322075602<br \/><a href=\"https:\/\/doi.org\/10.2174\/0118741207294056240322075602\" target=\"_blank\" rel=\"noopener\">CrossRef<\/a><\/li>\n<li>Shen L, Margolies LR, Rothstein JH, Fluder E, McBride R, Sieh W. Deep learning to improve breast cancer detection on screening mammography. <em>Sci Rep.<\/em> 2019;9(1):12495.<br \/><a href=\"https:\/\/doi.org\/10.1038\/s41598-019-48995-4\" target=\"_blank\" rel=\"noopener\">CrossRef<\/a><\/li>\n<li>Abdusalomov AB, Mukhiddinov M, Whangbo TK. Brain tumor detection based on deep learning approaches and magnetic resonance imaging. <em>Cancers (Basel).<\/em> 2023;15(16):4172.<br \/><a href=\"https:\/\/doi.org\/10.3390\/cancers15164172\" target=\"_blank\" rel=\"noopener\">CrossRef<\/a><\/li>\n<li>Samek W, Wiegand T, M\u00fcller KR. Explainable artificial intelligence: Understanding, visualizing and interpreting deep learning models. <em>ITU J ICT Discov.<\/em> 2017;1:1-10. https:\/\/doi.org\/10.48550\/arXiv.1708.08296<\/li>\n<li>Selvaraju RR, Cogswell M, Das A, Vedantam R, Parikh D, Batra D. Grad-CAM: Visual explanations from deep networks via gradient-based localization. <em>Int J Comput Vis.<\/em> 2020;128(2):336-359.<br \/><a href=\"https:\/\/doi.org\/10.1007\/s11263-019-01228-7\" target=\"_blank\" rel=\"noopener\">CrossRef<\/a><\/li>\n<li>Ribeiro MT, Singh S, Guestrin C. &#8220;Why should I trust you?&#8221;: Explaining the predictions of any classifier. <em>Proc 22nd ACM SIGKDD Int Conf Knowl Discov Data Min.<\/em> 2016:1135-1144.<br \/><a href=\"https:\/\/doi.org\/10.1145\/2939672.2939778\" target=\"_blank\" rel=\"noopener\">CrossRef<\/a><\/li>\n<li>Lundberg SM, Lee SI. A unified approach to interpreting model predictions. <em>Adv Neural Inf Process Syst.<\/em> https:\/\/doi.org\/10.48550\/arXiv.1705.07874<\/li>\n<li>Umarani CM, Gollagi SG, Allagi S, Sambrekar K, Ankali SB. Advancements in deep learning techniques for brain tumor segmentation: A survey. <em>Informatics Med Unlocked.<\/em> 2024;50:101576.<br \/><a href=\"https:\/\/doi.org\/10.1016\/j.imu.2024.101576\" target=\"_blank\" rel=\"noopener\">CrossRef<\/a><\/li>\n<li>Satushe V, Vyas V, Metkar S, Singh DP. AI in MRI brain tumor diagnosis: A systematic review of machine learning and deep learning advances (2010\u20132025). <em>Chemom Intell Lab Syst.<\/em> 2025;263:105414.<br \/><a href=\"https:\/\/doi.org\/10.1016\/j.chemolab.2025.105414\" target=\"_blank\" rel=\"noopener\">CrossRef<\/a><\/li>\n<li>Abdusalomov AB, Mukhiddinov M, Whangbo TK. Brain tumor detection based on deep learning approaches and magnetic resonance imaging. <em>Cancers (Basel).<\/em> 2023;15(16):4172.<br \/><a href=\"https:\/\/doi.org\/10.3390\/cancers15164172\" target=\"_blank\" rel=\"noopener\">CrossRef<\/a><\/li>\n<li>Sadeghi Z, Alizadehsani R, CIFCI MA, Kausar S, Rehman R, Mahanta P, et al. A review of explainable artificial intelligence in healthcare. <em>Comput Electr Eng.<\/em> 2024;118(Pt A):109370.<br \/><a href=\"https:\/\/doi.org\/10.1016\/j.compeleceng.2024.109370\" target=\"_blank\" rel=\"noopener\">CrossRef<\/a><\/li>\n<li>Xiao M, Zhang L, Shi W, Liu J, He W, Jiang Z. A visualization method based on the Grad-CAM for medical image segmentation model. <em>Proc 2021 Int Conf Electron Inf Eng Comput Sci (EIECS).<\/em> 2021:242-247.<br \/><a href=\"https:\/\/doi.org\/10.1109\/EIECS53707.2021.9587953\" target=\"_blank\" rel=\"noopener\">CrossRef<\/a><\/li>\n<li>Kun Y, Chunqing G, Yuehui G. An optimized LIME scheme for medical low light level image enhancement. <em>Comput Intell Neurosci.<\/em> 2022;2022:9613936.<br \/><a href=\"https:\/\/doi.org\/10.1155\/2022\/9613936\" target=\"_blank\" rel=\"noopener\">CrossRef<\/a><\/li>\n<li>Sun J, Sun CK, Tang YX, Liu TC, Lu CJ. Application of SHAP for explainable machine learning on age-based subgrouping mammography questionnaire data for positive mammography prediction and risk factor identification. <em>Healthcare (Basel).<\/em> 2023;11(14):2000.<br \/><a href=\"https:\/\/doi.org\/10.3390\/healthcare11142000\" target=\"_blank\" rel=\"noopener\">CrossRef<\/a><\/li>\n<li>Vimbi V, Shaffi N, Mahmud M. Interpreting artificial intelligence models: A systematic review on the application of LIME and SHAP in Alzheimer\u2019s disease detection. <em>Brain Inf.<\/em> 2024;11:10.<br \/><a href=\"https:\/\/doi.org\/10.1186\/s40708-024-00222-1\" target=\"_blank\" rel=\"noopener\">CrossRef<\/a><\/li>\n<li>Chanda T, Hauser K, Hobelsberger S, Bauer A, Stadlbauer A, Schulze C, et al. Dermatologist-like explainable AI enhances trust and confidence in diagnosing melanoma. <em>Nat Commun.<\/em> 2024;15:524.<br \/><a href=\"https:\/\/doi.org\/10.1038\/s41467-023-43095-4\" target=\"_blank\" rel=\"noopener\">CrossRef<\/a><\/li>\n<li>Tan TF, Dai P, Zhang X, Jin L, Poh S, Hong D, et al. Explainable artificial intelligence in ophthalmology. <em>Curr Opin Ophthalmol.<\/em> 2023;34(5):422-430.<br \/><a href=\"https:\/\/doi.org\/10.1097\/ICU.0000000000000983\" target=\"_blank\" rel=\"noopener\">CrossRef<\/a><\/li>\n<li>Cheng J, Huang W, Cao S, Yang R, Yang W, Yun Z, et al. Tumor region augmentation in MRI. <em>PLoS One.<\/em> 2015;10(10):e0140381.<br \/><a href=\"https:\/\/doi.org\/10.1371\/journal.pone.0140381\" target=\"_blank\" rel=\"noopener\">CrossRef<\/a><\/li>\n<li>SARTAJ Dataset. <em>GitHub Repository.<\/em> https:\/\/github.com\/sartajbhuvaji\/Brain-Tumor-Classification-MRI<\/li>\n<li>Br35H Dataset. <em>Kaggle Dataset.<\/em> https:\/\/www.kaggle.com\/datasets\/masoudnickparvar\/brain-tumor-mri-dataset<\/li>\n<li>Arora L, Singh SK, Kumar S, Verma R, Tiwari P, Gupta N, et al. Ensemble deep learning and EfficientNet for accurate diagnosis of diabetic retinopathy. <em>Sci Rep.<\/em> 2024;14:30554.<br \/><a href=\"https:\/\/doi.org\/10.1038\/s41598-024-81132-4\" target=\"_blank\" rel=\"noopener\">CrossRef<\/a><\/li>\n<li>Alruwaili M, Mohamed M. An integrated deep learning model with EfficientNet and ResNet for accurate multi-class skin disease classification. 2025;15:551.<br \/><a href=\"https:\/\/doi.org\/10.3390\/diagnostics15050551\" target=\"_blank\" rel=\"noopener\">CrossRef<\/a><\/li>\n<li>Mustapha MT, Ozsahin DU. Morphological analysis and subtype detection of acute myeloid leukemia in high-resolution blood smears using ConvNeXT. 2025;6:45.<br \/><a href=\"https:\/\/doi.org\/10.3390\/ai6030045\" target=\"_blank\" rel=\"noopener\">CrossRef<\/a><\/li>\n<li>Pang RY, Santy S, Just R, Reinecke K. BLIP: Facilitating the exploration of undesirable consequences of digital technologies. <em>Proc 2024 CHI Conf Hum Factors Comput Syst.<\/em> 2024:290. https:\/\/doi.org\/10.1145\/3613904.3642054<br \/><a href=\"https:\/\/doi.org\/10.1145\/3613904.3642054\" target=\"_blank\" rel=\"noopener\">CrossRef<\/a><\/li>\n<li>Singhal K, Azizi S, Tu T, Mahdavi S, Bernecker S, Loh P, et al. Large language models encode clinical knowledge. 2023;620:172-180.<br \/><a href=\"https:\/\/doi.org\/10.1038\/s41586-023-06291-2\" target=\"_blank\" rel=\"noopener\">CrossRef<\/a><\/li>\n<li>Lehman E, Johnson A. Clinical-T5: Large language models built using MIMIC clinical text (version 1.0.0). 2023. https:\/\/doi.org\/10.13026\/rj8x-v335<\/li>\n<\/ol>\n\n","protected":false},"excerpt":{"rendered":"<p>Introduction Cerebral neoplasms are among the most critical and life-threatening  [&#8230;]<\/p>\n","protected":false},"author":15,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[130],"tags":[],"class_list":["post-68436","post","type-post","status-publish","format-standard","hentry","category-vol18octoberspledition"],"_links":{"self":[{"href":"https:\/\/biomedpharmajournal.org\/staging\/wp-json\/wp\/v2\/posts\/68436","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/biomedpharmajournal.org\/staging\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/biomedpharmajournal.org\/staging\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/biomedpharmajournal.org\/staging\/wp-json\/wp\/v2\/users\/15"}],"replies":[{"embeddable":true,"href":"https:\/\/biomedpharmajournal.org\/staging\/wp-json\/wp\/v2\/comments?post=68436"}],"version-history":[{"count":4,"href":"https:\/\/biomedpharmajournal.org\/staging\/wp-json\/wp\/v2\/posts\/68436\/revisions"}],"predecessor-version":[{"id":68469,"href":"https:\/\/biomedpharmajournal.org\/staging\/wp-json\/wp\/v2\/posts\/68436\/revisions\/68469"}],"wp:attachment":[{"href":"https:\/\/biomedpharmajournal.org\/staging\/wp-json\/wp\/v2\/media?parent=68436"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/biomedpharmajournal.org\/staging\/wp-json\/wp\/v2\/categories?post=68436"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/biomedpharmajournal.org\/staging\/wp-json\/wp\/v2\/tags?post=68436"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}