Skip to content

Wazab-75/Brain-MRI-Analysis

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 

Repository files navigation

Brain MRI Analysis - Classification & Segmentation

This project explores deep learning techniques for analyzing brain MRI images, addressing two complementary tasks:

  1. Classification: Determining whether a tumor is present (tumor vs non-tumor)
  2. 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.


Part 1: Tumor Classification

image

Overview

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.

Model and Training Details

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)

Results

The final classification model achieves 87.18% accuracy on the test set.

image

Part 2: Tumor Segmentation

image

Overview

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.

Model and Training Details

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

Results

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.

image

Motivation

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.


Notes

This repository is intended for educational and research purposes only and is not a medical device.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors