Skip to content

Commit aede152

Browse files
authored
Merge pull request #491 from zivy/colab
Add support for Google Colab
2 parents ae4595a + d21f1a9 commit aede152

25 files changed

+849
-145
lines changed

Python/01_Image_Basics.ipynb

Lines changed: 35 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,38 @@
44
"cell_type": "markdown",
55
"metadata": {},
66
"source": [
7-
"# SimpleITK Image Basics <a href=\"https://mybinder.org/v2/gh/InsightSoftwareConsortium/SimpleITK-Notebooks/master?filepath=Python%2F01_Image_Basics.ipynb\"><img style=\"float: right;\" src=\"https://mybinder.org/badge_logo.svg\"></a>\n",
7+
"<table align=\"right\">\n",
8+
" <tr>\n",
9+
" <td>\n",
10+
" <a href=\"https://mybinder.org/v2/gh/InsightSoftwareConsortium/SimpleITK-Notebooks/main?filepath=Python%2F01_Image_Basics.ipynb\"><img src=\"https://mybinder.org/badge_logo.svg\" alt=\"Binder\"></a> \n",
11+
" </td>\n",
12+
" <td>\n",
13+
" <a href=\"https://colab.research.google.com/github/InsightSoftwareConsortium/SimpleITK-Notebooks/blob/main/Python/01_Image_Basics.ipynb\"><img src=\"https://colab.research.google.com/assets/colab-badge.svg\" alt=\"Colab\"/>\n",
14+
" </td>\n",
15+
" </tr>\n",
16+
"</table>"
17+
]
18+
},
19+
{
20+
"cell_type": "code",
21+
"execution_count": null,
22+
"metadata": {},
23+
"outputs": [],
24+
"source": [
25+
"# Setup to enable running the notebook in the Google Colab environment\n",
26+
"import os\n",
27+
"\n",
28+
"if \"COLAB_NOTEBOOK_ID\" in os.environ:\n",
29+
" !git clone https://github.com/InsightSoftwareConsortium/SimpleITK-Notebooks\n",
30+
" %cd SimpleITK-Notebooks/Python\n",
31+
" !pip install -q -r requirements.txt"
32+
]
33+
},
34+
{
35+
"cell_type": "markdown",
36+
"metadata": {},
37+
"source": [
38+
"# SimpleITK Image Basics \n",
839
"\n",
940
"This document will give a brief orientation to the SimpleITK Image class.\n",
1041
"\n",
@@ -427,7 +458,7 @@
427458
"metadata": {
428459
"anaconda-cloud": {},
429460
"kernelspec": {
430-
"display_name": "Python 3",
461+
"display_name": "Python 3 (ipykernel)",
431462
"language": "python",
432463
"name": "python3"
433464
},
@@ -441,9 +472,9 @@
441472
"name": "python",
442473
"nbconvert_exporter": "python",
443474
"pygments_lexer": "ipython3",
444-
"version": "3.8.5"
475+
"version": "3.12.11"
445476
}
446477
},
447478
"nbformat": 4,
448-
"nbformat_minor": 1
479+
"nbformat_minor": 4
449480
}

Python/02_Pythonic_Image.ipynb

Lines changed: 33 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,38 @@
44
"cell_type": "markdown",
55
"metadata": {},
66
"source": [
7-
"# Pythonic Syntactic Sugar <a href=\"https://mybinder.org/v2/gh/InsightSoftwareConsortium/SimpleITK-Notebooks/master?filepath=Python%2F02_Pythonic_Image.ipynb\"><img style=\"float: right;\" src=\"https://mybinder.org/badge_logo.svg\"></a>\n",
7+
"<table align=\"right\">\n",
8+
" <tr>\n",
9+
" <td>\n",
10+
" <a href=\"https://mybinder.org/v2/gh/InsightSoftwareConsortium/SimpleITK-Notebooks/main?filepath=Python%2F02_Pythonic_Image.ipynb\"><img style=\"float: right;\" src=\"https://mybinder.org/badge_logo.svg\" alt=\"Binder\"></a> \n",
11+
" </td>\n",
12+
" <td>\n",
13+
" <a href=\"https://colab.research.google.com/github/InsightSoftwareConsortium/SimpleITK-Notebooks/blob/main/Python/02_Pythonic_Image.ipynb\"><img src=\"https://colab.research.google.com/assets/colab-badge.svg\" alt=\"Colab\"/>\n",
14+
" </td>\n",
15+
" </tr>\n",
16+
"</table>"
17+
]
18+
},
19+
{
20+
"cell_type": "code",
21+
"execution_count": null,
22+
"metadata": {},
23+
"outputs": [],
24+
"source": [
25+
"# Setup to enable running the notebook in the Google Colab environment\n",
26+
"import os\n",
27+
"\n",
28+
"if \"COLAB_NOTEBOOK_ID\" in os.environ:\n",
29+
" !git clone https://github.com/InsightSoftwareConsortium/SimpleITK-Notebooks\n",
30+
" %cd SimpleITK-Notebooks/Python\n",
31+
" !pip install -q -r requirements.txt"
32+
]
33+
},
34+
{
35+
"cell_type": "markdown",
36+
"metadata": {},
37+
"source": [
38+
"# Pythonic Syntactic Sugar\n",
839
"\n",
940
"The Image Basics Notebook was straight forward and closely follows ITK's C++ interface.\n",
1041
"\n",
@@ -423,7 +454,7 @@
423454
"name": "python",
424455
"nbconvert_exporter": "python",
425456
"pygments_lexer": "ipython3",
426-
"version": "3.10.11"
457+
"version": "3.12.11"
427458
}
428459
},
429460
"nbformat": 4,

Python/03_Image_Details.ipynb

Lines changed: 33 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,38 @@
44
"cell_type": "markdown",
55
"metadata": {},
66
"source": [
7-
"# SimpleITK Images, They're Physical Objects <a href=\"https://mybinder.org/v2/gh/InsightSoftwareConsortium/SimpleITK-Notebooks/master?filepath=Python%2F03_Image_Details.ipynb\"><img style=\"float: right;\" src=\"https://mybinder.org/badge_logo.svg\"></a>\n",
7+
"<table align=\"right\">\n",
8+
" <tr>\n",
9+
" <td>\n",
10+
" <a href=\"https://mybinder.org/v2/gh/InsightSoftwareConsortium/SimpleITK-Notebooks/main?filepath=Python%2F03_Image_Details.ipynb\"><img style=\"float: right;\" src=\"https://mybinder.org/badge_logo.svg\" alt=\"Binder\"></a>\n",
11+
" </td>\n",
12+
" <td>\n",
13+
" <a href=\"https://colab.research.google.com/github/InsightSoftwareConsortium/SimpleITK-Notebooks/blob/main/Python/03_Image_Details.ipynb\"><img src=\"https://colab.research.google.com/assets/colab-badge.svg\" alt=\"Colab\"/>\n",
14+
" </td>\n",
15+
" </tr>\n",
16+
"</table>"
17+
]
18+
},
19+
{
20+
"cell_type": "code",
21+
"execution_count": null,
22+
"metadata": {},
23+
"outputs": [],
24+
"source": [
25+
"# Setup to enable running the notebook in the Google Colab environment\n",
26+
"import os\n",
27+
"\n",
28+
"if \"COLAB_NOTEBOOK_ID\" in os.environ:\n",
29+
" !git clone https://github.com/InsightSoftwareConsortium/SimpleITK-Notebooks\n",
30+
" %cd SimpleITK-Notebooks/Python\n",
31+
" !pip install -q -r requirements.txt"
32+
]
33+
},
34+
{
35+
"cell_type": "markdown",
36+
"metadata": {},
37+
"source": [
38+
"# SimpleITK Images, They're Physical Objects\n",
839
"\n",
940
"**SimpleITK conventions**:\n",
1041
"* Image access is in x,y,z order, image.GetPixel(x,y,z) or image[x,y,z], with zero based indexing.\n",
@@ -1429,7 +1460,7 @@
14291460
"name": "python",
14301461
"nbconvert_exporter": "python",
14311462
"pygments_lexer": "ipython3",
1432-
"version": "3.11.10"
1463+
"version": "3.12.11"
14331464
}
14341465
},
14351466
"nbformat": 4,

Python/04_Image_Display.ipynb

Lines changed: 33 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,38 @@
44
"cell_type": "markdown",
55
"metadata": {},
66
"source": [
7-
"# Image Display <a href=\"https://mybinder.org/v2/gh/InsightSoftwareConsortium/SimpleITK-Notebooks/master?filepath=Python%2F04_Image_Display.ipynb\"><img style=\"float: right;\" src=\"https://mybinder.org/badge_logo.svg\"></a>\n",
7+
"<table align=\"right\">\n",
8+
" <tr>\n",
9+
" <td>\n",
10+
" <a href=\"https://mybinder.org/v2/gh/InsightSoftwareConsortium/SimpleITK-Notebooks/main?filepath=Python%2F04_Image_Display.ipynb\"><img style=\"float: right;\" src=\"https://mybinder.org/badge_logo.svg\" alt=\"Binder\"></a>\n",
11+
" </td>\n",
12+
" <td>\n",
13+
" <a href=\"https://colab.research.google.com/github/InsightSoftwareConsortium/SimpleITK-Notebooks/blob/main/Python/04_Image_Display.ipynb\"><img src=\"https://colab.research.google.com/assets/colab-badge.svg\" alt=\"Colab\"/>\n",
14+
" </td>\n",
15+
" </tr>\n",
16+
"</table>"
17+
]
18+
},
19+
{
20+
"cell_type": "code",
21+
"execution_count": null,
22+
"metadata": {},
23+
"outputs": [],
24+
"source": [
25+
"# Setup to enable running the notebook in the Google Colab environment\n",
26+
"import os\n",
27+
"\n",
28+
"if \"COLAB_NOTEBOOK_ID\" in os.environ:\n",
29+
" !git clone https://github.com/InsightSoftwareConsortium/SimpleITK-Notebooks\n",
30+
" %cd SimpleITK-Notebooks/Python\n",
31+
" !pip install -q -r requirements.txt"
32+
]
33+
},
34+
{
35+
"cell_type": "markdown",
36+
"metadata": {},
37+
"source": [
38+
"# Image Display\n",
839
"\n",
940
"The native SimpleITK approach to displaying images is to use an external viewing program. In the notebook environment it is convenient to use matplotlib to display inline images and if the need arises we can implement some reasonably rich inline graphical user interfaces, combining control components from the ipywidgets package and matplotlib based display.\n",
1041
"\n",
@@ -338,7 +369,7 @@
338369
"name": "python",
339370
"nbconvert_exporter": "python",
340371
"pygments_lexer": "ipython3",
341-
"version": "3.8.12"
372+
"version": "3.12.11"
342373
}
343374
},
344375
"nbformat": 4,

Python/05_Results_Visualization.ipynb

Lines changed: 33 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,38 @@
44
"cell_type": "markdown",
55
"metadata": {},
66
"source": [
7-
"# Visualization of Segmentation and Registration Results <a href=\"https://mybinder.org/v2/gh/InsightSoftwareConsortium/SimpleITK-Notebooks/master?filepath=Python%2F05_Results_Visualization.ipynb\"><img style=\"float: right;\" src=\"https://mybinder.org/badge_logo.svg\"></a>\n",
7+
"<table align=\"right\">\n",
8+
" <tr>\n",
9+
" <td>\n",
10+
" <a href=\"https://mybinder.org/v2/gh/InsightSoftwareConsortium/SimpleITK-Notebooks/main?filepath=Python%2F05_Results_Visualization.ipynb\"><img style=\"float: right;\" src=\"https://mybinder.org/badge_logo.svg\" alt=\"Binder\"></a>\n",
11+
" </td>\n",
12+
" <td>\n",
13+
" <a href=\"https://colab.research.google.com/github/InsightSoftwareConsortium/SimpleITK-Notebooks/blob/main/Python/05_Results_Visualization.ipynb\"><img src=\"https://colab.research.google.com/assets/colab-badge.svg\" alt=\"Colab\"/>\n",
14+
" </td>\n",
15+
" </tr>\n",
16+
"</table>"
17+
]
18+
},
19+
{
20+
"cell_type": "code",
21+
"execution_count": null,
22+
"metadata": {},
23+
"outputs": [],
24+
"source": [
25+
"# Setup to enable running the notebook in the Google Colab environment\n",
26+
"import os\n",
27+
"\n",
28+
"if \"COLAB_NOTEBOOK_ID\" in os.environ:\n",
29+
" !git clone https://github.com/InsightSoftwareConsortium/SimpleITK-Notebooks\n",
30+
" %cd SimpleITK-Notebooks/Python\n",
31+
" !pip install -q -r requirements.txt"
32+
]
33+
},
34+
{
35+
"cell_type": "markdown",
36+
"metadata": {},
37+
"source": [
38+
"# Visualization of Segmentation and Registration Results\n",
839
"\n",
940
"In this notebook we illustrate various ways one can display the results of segmentation and registration algorithms so that they can be easily incorporated into a manuscript or presentation. For interactive data exploration we recommend using dedicated programs (e.g. 3D slicer). \n",
1041
"\n",
@@ -1430,7 +1461,7 @@
14301461
"name": "python",
14311462
"nbconvert_exporter": "python",
14321463
"pygments_lexer": "ipython3",
1433-
"version": "3.8.12"
1464+
"version": "3.12.11"
14341465
}
14351466
},
14361467
"nbformat": 4,

Python/10_matplotlibs_imshow.ipynb

Lines changed: 37 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,38 @@
44
"cell_type": "markdown",
55
"metadata": {},
66
"source": [
7-
"# Using `matplotlib` to display inline images <a href=\"https://mybinder.org/v2/gh/InsightSoftwareConsortium/SimpleITK-Notebooks/master?filepath=Python%2F10_matplotlib's_imshow.ipynb\"><img style=\"float: right;\" src=\"https://mybinder.org/badge_logo.svg\"></a>\n",
7+
"<table align=\"right\">\n",
8+
" <tr>\n",
9+
" <td>\n",
10+
" <a href=\"https://mybinder.org/v2/gh/InsightSoftwareConsortium/SimpleITK-Notebooks/main?filepath=Python%2F10_matplotlibs_imshow.ipynb\"><img style=\"float: right;\" src=\"https://mybinder.org/badge_logo.svg\" alt=\"Binder\"></a>\n",
11+
" </td>\n",
12+
" <td>\n",
13+
" <a href=\"https://colab.research.google.com/github/InsightSoftwareConsortium/SimpleITK-Notebooks/blob/main/Python/10_matplotlibs_imshow.ipynb\"><img src=\"https://colab.research.google.com/assets/colab-badge.svg\" alt=\"Colab\"/>\n",
14+
" </td>\n",
15+
" </tr>\n",
16+
"</table>"
17+
]
18+
},
19+
{
20+
"cell_type": "code",
21+
"execution_count": null,
22+
"metadata": {},
23+
"outputs": [],
24+
"source": [
25+
"# Setup to enable running the notebook in the Google Colab environment\n",
26+
"import os\n",
27+
"\n",
28+
"if \"COLAB_NOTEBOOK_ID\" in os.environ:\n",
29+
" !git clone https://github.com/InsightSoftwareConsortium/SimpleITK-Notebooks\n",
30+
" %cd SimpleITK-Notebooks/Python\n",
31+
" !pip install -q -r requirements.txt"
32+
]
33+
},
34+
{
35+
"cell_type": "markdown",
36+
"metadata": {},
37+
"source": [
38+
"# Using `matplotlib` to display inline images\n",
839
"\n",
940
"In this notebook we will explore using `matplotlib` to display images in our notebooks, and work towards developing a reusable function to display 2D,3D, color, and label overlays for SimpleITK images.\n",
1041
"\n",
@@ -15,6 +46,7 @@
1546
"cell_type": "code",
1647
"execution_count": null,
1748
"metadata": {
49+
"collapsed": true,
1850
"jupyter": {
1951
"outputs_hidden": true
2052
}
@@ -85,6 +117,7 @@
85117
"cell_type": "code",
86118
"execution_count": null,
87119
"metadata": {
120+
"collapsed": true,
88121
"jupyter": {
89122
"outputs_hidden": true
90123
}
@@ -132,6 +165,7 @@
132165
"cell_type": "code",
133166
"execution_count": null,
134167
"metadata": {
168+
"collapsed": true,
135169
"jupyter": {
136170
"outputs_hidden": true
137171
}
@@ -338,6 +372,7 @@
338372
"cell_type": "code",
339373
"execution_count": null,
340374
"metadata": {
375+
"collapsed": true,
341376
"jupyter": {
342377
"outputs_hidden": true
343378
}
@@ -540,7 +575,7 @@
540575
"name": "python",
541576
"nbconvert_exporter": "python",
542577
"pygments_lexer": "ipython3",
543-
"version": "3.8.12"
578+
"version": "3.12.11"
544579
}
545580
},
546581
"nbformat": 4,

Python/11_Progress.ipynb

Lines changed: 33 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,38 @@
44
"cell_type": "markdown",
55
"metadata": {},
66
"source": [
7-
"# Progress Reporting and Command Observers <a href=\"https://mybinder.org/v2/gh/InsightSoftwareConsortium/SimpleITK-Notebooks/master?filepath=Python%2F11_Progress.ipynb\"><img style=\"float: right;\" src=\"https://mybinder.org/badge_logo.svg\"></a>\n",
7+
"<table align=\"right\">\n",
8+
" <tr>\n",
9+
" <td>\n",
10+
" <a href=\"https://mybinder.org/v2/gh/InsightSoftwareConsortium/SimpleITK-Notebooks/main?filepath=Python%2F11_Progress.ipynb\"><img style=\"float: right;\" src=\"https://mybinder.org/badge_logo.svg\" alt=\"Binder\"></a>\n",
11+
" </td>\n",
12+
" <td>\n",
13+
" <a href=\"https://colab.research.google.com/github/InsightSoftwareConsortium/SimpleITK-Notebooks/blob/main/Python/11_Progress.ipynb\"><img src=\"https://colab.research.google.com/assets/colab-badge.svg\" alt=\"Colab\"/>\n",
14+
" </td>\n",
15+
" </tr>\n",
16+
"</table>"
17+
]
18+
},
19+
{
20+
"cell_type": "code",
21+
"execution_count": null,
22+
"metadata": {},
23+
"outputs": [],
24+
"source": [
25+
"# Setup to enable running the notebook in the Google Colab environment\n",
26+
"import os\n",
27+
"\n",
28+
"if \"COLAB_NOTEBOOK_ID\" in os.environ:\n",
29+
" !git clone https://github.com/InsightSoftwareConsortium/SimpleITK-Notebooks\n",
30+
" %cd SimpleITK-Notebooks/Python\n",
31+
" !pip install -q -r requirements.txt"
32+
]
33+
},
34+
{
35+
"cell_type": "markdown",
36+
"metadata": {},
37+
"source": [
38+
"# Progress Reporting and Command Observers\n",
839
"\n",
940
"SimpleITK `Filter`s and other classes derived from `ProcessObject`s have the ability for user code to be executed when certain events occur. This is known as the Command and Observer design patters to implement user callbacks. This allows for the monitoring and abortion of processes as they are being executed.\n",
1041
"\n",
@@ -571,7 +602,7 @@
571602
"name": "python",
572603
"nbconvert_exporter": "python",
573604
"pygments_lexer": "ipython3",
574-
"version": "3.8.12"
605+
"version": "3.12.11"
575606
}
576607
},
577608
"nbformat": 4,

0 commit comments

Comments
 (0)