A modular pipeline for 2D slice-wise cardiac MRI segmentation, comparing a custom UNet2D implementation against the self-configuring nnUNet framework on the Medical Segmentation Decathlon (MSD) Task02_Heart dataset.
- Overview
- Project Rationale
- Features
- Pipeline Architecture
- Key Findings
- Repository Structure
- Installation
- Usage
- Results & Visualization
- Contributing
- License
This repository provides an end-to-end pipeline for cardiac MRI segmentation using deep learning techniques. We compare our custom UNet2D implementation with the state-of-the-art nnUNet framework, analyzing performance differences, computational requirements, and implementation complexity.
High-quality segmentation of cardiac MRI volumes is critical for clinical diagnosis and treatment planning. While nnUNet has set a new benchmark by automatically adapting to any medical segmentation task, there is still value in understanding and optimizing a hand-crafted UNet2D architecture under limited compute environments. This repository demonstrates both approaches, highlights their trade-offs, and provides a reusable, end-to-end codebase for future research.
- Input Handling: Accepts complex-valued MRI images by considering real and imaginary parts as separate channels.
- High Capacity Models: With up to 125 million trainable parameters, our implementation is capable of learning intricate patterns for accurate reconstruction.
- Efficient Gradient Flow: Carefully designed skip connections and up-convolutions ensure efficient backpropagation of gradients.
- Customizability: Flexible architecture supporting various configuration options for experimentation.
- Comprehensive Evaluation: Automated quantitative analysis using multiple metrics (Dice, Jaccard, precision, recall).
- Visual Reporting: Generates PDF reports with visualizations for qualitative assessment.
- Download the Task02_Heart dataset from the MSD website (not included in this repo).
- Organize as:
Task02_Heart/ βββ imagesTr/ βββ labelsTr/ βββ imagesTs/
- Configure
data_root
inparameters.yaml
.
- Axial Slice Extraction from 3D NIfTI volumes.
- Intensity Normalization (minβmax scaling).
- On-the-fly Augmentations: random flips, rotations, zoom.
- Custom UNet2D: Fixed encoderβdecoder with skip-connections, mixed-precision training (FP16), Cross-Entropy loss.
- nnUNet: Self-configuring pipeline that selects 2D/3D architectures, patch sizes, hyperparameters, and advanced augmentations automatically.
- Training Script (
Implementation/training.py
):- Adam optimizer + ReduceLROnPlateau scheduler
- WandB logging for real-time metrics
- Checkpointing best validation Dice
- Inference Script (
Implementation/inference.py
):- Loads best model
- Computes Dice, Jaccard, precision, recall on test set
- Generates PDF visualizations
Metric | Custom UNet2D | nnUNet | Ξ |
---|---|---|---|
Average Dice | 0.387 | 0.932 | +0.545 |
Median Dice | 0.439 | 0.933 | +0.494 |
- nnUNet delivers substantially higher segmentation accuracy and more precise mask alignment, thanks to its adaptive architecture and advanced data handling.
- Custom UNet2D remains a viable lightweight solution but requires extensive manual tuning and lacks inter-slice context.
MR-Image-Reconstruction-Using-Deep-Learning/
βββ Data/ # Data processing utilities
βββ Implementation/ # Core implementation files
βββ deprecated/ # Legacy code (maintained for reference)
βββ home/raghuram/ARPL/MR-Image-Reconstruction-Using-Deep-Learning/ # Model results
βββ interface/ # User interface components
βββ nnUNet/ # nnUNet integration
βββ .gitignore # Git ignore file
βββ LICENSE # Project license
βββ LICENSE.md # License details
βββ README.md # This file
βββ requirements.txt # Dependencies
βββ resume_robotics.pdf # Additional documentation
βββ task_HSS.pdf # Task definition
-
Clone the repository:
git clone https://github.com/starceees/MR-Image-Reconstruction-Using-Deep-Learning.git cd MR-Image-Reconstruction-Using-Deep-Learning
-
Install dependencies:
pip install -r requirements.txt
-
Download and prepare the data:
- Download the Task02_Heart dataset from Medical Segmentation Decathlon
- Place it in the expected directory structure
- Update the configuration in
parameters.yaml
python Implementation/training.py
python Implementation/inference.py
Follow nnUNet's official instructions to train on Task02_Heart. Place results under nnUNet/nnunet_inference/
for direct comparison.
Our implementation automatically generates comprehensive PDF reports with segmentation visualizations and quantitative metrics. Example visualizations are included in the home/raghuram/ARPL/MR-Image-Reconstruction-Using-Deep-Learning/
directory.
Contributions are welcome! Please feel free to submit a Pull Request.
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature
) - Commit your changes (
git commit -m 'Add some amazing feature'
) - Push to the branch (
git push origin feature/amazing-feature
) - Open a Pull Request
This project is licensed under the terms of the LICENSE file included in the repository. See LICENSE for more details.