Skip to content

Commit b312fc8

Browse files
authored
Update modules notebooks to match format requirements (#1156)
### Description This PR updated several modules tutorials to match the format requirements of contribution guideline. CC @mingxin-zheng . ### 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: Nic Ma <[email protected]>
1 parent deabee8 commit b312fc8

12 files changed

+334
-1274
lines changed

modules/decollate_batch.ipynb

Lines changed: 27 additions & 61 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": {},
@@ -49,7 +65,7 @@
4965
},
5066
{
5167
"cell_type": "code",
52-
"execution_count": 1,
68+
"execution_count": null,
5369
"metadata": {
5470
"tags": []
5571
},
@@ -67,54 +83,12 @@
6783
},
6884
{
6985
"cell_type": "code",
70-
"execution_count": 1,
86+
"execution_count": null,
7187
"metadata": {
7288
"tags": []
7389
},
74-
"outputs": [
75-
{
76-
"name": "stdout",
77-
"output_type": "stream",
78-
"text": [
79-
"MONAI version: 0.4.0+544.g5e7345d\n",
80-
"Numpy version: 1.21.0\n",
81-
"Pytorch version: 1.9.0+cu102\n",
82-
"MONAI flags: HAS_EXT = False, USE_COMPILED = False\n",
83-
"MONAI rev id: 5e7345d384ae08011b0e250b93f615d6d5190258\n",
84-
"\n",
85-
"Optional dependencies:\n",
86-
"Pytorch Ignite version: 0.4.5\n",
87-
"Nibabel version: 3.2.1\n",
88-
"scikit-image version: 0.15.0\n",
89-
"Pillow version: 7.0.0\n",
90-
"Tensorboard version: 1.15.0+nv\n",
91-
"gdown version: 3.13.0\n",
92-
"TorchVision version: 0.9.0a0\n",
93-
"ITK version: 5.1.2\n",
94-
"tqdm version: 4.53.0\n",
95-
"lmdb version: 1.1.1\n",
96-
"psutil version: 5.8.0\n",
97-
"pandas version: 1.1.4\n",
98-
"einops version: 0.3.0\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-
],
90+
"outputs": [],
10691
"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",
11892
"import logging\n",
11993
"import os\n",
12094
"import sys\n",
@@ -162,19 +136,11 @@
162136
},
163137
{
164138
"cell_type": "code",
165-
"execution_count": 3,
139+
"execution_count": null,
166140
"metadata": {
167141
"tags": []
168142
},
169-
"outputs": [
170-
{
171-
"name": "stdout",
172-
"output_type": "stream",
173-
"text": [
174-
"/workspace/data/medical\n"
175-
]
176-
}
177-
],
143+
"outputs": [],
178144
"source": [
179145
"directory = os.environ.get(\"MONAI_DATA_DIRECTORY\")\n",
180146
"root_dir = tempfile.mkdtemp() if directory is None else directory\n",
@@ -190,7 +156,7 @@
190156
},
191157
{
192158
"cell_type": "code",
193-
"execution_count": 3,
159+
"execution_count": null,
194160
"metadata": {},
195161
"outputs": [],
196162
"source": [
@@ -210,7 +176,7 @@
210176
},
211177
{
212178
"cell_type": "code",
213-
"execution_count": 4,
179+
"execution_count": null,
214180
"metadata": {},
215181
"outputs": [],
216182
"source": [
@@ -237,7 +203,7 @@
237203
},
238204
{
239205
"cell_type": "code",
240-
"execution_count": 5,
206+
"execution_count": null,
241207
"metadata": {},
242208
"outputs": [],
243209
"source": [
@@ -267,7 +233,7 @@
267233
},
268234
{
269235
"cell_type": "code",
270-
"execution_count": 6,
236+
"execution_count": null,
271237
"metadata": {
272238
"tags": []
273239
},
@@ -353,7 +319,7 @@
353319
},
354320
{
355321
"cell_type": "code",
356-
"execution_count": 8,
322+
"execution_count": null,
357323
"metadata": {
358324
"pycharm": {
359325
"is_executing": true
@@ -382,7 +348,7 @@
382348
"name": "python",
383349
"nbconvert_exporter": "python",
384350
"pygments_lexer": "ipython3",
385-
"version": "3.8.12"
351+
"version": "3.8.10"
386352
}
387353
},
388354
"nbformat": 4,

modules/dice_loss_metric_notes.ipynb

Lines changed: 47 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,22 @@
11
{
22
"cells": [
3+
{
4+
"cell_type": "markdown",
5+
"id": "6459ddb8",
6+
"metadata": {},
7+
"source": [
8+
"Copyright (c) MONAI Consortium \n",
9+
"Licensed under the Apache License, Version 2.0 (the \"License\"); \n",
10+
"you may not use this file except in compliance with the License. \n",
11+
"You may obtain a copy of the License at \n",
12+
"&nbsp;&nbsp;&nbsp;&nbsp;http://www.apache.org/licenses/LICENSE-2.0 \n",
13+
"Unless required by applicable law or agreed to in writing, software \n",
14+
"distributed under the License is distributed on an \"AS IS\" BASIS, \n",
15+
"WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. \n",
16+
"See the License for the specific language governing permissions and \n",
17+
"limitations under the License."
18+
]
19+
},
320
{
421
"cell_type": "markdown",
522
"id": "0c5bf94b-4f1d-4e94-a6e6-94644095e910",
@@ -10,6 +27,32 @@
1027
"This notebook summarises some of the details relating to the `DiceLoss` and `DiceMetric` classes and their behaviour."
1128
]
1229
},
30+
{
31+
"cell_type": "markdown",
32+
"id": "952771b9",
33+
"metadata": {},
34+
"source": [
35+
"## Setup environment"
36+
]
37+
},
38+
{
39+
"cell_type": "code",
40+
"execution_count": null,
41+
"id": "7b7eb650",
42+
"metadata": {},
43+
"outputs": [],
44+
"source": [
45+
"!python -c \"import monai\" || pip install -q \"monai-weekly\""
46+
]
47+
},
48+
{
49+
"cell_type": "markdown",
50+
"id": "55f81921",
51+
"metadata": {},
52+
"source": [
53+
"## Setup imports"
54+
]
55+
},
1356
{
1457
"cell_type": "code",
1558
"execution_count": 1,
@@ -18,10 +61,13 @@
1861
"outputs": [],
1962
"source": [
2063
"import torch\n",
64+
"from monai.config import print_config\n",
2165
"from monai.losses import DiceLoss\n",
2266
"from monai.metrics import DiceMetric\n",
2367
"from monai.transforms import AsDiscrete, Compose\n",
2468
"\n",
69+
"print_config()\n",
70+
"\n",
2571
"\n",
2672
"def print_tensor(name, t):\n",
2773
" print(f\"{name}: {t.numpy().tolist()} shape: {tuple(t.shape)}\")"
@@ -412,7 +458,7 @@
412458
"name": "python",
413459
"nbconvert_exporter": "python",
414460
"pygments_lexer": "ipython3",
415-
"version": "3.8.12"
461+
"version": "3.8.10"
416462
}
417463
},
418464
"nbformat": 4,

modules/image_dataset.ipynb

Lines changed: 20 additions & 59 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": {},
@@ -44,7 +60,7 @@
4460
},
4561
{
4662
"cell_type": "code",
47-
"execution_count": 2,
63+
"execution_count": null,
4864
"metadata": {
4965
"execution": {
5066
"iopub.execute_input": "2021-01-14T12:34:04.909819Z",
@@ -54,63 +70,8 @@
5470
},
5571
"tags": []
5672
},
57-
"outputs": [
58-
{
59-
"name": "stdout",
60-
"output_type": "stream",
61-
"text": [
62-
"MONAI version: 1.1.0+16.gd990ff5e\n",
63-
"Numpy version: 1.23.5\n",
64-
"Pytorch version: 1.13.1\n",
65-
"MONAI flags: HAS_EXT = False, USE_COMPILED = False, USE_META_DICT = False\n",
66-
"MONAI rev id: d990ff5e6acab8655d507aeac934defd4f7a5fdc\n",
67-
"MONAI __file__: /Users/Documents/MONAI/monai/__init__.py\n",
68-
"\n",
69-
"Optional dependencies:\n",
70-
"Pytorch Ignite version: 0.4.10\n",
71-
"Nibabel version: 5.0.0\n",
72-
"scikit-image version: NOT INSTALLED or UNKNOWN VERSION.\n",
73-
"Pillow version: 9.4.0\n",
74-
"Tensorboard version: 2.11.0\n",
75-
"gdown version: 4.6.0\n",
76-
"TorchVision version: 0.14.1\n",
77-
"tqdm version: 4.64.1\n",
78-
"lmdb version: 1.4.0\n",
79-
"psutil version: 5.9.4\n",
80-
"pandas version: 1.5.2\n",
81-
"einops version: 0.6.0\n",
82-
"transformers version: 4.21.3\n",
83-
"mlflow version: 2.1.1\n",
84-
"pynrrd version: 1.0.0\n",
85-
"\n",
86-
"For details about installing the optional dependencies, please visit:\n",
87-
" https://docs.monai.io/en/latest/installation.html#installing-the-recommended-dependencies\n",
88-
"\n"
89-
]
90-
}
91-
],
73+
"outputs": [],
9274
"source": [
93-
"# Copyright 2020 - 2021 MONAI Consortium\n",
94-
"# Licensed under the Apache License, Version 2.0 (the \"License\");\n",
95-
"# you may not use this file except in compliance with the License.\n",
96-
"# You may obtain a copy of the License at\n",
97-
"# http://www.apache.org/licenses/LICENSE-2.0\n",
98-
"# Unless required by applicable law or agreed to in writing, software\n",
99-
"# distributed under the License is distributed on an \"AS IS\" BASIS,\n",
100-
"# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n",
101-
"# See the License for the specific language governing permissions and\n",
102-
"# limitations under the License.\n",
103-
"\n",
104-
"# Copyright 2020 MONAI Consortium\n",
105-
"# Licensed under the Apache License, Version 2.0 (the \"License\");\n",
106-
"# you may not use this file except in compliance with the License.\n",
107-
"# You may obtain a copy of the License at\n",
108-
"# http://www.apache.org/licenses/LICENSE-2.0\n",
109-
"# Unless required by applicable law or agreed to in writing, software\n",
110-
"# distributed under the License is distributed on an \"AS IS\" BASIS,\n",
111-
"# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n",
112-
"# See the License for the specific language governing permissions and\n",
113-
"# limitations under the License.\n",
11475
"import os\n",
11576
"import tempfile\n",
11677
"import shutil\n",
@@ -195,7 +156,7 @@
195156
" transform_with_metadata=True,\n",
196157
")\n",
197158
"print(\"image shape:\", img_dataset[0][0].shape)\n",
198-
"print(\"seg. shape:\", img_dataset[0][1].shape)"
159+
"print(\"seg shape:\", img_dataset[0][1].shape)"
199160
]
200161
},
201162
{
@@ -231,7 +192,7 @@
231192
"name": "python",
232193
"nbconvert_exporter": "python",
233194
"pygments_lexer": "ipython3",
234-
"version": "3.8.13"
195+
"version": "3.8.10"
235196
}
236197
},
237198
"nbformat": 4,

0 commit comments

Comments
 (0)