Spaces:
Runtime error
Runtime error
UI updated
Browse files
app.py
CHANGED
@@ -94,13 +94,14 @@ st.set_page_config(
|
|
94 |
|
95 |
# Sidebar content
|
96 |
with st.sidebar:
|
97 |
-
st.title("Segmenting vessels in the brain from a 3D Magnetic Resonance Angiograph
|
98 |
st.markdown("""
|
99 |
This application allows you to upload a 3D NIfTI file (dims: H x W x D, where the final dim is the slice dim in the axial plane), process it through a pre-trained 3D model (from DS6 and other related works), and download the output as a `.nii.gz` file containing the vessel segmentation.
|
100 |
|
101 |
**Instructions**:
|
102 |
-
- Upload your 3D NIfTI file (`.nii` or `.nii.gz`).
|
103 |
-
- Select a model from the dropdown menu.
|
|
|
104 |
- Click the "Process" button to generate the latent factors.
|
105 |
""")
|
106 |
st.markdown("---")
|
@@ -108,7 +109,34 @@ with st.sidebar:
|
|
108 |
|
109 |
# Main content
|
110 |
st.header("DS6, Deformation-Aware Semi-Supervised Learning: Application to Small Vessel Segmentation with Noisy Training Data")
|
|
|
|
|
111 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
112 |
# File uploader
|
113 |
uploaded_file = st.file_uploader(
|
114 |
"Please upload a 3D NIfTI file (.nii or .nii.gz)",
|
@@ -116,15 +144,28 @@ uploaded_file = st.file_uploader(
|
|
116 |
)
|
117 |
|
118 |
# Model selection
|
119 |
-
model_options = [
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
120 |
selected_model = st.selectbox("Select a pretrained model:", model_options)
|
121 |
|
122 |
# Mode selection
|
123 |
-
mode_options = ["Full volume inference", "Patch-based inference [Default for
|
124 |
-
selected_mode = st.selectbox("Select the
|
125 |
|
126 |
# Parameters for patch-based inference
|
127 |
-
if selected_mode == "Patch-based inference [Default for
|
128 |
col1, col2, col3 = st.columns(3)
|
129 |
with col1:
|
130 |
patch_size = st.number_input("Patch size:", min_value=1, value=64)
|
@@ -201,7 +242,7 @@ if uploaded_file is not None and process_button:
|
|
201 |
st.info("Running full volume inference...")
|
202 |
output = infer_full_vol(tensor, model)
|
203 |
else:
|
204 |
-
st.info("Running patch-based inference [Default for
|
205 |
output = infer_patch_based(tensor, model, patch_size=patch_size, stride_length=stride_length, stride_width=stride_width, stride_depth=stride_depth, batch_size=batch_size, num_worker=num_worker)
|
206 |
|
207 |
st.success("Processing complete.")
|
@@ -237,4 +278,69 @@ if uploaded_file is not None and process_button:
|
|
237 |
elif uploaded_file is None:
|
238 |
st.info("Awaiting file upload...")
|
239 |
elif not process_button:
|
240 |
-
st.info("Click the 'Process' button to start processing.")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
94 |
|
95 |
# Sidebar content
|
96 |
with st.sidebar:
|
97 |
+
st.title("Segmenting vessels in the brain from a 3D Magnetic Resonance Angiograph | DS6")
|
98 |
st.markdown("""
|
99 |
This application allows you to upload a 3D NIfTI file (dims: H x W x D, where the final dim is the slice dim in the axial plane), process it through a pre-trained 3D model (from DS6 and other related works), and download the output as a `.nii.gz` file containing the vessel segmentation.
|
100 |
|
101 |
**Instructions**:
|
102 |
+
- Upload your 3D NIfTI file (`.nii` or `.nii.gz`). The model was trained on `7T MRA-ToF` data, but it should work on other field strengths as well.
|
103 |
+
- Select a pretrained model from the dropdown menu.
|
104 |
+
- Select the inference mode (full volume or patch-based) from the dropdown menu.
|
105 |
- Click the "Process" button to generate the latent factors.
|
106 |
""")
|
107 |
st.markdown("---")
|
|
|
109 |
|
110 |
# Main content
|
111 |
st.header("DS6, Deformation-Aware Semi-Supervised Learning: Application to Small Vessel Segmentation with Noisy Training Data")
|
112 |
+
st.markdown("""
|
113 |
+
This application can be used to perform vessel segmentation by uploading a `Magnetic Resonance Angiograph (MRA-ToF)`, ideally acquired at 7T, but it should also work on other field strengths, in NIFTI format (.nii or .nii.gz).
|
114 |
|
115 |
+
The list of weights includes those from the original [DS6 paper](https://doi.org/10.3390/jimaging8100259), from the [SMILE-UHURA challenge](https://doi.org/10.7303/syn47164761), from a follow-up research [SPOCKMIP](https://arxiv.org/abs/2407.08655), as well as a [fine-tuned version](https://www.medrxiv.org/content/10.1101/2024.10.03.24314845v1) of the DS6 model (trained on the SMILE-UHURA dataset) using the Cambridge 7T Cerebral Small Vessel Disease (CamSVD) dataset, which contains data from subjects with lacunar strokes with SVD, non-lacunar strokes without SVD, and healthy controls.
|
116 |
+
|
117 |
+
Segmentation can be performed in 2 different inference modes: full volume inference and patch-based inference. All these research works used patch-based inference. However, if the volume is not large enough, and only large vessels are to be segmented, full volume inference may be performed, which is significantly faster. Nevertheless, full volume inference might result in an out-of-memory error (if the volume is very large) and may not segment the small vessels properly.
|
118 |
+
""")
|
119 |
+
with st.expander("List of available pretrained models"):
|
120 |
+
st.markdown(
|
121 |
+
"""
|
122 |
+
| Model Name | Description |
|
123 |
+
|------------|-------------|
|
124 |
+
| `DS6_UNet3D_woDeform` | UNet 3D, trained without deformation-aware learning |
|
125 |
+
| `DS6_UNetMSS3D_woDeform` | UNet MSS 3D, trained without deformation-aware learning |
|
126 |
+
| `DS6_UNetMSS3D_wDeform` | UNet MSS 3D, trained with deformation-aware learning [Proposed method, DS6] |
|
127 |
+
| `SMILEUHURA_DS6_UNet3D_woDeform` | UNet 3D, trained without deformation-aware learning on the SMILE-UHURA dataset |
|
128 |
+
| `SMILEUHURA_DS6_UNetMSS3D_woDeform` | UNet MSS 3D, trained without deformation-aware learning on the SMILE-UHURA dataset |
|
129 |
+
| `SMILEUHURA_DS6_UNetMSS3D_wDeform` | UNet MSS 3D, trained with deformation-aware learning on the SMILE-UHURA dataset |
|
130 |
+
| `SMILEUHURA_neuRoSliCCe_SPOCKMIP_UNetMSS3D_MIP` | UNet MSS 3D, trained with MIP (Maximum Intensity Projection) loss [Proposed method, SPOCKMIP] |
|
131 |
+
| `SMILEUHURA_neuRoSliCCe_SPOCKMIP_UNetMSS3D_mMIP` | UNet MSS 3D, trained with Multi-axis MIP loss [Proposed method, SPOCKMIP] |
|
132 |
+
| `SMILEUHURA_SPOCKMIP_UNet3D_MIP` | UNet 3D, trained with MIP (Maximum Intensity Projection) loss [Proposed method, SPOCKMIP] |
|
133 |
+
| `SMILEUHURA_SPOCKMIP_UNet3D_mMIP` | UNet 3D, trained with Multi-axis MIP loss [Proposed method, SPOCKMIP] |
|
134 |
+
| `SMILEUHURA_neuRoSliCCe_SPOCKMIP_UNetMSS3D_DS6MIP` | UNet MSS 3D, trained with deformation-aware learning, and then with MIP loss |
|
135 |
+
| `SMILEUHURA_DS6_CamSVD_UNetMSS3D_wDeform` | UNet MSS 3D, initially trained with deformation-aware learning on the SMILE-UHURA dataset, and then fine-tuned on the CamSVD dataset with deformation-aware learning |
|
136 |
+
"""
|
137 |
+
)
|
138 |
+
st.markdown("---")
|
139 |
+
|
140 |
# File uploader
|
141 |
uploaded_file = st.file_uploader(
|
142 |
"Please upload a 3D NIfTI file (.nii or .nii.gz)",
|
|
|
144 |
)
|
145 |
|
146 |
# Model selection
|
147 |
+
model_options = [
|
148 |
+
"DS6_UNet3D_woDeform",
|
149 |
+
"DS6_UNetMSS3D_woDeform",
|
150 |
+
"DS6_UNetMSS3D_wDeform",
|
151 |
+
"SMILEUHURA_DS6_UNet3D_woDeform",
|
152 |
+
"SMILEUHURA_DS6_UNetMSS3D_woDeform",
|
153 |
+
"SMILEUHURA_DS6_UNetMSS3D_wDeform",
|
154 |
+
"SMILEUHURA_neuRoSliCCe_SPOCKMIP_UNetMSS3D_MIP",
|
155 |
+
"SMILEUHURA_neuRoSliCCe_SPOCKMIP_UNetMSS3D_mMIP",
|
156 |
+
"SMILEUHURA_SPOCKMIP_UNet3D_MIP",
|
157 |
+
"SMILEUHURA_SPOCKMIP_UNet3D_mMIP",
|
158 |
+
"SMILEUHURA_neuRoSliCCe_SPOCKMIP_UNetMSS3D_DS6MIP",
|
159 |
+
"SMILEUHURA_DS6_CamSVD_UNetMSS3D_wDeform"
|
160 |
+
]
|
161 |
selected_model = st.selectbox("Select a pretrained model:", model_options)
|
162 |
|
163 |
# Mode selection
|
164 |
+
mode_options = ["Full volume inference", "Patch-based inference [Default for all the published works]"]
|
165 |
+
selected_mode = st.selectbox("Select the inference mode:", mode_options)
|
166 |
|
167 |
# Parameters for patch-based inference
|
168 |
+
if selected_mode == "Patch-based inference [Default for all the published works]":
|
169 |
col1, col2, col3 = st.columns(3)
|
170 |
with col1:
|
171 |
patch_size = st.number_input("Patch size:", min_value=1, value=64)
|
|
|
242 |
st.info("Running full volume inference...")
|
243 |
output = infer_full_vol(tensor, model)
|
244 |
else:
|
245 |
+
st.info("Running patch-based inference [Default for all the published works]...")
|
246 |
output = infer_patch_based(tensor, model, patch_size=patch_size, stride_length=stride_length, stride_width=stride_width, stride_depth=stride_depth, batch_size=batch_size, num_worker=num_worker)
|
247 |
|
248 |
st.success("Processing complete.")
|
|
|
278 |
elif uploaded_file is None:
|
279 |
st.info("Awaiting file upload...")
|
280 |
elif not process_button:
|
281 |
+
st.info("Click the 'Process' button to start processing.")
|
282 |
+
|
283 |
+
# Footer
|
284 |
+
st.markdown(
|
285 |
+
"""
|
286 |
+
---
|
287 |
+
## Credits
|
288 |
+
If you like this application, please click on **"Like"** on the top left!
|
289 |
+
|
290 |
+
If you use this application and/or any of these models, please cite the following paper:
|
291 |
+
|
292 |
+
```
|
293 |
+
@Article{chatterjee2022ds6,
|
294 |
+
AUTHOR = {Chatterjee, Soumick and Prabhu, Kartik and Pattadkal, Mahantesh and Bortsova, Gerda and Sarasaen, Chompunuch and Dubost, Florian and Mattern, Hendrik and de Bruijne, Marleen and Speck, Oliver and Nürnberger, Andreas},
|
295 |
+
TITLE = {DS6, Deformation-Aware Semi-Supervised Learning: Application to Small Vessel Segmentation with Noisy Training Data},
|
296 |
+
JOURNAL = {Journal of Imaging},
|
297 |
+
VOLUME = {8},
|
298 |
+
YEAR = {2022},
|
299 |
+
NUMBER = {10},
|
300 |
+
ARTICLE-NUMBER = {259},
|
301 |
+
URL = {https://www.mdpi.com/2313-433X/8/10/259},
|
302 |
+
ISSN = {2313-433X},
|
303 |
+
DOI = {10.3390/jimaging8100259}
|
304 |
+
}
|
305 |
+
```
|
306 |
+
|
307 |
+
If you use one of the models with the name starting with `SMILEUHURA`, please addiitonally cite the following paper:
|
308 |
+
|
309 |
+
```
|
310 |
+
@article{chatterjee2023smile,
|
311 |
+
title={SMILE-UHURA Challenge},
|
312 |
+
author={Chatterjee, S and Mattern, H and Dubost, F and Schreiber, S and Nürnberger, A and Speck, O},
|
313 |
+
year={2023},
|
314 |
+
doi = {10.7303/syn47164761},
|
315 |
+
URL = {https://doi.org/10.7303/syn47164761}
|
316 |
+
}
|
317 |
+
```
|
318 |
+
|
319 |
+
If you use one of the models that contains `SPOCKMIP` in its name, please addiitonally cite the following paper:
|
320 |
+
|
321 |
+
```
|
322 |
+
@article{radhakrishna2024spockmip,
|
323 |
+
title={SPOCKMIP: Segmentation of Vessels in MRAs with Enhanced Continuity using Maximum Intensity Projection as Loss},
|
324 |
+
author={Radhakrishna, Chethan and Chintalapati, Karthikesh Varma and Kumar, Sri Chandana Hudukula Ram and Sutrave, Raviteja and Mattern, Hendrik and Speck, Oliver and N{\"u}rnberger, Andreas and Chatterjee, Soumick},
|
325 |
+
journal={arXiv preprint arXiv:2407.08655},
|
326 |
+
year={2024}
|
327 |
+
}
|
328 |
+
```
|
329 |
+
|
330 |
+
If you use the `SMILEUHURA_DS6_CamSVD_UNetMSS3D_wDeform` model (i.e. fine-tuned on the CamSVD dataset), please addiitonally cite the following paper:
|
331 |
+
|
332 |
+
```
|
333 |
+
@article{ruiDS62024,
|
334 |
+
author = {Li, Rui and Chatterjee, Soumick and Jiaerken, Yeerfan and Radhakrishna, Chethan and Benjamin, Philip and Nannoni, Stefania and Tozer, Daniel J. and Markus, Hugh and Rodgers, Christopher T.},
|
335 |
+
title = {A Deep Learning Pipeline for Analysis of the 3D Morphology of the Cerebral Small Perforating Arteries from Time-of-Flight 7 Tesla MRI},
|
336 |
+
year = {2024},
|
337 |
+
doi = {10.1101/2024.10.03.24314845},
|
338 |
+
publisher = {Cold Spring Harbor Laboratory Press},
|
339 |
+
URL = {https://www.medrxiv.org/content/early/2024/10/04/2024.10.03.24314845},
|
340 |
+
journal = {medRxiv}
|
341 |
+
}
|
342 |
+
|
343 |
+
```
|
344 |
+
|
345 |
+
"""
|
346 |
+
)
|