- Executive Summary
- Overview
- Research Background
- Technology Stack
- Architecture
- Methodology
- Performance Metrics
- Installation & Quick Start
- Expected Outcomes
- Potential Applications
- Milestones
- Contributing
- License
- Contact
Brain tumor detection and classification remains one of the most challenging areas in medical imaging. Traditional diagnostic methods suffer from:
- Time-consuming processes requiring extensive manual analysis
- Subjectivity in interpretation leading to inconsistent diagnoses
- Human errors due to fatigue and cognitive limitations
- Limited scalability to handle increasing patient volumes
This project implements an automated brain tumor classification system using deep learning with PyTorch. The solution leverages Convolutional Neural Networks (CNNs) to analyze MRI scans and classify tumor types with high accuracy, providing rapid and objective diagnostic support.
- Automated classification of multiple tumor types (glioma, meningioma, pituitary tumor)
- Reduced diagnostic time from hours to seconds
- High accuracy achieved through state-of-the-art CNN architecture
- Scalable solution capable of processing large volumes of medical images
Brain tumor detection and classification is one of the most challenging areas in medical imaging. Traditional methods often suffer from:
- Time-consuming processes
- Subjectivity in diagnosis
- Human errors
This project leverages Deep Learning techniques to provide a solution that automates the classification of brain tumors from MRI scans. The goal is to enhance diagnostic efficiency and accuracy.
Using state-of-the-art Deep Learning models, this project aims to:
- Automate medical image analysis
- Classify tumor types with high precision
- Improve diagnostic speed and reduce human intervention
- Multi-class tumor classification: Distinguish between glioma, meningioma, pituitary tumor, and non-tumor cases
- Real-time inference: Process MRI scans in seconds
- Transfer learning support: Fine-tune on custom datasets
- Explainable AI: Visualize model decision-making through activation maps
- Clinical integration ready: REST API for PACS system integration
- Neuro-oncology clinics: Assist oncologists in tumor detection and treatment planning
- Radiology departments: Enhance radiologist workflow with automated pre-screening
- Telemedicine: Enable remote diagnosis in underserved areas
- Medical research: Facilitate large-scale epidemiological studies
- Educational tools: Training platform for medical students
This project builds upon established research in medical image analysis using deep learning. The approach is informed by several key studies:
Reference: https://arxiv.org/abs/1802.10200
Afshar, P., Mohammadi, A., & Plataniotis, K. N. (2018). "Brain Tumor Type Classification via Capsule Networks." 25th IEEE International Conference on Image Processing (ICIP).
Approach Summary:
- Method: Used Capsule Networks (CapsNets) for hierarchical feature learning
- Dataset: 3,064 T1-weighted contrast-enhanced MRI images (3 tumor types)
- Key Innovation: Spatial relationship preservation through dynamic routing
- Results: Achieved 86.56% accuracy, outperforming traditional CNNs
- Relevance: Demonstrated effectiveness of deep learning for multi-class tumor classification
Reference: https://www.sciencedirect.com/science/article/abs/pii/S0010482519302148
Deepak, S., & Ameer, P. M. (2019). "Brain tumor classification using deep CNN features via transfer learning." Computers in Biology and Medicine, 111, 103345.
Approach Summary:
- Method: Transfer learning using pre-trained GoogleNet with SVM classifier
- Dataset: 3,064 brain MRI images across 3 tumor categories
- Key Innovation: Feature extraction from pre-trained networks + traditional ML classifier
- Results: 97.1% accuracy using 5-fold cross-validation
- Relevance: Validates transfer learning approach for limited medical datasets
Approach Summary:
- Method: Multi-scale CNN architecture with attention mechanisms
- Key Innovation: Attention-guided feature fusion across multiple scales
- Results: Robust performance across varying image qualities
- Relevance: Inspires multi-scale feature extraction strategy
The project integrates techniques from:
- Computer vision: ResNet, DenseNet architectures for feature extraction
- Medical imaging: DICOM processing, image normalization techniques
- Machine learning: Cross-validation, hyperparameter optimization
- Clinical workflow: Integration with existing hospital information systems
- Deep Learning: PyTorch, TorchVision, ONNX
- Data Processing: NumPy, Pandas, PIL, OpenCV
- Visualization: Matplotlib, Seaborn, TensorBoard
- Model Evaluation: scikit-learn, torchmetrics
- Medical Imaging: SimpleITK, NiBabel
- Version Control: Git, GitHub
- Containerization: Docker
- Experiment Tracking: Weights & Biases / MLflow
- Code Quality: Black, Flake8, pytest
Framework: PyTorch - A leading framework for deep learning.
Model: Convolutional Neural Network (CNN) - A powerful architecture for image analysis consisting of:
- Convolutional layers for automatic feature extraction
- Batch normalization for training stability
- Max pooling for dimensionality reduction
- Fully connected layers for classification
- Dropout for regularization
Image Type: MRI Scans - T1-weighted contrast-enhanced brain MRI images
- Dataset Splitting: The dataset is split into training (70%), validation (15%), and test (15%) sets for robust model evaluation
- Convolution Output Dimension Calculation: Dynamically compute the output dimensions of convolution layers
- Max Pooling: Use max pooling to reduce dimensionality while preserving critical features
- Feature Extraction: Convolutional layers automatically extract relevant features from raw images
- Data Augmentation: Random rotations, flips, zooms, and intensity variations
- Data Exploration: Conducting in-depth analysis to understand data patterns, missing values, and distribution
- Preprocessing: Image normalization, resizing to 224Γ224, and intensity standardization
- Image Augmentation: Applying transformations like rotations, flips, and zoom to increase dataset diversity and improve generalization
- Model Training: Training the CNN using a supervised learning approach on labeled MRI data with Adam optimizer
- Multi-Class Classification: The model classifies MRI scans into different categories based on tumor types
- Validation: Continuous monitoring of validation metrics to prevent overfitting
- Evaluation: Comprehensive testing on held-out test set using multiple metrics
To evaluate the performance of the model, the following metrics are used:
- Accuracy: Overall correctness of the model's predictions
- Precision: The proportion of true positive predictions
- Recall: The proportion of true positives among all actual positive instances
- F1 Score: A balanced metric combining precision and recall
- Confusion Matrix: Detailed breakdown of classifications per tumor type
- ROC-AUC: Area under the receiver operating characteristic curve
To run this project, the following packages are required:
- Python 3.8+
- PyTorch 2.0+ (Deep learning framework)
- NumPy (Numerical operations)
- Pandas (Data handling)
- Matplotlib (Data visualization)
- scikit-learn (For model evaluation)
- torchvision (Image transformations)
- Pillow (Image processing)
Clone the repository and install dependencies:
git clone https://github.com/dhou22/Brain-Cancer-Detection-CNN.git
cd Brain-Cancer-Detection-CNN
pip install -r requirements.txtTrain the model using the following command:
python train.py --epochs 50 --batch-size 32 --lr 0.001To classify a new MRI scan, use the following Python script:
from model import CNN_TUMOR
import torch
from torchvision import transforms
from PIL import Image
# Load the trained model
model = CNN_TUMOR(params)
model.load_state_dict(torch.load("model_weights.pth"))
model.eval()
# Prepare the image for prediction
img = Image.open("path_to_image.jpg")
transform = transforms.Compose([
transforms.Resize((224, 224)),
transforms.ToTensor(),
transforms.Normalize(mean=[0.485, 0.456, 0.406],
std=[0.229, 0.224, 0.225])
])
img_tensor = transform(img).unsqueeze(0)
# Predict the tumor type
with torch.no_grad():
output = model(img_tensor)
prediction = torch.argmax(output, dim=1)
tumor_types = ['Glioma', 'Meningioma', 'Pituitary', 'No Tumor']
print(f"Predicted tumor type: {tumor_types[prediction.item()]}")- Improved diagnostic accuracy: Reducing human error in detecting brain tumors
- Faster medical image processing: Speeding up the diagnosis and treatment planning
- Reduced human bias: Delivering consistent results in tumor classification
- Support for healthcare professionals: Assisting clinicians in accurate decision-making
- Cost reduction: Decreasing diagnostic costs through automation
- Neuro-oncology: Use in clinical settings to assist oncologists in tumor detection and treatment planning
- Radiology departments: Enhancing the workflow of radiologists by automating classification
- Clinical Decision Support Systems: AI-powered tools that provide support for clinicians in diagnosing brain tumors
- Medical Research: Facilitating further research on brain tumor types and AI models for medical imaging
- Telemedicine: Enabling remote diagnosis in areas with limited access to specialists
- Drug development: Supporting pharmaceutical research through automated tumor characterization
- β Phase 1: Data collection and preprocessing (Completed)
- π Phase 2: Model training and optimization (In progress)
- π Phase 3: Evaluation and real-world testing (Upcoming)
- π Phase 4: Clinical validation and deployment (Future)
We welcome contributions! If you'd like to help with the project, please:
- Fork the repository
- Create a feature branch (
git checkout -b feature/AmazingFeature) - Commit your changes (
git commit -m 'Add some AmazingFeature') - Push to the branch (
git push origin feature/AmazingFeature) - Open a Pull Request
Please ensure your code follows PEP 8 style guidelines and includes appropriate tests.
This project is licensed under the MIT License - see the LICENSE file for details.
For questions or feedback, reach out to:
- Email: dhouha.meliane@esprit.tn
- LinkedIn: https://www.linkedin.com/in/dhouha-meliane/
- GitHub: @dhou22
-
Afshar, P., Mohammadi, A., & Plataniotis, K. N. (2018). Brain Tumor Type Classification via Capsule Networks. 25th IEEE International Conference on Image Processing (ICIP), 3129-3133.
-
Deepak, S., & Ameer, P. M. (2019). Brain tumor classification using deep CNN features via transfer learning. Computers in Biology and Medicine, 111, 103345.
Disclaimer: This project is intended as a research tool and should not replace professional medical diagnoses. Always consult healthcare professionals for accurate diagnoses. This system is designed to assist, not replace, clinical decision-making.
Acknowledgments: This research was inspired by and builds upon the pioneering work of researchers in medical AI and deep learning for healthcare applications.


