Skip to content

Commit 83b4256

Browse files
[pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
1 parent 60cf821 commit 83b4256

File tree

3 files changed

+36
-38
lines changed

3 files changed

+36
-38
lines changed

auto3dseg/tasks/kits23/README.md

Lines changed: 32 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,22 @@
11

2-
# KiTS23
2+
# KiTS23
33

44
<img align="right" src="./kits23_example.png" width=30%>
55

6-
This tutorial shows how to use Auto3DSeg with KiTS 2023 dataset from the MICCAI 2023 challenge **[The 2023 Kidney and Kidney Tumor Segmentation Challenge (KiTS23)](https://kits-challenge.org/kits23/)**.
6+
This tutorial shows how to use Auto3DSeg with KiTS 2023 dataset from the MICCAI 2023 challenge **[The 2023 Kidney and Kidney Tumor Segmentation Challenge (KiTS23)](https://kits-challenge.org/kits23/)**.
77
The example is based on the 1st place solution in the KiTS challenge [(NVAUTO team)](https://kits-challenge.org/kits23/#kits23-official-results):
88

99
Andriy Myronenko, Dong Yang, Yufan He and Daguang Xu: "Automated 3D Segmentation of Kidneys and Tumors in MICCAI KiTS 2023 Challenge". In MICCAI (2023). [arXiv](https://arxiv.org/abs/2310.04110)
1010

1111

1212
## Task overview
1313

14-
The task is to segment kidneys, tumors and cysts from 3D CTs. The dataset contains 489 cases with resolutions ranging between 0.39x0.39x0.5 and 1x1x5 mm.
15-
Please download the KiTS23 [dataset](https://kits-challenge.org/kits23/#) and place it in the "/data/kits23" folder to follow this tutorial.
14+
The task is to segment kidneys, tumors and cysts from 3D CTs. The dataset contains 489 cases with resolutions ranging between 0.39x0.39x0.5 and 1x1x5 mm.
15+
Please download the KiTS23 [dataset](https://kits-challenge.org/kits23/#) and place it in the "/data/kits23" folder to follow this tutorial.
1616

1717
## Auto3DSeg
1818

19-
With Auto3DSeg most segmentation parameters are automatically determined. In this tutorial, we start from a basic automated example, then show how different options can be adjusted if necessary. We use only the **SegResNet** algo here for simplicity, which is a training recipe based on the [segresnet](https://docs.monai.io/en/latest/networks.html#segresnetds).
19+
With Auto3DSeg most segmentation parameters are automatically determined. In this tutorial, we start from a basic automated example, then show how different options can be adjusted if necessary. We use only the **SegResNet** algo here for simplicity, which is a training recipe based on the [segresnet](https://docs.monai.io/en/latest/networks.html#segresnetds).
2020

2121

2222
### Running based on the input config (one-liner)
@@ -27,15 +27,15 @@ The Auto3DSeg can be run using a config **input.yaml**
2727
python -m monai.apps.auto3dseg AutoRunner run --input=./input.yaml --algos=segresnet
2828
```
2929

30-
This one line of code will run the full training workflow, including data analysis, multi-fold training, ensembling. The system will adjust parameters based on the data and your available GPU (or multi-GPU) hardware configuration.
31-
Here we explicitly specified to use only segresnet algo, for other possible parameters of the AutoRunner please see the [monai docs](https://github.com/Project-MONAI/MONAI/blob/main/monai/apps/auto3dseg/auto_runner.py).
30+
This one line of code will run the full training workflow, including data analysis, multi-fold training, ensembling. The system will adjust parameters based on the data and your available GPU (or multi-GPU) hardware configuration.
31+
Here we explicitly specified to use only segresnet algo, for other possible parameters of the AutoRunner please see the [monai docs](https://github.com/Project-MONAI/MONAI/blob/main/monai/apps/auto3dseg/auto_runner.py).
3232

3333
The [input.yaml](./input.yaml) describes the dataset (KiTS23) task, and must include at least 3 mandatory fields: modality (CT), dataset location (here it's /data/kits23) and the dataset manifest json file [kits23_folds.json](./kits23_folds.json).
3434
Other parameters can be also added to the input.yaml config. For KiTS23 dataset specifically, we include the "class_names" key to indicate label grouping for the 3 output classes that KiTS23 challenge requires (which is something specific for the KiTS task)
3535

3636
### Running from the code
3737

38-
If you prefer running from the code (which will allow more customizations), you can create a python file "example.py" and simply run it as
38+
If you prefer running from the code (which will allow more customizations), you can create a python file "example.py" and simply run it as
3939
```bash
4040
python example.py
4141
```
@@ -75,7 +75,7 @@ def main():
7575
"class_names":[
7676
{ "name": "kidney_and_mass", "index": [1,2,3] },
7777
{ "name": "mass", "index": [2,3] },
78-
{ "name": "tumor", "index": [2] }
78+
{ "name": "tumor", "index": [2] }
7979
]
8080
}
8181
runner = AutoRunner(input=input_dict, algos = 'segresnet')
@@ -96,14 +96,14 @@ The dictionary form of the input config is equivalent to the input.yaml. Notice,
9696

9797
# KiTS23 Auto3DSeg user input
9898

99-
modality: CT
100-
dataroot: /data/kits23
101-
datalist: kits23_folds.json
102-
class_names:
99+
modality: CT
100+
dataroot: /data/kits23
101+
datalist: kits23_folds.json
102+
class_names:
103103
- { name: kidney_and_mass, index: [1,2,3] }
104104
- { name: mass, index: [2,3] }
105105
- { name: tumor, index: [2] }
106-
sigmoid: true
106+
sigmoid: true
107107

108108
# additional options (OPTIONAL)
109109
auto_scale_allowed: false # disable auto scaling of some parameters to your GPU
@@ -116,8 +116,8 @@ batch_size: 1 # batch size is automatically determined accor
116116
augment_mode: ct_ax_1 # change the default augmentation transform sequence to an alternative (with only inplane/axial spatial rotations and scaling)
117117

118118
```
119-
Here we added more optional options to manually fine-tune the performance. The full list of the available "self-explanatory" options can be found [here](https://github.com/Project-MONAI/research-contributions/blob/main/auto3dseg/algorithm_templates/segresnet/configs/hyper_parameters.yaml).
120-
119+
Here we added more optional options to manually fine-tune the performance. The full list of the available "self-explanatory" options can be found [here](https://github.com/Project-MONAI/research-contributions/blob/main/auto3dseg/algorithm_templates/segresnet/configs/hyper_parameters.yaml).
120+
121121
### Input.yaml options and AutoRunner options combined
122122
123123
In the previous sections, we showed how to manually provide various input config options related to **training**. In the same file, one can also add AutoRunner related options, consider the following input3.yaml config
@@ -126,28 +126,28 @@ In the previous sections, we showed how to manually provide various input config
126126

127127
# KiTS23 Auto3DSeg user input
128128

129-
modality: CT
130-
dataroot: /data/kits23
131-
datalist: kits23_folds.json
132-
class_names:
129+
modality: CT
130+
dataroot: /data/kits23
131+
datalist: kits23_folds.json
132+
class_names:
133133
- { name: kidney_and_mass, index: [1,2,3] }
134134
- { name: mass, index: [2,3] }
135135
- { name: tumor, index: [2] }
136-
sigmoid: true
136+
sigmoid: true
137137

138138
# additional options (OPTIONAL)
139139
num_epochs: 600 # manually set number of training epochs to 600 (otherwise it's determined automatically)
140140

141141
# additional AutoRunner options (OPTIONAL)
142142
algos: segresnet
143143
num_fold: 1
144-
ensemble: false
144+
ensemble: false
145145
work_dir: tmp/tutorial_kits23
146146

147147
```
148148
Here we indicated to use only "segresnet" algo, and only 1 fold training, skip ensembling (since we train 1 model anyway), and change the default working directory. We can run it as
149149
```bash
150-
python -m monai.apps.auto3dseg AutoRunner run --input=./input3.yaml
150+
python -m monai.apps.auto3dseg AutoRunner run --input=./input3.yaml
151151
```
152152
One may prefer this format, if they want to put all options in a single file, instead of having training options vs AutoRunner options separatelly. The end results will be the same.
153153

@@ -160,21 +160,21 @@ python -m monai.apps.auto3dseg AutoRunner run --input=./input3.yaml --work_dir=t
160160
here the "work_dir", "dataroot", "num_epochs" options will override any defaults or any input.yaml provided options.
161161

162162
### KiTS 2023 specific options
163-
163+
164164
All the configurations here include some KiTS 2023 specific options below
165-
```yaml
166-
class_names:
165+
```yaml
166+
class_names:
167167
- { name: kidney_and_mass, index: [1,2,3] }
168168
- { name: mass, index: [2,3] }
169169
- { name: tumor, index: [2] }
170-
sigmoid: true
170+
sigmoid: true
171171

172172
```
173-
In KiTS 2023 challenge, the task is to segment 3 specific subregions: a) the first one must include all labels (kidneys, tumors, cysts) b) the second one is a union of tumors and cysts b) the third one is a tumor only region.
174-
Thus the "class_names" options indicates which label indices to merge together to create these 3 subregions. The "name" keys are used in Tensorboard for convenience (you can use your own names).
173+
In KiTS 2023 challenge, the task is to segment 3 specific subregions: a) the first one must include all labels (kidneys, tumors, cysts) b) the second one is a union of tumors and cysts b) the third one is a tumor only region.
174+
Thus the "class_names" options indicates which label indices to merge together to create these 3 subregions. The "name" keys are used in Tensorboard for convenience (you can use your own names).
175175
Since, the 3 sub-regions are overlapping the segmentation task is a multi-label task, where each voxel can potentially be assigned to several regions. A common formulation of such task is to use the final network activation a "sigmoid", instead of the default "softmax" for mutually exclusive label classes. The config options "sigmoid: true" explicitly indicates that we are going to use the final sigmoid activation (for the multi-label segmentation). Strictly speaking it's not necessary to add this option here, the system will automatically figure it out after inspecting "class_names" having the overlapping indices.
176176
177-
Experimentally, you can remove these configs (class_names and sigmoid) completely to try a traditional segmentation (multi-class), to segment 3 mutually exclusive regions: a) kidneys without tumors or cysts b) tumors c) cysts. Generally, this is the default workflow for multi-organ segmentation (with non-overlaping classes). This sub-region grouping is just something specific for the KiTS 2023 challenge.
177+
Experimentally, you can remove these configs (class_names and sigmoid) completely to try a traditional segmentation (multi-class), to segment 3 mutually exclusive regions: a) kidneys without tumors or cysts b) tumors c) cysts. Generally, this is the default workflow for multi-organ segmentation (with non-overlaping classes). This sub-region grouping is just something specific for the KiTS 2023 challenge.
178178
179179
### Auto3DSeg code location
180180
@@ -205,11 +205,11 @@ python -m monai.apps.auto3dseg AutoRunner run --input=./input.yaml --algos=segre
205205
## Validation performance: NVIDIA DGX-1 (8x V100 32G)
206206

207207
Training this KiTS 2023 example on on 8 GPU V100 32GB DGX machine, one can expect to get an average Dice of 0.87-0.88 (for fold 0). The higher end of the accuracy range is obtained if you set the ROI size to larger (e.g. roi_size: [336, 336, 336]), but
208-
this requires a large memory GPU device (such as Nvidia A100). Alternatively you can experiment with training longer, e.g. by setting num_epochs=1200.
208+
this requires a large memory GPU device (such as Nvidia A100). Alternatively you can experiment with training longer, e.g. by setting num_epochs=1200.
209209

210210
## Differences with 1st place KiTS23 solution
211211

212-
The tutorial here is to demonstrate how to use Auto3DSeg in general, with various examples for KiTS23 dataset. It is based on the 1st place KiTS23 solution [1], with the main differences being in [1] the training was done in 2 stages: first the approximate Kidney region was detected (by training a model to segment the foreground), second an ensemble of models were trained to segment the 3 KiTS subregions using the "Kidney subregion" cropped CTs. In this tutorial, we train to segment KiTS subregions directly on the full CT for simplicity (which gives a slightly lower average dice, ~1\%). Another difference is that in [1], the ensemble of several models were trained which included both Segresnet and DiNTS models, whereas in this tutorial we focus only on Segresnet.
212+
The tutorial here is to demonstrate how to use Auto3DSeg in general, with various examples for KiTS23 dataset. It is based on the 1st place KiTS23 solution [1], with the main differences being in [1] the training was done in 2 stages: first the approximate Kidney region was detected (by training a model to segment the foreground), second an ensemble of models were trained to segment the 3 KiTS subregions using the "Kidney subregion" cropped CTs. In this tutorial, we train to segment KiTS subregions directly on the full CT for simplicity (which gives a slightly lower average dice, ~1\%). Another difference is that in [1], the ensemble of several models were trained which included both Segresnet and DiNTS models, whereas in this tutorial we focus only on Segresnet.
213213

214214
## Data
215215

@@ -223,4 +223,3 @@ The KiTS23 challenge dataset [2,3] can be downloaded from [here](https://kits-ch
223223
[2] Heller, N., Isensee, F., Maier-Hein, K.H., Hou, X., Xie, C., Li, F., Nan, Y., Mu, G., Lin, Z., Han, M., et al.: The state of the art in kidney and kidney tumor segmentation in contrast-enhanced ct imaging: Results of the kits19 challenge. Medical Image Analysis 67, 101821 (2021)
224224

225225
[3] Heller, N., Wood, A., Isensee, F., Radsch, T., Tejpaul, R., Papanikolopoulos, N.,Weight, C.: The 2023 kidney and kidney tumor segmentation challenge, https://kits-challenge.org/kits23/
226-

auto3dseg/tasks/kits23/input.yaml

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,17 +11,16 @@ class_names: # names for tensorboard, and label index gro
1111
# OPTIONAL
1212
# use final sigmoid activation (instead of the default softmax), since KiTS regions are overlapping (multi-label segmentation)
1313
# this is optional to set, the system auto-detects overlapping labels automatically.
14-
sigmoid: true
14+
sigmoid: true
1515

1616
# the config below is optional, but it explicitly sets params as it was used during KiTS23 challenge
17-
# otherwise, the defaults are used, auto_scale_allowed is True and the system will attempt to guess these settings according to the available GPU (e.g. make batch size larger)
17+
# otherwise, the defaults are used, auto_scale_allowed is True and the system will attempt to guess these settings according to the available GPU (e.g. make batch size larger)
1818
auto_scale_allowed: false
1919
num_epochs: 600
2020
resample: true
21-
resample_resolution: [0.78125, 0.78125, 0.78125]
21+
resample_resolution: [0.78125, 0.78125, 0.78125]
2222
roi_size: [256, 256, 256]
2323
# roi_size: [336, 336, 336]
2424
# loss: {_target_: DiceLoss}
2525
# batch_size: 1
2626
# augment_mode: ct_ax_1
27-

auto3dseg/tasks/kits23/kits23_folds.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2488,4 +2488,4 @@
24882488
"fold": 4
24892489
}
24902490
]
2491-
}
2491+
}

0 commit comments

Comments
 (0)