-
Notifications
You must be signed in to change notification settings - Fork 57
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix path to input data for demos. Add the ConverTubesToPolyData demo.
- Loading branch information
Showing
2 changed files
with
180 additions
and
22 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,132 @@ | ||
{ | ||
"cells": [ | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"# Convert Tubes To PolyData" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"This notebook contains a few examples of how to call wrapped methods in itk and ITKTubeTK." | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"ITK and TubeTK must be installed on your system for this notebook to work. Typically, this is accomplished by\n", | ||
" > python -m pip install itk-tubetk" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 1, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"import os\n", | ||
"import sys\n", | ||
"import numpy" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 2, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"import itk\n", | ||
"from itk import TubeTK as ttk" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"Load the tubes" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 3, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"PixelType = itk.F\n", | ||
"Dimension = 3\n", | ||
"ImageType = itk.Image[PixelType, Dimension]\n", | ||
" \n", | ||
"# Read tre file\n", | ||
"TubeFileReaderType = itk.SpatialObjectReader[Dimension]\n", | ||
" \n", | ||
"tubeFileReader = TubeFileReaderType.New()\n", | ||
"tubeFileReader.SetFileName(\"Data/MRI-Normals/Normal071-VascularNetwork.tre\")\n", | ||
"tubeFileReader.Update()\n", | ||
"\n", | ||
"tubes = tubeFileReader.GetGroup()" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"Generate the polydata representation of the tubes and save it to the file \"Tube.vtp\".\n", | ||
"\n", | ||
"The Tube.vtp file can be displayed by dragging-and-dropping it onto ParaView Glance:\n", | ||
" https://kitware.github.io/paraview-glance/app/" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 4, | ||
"metadata": {}, | ||
"outputs": [ | ||
{ | ||
"name": "stderr", | ||
"output_type": "stream", | ||
"text": [ | ||
"itkImageF4 not loaded from module TubeTK because of exception:\n", | ||
" module 'itk.TubeTKPython' has no attribute 'itkImageF4'\n", | ||
"vectoritkImageF4 not loaded from module TubeTK because of exception:\n", | ||
" module 'itk.TubeTKPython' has no attribute 'vectoritkImageF4'\n" | ||
] | ||
} | ||
], | ||
"source": [ | ||
"ttk.WriteTubesAsPolyData.New(Input=tubes, FileName=\"Tube.vtp\").Update()" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [] | ||
} | ||
], | ||
"metadata": { | ||
"kernelspec": { | ||
"display_name": "WheelEnv", | ||
"language": "python", | ||
"name": "wheelenv" | ||
}, | ||
"language_info": { | ||
"codemirror_mode": { | ||
"name": "ipython", | ||
"version": 3 | ||
}, | ||
"file_extension": ".py", | ||
"mimetype": "text/x-python", | ||
"name": "python", | ||
"nbconvert_exporter": "python", | ||
"pygments_lexer": "ipython3", | ||
"version": "3.8.5" | ||
} | ||
}, | ||
"nbformat": 4, | ||
"nbformat_minor": 1 | ||
} |