Skip to content

Commit

Permalink
DOC: Use compare widget in notebooks
Browse files Browse the repository at this point in the history
  • Loading branch information
thewtex committed Jan 20, 2020
1 parent 9e5e12d commit e76fbf0
Show file tree
Hide file tree
Showing 3 changed files with 68 additions and 186 deletions.
125 changes: 28 additions & 97 deletions examples/0_HelloRegistrationWorld.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@
},
{
"cell_type": "code",
"execution_count": 1,
"execution_count": 2,
"metadata": {},
"outputs": [],
"source": [
"import itk\n",
"from itkwidgets import view, checkerboard"
"from itkwidgets import view, compare, checkerboard"
]
},
{
Expand All @@ -30,80 +30,41 @@
"source": [
"In image registration, we typically identify the two images as the fixed and moving image. Our goal is to find the spatial transformation that makes the moving image align with the fixed image.\n",
"\n",
"First, let's load our **fixed image**."
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {},
"outputs": [],
"source": [
"fixed = itk.imread('data/CT_2D_head_fixed.mha', itk.F)"
"First, let's load our **fixed image** and the image we will align to our fixed image, the **moving image**."
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {},
"outputs": [
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "e4158972d1a04e098425a4f40d0e7c4b",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"Viewer(geometries=[], gradient_opacity=0.22, point_sets=[], rendered_image=<itkImagePython.itkImageF2; proxy o…"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"view(fixed, ui_collapsed=True)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"And the image we will align to our fixed image, the **moving image**."
]
},
{
"cell_type": "code",
"execution_count": 4,
"metadata": {},
"outputs": [],
"source": [
"fixed = itk.imread('data/CT_2D_head_fixed.mha', itk.F)\n",
"moving = itk.imread('data/CT_2D_head_moving.mha', itk.F)"
]
},
{
"cell_type": "code",
"execution_count": 5,
"execution_count": 4,
"metadata": {},
"outputs": [
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "7a65180dd10d4e2ba85b81ade160e3ab",
"model_id": "b3ebeb5e96b64508a72580cd02bf86c3",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"Viewer(geometries=[], gradient_opacity=0.22, point_sets=[], rendered_image=<itkImagePython.itkImageF2; proxy o"
"AppLayout(children=(HBox(children=(Label(value='Link:'), Checkbox(value=False, description='cmap'), Checkbox(v"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"view(moving, ui_collapsed=True)"
"compare(fixed, moving, ui_collapsed=True)"
]
},
{
Expand All @@ -115,13 +76,13 @@
},
{
"cell_type": "code",
"execution_count": 6,
"execution_count": 5,
"metadata": {},
"outputs": [
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "8c8f18d0f55344e7b3eb44b56a1f0bb6",
"model_id": "9c0aa44dab00479eb61af83594bab01a",
"version_major": 2,
"version_minor": 0
},
Expand All @@ -139,7 +100,7 @@
},
{
"cell_type": "code",
"execution_count": 7,
"execution_count": 6,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -156,37 +117,37 @@
},
{
"cell_type": "code",
"execution_count": 8,
"execution_count": 7,
"metadata": {},
"outputs": [
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "ec232d21042e4f159272bec55c8a24a0",
"model_id": "30f9e21a18aa4ba3bbd0b07122785301",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"Viewer(geometries=[], gradient_opacity=0.22, point_sets=[], rendered_image=<itkImagePython.itkImageF2; proxy o"
"AppLayout(children=(HBox(children=(Label(value='Link:'), Checkbox(value=False, description='cmap'), Checkbox(v"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"view(registered_moving, ui_collapsed=True)"
"compare(fixed, registered_moving, ui_collapsed=True)"
]
},
{
"cell_type": "code",
"execution_count": 9,
"execution_count": 8,
"metadata": {},
"outputs": [
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "a6e2d7c491ba4d50b45b35e03e85a475",
"model_id": "4aea9949acf8440d88d0e2106f41f21e",
"version_major": 2,
"version_minor": 0
},
Expand All @@ -211,79 +172,48 @@
},
{
"cell_type": "code",
"execution_count": 10,
"metadata": {},
"outputs": [],
"source": [
"fixed = itk.imread('data/CT_3D_lung_fixed.mha', itk.F)"
]
},
{
"cell_type": "code",
"execution_count": 11,
"metadata": {},
"outputs": [
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "92cdb0e11f354bd49916557e2d6be968",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"Viewer(geometries=[], gradient_opacity=0.22, point_sets=[], rendered_image=<itkImagePython.itkImageF3; proxy o…"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"view(fixed)"
]
},
{
"cell_type": "code",
"execution_count": 12,
"execution_count": 9,
"metadata": {},
"outputs": [],
"source": [
"fixed = itk.imread('data/CT_3D_lung_fixed.mha', itk.F)\n",
"moving = itk.imread('data/CT_3D_lung_moving.mha', itk.F)"
]
},
{
"cell_type": "code",
"execution_count": 13,
"execution_count": 12,
"metadata": {},
"outputs": [
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "b52c532b5c724faaa5d22cbe4460a504",
"model_id": "3435f5147c574e35b581944cb40a3177",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"Viewer(geometries=[], gradient_opacity=0.22, point_sets=[], rendered_image=<itkImagePython.itkImageF3; proxy o"
"AppLayout(children=(HBox(children=(Label(value='Link:'), Checkbox(value=True, description='cmap'), Checkbox(va"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"view(moving)"
"# A human lung at different time points\n",
"compare(fixed, moving, link_cmap=True, link_gradient_opacity=True)"
]
},
{
"cell_type": "code",
"execution_count": 14,
"execution_count": 13,
"metadata": {},
"outputs": [
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "103b7484068044fb84ed5f7911aad9d1",
"model_id": "b0bba114c9a44411880775350294b876",
"version_major": 2,
"version_minor": 0
},
Expand All @@ -305,7 +235,8 @@
"metadata": {},
"outputs": [],
"source": [
"# With the default, conservative parameters, this can take a few minutes\n# on a low-compute-power system.\n",
"# With the default, conservative parameters, this can take a few minutes\n",
"# on a low-compute-power system.\n",
"registered = itk.elastix_registration_method(fixed, moving)"
]
},
Expand Down
Loading

0 comments on commit e76fbf0

Please # to comment.