This repository contains the implementation of deep learning models for Vertebral Body Segmentation with Extraction of Spinal Measurements and Disorder Disease Classification as described in our paper published in Biomedical Signal Processing and Control.
Title: Deep Learning based Vertebral Body Segmentation with Extraction of Spinal Measurements and Disorder Disease Classification
Link: https://www.sciencedirect.com/science/article/abs/pii/S1746809421008272
Citation:
@article{masood2022vertebral,
title={Deep learning based Vertebral Body Segmentation with extraction of spinal measurements and disorder disease classification},
author={Masood, Farhat and others},
journal={Biomedical Signal Processing and Control},
volume={71},
pages={103197},
year={2022},
publisher={Elsevier},
doi={10.1016/j.bspc.2021.103197}
}This project implements state-of-the-art deep learning models for automated vertebral body segmentation from medical images:
- UNet: A fully convolutional network specifically designed for medical image segmentation
- ResNet50-UNet: A hybrid architecture combining ResNet50 encoder with UNet decoder for improved feature extraction
- ✅ Complete implementation of UNet and ResNet50-based segmentation models
- ✅ Data preprocessing and augmentation pipelines
- ✅ Training and evaluation scripts
- ✅ Performance metrics (Dice Score, IoU, Accuracy)
- ✅ Visualization tools for segmentation results
- ✅ Pre-trained model checkpoints
- ✅ Inference on new images
This implementation uses the Vertebral Body Segmentation Dataset available at: https://data.mendeley.com/datasets/k3b363f3vz/2
After downloading, organize your dataset as follows:
data/
├── train/
│ ├── images/
│ │ ├── image_001.nii.gz
│ │ ├── image_002.nii.gz
│ │ └── ...
│ └── masks/
│ ├── mask_001.nii.gz
│ ├── mask_002.nii.gz
│ └── ...
├── val/
│ ├── images/
│ └── masks/
└── test/
├── images/
└── masks/
- Python 3.7 or higher
- CUDA-capable GPU (recommended for training)
- Clone the repository:
git clone https://github.com/farhatmasood/Vertebral-Body-Segmentation.git
cd Vertebral-Body-Segmentation- Install dependencies:
pip install -r requirements.txtTrain the UNet model:
python train.py --model unet --data_dir ./data --epochs 100 --batch_size 8Train the ResNet50-UNet model:
python train.py --model resnet50_unet --data_dir ./data --epochs 100 --batch_size 8Evaluate a trained model:
python evaluate.py --model unet --checkpoint ./checkpoints/unet_best.pth --data_dir ./dataRun inference on new images:
python predict.py --model unet --checkpoint ./checkpoints/unet_best.pth --input ./test_image.nii.gz --output ./prediction.nii.gzYou can customize training parameters by modifying config.yaml or passing command-line arguments. Key parameters include:
--model: Model architecture (unet, resnet50_unet)--epochs: Number of training epochs--batch_size: Batch size for training--lr: Learning rate--data_dir: Path to dataset directory
| Model | Dice Score | IoU | Accuracy |
|---|---|---|---|
| UNet | 0.923 | 0.858 | 0.956 |
| ResNet50-UNet | 0.935 | 0.878 | 0.963 |
Example segmentation outputs can be found in the results/ directory, showing:
- Original CT slices
- Ground truth segmentation masks
- Model predictions
- Overlayed visualizations
Vertebral-Body-Segmentation/
├── models/
│ ├── unet.py # UNet architecture
│ ├── resnet50_unet.py # ResNet50-UNet architecture
│ └── __init__.py
├── utils/
│ ├── dataset.py # Data loading and preprocessing
│ ├── metrics.py # Evaluation metrics
│ ├── visualization.py # Visualization utilities
│ └── __init__.py
├── train.py # Training script
├── evaluate.py # Evaluation script
├── predict.py # Inference script
├── config.yaml # Configuration file
├── requirements.txt # Python dependencies
├── README.md # This file
├── CITATION.bib # Citation information
└── LICENSE # GPL v3 License
The UNet model consists of:
- Encoder (contracting path): 4 downsampling blocks
- Decoder (expanding path): 4 upsampling blocks with skip connections
- Output: Binary segmentation mask
The ResNet50-UNet model features:
- Encoder: Pre-trained ResNet50 backbone
- Decoder: UNet-style upsampling with skip connections
- Enhanced feature extraction through residual connections
The following metrics are used for evaluation:
- Dice Coefficient: Measures overlap between predicted and ground truth segmentation
- Intersection over Union (IoU): Jaccard index for segmentation quality
- Pixel Accuracy: Overall pixel-wise classification accuracy
- Framework: PyTorch
- Loss Function: Combined Binary Cross-Entropy and Dice Loss
- Optimizer: Adam with learning rate scheduling
- Data Augmentation: Random rotations, flips, and intensity variations
- Input Size: 256×256 (2D slices) or 128×128×128 (3D volumes)
Contributions are welcome! Please feel free to submit a Pull Request.
This project is licensed under the GNU General Public License v3.0 - see the LICENSE file for details.
For questions or collaborations, please contact the authors through the paper or open an issue in this repository.
Note: This repository contains the implementation and code for research purposes. For clinical applications, please ensure proper validation and regulatory compliance.