parvezamu commited on
Commit
95498bc
·
verified ·
1 Parent(s): dfb2159

Fix model card metadata and update documentation

Browse files
Files changed (1) hide show
  1. README.md +178 -114
README.md CHANGED
@@ -1,178 +1,237 @@
1
- # SlicerStrokeSegmentator
2
-
3
- SlicerStrokeSegmentator is a 3D Slicer extension for automated chronic ischemic stroke lesion segmentation from T1-weighted brain MRI using nnU-Net v2.
4
-
5
- The extension performs local inference using a five-fold ensemble of pretrained models and displays predicted lesion segmentations directly in 3D Slicer.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
6
 
7
  ![SlicerStrokeSegmentator screenshot](SlicerStrokeSegmentator/Resources/Screenshots/StrokeSegmentator.png)
8
 
 
 
9
  ## Features
10
 
11
- - Automated chronic ischemic stroke lesion segmentation.
12
- - T1-weighted brain MRI input.
13
- - Five-fold nnU-Net v2 ensemble.
14
- - Local pretrained model directory selection.
15
- - Automatic verification of model checkpoints.
16
- - Model directory saved between Slicer sessions.
17
- - Segmentation results displayed directly in 3D Slicer.
18
- - CPU-based inference.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
19
 
20
  ## Requirements
21
 
22
- - 3D Slicer (tested with version 5.12.4 on Linux).
23
- - Compatible nnU-Net v2 installation in Slicer's Python environment.
24
- - T1-weighted MRI registered to MNI152 1 mm isotropic space.
25
- - Pretrained model weights obtained separately from the authors.
26
- - Sufficient RAM and disk space for inference.
27
 
28
- The extension currently uses CPU inference. Processing time depends on the computer hardware and input data.
29
 
30
- ## Installation
31
 
32
- The extension can be loaded into 3D Slicer from its source directory.
33
 
34
- 1. Download or clone this repository.
35
- 2. Open 3D Slicer.
36
- 3. Load the SlicerStrokeSegmentator scripted module.
37
- 4. Open the Stroke Segmentator module under Segmentation.
38
- 5. Obtain the pretrained model weights from the authors.
39
- 6. Extract the weights into a local directory.
40
- 7. Click "Select Local Model Directory".
41
- 8. Select the nnU-Net results root directory containing Dataset001_StrokeT1w.
42
 
43
- The extension uses ~/stroke_model as its default model directory.
44
 
45
- Installation through the Slicer Extension Manager is subject to acceptance into the Slicer ExtensionsIndex.
46
 
47
- ## Model Directory Structure
48
 
49
- The expected directory structure is:
50
 
51
- stroke_model/
52
- Dataset001_StrokeT1w/
53
- nnUNetTrainerImprovedLossCheckpoints__nnUNetPlans__3d_fullres/
54
- dataset.json
55
- plans.json
56
- fold_0/
57
- checkpoint_final.pth
58
- fold_1/
59
- checkpoint_final.pth
60
- fold_2/
61
- checkpoint_final.pth
62
- fold_3/
63
- checkpoint_final.pth
64
- fold_4/
65
- checkpoint_final.pth
66
 
67
- Select the stroke_model directory, not an individual trainer or fold directory.
68
 
69
- ## Usage
 
 
 
 
 
 
 
 
70
 
71
- 1. Open the Stroke Segmentator module.
72
- 2. Load a T1-weighted MRI registered to MNI152 1 mm space.
73
- 3. Select the MRI in the Input T1w selector.
74
- 4. Select the local pretrained model directory if needed.
75
- 5. Verify that all required model checkpoints are present.
76
- 6. Click "Segment Stroke Lesion".
77
- 7. Wait for inference to finish.
78
- 8. The predicted lesion segmentation will appear in the Slicer scene.
79
 
80
- The extension uses the custom nnU-Net trainer:
81
 
82
- nnUNetTrainerImprovedLossCheckpoints
83
 
84
- All five model folds are combined during prediction.
85
 
86
- ## Public Testing Dataset - ATLAS v3.0 (629 Cases)
87
 
88
- A collection of 629 publicly available ATLAS v3.0 T1-weighted brain MRI scans and their corresponding ground-truth stroke lesion masks is provided for testing SlicerStrokeSegmentator.
89
 
90
- The collection includes:
91
 
92
- - 329 newly released ATLAS v3.0 cases.
93
- - 300 cases from the former ATLAS v2.0 validation dataset.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
94
 
95
- These 629 cases were not included in the original 655-case ATLAS v2.0 training dataset used to develop the segmentation model.
96
 
97
- The images have been registered to MNI152 space for use with the segmentation pipeline. Users should verify that voxel spacing, image geometry, and preprocessing are compatible with the model.
98
 
99
- ### Dataset Download
 
 
 
 
 
100
 
101
- [Download ATLAS v3.0 - 629 Cases (Google Drive)](https://drive.google.com/drive/folders/1kgHygdB5PSDqj0ScFCj-nxuHOd5gPvXk?usp=sharing)
102
 
103
- The dataset is organised into two folders:
104
 
105
- ATLAS_v3.0/
106
- input/
107
- T1-weighted MRI scans
108
- masks/
109
- Ground-truth stroke lesion masks
110
 
111
- The input folder contains the MRI scans, while the masks folder contains their corresponding reference lesion segmentations.
112
 
113
- ### Testing Procedure
114
 
115
- 1. Download a T1-weighted MRI from the input folder.
116
- 2. Open 3D Slicer and select the Stroke Segmentator module.
117
- 3. Load the MRI into Slicer.
118
- 4. Select the pretrained model directory.
119
- 5. Click "Segment Stroke Lesion".
120
- 6. Wait until segmentation is complete.
121
- 7. Load the corresponding ground-truth lesion mask from the masks folder.
122
- 8. Compare the predicted segmentation with the reference mask.
123
 
124
- Suggested evaluation metrics include:
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
125
 
126
  - Dice similarity coefficient (DSC).
127
  - Lesion-wise precision, recall, and F1-score.
128
- - Hausdorff distance (HD95).
129
  - Lesion volume difference.
130
  - Segmentation failure rate.
131
 
132
- These metrics require a separate evaluation procedure and are not automatically calculated by the extension.
133
 
134
- ### Original Dataset Sources
135
 
136
- ATLAS dataset download portal:
137
- https://fcon_1000.projects.nitrc.org/indi/retro/atlas_download.html
138
 
139
- ISLES'26 dataset information:
140
- https://isles-26.grand-challenge.org/dataset/
141
 
142
- The official ISLES'26 challenge evaluates algorithms using native-space MRI. The MNI152-registered testing collection described here is intended for testing this extension and is not an official ISLES'26 submission.
143
 
144
- Users must comply with the original dataset's applicable access, attribution, and redistribution conditions.
145
 
146
- ## Model Access
147
 
148
- Pretrained model weights are not included in this repository.
149
 
150
- The associated research manuscript is currently under preparation. Model weights may be provided to authorised researchers upon request, subject to applicable access conditions.
151
-
152
- Contact:
153
 
154
  - pahm409@aucklanduni.ac.nz
155
  - parvezamu@gmail.com
156
 
157
- The repository will be updated with information about model availability following publication arrangements.
158
-
159
- ## Research and Clinical Use
160
 
161
- This software is intended for research purposes only.
162
 
163
- It is not established as a clinically validated diagnostic tool and should not be used independently for clinical diagnosis, treatment decisions, or patient management.
164
 
165
- Segmentation accuracy may vary depending on MRI acquisition, preprocessing, registration quality, lesion characteristics, and differences between training and evaluation datasets.
166
 
167
  ## Citation
168
 
169
  Ahmad et al. Manuscript in preparation.
170
 
171
- Auckland Bioengineering Institute,
172
- University of Auckland,
173
- New Zealand.
174
 
175
- Please cite the associated publication when it becomes available and acknowledge the original ATLAS dataset publications when using the testing data.
176
 
177
  ## Acknowledgements
178
 
@@ -180,8 +239,13 @@ HRC grant 21/144 IMPRESS.
180
 
181
  ## License
182
 
183
- The extension source code is released under the Apache License, Version 2.0.
184
 
185
- See LICENSE.txt for the complete licence terms.
186
 
187
- Pretrained model weights are distributed separately and may have different access and licensing conditions.
 
 
 
 
 
 
 
 
1
+ ---
2
+ language:
3
+ - en
4
+ tags:
5
+ - medical-imaging
6
+ - stroke
7
+ - lesion-segmentation
8
+ - brain-mri
9
+ - nnunet
10
+ - 3d-slicer
11
+ - pytorch
12
+ pipeline_tag: image-segmentation
13
+ ---
14
+
15
+ # Chronic Stroke Lesion Segmentation — nnU-Net v2
16
+
17
+ Pretrained nnU-Net v2 models for automated chronic ischemic stroke lesion segmentation from T1-weighted brain MRI.
18
+
19
+ The models can be used with the existing NNUNet extension for 3D Slicer, allowing researchers to generate lesion segmentations and visualize the results directly in Slicer.
20
 
21
  ![SlicerStrokeSegmentator screenshot](SlicerStrokeSegmentator/Resources/Screenshots/StrokeSegmentator.png)
22
 
23
+ The model repository includes five trained checkpoints, the nnU-Net configuration files, and the custom BCE+Dice trainer required for model loading.
24
+
25
  ## Features
26
 
27
+ - Automated chronic stroke lesion segmentation from T1-weighted MRI.
28
+ - nnU-Net v2 3D full-resolution architecture.
29
+ - Five-fold ensemble inference.
30
+ - Custom BCE+Dice trainer.
31
+ - Publicly available pretrained model weights.
32
+ - Integration with the existing 3D Slicer NNUNet extension.
33
+ - Local inference without uploading patient images to a remote server.
34
+
35
+ ## Model configuration
36
+
37
+ | Parameter | Value |
38
+ |---|---|
39
+ | Framework | nnU-Net v2 |
40
+ | Architecture configuration | 3d_fullres |
41
+ | Trainer | nnUNetTrainerBCEDice |
42
+ | Plans | nnUNetPlans |
43
+ | Target voxel spacing | 1 × 1 × 1 mm³ |
44
+ | Patch size | 128 × 128 × 128 |
45
+ | Training batch size | 2 |
46
+ | Intensity normalization | ZScoreNormalization |
47
+ | Ensemble | Five folds (0–4) |
48
+ | Input modality | T1-weighted MRI |
49
+
50
+ The target voxel spacing and normalization are specified in the nnU-Net plans. These preprocessing operations do not replace spatial registration.
51
 
52
  ## Requirements
53
 
54
+ - 3D Slicer with the NNUNet extension.
55
+ - Compatible nnU-Net v2 installation.
56
+ - PyTorch.
57
+ - T1-weighted brain MRI prepared consistently with the training data, including registration to MNI152 1 mm space.
58
+ - Sufficient system memory and disk space.
59
 
60
+ Tested environment: 3D Slicer 5.12.4 on Linux, with nnU-Net v2 2.8.1.
61
 
62
+ Successful inference has been demonstrated in this environment. Windows and macOS compatibility have not yet been independently verified.
63
 
64
+ ## Installation and model setup
65
 
66
+ ### 1. Install the NNUNet extension
 
 
 
 
 
 
 
67
 
68
+ Open 3D Slicer, navigate to the Extension Manager, and install the existing NNUNet extension.
69
 
70
+ Restart Slicer if requested.
71
 
72
+ ### 2. Download the pretrained model
73
 
74
+ Download the model repository:
75
 
76
+ https://huggingface.co/parvezamu/stroke-lesion-segmentation
 
 
 
 
 
 
 
 
 
 
 
 
 
 
77
 
78
+ The published model checkpoints are stored under:
79
 
80
+ ```text
81
+ Dataset001_StrokeT1w/
82
+ nnUNetTrainer__nnUNetPlans__3d_fullres/
83
+ fold_0/
84
+ fold_1/
85
+ fold_2/
86
+ fold_3/
87
+ fold_4/
88
+ ```
89
 
90
+ Each fold contains a `checkpoint_final.pth` file.
 
 
 
 
 
 
 
91
 
92
+ The repository also provides the nnU-Net configuration metadata, including `dataset.json` and `plans.json`.
93
 
94
+ ### 3. Install the custom trainer
95
 
96
+ Download:
97
 
98
+ [custom_trainer/nnUNetTrainerBCEDice.py](https://huggingface.co/parvezamu/stroke-lesion-segmentation/blob/main/custom_trainer/nnUNetTrainerBCEDice.py)
99
 
100
+ Copy the trainer into the `nnunetv2/training/nnUNetTrainer/` directory of the Python environment used by the Slicer NNUNet extension.
101
 
102
+ The custom trainer inherits from the standard nnU-Net trainer and defines the BCE+Dice loss implementation. No additional custom loss file is required.
103
 
104
+ For the tested Linux installation, the destination was:
105
+
106
+ ```text
107
+ Slicer-5.12.4-linux-amd64/
108
+ lib/Python/lib/python3.12/site-packages/
109
+ nnunetv2/training/nnUNetTrainer/
110
+ nnUNetTrainerBCEDice.py
111
+ ```
112
+
113
+ The exact location depends on the Slicer installation and operating system.
114
+
115
+ ### 4. Prepare the local model directory
116
+
117
+ The checkpoint metadata identifies the trainer as `nnUNetTrainerBCEDice`.
118
+
119
+ After downloading the model, rename the local trainer directory only from:
120
+
121
+ ```text
122
+ nnUNetTrainer__nnUNetPlans__3d_fullres
123
+ ```
124
+
125
+ to:
126
+
127
+ ```text
128
+ nnUNetTrainerBCEDice__nnUNetPlans__3d_fullres
129
+ ```
130
+
131
+ Arrange the local model files as follows:
132
+
133
+ ```text
134
+ stroke_model/
135
+ Dataset001_StrokeT1w/
136
+ nnUNetTrainerBCEDice__nnUNetPlans__3d_fullres/
137
+ dataset.json
138
+ plans.json
139
+ fold_0/
140
+ checkpoint_final.pth
141
+ fold_1/
142
+ checkpoint_final.pth
143
+ fold_2/
144
+ checkpoint_final.pth
145
+ fold_3/
146
+ checkpoint_final.pth
147
+ fold_4/
148
+ checkpoint_final.pth
149
+ ```
150
 
151
+ This is a local installation adjustment. The original Hugging Face checkpoint directory remains unchanged.
152
 
153
+ ### 5. Run inference in 3D Slicer
154
 
155
+ 1. Open 3D Slicer and launch the NNUNet extension.
156
+ 2. Load a T1-weighted MRI prepared in the required MNI152 space.
157
+ 3. Configure the local model directory and select the appropriate model.
158
+ 4. Select the available trained folds for ensemble inference.
159
+ 5. Run segmentation.
160
+ 6. Review the resulting lesion segmentation in the Slicer scene.
161
 
162
+ The predicted segmentation should be visually inspected, particularly for small lesions, atypical anatomy, and registration errors.
163
 
164
+ ## Input image preparation
165
 
166
+ The model was developed for T1-weighted brain MRI prepared in MNI152 space.
 
 
 
 
167
 
168
+ nnU-Net automatically performs configuration-dependent operations such as voxel resampling and Z-score intensity normalization during inference.
169
 
170
+ However, resampling is not equivalent to anatomical registration.
171
 
172
+ Users should ensure that their input images have undergone spatial preparation consistent with the training pipeline. Differences in registration, skull stripping, image orientation, field of view, or intensity characteristics may affect segmentation performance.
 
 
 
 
 
 
 
173
 
174
+ ## Public testing dataset — ATLAS v3.0 collection
175
+
176
+ A testing collection containing 629 ATLAS cases is available separately:
177
+
178
+ [Download ATLAS testing collection (Google Drive)](https://drive.google.com/drive/folders/1kgHygdB5PSDqj0ScFCj-nxuHOd5gPvXk?usp=sharing)
179
+
180
+ The collection is described as containing:
181
+
182
+ - 329 newly released ATLAS v3.0 cases.
183
+ - 300 cases from the former ATLAS v2.0 validation dataset.
184
+
185
+ These cases are separate from the original 655-case ATLAS v2.0 training dataset used to develop the segmentation model.
186
+
187
+ The testing collection contains T1-weighted MRI images and corresponding reference lesion masks. Users should verify image geometry, preprocessing, case correspondence, and applicable dataset access and redistribution conditions before use.
188
+
189
+ ### Suggested evaluation metrics
190
 
191
  - Dice similarity coefficient (DSC).
192
  - Lesion-wise precision, recall, and F1-score.
193
+ - 95th-percentile Hausdorff distance (HD95).
194
  - Lesion volume difference.
195
  - Segmentation failure rate.
196
 
197
+ These metrics require a separate evaluation procedure and are not automatically calculated by the pretrained model.
198
 
199
+ ### Original dataset source
200
 
201
+ [ATLAS dataset download portal](https://fcon_1000.projects.nitrc.org/indi/retro/atlas_download.html)
 
202
 
203
+ Please acknowledge the original ATLAS dataset publications and comply with their applicable terms.
 
204
 
205
+ ## Model availability
206
 
207
+ The pretrained model checkpoints and custom trainer are publicly available:
208
 
209
+ https://huggingface.co/parvezamu/stroke-lesion-segmentation
210
 
211
+ The associated research manuscript is currently in preparation.
212
 
213
+ For research enquiries:
 
 
214
 
215
  - pahm409@aucklanduni.ac.nz
216
  - parvezamu@gmail.com
217
 
218
+ ## Research and clinical use
 
 
219
 
220
+ For research use only.
221
 
222
+ This model is not established as a clinically validated diagnostic tool and should not be used independently for clinical diagnosis, treatment decisions, or patient management.
223
 
224
+ Segmentation performance may vary with MRI acquisition parameters, lesion size, anatomical changes, registration quality, and differences between training and evaluation datasets.
225
 
226
  ## Citation
227
 
228
  Ahmad et al. Manuscript in preparation.
229
 
230
+ Auckland Bioengineering Institute
231
+ University of Auckland
232
+ New Zealand
233
 
234
+ Please cite the associated publication when available and acknowledge the original ATLAS dataset publications.
235
 
236
  ## Acknowledgements
237
 
 
239
 
240
  ## License
241
 
 
242
 
 
243
 
244
+ The separate SlicerStrokeSegmentator extension source code is released under the Apache License, Version 2.0, as specified in its source repository. That license should not automatically be assumed to apply to the pretrained model weights.
245
+
246
+ ### Successful inference in 3D Slicer
247
+
248
+ The following screenshot shows the predicted chronic stroke lesion segmentation
249
+ overlaid on the T1-weighted MRI (`A207_T1w`) in axial, coronal, and sagittal views.
250
+
251
+ ![Five-fold chronic stroke lesion segmentation using nnU-Net v2 in 3D Slicer](SlicerStrokeSegmentator/Resources/Screenshots/StrokeSegmentator.png)