Skip to content

Create deepedit tutorial #661

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 24 commits into from
May 9, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
78c0f47
Create deepedit tutorial
diazandr3s Apr 18, 2022
ea2f91a
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Apr 18, 2022
9cf5de8
Merge branch 'master' into deepeditTutorial
diazandr3s Apr 18, 2022
14d21c9
Update train file
diazandr3s Apr 18, 2022
2c94c40
Merge branch 'master' into deepeditTutorial
diazandr3s Apr 22, 2022
5c72942
Merge branch 'master' into deepeditTutorial
diazandr3s Apr 24, 2022
fa4772b
Move custom transforms and interaction to MONAI core
diazandr3s Apr 24, 2022
4053460
Update imports from MONAI
diazandr3s Apr 26, 2022
60ceda1
Update Notebook and Readme
diazandr3s Apr 26, 2022
738a929
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Apr 26, 2022
168b9ed
Fix static errors in Notebook
diazandr3s Apr 26, 2022
de30dc6
Merge branch 'deepeditTutorial' of https://github.com/diazandr3s/tuto…
diazandr3s Apr 26, 2022
28d9c65
Fix spaces autofix
diazandr3s Apr 26, 2022
3c0661b
Merge branch 'master' into deepeditTutorial
diazandr3s May 6, 2022
0fb3ebe
Update DeepEdit transform names
diazandr3s May 8, 2022
d0258df
Update Readme
diazandr3s May 8, 2022
74a288c
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] May 8, 2022
fbfd44e
Address first round of comments
diazandr3s May 9, 2022
f75c82b
Merge branch 'deepeditTutorial' of https://github.com/diazandr3s/tuto…
diazandr3s May 9, 2022
4c738b1
Fix static issues
diazandr3s May 9, 2022
00246f4
Fix static
diazandr3s May 9, 2022
f7518c8
Fix static erros
diazandr3s May 9, 2022
198ff3b
Address second round of comments
diazandr3s May 9, 2022
e3872ea
Merge branch 'master' into deepeditTutorial
diazandr3s May 9, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,12 @@ This tutorial demonstrates the use of MONAI for training of registration and seg
#### [Deepgrow](./deepgrow)
The example show how to train/validate a 2D/3D deepgrow model. It also demonstrates running an inference for trained deepgrow models.

**DeepEdit**
#### [DeepEdit](./deepedit/ignite)
This example shows how to train/test a DeepEdit model. In this tutorial there is a Notebook that shows how to run
inference on a pretrained DeepEdit model.


**deployment**
#### [BentoML](./deployment/bentoml)
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.
Expand Down
88 changes: 88 additions & 0 deletions deepedit/ignite/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
# DeepEdit


DeepEdit is a method that combines an automatic and a semi-automatic approach for 3D medical images into a
single deep learning-based model. DeepEdit has three working modes: first, it can be used in click-free
inference mode (similar to a regular segmentation network), providing fully-automatic segmentation predictions which
can be used as a form of initialisation; second, it allows users to provide clicks to initialise and guide
a semi-automatic segmentation model; lastly, given an initial segmentation, DeepEdit can be used to refine
and improve the initial prediction by providing editing clicks. DeepEdit training process is similar to the algorithm
proposed by **_Sakinis et al._** [DeepGrow](../../deepgrow/ignite) - Gaussian-smoothed clicks for all labels and background
are generated and added as input to the backbone CNN, but removes the minimum-click limitation of DeepGrow.
Contrary to DeepGrow, DeepEdit model allows the prediction of an automatic segmentation-based
initialisation without user-provided clicks, which can then be further edited by providing clicks. Additionally,
DeepEdit can also be used for multi-label segmentation problems, allowing the user to generate/segment
all labels simultaneously instead of one label at a time.

This tutorial contains an example to train a DeepEdit model and a notebook to run inference
over a pre-trained model. The train file reads images and labels folders (imagesTr, labelsTr) as they come in the
[Medical Segmentation Decathlon](https://msd-for-monai.s3-us-west-2.amazonaws.com/Task09_Spleen.tar).

More information about the transforms used in DeepEdit are also in the Notebook.

**_Important note:_**

This tutorial is intended to show how to train and test a DeepEdit model in MONAI Core library. Users may also find interesting
DeepEdit model working in [MONAI Label](https://github.com/Project-MONAI/MONAILabel/tree/main/sample-apps/radiology#deepedit)
platform. There you can find how DeepEdit works along with 3D Slicer and/or OHIF.

<p align="center">
<img src="../../figures/general_schema_deepedit.png" alt="deepedit scheme">
</p>

**_Sakinis et al.,_** Interactive segmentation of medical images through
fully convolutional neural networks. (2019) https://arxiv.org/abs/1903.08205

### 1. Data

A DeepEdit model could be trained on any 3D medical image dataset.

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)

### 2. Questions and bugs

- 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.

- For bugs relating to MONAI functionality, please create an issue on the [main repository](https://github.com/Project-MONAI/MONAI/issues).

- For bugs relating to the running of a tutorial, please create an issue in [this repository](https://github.com/Project-MONAI/Tutorials/issues).

### 3. List of notebooks and examples

#### Prepare Your Data

- Download the Task09_Spleen zip file
- Decompressed the file
- Write the full path in the **input** flag in the [train file](./train.py)


#### [DeepEdit Training](./train.py)

This is an extension for [train.py](./train.py) that redefines basic default arguments to run 3D training.

```bash
# Run to know all possible options
python ./train.py -h

# Train a DeepEdit model
python ./train_3d.py
--input deepedit/Task09_Spleen \
--output deepedit_model/ \
--epochs 100

# After training to export/save as torch script model
python ./train.py
--input deepedit_model/model.pt \
--output deepedit_model/model.ts \
--export true
```

#### [DeepEdit Inference](./inference.ipynb)

This notebook helps to run any pre-transforms before running inference over a DeepEdit single label model.
It also helps to run post-transforms to get the final label mask.


#### DeepEdit Stats

By-default Tensorboard handlers are added as part of training/validation steps.
Empty file added deepedit/ignite/__init__.py
Empty file.
549 changes: 549 additions & 0 deletions deepedit/ignite/infoANDinference.ipynb

Large diffs are not rendered by default.

Loading