Skip to content

A full MRI-based brain tumor classification system built with Random Forests and Flask. It recognizes normal, glioma, meningioma, and pituitary tumor images and allows users to upload external scans for instant prediction and analysis.

Notifications You must be signed in to change notification settings

AmrBedir/NeuroDetect_RandomForest

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

17 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

๐Ÿง  NeuroDetect | Brain Tumor Classification & Analysis System | Random Forest Algorithm

Python Flask Scikit-Learn OpenCV License

NeuroDetect Dashboard Preview

An Advanced Computer Vision System for Automated Brain Tumor Classification using Random Forest Ensemble Learning.

View Demo โ€ข Installation โ€ข How It Works โ€ข Tech Stack

Snake animation


๐Ÿ“š Overview

NeuroDetect is a powerful medical imaging analysis system designed to classify brain MRI scans into four categories: Normal, Glioma, Meningioma, and Pituitary Tumor.

It features a fully interactive Web Dashboard built with Flask, providing real-time diagnostics, performance analytics, and printable medical reports โ€” bringing AI from code to clinical usability.

๐ŸŒŸ Key Features

  • ๐Ÿ–ฅ Web-Based Dashboard
  • โšก Real-Time Diagnosis
  • ๐Ÿ“Š Confusion Matrix & Class Distribution Charts
  • ๐Ÿ“ˆ Probability Breakdown for All Classes
  • ๐Ÿงพ Printable Medical Reports
  • ๐Ÿ›ก Robust Validation & Error Handling

๐Ÿ“ธ Demo Preview

Interactive Dashboard Diagnostic Result & Report

๐Ÿง  Classification Classes

Class Description
0. Normal Healthy brain with no detected tumor.
1. Glioma Tumor Tumor occurring in the brain/spinal cord.
2. Meningioma Tumor Tumor forming on protective membranes of brain/spinal cord.
3. Pituitary Tumor Abnormal growth in the pituitary gland.

๐Ÿ›  Technology Stack

Backend & AI

  • Python 3.x
  • Scikit-Learn (Random Forest Classifier)
  • OpenCV (Image preprocessing)
  • NumPy & Pandas

Web Framework

  • Flask
  • Jinja2

Frontend & Visualization

  • HTML5 / CSS3
  • Matplotlib & Seaborn
  • JavaScript (AJAX)

โš™๏ธ How It Works

1๏ธโƒฃ Data Preprocessing

  • Convert MRI โ†’ Grayscale
  • Resize to 128ร—128
  • Flatten to 1D vector
  • Normalize for model compatibility

2๏ธโƒฃ Model Training

  • Random Forest Classifier (Ensemble Learning)
  • Automatically trains on first app launch
  • 80/20 train-test split
  • High accuracy & reduced overfitting

3๏ธโƒฃ Real-Time Prediction (Flask API)

  • User uploads an image
  • Processed via BytesIO (not saved on disk)
  • Model outputs:
    • Predicted class
    • Confidence probability of each class
  • UI dynamically updates with results

๐Ÿ’ป Installation & Setup

1. Clone the Repository

git clone https://github.com/AmrBedir/NeuroDetect_RandomForest.git
cd NeuroDetect

2. Install Dependencies

pip install -r requirements.txt

If missing requirements.txt, install manually:

pip install flask scikit-learn opencv-python matplotlib seaborn pandas pillow

3. Dataset Structure

Ensure your dataset is placed as follows (After unzipping each file):

/brain_tumor_dataset
    /glioma_tumor
    /meningioma_tumor
    /normal
    /pituitary_tumor

4. Run the Application

python app.py

5. Access the Dashboard

Navigate to:

http://127.0.0.1:5000/

The model will auto-train on first run. Wait for the "System Ready" message.


๐Ÿ“Š Model Performance

Metric Score
Accuracy ~79.35%
Precision 80.11%
Recall 79.35%
F1-Score 79.26%

(Exact metrics may vary depending on dataset + random seed.)


๐Ÿ”ฎ Future Improvements

  • ๐Ÿš€ Switch to CNN Models (VGG16, ResNet50, EfficientNet)
  • ๐Ÿงฌ Add 3D MRI support (NIfTI)
  • โ˜๏ธ Cloud Deployment (AWS / Render / Heroku)
  • ๐Ÿ“ฑ REST API for Mobile Integration
  • ๐Ÿ—‚ Automated Reporting + Multi-User Accounts

๐Ÿค Contributors

Developed by NeuroDetect Team โ€” FCIS, Mansoura University


๐ŸŽ“ Supervised By

  • Dr. Mohamed ElMogy
  • Eng. Yasmeen Al-Saqqar

โš ๏ธ Disclaimer

This project is for educational & research purposes only.
It is NOT intended for medical diagnosis or treatment.
Always consult certified medical professionals.


๐Ÿ“ License

Licensed under the MIT License.
See the LICENSE file for full details.


Made with โค๏ธ fueled by โ˜•

About

A full MRI-based brain tumor classification system built with Random Forests and Flask. It recognizes normal, glioma, meningioma, and pituitary tumor images and allows users to upload external scans for instant prediction and analysis.

Topics

Resources

Stars

Watchers

Forks