-
-
single patient processing pipeline
-
About NeuroScan AI
-
ML model information
-
Patient Brain MRI uploaded
-
Scan ready for analysis
-
Analysis complete with gradcam, mask and tumor overlay shown
-
Analysis results and information
-
Patient's PDF report based on model analysis
-
Batch processing pipeline
-
Ready for batch processing
-
Batch processing initiated
-
Batch processing complete, each patient's analysis result is ready and a zip file containing the pdfs for all three patient for download
-
PDF output of batch processing
-
3D volumetric analysis initiated
NeuroScan: AI-Powered Brain MRI Analysis, Segmentation and 3D Visualization
Project Overview
NeuroScan is an AI-powered brain MRI analysis platform that combines deep learning, computer vision, and explainable AI to support the analysis of brain MRI scans.
The platform can classify MRI images into four categories: Glioma, Meningioma, Pituitary Tumour, and No Tumour. Beyond classification, it generates visual explanations of its predictions, segments potential tumour regions, and provides interactive 3D visualizations from multiple MRI slices.
Our goal was to go beyond building a model that simply predicts what an MRI image contains. We wanted to develop a more complete application that allows users to examine the model's predictions, visualize the regions it identifies, and understand some of the information behind its outputs.
NeuroScan is currently an academic research and educational prototype. It is not a clinically validated diagnostic system and is not intended to replace radiologists or qualified medical professionals.
The Problem
Brain MRI analysis is an important part of investigating and understanding brain abnormalities. However, interpreting medical images requires specialized expertise, and manually examining large numbers of images can be demanding.
There is also a challenge with many AI-based image classification systems: they provide predictions without making it easy to understand which regions of an image influenced those predictions.
This creates two related problems:
- How can deep learning be used to identify patterns associated with different brain tumour categories in MRI images?
- How can we make the outputs of an AI model more interpretable by providing visual explanations and highlighting the regions it identifies?
NeuroScan explores these questions by combining classification, segmentation, explainability, and visualization in one application.
Inspiration
We were interested in exploring how artificial intelligence could be applied to real-world problems, particularly in healthcare and medical imaging.
Brain MRI analysis presented an interesting opportunity to work with computer vision and deep learning beyond conventional image classification.
We wanted to understand not just how a model could recognize different tumour categories, but also how it could identify potential tumour regions and visually explain its predictions.
This led us to build NeuroScan as an integrated platform rather than a standalone machine learning model.
How We Built It
NeuroScan was developed using Python, PyTorch, Torchvision, Streamlit, OpenCV, Albumentations, Scikit-learn, Scikit-image, Plotly, and ReportLab.
The application is built around two independently trained deep learning models.
1. Brain MRI Classification — EfficientNet-B0
For classification, we implemented EfficientNet-B0 using transfer learning.
The model uses ImageNet-pretrained weights from Torchvision. Its original classification head was replaced with a new head designed to recognize four categories:
- Glioma
- Meningioma
- Pituitary Tumour
- No Tumour
The feature extraction backbone is frozen, while the new classification head is trained on the brain MRI dataset.
Input images are resized to 224 × 224 pixels, converted from grayscale to three channels, and normalized using ImageNet statistics.
The model produces a probability score for each category using softmax.
2. Tumour Segmentation — U-Net
Classification alone does not identify the exact pixels that make up a potential tumour region.
To address this, we implemented a U-Net architecture trained from scratch for binary image segmentation.
The model uses an encoder-decoder structure with skip connections to preserve spatial information. It processes MRI images and produces a pixel-level segmentation mask.
The output is converted into a probability map using sigmoid activation and thresholded at 0.5 to produce a binary mask.
We combine Binary Cross-Entropy Loss and Soft Dice Loss during training:
[ L = 0.5L_{\mathrm{BCE}} + 0.5L_{\mathrm{Dice}} ]
This helps the model learn to identify tumour regions despite the imbalance between tumour pixels and background pixels.
3. Explainable AI — Grad-CAM
We integrated Gradient-weighted Class Activation Mapping (Grad-CAM) to make the classifier's predictions easier to inspect.
Grad-CAM uses gradients from the classifier's final convolutional block to generate a heatmap highlighting image regions that influenced the predicted class.
The heatmap is overlaid on the original MRI image, and users can adjust its intensity through the application interface.
This provides a visual explanation of the classifier's behaviour, although it should not be interpreted as proof of tumour presence or as a clinical explanation.
4. 3D MRI Visualization
We also developed a 3D volumetric visualization feature.
Users can upload an ordered stack of MRI slices from one patient. Each slice passes through the existing analysis pipeline, and the resulting segmentation masks are combined into a 3D array.
We use the marching cubes algorithm from Scikit-image to generate a 3D mesh of the predicted tumour region. OpenCV is used to generate a brain outline, while Plotly Mesh3d provides an interactive visualization that users can rotate and inspect.
The current implementation uses slice-by-slice 2D inference and a manually selected Z-spacing multiplier. It is therefore a visualization prototype, not a calibrated reconstruction of actual tumour volume.
5. Application and Reporting
We integrated the different components into a Streamlit application with three processing modes:
- Single Patient: Analyse one MRI image and display classification, confidence scores, Grad-CAM, segmentation and a downloadable PDF report.
- Batch Processing: Submit multiple MRI images for analysis and generate individual reports packaged into a ZIP file.
- 3D Volumetric: Analyse multiple slices from one patient and generate an interactive 3D visualization.
The application also generates PDF reports containing patient information, classification results, confidence scores, tumour pixel measurements, and visual outputs.
Evaluation
We evaluated the classification model using the project's classifier/evaluate.py script on the dataset's Testing split, which contains 1,311 MRI images.
The evaluation includes accuracy, precision, recall, F1-score, a classification report, and a confusion matrix.
Classification Results
| Metric | Result |
|---|---|
| Accuracy | 92.45% |
| Weighted Precision | 0.925 |
| Weighted Recall | 0.925 |
| Weighted F1-score | 0.924 |
| Evaluation images | 1,311 |
Per-Class Performance
| Class | Precision | Recall | F1-score |
|---|---|---|---|
| No Tumour | 0.96 | 0.99 | 0.98 |
| Pituitary | 0.93 | 0.98 | 0.96 |
| Glioma | 0.95 | 0.84 | 0.89 |
| Meningioma | 0.84 | 0.86 | 0.85 |
The confusion matrix showed that the model correctly classified 402 out of 405 No Tumour images and 295 out of 300 Pituitary images.
One notable weakness was the confusion between Glioma and Meningioma, with 43 out of 300 actual Glioma images incorrectly classified as Meningioma.
Important Evaluation Caveat
Although the results above were calculated on the 1,311-image Testing split, the current training implementation also uses test accuracy for early stopping and best-checkpoint selection.
Consequently, this split was not completely independent of model selection, and the reported 92.45% accuracy may be optimistic. We have identified this as an important limitation.
A more rigorous evaluation would use three separate datasets:
- Training data for learning model parameters.
- Validation data for early stopping and checkpoint selection.
- An untouched test set for final performance measurement.
Segmentation Evaluation
The U-Net model is trained using an 80/20 training-validation split and evaluated during training using the hard Dice coefficient on thresholded segmentation masks.
However, the best validation Dice score is currently stored in the model checkpoint and has not yet been extracted and documented. We therefore do not claim a verified numerical segmentation score.
This is an area we intend to improve through more rigorous evaluation and reporting.
Who Benefits, and Who Could Be Harmed?
Who Could Benefit?
- Medical imaging researchers: NeuroScan provides an experimental platform for exploring deep learning approaches to brain MRI classification and segmentation.
- Students and AI developers: The project demonstrates how classification, segmentation, explainable AI, and 3D visualization can be integrated into a working application.
- Healthcare technology innovators: It provides a starting point for investigating AI-assisted medical imaging workflows.
- Medical professionals and radiology researchers: With further validation and development, tools like NeuroScan could potentially support research into image analysis and visualization.
Who Could Be Harmed?
An inaccurate AI prediction could create unnecessary concern or false reassurance if someone interprets it as a medical diagnosis.
False-positive segmentation could make healthy regions appear abnormal, while incorrect classification could fail to identify patterns that deserve further investigation.
There are also privacy concerns associated with medical imaging data and patient information. Improper handling or sharing of identifiable medical data could expose sensitive information.
For these reasons, NeuroScan is strictly an academic research prototype. It must not be used to make medical decisions, and its outputs require review by qualified medical professionals. Any future real-world deployment would require appropriate clinical validation, privacy safeguards, and regulatory consideration.
Challenges We Faced
One of our biggest challenges was integrating two different deep learning models into one application while ensuring that each model received the correct preprocessing.
Classification and segmentation are fundamentally different tasks. Classification predicts the category of an image, while segmentation identifies individual pixels belonging to a region. Getting both models to work consistently within the same application required experimentation.
Another challenge was implementing Grad-CAM. We wanted to make the classification process more interpretable, which required understanding how gradients from the network could be used to generate meaningful visual heatmaps.
The 3D visualization component also presented challenges. We had to process individual MRI slices, combine their predicted segmentation masks, and reconstruct them into an interactive 3D representation.
We also encountered challenges with model evaluation and dataset limitations. While the classification model produced encouraging results, we identified areas where the evaluation methodology and segmentation training process could be improved.
What We Learned
Building NeuroScan taught us that developing an AI-powered application involves much more than training a model and reporting its accuracy.
We gained practical experience in transfer learning, convolutional neural networks, image segmentation, model evaluation, explainable AI, image preprocessing, and deploying machine learning models through an interactive application.
We also learned the importance of understanding model limitations. A high accuracy score does not automatically mean a model is reliable, especially in a sensitive field such as healthcare.
Most importantly, we learned how to bring different machine learning components together into a functional application that users can interact with.
What We Would Do With Another Month
With another month of development, we would focus on improving NeuroScan's reliability, evaluation methodology, and ability to work with real medical imaging data.
Our priorities would be:
- Improve model evaluation: Introduce a separate validation dataset and evaluate the classifier on a completely untouched test set.
- Improve classification performance: Fine-tune selected EfficientNet-B0 layers, introduce appropriate data augmentation, and investigate the confusion between Glioma and Meningioma.
- Improve segmentation: Extract and report the U-Net validation Dice score, introduce IoU evaluation, and include healthy MRI images during segmentation training to reduce false-positive masks.
- Support medical imaging formats: Introduce DICOM and NIfTI support so that NeuroScan can process actual medical imaging files and access their spatial metadata.
- Improve 3D reconstruction: Use actual MRI voxel spacing and explore 3D or 2.5D deep learning architectures rather than relying entirely on independent 2D slice predictions.
- Improve prediction reliability: Introduce probability calibration, uncertainty estimation, and better handling of images outside the supported categories.
- Improve software reliability: Add automated tests and containerized deployment.
Our long-term goal is to develop NeuroScan into a more robust AI-assisted brain MRI analysis and visualization platform, supported by rigorous technical evaluation and appropriate medical expertise.
Technologies Used
- Python 3.12
- PyTorch
- Torchvision
- EfficientNet-B0
- U-Net
- PyTorch Grad-CAM
- Albumentations
- OpenCV
- Scikit-learn
- Scikit-image
- Streamlit
- Plotly
- ReportLab
Repository and Demo
GitHub Repository:
https://github.com/Ayoola-in/NeuroScanAI
Pretrained Model Weights:
https://huggingface.co/Ayoola-In/NeuroScan_AI
Project Demonstration Video:
https://youtu.be/S3kKXR32QpE
The repository contains the application code, model training and evaluation scripts, configuration files, and instructions for installing dependencies, downloading the trained model weights, and running NeuroScan locally.
Attribution and Acknowledgements
NeuroScan was developed by Team Aescanus.
The project uses the following external tools, architectures, and resources:
- EfficientNet-B0: The architecture and ImageNet-pretrained weights are provided through Torchvision. The original EfficientNet architecture is credited to its authors.
- U-Net: The segmentation architecture is based on the U-Net approach introduced by Ronneberger, Fischer, and Brox.
- Grad-CAM: Explainability is implemented using the PyTorch Grad-CAM library.
- PyTorch and Torchvision: Used for model development, training, and inference.
- Albumentations: Used for image preprocessing and augmentation in the segmentation pipeline.
- OpenCV, Scikit-learn, and Scikit-image: Used for image processing, evaluation, and 3D mesh reconstruction.
- Streamlit and Plotly: Used to build the application interface and interactive visualizations.
- ReportLab: Used for PDF report generation.
- MRI Dataset: The classification dataset corresponds to the publicly available Kaggle Brain Tumor MRI Dataset. The exact dataset uploader, original source URL, and applicable license should be added and verified before submission.
We acknowledge the original authors and maintainers of these architectures, libraries, pretrained weights, and datasets. Their work made important parts of this project possible.
AI Tools Disclosure
ChatGPT (OpenAI) was used to assist with technical documentation, refining project descriptions
Team
Developed by Team Aescanus
- Ayoola Ini-Oluwa Marvelous
- Adetunji Victor Adewale
Disclaimer: NeuroScan is an academic research and educational prototype. It has not undergone clinical validation and must not be used as a standalone diagnostic tool or to make medical decisions. All outputs require interpretation by qualified medical professionals.
Built With
- opencv
- plotly
- python
- pytorch
- reportlab.
- scikit-learn
- streamlit
- torchvision