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.
- 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.
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
- 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.
.
├── 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
-
Clone this repository:
git clone https://github.com/username/repository-name.git
-
Install dependencies:
pip install -r requirements.txt
-
Add your Kaggle API key to download the dataset:
- Place your
kaggle.json
file in the repository root.
- Place your
-
Download the BraTS2020 dataset:
kaggle datasets download -d awsaf49/brats20-dataset-training-validation
- 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.
- 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.
- Open the
U-net Implementation.ipynb
notebook. - Execute cells step-by-step to preprocess the data, train the model, and evaluate its performance.
Use the pre-trained weights in the weights_generated/
directory for inference.
- Training Loss: 0.0206
- Dice Coefficient: 0.6008
- Mean IoU: 0.8176
- Accuracy: 99.35%
- Precision: 99.38%
- Sensitivity: 99.22%
- Specificity: 99.79%
- 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.
- 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.