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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# MS3SEG: Pre-trained Models for MS Lesion Segmentation
|
| 2 |
+
|
| 3 |
+
[](https://doi.org/10.6084/m9.figshare.30393475)
|
| 4 |
+
[](https://doi.org/10.6084/m9.figshare.30393475)
|
| 5 |
+
[](https://github.com/Mahdi-Bashiri/MS3SEG)
|
| 6 |
+
[](https://creativecommons.org/licenses/by/4.0/)
|
| 7 |
+
|
| 8 |
+
Pre-trained deep learning models for Multiple Sclerosis lesion segmentation from the **MS3SEG dataset**.
|
| 9 |
+
|
| 10 |
+
> **Note:** These are representative models from Fold 4 of our 5-fold cross-validation. Complete training code and all fold results are available in our [GitHub repository](https://github.com/Mahdi-Bashiri/MS3SEG).
|
| 11 |
+
|
| 12 |
+
---
|
| 13 |
+
|
| 14 |
+
## π Repository Contents
|
| 15 |
+
|
| 16 |
+
```
|
| 17 |
+
MS3SEG/
|
| 18 |
+
βββ kfold_brain_segmentation_20250924_232752_unified_focal_loss/models/
|
| 19 |
+
β βββ binary_abnormal_wmh/ # Binary MS lesion segmentation
|
| 20 |
+
β β βββ u-net_fold_4_best.h5
|
| 21 |
+
β β βββ unet++_fold_4_best.h5
|
| 22 |
+
β β βββ unetr_fold_4_best.h5
|
| 23 |
+
β β βββ swinunetr_fold_4_best.h5
|
| 24 |
+
β β
|
| 25 |
+
β βββ binary_ventricles/ # Binary ventricle segmentation
|
| 26 |
+
β β βββ u-net_fold_4_best.h5
|
| 27 |
+
β β βββ unet++_fold_4_best.h5
|
| 28 |
+
β β βββ unetr_fold_4_best.h5
|
| 29 |
+
β β βββ swinunetr_fold_4_best.h5
|
| 30 |
+
β β
|
| 31 |
+
β βββ multi_class/ # 4-class tri-mask segmentation
|
| 32 |
+
β β βββ u-net_fold_4_best.h5
|
| 33 |
+
β β βββ unet++_fold_4_best.h5
|
| 34 |
+
β β βββ unetr_fold_4_best.h5
|
| 35 |
+
β β βββ swinunetr_fold_4_best.h5
|
| 36 |
+
β
|
| 37 |
+
βββ figures/
|
| 38 |
+
β βββ training_curves/ # Loss and metrics across epochs
|
| 39 |
+
β βββ sample_predictions/ # Visual results from paper
|
| 40 |
+
β
|
| 41 |
+
βββ config/
|
| 42 |
+
β βββ experiment_config.json # Model training configuration
|
| 43 |
+
βββ README.md # This file
|
| 44 |
+
```
|
| 45 |
+
|
| 46 |
+
**Total Size:** ~1.2 GB (12 model files)
|
| 47 |
+
|
| 48 |
+
---
|
| 49 |
+
|
| 50 |
+
## π― Model Overview
|
| 51 |
+
|
| 52 |
+
### Segmentation Scenarios
|
| 53 |
+
|
| 54 |
+
| Scenario | Classes | Description |
|
| 55 |
+
|----------|---------|-------------|
|
| 56 |
+
| **Multi-class** | 4 | Background, Ventricles, Normal WMH, Abnormal WMH (MS lesions) |
|
| 57 |
+
| **Binary Lesion** | 2 | MS lesions vs. everything else |
|
| 58 |
+
| **Binary Ventricle** | 2 | Ventricles vs. everything else |
|
| 59 |
+
|
| 60 |
+
### Model Architectures
|
| 61 |
+
|
| 62 |
+
- **U-Net**: Classic encoder-decoder with skip connections
|
| 63 |
+
- **U-Net++**: Nested skip pathways for improved feature propagation
|
| 64 |
+
- **UNETR**: Vision Transformer encoder with CNN decoder
|
| 65 |
+
- **Swin UNETR**: Hierarchical shifted-window attention
|
| 66 |
+
|
| 67 |
+
All models trained on **256Γ256 axial FLAIR images** from 64 patients (Fold 4 training set).
|
| 68 |
+
|
| 69 |
+
---
|
| 70 |
+
|
| 71 |
+
## π Performance (Fold 4 Validation Results)
|
| 72 |
+
|
| 73 |
+
### Multi-Class Segmentation (Dice Score)
|
| 74 |
+
|
| 75 |
+
| Model | Ventricles | Normal WMH | Abnormal WMH | Mean |
|
| 76 |
+
|-------|:----------:|:----------:|:------------:|:----:|
|
| 77 |
+
| **U-Net** | **0.8967** | **0.5935** | **0.6709** | **0.7204** |
|
| 78 |
+
| U-Net++ | 0.8904 | 0.5881 | 0.6512 | 0.7099 |
|
| 79 |
+
| UNETR | 0.8401 | 0.4692 | 0.6632 | 0.6575 |
|
| 80 |
+
| Swin UNETR | 0.8608 | 0.5203 | 0.5920 | 0.6577 |
|
| 81 |
+
|
| 82 |
+
### Binary Lesion Segmentation
|
| 83 |
+
|
| 84 |
+
| Model | Dice | IoU | HD95 (mm) |
|
| 85 |
+
|-------|:----:|:---:|:---------:|
|
| 86 |
+
| **U-Net** | **0.7407** | 0.5882 | 32.64 |
|
| 87 |
+
| U-Net++ | 0.5930 | 0.4215 | 35.12 |
|
| 88 |
+
| UNETR | 0.6632 | 0.4963 | 40.85 |
|
| 89 |
+
| Swin UNETR | 0.5841 | 0.4127 | 38.19 |
|
| 90 |
+
|
| 91 |
+
### Binary Ventricle Segmentation
|
| 92 |
+
|
| 93 |
+
| Model | Dice | IoU | HD95 (mm) |
|
| 94 |
+
|-------|:----:|:---:|:---------:|
|
| 95 |
+
| **U-Net** | **0.8967** | 0.8130 | 9.52 |
|
| 96 |
+
| U-Net++ | 0.8904 | 0.8026 | 10.18 |
|
| 97 |
+
| Swin UNETR | 0.8608 | 0.7560 | 12.73 |
|
| 98 |
+
| UNETR | 0.8401 | 0.7240 | 14.92 |
|
| 99 |
+
|
| 100 |
+
*Results are from validation set of Fold 4. See [paper](https://doi.org/10.6084/m9.figshare.30393475) for complete 5-fold statistics.*
|
| 101 |
+
|
| 102 |
+
---
|
| 103 |
+
|
| 104 |
+
## π Quick Start
|
| 105 |
+
|
| 106 |
+
### Installation
|
| 107 |
+
|
| 108 |
+
```bash
|
| 109 |
+
pip install tensorflow>=2.10.0 nibabel numpy
|
| 110 |
+
```
|
| 111 |
+
|
| 112 |
+
### Load and Use Models
|
| 113 |
+
|
| 114 |
+
```python
|
| 115 |
+
from tensorflow import keras
|
| 116 |
+
from huggingface_hub import hf_hub_download
|
| 117 |
+
import numpy as np
|
| 118 |
+
|
| 119 |
+
# Download model
|
| 120 |
+
model_path = hf_hub_download(
|
| 121 |
+
repo_id="Bawil/MS3SEG",
|
| 122 |
+
filename="models/multi_class/U-Net_fold4.h5"
|
| 123 |
+
)
|
| 124 |
+
|
| 125 |
+
# Load model
|
| 126 |
+
model = keras.models.load_model(model_path, compile=False)
|
| 127 |
+
|
| 128 |
+
# Prepare your data (256x256 FLAIR image)
|
| 129 |
+
# image shape: (batch, 256, 256, 1)
|
| 130 |
+
predictions = model.predict(image)
|
| 131 |
+
|
| 132 |
+
# For multi-class: get class labels
|
| 133 |
+
pred_classes = np.argmax(predictions, axis=-1)
|
| 134 |
+
# Classes: 0=background, 1=ventricles, 2=normal WMH, 3=abnormal WMH
|
| 135 |
+
|
| 136 |
+
# For binary: apply threshold
|
| 137 |
+
pred_binary = (predictions > 0.5).astype(np.uint8)
|
| 138 |
+
```
|
| 139 |
+
|
| 140 |
+
### Download All Models for One Scenario
|
| 141 |
+
|
| 142 |
+
```python
|
| 143 |
+
from huggingface_hub import snapshot_download
|
| 144 |
+
|
| 145 |
+
# Download entire scenario folder
|
| 146 |
+
snapshot_download(
|
| 147 |
+
repo_id="Bawil/MS3SEG",
|
| 148 |
+
allow_patterns="models/multi_class/*",
|
| 149 |
+
local_dir="./ms3seg_models"
|
| 150 |
+
)
|
| 151 |
+
```
|
| 152 |
+
|
| 153 |
+
---
|
| 154 |
+
|
| 155 |
+
## π Input Requirements
|
| 156 |
+
|
| 157 |
+
- **Format**: NIfTI (.nii.gz) or NumPy array
|
| 158 |
+
- **Modality**: T2-FLAIR (axial plane)
|
| 159 |
+
- **Dimensions**: 256 Γ 256 pixels
|
| 160 |
+
- **Channels**: 1 (grayscale)
|
| 161 |
+
- **Preprocessing**:
|
| 162 |
+
- Co-registered to FLAIR space
|
| 163 |
+
- Brain-extracted
|
| 164 |
+
- Intensity normalized to [0, 1]
|
| 165 |
+
- Voxel spacing: ~0.9 Γ 0.9 Γ 5.7 mmΒ³
|
| 166 |
+
|
| 167 |
+
See [preprocessing scripts](https://github.com/Mahdi-Bashiri/MS3SEG/tree/main/preprocessing) in our GitHub repository.
|
| 168 |
+
|
| 169 |
+
---
|
| 170 |
+
|
| 171 |
+
## π Dataset Information
|
| 172 |
+
|
| 173 |
+
**MS3SEG** is a Multiple Sclerosis MRI dataset with unique **tri-mask annotations**:
|
| 174 |
+
|
| 175 |
+
- **100 patients** from Iranian cohort (1.5T Toshiba scanner)
|
| 176 |
+
- **~2000 annotated slices** with expert consensus
|
| 177 |
+
- **4 annotation classes**: Background, Ventricles, Normal WMH, Abnormal WMH
|
| 178 |
+
- **Multiple sequences**: T1w, T2w, T2-FLAIR (axial + sagittal)
|
| 179 |
+
|
| 180 |
+
**Dataset Access:** [Figshare Repository](https://doi.org/10.6084/m9.figshare.30393475) (CC-BY-4.0 License)
|
| 181 |
+
|
| 182 |
+
---
|
| 183 |
+
|
| 184 |
+
## π§ Model Training Details
|
| 185 |
+
|
| 186 |
+
All models were trained with:
|
| 187 |
+
|
| 188 |
+
- **Loss Function**: Unified Focal Loss (combining Dice and Focal components)
|
| 189 |
+
- **Optimizer**: Adam (lr=1e-4)
|
| 190 |
+
- **Batch Size**: 4
|
| 191 |
+
- **Epochs**: 100 (with early stopping, patience=10)
|
| 192 |
+
- **Data Split**: 64 train / 16 validation patients (Fold 4)
|
| 193 |
+
- **Framework**: TensorFlow 2.10+
|
| 194 |
+
|
| 195 |
+
Complete training configuration available in `config.json`.
|
| 196 |
+
|
| 197 |
+
---
|
| 198 |
+
|
| 199 |
+
## π Citation
|
| 200 |
+
|
| 201 |
+
If you use these models in your research, please cite our paper:
|
| 202 |
+
|
| 203 |
+
```bibtex
|
| 204 |
+
@article{bashiri2026ms3seg,
|
| 205 |
+
title={A Multiple Sclerosis MRI Dataset with Tri-Mask Annotations for Lesion Segmentation},
|
| 206 |
+
author={Bashiri Bawil, Mahdi and Shamsi, Mousa and Ghalehasadi, Aydin and Jafargholkhanloo, Ali Fahmi and Shakeri Bavil, Abolhassan},
|
| 207 |
+
journal={Scientific Data},
|
| 208 |
+
year={2026},
|
| 209 |
+
doi={10.6084/m9.figshare.30393475},
|
| 210 |
+
publisher={Nature Publishing Group}
|
| 211 |
+
}
|
| 212 |
+
```
|
| 213 |
+
|
| 214 |
+
---
|
| 215 |
+
|
| 216 |
+
## π Resources
|
| 217 |
+
|
| 218 |
+
- **π Paper**: [Scientific Data](https://doi.org/10.6084/m9.figshare.30393475)
|
| 219 |
+
- **πΎ Dataset**: [Figshare](https://doi.org/10.6084/m9.figshare.30393475)
|
| 220 |
+
- **π» Code**: [GitHub](https://github.com/Mahdi-Bashiri/MS3SEG)
|
| 221 |
+
- **π§ Contact**: mehdi.bashiri.b@gmail.com
|
| 222 |
+
|
| 223 |
+
---
|
| 224 |
+
|
| 225 |
+
## β οΈ Important Notes
|
| 226 |
+
|
| 227 |
+
1. **Fold 4 Only**: These models represent one fold (Fold 4) from our 5-fold cross-validation. They demonstrate representative performance but should not be considered the final "best" models across all folds.
|
| 228 |
+
|
| 229 |
+
2. **Research Use**: These models are provided for research purposes. Clinical validation is required before any diagnostic application.
|
| 230 |
+
|
| 231 |
+
3. **Data Compatibility**: Models expect preprocessed data matching our pipeline. See [preprocessing documentation](https://github.com/Mahdi-Bashiri/MS3SEG/tree/main/preprocessing).
|
| 232 |
+
|
| 233 |
+
4. **Complete Results**: For all 5 folds and comprehensive evaluation, see our [GitHub repository](https://github.com/Mahdi-Bashiri/MS3SEG) and [paper](https://doi.org/10.6084/m9.figshare.30393475).
|
| 234 |
+
|
| 235 |
+
5. **Storage Considerations**: Full 5-fold model collection (38GB) is available upon request. These representative Fold 4 models (6GB) are sufficient for most use cases.
|
| 236 |
+
|
| 237 |
+
---
|
| 238 |
+
|
| 239 |
+
## π License
|
| 240 |
+
|
| 241 |
+
**Models**: CC-BY-4.0 (same as dataset)
|
| 242 |
+
**Code**: MIT License (see [GitHub](https://github.com/Mahdi-Bashiri/MS3SEG))
|
| 243 |
+
|
| 244 |
+
You are free to use, modify, and distribute these models with appropriate attribution.
|
| 245 |
+
|
| 246 |
+
---
|
| 247 |
+
|
| 248 |
+
## π Acknowledgments
|
| 249 |
+
|
| 250 |
+
Data acquired at Golgasht Medical Imaging Center, Tabriz, Iran. Ethics approval: Tabriz University of Medical Sciences (IR.TBZMED.REC.1402.902).
|
| 251 |
+
|
| 252 |
+
---
|
| 253 |
+
|
| 254 |
+
<div align="center">
|
| 255 |
+
|
| 256 |
+
**Made by the MS3SEG Team**
|
| 257 |
+
|
| 258 |
+
[GitHub](https://github.com/Mahdi-Bashiri/MS3SEG) β’ [Paper](https://doi.org/10.6084/m9.figshare.30393475) β’ [Dataset](https://doi.org/10.6084/m9.figshare.30393475)
|
| 259 |
+
|
| 260 |
+
</div>
|