Skip to content

Commit ccbc830

Browse files
authored
Merge pull request #61 from zivy/moveToModernNotebooks
Move to modern notebooks
2 parents cf9928d + 2c2312a commit ccbc830

18 files changed

Lines changed: 115 additions & 120 deletions

.github/workflows/main.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ jobs:
4545
matrix:
4646
# using macos-15-intel, last available intel architecture. macos-latest is arm64 architecture.
4747
os: [ubuntu-latest, windows-latest, macos-latest, macos-15-intel]
48-
inputs: ["00_ or 01_ or 02_ or 03_ or 04_ or 05_", "06_ or 07_ or 08_ or 09_ or 10_"]
48+
inputs: ["00_ or 01_ or 03_ or 04_ or 05_", "06_ or 07_ or 08_ or 09_ or 10_"]
4949
runs-on: ${{ matrix.os }}
5050
steps:
5151
- uses: actions/checkout@v6

00_setup.ipynb

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,16 +13,19 @@
1313
"\n",
1414
"For additional details see the [Jupyter project documentation](https://jupyter.org/documentation) on Jupyter Notebook or JupyterLab.\n",
1515
"\n",
16-
"## Convenience\n",
16+
"## Convenience (notebook v7.x)\n",
1717
"By default the contents of the Jupyter notebooks do not occupy the full browser window width. To take advantage of the full window width you can either configure each notebook independently by adding the following into a code cell:\n",
18+
"\n",
1819
"```\n",
19-
"from IPython.core.display import display, HTML\n",
20-
"display(HTML(\"<style>.container { width:100% !important; }</style>\"))\n",
20+
"from IPython.display import display, HTML\n",
21+
"display(HTML(\"<style>:root { --jp-notebook-max-width: 100% !important; }</style>\"))\n",
2122
"```\n",
2223
"Or apply this configuration to all notebooks by adding the following to\n",
2324
"the custom.css jupyter configuration file:\n",
2425
"```\n",
25-
".container { width:100% !important; }\n",
26+
":root {\n",
27+
" --jp-notebook-max-width: 100% !important;\n",
28+
"}\n",
2629
"```\n",
2730
"On OSX/Linux this file is found in `~/.jupyter/custom/custom.css` on windows it is\n",
2831
"found in `C:\\Users\\[your_user_name]\\.jupyter\\custom\\custom.css`.\n",
@@ -120,7 +123,9 @@
120123
},
121124
{
122125
"cell_type": "markdown",
123-
"metadata": {},
126+
"metadata": {
127+
"jp-MarkdownHeadingCollapsed": true
128+
},
124129
"source": [
125130
"<a href=\"01_spatial_transformations.ipynb\"><h2 align=right>Next &raquo;</h2></a>"
126131
]
@@ -142,9 +147,9 @@
142147
"name": "python",
143148
"nbconvert_exporter": "python",
144149
"pygments_lexer": "ipython3",
145-
"version": "3.9.13"
150+
"version": "3.13.5"
146151
}
147152
},
148153
"nbformat": 4,
149-
"nbformat_minor": 2
154+
"nbformat_minor": 4
150155
}

01_spatial_transformations.ipynb

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -296,6 +296,7 @@
296296
" plt.xlim(xlim)\n",
297297
" plt.ylim(ylim)\n",
298298
" plt.legend(loc=(0.25, 1.01))\n",
299+
" plt.show()\n",
299300
"\n",
300301
"\n",
301302
"# 2D square centered on (0,0)\n",
@@ -667,7 +668,7 @@
667668
"original_transformed = np.array(bspline.TransformPoint(pnt))\n",
668669
"secondary_transformed = np.array(displacement_field_transform.TransformPoint(pnt))\n",
669670
"print(\"Original transformation result: {0}\".format(original_transformed))\n",
670-
"print(\"Deformaiton field transformation result: {0}\".format(secondary_transformed))\n",
671+
"print(\"Deformation field transformation result: {0}\".format(secondary_transformed))\n",
671672
"print(\n",
672673
" \"Difference between transformed points is: {0}\".format(\n",
673674
" np.linalg.norm(original_transformed - secondary_transformed)\n",
@@ -863,7 +864,9 @@
863864
},
864865
{
865866
"cell_type": "markdown",
866-
"metadata": {},
867+
"metadata": {
868+
"jp-MarkdownHeadingCollapsed": true
869+
},
867870
"source": [
868871
"<a href=\"02_images_and_resampling.ipynb\"><h2 align=right>Next &raquo;</h2></a>"
869872
]
@@ -885,9 +888,9 @@
885888
"name": "python",
886889
"nbconvert_exporter": "python",
887890
"pygments_lexer": "ipython3",
888-
"version": "3.9.13"
891+
"version": "3.13.5"
889892
}
890893
},
891894
"nbformat": 4,
892-
"nbformat_minor": 2
895+
"nbformat_minor": 4
893896
}

02_images_and_resampling.ipynb

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,10 @@
135135
{
136136
"cell_type": "markdown",
137137
"metadata": {
138-
"collapsed": true
138+
"collapsed": true,
139+
"jupyter": {
140+
"outputs_hidden": true
141+
}
139142
},
140143
"source": [
141144
"Or, creation from file."
@@ -309,7 +312,7 @@
309312
"cell_type": "markdown",
310313
"metadata": {},
311314
"source": [
312-
"Comparative operators (&gt;, &gt;=, &lt;, &lt;=, ==) are also supported, returning binary images."
315+
"Comparative operators (&gt;, &gt;=, &lt;, &lt;=, ==) are also supported, returning binary images with pixel type of sitkUInt8."
313316
]
314317
},
315318
{
@@ -552,7 +555,10 @@
552555
{
553556
"cell_type": "markdown",
554557
"metadata": {
555-
"collapsed": true
558+
"collapsed": true,
559+
"jupyter": {
560+
"outputs_hidden": true
561+
}
556562
},
557563
"source": [
558564
"Write the volume as a series of JPEGs. The WriteImage function receives a volume and a list of images names and writes the volume according to the z axis. For a displayable result we need to rescale the image intensities (default is [0,255]) since the JPEG format requires a cast to the UInt8 pixel type."
@@ -820,9 +826,9 @@
820826
"name": "python",
821827
"nbconvert_exporter": "python",
822828
"pygments_lexer": "ipython3",
823-
"version": "3.9.13"
829+
"version": "3.13.5"
824830
}
825831
},
826832
"nbformat": 4,
827-
"nbformat_minor": 2
833+
"nbformat_minor": 4
828834
}

03_trust_but_verify.ipynb

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -70,11 +70,10 @@
7070
"import tempfile\n",
7171
"import pickle\n",
7272
"\n",
73-
"%matplotlib notebook\n",
73+
"%matplotlib ipympl\n",
7474
"import matplotlib.pyplot as plt\n",
7575
"import ipywidgets as widgets\n",
7676
"\n",
77-
"\n",
7877
"# utility method that either downloads data from the Girder repository or\n",
7978
"# if already downloaded returns the file name for reading from disk (cached data)\n",
8079
"from downloaddata import fetch_data as fdata\n",
@@ -498,6 +497,7 @@
498497
" )\n",
499498
" self.fig.tight_layout()\n",
500499
" self.update_display()\n",
500+
" plt.show()\n",
501501
"\n",
502502
" def create_ui(self):\n",
503503
" # Create the active GUI components. Height and width are specified in 'em' units. This is\n",
@@ -677,9 +677,7 @@
677677
{
678678
"cell_type": "code",
679679
"execution_count": null,
680-
"metadata": {
681-
"scrolled": false
682-
},
680+
"metadata": {},
683681
"outputs": [],
684682
"source": [
685683
"with open(faux_image_volume_file_name, \"rb\") as fp:\n",
@@ -734,9 +732,7 @@
734732
{
735733
"cell_type": "code",
736734
"execution_count": null,
737-
"metadata": {
738-
"scrolled": false
739-
},
735+
"metadata": {},
740736
"outputs": [],
741737
"source": [
742738
"with open(faux_series_volume_file_name, \"rb\") as fp:\n",
@@ -764,7 +760,9 @@
764760
},
765761
{
766762
"cell_type": "markdown",
767-
"metadata": {},
763+
"metadata": {
764+
"jp-MarkdownHeadingCollapsed": true
765+
},
768766
"source": [
769767
"<a href=\"04_data_augmentation.ipynb\"><h2 align=right>Next &raquo;</h2></a>"
770768
]
@@ -786,7 +784,7 @@
786784
"name": "python",
787785
"nbconvert_exporter": "python",
788786
"pygments_lexer": "ipython3",
789-
"version": "3.9.13"
787+
"version": "3.13.5"
790788
}
791789
},
792790
"nbformat": 4,

04_data_augmentation.ipynb

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
"import numpy as np\n",
3030
"import os\n",
3131
"\n",
32-
"%matplotlib notebook\n",
32+
"%matplotlib ipympl\n",
3333
"import gui\n",
3434
"\n",
3535
"from downloaddata import fetch_data as fdata\n",
@@ -386,7 +386,10 @@
386386
{
387387
"cell_type": "markdown",
388388
"metadata": {
389-
"collapsed": true
389+
"collapsed": true,
390+
"jupyter": {
391+
"outputs_hidden": true
392+
}
390393
},
391394
"source": [
392395
"## What about flipping\n",
@@ -884,9 +887,9 @@
884887
"name": "python",
885888
"nbconvert_exporter": "python",
886889
"pygments_lexer": "ipython3",
887-
"version": "3.9.13"
890+
"version": "3.13.5"
888891
}
889892
},
890893
"nbformat": 4,
891-
"nbformat_minor": 2
894+
"nbformat_minor": 4
892895
}

05_basic_registration.ipynb

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@
130130
"import SimpleITK as sitk\n",
131131
"from downloaddata import fetch_data as fdata\n",
132132
"\n",
133-
"%matplotlib notebook\n",
133+
"%matplotlib ipympl\n",
134134
"import gui\n",
135135
"import registration_gui as rgui\n",
136136
"\n",
@@ -445,7 +445,10 @@
445445
{
446446
"cell_type": "markdown",
447447
"metadata": {
448-
"collapsed": true
448+
"collapsed": true,
449+
"jupyter": {
450+
"outputs_hidden": true
451+
}
449452
},
450453
"source": [
451454
"## Initialization\n",
@@ -757,9 +760,9 @@
757760
"name": "python",
758761
"nbconvert_exporter": "python",
759762
"pygments_lexer": "ipython3",
760-
"version": "3.9.13"
763+
"version": "3.13.5"
761764
}
762765
},
763766
"nbformat": 4,
764-
"nbformat_minor": 2
767+
"nbformat_minor": 4
765768
}

06_advanced_registration.ipynb

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -687,7 +687,11 @@
687687
{
688688
"cell_type": "markdown",
689689
"metadata": {
690-
"collapsed": true
690+
"collapsed": true,
691+
"jp-MarkdownHeadingCollapsed": true,
692+
"jupyter": {
693+
"outputs_hidden": true
694+
}
691695
},
692696
"source": [
693697
"<a href=\"07_registration_application.ipynb\"><h2 align=right>Next &raquo;</h2></a>"
@@ -710,9 +714,9 @@
710714
"name": "python",
711715
"nbconvert_exporter": "python",
712716
"pygments_lexer": "ipython3",
713-
"version": "3.9.13"
717+
"version": "3.13.5"
714718
}
715719
},
716720
"nbformat": 4,
717-
"nbformat_minor": 2
721+
"nbformat_minor": 4
718722
}

07_registration_application.ipynb

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@
4545
"import os.path\n",
4646
"import copy\n",
4747
"\n",
48-
"%matplotlib notebook\n",
48+
"%matplotlib ipympl\n",
4949
"import gui\n",
5050
"import matplotlib.pyplot as plt\n",
5151
"\n",
@@ -115,9 +115,7 @@
115115
{
116116
"cell_type": "code",
117117
"execution_count": null,
118-
"metadata": {
119-
"scrolled": false
120-
},
118+
"metadata": {},
121119
"outputs": [],
122120
"source": [
123121
"# The ROI we specify is in a region that is expected to have uniform intensities.\n",
@@ -473,9 +471,7 @@
473471
{
474472
"cell_type": "code",
475473
"execution_count": null,
476-
"metadata": {
477-
"scrolled": false
478-
},
474+
"metadata": {},
479475
"outputs": [],
480476
"source": [
481477
"metric_sampling_percentage = 0.2\n",
@@ -684,9 +680,9 @@
684680
"name": "python",
685681
"nbconvert_exporter": "python",
686682
"pygments_lexer": "ipython3",
687-
"version": "3.9.13"
683+
"version": "3.13.5"
688684
}
689685
},
690686
"nbformat": 4,
691-
"nbformat_minor": 2
687+
"nbformat_minor": 4
692688
}

08_segmentation_and_shape_analysis.ipynb

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
"import SimpleITK as sitk\n",
2424
"import pandas as pd\n",
2525
"\n",
26-
"%matplotlib notebook\n",
26+
"%matplotlib ipympl\n",
2727
"\n",
2828
"import matplotlib.pyplot as plt\n",
2929
"import gui\n",
@@ -432,9 +432,7 @@
432432
{
433433
"cell_type": "code",
434434
"execution_count": null,
435-
"metadata": {
436-
"scrolled": false
437-
},
435+
"metadata": {},
438436
"outputs": [],
439437
"source": [
440438
"bacteria_labels = shape_stats.GetLabels()\n",
@@ -505,9 +503,9 @@
505503
"name": "python",
506504
"nbconvert_exporter": "python",
507505
"pygments_lexer": "ipython3",
508-
"version": "3.9.13"
506+
"version": "3.13.5"
509507
}
510508
},
511509
"nbformat": 4,
512-
"nbformat_minor": 2
510+
"nbformat_minor": 4
513511
}

0 commit comments

Comments
 (0)