This project explores deep learning techniques for analyzing brain MRI images, addressing two complementary tasks:
- Classification: Determining whether a tumor is present (tumor vs non-tumor)
- Segmentation: Localizing tumor regions at the pixel level
It was developed as a hands-on project to gain experience with medical imaging data and convolutional neural networks using PyTorch, covering common challenges such as noise, variability between patients, and class imbalance.
Brain MRI images can be difficult to analyze due to low contrast, acquisition noise, and anatomical differences across patients. This component trains a convolutional neural network (CNN) to distinguish between MRI scans that contain a tumor and those that do not.
Architecture & Dataset:
- Framework: PyTorch
- Architecture: CNN with 3 convolutional blocks and batch normalization
- Dataset: Brain MRI Images for Brain Tumor Detection (Kaggle - navoneel/brain-mri-images-for-brain-tumor-detection)
- Dataset size: 253 images
- Input: Brain MRI images (resized to 128×128 pixels, grayscale)
- Output: Binary classification (tumor / non-tumor)
Training Configuration:
- Data split: 70% train / 15% validation / 15% test
- Epochs: 100
- Optimizer: Adam (learning rate: 1e-4)
- Loss function: Cross-Entropy
Data Augmentation:
- Random rotation (±15 degrees)
- Random horizontal flip
- Random affine transformation
- Normalization (mean=0.245, std=0.21)
The final classification model achieves 87.18% accuracy on the test set.
While classification answers whether a tumor is present, segmentation aims to determine where the tumor is located by predicting a binary mask that highlights tumor regions at the pixel level. This task is more fine-grained and better aligned with clinical analysis, as it enables localization and shape assessment of pathological regions.
Architecture & Dataset:
- Framework: PyTorch
- Architecture: U-Net (encoder–decoder with skip connections)
- Dataset: Brain Tumor Segmentation (Kaggle - nikhilroxtomar/brain-tumor-segmentation)
- Dataset size: 3,064 image-mask pairs
- Input: Brain MRI images (resized to 256×256 pixels)
- Output: Binary segmentation mask (tumor vs background)
Training Configuration:
- Data split: 70% train / 15% validation / 15% test
- Epochs: 30
- Optimizer: Adam (learning rate: 1e-4)
- Loss function: Combined Dice + Binary Cross-Entropy (BCE) loss
Pipeline:
- Image and mask loading with spatial alignment
- Image resizing to 256×256 pixels
- Preprocessing and normalization
- Pixel-wise training with combined loss function
- Qualitative evaluation on validation set
The U-Net architecture was chosen due to its effectiveness in medical image segmentation, particularly for handling limited data and preserving spatial details through skip connections.
Final epoch results:
- Training loss: 0.2125
- Validation loss: 0.3282
The close gap between training and validation losses indicates reasonable generalization. Segmentation quality was primarily assessed through visual inspection of predicted masks alongside ground-truth annotations, ensuring anatomically plausible tumor localization.
This project was motivated by an interest in medical imaging and applied deep learning.
It serves as an introduction to working with healthcare data and building models that could support clinical decision-making.
This repository is intended for educational and research purposes only and is not a medical device.