forked from InsightSoftwareConsortium/itkwidgets
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
133 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,118 @@ | ||
{ | ||
"cells": [ | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"# Install dependencies for this example\n", | ||
"# Note: This does not include itk-jupyter-widgets, itself\n", | ||
"import sys\n", | ||
"!{sys.executable} -m pip install vtk requests" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 2, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"import vtk\n", | ||
"\n", | ||
"import requests\n", | ||
"import shutil\n", | ||
"import os\n", | ||
"\n", | ||
"from itkwidgets import view" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 3, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"# Download data\n", | ||
"file_name = 'vase.vti'\n", | ||
"if not os.path.exists(file_name):\n", | ||
" response = requests.get('https://data.kitware.com/api/v1/file/5a826bdc8d777f0685782960/download', stream=True)\n", | ||
" with open(file_name, 'wb') as fp:\n", | ||
" response.raw.decode_content = True\n", | ||
" shutil.copyfileobj(response.raw, fp)" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 4, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"reader = vtk.vtkXMLImageDataReader()\n", | ||
"reader.SetFileName(file_name)\n", | ||
"reader.Update()\n", | ||
"vtk_image = reader.GetOutput()" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 5, | ||
"metadata": {}, | ||
"outputs": [ | ||
{ | ||
"data": { | ||
"application/vnd.jupyter.widget-view+json": { | ||
"model_id": "a50c990db54a4d41b274aba2869e782d", | ||
"version_major": 2, | ||
"version_minor": 0 | ||
}, | ||
"text/html": [ | ||
"<p>Failed to display Jupyter Widget of type <code>Viewer</code>.</p>\n", | ||
"<p>\n", | ||
" If you're reading this message in the Jupyter Notebook or JupyterLab Notebook, it may mean\n", | ||
" that the widgets JavaScript is still loading. If this message persists, it\n", | ||
" likely means that the widgets JavaScript library is either not installed or\n", | ||
" not enabled. See the <a href=\"https://ipywidgets.readthedocs.io/en/stable/user_install.html\">Jupyter\n", | ||
" Widgets Documentation</a> for setup instructions.\n", | ||
"</p>\n", | ||
"<p>\n", | ||
" If you're reading this message in another frontend (for example, a static\n", | ||
" rendering on GitHub or <a href=\"https://nbviewer.jupyter.org/\">NBViewer</a>),\n", | ||
" it may mean that your frontend doesn't currently support widgets.\n", | ||
"</p>\n" | ||
], | ||
"text/plain": [ | ||
"Viewer(image=<itkImagePython.itkImageUC3; proxy of <Swig Object of type 'itkImageUC3 *' at 0x7fc0d2764ba0> >)" | ||
] | ||
}, | ||
"metadata": {}, | ||
"output_type": "display_data" | ||
} | ||
], | ||
"source": [ | ||
"view(vtk_image)" | ||
] | ||
} | ||
], | ||
"metadata": { | ||
"kernelspec": { | ||
"display_name": "Python 2", | ||
"language": "python", | ||
"name": "python2" | ||
}, | ||
"language_info": { | ||
"codemirror_mode": { | ||
"name": "ipython", | ||
"version": 2 | ||
}, | ||
"file_extension": ".py", | ||
"mimetype": "text/x-python", | ||
"name": "python", | ||
"nbconvert_exporter": "python", | ||
"pygments_lexer": "ipython2", | ||
"version": "2.7.12" | ||
} | ||
}, | ||
"nbformat": 4, | ||
"nbformat_minor": 2 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters