Skip to content

ArjunPesaru/Brain_tumor_project

Repository files navigation

Brain Tumor Segmentation and Analysis

Introduction

This project focuses on brain tumor segmentation using a 2D U-Net architecture tailored for multi-class segmentation of brain tumors. Leveraging MRI data from the BraTS2020 dataset, the model identifies and delineates key tumor regions, including necrosis, edema, and enhancing tumor areas. This work emphasizes computational efficiency, segmentation accuracy, and robust preprocessing techniques.

Features

  • Architecture: U-Net with skip connections for precise tumor boundary delineation.
  • Multi-Modality Input: T1ce (contrast-enhanced) and FLAIR MRI modalities for enhanced segmentation accuracy.
  • Custom Data Generator: Efficient real-time loading and preprocessing of MRI slices.
  • Hybrid Loss Function: Combines categorical cross-entropy and Dice loss to address class imbalance.
  • Evaluation Metrics: Dice Coefficient, IoU, Precision, Sensitivity, and Specificity for performance evaluation.

Dataset

The project uses the BraTS2020 dataset, which provides expert-annotated MRI scans labeled into four segmentation classes:

  • Class 0: Background (Non-Tumor Region)
  • Class 1: Necrotic and Non-Enhancing Tumor
  • Class 2: Peritumoral Edema
  • Class 3: Enhancing Tumor

Key Characteristics

  • MRI scans are 3D volumes with dimensions of 240×240×155.
  • The dataset includes four MRI modalities: T1, T1ce, T2, and FLAIR.
  • Significant class imbalance and memory constraints necessitated preprocessing optimizations.

Repository Structure

.
├── U-net Implementation.ipynb   # Jupyter Notebook with full implementation
├── weights_generated/           # Pre-trained model weights
├── requirements.txt             # List of dependencies
├── kaggle.json                  # Kaggle API key for dataset access
├── training.log                 # Logs capturing training metrics

Installation and Setup

  1. Clone this repository:

    git clone https://github.com/username/repository-name.git
  2. Install dependencies:

    pip install -r requirements.txt
  3. Add your Kaggle API key to download the dataset:

    • Place your kaggle.json file in the repository root.
  4. Download the BraTS2020 dataset:

    kaggle datasets download -d awsaf49/brats20-dataset-training-validation

Methodology

Preprocessing Pipeline

  • Slice Selection: Retains only slices 60–135 to focus on tumor-relevant regions.
  • Normalization: Ensures uniformity by applying zero mean and unit variance scaling.
  • Resizing: Reduces slice dimensions to 128×128 for computational efficiency.
  • One-Hot Encoding: Transforms segmentation masks for multi-class predictions.

Model Architecture

  • Encoder: Extracts hierarchical features using convolutional layers and max-pooling.
  • Bottleneck: Employs dropout regularization to prevent overfitting.
  • Decoder: Uses transposed convolutions and skip connections to enhance spatial resolution.
  • Output Layer: Produces multi-class segmentation probabilities using softmax activation.

Usage

Train the Model

  1. Open the U-net Implementation.ipynb notebook.
  2. Execute cells step-by-step to preprocess the data, train the model, and evaluate its performance.

Load Pre-trained Weights

Use the pre-trained weights in the weights_generated/ directory for inference.

Results

  • Training Loss: 0.0206
  • Dice Coefficient: 0.6008
  • Mean IoU: 0.8176
  • Accuracy: 99.35%
  • Precision: 99.38%
  • Sensitivity: 99.22%
  • Specificity: 99.79%

Experiments and Insights

  • Multi-modality input improved segmentation accuracy by 8% compared to single-modality models.
  • Preprocessing reduced training time by 30% without sacrificing performance.
  • The hybrid loss function enhanced segmentation for smaller tumor regions.

Future Work

  • Incorporate Additional Modalities: Extend to include T1 and T2 modalities.
  • 3D U-Net Implementation: Leverage volumetric context for enhanced accuracy.
  • Attention Mechanisms: Explore attention-based models for finer segmentation.
  • Real-World Deployment: Optimize for clinical workflows with improved inference speeds.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published