Skip to content

Update modules notebooks to match format requirements #1156

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 14 commits into from
Jan 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
88 changes: 27 additions & 61 deletions modules/decollate_batch.ipynb
Original file line number Diff line number Diff line change
@@ -1,5 +1,21 @@
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Copyright (c) MONAI Consortium \n",
"Licensed under the Apache License, Version 2.0 (the \"License\"); \n",
"you may not use this file except in compliance with the License. \n",
"You may obtain a copy of the License at \n",
"    http://www.apache.org/licenses/LICENSE-2.0 \n",
"Unless required by applicable law or agreed to in writing, software \n",
"distributed under the License is distributed on an \"AS IS\" BASIS, \n",
"WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. \n",
"See the License for the specific language governing permissions and \n",
"limitations under the License."
]
},
{
"cell_type": "markdown",
"metadata": {},
Expand Down Expand Up @@ -49,7 +65,7 @@
},
{
"cell_type": "code",
"execution_count": 1,
"execution_count": null,
"metadata": {
"tags": []
},
Expand All @@ -67,54 +83,12 @@
},
{
"cell_type": "code",
"execution_count": 1,
"execution_count": null,
"metadata": {
"tags": []
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"MONAI version: 0.4.0+544.g5e7345d\n",
"Numpy version: 1.21.0\n",
"Pytorch version: 1.9.0+cu102\n",
"MONAI flags: HAS_EXT = False, USE_COMPILED = False\n",
"MONAI rev id: 5e7345d384ae08011b0e250b93f615d6d5190258\n",
"\n",
"Optional dependencies:\n",
"Pytorch Ignite version: 0.4.5\n",
"Nibabel version: 3.2.1\n",
"scikit-image version: 0.15.0\n",
"Pillow version: 7.0.0\n",
"Tensorboard version: 1.15.0+nv\n",
"gdown version: 3.13.0\n",
"TorchVision version: 0.9.0a0\n",
"ITK version: 5.1.2\n",
"tqdm version: 4.53.0\n",
"lmdb version: 1.1.1\n",
"psutil version: 5.8.0\n",
"pandas version: 1.1.4\n",
"einops version: 0.3.0\n",
"\n",
"For details about installing the optional dependencies, please visit:\n",
" https://docs.monai.io/en/latest/installation.html#installing-the-recommended-dependencies\n",
"\n"
]
}
],
"outputs": [],
"source": [
"# Copyright 2020 MONAI Consortium\n",
"# Licensed under the Apache License, Version 2.0 (the \"License\");\n",
"# you may not use this file except in compliance with the License.\n",
"# You may obtain a copy of the License at\n",
"# http://www.apache.org/licenses/LICENSE-2.0\n",
"# Unless required by applicable law or agreed to in writing, software\n",
"# distributed under the License is distributed on an \"AS IS\" BASIS,\n",
"# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n",
"# See the License for the specific language governing permissions and\n",
"# limitations under the License.\n",
"\n",
"import logging\n",
"import os\n",
"import sys\n",
Expand Down Expand Up @@ -162,19 +136,11 @@
},
{
"cell_type": "code",
"execution_count": 3,
"execution_count": null,
"metadata": {
"tags": []
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"/workspace/data/medical\n"
]
}
],
"outputs": [],
"source": [
"directory = os.environ.get(\"MONAI_DATA_DIRECTORY\")\n",
"root_dir = tempfile.mkdtemp() if directory is None else directory\n",
Expand All @@ -190,7 +156,7 @@
},
{
"cell_type": "code",
"execution_count": 3,
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -210,7 +176,7 @@
},
{
"cell_type": "code",
"execution_count": 4,
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -237,7 +203,7 @@
},
{
"cell_type": "code",
"execution_count": 5,
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
Expand Down Expand Up @@ -267,7 +233,7 @@
},
{
"cell_type": "code",
"execution_count": 6,
"execution_count": null,
"metadata": {
"tags": []
},
Expand Down Expand Up @@ -353,7 +319,7 @@
},
{
"cell_type": "code",
"execution_count": 8,
"execution_count": null,
"metadata": {
"pycharm": {
"is_executing": true
Expand Down Expand Up @@ -382,7 +348,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.8.12"
"version": "3.8.10"
}
},
"nbformat": 4,
Expand Down
48 changes: 47 additions & 1 deletion modules/dice_loss_metric_notes.ipynb
Original file line number Diff line number Diff line change
@@ -1,5 +1,22 @@
{
"cells": [
{
"cell_type": "markdown",
"id": "6459ddb8",
"metadata": {},
"source": [
"Copyright (c) MONAI Consortium \n",
"Licensed under the Apache License, Version 2.0 (the \"License\"); \n",
"you may not use this file except in compliance with the License. \n",
"You may obtain a copy of the License at \n",
"    http://www.apache.org/licenses/LICENSE-2.0 \n",
"Unless required by applicable law or agreed to in writing, software \n",
"distributed under the License is distributed on an \"AS IS\" BASIS, \n",
"WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. \n",
"See the License for the specific language governing permissions and \n",
"limitations under the License."
]
},
{
"cell_type": "markdown",
"id": "0c5bf94b-4f1d-4e94-a6e6-94644095e910",
Expand All @@ -10,6 +27,32 @@
"This notebook summarises some of the details relating to the `DiceLoss` and `DiceMetric` classes and their behaviour."
]
},
{
"cell_type": "markdown",
"id": "952771b9",
"metadata": {},
"source": [
"## Setup environment"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "7b7eb650",
"metadata": {},
"outputs": [],
"source": [
"!python -c \"import monai\" || pip install -q \"monai-weekly\""
]
},
{
"cell_type": "markdown",
"id": "55f81921",
"metadata": {},
"source": [
"## Setup imports"
]
},
{
"cell_type": "code",
"execution_count": 1,
Expand All @@ -18,10 +61,13 @@
"outputs": [],
"source": [
"import torch\n",
"from monai.config import print_config\n",
"from monai.losses import DiceLoss\n",
"from monai.metrics import DiceMetric\n",
"from monai.transforms import AsDiscrete, Compose\n",
"\n",
"print_config()\n",
"\n",
"\n",
"def print_tensor(name, t):\n",
" print(f\"{name}: {t.numpy().tolist()} shape: {tuple(t.shape)}\")"
Expand Down Expand Up @@ -412,7 +458,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.8.12"
"version": "3.8.10"
}
},
"nbformat": 4,
Expand Down
79 changes: 20 additions & 59 deletions modules/image_dataset.ipynb
Original file line number Diff line number Diff line change
@@ -1,5 +1,21 @@
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Copyright (c) MONAI Consortium \n",
"Licensed under the Apache License, Version 2.0 (the \"License\"); \n",
"you may not use this file except in compliance with the License. \n",
"You may obtain a copy of the License at \n",
"    http://www.apache.org/licenses/LICENSE-2.0 \n",
"Unless required by applicable law or agreed to in writing, software \n",
"distributed under the License is distributed on an \"AS IS\" BASIS, \n",
"WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. \n",
"See the License for the specific language governing permissions and \n",
"limitations under the License."
]
},
{
"cell_type": "markdown",
"metadata": {},
Expand Down Expand Up @@ -44,7 +60,7 @@
},
{
"cell_type": "code",
"execution_count": 2,
"execution_count": null,
"metadata": {
"execution": {
"iopub.execute_input": "2021-01-14T12:34:04.909819Z",
Expand All @@ -54,63 +70,8 @@
},
"tags": []
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"MONAI version: 1.1.0+16.gd990ff5e\n",
"Numpy version: 1.23.5\n",
"Pytorch version: 1.13.1\n",
"MONAI flags: HAS_EXT = False, USE_COMPILED = False, USE_META_DICT = False\n",
"MONAI rev id: d990ff5e6acab8655d507aeac934defd4f7a5fdc\n",
"MONAI __file__: /Users/Documents/MONAI/monai/__init__.py\n",
"\n",
"Optional dependencies:\n",
"Pytorch Ignite version: 0.4.10\n",
"Nibabel version: 5.0.0\n",
"scikit-image version: NOT INSTALLED or UNKNOWN VERSION.\n",
"Pillow version: 9.4.0\n",
"Tensorboard version: 2.11.0\n",
"gdown version: 4.6.0\n",
"TorchVision version: 0.14.1\n",
"tqdm version: 4.64.1\n",
"lmdb version: 1.4.0\n",
"psutil version: 5.9.4\n",
"pandas version: 1.5.2\n",
"einops version: 0.6.0\n",
"transformers version: 4.21.3\n",
"mlflow version: 2.1.1\n",
"pynrrd version: 1.0.0\n",
"\n",
"For details about installing the optional dependencies, please visit:\n",
" https://docs.monai.io/en/latest/installation.html#installing-the-recommended-dependencies\n",
"\n"
]
}
],
"outputs": [],
"source": [
"# Copyright 2020 - 2021 MONAI Consortium\n",
"# Licensed under the Apache License, Version 2.0 (the \"License\");\n",
"# you may not use this file except in compliance with the License.\n",
"# You may obtain a copy of the License at\n",
"# http://www.apache.org/licenses/LICENSE-2.0\n",
"# Unless required by applicable law or agreed to in writing, software\n",
"# distributed under the License is distributed on an \"AS IS\" BASIS,\n",
"# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n",
"# See the License for the specific language governing permissions and\n",
"# limitations under the License.\n",
"\n",
"# Copyright 2020 MONAI Consortium\n",
"# Licensed under the Apache License, Version 2.0 (the \"License\");\n",
"# you may not use this file except in compliance with the License.\n",
"# You may obtain a copy of the License at\n",
"# http://www.apache.org/licenses/LICENSE-2.0\n",
"# Unless required by applicable law or agreed to in writing, software\n",
"# distributed under the License is distributed on an \"AS IS\" BASIS,\n",
"# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n",
"# See the License for the specific language governing permissions and\n",
"# limitations under the License.\n",
"import os\n",
"import tempfile\n",
"import shutil\n",
Expand Down Expand Up @@ -195,7 +156,7 @@
" transform_with_metadata=True,\n",
")\n",
"print(\"image shape:\", img_dataset[0][0].shape)\n",
"print(\"seg. shape:\", img_dataset[0][1].shape)"
"print(\"seg shape:\", img_dataset[0][1].shape)"
]
},
{
Expand Down Expand Up @@ -231,7 +192,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.8.13"
"version": "3.8.10"
}
},
"nbformat": 4,
Expand Down
Loading