Skip to content

Commit 5a3f5ee

Browse files
1161 update files according to new contributing guide (#1162)
Signed-off-by: Yiheng Wang <[email protected]> Fixes #1161 . ### Description I checked and updated the following tutorials in `modules` according to new contributing guide: - `dynunet_pipeline` - `engines` - `generate_random_permutations` - `interpretability` - `3d_image_transforms.ipynb` - `autoencoder_mednist.ipynb` - `batch_output_transform.ipynb` - `benchmark_global_mutual_information.ipynb` - `compute_metric.py` - `cross_validation_models_ensemble.ipynb` - `csv_datasets.ipynb` ### Checks <!--- Put an `x` in all the boxes that apply, and remove the not applicable items --> - [x] Avoid including large-size files in the PR. - [x] Clean up long text outputs from code cells in the notebook. - [x] For security purposes, please check the contents and remove any sensitive info such as user names and private key. - [x] Ensure (1) hyperlinks and markdown anchors are working (2) use relative paths for tutorial repo files (3) put figure and graphs in the `./figure` folder - [x] Notebook runs automatically `./runner.sh -t <path to .ipynb file>` Signed-off-by: Yiheng Wang <[email protected]> Co-authored-by: Mingxin Zheng <[email protected]>
1 parent a2652fb commit 5a3f5ee

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

53 files changed

+986
-1324
lines changed

modules/3d_image_transforms.ipynb

Lines changed: 28 additions & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,21 @@
11
{
22
"cells": [
3+
{
4+
"cell_type": "markdown",
5+
"metadata": {},
6+
"source": [
7+
"Copyright (c) MONAI Consortium \n",
8+
"Licensed under the Apache License, Version 2.0 (the \"License\"); \n",
9+
"you may not use this file except in compliance with the License. \n",
10+
"You may obtain a copy of the License at \n",
11+
"&nbsp;&nbsp;&nbsp;&nbsp;http://www.apache.org/licenses/LICENSE-2.0 \n",
12+
"Unless required by applicable law or agreed to in writing, software \n",
13+
"distributed under the License is distributed on an \"AS IS\" BASIS, \n",
14+
"WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. \n",
15+
"See the License for the specific language governing permissions and \n",
16+
"limitations under the License."
17+
]
18+
},
319
{
420
"cell_type": "markdown",
521
"metadata": {},
@@ -28,9 +44,16 @@
2844
"!python -c \"import matplotlib\" || pip install -q matplotlib"
2945
]
3046
},
47+
{
48+
"cell_type": "markdown",
49+
"metadata": {},
50+
"source": [
51+
"## Setup imports"
52+
]
53+
},
3154
{
3255
"cell_type": "code",
33-
"execution_count": 2,
56+
"execution_count": null,
3457
"metadata": {
3558
"tags": []
3659
},
@@ -52,69 +75,7 @@
5275
"import tempfile\n",
5376
"import shutil\n",
5477
"import os\n",
55-
"import glob"
56-
]
57-
},
58-
{
59-
"cell_type": "markdown",
60-
"metadata": {},
61-
"source": [
62-
"## Setup imports"
63-
]
64-
},
65-
{
66-
"cell_type": "code",
67-
"execution_count": 3,
68-
"metadata": {
69-
"tags": []
70-
},
71-
"outputs": [
72-
{
73-
"name": "stdout",
74-
"output_type": "stream",
75-
"text": [
76-
"MONAI version: 0.9.1rc1\n",
77-
"Numpy version: 1.23.0\n",
78-
"Pytorch version: 1.12.0+cu102\n",
79-
"MONAI flags: HAS_EXT = False, USE_COMPILED = False\n",
80-
"MONAI rev id: 99b9dd7cf0667113e56f0dd90d40699115048d59\n",
81-
"MONAI __file__: /home/wenqil/Documents/MONAI/monai/__init__.py\n",
82-
"\n",
83-
"Optional dependencies:\n",
84-
"Pytorch Ignite version: 0.4.9\n",
85-
"Nibabel version: 4.0.1\n",
86-
"scikit-image version: 0.19.3\n",
87-
"Pillow version: 9.2.0\n",
88-
"Tensorboard version: 2.9.1\n",
89-
"gdown version: 4.5.1\n",
90-
"TorchVision version: 0.13.0+cu102\n",
91-
"tqdm version: 4.64.0\n",
92-
"lmdb version: 1.3.0\n",
93-
"psutil version: 5.9.1\n",
94-
"pandas version: 1.4.3\n",
95-
"einops version: 0.4.1\n",
96-
"transformers version: 4.20.1\n",
97-
"mlflow version: 1.27.0\n",
98-
"pynrrd version: 0.4.3\n",
99-
"\n",
100-
"For details about installing the optional dependencies, please visit:\n",
101-
" https://docs.monai.io/en/latest/installation.html#installing-the-recommended-dependencies\n",
102-
"\n"
103-
]
104-
}
105-
],
106-
"source": [
107-
"# Copyright 2020 MONAI Consortium\n",
108-
"# Licensed under the Apache License, Version 2.0 (the \"License\");\n",
109-
"# you may not use this file except in compliance with the License.\n",
110-
"# You may obtain a copy of the License at\n",
111-
"# http://www.apache.org/licenses/LICENSE-2.0\n",
112-
"# Unless required by applicable law or agreed to in writing, software\n",
113-
"# distributed under the License is distributed on an \"AS IS\" BASIS,\n",
114-
"# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n",
115-
"# See the License for the specific language governing permissions and\n",
116-
"# limitations under the License.\n",
117-
"\n",
78+
"import glob\n",
11879
"\n",
11980
"print_config()"
12081
]
@@ -132,19 +93,11 @@
13293
},
13394
{
13495
"cell_type": "code",
135-
"execution_count": 4,
96+
"execution_count": null,
13697
"metadata": {
13798
"tags": []
13899
},
139-
"outputs": [
140-
{
141-
"name": "stdout",
142-
"output_type": "stream",
143-
"text": [
144-
"root dir is: /home/wenqil/Documents/monai_data\n"
145-
]
146-
}
147-
],
100+
"outputs": [],
148101
"source": [
149102
"directory = os.environ.get(\"MONAI_DATA_DIRECTORY\")\n",
150103
"root_dir = tempfile.mkdtemp() if directory is None else directory\n",
@@ -829,7 +782,7 @@
829782
"name": "python",
830783
"nbconvert_exporter": "python",
831784
"pygments_lexer": "ipython3",
832-
"version": "3.8.13"
785+
"version": "3.8.10"
833786
}
834787
},
835788
"nbformat": 4,

modules/autoencoder_mednist.ipynb

Lines changed: 23 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,21 @@
11
{
22
"cells": [
3+
{
4+
"cell_type": "markdown",
5+
"metadata": {},
6+
"source": [
7+
"Copyright (c) MONAI Consortium \n",
8+
"Licensed under the Apache License, Version 2.0 (the \"License\"); \n",
9+
"you may not use this file except in compliance with the License. \n",
10+
"You may obtain a copy of the License at \n",
11+
"&nbsp;&nbsp;&nbsp;&nbsp;http://www.apache.org/licenses/LICENSE-2.0 \n",
12+
"Unless required by applicable law or agreed to in writing, software \n",
13+
"distributed under the License is distributed on an \"AS IS\" BASIS, \n",
14+
"WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. \n",
15+
"See the License for the specific language governing permissions and \n",
16+
"limitations under the License."
17+
]
18+
},
319
{
420
"cell_type": "markdown",
521
"metadata": {},
@@ -37,47 +53,16 @@
3753
"cell_type": "markdown",
3854
"metadata": {},
3955
"source": [
40-
"# 1. Imports and configuration"
56+
"## Setup imports"
4157
]
4258
},
4359
{
4460
"cell_type": "code",
45-
"execution_count": 2,
61+
"execution_count": null,
4662
"metadata": {
4763
"tags": []
4864
},
49-
"outputs": [
50-
{
51-
"name": "stdout",
52-
"output_type": "stream",
53-
"text": [
54-
"MONAI version: 0.6.0rc1+23.gc6793fd0\n",
55-
"Numpy version: 1.20.3\n",
56-
"Pytorch version: 1.9.0a0+c3d40fd\n",
57-
"MONAI flags: HAS_EXT = True, USE_COMPILED = False\n",
58-
"MONAI rev id: c6793fd0f316a448778d0047664aaf8c1895fe1c\n",
59-
"\n",
60-
"Optional dependencies:\n",
61-
"Pytorch Ignite version: 0.4.5\n",
62-
"Nibabel version: 3.2.1\n",
63-
"scikit-image version: 0.15.0\n",
64-
"Pillow version: 8.2.0\n",
65-
"Tensorboard version: 2.5.0\n",
66-
"gdown version: 3.13.0\n",
67-
"TorchVision version: 0.10.0a0\n",
68-
"ITK version: 5.1.2\n",
69-
"tqdm version: 4.53.0\n",
70-
"lmdb version: 1.2.1\n",
71-
"psutil version: 5.8.0\n",
72-
"pandas version: 1.1.4\n",
73-
"einops version: 0.3.0\n",
74-
"\n",
75-
"For details about installing the optional dependencies, please visit:\n",
76-
" https://docs.monai.io/en/latest/installation.html#installing-the-recommended-dependencies\n",
77-
"\n"
78-
]
79-
}
80-
],
65+
"outputs": [],
8166
"source": [
8267
"import logging\n",
8368
"import os\n",
@@ -147,7 +132,7 @@
147132
"cell_type": "markdown",
148133
"metadata": {},
149134
"source": [
150-
"# 2. Get the data\n",
135+
"# Get the data\n",
151136
"\n",
152137
"The MedNIST dataset was gathered from several sets from [TCIA](https://wiki.cancerimagingarchive.net/display/Public/Data+Usage+Policies+and+Restrictions),\n",
153138
"[the RSNA Bone Age Challenge](http://rsnachallenges.cloudapp.net/competitions/4),\n",
@@ -255,7 +240,7 @@
255240
"cell_type": "markdown",
256241
"metadata": {},
257242
"source": [
258-
"# 3. Create the image transform chain\n",
243+
"# Create the image transform chain\n",
259244
"\n",
260245
"To train the autoencoder to de-blur/de-noise our images, we'll want to pass the degraded image into the encoder, but in the loss function, we'll do the comparison with the original, undegraded version. In this sense, the loss function will be minimised when the encode and decode steps manage to remove the degradation.\n",
261246
"\n",
@@ -427,15 +412,7 @@
427412
"cell_type": "code",
428413
"execution_count": null,
429414
"metadata": {},
430-
"outputs": [
431-
{
432-
"name": "stderr",
433-
"output_type": "stream",
434-
"text": [
435-
"orig -- epoch 30, average loss: 0.0110: 60%|██████ | 30/50 [01:41<01:08, 3.40s/it]"
436-
]
437-
}
438-
],
415+
"outputs": [],
439416
"source": [
440417
"max_epochs = 50\n",
441418
"training_types = ['orig', 'gaus', 's&p']\n",
@@ -524,7 +501,7 @@
524501
"name": "python",
525502
"nbconvert_exporter": "python",
526503
"pygments_lexer": "ipython3",
527-
"version": "3.8.13"
504+
"version": "3.8.10"
528505
}
529506
},
530507
"nbformat": 4,

modules/batch_output_transform.ipynb

Lines changed: 22 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,21 @@
11
{
22
"cells": [
3+
{
4+
"cell_type": "markdown",
5+
"metadata": {},
6+
"source": [
7+
"Copyright (c) MONAI Consortium \n",
8+
"Licensed under the Apache License, Version 2.0 (the \"License\"); \n",
9+
"you may not use this file except in compliance with the License. \n",
10+
"You may obtain a copy of the License at \n",
11+
"&nbsp;&nbsp;&nbsp;&nbsp;http://www.apache.org/licenses/LICENSE-2.0 \n",
12+
"Unless required by applicable law or agreed to in writing, software \n",
13+
"distributed under the License is distributed on an \"AS IS\" BASIS, \n",
14+
"WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. \n",
15+
"See the License for the specific language governing permissions and \n",
16+
"limitations under the License."
17+
]
18+
},
319
{
420
"cell_type": "markdown",
521
"metadata": {},
@@ -51,21 +67,10 @@
5167
},
5268
{
5369
"cell_type": "code",
54-
"execution_count": 1,
70+
"execution_count": null,
5571
"metadata": {},
5672
"outputs": [],
5773
"source": [
58-
"# Copyright 2020 MONAI Consortium\n",
59-
"# Licensed under the Apache License, Version 2.0 (the \"License\");\n",
60-
"# you may not use this file except in compliance with the License.\n",
61-
"# You may obtain a copy of the License at\n",
62-
"# http://www.apache.org/licenses/LICENSE-2.0\n",
63-
"# Unless required by applicable law or agreed to in writing, software\n",
64-
"# distributed under the License is distributed on an \"AS IS\" BASIS,\n",
65-
"# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n",
66-
"# See the License for the specific language governing permissions and\n",
67-
"# limitations under the License.\n",
68-
"\n",
6974
"import logging\n",
7075
"import os\n",
7176
"import sys\n",
@@ -78,6 +83,7 @@
7883
"import torch\n",
7984
"from ignite.metrics import Accuracy\n",
8085
"\n",
86+
"from monai.config import print_config\n",
8187
"from monai.data import CacheDataset, create_test_image_3d, DataLoader\n",
8288
"from monai.engines import SupervisedEvaluator, SupervisedTrainer\n",
8389
"from monai.handlers import (\n",
@@ -105,7 +111,9 @@
105111
")\n",
106112
"from monai.utils import get_torch_version_tuple\n",
107113
"\n",
108-
"logging.basicConfig(stream=sys.stdout, level=logging.INFO)"
114+
"logging.basicConfig(stream=sys.stdout, level=logging.INFO)\n",
115+
"\n",
116+
"print_config()"
109117
]
110118
},
111119
{
@@ -425,7 +433,7 @@
425433
"name": "python",
426434
"nbconvert_exporter": "python",
427435
"pygments_lexer": "ipython3",
428-
"version": "3.8.13"
436+
"version": "3.8.10"
429437
}
430438
},
431439
"nbformat": 4,

0 commit comments

Comments
 (0)