Skip to content

Commit f6a1eed

Browse files
Create deepedit tutorial (#661)
* Create deepedit tutorial Signed-off-by: Andres Diaz-Pinto <[email protected]> * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Update train file Signed-off-by: Andres Diaz-Pinto <[email protected]> * Move custom transforms and interaction to MONAI core Signed-off-by: Andres Diaz-Pinto <[email protected]> * Update imports from MONAI Signed-off-by: Andres Diaz-Pinto <[email protected]> * Update Notebook and Readme Signed-off-by: Andres Diaz-Pinto <[email protected]> * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Fix static errors in Notebook Signed-off-by: Andres Diaz-Pinto <[email protected]> * Fix spaces autofix Signed-off-by: Andres Diaz-Pinto <[email protected]> * Update DeepEdit transform names Signed-off-by: Andres Diaz-Pinto <[email protected]> * Update Readme Signed-off-by: Andres Diaz-Pinto <[email protected]> * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Address first round of comments Signed-off-by: Andres Diaz-Pinto <[email protected]> * Fix static issues Signed-off-by: Andres Diaz-Pinto <[email protected]> * Fix static Signed-off-by: Andres Diaz-Pinto <[email protected]> * Fix static erros Signed-off-by: Andres Diaz-Pinto <[email protected]> * Address second round of comments Signed-off-by: Andres Diaz-Pinto <[email protected]> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
1 parent 6b1d67b commit f6a1eed

File tree

7 files changed

+1110
-0
lines changed

7 files changed

+1110
-0
lines changed

README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,12 @@ This tutorial demonstrates the use of MONAI for training of registration and seg
130130
#### [Deepgrow](./deepgrow)
131131
The example show how to train/validate a 2D/3D deepgrow model. It also demonstrates running an inference for trained deepgrow models.
132132

133+
**DeepEdit**
134+
#### [DeepEdit](./deepedit/ignite)
135+
This example shows how to train/test a DeepEdit model. In this tutorial there is a Notebook that shows how to run
136+
inference on a pretrained DeepEdit model.
137+
138+
133139
**deployment**
134140
#### [BentoML](./deployment/bentoml)
135141
This is a simple example of training and deploying a MONAI network with [BentoML](https://www.bentoml.ai/) as a web server, either locally using the BentoML respository or as a containerized service.

deepedit/ignite/README.md

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
# DeepEdit
2+
3+
4+
DeepEdit is a method that combines an automatic and a semi-automatic approach for 3D medical images into a
5+
single deep learning-based model. DeepEdit has three working modes: first, it can be used in click-free
6+
inference mode (similar to a regular segmentation network), providing fully-automatic segmentation predictions which
7+
can be used as a form of initialisation; second, it allows users to provide clicks to initialise and guide
8+
a semi-automatic segmentation model; lastly, given an initial segmentation, DeepEdit can be used to refine
9+
and improve the initial prediction by providing editing clicks. DeepEdit training process is similar to the algorithm
10+
proposed by **_Sakinis et al._** [DeepGrow](../../deepgrow/ignite) - Gaussian-smoothed clicks for all labels and background
11+
are generated and added as input to the backbone CNN, but removes the minimum-click limitation of DeepGrow.
12+
Contrary to DeepGrow, DeepEdit model allows the prediction of an automatic segmentation-based
13+
initialisation without user-provided clicks, which can then be further edited by providing clicks. Additionally,
14+
DeepEdit can also be used for multi-label segmentation problems, allowing the user to generate/segment
15+
all labels simultaneously instead of one label at a time.
16+
17+
This tutorial contains an example to train a DeepEdit model and a notebook to run inference
18+
over a pre-trained model. The train file reads images and labels folders (imagesTr, labelsTr) as they come in the
19+
[Medical Segmentation Decathlon](https://msd-for-monai.s3-us-west-2.amazonaws.com/Task09_Spleen.tar).
20+
21+
More information about the transforms used in DeepEdit are also in the Notebook.
22+
23+
**_Important note:_**
24+
25+
This tutorial is intended to show how to train and test a DeepEdit model in MONAI Core library. Users may also find interesting
26+
DeepEdit model working in [MONAI Label](https://github.com/Project-MONAI/MONAILabel/tree/main/sample-apps/radiology#deepedit)
27+
platform. There you can find how DeepEdit works along with 3D Slicer and/or OHIF.
28+
29+
<p align="center">
30+
<img src="../../figures/general_schema_deepedit.png" alt="deepedit scheme">
31+
</p>
32+
33+
**_Sakinis et al.,_** Interactive segmentation of medical images through
34+
fully convolutional neural networks. (2019) https://arxiv.org/abs/1903.08205
35+
36+
### 1. Data
37+
38+
A DeepEdit model could be trained on any 3D medical image dataset.
39+
40+
For this tutorial we used the public available dataset (Task09_Spleen) that can be downloaded from [Medical Segmentation Decathlon](https://drive.google.com/drive/folders/1HqEgzS8BV2c7xYNrZdEAnrHk7osJJ--2)
41+
42+
### 2. Questions and bugs
43+
44+
- For questions relating to the use of MONAI, please us our [Discussions tab](https://github.com/Project-MONAI/MONAI/discussions) on the main repository of MONAI.
45+
46+
- For bugs relating to MONAI functionality, please create an issue on the [main repository](https://github.com/Project-MONAI/MONAI/issues).
47+
48+
- For bugs relating to the running of a tutorial, please create an issue in [this repository](https://github.com/Project-MONAI/Tutorials/issues).
49+
50+
### 3. List of notebooks and examples
51+
52+
#### Prepare Your Data
53+
54+
- Download the Task09_Spleen zip file
55+
- Decompressed the file
56+
- Write the full path in the **input** flag in the [train file](./train.py)
57+
58+
59+
#### [DeepEdit Training](./train.py)
60+
61+
This is an extension for [train.py](./train.py) that redefines basic default arguments to run 3D training.
62+
63+
```bash
64+
# Run to know all possible options
65+
python ./train.py -h
66+
67+
# Train a DeepEdit model
68+
python ./train_3d.py
69+
--input deepedit/Task09_Spleen \
70+
--output deepedit_model/ \
71+
--epochs 100
72+
73+
# After training to export/save as torch script model
74+
python ./train.py
75+
--input deepedit_model/model.pt \
76+
--output deepedit_model/model.ts \
77+
--export true
78+
```
79+
80+
#### [DeepEdit Inference](./inference.ipynb)
81+
82+
This notebook helps to run any pre-transforms before running inference over a DeepEdit single label model.
83+
It also helps to run post-transforms to get the final label mask.
84+
85+
86+
#### DeepEdit Stats
87+
88+
By-default Tensorboard handlers are added as part of training/validation steps.

deepedit/ignite/__init__.py

Whitespace-only changes.

deepedit/ignite/infoANDinference.ipynb

Lines changed: 549 additions & 0 deletions
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)