<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://www.slicer.org/w/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Blezek</id>
	<title>Slicer Wiki - User contributions [en]</title>
	<link rel="self" type="application/atom+xml" href="https://www.slicer.org/w/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Blezek"/>
	<link rel="alternate" type="text/html" href="https://www.slicer.org/wiki/Special:Contributions/Blezek"/>
	<updated>2026-05-03T07:17:05Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.33.0</generator>
	<entry>
		<id>https://www.slicer.org/w/index.php?title=Slicer3:Python&amp;diff=15792</id>
		<title>Slicer3:Python</title>
		<link rel="alternate" type="text/html" href="https://www.slicer.org/w/index.php?title=Slicer3:Python&amp;diff=15792"/>
		<updated>2010-05-13T02:52:16Z</updated>

		<summary type="html">&lt;p&gt;Blezek: /* Cython support */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Status of Python in Slicer ==&lt;br /&gt;
As of Slicer 3.4, '''python''' and '''numpy''' are enabled by default. &lt;br /&gt;
&lt;br /&gt;
'''scipy''' and '''matplotlib''' are ''not'' enabled due to the difficulty in compiling binaries of them for distribution.  It is possible for people to compile their own versions of scipy to install and use with a local copy of slicer.  This is also true for many other python modules (see [[Slicer3:Python:ipython | the ipython installation technique]] as an example that should work for other distutils based python code.)&lt;br /&gt;
&lt;br /&gt;
Though [http://matplotlib.sourceforge.net/ matplotlib] is still not properly interacting with Slicer3, NumPy and Python support should work well for all platforms.  [[Slicer3:Execution_Model_Documentation:Python | Python command line modules]] are well supported, as is building full [[Modules:Python | GUI modules in Python]].&lt;br /&gt;
&lt;br /&gt;
== Python for scientific computing ==&lt;br /&gt;
Python has a fairly comprehensive package for scientific computing called [http://scipy.org SciPy].  Of main interest to Slicer users/developers is [http://numpy.scipy.org NumPy].  NumPy provides most of the features of the Matlab image processing toolbox and numeric computations, but in an Open Source package.  A compelling reason to use NumPy is the ease of interaction and integration with Slicer3.&lt;br /&gt;
&lt;br /&gt;
== Slicer3 and Python ==&lt;br /&gt;
&lt;br /&gt;
==== Enabling Python in the Slicer Build====&lt;br /&gt;
# Edit slicer_variables.tcl&lt;br /&gt;
## Change &amp;quot;set ::USE_PYTHON &amp;quot;off&amp;quot;&amp;quot; to &amp;quot;on&amp;quot;&lt;br /&gt;
# '''Optional:''' If you prefer to use your system Python installation, change set ::USE_SYSTEM_PYTHON &amp;quot;false&amp;quot; to &amp;quot;true&amp;quot;&lt;br /&gt;
## This will give an error under Linux and Windows, but it can be easily fixed by adding the system path for Python, just search for &amp;quot;if { $::USE_SYSTEM_PYTHON } {&amp;quot;&lt;br /&gt;
# '''Optional:''' installing SciPy&lt;br /&gt;
## [http://sourceforge.net/project/showfiles.php?group_id=27747 Download] the scipy egg for your platform&lt;br /&gt;
## Unzip the egg in any directory that is part of Slicer's Python path, eg Slicer3-build/lib/Slicer3/Plugins&lt;br /&gt;
## SciPy should now be available in Slicer's Python interpreter&lt;br /&gt;
&lt;br /&gt;
Build Slicer3 using &amp;quot;getbuildtest.tcl&amp;quot;, i.e.:&lt;br /&gt;
&lt;br /&gt;
 Macintosh:Slicer3 blezek$ Scripts/getbuildtest.tcl&lt;br /&gt;
&lt;br /&gt;
A new menu command '''Python Interpreter''' should appear on the Window menu.&lt;br /&gt;
&lt;br /&gt;
[[Image:PythonMenu.png]]&lt;br /&gt;
&lt;br /&gt;
This command should bring up the '''Python Console''' window.&lt;br /&gt;
&lt;br /&gt;
[[Image:PythonConsole.png]]&lt;br /&gt;
&lt;br /&gt;
==== Using System Python Libraries with Slicer's python ====&lt;br /&gt;
&lt;br /&gt;
It is possible in many instances to use binary packages from the scipy site or from [http://enthought.com Enthought] along with the pre-built slicer.  The following works on the mac, for instance:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
import sys&lt;br /&gt;
d = '/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/'&lt;br /&gt;
packages = ['matplotlib', 'neuroimaging', 'numpy', '', 'scipy']&lt;br /&gt;
for p in packages:&lt;br /&gt;
  sys.path.append(d+p)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Basic Slicer/Python tutorial ==&lt;br /&gt;
''Note: this is initial documentation only, and is subject to change as the API evolves.''&lt;br /&gt;
&lt;br /&gt;
The Slicer Python interpreter has access to all Python modules referenced by the environment variable '''PYTHONPATH''' as well as the '''Slicer''' internal module.  The '''Slicer''' module also supports the interface between Slicer Volume Nodes and NumPy.  It would be instructive for the reader to review the [http://www.scipy.org/Documentation NumPy documentation].  For serious users of NumPy, there is the [http://www.tramy.us/ ''Guide to NumPy''] by Travis Oliphant for purchase.&lt;br /&gt;
&lt;br /&gt;
The main interface to Slicer from Python is through the Slicer Python module.  From there, the Python user can access any of Slicer's global objects and MRML tree.  For example:&lt;br /&gt;
&lt;br /&gt;
  &amp;gt;&amp;gt;&amp;gt; import Slicer&lt;br /&gt;
  &amp;gt;&amp;gt;&amp;gt; Slicer.slicer&lt;br /&gt;
  &amp;lt;Slicer.Slicer object at 0x9f325f0&amp;gt;&lt;br /&gt;
  &amp;gt;&amp;gt;&amp;gt; Slicer.slicer.MRMLScene.GetNumberOfNodesByClass ( 'vtkMRMLVolumeNode' )&lt;br /&gt;
  0&lt;br /&gt;
  &amp;gt;&amp;gt;&amp;gt; &lt;br /&gt;
&lt;br /&gt;
In this case, no 'vtkMRMLVolumeNode's were loaded into Slicer.&lt;br /&gt;
&lt;br /&gt;
VTK objects may be easily constructed, as well as any other object available from the C++ Slicer API.&lt;br /&gt;
&lt;br /&gt;
 &amp;gt;&amp;gt;&amp;gt; a = Slicer.slicer.vtkPolyData()&lt;br /&gt;
 &amp;gt;&amp;gt;&amp;gt; help ( a )&lt;br /&gt;
 Help on vtkPolyData in module Slicer object:&lt;br /&gt;
 &lt;br /&gt;
 class vtkPolyData(vtkPointSet)&lt;br /&gt;
  |  Method resolution order:&lt;br /&gt;
  |      vtkPolyData&lt;br /&gt;
  |      vtkPointSet&lt;br /&gt;
  |      vtkDataSet&lt;br /&gt;
  &amp;lt;output truncated&amp;gt;&lt;br /&gt;
&lt;br /&gt;
VTK objects created in this manner conform as closely as possible to the VTK Python bindings, but must be created through the slicer object inside the Slicer module.  Each object may be fully subclassed following the [http://www.onlamp.com/pub/a/python/2003/04/17/metaclasses.html meta object pattern].&lt;br /&gt;
&lt;br /&gt;
==== A few details on Python in Slicer ====&lt;br /&gt;
&lt;br /&gt;
Although it is possible to use Slicer within Python, enabling Python in a Slicer build does not trigger Python wrapping of C++ classes. Instead, Python has access to the Slicer API through Tcl. Whenever a constructor for an object is invoked, e.g.&lt;br /&gt;
&lt;br /&gt;
 from Slicer import slicer &lt;br /&gt;
 surface = slicer.vtkPolyData()&lt;br /&gt;
&lt;br /&gt;
to create a VTK object, or&lt;br /&gt;
&lt;br /&gt;
 modelNode = slicer.vtkMRMLModelNode()&lt;br /&gt;
&lt;br /&gt;
to create a MRML node, the Python interpreter tells the Tcl interpreter to instantiate a vtkPolyData or vtkMRMLModelNode (this happens through the Tcl wrappers which are built as part of the basic Slicer) and makes it available to the Python interface. More in detail, Python asks Tcl to illustrate what is a vtkPolyData, what are the parent classes and the methods, creates the whole class hierarchy on the fly, and creates an instance of that object.&lt;br /&gt;
When one calls an object's method, like&lt;br /&gt;
&lt;br /&gt;
 numberOfPoints = surface.GetNumberOfPoints()&lt;br /&gt;
&lt;br /&gt;
the Python interpreter relies the call to the Tcl interpreter and returns the proper return value. Any object available to Tcl is the same object available to Python, and this allows for a great flexibility, as everything lives in a common space.&lt;br /&gt;
&lt;br /&gt;
Writing modules (especially interactive modules) in Python can lead to quite a speed up in the development cycle, since the code is more concise, it requires less file shuffling and, more than anything, it doesn't need to be recompiled (in some cases you don't even need to exit Slicer).&lt;br /&gt;
&lt;br /&gt;
More than this, enabling Python in Slicer opens up the possibility of accessing a very wide range of Python libraries, such as Numpy and Scipy, from within Slicer (interactively or in modules), making the Slicer use cases potentially explode.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== NumPy tutorial ====&lt;br /&gt;
&lt;br /&gt;
Python and NumPy give direct access to the volume data in Slicer by wrapping the image data in a NumPy '''array''' object through the '''.ToArray()''' method on the volume node.  This tutorial assumes you have installed [http://scipy.org/Download SciPy].&lt;br /&gt;
&lt;br /&gt;
 &amp;gt;&amp;gt;&amp;gt; # Access the image data directly&lt;br /&gt;
 &amp;gt;&amp;gt;&amp;gt; from Slicer import slicer&lt;br /&gt;
 &amp;gt;&amp;gt;&amp;gt; nodes = slicer.ListVolumeNodes()&lt;br /&gt;
 &amp;gt;&amp;gt;&amp;gt; t2 = nodes['T2.hdr']&lt;br /&gt;
 &amp;gt;&amp;gt;&amp;gt; data = t2.GetImageData().ToArray()&lt;br /&gt;
 &amp;gt;&amp;gt;&amp;gt; print data&lt;br /&gt;
 [[[ 0  0  0 ...,  0  0  0]&lt;br /&gt;
   [ 0  0  1 ...,  0  1  0]&lt;br /&gt;
   [ 0  0  0 ...,  0  0  0]&lt;br /&gt;
   ..., &lt;br /&gt;
   [ 0  8  0 ...,  0  1  2]&lt;br /&gt;
   [ 0  0  0 ...,  4  1  2]&lt;br /&gt;
   [ 0  0  2 ...,  6  0  2]]&lt;br /&gt;
 &lt;br /&gt;
 &amp;lt;&amp;lt;&amp;lt; Some output truncated &amp;gt;&amp;gt;&amp;gt; &lt;br /&gt;
 &lt;br /&gt;
  [[ 0  0  0 ...,  0  0  0]&lt;br /&gt;
   [ 0  0  0 ...,  0  0  0]&lt;br /&gt;
   [ 0  0  0 ...,  0  0  0]&lt;br /&gt;
   ..., &lt;br /&gt;
   [ 0  3  3 ...,  0  0  8]&lt;br /&gt;
   [ 0  6  0 ...,  5  3 13]&lt;br /&gt;
   [ 0  5  1 ...,  9  3  8]]]&lt;br /&gt;
 &amp;gt;&amp;gt;&amp;gt; # Load the image filtering package from scipy&lt;br /&gt;
 &amp;gt;&amp;gt;&amp;gt; import scipy.ndimage&lt;br /&gt;
 &amp;gt;&amp;gt;&amp;gt; # Filter into a new array&lt;br /&gt;
 &amp;gt;&amp;gt;&amp;gt; temp = scipy.ndimage.gaussian_filter ( data, 2.0 )&lt;br /&gt;
 &amp;gt;&amp;gt;&amp;gt; # Copy back into Slicer&lt;br /&gt;
 &amp;gt;&amp;gt;&amp;gt; data[:] = temp[:]&lt;br /&gt;
 &amp;gt;&amp;gt;&amp;gt; t2.Modified()&lt;br /&gt;
&lt;br /&gt;
Before:&lt;br /&gt;
&lt;br /&gt;
[[Image:PythonBefore.png]]&lt;br /&gt;
&lt;br /&gt;
After:&lt;br /&gt;
&lt;br /&gt;
[[Image:PythonAfter.png]]&lt;br /&gt;
&lt;br /&gt;
===== Accessing Tensor Data =====&lt;br /&gt;
&lt;br /&gt;
Because of the way vtk stores tensors, it is not directly accessible via the GetImageData().ToArray() approach used for scalar images.&lt;br /&gt;
&lt;br /&gt;
Instead, you can access it with something like:&lt;br /&gt;
 i = Slicer.slicer.MRML['dti'].GetImageData().GetPointData().GetTensors().ToArray()&lt;br /&gt;
&lt;br /&gt;
The default shape of this will be Nx9 where N is the total number of voxels in the volume.  You can convert these to tensors with something like:&lt;br /&gt;
&lt;br /&gt;
 d = Slicer.slicer.MRML['dti'].GetImageData().GetDimensions()&lt;br /&gt;
 d.reverse()&lt;br /&gt;
 tensors = i.reshape(d+[3,3])&lt;br /&gt;
&lt;br /&gt;
==== The NumPy command line module ====&lt;br /&gt;
&lt;br /&gt;
In order to speed up experimentation, a Numpy command line module is available.&lt;br /&gt;
&lt;br /&gt;
It takes in input one or two volume nodes and an output volume node, plus a path to a Python script residing in a text file. &lt;br /&gt;
&lt;br /&gt;
Upon execution, input volume nodes are converted to ndarray variables named iarray and iarray2. The user simply has to put Numpy/Scipy code in the text file, taking care that the output array is stored in a variable named oarray. For example, the file could look like&lt;br /&gt;
&lt;br /&gt;
 import scipy.ndimage&lt;br /&gt;
 oarray = scipy.ndimage.gaussian_filter ( iarray, 2.0 )&lt;br /&gt;
&lt;br /&gt;
The module will take care of taking the content of oarray and storing it in the output volume node (note: differently from the example above, and more in line with Slicer practices, the result of processing is stored in a different output volume, which is selected from the node selector). &lt;br /&gt;
&lt;br /&gt;
To rerun different NumPy code on the input image, simply edit the script file, save it and rerun the module.&lt;br /&gt;
&lt;br /&gt;
== Cython support ==&lt;br /&gt;
[http://www.cython.org/ Cython] is an open source project that compiles a Python code into a shared library.  Cython can compile most Python code, but gains the most speed when the Python code is augmented with clues to Cython regarding the datatype of a variable.  To use Cython on your Slicer Python (slipy?) code, you must compile the Cython code into a shared library.  All example code may be found on the [http://github.com/dblezek/Slipy-Tractograhpy slipy project] (Tractograhpy was [http://en.wiktionary.org/wiki/fat-finger fat-fingered]) on [http://www.github.org Github].&lt;br /&gt;
&lt;br /&gt;
First install Cython:&lt;br /&gt;
 hg clone http://hg.cython.org/cython-closures/&lt;br /&gt;
 cd cython-closures&lt;br /&gt;
 ~/Slicer3-lib/Python-build/bin/python setup.py install&lt;br /&gt;
&lt;br /&gt;
Next, create setup.py to build your code:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
import distutils&lt;br /&gt;
import distutils.sysconfig&lt;br /&gt;
&lt;br /&gt;
from distutils.core import setup&lt;br /&gt;
from distutils.extension import Extension&lt;br /&gt;
from Cython.Distutils import build_ext&lt;br /&gt;
&lt;br /&gt;
ext_modules = [Extension(&amp;quot;OneTensorCython&amp;quot;, [&amp;quot;OneTensorCython.pyx&amp;quot;])]&lt;br /&gt;
&lt;br /&gt;
setup(&lt;br /&gt;
    name = 'Tractography filtering with python',&lt;br /&gt;
    cmdclass = {'build_ext': build_ext},&lt;br /&gt;
    ext_modules = ext_modules&lt;br /&gt;
)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Build your Cython code with Slicer's Python using the --inplace flag:&lt;br /&gt;
 ~/Slicer3-lib/Python-build/bin/python setup.py build_ext --inplace&lt;br /&gt;
&lt;br /&gt;
To use your Cython code as a Slicer module, you will need to write a pure Python wrapper.  The current plug-in mechanism interrogates the function for it's parameters, which does not work on the compiled functions that Cython uses.  This example simply passes through to the Cython module '''OneTensorCython'''.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
import OneTensorCython&lt;br /&gt;
&lt;br /&gt;
XML = OneTensorCython.XML&lt;br /&gt;
&lt;br /&gt;
def Execute(dwi_node, seeds_node, mask_node, ff_node):&lt;br /&gt;
    OneTensorCython.Execute (dwi_node, seeds_node, mask_node, ff_node)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Matplotlib plotting functionality ==&lt;br /&gt;
Matplotlib may be used from within Slicer, but currently (on the Mac) the Tk backend locks up and crashes Slicer.  However, Matplotlib may still be used through one of the non-GUI backends.  More details can be found on the [http://matplotlib.sourceforge.net/ MatPlotLib] pages.&lt;br /&gt;
&lt;br /&gt;
 import matplotlib&lt;br /&gt;
 matplotlib.use ( 'Agg' )&lt;br /&gt;
 from pylab import *&lt;br /&gt;
 &lt;br /&gt;
 t1 = arange(0.0, 5.0, 0.1)&lt;br /&gt;
 t2 = arange(0.0, 5.0, 0.02)&lt;br /&gt;
 t3 = arange(0.0, 2.0, 0.01) &lt;br /&gt;
 &lt;br /&gt;
 subplot(211)&lt;br /&gt;
 plot(t1, cos(2*pi*t1)*exp(-t1), 'bo', t2, cos(2*pi*t2)*exp(-t2), 'k')&lt;br /&gt;
 grid(True)&lt;br /&gt;
 title('A tale of 2 subplots')&lt;br /&gt;
 ylabel('Damped')&lt;br /&gt;
 &lt;br /&gt;
 subplot(212)&lt;br /&gt;
 plot(t3, cos(2*pi*t3), 'r--')&lt;br /&gt;
 grid(True)&lt;br /&gt;
 xlabel('time (s)')&lt;br /&gt;
 ylabel('Undamped')&lt;br /&gt;
 savefig ( 'MatplotlibExample.png' )&lt;br /&gt;
 &lt;br /&gt;
 import Slicer&lt;br /&gt;
 r = Slicer.slicer.vtkPNGReader()&lt;br /&gt;
 v = Slicer.slicer.vtkImageViewer()&lt;br /&gt;
 r.SetFileName( 'MatplotlibExample.png' )&lt;br /&gt;
 &lt;br /&gt;
 v.SetColorWindow(255)&lt;br /&gt;
 v.SetColorLevel(128)&lt;br /&gt;
 v.SetInput(r.GetOutput())&lt;br /&gt;
 v.Render()&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Image:MatplotlibExample.png]]&lt;br /&gt;
&lt;br /&gt;
== Where to go from here ==&lt;br /&gt;
Far from exhaustive, this documentation is intended to whet the appitite of researchers who love the power of Matlab, but feel trapped inside, unable to break out and deploy applications.  This Python interface to Slicer is intended to help!  Here are some selected resources to begin to understand the power of what the combined NumPy - Slicer package offers.&lt;br /&gt;
&lt;br /&gt;
=== Python Language Information ===&lt;br /&gt;
&lt;br /&gt;
* [http://www.python.org/doc/ Python documentation]&lt;br /&gt;
** [http://www.rexx.com/~dkuhlman/python_101/python_101.html Gentle introduction to Python]&lt;br /&gt;
** [http://www.python.org/doc/Intros.html Python introduction]&lt;br /&gt;
&lt;br /&gt;
=== Numpy and Scipy Information ===&lt;br /&gt;
&lt;br /&gt;
* [http://www.scipy.org/NumPy NumPy documentation]&lt;br /&gt;
** [http://www.trelgol.com/ Comprehensive ''Guide to NumPy''] by the current maintainer&lt;br /&gt;
** [http://numeric.scipy.org/numpydoc/numdoc.htm Old NumPy documentation] ([http://numeric.scipy.org/numpy.pdf pdf])&lt;br /&gt;
* [http://www.scipy.org SciPy] [http://scipy.org/Documentation Documentation]&lt;br /&gt;
* [http://matplotlib.sourceforge.net/ MatPlotLib]&lt;br /&gt;
&lt;br /&gt;
=== Writing Slicer Modules in Python ===&lt;br /&gt;
&lt;br /&gt;
Painless Development in Slicer3 with Python, talk given by Demian Wassermann at the LMI, sept. 2008&lt;br /&gt;
* Slides: Introduction to Slicer3 with Python: [[media:PythonSlicer.pdf]]&lt;br /&gt;
* Slides: Numpy indexing and example: [[media:PythonSlicerNumpy.pdf]]&lt;br /&gt;
* See [[Slicer3:Python:DemianExamples | Demian's Example Code]]&lt;br /&gt;
&lt;br /&gt;
Slicer Python breakout session in Salt Lake City, Winter Project Week 2009, by Luca Antiga.&lt;br /&gt;
* Slides: [[media:ProjectWeekBreakout2009_SlicerPython.pdf]]‎&lt;br /&gt;
&lt;br /&gt;
* [[Slicer3:Execution_Model_Documentation:Python|Scripted Command Line Modules in Python]]&lt;br /&gt;
* [[Slicer3:Execution_Model_Documentation:Programmatic_Invocation#Python_Example|Invoking command line modules from Python]]&lt;br /&gt;
&lt;br /&gt;
=== Additional Experiments ===&lt;br /&gt;
&lt;br /&gt;
* An experiment to create an [[Slicer3:Python:ScriptedActor|OpenGL VTK Actor in Python]].&lt;br /&gt;
* An experiment to call [[Slicer3:Python:pitky |ITK with C++ from Python]] using [http://www.scipy.org/Cookbook/Weave weave].&lt;br /&gt;
* [[Slicer3:Python:ipython|Installing ipython]] interface&lt;/div&gt;</summary>
		<author><name>Blezek</name></author>
		
	</entry>
	<entry>
		<id>https://www.slicer.org/w/index.php?title=Slicer3:Python&amp;diff=15791</id>
		<title>Slicer3:Python</title>
		<link rel="alternate" type="text/html" href="https://www.slicer.org/w/index.php?title=Slicer3:Python&amp;diff=15791"/>
		<updated>2010-05-13T01:17:30Z</updated>

		<summary type="html">&lt;p&gt;Blezek: /* Cython support */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Status of Python in Slicer ==&lt;br /&gt;
As of Slicer 3.4, '''python''' and '''numpy''' are enabled by default. &lt;br /&gt;
&lt;br /&gt;
'''scipy''' and '''matplotlib''' are ''not'' enabled due to the difficulty in compiling binaries of them for distribution.  It is possible for people to compile their own versions of scipy to install and use with a local copy of slicer.  This is also true for many other python modules (see [[Slicer3:Python:ipython | the ipython installation technique]] as an example that should work for other distutils based python code.)&lt;br /&gt;
&lt;br /&gt;
Though [http://matplotlib.sourceforge.net/ matplotlib] is still not properly interacting with Slicer3, NumPy and Python support should work well for all platforms.  [[Slicer3:Execution_Model_Documentation:Python | Python command line modules]] are well supported, as is building full [[Modules:Python | GUI modules in Python]].&lt;br /&gt;
&lt;br /&gt;
== Python for scientific computing ==&lt;br /&gt;
Python has a fairly comprehensive package for scientific computing called [http://scipy.org SciPy].  Of main interest to Slicer users/developers is [http://numpy.scipy.org NumPy].  NumPy provides most of the features of the Matlab image processing toolbox and numeric computations, but in an Open Source package.  A compelling reason to use NumPy is the ease of interaction and integration with Slicer3.&lt;br /&gt;
&lt;br /&gt;
== Slicer3 and Python ==&lt;br /&gt;
&lt;br /&gt;
==== Enabling Python in the Slicer Build====&lt;br /&gt;
# Edit slicer_variables.tcl&lt;br /&gt;
## Change &amp;quot;set ::USE_PYTHON &amp;quot;off&amp;quot;&amp;quot; to &amp;quot;on&amp;quot;&lt;br /&gt;
# '''Optional:''' If you prefer to use your system Python installation, change set ::USE_SYSTEM_PYTHON &amp;quot;false&amp;quot; to &amp;quot;true&amp;quot;&lt;br /&gt;
## This will give an error under Linux and Windows, but it can be easily fixed by adding the system path for Python, just search for &amp;quot;if { $::USE_SYSTEM_PYTHON } {&amp;quot;&lt;br /&gt;
# '''Optional:''' installing SciPy&lt;br /&gt;
## [http://sourceforge.net/project/showfiles.php?group_id=27747 Download] the scipy egg for your platform&lt;br /&gt;
## Unzip the egg in any directory that is part of Slicer's Python path, eg Slicer3-build/lib/Slicer3/Plugins&lt;br /&gt;
## SciPy should now be available in Slicer's Python interpreter&lt;br /&gt;
&lt;br /&gt;
Build Slicer3 using &amp;quot;getbuildtest.tcl&amp;quot;, i.e.:&lt;br /&gt;
&lt;br /&gt;
 Macintosh:Slicer3 blezek$ Scripts/getbuildtest.tcl&lt;br /&gt;
&lt;br /&gt;
A new menu command '''Python Interpreter''' should appear on the Window menu.&lt;br /&gt;
&lt;br /&gt;
[[Image:PythonMenu.png]]&lt;br /&gt;
&lt;br /&gt;
This command should bring up the '''Python Console''' window.&lt;br /&gt;
&lt;br /&gt;
[[Image:PythonConsole.png]]&lt;br /&gt;
&lt;br /&gt;
==== Using System Python Libraries with Slicer's python ====&lt;br /&gt;
&lt;br /&gt;
It is possible in many instances to use binary packages from the scipy site or from [http://enthought.com Enthought] along with the pre-built slicer.  The following works on the mac, for instance:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
import sys&lt;br /&gt;
d = '/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/'&lt;br /&gt;
packages = ['matplotlib', 'neuroimaging', 'numpy', '', 'scipy']&lt;br /&gt;
for p in packages:&lt;br /&gt;
  sys.path.append(d+p)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Basic Slicer/Python tutorial ==&lt;br /&gt;
''Note: this is initial documentation only, and is subject to change as the API evolves.''&lt;br /&gt;
&lt;br /&gt;
The Slicer Python interpreter has access to all Python modules referenced by the environment variable '''PYTHONPATH''' as well as the '''Slicer''' internal module.  The '''Slicer''' module also supports the interface between Slicer Volume Nodes and NumPy.  It would be instructive for the reader to review the [http://www.scipy.org/Documentation NumPy documentation].  For serious users of NumPy, there is the [http://www.tramy.us/ ''Guide to NumPy''] by Travis Oliphant for purchase.&lt;br /&gt;
&lt;br /&gt;
The main interface to Slicer from Python is through the Slicer Python module.  From there, the Python user can access any of Slicer's global objects and MRML tree.  For example:&lt;br /&gt;
&lt;br /&gt;
  &amp;gt;&amp;gt;&amp;gt; import Slicer&lt;br /&gt;
  &amp;gt;&amp;gt;&amp;gt; Slicer.slicer&lt;br /&gt;
  &amp;lt;Slicer.Slicer object at 0x9f325f0&amp;gt;&lt;br /&gt;
  &amp;gt;&amp;gt;&amp;gt; Slicer.slicer.MRMLScene.GetNumberOfNodesByClass ( 'vtkMRMLVolumeNode' )&lt;br /&gt;
  0&lt;br /&gt;
  &amp;gt;&amp;gt;&amp;gt; &lt;br /&gt;
&lt;br /&gt;
In this case, no 'vtkMRMLVolumeNode's were loaded into Slicer.&lt;br /&gt;
&lt;br /&gt;
VTK objects may be easily constructed, as well as any other object available from the C++ Slicer API.&lt;br /&gt;
&lt;br /&gt;
 &amp;gt;&amp;gt;&amp;gt; a = Slicer.slicer.vtkPolyData()&lt;br /&gt;
 &amp;gt;&amp;gt;&amp;gt; help ( a )&lt;br /&gt;
 Help on vtkPolyData in module Slicer object:&lt;br /&gt;
 &lt;br /&gt;
 class vtkPolyData(vtkPointSet)&lt;br /&gt;
  |  Method resolution order:&lt;br /&gt;
  |      vtkPolyData&lt;br /&gt;
  |      vtkPointSet&lt;br /&gt;
  |      vtkDataSet&lt;br /&gt;
  &amp;lt;output truncated&amp;gt;&lt;br /&gt;
&lt;br /&gt;
VTK objects created in this manner conform as closely as possible to the VTK Python bindings, but must be created through the slicer object inside the Slicer module.  Each object may be fully subclassed following the [http://www.onlamp.com/pub/a/python/2003/04/17/metaclasses.html meta object pattern].&lt;br /&gt;
&lt;br /&gt;
==== A few details on Python in Slicer ====&lt;br /&gt;
&lt;br /&gt;
Although it is possible to use Slicer within Python, enabling Python in a Slicer build does not trigger Python wrapping of C++ classes. Instead, Python has access to the Slicer API through Tcl. Whenever a constructor for an object is invoked, e.g.&lt;br /&gt;
&lt;br /&gt;
 from Slicer import slicer &lt;br /&gt;
 surface = slicer.vtkPolyData()&lt;br /&gt;
&lt;br /&gt;
to create a VTK object, or&lt;br /&gt;
&lt;br /&gt;
 modelNode = slicer.vtkMRMLModelNode()&lt;br /&gt;
&lt;br /&gt;
to create a MRML node, the Python interpreter tells the Tcl interpreter to instantiate a vtkPolyData or vtkMRMLModelNode (this happens through the Tcl wrappers which are built as part of the basic Slicer) and makes it available to the Python interface. More in detail, Python asks Tcl to illustrate what is a vtkPolyData, what are the parent classes and the methods, creates the whole class hierarchy on the fly, and creates an instance of that object.&lt;br /&gt;
When one calls an object's method, like&lt;br /&gt;
&lt;br /&gt;
 numberOfPoints = surface.GetNumberOfPoints()&lt;br /&gt;
&lt;br /&gt;
the Python interpreter relies the call to the Tcl interpreter and returns the proper return value. Any object available to Tcl is the same object available to Python, and this allows for a great flexibility, as everything lives in a common space.&lt;br /&gt;
&lt;br /&gt;
Writing modules (especially interactive modules) in Python can lead to quite a speed up in the development cycle, since the code is more concise, it requires less file shuffling and, more than anything, it doesn't need to be recompiled (in some cases you don't even need to exit Slicer).&lt;br /&gt;
&lt;br /&gt;
More than this, enabling Python in Slicer opens up the possibility of accessing a very wide range of Python libraries, such as Numpy and Scipy, from within Slicer (interactively or in modules), making the Slicer use cases potentially explode.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== NumPy tutorial ====&lt;br /&gt;
&lt;br /&gt;
Python and NumPy give direct access to the volume data in Slicer by wrapping the image data in a NumPy '''array''' object through the '''.ToArray()''' method on the volume node.  This tutorial assumes you have installed [http://scipy.org/Download SciPy].&lt;br /&gt;
&lt;br /&gt;
 &amp;gt;&amp;gt;&amp;gt; # Access the image data directly&lt;br /&gt;
 &amp;gt;&amp;gt;&amp;gt; from Slicer import slicer&lt;br /&gt;
 &amp;gt;&amp;gt;&amp;gt; nodes = slicer.ListVolumeNodes()&lt;br /&gt;
 &amp;gt;&amp;gt;&amp;gt; t2 = nodes['T2.hdr']&lt;br /&gt;
 &amp;gt;&amp;gt;&amp;gt; data = t2.GetImageData().ToArray()&lt;br /&gt;
 &amp;gt;&amp;gt;&amp;gt; print data&lt;br /&gt;
 [[[ 0  0  0 ...,  0  0  0]&lt;br /&gt;
   [ 0  0  1 ...,  0  1  0]&lt;br /&gt;
   [ 0  0  0 ...,  0  0  0]&lt;br /&gt;
   ..., &lt;br /&gt;
   [ 0  8  0 ...,  0  1  2]&lt;br /&gt;
   [ 0  0  0 ...,  4  1  2]&lt;br /&gt;
   [ 0  0  2 ...,  6  0  2]]&lt;br /&gt;
 &lt;br /&gt;
 &amp;lt;&amp;lt;&amp;lt; Some output truncated &amp;gt;&amp;gt;&amp;gt; &lt;br /&gt;
 &lt;br /&gt;
  [[ 0  0  0 ...,  0  0  0]&lt;br /&gt;
   [ 0  0  0 ...,  0  0  0]&lt;br /&gt;
   [ 0  0  0 ...,  0  0  0]&lt;br /&gt;
   ..., &lt;br /&gt;
   [ 0  3  3 ...,  0  0  8]&lt;br /&gt;
   [ 0  6  0 ...,  5  3 13]&lt;br /&gt;
   [ 0  5  1 ...,  9  3  8]]]&lt;br /&gt;
 &amp;gt;&amp;gt;&amp;gt; # Load the image filtering package from scipy&lt;br /&gt;
 &amp;gt;&amp;gt;&amp;gt; import scipy.ndimage&lt;br /&gt;
 &amp;gt;&amp;gt;&amp;gt; # Filter into a new array&lt;br /&gt;
 &amp;gt;&amp;gt;&amp;gt; temp = scipy.ndimage.gaussian_filter ( data, 2.0 )&lt;br /&gt;
 &amp;gt;&amp;gt;&amp;gt; # Copy back into Slicer&lt;br /&gt;
 &amp;gt;&amp;gt;&amp;gt; data[:] = temp[:]&lt;br /&gt;
 &amp;gt;&amp;gt;&amp;gt; t2.Modified()&lt;br /&gt;
&lt;br /&gt;
Before:&lt;br /&gt;
&lt;br /&gt;
[[Image:PythonBefore.png]]&lt;br /&gt;
&lt;br /&gt;
After:&lt;br /&gt;
&lt;br /&gt;
[[Image:PythonAfter.png]]&lt;br /&gt;
&lt;br /&gt;
===== Accessing Tensor Data =====&lt;br /&gt;
&lt;br /&gt;
Because of the way vtk stores tensors, it is not directly accessible via the GetImageData().ToArray() approach used for scalar images.&lt;br /&gt;
&lt;br /&gt;
Instead, you can access it with something like:&lt;br /&gt;
 i = Slicer.slicer.MRML['dti'].GetImageData().GetPointData().GetTensors().ToArray()&lt;br /&gt;
&lt;br /&gt;
The default shape of this will be Nx9 where N is the total number of voxels in the volume.  You can convert these to tensors with something like:&lt;br /&gt;
&lt;br /&gt;
 d = Slicer.slicer.MRML['dti'].GetImageData().GetDimensions()&lt;br /&gt;
 d.reverse()&lt;br /&gt;
 tensors = i.reshape(d+[3,3])&lt;br /&gt;
&lt;br /&gt;
==== The NumPy command line module ====&lt;br /&gt;
&lt;br /&gt;
In order to speed up experimentation, a Numpy command line module is available.&lt;br /&gt;
&lt;br /&gt;
It takes in input one or two volume nodes and an output volume node, plus a path to a Python script residing in a text file. &lt;br /&gt;
&lt;br /&gt;
Upon execution, input volume nodes are converted to ndarray variables named iarray and iarray2. The user simply has to put Numpy/Scipy code in the text file, taking care that the output array is stored in a variable named oarray. For example, the file could look like&lt;br /&gt;
&lt;br /&gt;
 import scipy.ndimage&lt;br /&gt;
 oarray = scipy.ndimage.gaussian_filter ( iarray, 2.0 )&lt;br /&gt;
&lt;br /&gt;
The module will take care of taking the content of oarray and storing it in the output volume node (note: differently from the example above, and more in line with Slicer practices, the result of processing is stored in a different output volume, which is selected from the node selector). &lt;br /&gt;
&lt;br /&gt;
To rerun different NumPy code on the input image, simply edit the script file, save it and rerun the module.&lt;br /&gt;
&lt;br /&gt;
== Cython support ==&lt;br /&gt;
[http://www.cython.org/ Cython] is an open source project that compiles a Python code into a shared library.  Cython can compile most Python code, but gains the most speed when the Python code is augmented with clues to Cython regarding the datatype of a variable.  To use Cython on your Slicer Python (slipy?) code, you must compile the Cython code into a shared library.  All example code may be found on the [http://github.com/dblezek/Slipy-Tractograhpy slipy project] on [http://www.github.org Github].&lt;br /&gt;
&lt;br /&gt;
First install Cython:&lt;br /&gt;
 hg clone http://hg.cython.org/cython-closures/&lt;br /&gt;
 cd cython-closures&lt;br /&gt;
 ~/Slicer3-lib/Python-build/bin/python setup.py install&lt;br /&gt;
&lt;br /&gt;
Next, create setup.py to build your code:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
import distutils&lt;br /&gt;
import distutils.sysconfig&lt;br /&gt;
&lt;br /&gt;
from distutils.core import setup&lt;br /&gt;
from distutils.extension import Extension&lt;br /&gt;
from Cython.Distutils import build_ext&lt;br /&gt;
&lt;br /&gt;
ext_modules = [Extension(&amp;quot;OneTensorCython&amp;quot;, [&amp;quot;OneTensorCython.pyx&amp;quot;])]&lt;br /&gt;
&lt;br /&gt;
setup(&lt;br /&gt;
    name = 'Tractography filtering with python',&lt;br /&gt;
    cmdclass = {'build_ext': build_ext},&lt;br /&gt;
    ext_modules = ext_modules&lt;br /&gt;
)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Build your Cython code with Slicer's Python using the --inplace flag:&lt;br /&gt;
 ~/Slicer3-lib/Python-build/bin/python setup.py build_ext --inplace&lt;br /&gt;
&lt;br /&gt;
To use your Cython code as a Slicer module, you will need to write a pure Python wrapper.  The current plug-in mechanism interrogates the function for it's parameters, which does not work on the compiled functions that Cython uses.  This example simply passes through to the Cython module '''OneTensorCython'''.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
import OneTensorCython&lt;br /&gt;
&lt;br /&gt;
XML = OneTensorCython.XML&lt;br /&gt;
&lt;br /&gt;
def Execute(dwi_node, seeds_node, mask_node, ff_node):&lt;br /&gt;
    OneTensorCython.Execute (dwi_node, seeds_node, mask_node, ff_node)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Matplotlib plotting functionality ==&lt;br /&gt;
Matplotlib may be used from within Slicer, but currently (on the Mac) the Tk backend locks up and crashes Slicer.  However, Matplotlib may still be used through one of the non-GUI backends.  More details can be found on the [http://matplotlib.sourceforge.net/ MatPlotLib] pages.&lt;br /&gt;
&lt;br /&gt;
 import matplotlib&lt;br /&gt;
 matplotlib.use ( 'Agg' )&lt;br /&gt;
 from pylab import *&lt;br /&gt;
 &lt;br /&gt;
 t1 = arange(0.0, 5.0, 0.1)&lt;br /&gt;
 t2 = arange(0.0, 5.0, 0.02)&lt;br /&gt;
 t3 = arange(0.0, 2.0, 0.01) &lt;br /&gt;
 &lt;br /&gt;
 subplot(211)&lt;br /&gt;
 plot(t1, cos(2*pi*t1)*exp(-t1), 'bo', t2, cos(2*pi*t2)*exp(-t2), 'k')&lt;br /&gt;
 grid(True)&lt;br /&gt;
 title('A tale of 2 subplots')&lt;br /&gt;
 ylabel('Damped')&lt;br /&gt;
 &lt;br /&gt;
 subplot(212)&lt;br /&gt;
 plot(t3, cos(2*pi*t3), 'r--')&lt;br /&gt;
 grid(True)&lt;br /&gt;
 xlabel('time (s)')&lt;br /&gt;
 ylabel('Undamped')&lt;br /&gt;
 savefig ( 'MatplotlibExample.png' )&lt;br /&gt;
 &lt;br /&gt;
 import Slicer&lt;br /&gt;
 r = Slicer.slicer.vtkPNGReader()&lt;br /&gt;
 v = Slicer.slicer.vtkImageViewer()&lt;br /&gt;
 r.SetFileName( 'MatplotlibExample.png' )&lt;br /&gt;
 &lt;br /&gt;
 v.SetColorWindow(255)&lt;br /&gt;
 v.SetColorLevel(128)&lt;br /&gt;
 v.SetInput(r.GetOutput())&lt;br /&gt;
 v.Render()&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Image:MatplotlibExample.png]]&lt;br /&gt;
&lt;br /&gt;
== Where to go from here ==&lt;br /&gt;
Far from exhaustive, this documentation is intended to whet the appitite of researchers who love the power of Matlab, but feel trapped inside, unable to break out and deploy applications.  This Python interface to Slicer is intended to help!  Here are some selected resources to begin to understand the power of what the combined NumPy - Slicer package offers.&lt;br /&gt;
&lt;br /&gt;
=== Python Language Information ===&lt;br /&gt;
&lt;br /&gt;
* [http://www.python.org/doc/ Python documentation]&lt;br /&gt;
** [http://www.rexx.com/~dkuhlman/python_101/python_101.html Gentle introduction to Python]&lt;br /&gt;
** [http://www.python.org/doc/Intros.html Python introduction]&lt;br /&gt;
&lt;br /&gt;
=== Numpy and Scipy Information ===&lt;br /&gt;
&lt;br /&gt;
* [http://www.scipy.org/NumPy NumPy documentation]&lt;br /&gt;
** [http://www.trelgol.com/ Comprehensive ''Guide to NumPy''] by the current maintainer&lt;br /&gt;
** [http://numeric.scipy.org/numpydoc/numdoc.htm Old NumPy documentation] ([http://numeric.scipy.org/numpy.pdf pdf])&lt;br /&gt;
* [http://www.scipy.org SciPy] [http://scipy.org/Documentation Documentation]&lt;br /&gt;
* [http://matplotlib.sourceforge.net/ MatPlotLib]&lt;br /&gt;
&lt;br /&gt;
=== Writing Slicer Modules in Python ===&lt;br /&gt;
&lt;br /&gt;
Painless Development in Slicer3 with Python, talk given by Demian Wassermann at the LMI, sept. 2008&lt;br /&gt;
* Slides: Introduction to Slicer3 with Python: [[media:PythonSlicer.pdf]]&lt;br /&gt;
* Slides: Numpy indexing and example: [[media:PythonSlicerNumpy.pdf]]&lt;br /&gt;
* See [[Slicer3:Python:DemianExamples | Demian's Example Code]]&lt;br /&gt;
&lt;br /&gt;
Slicer Python breakout session in Salt Lake City, Winter Project Week 2009, by Luca Antiga.&lt;br /&gt;
* Slides: [[media:ProjectWeekBreakout2009_SlicerPython.pdf]]‎&lt;br /&gt;
&lt;br /&gt;
* [[Slicer3:Execution_Model_Documentation:Python|Scripted Command Line Modules in Python]]&lt;br /&gt;
* [[Slicer3:Execution_Model_Documentation:Programmatic_Invocation#Python_Example|Invoking command line modules from Python]]&lt;br /&gt;
&lt;br /&gt;
=== Additional Experiments ===&lt;br /&gt;
&lt;br /&gt;
* An experiment to create an [[Slicer3:Python:ScriptedActor|OpenGL VTK Actor in Python]].&lt;br /&gt;
* An experiment to call [[Slicer3:Python:pitky |ITK with C++ from Python]] using [http://www.scipy.org/Cookbook/Weave weave].&lt;br /&gt;
* [[Slicer3:Python:ipython|Installing ipython]] interface&lt;/div&gt;</summary>
		<author><name>Blezek</name></author>
		
	</entry>
	<entry>
		<id>https://www.slicer.org/w/index.php?title=Slicer3:Python&amp;diff=15720</id>
		<title>Slicer3:Python</title>
		<link rel="alternate" type="text/html" href="https://www.slicer.org/w/index.php?title=Slicer3:Python&amp;diff=15720"/>
		<updated>2010-05-11T03:33:28Z</updated>

		<summary type="html">&lt;p&gt;Blezek: /* Cython support */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Status of Python in Slicer ==&lt;br /&gt;
As of Slicer 3.4, '''python''' and '''numpy''' are enabled by default. &lt;br /&gt;
&lt;br /&gt;
'''scipy''' and '''matplotlib''' are ''not'' enabled due to the difficulty in compiling binaries of them for distribution.  It is possible for people to compile their own versions of scipy to install and use with a local copy of slicer.  This is also true for many other python modules (see [[Slicer3:Python:ipython | the ipython installation technique]] as an example that should work for other distutils based python code.)&lt;br /&gt;
&lt;br /&gt;
Though [http://matplotlib.sourceforge.net/ matplotlib] is still not properly interacting with Slicer3, NumPy and Python support should work well for all platforms.  [[Slicer3:Execution_Model_Documentation:Python | Python command line modules]] are well supported, as is building full [[Modules:Python | GUI modules in Python]].&lt;br /&gt;
&lt;br /&gt;
== Python for scientific computing ==&lt;br /&gt;
Python has a fairly comprehensive package for scientific computing called [http://scipy.org SciPy].  Of main interest to Slicer users/developers is [http://numpy.scipy.org NumPy].  NumPy provides most of the features of the Matlab image processing toolbox and numeric computations, but in an Open Source package.  A compelling reason to use NumPy is the ease of interaction and integration with Slicer3.&lt;br /&gt;
&lt;br /&gt;
== Slicer3 and Python ==&lt;br /&gt;
&lt;br /&gt;
==== Enabling Python in the Slicer Build====&lt;br /&gt;
# Edit slicer_variables.tcl&lt;br /&gt;
## Change &amp;quot;set ::USE_PYTHON &amp;quot;off&amp;quot;&amp;quot; to &amp;quot;on&amp;quot;&lt;br /&gt;
# '''Optional:''' If you prefer to use your system Python installation, change set ::USE_SYSTEM_PYTHON &amp;quot;false&amp;quot; to &amp;quot;true&amp;quot;&lt;br /&gt;
## This will give an error under Linux and Windows, but it can be easily fixed by adding the system path for Python, just search for &amp;quot;if { $::USE_SYSTEM_PYTHON } {&amp;quot;&lt;br /&gt;
# '''Optional:''' installing SciPy&lt;br /&gt;
## [http://sourceforge.net/project/showfiles.php?group_id=27747 Download] the scipy egg for your platform&lt;br /&gt;
## Unzip the egg in any directory that is part of Slicer's Python path, eg Slicer3-build/lib/Slicer3/Plugins&lt;br /&gt;
## SciPy should now be available in Slicer's Python interpreter&lt;br /&gt;
&lt;br /&gt;
Build Slicer3 using &amp;quot;getbuildtest.tcl&amp;quot;, i.e.:&lt;br /&gt;
&lt;br /&gt;
 Macintosh:Slicer3 blezek$ Scripts/getbuildtest.tcl&lt;br /&gt;
&lt;br /&gt;
A new menu command '''Python Interpreter''' should appear on the Window menu.&lt;br /&gt;
&lt;br /&gt;
[[Image:PythonMenu.png]]&lt;br /&gt;
&lt;br /&gt;
This command should bring up the '''Python Console''' window.&lt;br /&gt;
&lt;br /&gt;
[[Image:PythonConsole.png]]&lt;br /&gt;
&lt;br /&gt;
==== Using System Python Libraries with Slicer's python ====&lt;br /&gt;
&lt;br /&gt;
It is possible in many instances to use binary packages from the scipy site or from [http://enthought.com Enthought] along with the pre-built slicer.  The following works on the mac, for instance:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
import sys&lt;br /&gt;
d = '/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/'&lt;br /&gt;
packages = ['matplotlib', 'neuroimaging', 'numpy', '', 'scipy']&lt;br /&gt;
for p in packages:&lt;br /&gt;
  sys.path.append(d+p)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Basic Slicer/Python tutorial ==&lt;br /&gt;
''Note: this is initial documentation only, and is subject to change as the API evolves.''&lt;br /&gt;
&lt;br /&gt;
The Slicer Python interpreter has access to all Python modules referenced by the environment variable '''PYTHONPATH''' as well as the '''Slicer''' internal module.  The '''Slicer''' module also supports the interface between Slicer Volume Nodes and NumPy.  It would be instructive for the reader to review the [http://www.scipy.org/Documentation NumPy documentation].  For serious users of NumPy, there is the [http://www.tramy.us/ ''Guide to NumPy''] by Travis Oliphant for purchase.&lt;br /&gt;
&lt;br /&gt;
The main interface to Slicer from Python is through the Slicer Python module.  From there, the Python user can access any of Slicer's global objects and MRML tree.  For example:&lt;br /&gt;
&lt;br /&gt;
  &amp;gt;&amp;gt;&amp;gt; import Slicer&lt;br /&gt;
  &amp;gt;&amp;gt;&amp;gt; Slicer.slicer&lt;br /&gt;
  &amp;lt;Slicer.Slicer object at 0x9f325f0&amp;gt;&lt;br /&gt;
  &amp;gt;&amp;gt;&amp;gt; Slicer.slicer.MRMLScene.GetNumberOfNodesByClass ( 'vtkMRMLVolumeNode' )&lt;br /&gt;
  0&lt;br /&gt;
  &amp;gt;&amp;gt;&amp;gt; &lt;br /&gt;
&lt;br /&gt;
In this case, no 'vtkMRMLVolumeNode's were loaded into Slicer.&lt;br /&gt;
&lt;br /&gt;
VTK objects may be easily constructed, as well as any other object available from the C++ Slicer API.&lt;br /&gt;
&lt;br /&gt;
 &amp;gt;&amp;gt;&amp;gt; a = Slicer.slicer.vtkPolyData()&lt;br /&gt;
 &amp;gt;&amp;gt;&amp;gt; help ( a )&lt;br /&gt;
 Help on vtkPolyData in module Slicer object:&lt;br /&gt;
 &lt;br /&gt;
 class vtkPolyData(vtkPointSet)&lt;br /&gt;
  |  Method resolution order:&lt;br /&gt;
  |      vtkPolyData&lt;br /&gt;
  |      vtkPointSet&lt;br /&gt;
  |      vtkDataSet&lt;br /&gt;
  &amp;lt;output truncated&amp;gt;&lt;br /&gt;
&lt;br /&gt;
VTK objects created in this manner conform as closely as possible to the VTK Python bindings, but must be created through the slicer object inside the Slicer module.  Each object may be fully subclassed following the [http://www.onlamp.com/pub/a/python/2003/04/17/metaclasses.html meta object pattern].&lt;br /&gt;
&lt;br /&gt;
==== A few details on Python in Slicer ====&lt;br /&gt;
&lt;br /&gt;
Although it is possible to use Slicer within Python, enabling Python in a Slicer build does not trigger Python wrapping of C++ classes. Instead, Python has access to the Slicer API through Tcl. Whenever a constructor for an object is invoked, e.g.&lt;br /&gt;
&lt;br /&gt;
 from Slicer import slicer &lt;br /&gt;
 surface = slicer.vtkPolyData()&lt;br /&gt;
&lt;br /&gt;
to create a VTK object, or&lt;br /&gt;
&lt;br /&gt;
 modelNode = slicer.vtkMRMLModelNode()&lt;br /&gt;
&lt;br /&gt;
to create a MRML node, the Python interpreter tells the Tcl interpreter to instantiate a vtkPolyData or vtkMRMLModelNode (this happens through the Tcl wrappers which are built as part of the basic Slicer) and makes it available to the Python interface. More in detail, Python asks Tcl to illustrate what is a vtkPolyData, what are the parent classes and the methods, creates the whole class hierarchy on the fly, and creates an instance of that object.&lt;br /&gt;
When one calls an object's method, like&lt;br /&gt;
&lt;br /&gt;
 numberOfPoints = surface.GetNumberOfPoints()&lt;br /&gt;
&lt;br /&gt;
the Python interpreter relies the call to the Tcl interpreter and returns the proper return value. Any object available to Tcl is the same object available to Python, and this allows for a great flexibility, as everything lives in a common space.&lt;br /&gt;
&lt;br /&gt;
Writing modules (especially interactive modules) in Python can lead to quite a speed up in the development cycle, since the code is more concise, it requires less file shuffling and, more than anything, it doesn't need to be recompiled (in some cases you don't even need to exit Slicer).&lt;br /&gt;
&lt;br /&gt;
More than this, enabling Python in Slicer opens up the possibility of accessing a very wide range of Python libraries, such as Numpy and Scipy, from within Slicer (interactively or in modules), making the Slicer use cases potentially explode.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== NumPy tutorial ====&lt;br /&gt;
&lt;br /&gt;
Python and NumPy give direct access to the volume data in Slicer by wrapping the image data in a NumPy '''array''' object through the '''.ToArray()''' method on the volume node.  This tutorial assumes you have installed [http://scipy.org/Download SciPy].&lt;br /&gt;
&lt;br /&gt;
 &amp;gt;&amp;gt;&amp;gt; # Access the image data directly&lt;br /&gt;
 &amp;gt;&amp;gt;&amp;gt; from Slicer import slicer&lt;br /&gt;
 &amp;gt;&amp;gt;&amp;gt; nodes = slicer.ListVolumeNodes()&lt;br /&gt;
 &amp;gt;&amp;gt;&amp;gt; t2 = nodes['T2.hdr']&lt;br /&gt;
 &amp;gt;&amp;gt;&amp;gt; data = t2.GetImageData().ToArray()&lt;br /&gt;
 &amp;gt;&amp;gt;&amp;gt; print data&lt;br /&gt;
 [[[ 0  0  0 ...,  0  0  0]&lt;br /&gt;
   [ 0  0  1 ...,  0  1  0]&lt;br /&gt;
   [ 0  0  0 ...,  0  0  0]&lt;br /&gt;
   ..., &lt;br /&gt;
   [ 0  8  0 ...,  0  1  2]&lt;br /&gt;
   [ 0  0  0 ...,  4  1  2]&lt;br /&gt;
   [ 0  0  2 ...,  6  0  2]]&lt;br /&gt;
 &lt;br /&gt;
 &amp;lt;&amp;lt;&amp;lt; Some output truncated &amp;gt;&amp;gt;&amp;gt; &lt;br /&gt;
 &lt;br /&gt;
  [[ 0  0  0 ...,  0  0  0]&lt;br /&gt;
   [ 0  0  0 ...,  0  0  0]&lt;br /&gt;
   [ 0  0  0 ...,  0  0  0]&lt;br /&gt;
   ..., &lt;br /&gt;
   [ 0  3  3 ...,  0  0  8]&lt;br /&gt;
   [ 0  6  0 ...,  5  3 13]&lt;br /&gt;
   [ 0  5  1 ...,  9  3  8]]]&lt;br /&gt;
 &amp;gt;&amp;gt;&amp;gt; # Load the image filtering package from scipy&lt;br /&gt;
 &amp;gt;&amp;gt;&amp;gt; import scipy.ndimage&lt;br /&gt;
 &amp;gt;&amp;gt;&amp;gt; # Filter into a new array&lt;br /&gt;
 &amp;gt;&amp;gt;&amp;gt; temp = scipy.ndimage.gaussian_filter ( data, 2.0 )&lt;br /&gt;
 &amp;gt;&amp;gt;&amp;gt; # Copy back into Slicer&lt;br /&gt;
 &amp;gt;&amp;gt;&amp;gt; data[:] = temp[:]&lt;br /&gt;
 &amp;gt;&amp;gt;&amp;gt; t2.Modified()&lt;br /&gt;
&lt;br /&gt;
Before:&lt;br /&gt;
&lt;br /&gt;
[[Image:PythonBefore.png]]&lt;br /&gt;
&lt;br /&gt;
After:&lt;br /&gt;
&lt;br /&gt;
[[Image:PythonAfter.png]]&lt;br /&gt;
&lt;br /&gt;
===== Accessing Tensor Data =====&lt;br /&gt;
&lt;br /&gt;
Because of the way vtk stores tensors, it is not directly accessible via the GetImageData().ToArray() approach used for scalar images.&lt;br /&gt;
&lt;br /&gt;
Instead, you can access it with something like:&lt;br /&gt;
 i = Slicer.slicer.MRML['dti'].GetImageData().GetPointData().GetTensors().ToArray()&lt;br /&gt;
&lt;br /&gt;
The default shape of this will be Nx9 where N is the total number of voxels in the volume.  You can convert these to tensors with something like:&lt;br /&gt;
&lt;br /&gt;
 d = Slicer.slicer.MRML['dti'].GetImageData().GetDimensions()&lt;br /&gt;
 d.reverse()&lt;br /&gt;
 tensors = i.reshape(d+[3,3])&lt;br /&gt;
&lt;br /&gt;
==== The NumPy command line module ====&lt;br /&gt;
&lt;br /&gt;
In order to speed up experimentation, a Numpy command line module is available.&lt;br /&gt;
&lt;br /&gt;
It takes in input one or two volume nodes and an output volume node, plus a path to a Python script residing in a text file. &lt;br /&gt;
&lt;br /&gt;
Upon execution, input volume nodes are converted to ndarray variables named iarray and iarray2. The user simply has to put Numpy/Scipy code in the text file, taking care that the output array is stored in a variable named oarray. For example, the file could look like&lt;br /&gt;
&lt;br /&gt;
 import scipy.ndimage&lt;br /&gt;
 oarray = scipy.ndimage.gaussian_filter ( iarray, 2.0 )&lt;br /&gt;
&lt;br /&gt;
The module will take care of taking the content of oarray and storing it in the output volume node (note: differently from the example above, and more in line with Slicer practices, the result of processing is stored in a different output volume, which is selected from the node selector). &lt;br /&gt;
&lt;br /&gt;
To rerun different NumPy code on the input image, simply edit the script file, save it and rerun the module.&lt;br /&gt;
&lt;br /&gt;
== Cython support ==&lt;br /&gt;
[http://www.cython.org/ Cython] is an open source project that compiles a Python code into a shared library.  Cython can compile most Python code, but gains the most speed when the Python code is augmented with clues to Cython regarding the datatype of a variable.  To use Cython on your Slicer Python (slipy?) code, you must compile the Cython code into a shared library.&lt;br /&gt;
&lt;br /&gt;
First install Cython:&lt;br /&gt;
 hg clone http://hg.cython.org/cython-closures/&lt;br /&gt;
 cd cython-closures&lt;br /&gt;
 ~/Slicer3-lib/Python-build/bin/python setup.py install&lt;br /&gt;
&lt;br /&gt;
Next, create setup.py to build your code:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
import distutils&lt;br /&gt;
import distutils.sysconfig&lt;br /&gt;
&lt;br /&gt;
from distutils.core import setup&lt;br /&gt;
from distutils.extension import Extension&lt;br /&gt;
from Cython.Distutils import build_ext&lt;br /&gt;
&lt;br /&gt;
ext_modules = [Extension(&amp;quot;OneTensorCython&amp;quot;, [&amp;quot;OneTensorCython.pyx&amp;quot;])]&lt;br /&gt;
&lt;br /&gt;
setup(&lt;br /&gt;
    name = 'Tractography filtering with python',&lt;br /&gt;
    cmdclass = {'build_ext': build_ext},&lt;br /&gt;
    ext_modules = ext_modules&lt;br /&gt;
)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Build your Cython code with Slicer's Python using the --inplace flag:&lt;br /&gt;
 ~/Slicer3-lib/Python-build/bin/python setup.py build_ext --inplace&lt;br /&gt;
&lt;br /&gt;
To use your Cython code as a Slicer module, you will need to write a pure Python wrapper.  The current plug-in mechanism interrogates the function for it's parameters, which does not work on the compiled functions that Cython uses.  This example simply passes through to the Cython module '''OneTensorCython'''.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
import OneTensorCython&lt;br /&gt;
&lt;br /&gt;
XML = OneTensorCython.XML&lt;br /&gt;
&lt;br /&gt;
def Execute(dwi_node, seeds_node, mask_node, ff_node):&lt;br /&gt;
    OneTensorCython.Execute (dwi_node, seeds_node, mask_node, ff_node)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Matplotlib plotting functionality ==&lt;br /&gt;
Matplotlib may be used from within Slicer, but currently (on the Mac) the Tk backend locks up and crashes Slicer.  However, Matplotlib may still be used through one of the non-GUI backends.  More details can be found on the [http://matplotlib.sourceforge.net/ MatPlotLib] pages.&lt;br /&gt;
&lt;br /&gt;
 import matplotlib&lt;br /&gt;
 matplotlib.use ( 'Agg' )&lt;br /&gt;
 from pylab import *&lt;br /&gt;
 &lt;br /&gt;
 t1 = arange(0.0, 5.0, 0.1)&lt;br /&gt;
 t2 = arange(0.0, 5.0, 0.02)&lt;br /&gt;
 t3 = arange(0.0, 2.0, 0.01) &lt;br /&gt;
 &lt;br /&gt;
 subplot(211)&lt;br /&gt;
 plot(t1, cos(2*pi*t1)*exp(-t1), 'bo', t2, cos(2*pi*t2)*exp(-t2), 'k')&lt;br /&gt;
 grid(True)&lt;br /&gt;
 title('A tale of 2 subplots')&lt;br /&gt;
 ylabel('Damped')&lt;br /&gt;
 &lt;br /&gt;
 subplot(212)&lt;br /&gt;
 plot(t3, cos(2*pi*t3), 'r--')&lt;br /&gt;
 grid(True)&lt;br /&gt;
 xlabel('time (s)')&lt;br /&gt;
 ylabel('Undamped')&lt;br /&gt;
 savefig ( 'MatplotlibExample.png' )&lt;br /&gt;
 &lt;br /&gt;
 import Slicer&lt;br /&gt;
 r = Slicer.slicer.vtkPNGReader()&lt;br /&gt;
 v = Slicer.slicer.vtkImageViewer()&lt;br /&gt;
 r.SetFileName( 'MatplotlibExample.png' )&lt;br /&gt;
 &lt;br /&gt;
 v.SetColorWindow(255)&lt;br /&gt;
 v.SetColorLevel(128)&lt;br /&gt;
 v.SetInput(r.GetOutput())&lt;br /&gt;
 v.Render()&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Image:MatplotlibExample.png]]&lt;br /&gt;
&lt;br /&gt;
== Where to go from here ==&lt;br /&gt;
Far from exhaustive, this documentation is intended to whet the appitite of researchers who love the power of Matlab, but feel trapped inside, unable to break out and deploy applications.  This Python interface to Slicer is intended to help!  Here are some selected resources to begin to understand the power of what the combined NumPy - Slicer package offers.&lt;br /&gt;
&lt;br /&gt;
=== Python Language Information ===&lt;br /&gt;
&lt;br /&gt;
* [http://www.python.org/doc/ Python documentation]&lt;br /&gt;
** [http://www.rexx.com/~dkuhlman/python_101/python_101.html Gentle introduction to Python]&lt;br /&gt;
** [http://www.python.org/doc/Intros.html Python introduction]&lt;br /&gt;
&lt;br /&gt;
=== Numpy and Scipy Information ===&lt;br /&gt;
&lt;br /&gt;
* [http://www.scipy.org/NumPy NumPy documentation]&lt;br /&gt;
** [http://www.trelgol.com/ Comprehensive ''Guide to NumPy''] by the current maintainer&lt;br /&gt;
** [http://numeric.scipy.org/numpydoc/numdoc.htm Old NumPy documentation] ([http://numeric.scipy.org/numpy.pdf pdf])&lt;br /&gt;
* [http://www.scipy.org SciPy] [http://scipy.org/Documentation Documentation]&lt;br /&gt;
* [http://matplotlib.sourceforge.net/ MatPlotLib]&lt;br /&gt;
&lt;br /&gt;
=== Writing Slicer Modules in Python ===&lt;br /&gt;
&lt;br /&gt;
Painless Development in Slicer3 with Python, talk given by Demian Wassermann at the LMI, sept. 2008&lt;br /&gt;
* Slides: Introduction to Slicer3 with Python: [[media:PythonSlicer.pdf]]&lt;br /&gt;
* Slides: Numpy indexing and example: [[media:PythonSlicerNumpy.pdf]]&lt;br /&gt;
* See [[Slicer3:Python:DemianExamples | Demian's Example Code]]&lt;br /&gt;
&lt;br /&gt;
Slicer Python breakout session in Salt Lake City, Winter Project Week 2009, by Luca Antiga.&lt;br /&gt;
* Slides: [[media:ProjectWeekBreakout2009_SlicerPython.pdf]]‎&lt;br /&gt;
&lt;br /&gt;
* [[Slicer3:Execution_Model_Documentation:Python|Scripted Command Line Modules in Python]]&lt;br /&gt;
* [[Slicer3:Execution_Model_Documentation:Programmatic_Invocation#Python_Example|Invoking command line modules from Python]]&lt;br /&gt;
&lt;br /&gt;
=== Additional Experiments ===&lt;br /&gt;
&lt;br /&gt;
* An experiment to create an [[Slicer3:Python:ScriptedActor|OpenGL VTK Actor in Python]].&lt;br /&gt;
* An experiment to call [[Slicer3:Python:pitky |ITK with C++ from Python]] using [http://www.scipy.org/Cookbook/Weave weave].&lt;br /&gt;
* [[Slicer3:Python:ipython|Installing ipython]] interface&lt;/div&gt;</summary>
		<author><name>Blezek</name></author>
		
	</entry>
	<entry>
		<id>https://www.slicer.org/w/index.php?title=Slicer3:Python&amp;diff=15719</id>
		<title>Slicer3:Python</title>
		<link rel="alternate" type="text/html" href="https://www.slicer.org/w/index.php?title=Slicer3:Python&amp;diff=15719"/>
		<updated>2010-05-11T02:52:20Z</updated>

		<summary type="html">&lt;p&gt;Blezek: /* Matplotlib plotting functionality */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Status of Python in Slicer ==&lt;br /&gt;
As of Slicer 3.4, '''python''' and '''numpy''' are enabled by default. &lt;br /&gt;
&lt;br /&gt;
'''scipy''' and '''matplotlib''' are ''not'' enabled due to the difficulty in compiling binaries of them for distribution.  It is possible for people to compile their own versions of scipy to install and use with a local copy of slicer.  This is also true for many other python modules (see [[Slicer3:Python:ipython | the ipython installation technique]] as an example that should work for other distutils based python code.)&lt;br /&gt;
&lt;br /&gt;
Though [http://matplotlib.sourceforge.net/ matplotlib] is still not properly interacting with Slicer3, NumPy and Python support should work well for all platforms.  [[Slicer3:Execution_Model_Documentation:Python | Python command line modules]] are well supported, as is building full [[Modules:Python | GUI modules in Python]].&lt;br /&gt;
&lt;br /&gt;
== Python for scientific computing ==&lt;br /&gt;
Python has a fairly comprehensive package for scientific computing called [http://scipy.org SciPy].  Of main interest to Slicer users/developers is [http://numpy.scipy.org NumPy].  NumPy provides most of the features of the Matlab image processing toolbox and numeric computations, but in an Open Source package.  A compelling reason to use NumPy is the ease of interaction and integration with Slicer3.&lt;br /&gt;
&lt;br /&gt;
== Slicer3 and Python ==&lt;br /&gt;
&lt;br /&gt;
==== Enabling Python in the Slicer Build====&lt;br /&gt;
# Edit slicer_variables.tcl&lt;br /&gt;
## Change &amp;quot;set ::USE_PYTHON &amp;quot;off&amp;quot;&amp;quot; to &amp;quot;on&amp;quot;&lt;br /&gt;
# '''Optional:''' If you prefer to use your system Python installation, change set ::USE_SYSTEM_PYTHON &amp;quot;false&amp;quot; to &amp;quot;true&amp;quot;&lt;br /&gt;
## This will give an error under Linux and Windows, but it can be easily fixed by adding the system path for Python, just search for &amp;quot;if { $::USE_SYSTEM_PYTHON } {&amp;quot;&lt;br /&gt;
# '''Optional:''' installing SciPy&lt;br /&gt;
## [http://sourceforge.net/project/showfiles.php?group_id=27747 Download] the scipy egg for your platform&lt;br /&gt;
## Unzip the egg in any directory that is part of Slicer's Python path, eg Slicer3-build/lib/Slicer3/Plugins&lt;br /&gt;
## SciPy should now be available in Slicer's Python interpreter&lt;br /&gt;
&lt;br /&gt;
Build Slicer3 using &amp;quot;getbuildtest.tcl&amp;quot;, i.e.:&lt;br /&gt;
&lt;br /&gt;
 Macintosh:Slicer3 blezek$ Scripts/getbuildtest.tcl&lt;br /&gt;
&lt;br /&gt;
A new menu command '''Python Interpreter''' should appear on the Window menu.&lt;br /&gt;
&lt;br /&gt;
[[Image:PythonMenu.png]]&lt;br /&gt;
&lt;br /&gt;
This command should bring up the '''Python Console''' window.&lt;br /&gt;
&lt;br /&gt;
[[Image:PythonConsole.png]]&lt;br /&gt;
&lt;br /&gt;
==== Using System Python Libraries with Slicer's python ====&lt;br /&gt;
&lt;br /&gt;
It is possible in many instances to use binary packages from the scipy site or from [http://enthought.com Enthought] along with the pre-built slicer.  The following works on the mac, for instance:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
import sys&lt;br /&gt;
d = '/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/'&lt;br /&gt;
packages = ['matplotlib', 'neuroimaging', 'numpy', '', 'scipy']&lt;br /&gt;
for p in packages:&lt;br /&gt;
  sys.path.append(d+p)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Basic Slicer/Python tutorial ==&lt;br /&gt;
''Note: this is initial documentation only, and is subject to change as the API evolves.''&lt;br /&gt;
&lt;br /&gt;
The Slicer Python interpreter has access to all Python modules referenced by the environment variable '''PYTHONPATH''' as well as the '''Slicer''' internal module.  The '''Slicer''' module also supports the interface between Slicer Volume Nodes and NumPy.  It would be instructive for the reader to review the [http://www.scipy.org/Documentation NumPy documentation].  For serious users of NumPy, there is the [http://www.tramy.us/ ''Guide to NumPy''] by Travis Oliphant for purchase.&lt;br /&gt;
&lt;br /&gt;
The main interface to Slicer from Python is through the Slicer Python module.  From there, the Python user can access any of Slicer's global objects and MRML tree.  For example:&lt;br /&gt;
&lt;br /&gt;
  &amp;gt;&amp;gt;&amp;gt; import Slicer&lt;br /&gt;
  &amp;gt;&amp;gt;&amp;gt; Slicer.slicer&lt;br /&gt;
  &amp;lt;Slicer.Slicer object at 0x9f325f0&amp;gt;&lt;br /&gt;
  &amp;gt;&amp;gt;&amp;gt; Slicer.slicer.MRMLScene.GetNumberOfNodesByClass ( 'vtkMRMLVolumeNode' )&lt;br /&gt;
  0&lt;br /&gt;
  &amp;gt;&amp;gt;&amp;gt; &lt;br /&gt;
&lt;br /&gt;
In this case, no 'vtkMRMLVolumeNode's were loaded into Slicer.&lt;br /&gt;
&lt;br /&gt;
VTK objects may be easily constructed, as well as any other object available from the C++ Slicer API.&lt;br /&gt;
&lt;br /&gt;
 &amp;gt;&amp;gt;&amp;gt; a = Slicer.slicer.vtkPolyData()&lt;br /&gt;
 &amp;gt;&amp;gt;&amp;gt; help ( a )&lt;br /&gt;
 Help on vtkPolyData in module Slicer object:&lt;br /&gt;
 &lt;br /&gt;
 class vtkPolyData(vtkPointSet)&lt;br /&gt;
  |  Method resolution order:&lt;br /&gt;
  |      vtkPolyData&lt;br /&gt;
  |      vtkPointSet&lt;br /&gt;
  |      vtkDataSet&lt;br /&gt;
  &amp;lt;output truncated&amp;gt;&lt;br /&gt;
&lt;br /&gt;
VTK objects created in this manner conform as closely as possible to the VTK Python bindings, but must be created through the slicer object inside the Slicer module.  Each object may be fully subclassed following the [http://www.onlamp.com/pub/a/python/2003/04/17/metaclasses.html meta object pattern].&lt;br /&gt;
&lt;br /&gt;
==== A few details on Python in Slicer ====&lt;br /&gt;
&lt;br /&gt;
Although it is possible to use Slicer within Python, enabling Python in a Slicer build does not trigger Python wrapping of C++ classes. Instead, Python has access to the Slicer API through Tcl. Whenever a constructor for an object is invoked, e.g.&lt;br /&gt;
&lt;br /&gt;
 from Slicer import slicer &lt;br /&gt;
 surface = slicer.vtkPolyData()&lt;br /&gt;
&lt;br /&gt;
to create a VTK object, or&lt;br /&gt;
&lt;br /&gt;
 modelNode = slicer.vtkMRMLModelNode()&lt;br /&gt;
&lt;br /&gt;
to create a MRML node, the Python interpreter tells the Tcl interpreter to instantiate a vtkPolyData or vtkMRMLModelNode (this happens through the Tcl wrappers which are built as part of the basic Slicer) and makes it available to the Python interface. More in detail, Python asks Tcl to illustrate what is a vtkPolyData, what are the parent classes and the methods, creates the whole class hierarchy on the fly, and creates an instance of that object.&lt;br /&gt;
When one calls an object's method, like&lt;br /&gt;
&lt;br /&gt;
 numberOfPoints = surface.GetNumberOfPoints()&lt;br /&gt;
&lt;br /&gt;
the Python interpreter relies the call to the Tcl interpreter and returns the proper return value. Any object available to Tcl is the same object available to Python, and this allows for a great flexibility, as everything lives in a common space.&lt;br /&gt;
&lt;br /&gt;
Writing modules (especially interactive modules) in Python can lead to quite a speed up in the development cycle, since the code is more concise, it requires less file shuffling and, more than anything, it doesn't need to be recompiled (in some cases you don't even need to exit Slicer).&lt;br /&gt;
&lt;br /&gt;
More than this, enabling Python in Slicer opens up the possibility of accessing a very wide range of Python libraries, such as Numpy and Scipy, from within Slicer (interactively or in modules), making the Slicer use cases potentially explode.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== NumPy tutorial ====&lt;br /&gt;
&lt;br /&gt;
Python and NumPy give direct access to the volume data in Slicer by wrapping the image data in a NumPy '''array''' object through the '''.ToArray()''' method on the volume node.  This tutorial assumes you have installed [http://scipy.org/Download SciPy].&lt;br /&gt;
&lt;br /&gt;
 &amp;gt;&amp;gt;&amp;gt; # Access the image data directly&lt;br /&gt;
 &amp;gt;&amp;gt;&amp;gt; from Slicer import slicer&lt;br /&gt;
 &amp;gt;&amp;gt;&amp;gt; nodes = slicer.ListVolumeNodes()&lt;br /&gt;
 &amp;gt;&amp;gt;&amp;gt; t2 = nodes['T2.hdr']&lt;br /&gt;
 &amp;gt;&amp;gt;&amp;gt; data = t2.GetImageData().ToArray()&lt;br /&gt;
 &amp;gt;&amp;gt;&amp;gt; print data&lt;br /&gt;
 [[[ 0  0  0 ...,  0  0  0]&lt;br /&gt;
   [ 0  0  1 ...,  0  1  0]&lt;br /&gt;
   [ 0  0  0 ...,  0  0  0]&lt;br /&gt;
   ..., &lt;br /&gt;
   [ 0  8  0 ...,  0  1  2]&lt;br /&gt;
   [ 0  0  0 ...,  4  1  2]&lt;br /&gt;
   [ 0  0  2 ...,  6  0  2]]&lt;br /&gt;
 &lt;br /&gt;
 &amp;lt;&amp;lt;&amp;lt; Some output truncated &amp;gt;&amp;gt;&amp;gt; &lt;br /&gt;
 &lt;br /&gt;
  [[ 0  0  0 ...,  0  0  0]&lt;br /&gt;
   [ 0  0  0 ...,  0  0  0]&lt;br /&gt;
   [ 0  0  0 ...,  0  0  0]&lt;br /&gt;
   ..., &lt;br /&gt;
   [ 0  3  3 ...,  0  0  8]&lt;br /&gt;
   [ 0  6  0 ...,  5  3 13]&lt;br /&gt;
   [ 0  5  1 ...,  9  3  8]]]&lt;br /&gt;
 &amp;gt;&amp;gt;&amp;gt; # Load the image filtering package from scipy&lt;br /&gt;
 &amp;gt;&amp;gt;&amp;gt; import scipy.ndimage&lt;br /&gt;
 &amp;gt;&amp;gt;&amp;gt; # Filter into a new array&lt;br /&gt;
 &amp;gt;&amp;gt;&amp;gt; temp = scipy.ndimage.gaussian_filter ( data, 2.0 )&lt;br /&gt;
 &amp;gt;&amp;gt;&amp;gt; # Copy back into Slicer&lt;br /&gt;
 &amp;gt;&amp;gt;&amp;gt; data[:] = temp[:]&lt;br /&gt;
 &amp;gt;&amp;gt;&amp;gt; t2.Modified()&lt;br /&gt;
&lt;br /&gt;
Before:&lt;br /&gt;
&lt;br /&gt;
[[Image:PythonBefore.png]]&lt;br /&gt;
&lt;br /&gt;
After:&lt;br /&gt;
&lt;br /&gt;
[[Image:PythonAfter.png]]&lt;br /&gt;
&lt;br /&gt;
===== Accessing Tensor Data =====&lt;br /&gt;
&lt;br /&gt;
Because of the way vtk stores tensors, it is not directly accessible via the GetImageData().ToArray() approach used for scalar images.&lt;br /&gt;
&lt;br /&gt;
Instead, you can access it with something like:&lt;br /&gt;
 i = Slicer.slicer.MRML['dti'].GetImageData().GetPointData().GetTensors().ToArray()&lt;br /&gt;
&lt;br /&gt;
The default shape of this will be Nx9 where N is the total number of voxels in the volume.  You can convert these to tensors with something like:&lt;br /&gt;
&lt;br /&gt;
 d = Slicer.slicer.MRML['dti'].GetImageData().GetDimensions()&lt;br /&gt;
 d.reverse()&lt;br /&gt;
 tensors = i.reshape(d+[3,3])&lt;br /&gt;
&lt;br /&gt;
==== The NumPy command line module ====&lt;br /&gt;
&lt;br /&gt;
In order to speed up experimentation, a Numpy command line module is available.&lt;br /&gt;
&lt;br /&gt;
It takes in input one or two volume nodes and an output volume node, plus a path to a Python script residing in a text file. &lt;br /&gt;
&lt;br /&gt;
Upon execution, input volume nodes are converted to ndarray variables named iarray and iarray2. The user simply has to put Numpy/Scipy code in the text file, taking care that the output array is stored in a variable named oarray. For example, the file could look like&lt;br /&gt;
&lt;br /&gt;
 import scipy.ndimage&lt;br /&gt;
 oarray = scipy.ndimage.gaussian_filter ( iarray, 2.0 )&lt;br /&gt;
&lt;br /&gt;
The module will take care of taking the content of oarray and storing it in the output volume node (note: differently from the example above, and more in line with Slicer practices, the result of processing is stored in a different output volume, which is selected from the node selector). &lt;br /&gt;
&lt;br /&gt;
To rerun different NumPy code on the input image, simply edit the script file, save it and rerun the module.&lt;br /&gt;
&lt;br /&gt;
== Cython support ==&lt;br /&gt;
== Matplotlib plotting functionality ==&lt;br /&gt;
Matplotlib may be used from within Slicer, but currently (on the Mac) the Tk backend locks up and crashes Slicer.  However, Matplotlib may still be used through one of the non-GUI backends.  More details can be found on the [http://matplotlib.sourceforge.net/ MatPlotLib] pages.&lt;br /&gt;
&lt;br /&gt;
 import matplotlib&lt;br /&gt;
 matplotlib.use ( 'Agg' )&lt;br /&gt;
 from pylab import *&lt;br /&gt;
 &lt;br /&gt;
 t1 = arange(0.0, 5.0, 0.1)&lt;br /&gt;
 t2 = arange(0.0, 5.0, 0.02)&lt;br /&gt;
 t3 = arange(0.0, 2.0, 0.01) &lt;br /&gt;
 &lt;br /&gt;
 subplot(211)&lt;br /&gt;
 plot(t1, cos(2*pi*t1)*exp(-t1), 'bo', t2, cos(2*pi*t2)*exp(-t2), 'k')&lt;br /&gt;
 grid(True)&lt;br /&gt;
 title('A tale of 2 subplots')&lt;br /&gt;
 ylabel('Damped')&lt;br /&gt;
 &lt;br /&gt;
 subplot(212)&lt;br /&gt;
 plot(t3, cos(2*pi*t3), 'r--')&lt;br /&gt;
 grid(True)&lt;br /&gt;
 xlabel('time (s)')&lt;br /&gt;
 ylabel('Undamped')&lt;br /&gt;
 savefig ( 'MatplotlibExample.png' )&lt;br /&gt;
 &lt;br /&gt;
 import Slicer&lt;br /&gt;
 r = Slicer.slicer.vtkPNGReader()&lt;br /&gt;
 v = Slicer.slicer.vtkImageViewer()&lt;br /&gt;
 r.SetFileName( 'MatplotlibExample.png' )&lt;br /&gt;
 &lt;br /&gt;
 v.SetColorWindow(255)&lt;br /&gt;
 v.SetColorLevel(128)&lt;br /&gt;
 v.SetInput(r.GetOutput())&lt;br /&gt;
 v.Render()&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Image:MatplotlibExample.png]]&lt;br /&gt;
&lt;br /&gt;
== Where to go from here ==&lt;br /&gt;
Far from exhaustive, this documentation is intended to whet the appitite of researchers who love the power of Matlab, but feel trapped inside, unable to break out and deploy applications.  This Python interface to Slicer is intended to help!  Here are some selected resources to begin to understand the power of what the combined NumPy - Slicer package offers.&lt;br /&gt;
&lt;br /&gt;
=== Python Language Information ===&lt;br /&gt;
&lt;br /&gt;
* [http://www.python.org/doc/ Python documentation]&lt;br /&gt;
** [http://www.rexx.com/~dkuhlman/python_101/python_101.html Gentle introduction to Python]&lt;br /&gt;
** [http://www.python.org/doc/Intros.html Python introduction]&lt;br /&gt;
&lt;br /&gt;
=== Numpy and Scipy Information ===&lt;br /&gt;
&lt;br /&gt;
* [http://www.scipy.org/NumPy NumPy documentation]&lt;br /&gt;
** [http://www.trelgol.com/ Comprehensive ''Guide to NumPy''] by the current maintainer&lt;br /&gt;
** [http://numeric.scipy.org/numpydoc/numdoc.htm Old NumPy documentation] ([http://numeric.scipy.org/numpy.pdf pdf])&lt;br /&gt;
* [http://www.scipy.org SciPy] [http://scipy.org/Documentation Documentation]&lt;br /&gt;
* [http://matplotlib.sourceforge.net/ MatPlotLib]&lt;br /&gt;
&lt;br /&gt;
=== Writing Slicer Modules in Python ===&lt;br /&gt;
&lt;br /&gt;
Painless Development in Slicer3 with Python, talk given by Demian Wassermann at the LMI, sept. 2008&lt;br /&gt;
* Slides: Introduction to Slicer3 with Python: [[media:PythonSlicer.pdf]]&lt;br /&gt;
* Slides: Numpy indexing and example: [[media:PythonSlicerNumpy.pdf]]&lt;br /&gt;
* See [[Slicer3:Python:DemianExamples | Demian's Example Code]]&lt;br /&gt;
&lt;br /&gt;
Slicer Python breakout session in Salt Lake City, Winter Project Week 2009, by Luca Antiga.&lt;br /&gt;
* Slides: [[media:ProjectWeekBreakout2009_SlicerPython.pdf]]‎&lt;br /&gt;
&lt;br /&gt;
* [[Slicer3:Execution_Model_Documentation:Python|Scripted Command Line Modules in Python]]&lt;br /&gt;
* [[Slicer3:Execution_Model_Documentation:Programmatic_Invocation#Python_Example|Invoking command line modules from Python]]&lt;br /&gt;
&lt;br /&gt;
=== Additional Experiments ===&lt;br /&gt;
&lt;br /&gt;
* An experiment to create an [[Slicer3:Python:ScriptedActor|OpenGL VTK Actor in Python]].&lt;br /&gt;
* An experiment to call [[Slicer3:Python:pitky |ITK with C++ from Python]] using [http://www.scipy.org/Cookbook/Weave weave].&lt;br /&gt;
* [[Slicer3:Python:ipython|Installing ipython]] interface&lt;/div&gt;</summary>
		<author><name>Blezek</name></author>
		
	</entry>
	<entry>
		<id>https://www.slicer.org/w/index.php?title=Documentation/3.6&amp;diff=14757</id>
		<title>Documentation/3.6</title>
		<link rel="alternate" type="text/html" href="https://www.slicer.org/w/index.php?title=Documentation/3.6&amp;diff=14757"/>
		<updated>2010-04-29T02:28:04Z</updated>

		<summary type="html">&lt;p&gt;Blezek: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This is work in progress&lt;br /&gt;
&lt;br /&gt;
=Main GUI=&lt;br /&gt;
&lt;br /&gt;
*[[Modules:MainApplicationGUI-Documentation-3.6| Main Application GUI]] (Wendy Plesniak) &lt;br /&gt;
*[[Modules:EventBindings-3.6| &amp;quot;Hot-keys&amp;quot; and Keyboard Shortcuts]] (Wendy Plesniak) &lt;br /&gt;
*[[Modules:Loading-Data-3.6| Loading Data]] (scenes, DICOM, volumes, models, fiducials, transforms, etc.)   (Wendy Plesniak)&lt;br /&gt;
*[[Modules:Saving-Documentation-3.6| Saving Data]] (scenes, volumes, models, fiducials, transforms, etc.)  (Wendy Plesniak)&lt;br /&gt;
*[[Modules:SceneSnapshots-3.6| Creating and Restoring Scene Snapshots]] (Wendy Plesniak)&lt;br /&gt;
*[[Modules:ExtensionsManagementWizard-Documentation-3.6| Extensions Management Wizard]] '''in progress''' (Wendy Plesniak)&lt;br /&gt;
&lt;br /&gt;
=Modules=&lt;br /&gt;
*Please copy the template linked below, paste it into your page and customize it with your module's information.&lt;br /&gt;
[[Slicer3:Module_Documentation-3.6_Template|Slicer3:Module_Documentation-3.6_Template]] &lt;br /&gt;
*See Requirements for Modules for info to be put into the Help and Acknowledgment Tabs&lt;br /&gt;
*To put your lab's logo into a module, see [[Slicer3:Execution_Model_Documentation#Adding_Module_Logos_to_Slicer3|here]]&lt;br /&gt;
&lt;br /&gt;
Please adhere to the naming scheme for the module documentation:&lt;br /&gt;
*[ [Modules:MyModuleNameNoSpaces-Documentation-3.6|My Module Name With Spaces] ] (First Last Name)&lt;br /&gt;
&lt;br /&gt;
=Requirements for Modules=&lt;br /&gt;
{| border=&amp;quot;00&amp;quot; cellpadding=&amp;quot;5&amp;quot; cellspacing=&amp;quot;0&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| rowspan=&amp;quot;2&amp;quot;| &lt;br /&gt;
* The module is '''feature complete''', it does everything that it advertises it can do&lt;br /&gt;
* The module has a '''test'''. See [http://wiki.na-mic.org/Wiki/index.php/Slicer3:Execution_Model_Testing '''here'''] for more information.&lt;br /&gt;
* Module has '''documentation''' on the [[Documentation-3.5#Modules|Slicer wiki]]. Please use the template provided [[Documentation-3.6#Modules|'''here''']] to structure your page. Please keep in mind that our users are not computer scientists with a background in computer vision.&lt;br /&gt;
*Please add a pointer to the documentation on the Slicer wiki to the the '''Help''' tab of the module. See the '''Editor module''' in Slicer for an example.&lt;br /&gt;
* The contributor (and their manager/advisor), the lab (with labs/institution logo) and the funding source (with grant number, logo optional) are listed in the '''Acknowledegment''' tab of the module. Please see the '''Models module''' for an example. The people listed in the acknowledgement will be the primary people for support and maintenance relative of the module. [[Slicer3:Execution_Model_Documentation#Adding_Module_Logos_to_Slicer3|See here for more information.]]&lt;br /&gt;
** '''Style Guide:''' All acknowledgment icons should be 100x100 pixels, preferably in png format.&lt;br /&gt;
** '''Accessing logos:''' Icons for BIRN, NAC, NA-MIC and IGT are included in Slicer3/Base/GUI//vtkSlicerBaseAcknowledgementLogoIcons.cxx/h and resources for them are in Slicer3/Base/GUI/Resources/vtkSlicerBaseAcknowledgementLogos_ImageData.h. The API for vtkSlicerModuleGUI provides access to these icons. &lt;br /&gt;
** '''Adding logos:''' Please add additional image resources and logo icons to these files as required in order to promote shared use (and to prevent duplication in the code.)&lt;br /&gt;
* Many modules are better suited to be [[Documentation-3.4#Extensions_for_Downloading|downloadable extensions]].  The same module creation guidelines apply, but the actual implementation is done outside of the slicer source code repository.&lt;br /&gt;
* Follow [[Documentation-3.5-Rons-Rules|'''Ron's rules for tools''']]&lt;br /&gt;
| style=&amp;quot;background: #e5e5e5&amp;quot; align=&amp;quot;center&amp;quot;| Examples for the Help and &lt;br /&gt;
Acknowledgment Panels&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;background: #ebeced&amp;quot;|[[Image:SlicerHelpExample.png|center|200px]][[Image:SlicerAcknowledgementExample.png|center|200px]] &lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=List of Modules added or significantly revised since the 3.4 release=&lt;br /&gt;
* Interactive Editor&lt;br /&gt;
* Volume Rendering&lt;br /&gt;
* Colors (Nicole Aucoin)&lt;br /&gt;
* MRI Bias Field Correction (Sylvain Jaume)&lt;br /&gt;
* 4D Image (Viewer) (Junichi Tokuda)&lt;br /&gt;
* 4D Analysis (Time-intensity curve plotting and analysis) (Junichi Tokuda)&lt;br /&gt;
* Fast Marching segmentation (Andriy Fedorov)&lt;br /&gt;
* Mesh Contour Segmentation (Peter Karasev)&lt;br /&gt;
* Crop Volume (Subvolume extraction with ROI widget) (Andriy Fedorov)&lt;br /&gt;
* Measurements (rulers and angles) (Nicole Aucoin)&lt;br /&gt;
* Affine registration (Casey Goodlett)&lt;br /&gt;
* Collect Patient Fiducials (Andrew Wiles)&lt;br /&gt;
* IGT Tool Selector (Andrew Wiles)&lt;br /&gt;
* Fiducials (Nicole Aucoin)&lt;br /&gt;
* PETCTFusion (Wendy Plesniak)&lt;br /&gt;
* N4 Bias Field Correction (Andriy Fedorov)&lt;br /&gt;
&lt;br /&gt;
=List of Modules=&lt;br /&gt;
==Core==&lt;br /&gt;
*[[Modules:Cameras-Documentation-3.6| Camera Module]] (Sebastian Barre)&lt;br /&gt;
*[[Modules:Welcome-Documentation-3.6| Welcome Module]] (Wendy Plesniak, Steve Pieper, Sonia Pujol, Ron Kikinis)&lt;br /&gt;
*[[Modules:Volumes-Documentation-3.6| Volumes Module]] (Alex Yarmarkovich, Steve Pieper) &lt;br /&gt;
**[[Modules:Volumes:Diffusion Editor-Documentation-3.6| Diffusion Editor]] (Kerstin Kessel)&lt;br /&gt;
*[[Modules:Models-Documentation-3.6| Models Module]] (Alex Yarmarkovich) &lt;br /&gt;
*[[Modules:Fiducials-Documentation-3.6| Fiducials Module]]  (Nicole Aucoin) &lt;br /&gt;
*[[Modules:Measurements-Documentation-3.6 | Measurements (rulers and angles) ]] (Nicole Aucoin)&lt;br /&gt;
*[[Modules:Data-Documentation-3.6| Data Module]] (Alex Yarmarkovich) &lt;br /&gt;
*[[Modules:Slices-Documentation-3.6|Slices Module]] (Jim Miller) &lt;br /&gt;
*[[Modules:Colors-Documentation-3.6| Color Module]] (Nicole Aucoin) &lt;br /&gt;
*[[Modules:Editor-Documentation-3.4| Interactive Editor]] (Steve Pieper)   &amp;lt;span style=&amp;quot;background:hotpink; color:white&amp;quot;&amp;gt;Not yet 3.6&amp;lt;/span&amp;gt;&amp;lt;font background=hotpink color=white&amp;gt;Not yet 3.6&amp;lt;/font&amp;gt;&lt;br /&gt;
*[[Modules:ROIModule-Documentation-3.6|ROI Module]] (Alex Yarmarkovich) &lt;br /&gt;
*[[Modules:PETCTFusion-Documentation-3.6 | PET/CT Fusion Module]] (Wendy Plesniak)&lt;br /&gt;
*[[Modules:VolumeRendering-Documentation-3.6| Volume Rendering Module]] (Yanling Liu, Alex Yarmarkovich)&lt;br /&gt;
&lt;br /&gt;
==Specialized Modules==&lt;br /&gt;
&lt;br /&gt;
Please adhere to the naming scheme for the module documentation:&lt;br /&gt;
*[[Modules:MyModuleNameNoSpaces-Documentation-3.6|My Module Name With Spaces] ] (First Last Name)&lt;br /&gt;
&lt;br /&gt;
===Wizards===&lt;br /&gt;
*[[Modules:ChangeTracker-Documentation-3.6|ChangeTracker]] (Andriy Fedorov)&lt;br /&gt;
*[[Modules:IA_FEMesh-Documentation-3.6|IA FE Meshing Module]] (Vincent Magnotta, Curt Lisle)&lt;br /&gt;
&lt;br /&gt;
===Informatics Modules===&lt;br /&gt;
*[[Modules:FetchMI-Documentation-3.6| Fetch Medical Informatics Module]] (Wendy Plesniak, Dan Marcus)  &lt;br /&gt;
*[[Modules:QDECModule-Documentation-3.6| QDEC Module]] (Nicole Aucoin) &lt;br /&gt;
*[[Modules:QueryAtlas-Documentation-3.6|Query Atlas Module]] (Wendy Plesniak)&lt;br /&gt;
&lt;br /&gt;
===Registration===&lt;br /&gt;
*[[Slicer3:Registration|'''Overview of all Registration Modules''' ]]: go here for more detailed help on selecting your registration module.&lt;br /&gt;
*Fast&lt;br /&gt;
**[[Modules:Transforms-Documentation-3.6|Transforms]]:  manual &amp;amp; interactive rigid registration , (Alex Yarmarkovich)&lt;br /&gt;
**[[Modules:AffineRegistration-Documentation-3.6|Fast Affine Registration]]:  automated fast affine registration , (Jim Miller)   &lt;br /&gt;
**[[Modules:RigidRegistration-Documentation-3.6|Fast Rigid Registration]]:  automated fast rigid (6 DOF) registration , (Jim Miller)  &lt;br /&gt;
**[[Modules:DeformableB-SplineRegistration-Documentation-3.6|Fast Nonrigid BSpline Registration]]: fast non-rigid registration , (Bill Lorensen)  &lt;br /&gt;
*Robust&lt;br /&gt;
**[[Modules:RegisterImages-Documentation-3.6|Expert Pipeline Rigid-Affine-Nonrigid Registration]]:  automated registration with extensive parameter options, robust initialization, variable DOF and masking options, (Casey Goodlett)&lt;br /&gt;
**[[Modules:RegisterImagesMultiRes-Documentation-3.6|Robust Multiresolution Affine Registration]]: affine registration in multi-resolution scheme, robust to large differences in initial position or image content ,  (Casey Goodlett)&lt;br /&gt;
** [[Modules:BRAINSDemonWarp|BRAINSDemonWarp]] Hans Johnson (hans-johnson@uiowa.edu). Belongs to registration, robust&lt;br /&gt;
** [[Modules:BRAINSFit|BRAINSFit]] Hans Johnson (hans-johnson@uiowa.edu) . Belongs to registration robust&lt;br /&gt;
** [[Modules:BRAINSResample|BRAINSResample]] Hans Johnson (hans-johnson@uiowa.edu) . Belongs to registration robust&lt;br /&gt;
&lt;br /&gt;
*Brain Only&lt;br /&gt;
**[[Modules:ACPCTransform-Documentation-3.6|ACPC Transform]]: align a single brain along AC-PC line ,  (Nicole Aucoin)&lt;br /&gt;
*Non-Raster-Image Data&lt;br /&gt;
**[[Modules:TransformFromFiducials-Documentation-3.6|Fiducial Registration]]: align two sets of fiducials (translation, rigid or similarity)  (Casey Goodlett)&lt;br /&gt;
**[[Modules:PythonSurfaceICPRegistration-Documentation-3.6|Surface Registration]]: automated surface-to-surface (model) registration (Luca Antiga, Daniel Blezek)&lt;br /&gt;
*Experimental and auxiliary&lt;br /&gt;
**[[Modules:RegistrationMetrics-Documentation-3.6 | Registration Metrics (HD and DSC) ]] (Haytham Elhawary)  &amp;lt;span style=&amp;quot;background:hotpink; color:white&amp;quot;&amp;gt;Updated to 3.6 but needs checking&amp;lt;/span&amp;gt;&amp;lt;font background=hotpink color=white&amp;gt;&amp;lt;/font&amp;gt;&lt;br /&gt;
**[[Modules:LinearRegistration-Documentation-3.4|Linear Registration]]: obsolete: old version of the ''Fast Rigid Registration'' (Daniel Blezek)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Segmentation===&lt;br /&gt;
*[[Modules:SegmentationOverview3.6|Overview]]&lt;br /&gt;
**[[Modules:EMSegmentTemplateBuilder3.6|EM Segment Template Builder 3.6]] (Kilian Pohl)  &lt;br /&gt;
**[[Modules:EMSegment-Command-Line3.6|EM Segment Command-Line]] (Kilian Pohl)  &lt;br /&gt;
**[[Modules:EMSegment-Simple3.6|EM Segment Simple]] (Kilian Pohl) &lt;br /&gt;
**[[Modules:FastMarchingSegmentation-Documentation-3.6|Fast Marching segmentation]] (Andriy Fedorov)&lt;br /&gt;
**[[Modules:OtsuThresholdSegmentation-Documentation-3.6|Otsu Threshold Segmentation]] (Bill Lorensen)&lt;br /&gt;
**[[Modules:Simple Region Growing-Documentation-3.6|Simple Region Growing]] (Jim Miller, Harini Veeraraghavan)  &lt;br /&gt;
**[[Modules:RobustStatisticsSeg-Documentation-3.6|RobustStatisticsSeg]] Yi Gao (yigao@gatech.edu).&lt;br /&gt;
**[[Modules:BRAINSROIAuto|BRAINSROIAuto]] Hans Johnson (hans-johnson@uiowa.edu).&lt;br /&gt;
&lt;br /&gt;
===Statistics===&lt;br /&gt;
*[[Modules:LabelStatistics-Documentation-3.6|Label Statistics]] (Steve Pieper)&lt;br /&gt;
&lt;br /&gt;
===Diffusion MRI===&lt;br /&gt;
*Diffusion MRI&lt;br /&gt;
** DWI filtering&lt;br /&gt;
***[[Modules:JointRicianLMMSEImageFilter-Documentation-3.6|Joint Rician LMMSE Image Filter]] (Antonio Tristán Vega, Santiago Aja-Fernandez)   &lt;br /&gt;
***[[Modules:RicianLMMSEImageFilter-Documentation-3.6|Rician LMMSE Image Filter]] (Antonio Tristán Vega, Santiago Aja-Fernandez, Marc Niethammer)  &lt;br /&gt;
***[[Modules:UnbiasedNonLocalMeans-Documentation-3.6|Unbiased Non Local Means filter for DWI]]  (Antonio Tristán Vega, Santiago Aja-Fernandez)  &lt;br /&gt;
** Diffusion tensor utilities&lt;br /&gt;
***[[Modules:DiffusionTensorEstimation-Documentation-3.6|Diffusion Tensor Estimation]] (Raul San Jose Estepar)   &lt;br /&gt;
***[[Modules:DiffusionTensorScalarMeasurements-Documentation-3.6 | Diffusion Tensor Scalar Measurements]] (Raul San Jose Estepar)  &lt;br /&gt;
** Resampling&lt;br /&gt;
***[[Modules:ResampleDTIVolume-Documentation-3.6|Resample DTI Volume]] (Francois Budin)&lt;br /&gt;
** Tractography&lt;br /&gt;
***[[Modules:ROISeeding-Documentation-3.6 | Label Seeding]] (Raul San Jose Estepar)   &lt;br /&gt;
***[[Modules:FiducialSeeding-Documentation-3.6|Fiducial Seeding]] (Alex Yarmakovich, Steve Pieper) &lt;br /&gt;
***[[Modules:DTIDisplay-Documentation-3.6|FiberBundles]] (Alex Yarmakovich) &lt;br /&gt;
***[[Modules:StochasticTractography-Documentation-3.6|Python Stochastic Tractography]] (Julien de Siebenthal)   &lt;br /&gt;
***[[Modules:ROISelect-Documentation-3.6|ROI Select]] (Lauren O'Donnell)&lt;br /&gt;
&lt;br /&gt;
===IGT===&lt;br /&gt;
*[[Modules:OpenIGTLinkIF-Documentation-3.6| OpenIGTLinkIF Module]] (Junichi Tokuda)&lt;br /&gt;
*[[Modules:NeuroNav-Documentation-3.6| NeuroNav Module]] (Haiying Liu)&lt;br /&gt;
*[[Modules:ProstateNav-Documentation-3.6| ProstateNav Module]] (Junichi Tokuda, Andras Lasso)&lt;br /&gt;
*[[Modules:CollectFiducials-Documentation-3.6 | Collect Patient Fiducials ]] (Andrew Wiles)&lt;br /&gt;
*[[Modules:IGTToolSelector-Documentation-3.6 | IGT Tool Selector ]] (Andrew Wiles)&lt;br /&gt;
&lt;br /&gt;
===Time Series===&lt;br /&gt;
* [[Modules:FourDImage-Documentation-3.6|4D Image (Viewer)]] (Junichi Tokuda)&lt;br /&gt;
&lt;br /&gt;
===Filtering===&lt;br /&gt;
*[[Modules:MRIBiasFieldCorrection-Documentation-3.6|MRI Bias Field Correction]] (Sylvain Jaume)&lt;br /&gt;
*[[Modules:CheckerboardFilter-Documentation-3.6|Checkerboard Filter]] (Bill Lorensen, Jim Miller)&lt;br /&gt;
*[[Modules:HistogramMatching-Documentation-3.6|Histogram Matching]] '''In progress''' (Bill Lorensen, Xiaodong Tao)&lt;br /&gt;
*[[Modules:ImageLabelCombine-3.6|Image Label Combine]] (Alex Yarmarkovich)  &lt;br /&gt;
*[[Modules:ResampleVolume-Documentation-3.6|Resample Volume]] (Bill Lorensen)&lt;br /&gt;
*[[Modules:ResampleScalarVectorDWIVolume-Documentation-3.6|Resample Scalar/Vector/DWI Volume]] (Francois Budin)&lt;br /&gt;
*[[Modules:ThresholdImage-Documentation-3.6|Threshold Image]] (Nicole Aucoin)&lt;br /&gt;
*[[Modules:OtsuThreshold-Documentation-3.6|Otsu Threshold]] (Bill Lorensen) &lt;br /&gt;
*Arithmetic&lt;br /&gt;
**[[Modules:AddImages-Documentation-3.6|Add Images]] (Harini Veeraraghavan) &lt;br /&gt;
**[[Modules:SubtractImages-Documentation-3.6|Subtract Images]] (Harini Veeraraghavan)  &lt;br /&gt;
** [[Modules:CastImage-Documentation-3.6|Cast Image]] (Nicole Aucoin) &lt;br /&gt;
** [[Modules:MaskImage-Documentation-3.6|Mask Image]] (Nicole Aucoin) &lt;br /&gt;
*Denoising&lt;br /&gt;
**[[Modules:GradientAnisotropicFilter-Documentation-3.6| Gradient Anisotropic Filter]]  (Bill Lorensen)&lt;br /&gt;
**[[Modules:CurvatureAnisotropicDiffusion-Documentation-3.6|Curvature Anisotropic Diffusion]] (Bill Lorensen)&lt;br /&gt;
**[[Modules:GaussianBlur-Documentation-3.4|Gaussian Blur]] (Julien Jomier, Stephen Aylward)  &amp;lt;span style=&amp;quot;background:hotpink; color:white&amp;quot;&amp;gt;Not yet 3.6&amp;lt;/span&amp;gt;&amp;lt;font background=hotpink color=white&amp;gt;Not yet 3.6&amp;lt;/font&amp;gt;&lt;br /&gt;
**[[Modules:MedianFilter-Documentation-3.6|Median Filter]] '''In progress''' (Xiaodong Tao)  &lt;br /&gt;
*Morphology&lt;br /&gt;
**[[Modules:VotingBinaryHoleFilling-Documentation-3.6|Voting Binary Hole Filling]] (Jim Miller)  &lt;br /&gt;
**[[Modules:GrayscaleFillHole-Documentation-3.6|Grayscale Fill Hole]] (Bill Lorensen)&lt;br /&gt;
**[[Modules:GrayscaleGrindPeak-Documentation-3.6|Grayscale Grind Peak]] (Bill Lorensen)&lt;br /&gt;
&lt;br /&gt;
===Surface Models===&lt;br /&gt;
*[[Modules:ModelMaker-Documentation-3.6| ModelMaker]] (Nicole Aucoin) &lt;br /&gt;
*[[Modules:GrayscaleModelMaker-Documentation-3.6|Grayscale Model Maker]] (Bill Lorensen)  &amp;lt;span style=&amp;quot;background:hotpink; color:white&amp;quot;&amp;gt;Not yet 3.6&amp;lt;/span&amp;gt;&amp;lt;font background=hotpink color=white&amp;gt;Not yet 3.6&amp;lt;/font&amp;gt;&lt;br /&gt;
*[[Modules:MeshContourSegmentation-Documentation-3.6|Mesh Contour Segmentation]] (Peter Karasev)  &lt;br /&gt;
*[[Modules:PythonSurfaceConnectivity-Documentation-3.6| Python Surface Connectivity]] (Luca Antiga, Daniel Blezek)&lt;br /&gt;
*[[Modules:PythonSurfaceICPRegistration-Documentation-3.6| Python Surface ICP Registration]] (Luca Antiga, Daniel Blezek)&lt;br /&gt;
*[[Modules:PythonSurfaceToolbox-Documentation-3.6| Python Surface Toolbox]] (Luca Antiga, Daniel Blezek) &lt;br /&gt;
*[[Modules:ClipModel-Documentation-3.6| Clip Model]] (Alex Yarmarkovich)  &lt;br /&gt;
*[[Modules:Model_Into_Label_Volume_Documentation-3.6| Model into Label Volume]] (Nicole Aucoin)&lt;br /&gt;
*[[Modules:MergeModels-Documentation-3.6| Merge Models]] (Nicole Aucoin)&lt;br /&gt;
&lt;br /&gt;
===Batch processing===&lt;br /&gt;
*[[Modules:EMSegmentBatch-Documentation-3.6|EM Segmenter batch]] (Julien Jomier, Brad Davis)&lt;br /&gt;
*[[Modules:GaussianBlurBatch-Documentation-3.6|Gaussian Blur batch]] (Julien Jomier, Stephen Aylward)&lt;br /&gt;
*[[Modules:RegisterImagesBatch-Documentation-3.6|Register Images batch]] (Julien Finet, Stephen Aylward)&lt;br /&gt;
*[[Modules:ResampleVolumeBatch-Documentation-3.6|Resample Volume batch]] (Julien Finet)&lt;br /&gt;
&lt;br /&gt;
===Converters===&lt;br /&gt;
*[[Modules:CreateaDicomSeries-Documentation-3.6|Create a Dicom Series]] '''(in progress)''' (Xiaodong Tao)  &lt;br /&gt;
*[[Modules:DicomToNRRD-3.6|Dicom to NRRD]] '''(in progress)''' (Xiaodong Tao)&lt;br /&gt;
*[[Modules:OrientImages-Documentation-3.6|Orient Images]] '''(In progress)''' (Xiaodong Tao)  &lt;br /&gt;
*[[Modules:PythonExplodeVolumeTransform-Documentation-3.6| Python Explode Volume Transform]] (Luca Antiga, Daniel Blezek)&lt;br /&gt;
*[[Modules:CropVolume-Documentation-3.6|Crop Volume]] (previously ExtractSubvolumeROI) (Andriy Fedorov)&lt;br /&gt;
&lt;br /&gt;
==Experimental==&lt;br /&gt;
* [[Modules:N4ITKBiasFieldCorrection-Documentation-3.6|N4 Bias Field Correction]] (Andriy Fedorov)&lt;br /&gt;
&lt;br /&gt;
=Slicer Extensions=&lt;br /&gt;
&lt;br /&gt;
==Extensions for Downloading==&lt;br /&gt;
===Introduction===&lt;br /&gt;
[[Image:SlicerOnNITRC2009.png|thumb|right|Slicer on NITRC]]&lt;br /&gt;
* Slicer Extensions are a mechanism for third parties to provide modules which extend the functionality of 3d Slicer.&lt;br /&gt;
* Some of the extensions do not use the Slicer license. Please review carefully.&lt;br /&gt;
* For a subset of extensions, you can use the extension wizard in Slicer to find their webpages and to install/uninstall individual extensions. In case of problems with those modules, please talk directly to the developers of the extensions.&lt;br /&gt;
* The version that is available through the extension manager is chosen by the developer of that extension   &lt;br /&gt;
&lt;br /&gt;
We are using NITRC as the primary repository for contributed extensions. As a general rule, we do not test the extensions ourselves. Use them at your own risk.&lt;br /&gt;
Click [http://www.nitrc.org/search/?type_of_search=soft&amp;amp;words=slicer3&amp;amp;Search.x=0&amp;amp;Search.y=0&amp;amp;Search=Search  here] to see a listing of Slicer 3 extensions on NITRC.&lt;br /&gt;
&lt;br /&gt;
[[Image:Slicer-3.4.1-extension-manager-2009-10-02.png|thumb|right|Extension manager dialog box]]&lt;br /&gt;
To add extension modules to an installed binary of slicer:&lt;br /&gt;
* Use the View-&amp;gt;Extension Manager menu option&lt;br /&gt;
* The dialog will be initialized with the URL to the extensions that have been compiled to match your binary of slicer.&lt;br /&gt;
** '''Note''' installing extensions from a different repository URL is likely to be unstable due to platform and software version differences.&lt;br /&gt;
** You can select a local install directory for your downloaded extensions (be sure to choose a directory with enough free space).&lt;br /&gt;
* Select the extensions you wish to install and click to download them.  Installed extensions will be available when you restart slicer.&lt;br /&gt;
* To turn modules on or off, you can use the Module Settings page of the View-&amp;gt;Application Settings dialog.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
*Extensions are compiled as part of the nightly build. In order to have your extension compiled nightly and made available to end users, please contact the Slicer team. For explanations for developers see [[Slicer3:Extensions| here]]&lt;br /&gt;
&lt;br /&gt;
'''Installation'''&lt;br /&gt;
*Click on the cogwheel icon to start the extensions wizard (highlighted in red)&lt;br /&gt;
[[image:Slicertoolbar.png|Extensions Wizard]]&lt;br /&gt;
&lt;br /&gt;
===Listing of plug-ins===&lt;br /&gt;
&lt;br /&gt;
'''Available Extensions'''&lt;br /&gt;
&lt;br /&gt;
* [[Modules:ABC-Documentation-3.5|ABC]] Marcel Prastawa (prastawa@sci.utah.edu) (a.k.a. Atlas Based Classification) '''Not yet 3.6'''. Belongs to segmentation&lt;br /&gt;
&lt;br /&gt;
* [[Modules:ARCTIC-Documentation-3.6|ARCTIC]] Cedric Mathieu and Clement Vachet (cvachet@email.unc.edu) (a.k.a Automatic Regional Cortical ThICkness) '''Not yet 3.6'''. Belongs to wizards&lt;br /&gt;
&lt;br /&gt;
* [[Modules:BRAINSMush|BRAINSMush]] Hans Johnson (hans-johnson@uiowa.edu) '''Not yet 3.6'''. Belongs to registration robust.&lt;br /&gt;
&lt;br /&gt;
* [[Modules:CMTK|CMTK]] Computational Morphometry Toolkit Torsten Rohlfing (torsten@synapse.sri.com) '''Not yet 3.6'''. Belongs to registration robust.&lt;br /&gt;
&lt;br /&gt;
* [[Modules:EMDTIClustering-Documentation-3.6|EMFiberClusteringModule]] Mahnaz Maddah (maddah@ge.com) (a.k.a. Quantitative Diffusion Tools). Belongs to tractography&lt;br /&gt;
&lt;br /&gt;
* [[Modules:FourDAnalysis-Documentation-3.6|4D Analysis (Time-series plotting and analysis including kinetic analysis of DCE MRI)]] Junichi Tokuda (tokuda@bwh.harvard.edu)&lt;br /&gt;
&lt;br /&gt;
* [[Modules:FuzzySegmentationModule|FuzzySegmentationModule]] Xiaodong Tao (taox@research.ge.com) '''Not yet 3.6'''. Belongs to segmentation.&lt;br /&gt;
&lt;br /&gt;
* [[Modules:HammerRegistration|HammerRegistration]] GuorongWu, XiaodongTao, JimMiller, DinggangShen (dgshen@med.unc.edu) '''Not yet 3.6'''. Belongs to registration robust.&lt;br /&gt;
&lt;br /&gt;
* [[Modules:LabelDiameterEstimation-Documentation-3.5|LabelDiameterEstimation]] Andriy Fedorov (fedorov@bwh.harvard.edu) '''Not yet 3.6'''. Belongs to Statistics.&lt;br /&gt;
&lt;br /&gt;
* [[Modules:LesionSegmentationApplications-Documentation-3.6|LesionSegmentationApplications]] Mark Scully (mscully@mrn.org) (a.k.a. 3DSlicerLupusLesionModule) '''Not yet 3.6'''. Belongs to wizards.&lt;br /&gt;
&lt;br /&gt;
* [[Modules:Plastimatch|Plastimatch]] Greg Sharp (gcsharp@partners.org) '''Not yet 3.6'''. Belongs to registration robust.&lt;br /&gt;
&lt;br /&gt;
* [[Modules:RicianNoiseFilter|RicianNoiseFilter]] Ross Whitaker (whitaker@cs.utah.edu) '''Not yet 3.6'''. Belongs to DWI&lt;br /&gt;
&lt;br /&gt;
* [[Modules:SkullStripperModule|SkullStripperModule]] Xiaodong Tao (taox@research.ge.com) '''Not yet 3.6'''. Belongs to wizards&lt;br /&gt;
&lt;br /&gt;
* [[Modules:SpineSegmentation-Documentation-3.6|SpineSegmentation]] Sylvain Jaume (sylvain@csail.mit.edu). Belongs to wizards&lt;br /&gt;
&lt;br /&gt;
* [[Image:Slicervmtk_logo.png|150px]] The Vascular Modeling Toolkit in 3D Slicer, Daniel Haehn (haehn@bwh.harvard.edu)&lt;br /&gt;
&lt;br /&gt;
:*[[Modules:VMTKSlicerModule|VmtkSlicerModule]] prerequisite install for all VMTK plug-ins&lt;br /&gt;
&lt;br /&gt;
:*[[Modules:VMTKCenterlines|VMTKCenterlines]] providing centerline computation of surface models&lt;br /&gt;
&lt;br /&gt;
:*[[Modules:VMTKEasyLevelSetSegmentation|VMTKEasyLevelSetSegmentation]] providing level-set segmentation of vessels, aneurysms and tubular structures using an easy interface&lt;br /&gt;
&lt;br /&gt;
:*[[Modules:VMTKLevelSetSegmentation|VMTKLevelSetSegmentation]] providing level-set segmentation of vessels, aneurysms and tubular structures using different algorithms for initialization and evolution&lt;br /&gt;
&lt;br /&gt;
:*[[Modules:VMTKVesselEnhancement|VMTKVesselEnhancement]] providing vessel enhancement filters to highlight vascular or tubular structures&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Example Extensions====&lt;br /&gt;
&lt;br /&gt;
* [[Modules:ExampleCommandLine|ExampleCommandLine]] Jim Miller '''Not yet 3.6'''&lt;br /&gt;
&lt;br /&gt;
* [[Modules:ExampleLoadableGuiLessModule|ExampleLoadableGuiLessModule]] Steve Pieper '''Not yet 3.6'''&lt;br /&gt;
&lt;br /&gt;
* [[Modules:ExampleLoadableModule|ExampleLoadableModule]] Steve Pieper '''Not yet 3.6'''&lt;br /&gt;
&lt;br /&gt;
* [[Modules:PythonSampleScriptedModule|PythonSampleScriptedModule]] Steve Pieper '''Not yet 3.6'''&lt;br /&gt;
&lt;br /&gt;
* [[Modules:TclSampleScriptedModule|TclSampleScriptedModule]] Steve Pieper '''Not yet 3.6'''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Non-SPL Supported Compatibility Packages'''&lt;br /&gt;
&lt;br /&gt;
* [[Modules:BioImageSuite|BioImageSuite]] Xenios Papademtrios '''Not yet 3.6'''&lt;br /&gt;
&lt;br /&gt;
=QA=&lt;br /&gt;
[[Slicer-3.6-QA|Slicer 3.6 QA table]]&lt;/div&gt;</summary>
		<author><name>Blezek</name></author>
		
	</entry>
	<entry>
		<id>https://www.slicer.org/w/index.php?title=Modules:LinearRegistration-Documentation-3.6&amp;diff=14752</id>
		<title>Modules:LinearRegistration-Documentation-3.6</title>
		<link rel="alternate" type="text/html" href="https://www.slicer.org/w/index.php?title=Modules:LinearRegistration-Documentation-3.6&amp;diff=14752"/>
		<updated>2010-04-29T02:19:56Z</updated>

		<summary type="html">&lt;p&gt;Blezek: /* Use Cases, Examples */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Documentation-3.6|Return to Slicer 3.6 Documentation]]&lt;br /&gt;
&lt;br /&gt;
[[Announcements:Slicer3.6#Highlights|Gallery of New Features]]&lt;br /&gt;
&lt;br /&gt;
__NOTOC__&lt;br /&gt;
===Linear Registration===&lt;br /&gt;
Linear Registration&lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
|[[Image:LinearRegistrationUI.png|thumb|280px|User Interface]]&lt;br /&gt;
|[[Image:LinearRegistration.png|thumb|280px|Linear Registration Module]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== General Information ==&lt;br /&gt;
===Module Type &amp;amp; Category===&lt;br /&gt;
&lt;br /&gt;
Type: Interactive or CLI&lt;br /&gt;
&lt;br /&gt;
Category: Registration&lt;br /&gt;
&lt;br /&gt;
===Authors, Collaborators &amp;amp; Contact===&lt;br /&gt;
* Author: Daniel Blezek&lt;br /&gt;
* Contact: daniel.blezek@gmail.com&lt;br /&gt;
&lt;br /&gt;
===Module Description===&lt;br /&gt;
This command line module implements a registration algorithm based on the Mattes mutual information registration metric.  The transformation mapping the moving image to the fixed image consists of 3 translations and 3 rotations.  Thus only rigid body transformations are permitted.  Both the fixed and moving images may be optionally smoothed before registration.  The module optionally breaks the optimization into multiple stages, each with a different learning rate and number of iterations.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Usage ==&lt;br /&gt;
&lt;br /&gt;
===Use Cases, Examples===&lt;br /&gt;
&lt;br /&gt;
* This module is often used to align images of the same subject acquired at different times.&lt;br /&gt;
* The Mattes mutual information metric is suitable for aligning images of the same or different modalities.&lt;br /&gt;
* The rigid body transformation allows a limited degree of deformation and frequently is used as a pre-processing step for higher order transformations such as the [[Modules:DeformableB-SplineRegistration-Documentation-3.6|BSpline]] and [[Modules:DiffeomorphicDemonsAlgorithm-Documentation-3.6| Demons]].&lt;br /&gt;
&lt;br /&gt;
===Quick Tour of Features and Use===&lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
|&lt;br /&gt;
* '''Preprocessing'''&lt;br /&gt;
** '''Smoothing level for fixed image''' Amount of smoothing applied to fixed image prior to registration. Default is 0 (none). Range is 0-5 (unitless). Consider smoothing the input data if there is considerable amounts of noise or the noise pattern in the fixed and moving images is very different.&lt;br /&gt;
** '''Smoothing level for moving image''' Amount of smoothing applied to moving image prior to registration. Default is 0 (none). Range is 0-5 (unitless). Consider smoothing the input data if there is considerable amounts of noise or the noise pattern in the fixed and moving images is very different.&lt;br /&gt;
* '''Registration Parameters'''&lt;br /&gt;
** '''Histogram Bins''' Number of bins used to generate the joint probability function used for the mutual information calculation.  Generally, 30-100 are used, or roughly 1/3 the number of grey levels in the images.&lt;br /&gt;
** '''Spatial Samples''' Number of sample locations to use in calculating the mutual information.  The Mattes mutual information metric uses this number of samples for stocastic sampling of the images.  2-5% of the number of samples in the image is usually sufficient for registration.&lt;br /&gt;
** '''Iterations''' Comma separated list of iterations. Must have the same number of elements as the learning rate.&lt;br /&gt;
** '''Learning Rate''' Comma separated list of learning rates. Learning rate is a scale factor on the gradient of the registration objective function (gradient with respect to the parameters of the transformation) used to update the parameters of the transformation during optimization. Smaller values cause the optimizer to take smaller steps through the parameter space. Larger values are typically used early in the registration process to take large jumps in parameter space followed by smaller values to home in on the optimum value of the registration objective function. Default is: 0.01, 0.005, 0.0005, 0.0002. Must have the same number of elements as iterations.&lt;br /&gt;
** '''Transform scaling'''  The relative scaling between rotation and translation parameters, i.e. a value of 100 means 10mm = 1 degree. (Actual scale used is 1/(TranslationScale^2)). This parameter is used to &amp;quot;weight&amp;quot; or &amp;quot;standardized&amp;quot; the transform parameters and their effect on the registration objective function.&lt;br /&gt;
* '''Input/Output'''&lt;br /&gt;
** '''Initial transform''' (Optional)  Initial transform for aligning the fixed and moving image.  Maps positions in the fixed coordinate frame to positions in the moving coordinate frame.&lt;br /&gt;
** '''Fixed Image''' The fixed image to register the moving image against.  The transform calculated maps a spatial position within the Fixed Image to a spatial position within the moving image.&lt;br /&gt;
** '''Moving Image''' The moving image to register to the fixed image.&lt;br /&gt;
** '''Output Transform''' Transform calculated that aligns the fixed and moving image. Maps positions in the fixed coordinate frame to the moving coordinate frame. This parameter is optional, and both an output transform and an output volume may be specified.&lt;br /&gt;
** '''Output Volume''' Resampled moving image to the fixed image coordinate frame.  This is output is optional.&lt;br /&gt;
|[[Image:LinearRegistrationUI.png|thumb|280px|User Interface]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Development ==&lt;br /&gt;
&lt;br /&gt;
===Dependencies===&lt;br /&gt;
&lt;br /&gt;
No other modules are required for this module.&lt;br /&gt;
&lt;br /&gt;
===Limitations===&lt;br /&gt;
&lt;br /&gt;
The module uses an [http://www.itk.org/Doxygen/html/classitk_1_1OrientImageFilter.html itkOrientImageFilter] to realign the fixed and moving images to axial before registration.  This is required due to limitations in [http://www.itk.org/Wiki/Proposals:Orientation ITK's handling] of non-axial images in filters used by registration.&lt;br /&gt;
&lt;br /&gt;
===Known bugs===&lt;br /&gt;
&lt;br /&gt;
None.  To report bugs, follow this [http://na-mic.org/Mantis/main_page.php link] to the Slicer3 bug tracker. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Usability issues===&lt;br /&gt;
&lt;br /&gt;
Follow this [http://na-mic.org/Mantis/main_page.php link] to the Slicer3 bug tracker. Please select the '''usability issue category''' when browsing or contributing.&lt;br /&gt;
&lt;br /&gt;
===Source code &amp;amp; documentation===&lt;br /&gt;
&lt;br /&gt;
Source Code: [http://www.na-mic.org/ViewVC/index.cgi/trunk/Applications/CLI/LinearRegistration.cxx C++ Source] and [http://www.na-mic.org/ViewVC/index.cgi/trunk/Applications/CLI/LinearRegistration.xml XML Description]&lt;br /&gt;
&lt;br /&gt;
Documentation:&lt;br /&gt;
&lt;br /&gt;
== More Information == &lt;br /&gt;
&lt;br /&gt;
===Acknowledgment===&lt;br /&gt;
This work is part of the National Alliance for Medical Image&lt;br /&gt;
Computing (NAMIC), funded by the National Institutes of Health&lt;br /&gt;
through the NIH Roadmap for Medical Research, Grant U54 EB005149.&lt;br /&gt;
Information on the National Centers for Biomedical Computing&lt;br /&gt;
can be obtained from [http://www.ncbcs.org/ National Centers for Biomedical Computing].&lt;br /&gt;
&lt;br /&gt;
===References===&lt;br /&gt;
D. Mattes, D.R. Haynor, H. Vesselle, T.K. Lewellen, and  W. Eubank. PET-CT image registration in the chest using  free-form deformations. ''IEEE Transactions on Medical Imaging'',  22(1):120–128, 2003.&lt;/div&gt;</summary>
		<author><name>Blezek</name></author>
		
	</entry>
	<entry>
		<id>https://www.slicer.org/w/index.php?title=Modules:LinearRegistration-Documentation-3.6&amp;diff=14751</id>
		<title>Modules:LinearRegistration-Documentation-3.6</title>
		<link rel="alternate" type="text/html" href="https://www.slicer.org/w/index.php?title=Modules:LinearRegistration-Documentation-3.6&amp;diff=14751"/>
		<updated>2010-04-29T02:18:57Z</updated>

		<summary type="html">&lt;p&gt;Blezek: Created page with 'Return to Slicer 3.6 Documentation  Gallery of New Features  __NOTOC__ ===Linear Registration=== Linear Registration …'&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Documentation-3.6|Return to Slicer 3.6 Documentation]]&lt;br /&gt;
&lt;br /&gt;
[[Announcements:Slicer3.6#Highlights|Gallery of New Features]]&lt;br /&gt;
&lt;br /&gt;
__NOTOC__&lt;br /&gt;
===Linear Registration===&lt;br /&gt;
Linear Registration&lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
|[[Image:LinearRegistrationUI.png|thumb|280px|User Interface]]&lt;br /&gt;
|[[Image:LinearRegistration.png|thumb|280px|Linear Registration Module]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== General Information ==&lt;br /&gt;
===Module Type &amp;amp; Category===&lt;br /&gt;
&lt;br /&gt;
Type: Interactive or CLI&lt;br /&gt;
&lt;br /&gt;
Category: Registration&lt;br /&gt;
&lt;br /&gt;
===Authors, Collaborators &amp;amp; Contact===&lt;br /&gt;
* Author: Daniel Blezek&lt;br /&gt;
* Contact: daniel.blezek@gmail.com&lt;br /&gt;
&lt;br /&gt;
===Module Description===&lt;br /&gt;
This command line module implements a registration algorithm based on the Mattes mutual information registration metric.  The transformation mapping the moving image to the fixed image consists of 3 translations and 3 rotations.  Thus only rigid body transformations are permitted.  Both the fixed and moving images may be optionally smoothed before registration.  The module optionally breaks the optimization into multiple stages, each with a different learning rate and number of iterations.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Usage ==&lt;br /&gt;
&lt;br /&gt;
===Use Cases, Examples===&lt;br /&gt;
&lt;br /&gt;
* This module is often used to align images of the same subject acquired at different times.&lt;br /&gt;
* The Mattes mutual information metric is suitable for aligning images of the same or different modalities.&lt;br /&gt;
* The rigid body transformation allows a limited degree of deformation and frequently is used as a pre-processing step for higher order transformations such as the [[Modules:DeformableB-SplineRegistration-Documentation-3.4|BSpline]] and [[Modules:DiffeomorphicDemonsAlgorithm-Documentation03.4| Demons]].&lt;br /&gt;
&lt;br /&gt;
===Quick Tour of Features and Use===&lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
|&lt;br /&gt;
* '''Preprocessing'''&lt;br /&gt;
** '''Smoothing level for fixed image''' Amount of smoothing applied to fixed image prior to registration. Default is 0 (none). Range is 0-5 (unitless). Consider smoothing the input data if there is considerable amounts of noise or the noise pattern in the fixed and moving images is very different.&lt;br /&gt;
** '''Smoothing level for moving image''' Amount of smoothing applied to moving image prior to registration. Default is 0 (none). Range is 0-5 (unitless). Consider smoothing the input data if there is considerable amounts of noise or the noise pattern in the fixed and moving images is very different.&lt;br /&gt;
* '''Registration Parameters'''&lt;br /&gt;
** '''Histogram Bins''' Number of bins used to generate the joint probability function used for the mutual information calculation.  Generally, 30-100 are used, or roughly 1/3 the number of grey levels in the images.&lt;br /&gt;
** '''Spatial Samples''' Number of sample locations to use in calculating the mutual information.  The Mattes mutual information metric uses this number of samples for stocastic sampling of the images.  2-5% of the number of samples in the image is usually sufficient for registration.&lt;br /&gt;
** '''Iterations''' Comma separated list of iterations. Must have the same number of elements as the learning rate.&lt;br /&gt;
** '''Learning Rate''' Comma separated list of learning rates. Learning rate is a scale factor on the gradient of the registration objective function (gradient with respect to the parameters of the transformation) used to update the parameters of the transformation during optimization. Smaller values cause the optimizer to take smaller steps through the parameter space. Larger values are typically used early in the registration process to take large jumps in parameter space followed by smaller values to home in on the optimum value of the registration objective function. Default is: 0.01, 0.005, 0.0005, 0.0002. Must have the same number of elements as iterations.&lt;br /&gt;
** '''Transform scaling'''  The relative scaling between rotation and translation parameters, i.e. a value of 100 means 10mm = 1 degree. (Actual scale used is 1/(TranslationScale^2)). This parameter is used to &amp;quot;weight&amp;quot; or &amp;quot;standardized&amp;quot; the transform parameters and their effect on the registration objective function.&lt;br /&gt;
* '''Input/Output'''&lt;br /&gt;
** '''Initial transform''' (Optional)  Initial transform for aligning the fixed and moving image.  Maps positions in the fixed coordinate frame to positions in the moving coordinate frame.&lt;br /&gt;
** '''Fixed Image''' The fixed image to register the moving image against.  The transform calculated maps a spatial position within the Fixed Image to a spatial position within the moving image.&lt;br /&gt;
** '''Moving Image''' The moving image to register to the fixed image.&lt;br /&gt;
** '''Output Transform''' Transform calculated that aligns the fixed and moving image. Maps positions in the fixed coordinate frame to the moving coordinate frame. This parameter is optional, and both an output transform and an output volume may be specified.&lt;br /&gt;
** '''Output Volume''' Resampled moving image to the fixed image coordinate frame.  This is output is optional.&lt;br /&gt;
|[[Image:LinearRegistrationUI.png|thumb|280px|User Interface]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Development ==&lt;br /&gt;
&lt;br /&gt;
===Dependencies===&lt;br /&gt;
&lt;br /&gt;
No other modules are required for this module.&lt;br /&gt;
&lt;br /&gt;
===Limitations===&lt;br /&gt;
&lt;br /&gt;
The module uses an [http://www.itk.org/Doxygen/html/classitk_1_1OrientImageFilter.html itkOrientImageFilter] to realign the fixed and moving images to axial before registration.  This is required due to limitations in [http://www.itk.org/Wiki/Proposals:Orientation ITK's handling] of non-axial images in filters used by registration.&lt;br /&gt;
&lt;br /&gt;
===Known bugs===&lt;br /&gt;
&lt;br /&gt;
None.  To report bugs, follow this [http://na-mic.org/Mantis/main_page.php link] to the Slicer3 bug tracker. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Usability issues===&lt;br /&gt;
&lt;br /&gt;
Follow this [http://na-mic.org/Mantis/main_page.php link] to the Slicer3 bug tracker. Please select the '''usability issue category''' when browsing or contributing.&lt;br /&gt;
&lt;br /&gt;
===Source code &amp;amp; documentation===&lt;br /&gt;
&lt;br /&gt;
Source Code: [http://www.na-mic.org/ViewVC/index.cgi/trunk/Applications/CLI/LinearRegistration.cxx C++ Source] and [http://www.na-mic.org/ViewVC/index.cgi/trunk/Applications/CLI/LinearRegistration.xml XML Description]&lt;br /&gt;
&lt;br /&gt;
Documentation:&lt;br /&gt;
&lt;br /&gt;
== More Information == &lt;br /&gt;
&lt;br /&gt;
===Acknowledgment===&lt;br /&gt;
This work is part of the National Alliance for Medical Image&lt;br /&gt;
Computing (NAMIC), funded by the National Institutes of Health&lt;br /&gt;
through the NIH Roadmap for Medical Research, Grant U54 EB005149.&lt;br /&gt;
Information on the National Centers for Biomedical Computing&lt;br /&gt;
can be obtained from [http://www.ncbcs.org/ National Centers for Biomedical Computing].&lt;br /&gt;
&lt;br /&gt;
===References===&lt;br /&gt;
D. Mattes, D.R. Haynor, H. Vesselle, T.K. Lewellen, and  W. Eubank. PET-CT image registration in the chest using  free-form deformations. ''IEEE Transactions on Medical Imaging'',  22(1):120–128, 2003.&lt;/div&gt;</summary>
		<author><name>Blezek</name></author>
		
	</entry>
	<entry>
		<id>https://www.slicer.org/w/index.php?title=File:LinearRegistrationUI.png&amp;diff=14750</id>
		<title>File:LinearRegistrationUI.png</title>
		<link rel="alternate" type="text/html" href="https://www.slicer.org/w/index.php?title=File:LinearRegistrationUI.png&amp;diff=14750"/>
		<updated>2010-04-29T02:15:17Z</updated>

		<summary type="html">&lt;p&gt;Blezek: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Blezek</name></author>
		
	</entry>
	<entry>
		<id>https://www.slicer.org/w/index.php?title=Modules:PythonExplodeVolumeTransform-Documentation-3.6&amp;diff=14749</id>
		<title>Modules:PythonExplodeVolumeTransform-Documentation-3.6</title>
		<link rel="alternate" type="text/html" href="https://www.slicer.org/w/index.php?title=Modules:PythonExplodeVolumeTransform-Documentation-3.6&amp;diff=14749"/>
		<updated>2010-04-29T02:09:02Z</updated>

		<summary type="html">&lt;p&gt;Blezek: /* Quick Tour of Features and Use */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Documentation-3.6|Return to Slicer 3.6 Documentation]]&lt;br /&gt;
&lt;br /&gt;
[[Announcements:Slicer3.6#Highlights|Gallery of New Features]]&lt;br /&gt;
&lt;br /&gt;
__NOTOC__&lt;br /&gt;
===Module Name===&lt;br /&gt;
Python Explode Volume Transform&lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
|[[Image:PythonExploneVolumeTransformUI.png|thumb|280px|User Interface]]&lt;br /&gt;
|}&lt;br /&gt;
{|&lt;br /&gt;
|[[Image:ExplodeVolumeTransform1.png|thumb|320px|Figure 1: Volume loaded with RAS orientation (orientation &amp;quot;From file&amp;quot;)]]&lt;br /&gt;
|[[Image:ExplodeVolumeTransform2.png|thumb|320px|Figure 2: Same volume loaded with IJK orientation]]&lt;br /&gt;
|}&lt;br /&gt;
{|&lt;br /&gt;
|[[Image:ExplodeVolumeTransform3.png|thumb|320px|Figure 3: Exploded RAS volume: ijkToRAS transform + IJK volume (see MRML tree widget on the left)]]&lt;br /&gt;
|[[Image:ExplodeVolumeTransform4.png|thumb|320px|Figure 4: The volume loaded with IJK orientation (from Figure 2) moved under the output transform assumes RAS orientation]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== General Information ==&lt;br /&gt;
===Module Type &amp;amp; Category===&lt;br /&gt;
&lt;br /&gt;
Type: CLI&lt;br /&gt;
&lt;br /&gt;
Category: Converters&lt;br /&gt;
&lt;br /&gt;
===Authors, Collaborators &amp;amp; Contact===&lt;br /&gt;
* Luca Antiga: Orobix Srl &amp;amp; Mario Negri Institute&lt;br /&gt;
* Daniel Blezek: Mayo Clinic&lt;br /&gt;
* Contact: Luca Antiga, luca.antiga@orobix.com&lt;br /&gt;
&lt;br /&gt;
===Module Description===&lt;br /&gt;
This Python module takes a volume in input, extracts its IJKToRAS transform by matrix manipulation, where IJK is the local (VTK-compatible) coordinate system, and generates an IJK-oriented volume in the MRML scene as a child of a IJKToRAS transform node.&lt;br /&gt;
&lt;br /&gt;
== Usage ==&lt;br /&gt;
&lt;br /&gt;
===Use Cases, Examples===&lt;br /&gt;
&lt;br /&gt;
* The module is appropriate when a CLI module can only handle non-oriented images (i.e. images oriented as the XYZ axes), like pure-VTK modules.&lt;br /&gt;
* The typical use is as follows: run a volume through this filter, use the output volume as input for the non-orientation-aware CLI module and place the output of this latter module under the IJKToRAS transform generated by the present module by using the MRML tree widget.&lt;br /&gt;
* Use case: you have data generated from a RAS-agnostic program (e.g. fiber tracts generated in Matlab) and you want to place them in your RAS oriented scene in Slicer. What you do is then to load the MR b0 volume with orientation &amp;quot;From file&amp;quot;, explode its ijkToRAS Transform, load the fiber tracts and place them under the exploded transform in the MRML tree (note that you may have to invert the transform beforehand if what you move under the transform is a polydata, as in this case). You can then (optionally) right-click on the fiber tract nodes and choose &amp;quot;Harden transforms&amp;quot; in order to have the transform applied to the fiber points. At this point you can save them in RAS.&lt;br /&gt;
&lt;br /&gt;
===Tutorials===&lt;br /&gt;
&lt;br /&gt;
NA&lt;br /&gt;
&lt;br /&gt;
===Quick Tour of Features and Use===&lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
|&lt;br /&gt;
* '''Explode Volume Transform Parameters:'''&lt;br /&gt;
** &amp;quot;Keep origin in volume&amp;quot;: Toggle the inclusion of the origin in the extracted transform rather than in the output volume. The default is to include the origin in the transform, which produces an output volume node with the origin in 0,0,0 (same as if the node was saved and then loaded with the orientation set to IJK).&lt;br /&gt;
&lt;br /&gt;
* '''IO:'''&lt;br /&gt;
** ''Input Volume'': the input volume&lt;br /&gt;
** ''Output Volume'': the output volume, the input volume aligned with the XYZ axes (IJK orientation), set as the child of the corresponding IJKToRAS transform.&lt;br /&gt;
|[[Image:PythonExploneVolumeTransformUI.png|thumb|280px|User Interface]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Development ==&lt;br /&gt;
&lt;br /&gt;
===Notes from the Developer(s)===&lt;br /&gt;
&lt;br /&gt;
NA&lt;br /&gt;
&lt;br /&gt;
===Dependencies===&lt;br /&gt;
&lt;br /&gt;
Python&lt;br /&gt;
&lt;br /&gt;
===Tests===&lt;br /&gt;
&lt;br /&gt;
NA&lt;br /&gt;
&lt;br /&gt;
===Known bugs===&lt;br /&gt;
&lt;br /&gt;
Follow this [http://na-mic.org/Mantis/main_page.php link] to the Slicer3 bug tracker. &lt;br /&gt;
&lt;br /&gt;
===Usability issues===&lt;br /&gt;
&lt;br /&gt;
Follow this [http://na-mic.org/Mantis/main_page.php link] to the Slicer3 bug tracker. Please select the '''usability issue category''' when browsing or contributing.&lt;br /&gt;
&lt;br /&gt;
===Source code &amp;amp; documentation===&lt;br /&gt;
&lt;br /&gt;
Links to the module's source code:&lt;br /&gt;
&lt;br /&gt;
Source code:&lt;br /&gt;
*[http://viewvc.slicer.org/viewcvs.cgi/trunk/Modules/Python/ExplodeVolumeTransform.py ExplodeVolumeTransform.py]&lt;br /&gt;
 &lt;br /&gt;
== More Information == &lt;br /&gt;
&lt;br /&gt;
===Acknowledgment===&lt;br /&gt;
NA&lt;br /&gt;
&lt;br /&gt;
===References===&lt;br /&gt;
NA&lt;/div&gt;</summary>
		<author><name>Blezek</name></author>
		
	</entry>
	<entry>
		<id>https://www.slicer.org/w/index.php?title=Modules:PythonExplodeVolumeTransform-Documentation-3.6&amp;diff=14748</id>
		<title>Modules:PythonExplodeVolumeTransform-Documentation-3.6</title>
		<link rel="alternate" type="text/html" href="https://www.slicer.org/w/index.php?title=Modules:PythonExplodeVolumeTransform-Documentation-3.6&amp;diff=14748"/>
		<updated>2010-04-29T02:08:44Z</updated>

		<summary type="html">&lt;p&gt;Blezek: /* Module Name */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Documentation-3.6|Return to Slicer 3.6 Documentation]]&lt;br /&gt;
&lt;br /&gt;
[[Announcements:Slicer3.6#Highlights|Gallery of New Features]]&lt;br /&gt;
&lt;br /&gt;
__NOTOC__&lt;br /&gt;
===Module Name===&lt;br /&gt;
Python Explode Volume Transform&lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
|[[Image:PythonExploneVolumeTransformUI.png|thumb|280px|User Interface]]&lt;br /&gt;
|}&lt;br /&gt;
{|&lt;br /&gt;
|[[Image:ExplodeVolumeTransform1.png|thumb|320px|Figure 1: Volume loaded with RAS orientation (orientation &amp;quot;From file&amp;quot;)]]&lt;br /&gt;
|[[Image:ExplodeVolumeTransform2.png|thumb|320px|Figure 2: Same volume loaded with IJK orientation]]&lt;br /&gt;
|}&lt;br /&gt;
{|&lt;br /&gt;
|[[Image:ExplodeVolumeTransform3.png|thumb|320px|Figure 3: Exploded RAS volume: ijkToRAS transform + IJK volume (see MRML tree widget on the left)]]&lt;br /&gt;
|[[Image:ExplodeVolumeTransform4.png|thumb|320px|Figure 4: The volume loaded with IJK orientation (from Figure 2) moved under the output transform assumes RAS orientation]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== General Information ==&lt;br /&gt;
===Module Type &amp;amp; Category===&lt;br /&gt;
&lt;br /&gt;
Type: CLI&lt;br /&gt;
&lt;br /&gt;
Category: Converters&lt;br /&gt;
&lt;br /&gt;
===Authors, Collaborators &amp;amp; Contact===&lt;br /&gt;
* Luca Antiga: Orobix Srl &amp;amp; Mario Negri Institute&lt;br /&gt;
* Daniel Blezek: Mayo Clinic&lt;br /&gt;
* Contact: Luca Antiga, luca.antiga@orobix.com&lt;br /&gt;
&lt;br /&gt;
===Module Description===&lt;br /&gt;
This Python module takes a volume in input, extracts its IJKToRAS transform by matrix manipulation, where IJK is the local (VTK-compatible) coordinate system, and generates an IJK-oriented volume in the MRML scene as a child of a IJKToRAS transform node.&lt;br /&gt;
&lt;br /&gt;
== Usage ==&lt;br /&gt;
&lt;br /&gt;
===Use Cases, Examples===&lt;br /&gt;
&lt;br /&gt;
* The module is appropriate when a CLI module can only handle non-oriented images (i.e. images oriented as the XYZ axes), like pure-VTK modules.&lt;br /&gt;
* The typical use is as follows: run a volume through this filter, use the output volume as input for the non-orientation-aware CLI module and place the output of this latter module under the IJKToRAS transform generated by the present module by using the MRML tree widget.&lt;br /&gt;
* Use case: you have data generated from a RAS-agnostic program (e.g. fiber tracts generated in Matlab) and you want to place them in your RAS oriented scene in Slicer. What you do is then to load the MR b0 volume with orientation &amp;quot;From file&amp;quot;, explode its ijkToRAS Transform, load the fiber tracts and place them under the exploded transform in the MRML tree (note that you may have to invert the transform beforehand if what you move under the transform is a polydata, as in this case). You can then (optionally) right-click on the fiber tract nodes and choose &amp;quot;Harden transforms&amp;quot; in order to have the transform applied to the fiber points. At this point you can save them in RAS.&lt;br /&gt;
&lt;br /&gt;
===Tutorials===&lt;br /&gt;
&lt;br /&gt;
NA&lt;br /&gt;
&lt;br /&gt;
===Quick Tour of Features and Use===&lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
|&lt;br /&gt;
* '''Explode Volume Transform Parameters:'''&lt;br /&gt;
** &amp;quot;Keep origin in volume&amp;quot;: Toggle the inclusion of the origin in the extracted transform rather than in the output volume. The default is to include the origin in the transform, which produces an output volume node with the origin in 0,0,0 (same as if the node was saved and then loaded with the orientation set to IJK).&lt;br /&gt;
&lt;br /&gt;
* '''IO:'''&lt;br /&gt;
** ''Input Volume'': the input volume&lt;br /&gt;
** ''Output Volume'': the output volume, the input volume aligned with the XYZ axes (IJK orientation), set as the child of the corresponding IJKToRAS transform.&lt;br /&gt;
|[[Image:screenshotBlankNotOptional.png|thumb|280px|User Interface]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Development ==&lt;br /&gt;
&lt;br /&gt;
===Notes from the Developer(s)===&lt;br /&gt;
&lt;br /&gt;
NA&lt;br /&gt;
&lt;br /&gt;
===Dependencies===&lt;br /&gt;
&lt;br /&gt;
Python&lt;br /&gt;
&lt;br /&gt;
===Tests===&lt;br /&gt;
&lt;br /&gt;
NA&lt;br /&gt;
&lt;br /&gt;
===Known bugs===&lt;br /&gt;
&lt;br /&gt;
Follow this [http://na-mic.org/Mantis/main_page.php link] to the Slicer3 bug tracker. &lt;br /&gt;
&lt;br /&gt;
===Usability issues===&lt;br /&gt;
&lt;br /&gt;
Follow this [http://na-mic.org/Mantis/main_page.php link] to the Slicer3 bug tracker. Please select the '''usability issue category''' when browsing or contributing.&lt;br /&gt;
&lt;br /&gt;
===Source code &amp;amp; documentation===&lt;br /&gt;
&lt;br /&gt;
Links to the module's source code:&lt;br /&gt;
&lt;br /&gt;
Source code:&lt;br /&gt;
*[http://viewvc.slicer.org/viewcvs.cgi/trunk/Modules/Python/ExplodeVolumeTransform.py ExplodeVolumeTransform.py]&lt;br /&gt;
 &lt;br /&gt;
== More Information == &lt;br /&gt;
&lt;br /&gt;
===Acknowledgment===&lt;br /&gt;
NA&lt;br /&gt;
&lt;br /&gt;
===References===&lt;br /&gt;
NA&lt;/div&gt;</summary>
		<author><name>Blezek</name></author>
		
	</entry>
	<entry>
		<id>https://www.slicer.org/w/index.php?title=File:PythonExploneVolumeTransformUI.png&amp;diff=14747</id>
		<title>File:PythonExploneVolumeTransformUI.png</title>
		<link rel="alternate" type="text/html" href="https://www.slicer.org/w/index.php?title=File:PythonExploneVolumeTransformUI.png&amp;diff=14747"/>
		<updated>2010-04-29T02:08:28Z</updated>

		<summary type="html">&lt;p&gt;Blezek: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Blezek</name></author>
		
	</entry>
	<entry>
		<id>https://www.slicer.org/w/index.php?title=Modules:PythonSurfaceToolbox-Documentation-3.6&amp;diff=14746</id>
		<title>Modules:PythonSurfaceToolbox-Documentation-3.6</title>
		<link rel="alternate" type="text/html" href="https://www.slicer.org/w/index.php?title=Modules:PythonSurfaceToolbox-Documentation-3.6&amp;diff=14746"/>
		<updated>2010-04-29T02:05:30Z</updated>

		<summary type="html">&lt;p&gt;Blezek: /* Quick Tour of Features and Use */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Documentation-3.6|Return to Slicer 3.6 Documentation]]&lt;br /&gt;
&lt;br /&gt;
[[Announcements:Slicer3.6#Highlights|Gallery of New Features]]&lt;br /&gt;
&lt;br /&gt;
__NOTOC__&lt;br /&gt;
===Module Name===&lt;br /&gt;
Python Surface Toolbox&lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
|[[Image:PythonSurfaceToolboxUI.png|thumb|280px|User Interface]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== General Information ==&lt;br /&gt;
===Module Type &amp;amp; Category===&lt;br /&gt;
&lt;br /&gt;
Type: CLI&lt;br /&gt;
&lt;br /&gt;
Category: Surface Models&lt;br /&gt;
&lt;br /&gt;
===Authors, Collaborators &amp;amp; Contact===&lt;br /&gt;
* Luca Antiga: Orobix Srl &amp;amp; Mario Negri Institute&lt;br /&gt;
* Daniel Blezek: Mayo Clinic&lt;br /&gt;
* Contact: Luca Antiga, luca.antiga@orobix.com&lt;br /&gt;
&lt;br /&gt;
===Module Description===&lt;br /&gt;
This Python module provides several useful surface processing algorithms, namely decimation, smoothing, normal computation, surface cleaning.&lt;br /&gt;
&lt;br /&gt;
== Usage ==&lt;br /&gt;
&lt;br /&gt;
===Use Cases, Examples===&lt;br /&gt;
&lt;br /&gt;
* The module is appropriate when a surface has been extracted (e.g. with the Modelmaker module) but its appearance has to be improved.&lt;br /&gt;
&lt;br /&gt;
===Tutorials===&lt;br /&gt;
&lt;br /&gt;
NA&lt;br /&gt;
&lt;br /&gt;
===Quick Tour of Features and Use===&lt;br /&gt;
&lt;br /&gt;
A list panels in the interface, their features, what they mean, and how to use them. For instance:&lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
|&lt;br /&gt;
* '''Surface Decimation:'''&lt;br /&gt;
** ''Enabled'': enable topology-preserving surface decimation.&lt;br /&gt;
** ''Target reduction'': target percentage reduction in number of triangles (this target reduction may not be achieved depending on the constraints on the topology).&lt;br /&gt;
** ''Boundary vertex deletion'': allow deletion of points located on the boundary of the surface.&lt;br /&gt;
* '''Surface Smoothing:'''&lt;br /&gt;
** ''Enabled'': enable surface smoothing.&lt;br /&gt;
** ''Smoothing method'': choose between Laplace or Taubin surface smoothing algorithms (while Taubin is a non-shrinking filter, Laplace will tend to shrink the surface under the effect of curvature).&lt;br /&gt;
** ''Boundary smoothing'': allow smoothing of points located on the boundary of the surface.&lt;br /&gt;
** ''Laplace number of iterations'': number of iterations set when the Laplace algorithm is selected.&lt;br /&gt;
** ''Laplace relaxation factor'': the factor by which a point moves towards the barycenter of its neighbors in the Laplace algorithm.&lt;br /&gt;
** ''Taubin number of iterations'': number of iterations set when the Taubin algorithm is selected.&lt;br /&gt;
** ''Taubin passband'': spatial frequency cutoff for the Taubin algorithm.&lt;br /&gt;
* '''Surface Normals:'''&lt;br /&gt;
** ''Enabled'': enable computation of consistently-oriented surface normals (advised after smoothing - smoothing algorithms only move points and do not update normals accordingly, so the surface might still look non-smooth after smoothing when Gouraud shading is used).&lt;br /&gt;
** ''Flip normals'': toggle direction of normals - the algorithm will do its best to orient the normals consistently &amp;quot;outwards&amp;quot; a surface, if the surface is orientable. This switch will make normals point &amp;quot;inwards&amp;quot;&lt;br /&gt;
** ''Splitting'': toggle splitting of surface when angle between the normals of two neighboring triangles is above the Feature angle. This improves the shading appearance of sharp edges but produces topological holes in the surface.&lt;br /&gt;
** ''Feature angle'': angle (in degrees) between two neighboring triangles beyond which the edge between the triangles is split. &lt;br /&gt;
* '''Surface Cleaner:'''&lt;br /&gt;
** ''Enabled'': enable cleaning (merging of coincident points, elimination of unused points, treatment of degenerate cells) of the surface.&lt;br /&gt;
* '''IO:'''&lt;br /&gt;
** ''Input Surface'': the input surface&lt;br /&gt;
** ''Output Surface'': the output surface, i.e. the input surface filtered through all the &amp;quot;Enabled&amp;quot; filters.&lt;br /&gt;
|[[Image:PythonSurfaceToolboxUI.png|thumb|280px|User Interface]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Development ==&lt;br /&gt;
&lt;br /&gt;
===Notes from the Developer(s)===&lt;br /&gt;
&lt;br /&gt;
The module internally uses the following VTK filters:&lt;br /&gt;
&lt;br /&gt;
[http://www.vtk.org/doc/nightly/html/classvtkDecimatePro.html vtkDecimatePro]&lt;br /&gt;
&lt;br /&gt;
[http://www.vtk.org/doc/nightly/html/classvtkSmoothPolyDataFilter.html vtkSmoothPolyDataFilter]&lt;br /&gt;
&lt;br /&gt;
[http://www.vtk.org/doc/nightly/html/classvtkWindowedSincPolyDataFilter.html vtkWindowedSincPolyDataFilter]&lt;br /&gt;
&lt;br /&gt;
[http://www.vtk.org/doc/nightly/html/classvtkPolyDataNormals.html vtkPolyDataNormals]&lt;br /&gt;
&lt;br /&gt;
[http://www.vtk.org/doc/nightly/html/classvtkCleanPolyData.html vtkCleanPolyData]&lt;br /&gt;
&lt;br /&gt;
===Dependencies===&lt;br /&gt;
&lt;br /&gt;
Python&lt;br /&gt;
&lt;br /&gt;
===Tests===&lt;br /&gt;
&lt;br /&gt;
NA&lt;br /&gt;
&lt;br /&gt;
===Known bugs===&lt;br /&gt;
&lt;br /&gt;
Follow this [http://na-mic.org/Mantis/main_page.php link] to the Slicer3 bug tracker. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Usability issues===&lt;br /&gt;
&lt;br /&gt;
Follow this [http://na-mic.org/Mantis/main_page.php link] to the Slicer3 bug tracker. Please select the '''usability issue category''' when browsing or contributing.&lt;br /&gt;
&lt;br /&gt;
===Source code &amp;amp; documentation===&lt;br /&gt;
&lt;br /&gt;
Links to the module's source code:&lt;br /&gt;
&lt;br /&gt;
Source code:&lt;br /&gt;
*[http://viewvc.slicer.org/viewcvs.cgi/trunk/Modules/Python/SurfaceToolbox.py SurfaceToolbox.py]  &lt;br /&gt;
&lt;br /&gt;
== More Information == &lt;br /&gt;
&lt;br /&gt;
===Acknowledgment===&lt;br /&gt;
NA&lt;br /&gt;
&lt;br /&gt;
===References===&lt;br /&gt;
NA&lt;/div&gt;</summary>
		<author><name>Blezek</name></author>
		
	</entry>
	<entry>
		<id>https://www.slicer.org/w/index.php?title=Modules:PythonSurfaceToolbox-Documentation-3.6&amp;diff=14745</id>
		<title>Modules:PythonSurfaceToolbox-Documentation-3.6</title>
		<link rel="alternate" type="text/html" href="https://www.slicer.org/w/index.php?title=Modules:PythonSurfaceToolbox-Documentation-3.6&amp;diff=14745"/>
		<updated>2010-04-29T02:05:12Z</updated>

		<summary type="html">&lt;p&gt;Blezek: /* Module Name */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Documentation-3.6|Return to Slicer 3.6 Documentation]]&lt;br /&gt;
&lt;br /&gt;
[[Announcements:Slicer3.6#Highlights|Gallery of New Features]]&lt;br /&gt;
&lt;br /&gt;
__NOTOC__&lt;br /&gt;
===Module Name===&lt;br /&gt;
Python Surface Toolbox&lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
|[[Image:PythonSurfaceToolboxUI.png|thumb|280px|User Interface]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== General Information ==&lt;br /&gt;
===Module Type &amp;amp; Category===&lt;br /&gt;
&lt;br /&gt;
Type: CLI&lt;br /&gt;
&lt;br /&gt;
Category: Surface Models&lt;br /&gt;
&lt;br /&gt;
===Authors, Collaborators &amp;amp; Contact===&lt;br /&gt;
* Luca Antiga: Orobix Srl &amp;amp; Mario Negri Institute&lt;br /&gt;
* Daniel Blezek: Mayo Clinic&lt;br /&gt;
* Contact: Luca Antiga, luca.antiga@orobix.com&lt;br /&gt;
&lt;br /&gt;
===Module Description===&lt;br /&gt;
This Python module provides several useful surface processing algorithms, namely decimation, smoothing, normal computation, surface cleaning.&lt;br /&gt;
&lt;br /&gt;
== Usage ==&lt;br /&gt;
&lt;br /&gt;
===Use Cases, Examples===&lt;br /&gt;
&lt;br /&gt;
* The module is appropriate when a surface has been extracted (e.g. with the Modelmaker module) but its appearance has to be improved.&lt;br /&gt;
&lt;br /&gt;
===Tutorials===&lt;br /&gt;
&lt;br /&gt;
NA&lt;br /&gt;
&lt;br /&gt;
===Quick Tour of Features and Use===&lt;br /&gt;
&lt;br /&gt;
A list panels in the interface, their features, what they mean, and how to use them. For instance:&lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
|&lt;br /&gt;
* '''Surface Decimation:'''&lt;br /&gt;
** ''Enabled'': enable topology-preserving surface decimation.&lt;br /&gt;
** ''Target reduction'': target percentage reduction in number of triangles (this target reduction may not be achieved depending on the constraints on the topology).&lt;br /&gt;
** ''Boundary vertex deletion'': allow deletion of points located on the boundary of the surface.&lt;br /&gt;
* '''Surface Smoothing:'''&lt;br /&gt;
** ''Enabled'': enable surface smoothing.&lt;br /&gt;
** ''Smoothing method'': choose between Laplace or Taubin surface smoothing algorithms (while Taubin is a non-shrinking filter, Laplace will tend to shrink the surface under the effect of curvature).&lt;br /&gt;
** ''Boundary smoothing'': allow smoothing of points located on the boundary of the surface.&lt;br /&gt;
** ''Laplace number of iterations'': number of iterations set when the Laplace algorithm is selected.&lt;br /&gt;
** ''Laplace relaxation factor'': the factor by which a point moves towards the barycenter of its neighbors in the Laplace algorithm.&lt;br /&gt;
** ''Taubin number of iterations'': number of iterations set when the Taubin algorithm is selected.&lt;br /&gt;
** ''Taubin passband'': spatial frequency cutoff for the Taubin algorithm.&lt;br /&gt;
* '''Surface Normals:'''&lt;br /&gt;
** ''Enabled'': enable computation of consistently-oriented surface normals (advised after smoothing - smoothing algorithms only move points and do not update normals accordingly, so the surface might still look non-smooth after smoothing when Gouraud shading is used).&lt;br /&gt;
** ''Flip normals'': toggle direction of normals - the algorithm will do its best to orient the normals consistently &amp;quot;outwards&amp;quot; a surface, if the surface is orientable. This switch will make normals point &amp;quot;inwards&amp;quot;&lt;br /&gt;
** ''Splitting'': toggle splitting of surface when angle between the normals of two neighboring triangles is above the Feature angle. This improves the shading appearance of sharp edges but produces topological holes in the surface.&lt;br /&gt;
** ''Feature angle'': angle (in degrees) between two neighboring triangles beyond which the edge between the triangles is split. &lt;br /&gt;
* '''Surface Cleaner:'''&lt;br /&gt;
** ''Enabled'': enable cleaning (merging of coincident points, elimination of unused points, treatment of degenerate cells) of the surface.&lt;br /&gt;
* '''IO:'''&lt;br /&gt;
** ''Input Surface'': the input surface&lt;br /&gt;
** ''Output Surface'': the output surface, i.e. the input surface filtered through all the &amp;quot;Enabled&amp;quot; filters.&lt;br /&gt;
|[[Image:screenshotBlankNotOptional.png|thumb|280px|User Interface]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Development ==&lt;br /&gt;
&lt;br /&gt;
===Notes from the Developer(s)===&lt;br /&gt;
&lt;br /&gt;
The module internally uses the following VTK filters:&lt;br /&gt;
&lt;br /&gt;
[http://www.vtk.org/doc/nightly/html/classvtkDecimatePro.html vtkDecimatePro]&lt;br /&gt;
&lt;br /&gt;
[http://www.vtk.org/doc/nightly/html/classvtkSmoothPolyDataFilter.html vtkSmoothPolyDataFilter]&lt;br /&gt;
&lt;br /&gt;
[http://www.vtk.org/doc/nightly/html/classvtkWindowedSincPolyDataFilter.html vtkWindowedSincPolyDataFilter]&lt;br /&gt;
&lt;br /&gt;
[http://www.vtk.org/doc/nightly/html/classvtkPolyDataNormals.html vtkPolyDataNormals]&lt;br /&gt;
&lt;br /&gt;
[http://www.vtk.org/doc/nightly/html/classvtkCleanPolyData.html vtkCleanPolyData]&lt;br /&gt;
&lt;br /&gt;
===Dependencies===&lt;br /&gt;
&lt;br /&gt;
Python&lt;br /&gt;
&lt;br /&gt;
===Tests===&lt;br /&gt;
&lt;br /&gt;
NA&lt;br /&gt;
&lt;br /&gt;
===Known bugs===&lt;br /&gt;
&lt;br /&gt;
Follow this [http://na-mic.org/Mantis/main_page.php link] to the Slicer3 bug tracker. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Usability issues===&lt;br /&gt;
&lt;br /&gt;
Follow this [http://na-mic.org/Mantis/main_page.php link] to the Slicer3 bug tracker. Please select the '''usability issue category''' when browsing or contributing.&lt;br /&gt;
&lt;br /&gt;
===Source code &amp;amp; documentation===&lt;br /&gt;
&lt;br /&gt;
Links to the module's source code:&lt;br /&gt;
&lt;br /&gt;
Source code:&lt;br /&gt;
*[http://viewvc.slicer.org/viewcvs.cgi/trunk/Modules/Python/SurfaceToolbox.py SurfaceToolbox.py]  &lt;br /&gt;
&lt;br /&gt;
== More Information == &lt;br /&gt;
&lt;br /&gt;
===Acknowledgment===&lt;br /&gt;
NA&lt;br /&gt;
&lt;br /&gt;
===References===&lt;br /&gt;
NA&lt;/div&gt;</summary>
		<author><name>Blezek</name></author>
		
	</entry>
	<entry>
		<id>https://www.slicer.org/w/index.php?title=File:PythonSurfaceToolboxUI.png&amp;diff=14744</id>
		<title>File:PythonSurfaceToolboxUI.png</title>
		<link rel="alternate" type="text/html" href="https://www.slicer.org/w/index.php?title=File:PythonSurfaceToolboxUI.png&amp;diff=14744"/>
		<updated>2010-04-29T02:04:59Z</updated>

		<summary type="html">&lt;p&gt;Blezek: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Blezek</name></author>
		
	</entry>
	<entry>
		<id>https://www.slicer.org/w/index.php?title=Modules:PythonSurfaceICPRegistration-Documentation-3.6&amp;diff=14743</id>
		<title>Modules:PythonSurfaceICPRegistration-Documentation-3.6</title>
		<link rel="alternate" type="text/html" href="https://www.slicer.org/w/index.php?title=Modules:PythonSurfaceICPRegistration-Documentation-3.6&amp;diff=14743"/>
		<updated>2010-04-29T02:01:34Z</updated>

		<summary type="html">&lt;p&gt;Blezek: /* Quick Tour of Features and Use */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Documentation-3.6|Return to Slicer 3.6 Documentation]]&lt;br /&gt;
&lt;br /&gt;
[[Announcements:Slicer3.6#Highlights|Gallery of New Features]]&lt;br /&gt;
&lt;br /&gt;
__NOTOC__&lt;br /&gt;
===Module Name===&lt;br /&gt;
Python ICP Registration&lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
|[[Image:PythonSurfaceICPRegistrationUI.png|thumb|280px|User Interface]]&lt;br /&gt;
|[[Image:PythonICP1.png|thumb|280px|Figure 1: Full model of aneurysm and (unregistered) aneurysm dome]]&lt;br /&gt;
|[[Image:PythonICP2.png|thumb|280px|Figure 2: Aneurysm dome registered on the full model]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== General Information ==&lt;br /&gt;
===Module Type &amp;amp; Category===&lt;br /&gt;
&lt;br /&gt;
Type: CLI&lt;br /&gt;
&lt;br /&gt;
Category: Surface Models&lt;br /&gt;
&lt;br /&gt;
===Authors, Collaborators &amp;amp; Contact===&lt;br /&gt;
* Luca Antiga: Orobix Srl &amp;amp; Mario Negri Institute&lt;br /&gt;
* Daniel Blezek: Mayo Clinic&lt;br /&gt;
* Contact: Luca Antiga, luca.antiga@orobix.com&lt;br /&gt;
&lt;br /&gt;
===Module Description===&lt;br /&gt;
This Python module registers an input surface to a target surface using the Iterative Closest Point algorithm using rigid, similarity and affine transforms.&lt;br /&gt;
&lt;br /&gt;
== Usage ==&lt;br /&gt;
&lt;br /&gt;
===Use Cases, Examples===&lt;br /&gt;
&lt;br /&gt;
* The module is appropriate when there is need for aligning surfaces, e.g. for comparison of surface features.&lt;br /&gt;
* Possible improvements are the generation of the registration transform in output (TO DO).&lt;br /&gt;
&lt;br /&gt;
===Tutorials===&lt;br /&gt;
&lt;br /&gt;
NA&lt;br /&gt;
&lt;br /&gt;
===Quick Tour of Features and Use===&lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
|&lt;br /&gt;
* '''Surface ICP Registration Parameters:'''&lt;br /&gt;
** ''Landmark transform mode'': choose between RigidBody, Similarity or Affine transforms for registration of the surfaces. &lt;br /&gt;
** ''Mean distance mode'': choose between square root of the average of the sum of squares of the closest point distances (RMS) or mean of the sum of absolute values of the closest point distances (Absolute)&lt;br /&gt;
** ''Maximum number of iterations'': number of iterations beyond which the ICP algorithm won't proceed even if the maximum mean distance is above threshold. &lt;br /&gt;
** ''Maximum number of landmarks'': maximum number of surface landmarks used to minimize distance between surfaces&lt;br /&gt;
** ''Start by matching centroids'': initialize the transform by translating the input surface so that its centroid coincides the centroid of the target surface. &lt;br /&gt;
** ''Check mean distance'': force checking distance between every two iterations (slower but more accurate)&lt;br /&gt;
** ''Maximum mean distance'': distance threshold, the algorithm stops when the mean distance between the surfaces is below this threshold &lt;br /&gt;
* '''IO:'''&lt;br /&gt;
** ''Initial Transform'': the (optional) initial transform that is applied to the input surface prior to registration&lt;br /&gt;
** ''Input Surface'': the input (moving) surface&lt;br /&gt;
** ''Target Surface'': the target (not moving) surface&lt;br /&gt;
** ''Output Surface'': the output surface, i.e. the input surface registered on the target surface. Optional.&lt;br /&gt;
** ''Output Transform'': the computed ICP transform MRML node. Optional (if both Output Surface and Output Transform are specified, the output surface is placed as a child of the output transform).&lt;br /&gt;
|[[Image:PythonSurfaceICPRegistrationUI.png|thumb|280px|User Interface]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Development ==&lt;br /&gt;
&lt;br /&gt;
===Notes from the Developer(s)===&lt;br /&gt;
&lt;br /&gt;
The module internally uses [http://www.vtk.org/doc/nightly/html/classvtkIterativeClosestPointTransform.html vtkIterativeClosestPointTransform].&lt;br /&gt;
&lt;br /&gt;
===Dependencies===&lt;br /&gt;
&lt;br /&gt;
Python&lt;br /&gt;
&lt;br /&gt;
===Tests===&lt;br /&gt;
&lt;br /&gt;
NA&lt;br /&gt;
&lt;br /&gt;
===Known bugs===&lt;br /&gt;
&lt;br /&gt;
Follow this [http://na-mic.org/Mantis/main_page.php link] to the Slicer3 bug tracker. &lt;br /&gt;
&lt;br /&gt;
===Usability issues===&lt;br /&gt;
&lt;br /&gt;
Follow this [http://na-mic.org/Mantis/main_page.php link] to the Slicer3 bug tracker. Please select the '''usability issue category''' when browsing or contributing.&lt;br /&gt;
&lt;br /&gt;
===Source code &amp;amp; documentation===&lt;br /&gt;
&lt;br /&gt;
Links to the module's source code:&lt;br /&gt;
&lt;br /&gt;
Source code:&lt;br /&gt;
*[http://viewvc.slicer.org/viewcvs.cgi/trunk/Modules/Python/SurfaceICPRegistration.py SurfaceICPRegistration.py] &lt;br /&gt;
 &lt;br /&gt;
== More Information == &lt;br /&gt;
&lt;br /&gt;
===Acknowledgment===&lt;br /&gt;
&lt;br /&gt;
NA&lt;br /&gt;
&lt;br /&gt;
===References===&lt;br /&gt;
&lt;br /&gt;
NA&lt;/div&gt;</summary>
		<author><name>Blezek</name></author>
		
	</entry>
	<entry>
		<id>https://www.slicer.org/w/index.php?title=Modules:PythonSurfaceICPRegistration-Documentation-3.6&amp;diff=14742</id>
		<title>Modules:PythonSurfaceICPRegistration-Documentation-3.6</title>
		<link rel="alternate" type="text/html" href="https://www.slicer.org/w/index.php?title=Modules:PythonSurfaceICPRegistration-Documentation-3.6&amp;diff=14742"/>
		<updated>2010-04-29T02:01:14Z</updated>

		<summary type="html">&lt;p&gt;Blezek: /* Module Name */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Documentation-3.6|Return to Slicer 3.6 Documentation]]&lt;br /&gt;
&lt;br /&gt;
[[Announcements:Slicer3.6#Highlights|Gallery of New Features]]&lt;br /&gt;
&lt;br /&gt;
__NOTOC__&lt;br /&gt;
===Module Name===&lt;br /&gt;
Python ICP Registration&lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
|[[Image:PythonSurfaceICPRegistrationUI.png|thumb|280px|User Interface]]&lt;br /&gt;
|[[Image:PythonICP1.png|thumb|280px|Figure 1: Full model of aneurysm and (unregistered) aneurysm dome]]&lt;br /&gt;
|[[Image:PythonICP2.png|thumb|280px|Figure 2: Aneurysm dome registered on the full model]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== General Information ==&lt;br /&gt;
===Module Type &amp;amp; Category===&lt;br /&gt;
&lt;br /&gt;
Type: CLI&lt;br /&gt;
&lt;br /&gt;
Category: Surface Models&lt;br /&gt;
&lt;br /&gt;
===Authors, Collaborators &amp;amp; Contact===&lt;br /&gt;
* Luca Antiga: Orobix Srl &amp;amp; Mario Negri Institute&lt;br /&gt;
* Daniel Blezek: Mayo Clinic&lt;br /&gt;
* Contact: Luca Antiga, luca.antiga@orobix.com&lt;br /&gt;
&lt;br /&gt;
===Module Description===&lt;br /&gt;
This Python module registers an input surface to a target surface using the Iterative Closest Point algorithm using rigid, similarity and affine transforms.&lt;br /&gt;
&lt;br /&gt;
== Usage ==&lt;br /&gt;
&lt;br /&gt;
===Use Cases, Examples===&lt;br /&gt;
&lt;br /&gt;
* The module is appropriate when there is need for aligning surfaces, e.g. for comparison of surface features.&lt;br /&gt;
* Possible improvements are the generation of the registration transform in output (TO DO).&lt;br /&gt;
&lt;br /&gt;
===Tutorials===&lt;br /&gt;
&lt;br /&gt;
NA&lt;br /&gt;
&lt;br /&gt;
===Quick Tour of Features and Use===&lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
|&lt;br /&gt;
* '''Surface ICP Registration Parameters:'''&lt;br /&gt;
** ''Landmark transform mode'': choose between RigidBody, Similarity or Affine transforms for registration of the surfaces. &lt;br /&gt;
** ''Mean distance mode'': choose between square root of the average of the sum of squares of the closest point distances (RMS) or mean of the sum of absolute values of the closest point distances (Absolute)&lt;br /&gt;
** ''Maximum number of iterations'': number of iterations beyond which the ICP algorithm won't proceed even if the maximum mean distance is above threshold. &lt;br /&gt;
** ''Maximum number of landmarks'': maximum number of surface landmarks used to minimize distance between surfaces&lt;br /&gt;
** ''Start by matching centroids'': initialize the transform by translating the input surface so that its centroid coincides the centroid of the target surface. &lt;br /&gt;
** ''Check mean distance'': force checking distance between every two iterations (slower but more accurate)&lt;br /&gt;
** ''Maximum mean distance'': distance threshold, the algorithm stops when the mean distance between the surfaces is below this threshold &lt;br /&gt;
* '''IO:'''&lt;br /&gt;
** ''Initial Transform'': the (optional) initial transform that is applied to the input surface prior to registration&lt;br /&gt;
** ''Input Surface'': the input (moving) surface&lt;br /&gt;
** ''Target Surface'': the target (not moving) surface&lt;br /&gt;
** ''Output Surface'': the output surface, i.e. the input surface registered on the target surface. Optional.&lt;br /&gt;
** ''Output Transform'': the computed ICP transform MRML node. Optional (if both Output Surface and Output Transform are specified, the output surface is placed as a child of the output transform).&lt;br /&gt;
|[[Image:screenshotBlankNotOptional.png|thumb|280px|User Interface]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Development ==&lt;br /&gt;
&lt;br /&gt;
===Notes from the Developer(s)===&lt;br /&gt;
&lt;br /&gt;
The module internally uses [http://www.vtk.org/doc/nightly/html/classvtkIterativeClosestPointTransform.html vtkIterativeClosestPointTransform].&lt;br /&gt;
&lt;br /&gt;
===Dependencies===&lt;br /&gt;
&lt;br /&gt;
Python&lt;br /&gt;
&lt;br /&gt;
===Tests===&lt;br /&gt;
&lt;br /&gt;
NA&lt;br /&gt;
&lt;br /&gt;
===Known bugs===&lt;br /&gt;
&lt;br /&gt;
Follow this [http://na-mic.org/Mantis/main_page.php link] to the Slicer3 bug tracker. &lt;br /&gt;
&lt;br /&gt;
===Usability issues===&lt;br /&gt;
&lt;br /&gt;
Follow this [http://na-mic.org/Mantis/main_page.php link] to the Slicer3 bug tracker. Please select the '''usability issue category''' when browsing or contributing.&lt;br /&gt;
&lt;br /&gt;
===Source code &amp;amp; documentation===&lt;br /&gt;
&lt;br /&gt;
Links to the module's source code:&lt;br /&gt;
&lt;br /&gt;
Source code:&lt;br /&gt;
*[http://viewvc.slicer.org/viewcvs.cgi/trunk/Modules/Python/SurfaceICPRegistration.py SurfaceICPRegistration.py] &lt;br /&gt;
 &lt;br /&gt;
== More Information == &lt;br /&gt;
&lt;br /&gt;
===Acknowledgment===&lt;br /&gt;
&lt;br /&gt;
NA&lt;br /&gt;
&lt;br /&gt;
===References===&lt;br /&gt;
&lt;br /&gt;
NA&lt;/div&gt;</summary>
		<author><name>Blezek</name></author>
		
	</entry>
	<entry>
		<id>https://www.slicer.org/w/index.php?title=File:PythonSurfaceICPRegistrationUI.png&amp;diff=14741</id>
		<title>File:PythonSurfaceICPRegistrationUI.png</title>
		<link rel="alternate" type="text/html" href="https://www.slicer.org/w/index.php?title=File:PythonSurfaceICPRegistrationUI.png&amp;diff=14741"/>
		<updated>2010-04-29T02:00:59Z</updated>

		<summary type="html">&lt;p&gt;Blezek: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Blezek</name></author>
		
	</entry>
	<entry>
		<id>https://www.slicer.org/w/index.php?title=Modules:PythonSurfaceConnectivity-Documentation-3.6&amp;diff=14740</id>
		<title>Modules:PythonSurfaceConnectivity-Documentation-3.6</title>
		<link rel="alternate" type="text/html" href="https://www.slicer.org/w/index.php?title=Modules:PythonSurfaceConnectivity-Documentation-3.6&amp;diff=14740"/>
		<updated>2010-04-29T01:38:06Z</updated>

		<summary type="html">&lt;p&gt;Blezek: /* Quick Tour of Features and Use */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Documentation-3.6|Return to Slicer 3.6 Documentation]]&lt;br /&gt;
&lt;br /&gt;
[[Announcements:Slicer3.6#Highlights|Gallery of New Features]]&lt;br /&gt;
&lt;br /&gt;
__NOTOC__&lt;br /&gt;
===Module Name===&lt;br /&gt;
Python Surface Connectivity&lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
|[[Image:PythonSurfaceConnectivityUI.png|thumb|280px|User Interface]]&lt;br /&gt;
|[[Image:PythonSurfaceConnectivity1.png|thumb|280px|Figure 1: Clipped model of ICA aneurysm]]&lt;br /&gt;
|[[Image:PythonSurfaceConnectivity2.png|thumb|280px|Figure 2: Connnected region closest to user-specified seed is extracted]]&lt;br /&gt;
|[[Image:PythonSurfaceConnectivity3.png|thumb|280px|Figure 2: All connected regions are extracted and one seed is generated for every region]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== General Information ==&lt;br /&gt;
===Module Type &amp;amp; Category===&lt;br /&gt;
&lt;br /&gt;
Type: CLI&lt;br /&gt;
&lt;br /&gt;
Category: Surface Models&lt;br /&gt;
&lt;br /&gt;
===Authors, Collaborators &amp;amp; Contact===&lt;br /&gt;
* Luca Antiga: Orobix Srl, Mario Negri Institute&lt;br /&gt;
* Daniel Blezek: Mayo Clinic&lt;br /&gt;
* Contact: Luca Antiga, luca.antiga@orobix.com&lt;br /&gt;
&lt;br /&gt;
===Module Description===&lt;br /&gt;
This Python module takes in input a surface and labels it according to surface connectivity. The module either labels the surface with a different RegionId for each connected region, or it extracts the connected region closest to an input fiducial. Optionally, the module produces a list of fiducials positioned on each connected region and labeled with its RegionId.&lt;br /&gt;
&lt;br /&gt;
== Usage ==&lt;br /&gt;
&lt;br /&gt;
===Use Cases, Examples===&lt;br /&gt;
&lt;br /&gt;
* The module is appropriate when there is need of extracting different disconnected components of a model or label them.&lt;br /&gt;
* For developers: the module is a good example on how Python CLI modules can access and modify the MRML scene (unlike executable and shared library CLI modules)&lt;br /&gt;
&lt;br /&gt;
===Tutorials===&lt;br /&gt;
&lt;br /&gt;
NA&lt;br /&gt;
&lt;br /&gt;
===Quick Tour of Features and Use===&lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
|&lt;br /&gt;
* '''Surface Connectivity Parameters:'''&lt;br /&gt;
** ''Connectivity mode'': choose between assigning a RegionId to each connected region (AllRegions) or extract the connected region closest to a seed fiducial (ClosestToSeed). &lt;br /&gt;
** ''Enable output fiducials'': enable output of a fiducial list containing one fiducial per connected region labeled with the corresponding RegionId&lt;br /&gt;
* '''IO:'''&lt;br /&gt;
** ''Input Surface'': the input surface&lt;br /&gt;
** ''Output Surface'': the labeled surface (for AllRegions mode) or the labeled portion of the surface closest to the seed (for ClosestToSeed)&lt;br /&gt;
|[[Image:PythonSurfaceConnectivityUI.png|thumb|280px|User Interface]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Development ==&lt;br /&gt;
&lt;br /&gt;
===Notes from the Developer(s)===&lt;br /&gt;
&lt;br /&gt;
The module internally uses [http://www.vtk.org/doc/nightly/html/classvtkPolyDataConnectivityFilter.html vtkPolyDataConnectivityFilter].&lt;br /&gt;
&lt;br /&gt;
===Dependencies===&lt;br /&gt;
&lt;br /&gt;
Python&lt;br /&gt;
&lt;br /&gt;
===Tests===&lt;br /&gt;
&lt;br /&gt;
NA&lt;br /&gt;
&lt;br /&gt;
===Known bugs===&lt;br /&gt;
&lt;br /&gt;
Follow this [http://na-mic.org/Mantis/main_page.php link] to the Slicer3 bug tracker. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Usability issues===&lt;br /&gt;
&lt;br /&gt;
Follow this [http://na-mic.org/Mantis/main_page.php link] to the Slicer3 bug tracker. Please select the '''usability issue category''' when browsing or contributing.&lt;br /&gt;
&lt;br /&gt;
===Source code &amp;amp; documentation===&lt;br /&gt;
&lt;br /&gt;
Links to the module's source code:&lt;br /&gt;
&lt;br /&gt;
Source code:&lt;br /&gt;
*[http://viewvc.slicer.org/viewcvs.cgi/trunk/Modules/Python/SurfaceConnectivity.py SurfaceConnectivity.py]&lt;br /&gt;
 &lt;br /&gt;
== More Information == &lt;br /&gt;
&lt;br /&gt;
===Acknowledgment===&lt;br /&gt;
NA&lt;br /&gt;
&lt;br /&gt;
===References===&lt;br /&gt;
NA&lt;/div&gt;</summary>
		<author><name>Blezek</name></author>
		
	</entry>
	<entry>
		<id>https://www.slicer.org/w/index.php?title=Modules:PythonSurfaceConnectivity-Documentation-3.6&amp;diff=14739</id>
		<title>Modules:PythonSurfaceConnectivity-Documentation-3.6</title>
		<link rel="alternate" type="text/html" href="https://www.slicer.org/w/index.php?title=Modules:PythonSurfaceConnectivity-Documentation-3.6&amp;diff=14739"/>
		<updated>2010-04-29T01:37:47Z</updated>

		<summary type="html">&lt;p&gt;Blezek: /* Module Name */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Documentation-3.6|Return to Slicer 3.6 Documentation]]&lt;br /&gt;
&lt;br /&gt;
[[Announcements:Slicer3.6#Highlights|Gallery of New Features]]&lt;br /&gt;
&lt;br /&gt;
__NOTOC__&lt;br /&gt;
===Module Name===&lt;br /&gt;
Python Surface Connectivity&lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
|[[Image:PythonSurfaceConnectivityUI.png|thumb|280px|User Interface]]&lt;br /&gt;
|[[Image:PythonSurfaceConnectivity1.png|thumb|280px|Figure 1: Clipped model of ICA aneurysm]]&lt;br /&gt;
|[[Image:PythonSurfaceConnectivity2.png|thumb|280px|Figure 2: Connnected region closest to user-specified seed is extracted]]&lt;br /&gt;
|[[Image:PythonSurfaceConnectivity3.png|thumb|280px|Figure 2: All connected regions are extracted and one seed is generated for every region]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== General Information ==&lt;br /&gt;
===Module Type &amp;amp; Category===&lt;br /&gt;
&lt;br /&gt;
Type: CLI&lt;br /&gt;
&lt;br /&gt;
Category: Surface Models&lt;br /&gt;
&lt;br /&gt;
===Authors, Collaborators &amp;amp; Contact===&lt;br /&gt;
* Luca Antiga: Orobix Srl, Mario Negri Institute&lt;br /&gt;
* Daniel Blezek: Mayo Clinic&lt;br /&gt;
* Contact: Luca Antiga, luca.antiga@orobix.com&lt;br /&gt;
&lt;br /&gt;
===Module Description===&lt;br /&gt;
This Python module takes in input a surface and labels it according to surface connectivity. The module either labels the surface with a different RegionId for each connected region, or it extracts the connected region closest to an input fiducial. Optionally, the module produces a list of fiducials positioned on each connected region and labeled with its RegionId.&lt;br /&gt;
&lt;br /&gt;
== Usage ==&lt;br /&gt;
&lt;br /&gt;
===Use Cases, Examples===&lt;br /&gt;
&lt;br /&gt;
* The module is appropriate when there is need of extracting different disconnected components of a model or label them.&lt;br /&gt;
* For developers: the module is a good example on how Python CLI modules can access and modify the MRML scene (unlike executable and shared library CLI modules)&lt;br /&gt;
&lt;br /&gt;
===Tutorials===&lt;br /&gt;
&lt;br /&gt;
NA&lt;br /&gt;
&lt;br /&gt;
===Quick Tour of Features and Use===&lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
|&lt;br /&gt;
* '''Surface Connectivity Parameters:'''&lt;br /&gt;
** ''Connectivity mode'': choose between assigning a RegionId to each connected region (AllRegions) or extract the connected region closest to a seed fiducial (ClosestToSeed). &lt;br /&gt;
** ''Enable output fiducials'': enable output of a fiducial list containing one fiducial per connected region labeled with the corresponding RegionId&lt;br /&gt;
* '''IO:'''&lt;br /&gt;
** ''Input Surface'': the input surface&lt;br /&gt;
** ''Output Surface'': the labeled surface (for AllRegions mode) or the labeled portion of the surface closest to the seed (for ClosestToSeed)&lt;br /&gt;
|[[Image:screenshotBlankNotOptional.png|thumb|280px|User Interface]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Development ==&lt;br /&gt;
&lt;br /&gt;
===Notes from the Developer(s)===&lt;br /&gt;
&lt;br /&gt;
The module internally uses [http://www.vtk.org/doc/nightly/html/classvtkPolyDataConnectivityFilter.html vtkPolyDataConnectivityFilter].&lt;br /&gt;
&lt;br /&gt;
===Dependencies===&lt;br /&gt;
&lt;br /&gt;
Python&lt;br /&gt;
&lt;br /&gt;
===Tests===&lt;br /&gt;
&lt;br /&gt;
NA&lt;br /&gt;
&lt;br /&gt;
===Known bugs===&lt;br /&gt;
&lt;br /&gt;
Follow this [http://na-mic.org/Mantis/main_page.php link] to the Slicer3 bug tracker. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Usability issues===&lt;br /&gt;
&lt;br /&gt;
Follow this [http://na-mic.org/Mantis/main_page.php link] to the Slicer3 bug tracker. Please select the '''usability issue category''' when browsing or contributing.&lt;br /&gt;
&lt;br /&gt;
===Source code &amp;amp; documentation===&lt;br /&gt;
&lt;br /&gt;
Links to the module's source code:&lt;br /&gt;
&lt;br /&gt;
Source code:&lt;br /&gt;
*[http://viewvc.slicer.org/viewcvs.cgi/trunk/Modules/Python/SurfaceConnectivity.py SurfaceConnectivity.py]&lt;br /&gt;
 &lt;br /&gt;
== More Information == &lt;br /&gt;
&lt;br /&gt;
===Acknowledgment===&lt;br /&gt;
NA&lt;br /&gt;
&lt;br /&gt;
===References===&lt;br /&gt;
NA&lt;/div&gt;</summary>
		<author><name>Blezek</name></author>
		
	</entry>
	<entry>
		<id>https://www.slicer.org/w/index.php?title=File:PythonSurfaceConnectivityUI.png&amp;diff=14738</id>
		<title>File:PythonSurfaceConnectivityUI.png</title>
		<link rel="alternate" type="text/html" href="https://www.slicer.org/w/index.php?title=File:PythonSurfaceConnectivityUI.png&amp;diff=14738"/>
		<updated>2010-04-29T01:37:10Z</updated>

		<summary type="html">&lt;p&gt;Blezek: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Blezek</name></author>
		
	</entry>
	<entry>
		<id>https://www.slicer.org/w/index.php?title=Modules:LinearRegistration-Documentation-3.4&amp;diff=8347</id>
		<title>Modules:LinearRegistration-Documentation-3.4</title>
		<link rel="alternate" type="text/html" href="https://www.slicer.org/w/index.php?title=Modules:LinearRegistration-Documentation-3.4&amp;diff=8347"/>
		<updated>2009-03-03T05:14:31Z</updated>

		<summary type="html">&lt;p&gt;Blezek: /* Linear Registration */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Documentation-3.4|Return to Slicer 3.4 Documentation]]&lt;br /&gt;
__NOTOC__&lt;br /&gt;
===Linear Registration===&lt;br /&gt;
Linear Registration&lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
|[[Image:LinearRegistration.png|thumb|280px|Linear Registration Module]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== General Information ==&lt;br /&gt;
===Module Type &amp;amp; Category===&lt;br /&gt;
&lt;br /&gt;
Type: CLI&lt;br /&gt;
&lt;br /&gt;
Category: Registration&lt;br /&gt;
&lt;br /&gt;
===Authors, Collaborators &amp;amp; Contact===&lt;br /&gt;
* Author: Daniel Blezek&lt;br /&gt;
* Contact: daniel.blezek at gmail.com&lt;br /&gt;
&lt;br /&gt;
===Module Description===&lt;br /&gt;
This command line module implements a registration algorithm based on the Mattes mutual information registration metric.  The transformation mapping the moving image to the fixed image consists of 3 translations and 3 rotations.  Thus only rigid body transformations are permitted.  Both the fixed and moving images may be optionally smoothed before registration.  The module optionally breaks the optimization into multiple stages, each with a different learning rate and number of iterations.&lt;br /&gt;
&lt;br /&gt;
== Usage ==&lt;br /&gt;
&lt;br /&gt;
===Examples, Use Cases &amp;amp; Tutorials===&lt;br /&gt;
&lt;br /&gt;
* This module is often used to align images of the same subject acquired at different times.&lt;br /&gt;
* The Mattes mutual information metric is suitable for aligning images of the same or different modalities.&lt;br /&gt;
* The rigid body transformation allows a limited degree of deformation and frequently is used as a pre-processing step for higher order transformations such as the [[Modules:DeformableB-SplineRegistration-Documentation-3.4|BSpline]] and [[Modules:DiffeomorphicDemonsAlgorithm-Documentation03.4| Demons]].&lt;br /&gt;
&lt;br /&gt;
===Quick Tour of Features and Use===&lt;br /&gt;
{|&lt;br /&gt;
|[[Image:LinearRegistration.png|thumb|280px|Linear Registration Module]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===Parameters===&lt;br /&gt;
===Parameter Description===&lt;br /&gt;
* '''Preprocessing'''&lt;br /&gt;
** '''Smoothing level for fixed image''' Amount of smoothing applied to fixed image prior to registration. Default is 0 (none). Range is 0-5 (unitless). Consider smoothing the input data if there is considerable amounts of noise or the noise pattern in the fixed and moving images is very different.&lt;br /&gt;
** '''Smoothing level for moving image''' Amount of smoothing applied to moving image prior to registration. Default is 0 (none). Range is 0-5 (unitless). Consider smoothing the input data if there is considerable amounts of noise or the noise pattern in the fixed and moving images is very different.&lt;br /&gt;
* '''Registration Parameters'''&lt;br /&gt;
** '''Histogram Bins''' Number of bins used to generate the joint probability function used for the mutual information calculation.  Generally, 30-100 are used, or roughly 1/3 the number of grey levels in the images.&lt;br /&gt;
** '''Spatial Samples''' Number of sample locations to use in calculating the mutual information.  The Mattes mutual information metric uses this number of samples for stocastic sampling of the images.  2-5% of the number of samples in the image is usually sufficient for registration.&lt;br /&gt;
** '''Iterations''' Comma separated list of iterations. Must have the same number of elements as the learning rate.&lt;br /&gt;
** '''Learning Rate''' Comma separated list of learning rates. Learning rate is a scale factor on the gradient of the registration objective function (gradient with respect to the parameters of the transformation) used to update the parameters of the transformation during optimization. Smaller values cause the optimizer to take smaller steps through the parameter space. Larger values are typically used early in the registration process to take large jumps in parameter space followed by smaller values to home in on the optimum value of the registration objective function. Default is: 0.01, 0.005, 0.0005, 0.0002. Must have the same number of elements as iterations.&lt;br /&gt;
** '''Transform scaling'''  The relative scaling between rotation and translation parameters, i.e. a value of 100 means 10mm = 1 degree. (Actual scale used is 1/(TranslationScale^2)). This parameter is used to &amp;quot;weight&amp;quot; or &amp;quot;standardized&amp;quot; the transform parameters and their effect on the registration objective function.&lt;br /&gt;
* '''Input/Output'''&lt;br /&gt;
** '''Initial transform''' (Optional)  Initial transform for aligning the fixed and moving image.  Maps positions in the fixed coordinate frame to positions in the moving coordinate frame.&lt;br /&gt;
** '''Fixed Image''' The fixed image to register the moving image against.  The transform calculated maps a spatial position within the Fixed Image to a spatial position within the moving image.&lt;br /&gt;
** '''Moving Image''' The moving image to register to the fixed image.&lt;br /&gt;
** '''Output Transform''' Transform calculated that aligns the fixed and moving image. Maps positions in the fixed coordinate frame to the moving coordinate frame. This parameter is optional, and both an output transform and an output volume may be specified.&lt;br /&gt;
** '''Output Volume''' Resampled moving image to the fixed image coordinate frame.  This is output is optional.&lt;br /&gt;
&lt;br /&gt;
== Development ==&lt;br /&gt;
&lt;br /&gt;
===Dependencies===&lt;br /&gt;
&lt;br /&gt;
No other modules are required for this module.&lt;br /&gt;
&lt;br /&gt;
===Limitations===&lt;br /&gt;
&lt;br /&gt;
The module uses an [http://www.itk.org/Doxygen/html/classitk_1_1OrientImageFilter.html itkOrientImageFilter] to realign the fixed and moving images to axial before registration.  This is required due to limitations in [http://www.itk.org/Wiki/Proposals:Orientation ITK's handling] of non-axial images in filters used by registration.&lt;br /&gt;
&lt;br /&gt;
===Known bugs===&lt;br /&gt;
&lt;br /&gt;
None.  To report bugs, follow this [http://na-mic.org/Mantis/main_page.php link] to the Slicer3 bug tracker. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Usability issues===&lt;br /&gt;
&lt;br /&gt;
Follow this [http://na-mic.org/Mantis/main_page.php link] to the Slicer3 bug tracker. Please select the '''usability issue category''' when browsing or contributing.&lt;br /&gt;
&lt;br /&gt;
===Source code &amp;amp; documentation===&lt;br /&gt;
&lt;br /&gt;
Source Code: [http://www.na-mic.org/ViewVC/index.cgi/trunk/Applications/CLI/LinearRegistration.cxx C++ Source] and [http://www.na-mic.org/ViewVC/index.cgi/trunk/Applications/CLI/LinearRegistration.xml XML Description]&lt;br /&gt;
&lt;br /&gt;
Documentation:&lt;br /&gt;
&lt;br /&gt;
== More Information == &lt;br /&gt;
&lt;br /&gt;
===Acknowledgment===&lt;br /&gt;
This work is part of the National Alliance for Medical Image&lt;br /&gt;
Computing (NAMIC), funded by the National Institutes of Health&lt;br /&gt;
through the NIH Roadmap for Medical Research, Grant U54 EB005149.&lt;br /&gt;
Information on the National Centers for Biomedical Computing&lt;br /&gt;
can be obtained from [http://www.ncbcs.org/ National Centers for Biomedical Computing].&lt;br /&gt;
&lt;br /&gt;
===References===&lt;br /&gt;
D. Mattes, D.R. Haynor, H. Vesselle, T.K. Lewellen, and  W. Eubank. PET-CT image registration in the chest using  free-form deformations. ''IEEE Transactions on Medical Imaging'',  22(1):120–128, 2003.&lt;/div&gt;</summary>
		<author><name>Blezek</name></author>
		
	</entry>
	<entry>
		<id>https://www.slicer.org/w/index.php?title=Modules:LinearRegistration-Documentation-3.4&amp;diff=8346</id>
		<title>Modules:LinearRegistration-Documentation-3.4</title>
		<link rel="alternate" type="text/html" href="https://www.slicer.org/w/index.php?title=Modules:LinearRegistration-Documentation-3.4&amp;diff=8346"/>
		<updated>2009-03-03T05:14:05Z</updated>

		<summary type="html">&lt;p&gt;Blezek: /* Quick Tour of Features and Use */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Documentation-3.4|Return to Slicer 3.4 Documentation]]&lt;br /&gt;
__NOTOC__&lt;br /&gt;
===Linear Registration===&lt;br /&gt;
Linear Registration&lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
|[[Image:screenshotBlank.png|thumb|280px|Caption 1]]&lt;br /&gt;
|[[Image:screenshotBlank.png|thumb|280px|Caption 2]]&lt;br /&gt;
|[[Image:screenshotBlank.png|thumb|280px|Caption 3]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== General Information ==&lt;br /&gt;
===Module Type &amp;amp; Category===&lt;br /&gt;
&lt;br /&gt;
Type: CLI&lt;br /&gt;
&lt;br /&gt;
Category: Registration&lt;br /&gt;
&lt;br /&gt;
===Authors, Collaborators &amp;amp; Contact===&lt;br /&gt;
* Author: Daniel Blezek&lt;br /&gt;
* Contact: daniel.blezek at gmail.com&lt;br /&gt;
&lt;br /&gt;
===Module Description===&lt;br /&gt;
This command line module implements a registration algorithm based on the Mattes mutual information registration metric.  The transformation mapping the moving image to the fixed image consists of 3 translations and 3 rotations.  Thus only rigid body transformations are permitted.  Both the fixed and moving images may be optionally smoothed before registration.  The module optionally breaks the optimization into multiple stages, each with a different learning rate and number of iterations.&lt;br /&gt;
&lt;br /&gt;
== Usage ==&lt;br /&gt;
&lt;br /&gt;
===Examples, Use Cases &amp;amp; Tutorials===&lt;br /&gt;
&lt;br /&gt;
* This module is often used to align images of the same subject acquired at different times.&lt;br /&gt;
* The Mattes mutual information metric is suitable for aligning images of the same or different modalities.&lt;br /&gt;
* The rigid body transformation allows a limited degree of deformation and frequently is used as a pre-processing step for higher order transformations such as the [[Modules:DeformableB-SplineRegistration-Documentation-3.4|BSpline]] and [[Modules:DiffeomorphicDemonsAlgorithm-Documentation03.4| Demons]].&lt;br /&gt;
&lt;br /&gt;
===Quick Tour of Features and Use===&lt;br /&gt;
{|&lt;br /&gt;
|[[Image:LinearRegistration.png|thumb|280px|Linear Registration Module]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===Parameters===&lt;br /&gt;
===Parameter Description===&lt;br /&gt;
* '''Preprocessing'''&lt;br /&gt;
** '''Smoothing level for fixed image''' Amount of smoothing applied to fixed image prior to registration. Default is 0 (none). Range is 0-5 (unitless). Consider smoothing the input data if there is considerable amounts of noise or the noise pattern in the fixed and moving images is very different.&lt;br /&gt;
** '''Smoothing level for moving image''' Amount of smoothing applied to moving image prior to registration. Default is 0 (none). Range is 0-5 (unitless). Consider smoothing the input data if there is considerable amounts of noise or the noise pattern in the fixed and moving images is very different.&lt;br /&gt;
* '''Registration Parameters'''&lt;br /&gt;
** '''Histogram Bins''' Number of bins used to generate the joint probability function used for the mutual information calculation.  Generally, 30-100 are used, or roughly 1/3 the number of grey levels in the images.&lt;br /&gt;
** '''Spatial Samples''' Number of sample locations to use in calculating the mutual information.  The Mattes mutual information metric uses this number of samples for stocastic sampling of the images.  2-5% of the number of samples in the image is usually sufficient for registration.&lt;br /&gt;
** '''Iterations''' Comma separated list of iterations. Must have the same number of elements as the learning rate.&lt;br /&gt;
** '''Learning Rate''' Comma separated list of learning rates. Learning rate is a scale factor on the gradient of the registration objective function (gradient with respect to the parameters of the transformation) used to update the parameters of the transformation during optimization. Smaller values cause the optimizer to take smaller steps through the parameter space. Larger values are typically used early in the registration process to take large jumps in parameter space followed by smaller values to home in on the optimum value of the registration objective function. Default is: 0.01, 0.005, 0.0005, 0.0002. Must have the same number of elements as iterations.&lt;br /&gt;
** '''Transform scaling'''  The relative scaling between rotation and translation parameters, i.e. a value of 100 means 10mm = 1 degree. (Actual scale used is 1/(TranslationScale^2)). This parameter is used to &amp;quot;weight&amp;quot; or &amp;quot;standardized&amp;quot; the transform parameters and their effect on the registration objective function.&lt;br /&gt;
* '''Input/Output'''&lt;br /&gt;
** '''Initial transform''' (Optional)  Initial transform for aligning the fixed and moving image.  Maps positions in the fixed coordinate frame to positions in the moving coordinate frame.&lt;br /&gt;
** '''Fixed Image''' The fixed image to register the moving image against.  The transform calculated maps a spatial position within the Fixed Image to a spatial position within the moving image.&lt;br /&gt;
** '''Moving Image''' The moving image to register to the fixed image.&lt;br /&gt;
** '''Output Transform''' Transform calculated that aligns the fixed and moving image. Maps positions in the fixed coordinate frame to the moving coordinate frame. This parameter is optional, and both an output transform and an output volume may be specified.&lt;br /&gt;
** '''Output Volume''' Resampled moving image to the fixed image coordinate frame.  This is output is optional.&lt;br /&gt;
&lt;br /&gt;
== Development ==&lt;br /&gt;
&lt;br /&gt;
===Dependencies===&lt;br /&gt;
&lt;br /&gt;
No other modules are required for this module.&lt;br /&gt;
&lt;br /&gt;
===Limitations===&lt;br /&gt;
&lt;br /&gt;
The module uses an [http://www.itk.org/Doxygen/html/classitk_1_1OrientImageFilter.html itkOrientImageFilter] to realign the fixed and moving images to axial before registration.  This is required due to limitations in [http://www.itk.org/Wiki/Proposals:Orientation ITK's handling] of non-axial images in filters used by registration.&lt;br /&gt;
&lt;br /&gt;
===Known bugs===&lt;br /&gt;
&lt;br /&gt;
None.  To report bugs, follow this [http://na-mic.org/Mantis/main_page.php link] to the Slicer3 bug tracker. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Usability issues===&lt;br /&gt;
&lt;br /&gt;
Follow this [http://na-mic.org/Mantis/main_page.php link] to the Slicer3 bug tracker. Please select the '''usability issue category''' when browsing or contributing.&lt;br /&gt;
&lt;br /&gt;
===Source code &amp;amp; documentation===&lt;br /&gt;
&lt;br /&gt;
Source Code: [http://www.na-mic.org/ViewVC/index.cgi/trunk/Applications/CLI/LinearRegistration.cxx C++ Source] and [http://www.na-mic.org/ViewVC/index.cgi/trunk/Applications/CLI/LinearRegistration.xml XML Description]&lt;br /&gt;
&lt;br /&gt;
Documentation:&lt;br /&gt;
&lt;br /&gt;
== More Information == &lt;br /&gt;
&lt;br /&gt;
===Acknowledgment===&lt;br /&gt;
This work is part of the National Alliance for Medical Image&lt;br /&gt;
Computing (NAMIC), funded by the National Institutes of Health&lt;br /&gt;
through the NIH Roadmap for Medical Research, Grant U54 EB005149.&lt;br /&gt;
Information on the National Centers for Biomedical Computing&lt;br /&gt;
can be obtained from [http://www.ncbcs.org/ National Centers for Biomedical Computing].&lt;br /&gt;
&lt;br /&gt;
===References===&lt;br /&gt;
D. Mattes, D.R. Haynor, H. Vesselle, T.K. Lewellen, and  W. Eubank. PET-CT image registration in the chest using  free-form deformations. ''IEEE Transactions on Medical Imaging'',  22(1):120–128, 2003.&lt;/div&gt;</summary>
		<author><name>Blezek</name></author>
		
	</entry>
	<entry>
		<id>https://www.slicer.org/w/index.php?title=File:LinearRegistration.png&amp;diff=8345</id>
		<title>File:LinearRegistration.png</title>
		<link rel="alternate" type="text/html" href="https://www.slicer.org/w/index.php?title=File:LinearRegistration.png&amp;diff=8345"/>
		<updated>2009-03-03T05:13:43Z</updated>

		<summary type="html">&lt;p&gt;Blezek: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Blezek</name></author>
		
	</entry>
	<entry>
		<id>https://www.slicer.org/w/index.php?title=Modules:LinearRegistration-Documentation-3.4&amp;diff=8344</id>
		<title>Modules:LinearRegistration-Documentation-3.4</title>
		<link rel="alternate" type="text/html" href="https://www.slicer.org/w/index.php?title=Modules:LinearRegistration-Documentation-3.4&amp;diff=8344"/>
		<updated>2009-03-03T05:13:27Z</updated>

		<summary type="html">&lt;p&gt;Blezek: /* Quick Tour of Features and Use */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Documentation-3.4|Return to Slicer 3.4 Documentation]]&lt;br /&gt;
__NOTOC__&lt;br /&gt;
===Linear Registration===&lt;br /&gt;
Linear Registration&lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
|[[Image:screenshotBlank.png|thumb|280px|Caption 1]]&lt;br /&gt;
|[[Image:screenshotBlank.png|thumb|280px|Caption 2]]&lt;br /&gt;
|[[Image:screenshotBlank.png|thumb|280px|Caption 3]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== General Information ==&lt;br /&gt;
===Module Type &amp;amp; Category===&lt;br /&gt;
&lt;br /&gt;
Type: CLI&lt;br /&gt;
&lt;br /&gt;
Category: Registration&lt;br /&gt;
&lt;br /&gt;
===Authors, Collaborators &amp;amp; Contact===&lt;br /&gt;
* Author: Daniel Blezek&lt;br /&gt;
* Contact: daniel.blezek at gmail.com&lt;br /&gt;
&lt;br /&gt;
===Module Description===&lt;br /&gt;
This command line module implements a registration algorithm based on the Mattes mutual information registration metric.  The transformation mapping the moving image to the fixed image consists of 3 translations and 3 rotations.  Thus only rigid body transformations are permitted.  Both the fixed and moving images may be optionally smoothed before registration.  The module optionally breaks the optimization into multiple stages, each with a different learning rate and number of iterations.&lt;br /&gt;
&lt;br /&gt;
== Usage ==&lt;br /&gt;
&lt;br /&gt;
===Examples, Use Cases &amp;amp; Tutorials===&lt;br /&gt;
&lt;br /&gt;
* This module is often used to align images of the same subject acquired at different times.&lt;br /&gt;
* The Mattes mutual information metric is suitable for aligning images of the same or different modalities.&lt;br /&gt;
* The rigid body transformation allows a limited degree of deformation and frequently is used as a pre-processing step for higher order transformations such as the [[Modules:DeformableB-SplineRegistration-Documentation-3.4|BSpline]] and [[Modules:DiffeomorphicDemonsAlgorithm-Documentation03.4| Demons]].&lt;br /&gt;
&lt;br /&gt;
===Quick Tour of Features and Use===&lt;br /&gt;
&lt;br /&gt;
[[Image:LinearRegistration.png|thumb|280px|Linear Registration Module]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Parameters===&lt;br /&gt;
===Parameter Description===&lt;br /&gt;
* '''Preprocessing'''&lt;br /&gt;
** '''Smoothing level for fixed image''' Amount of smoothing applied to fixed image prior to registration. Default is 0 (none). Range is 0-5 (unitless). Consider smoothing the input data if there is considerable amounts of noise or the noise pattern in the fixed and moving images is very different.&lt;br /&gt;
** '''Smoothing level for moving image''' Amount of smoothing applied to moving image prior to registration. Default is 0 (none). Range is 0-5 (unitless). Consider smoothing the input data if there is considerable amounts of noise or the noise pattern in the fixed and moving images is very different.&lt;br /&gt;
* '''Registration Parameters'''&lt;br /&gt;
** '''Histogram Bins''' Number of bins used to generate the joint probability function used for the mutual information calculation.  Generally, 30-100 are used, or roughly 1/3 the number of grey levels in the images.&lt;br /&gt;
** '''Spatial Samples''' Number of sample locations to use in calculating the mutual information.  The Mattes mutual information metric uses this number of samples for stocastic sampling of the images.  2-5% of the number of samples in the image is usually sufficient for registration.&lt;br /&gt;
** '''Iterations''' Comma separated list of iterations. Must have the same number of elements as the learning rate.&lt;br /&gt;
** '''Learning Rate''' Comma separated list of learning rates. Learning rate is a scale factor on the gradient of the registration objective function (gradient with respect to the parameters of the transformation) used to update the parameters of the transformation during optimization. Smaller values cause the optimizer to take smaller steps through the parameter space. Larger values are typically used early in the registration process to take large jumps in parameter space followed by smaller values to home in on the optimum value of the registration objective function. Default is: 0.01, 0.005, 0.0005, 0.0002. Must have the same number of elements as iterations.&lt;br /&gt;
** '''Transform scaling'''  The relative scaling between rotation and translation parameters, i.e. a value of 100 means 10mm = 1 degree. (Actual scale used is 1/(TranslationScale^2)). This parameter is used to &amp;quot;weight&amp;quot; or &amp;quot;standardized&amp;quot; the transform parameters and their effect on the registration objective function.&lt;br /&gt;
* '''Input/Output'''&lt;br /&gt;
** '''Initial transform''' (Optional)  Initial transform for aligning the fixed and moving image.  Maps positions in the fixed coordinate frame to positions in the moving coordinate frame.&lt;br /&gt;
** '''Fixed Image''' The fixed image to register the moving image against.  The transform calculated maps a spatial position within the Fixed Image to a spatial position within the moving image.&lt;br /&gt;
** '''Moving Image''' The moving image to register to the fixed image.&lt;br /&gt;
** '''Output Transform''' Transform calculated that aligns the fixed and moving image. Maps positions in the fixed coordinate frame to the moving coordinate frame. This parameter is optional, and both an output transform and an output volume may be specified.&lt;br /&gt;
** '''Output Volume''' Resampled moving image to the fixed image coordinate frame.  This is output is optional.&lt;br /&gt;
&lt;br /&gt;
== Development ==&lt;br /&gt;
&lt;br /&gt;
===Dependencies===&lt;br /&gt;
&lt;br /&gt;
No other modules are required for this module.&lt;br /&gt;
&lt;br /&gt;
===Limitations===&lt;br /&gt;
&lt;br /&gt;
The module uses an [http://www.itk.org/Doxygen/html/classitk_1_1OrientImageFilter.html itkOrientImageFilter] to realign the fixed and moving images to axial before registration.  This is required due to limitations in [http://www.itk.org/Wiki/Proposals:Orientation ITK's handling] of non-axial images in filters used by registration.&lt;br /&gt;
&lt;br /&gt;
===Known bugs===&lt;br /&gt;
&lt;br /&gt;
None.  To report bugs, follow this [http://na-mic.org/Mantis/main_page.php link] to the Slicer3 bug tracker. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Usability issues===&lt;br /&gt;
&lt;br /&gt;
Follow this [http://na-mic.org/Mantis/main_page.php link] to the Slicer3 bug tracker. Please select the '''usability issue category''' when browsing or contributing.&lt;br /&gt;
&lt;br /&gt;
===Source code &amp;amp; documentation===&lt;br /&gt;
&lt;br /&gt;
Source Code: [http://www.na-mic.org/ViewVC/index.cgi/trunk/Applications/CLI/LinearRegistration.cxx C++ Source] and [http://www.na-mic.org/ViewVC/index.cgi/trunk/Applications/CLI/LinearRegistration.xml XML Description]&lt;br /&gt;
&lt;br /&gt;
Documentation:&lt;br /&gt;
&lt;br /&gt;
== More Information == &lt;br /&gt;
&lt;br /&gt;
===Acknowledgment===&lt;br /&gt;
This work is part of the National Alliance for Medical Image&lt;br /&gt;
Computing (NAMIC), funded by the National Institutes of Health&lt;br /&gt;
through the NIH Roadmap for Medical Research, Grant U54 EB005149.&lt;br /&gt;
Information on the National Centers for Biomedical Computing&lt;br /&gt;
can be obtained from [http://www.ncbcs.org/ National Centers for Biomedical Computing].&lt;br /&gt;
&lt;br /&gt;
===References===&lt;br /&gt;
D. Mattes, D.R. Haynor, H. Vesselle, T.K. Lewellen, and  W. Eubank. PET-CT image registration in the chest using  free-form deformations. ''IEEE Transactions on Medical Imaging'',  22(1):120–128, 2003.&lt;/div&gt;</summary>
		<author><name>Blezek</name></author>
		
	</entry>
	<entry>
		<id>https://www.slicer.org/w/index.php?title=Modules:AffineRegistration-Documentation-3.4&amp;diff=8343</id>
		<title>Modules:AffineRegistration-Documentation-3.4</title>
		<link rel="alternate" type="text/html" href="https://www.slicer.org/w/index.php?title=Modules:AffineRegistration-Documentation-3.4&amp;diff=8343"/>
		<updated>2009-03-03T04:34:08Z</updated>

		<summary type="html">&lt;p&gt;Blezek: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Documentation-3.4|Return to Slicer 3.4 Documentation]]&lt;br /&gt;
__NOTOC__&lt;br /&gt;
===Affine Registration===&lt;br /&gt;
Affine Registration&lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
|[[Image:AffineRegistration.png|thumb|280px|Affine Registration Module]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== General Information ==&lt;br /&gt;
===Module Type &amp;amp; Category===&lt;br /&gt;
&lt;br /&gt;
Type: CLI&lt;br /&gt;
&lt;br /&gt;
Category: Registration&lt;br /&gt;
&lt;br /&gt;
===Authors, Collaborators &amp;amp; Contact===&lt;br /&gt;
* Author: Daniel Blezek&lt;br /&gt;
* Contact: daniel.blezek at gmail.com&lt;br /&gt;
&lt;br /&gt;
===Module Description===&lt;br /&gt;
This command line module implements a registration algorithm based on the Mattes mutual information registration metric and the affine transformation.  Both the fixed and moving images may be optionally smoothed before registration.&lt;br /&gt;
&lt;br /&gt;
== Usage ==&lt;br /&gt;
&lt;br /&gt;
===Examples, Use Cases &amp;amp; Tutorials===&lt;br /&gt;
&lt;br /&gt;
* This module is often used to align images of different subjects.&lt;br /&gt;
* The affine transformation allows a limited degree of deformation and frequently is used as a pre-processing step for higher order transformations such as the [[Modules:DeformableB-SplineRegistration-Documentation-3.4|BSpline]] and [[Modules:DiffeomorphicDemonsAlgorithm-Documentation03.4| Demons]].&lt;br /&gt;
&lt;br /&gt;
===Short tutorial===&lt;br /&gt;
In this short tutorial, we will show how the Affine Registration module can be used to register two images from different subjects.  The data is from the [http://www.oasis-brains.org/ Oasis Brains project] and the [http://www.loni.ucla.edu/Atlases/Atlas_Detail.jsp?atlas_id=6 ICBM.  We will be registering the volumes icbm452_atlas_air12_sinc.hdr and OAS1_0001_MR1_mpr-1_anon.hdr.  Be sure to load the volumes with the &amp;quot;Centered&amp;quot; option checked.  Rotation is performed around the center, and a centered volume usually produces a more robust result.&lt;br /&gt;
&lt;br /&gt;
With the images loaded into Slicer, select the Registration-Affine Registration module as shown:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
|[[Image:AffineRegistration.png|thumb|280px|Affine Registration Defaults]]&lt;br /&gt;
|[[Image:BeforeAffineRegistration.png|thumb|280px|Before Registration]]&lt;br /&gt;
|[[Image:AfterAffineRegistration.png|thumb|280px|After Registration]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Set the Fixed image to icbm452_atlas_air12_sinc.hdr and the moving image to OAS1_0001_MR1_mpr-1_anon.hdr.  The default settings are sufficient to register these images&lt;br /&gt;
&lt;br /&gt;
===Parameter Description===&lt;br /&gt;
* '''Preprocessing'''&lt;br /&gt;
** '''Smoothing level for fixed image''' Amount of smoothing applied to fixed image prior to registration. Default is 0 (none). Range is 0-5 (unitless). Consider smoothing the input data if there is considerable amounts of noise or the noise pattern in the fixed and moving images is very different.&lt;br /&gt;
** '''Smoothing level for moving image''' Amount of smoothing applied to moving image prior to registration. Default is 0 (none). Range is 0-5 (unitless). Consider smoothing the input data if there is considerable amounts of noise or the noise pattern in the fixed and moving images is very different.&lt;br /&gt;
* '''Registration Parameters'''&lt;br /&gt;
** '''Histogram Bins''' Number of bins used to generate the joint probability function used for the mutual information calculation.  Generally, 30-100 are used, or roughly 1/3 the number of grey levels in the images.&lt;br /&gt;
** '''Spatial Samples''' Number of sample locations to use in calculating the mutual information.  The Mattes mutual information metric uses this number of samples for stocastic sampling of the images.  2-5% of the number of samples in the image is usually sufficient for registration.&lt;br /&gt;
** '''Iterations''' Number of iterations to run.  The default of 2000 is often sufficient for convergence.&lt;br /&gt;
** '''Transform scaling'''  The relative scaling between rotation and translation parameters, i.e. a value of 100 means 10mm = 1 degree. (Actual scale used is 1/(TranslationScale^2)). This parameter is used to &amp;quot;weight&amp;quot; or &amp;quot;standardized&amp;quot; the transform parameters and their effect on the registration objective function.&lt;br /&gt;
* '''Input/Output'''&lt;br /&gt;
** '''Initial transform''' (Optional)  Initial transform for aligning the fixed and moving image.  Maps positions in the fixed coordinate frame to positions in the moving coordinate frame.&lt;br /&gt;
** '''Fixed Image''' The fixed image to register the moving image against.  The transform calculated maps a spatial position within the Fixed Image to a spatial position within the moving image.&lt;br /&gt;
** '''Moving Image''' The moving image to register to the fixed image.&lt;br /&gt;
** '''Output Transform''' Transform calculated that aligns the fixed and moving image. Maps positions in the fixed coordinate frame to the moving coordinate frame. This parameter is optional, and both an output transform and an output volume may be specified.&lt;br /&gt;
** '''Output Volume''' Resampled moving image to the fixed image coordinate frame.  This is output is optional.&lt;br /&gt;
&lt;br /&gt;
== Development ==&lt;br /&gt;
&lt;br /&gt;
===Dependencies===&lt;br /&gt;
&lt;br /&gt;
No other modules are required for this module.&lt;br /&gt;
&lt;br /&gt;
===Limitations===&lt;br /&gt;
&lt;br /&gt;
The module uses an [http://www.itk.org/Doxygen/html/classitk_1_1OrientImageFilter.html itkOrientImageFilter] to realign the fixed and moving images to axial before registration.  This is required due to limitations in [http://www.itk.org/Wiki/Proposals:Orientation ITK's handling] of non-axial images in filters used by registration.&lt;br /&gt;
&lt;br /&gt;
===Known bugs===&lt;br /&gt;
&lt;br /&gt;
None.  To report bugs, follow this [http://na-mic.org/Mantis/main_page.php link] to the Slicer3 bug tracker. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Usability issues===&lt;br /&gt;
&lt;br /&gt;
Follow this [http://na-mic.org/Mantis/main_page.php link] to the Slicer3 bug tracker. Please select the '''usability issue category''' when browsing or contributing.&lt;br /&gt;
&lt;br /&gt;
===Source code &amp;amp; documentation===&lt;br /&gt;
&lt;br /&gt;
Source Code: [http://www.na-mic.org/ViewVC/index.cgi/trunk/Applications/CLI/AffineRegistration.cxx C++ Source] and [http://www.na-mic.org/ViewVC/index.cgi/trunk/Applications/CLI/AffineRegistration.xml XML Description]&lt;br /&gt;
&lt;br /&gt;
Documentation:&lt;br /&gt;
&lt;br /&gt;
== More Information == &lt;br /&gt;
&lt;br /&gt;
===Acknowledgment===&lt;br /&gt;
This work is part of the National Alliance for Medical Image&lt;br /&gt;
Computing (NAMIC), funded by the National Institutes of Health&lt;br /&gt;
through the NIH Roadmap for Medical Research, Grant U54 EB005149.&lt;br /&gt;
Information on the National Centers for Biomedical Computing&lt;br /&gt;
can be obtained from [http://www.ncbcs.org/ National Centers for Biomedical Computing].&lt;br /&gt;
&lt;br /&gt;
===References===&lt;br /&gt;
D. Mattes, D.R. Haynor, H. Vesselle, T.K. Lewellen, and  W. Eubank. PET-CT image registration in the chest using  free-form deformations. ''IEEE Transactions on Medical Imaging'',  22(1):120–128, 2003.&lt;/div&gt;</summary>
		<author><name>Blezek</name></author>
		
	</entry>
	<entry>
		<id>https://www.slicer.org/w/index.php?title=File:AfterAffineRegistration.png&amp;diff=8342</id>
		<title>File:AfterAffineRegistration.png</title>
		<link rel="alternate" type="text/html" href="https://www.slicer.org/w/index.php?title=File:AfterAffineRegistration.png&amp;diff=8342"/>
		<updated>2009-03-03T04:31:16Z</updated>

		<summary type="html">&lt;p&gt;Blezek: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Blezek</name></author>
		
	</entry>
	<entry>
		<id>https://www.slicer.org/w/index.php?title=File:BeforeAffineRegistration.png&amp;diff=8341</id>
		<title>File:BeforeAffineRegistration.png</title>
		<link rel="alternate" type="text/html" href="https://www.slicer.org/w/index.php?title=File:BeforeAffineRegistration.png&amp;diff=8341"/>
		<updated>2009-03-03T04:31:03Z</updated>

		<summary type="html">&lt;p&gt;Blezek: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Blezek</name></author>
		
	</entry>
	<entry>
		<id>https://www.slicer.org/w/index.php?title=File:AffineRegistration.png&amp;diff=8340</id>
		<title>File:AffineRegistration.png</title>
		<link rel="alternate" type="text/html" href="https://www.slicer.org/w/index.php?title=File:AffineRegistration.png&amp;diff=8340"/>
		<updated>2009-03-03T04:30:49Z</updated>

		<summary type="html">&lt;p&gt;Blezek: uploaded a new version of &amp;quot;Image:AffineRegistration.png&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Blezek</name></author>
		
	</entry>
	<entry>
		<id>https://www.slicer.org/w/index.php?title=File:AffineRegistration.png&amp;diff=8339</id>
		<title>File:AffineRegistration.png</title>
		<link rel="alternate" type="text/html" href="https://www.slicer.org/w/index.php?title=File:AffineRegistration.png&amp;diff=8339"/>
		<updated>2009-03-03T03:53:45Z</updated>

		<summary type="html">&lt;p&gt;Blezek: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Blezek</name></author>
		
	</entry>
	<entry>
		<id>https://www.slicer.org/w/index.php?title=Modules:AffineRegistration-Documentation-3.4&amp;diff=8338</id>
		<title>Modules:AffineRegistration-Documentation-3.4</title>
		<link rel="alternate" type="text/html" href="https://www.slicer.org/w/index.php?title=Modules:AffineRegistration-Documentation-3.4&amp;diff=8338"/>
		<updated>2009-03-03T03:11:33Z</updated>

		<summary type="html">&lt;p&gt;Blezek: /* Quick Tour of Features and Use */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Documentation-3.4|Return to Slicer 3.4 Documentation]]&lt;br /&gt;
__NOTOC__&lt;br /&gt;
===Affine Registration===&lt;br /&gt;
Affine Registration&lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
|[[Image:screenshotBlank.png|thumb|280px|Caption 1]]&lt;br /&gt;
|[[Image:screenshotBlank.png|thumb|280px|Caption 2]]&lt;br /&gt;
|[[Image:screenshotBlank.png|thumb|280px|Caption 3]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== General Information ==&lt;br /&gt;
===Module Type &amp;amp; Category===&lt;br /&gt;
&lt;br /&gt;
Type: CLI&lt;br /&gt;
&lt;br /&gt;
Category: Registration&lt;br /&gt;
&lt;br /&gt;
===Authors, Collaborators &amp;amp; Contact===&lt;br /&gt;
* Author: Daniel Blezek&lt;br /&gt;
* Contact: daniel.blezek at gmail.com&lt;br /&gt;
&lt;br /&gt;
===Module Description===&lt;br /&gt;
This command line module implements a registration algorithm based on the Mattes mutual information registration metric and the affine transformation.  Both the fixed and moving images may be optionally smoothed before registration.&lt;br /&gt;
&lt;br /&gt;
== Usage ==&lt;br /&gt;
&lt;br /&gt;
===Examples, Use Cases &amp;amp; Tutorials===&lt;br /&gt;
&lt;br /&gt;
* This module is often used to align images of different subjects.&lt;br /&gt;
* The affine transformation allows a limited degree of deformation and frequently is used as a pre-processing step for higher order transformations such as the [[Modules:DeformableB-SplineRegistration-Documentation-3.4|BSpline]] and [[Modules:DiffeomorphicDemonsAlgorithm-Documentation03.4| Demons]].&lt;br /&gt;
&lt;br /&gt;
===Short tutorial===&lt;br /&gt;
In this short tutorial, we will show how the Affine Registration module can be used to register two images from different subjects.  The data is from tho [http://www.oasis-brains.org/ Oasis Brains project], subjects OAS1_0001 and OAS1_0004.  We will be registering the volumes OAS1_0001_MR1_mpr-1_anon.hdr and OAS1_0004_MR1_mpr-1_anon.hdr.&lt;br /&gt;
&lt;br /&gt;
With the images loaded into Slicer, select the Registration-Affine Registration module as shown:&lt;br /&gt;
&lt;br /&gt;
===Parameter Description===&lt;br /&gt;
* '''Preprocessing'''&lt;br /&gt;
** '''Smoothing level for fixed image''' Amount of smoothing applied to fixed image prior to registration. Default is 0 (none). Range is 0-5 (unitless). Consider smoothing the input data if there is considerable amounts of noise or the noise pattern in the fixed and moving images is very different.&lt;br /&gt;
** '''Smoothing level for moving image''' Amount of smoothing applied to moving image prior to registration. Default is 0 (none). Range is 0-5 (unitless). Consider smoothing the input data if there is considerable amounts of noise or the noise pattern in the fixed and moving images is very different.&lt;br /&gt;
* '''Registration Parameters'''&lt;br /&gt;
** '''Histogram Bins''' Number of bins used to generate the joint probability function used for the mutual information calculation.  Generally, 30-100 are used, or roughly 1/3 the number of grey levels in the images.&lt;br /&gt;
** '''Spatial Samples''' Number of sample locations to use in calculating the mutual information.  The Mattes mutual information metric uses this number of samples for stocastic sampling of the images.  2-5% of the number of samples in the image is usually sufficient for registration.&lt;br /&gt;
** '''Iterations''' Number of iterations to run.  The default of 2000 is often sufficient for convergence.&lt;br /&gt;
** '''Transform scaling'''  The relative scaling between rotation and translation parameters, i.e. a value of 100 means 10mm = 1 degree. (Actual scale used is 1/(TranslationScale^2)). This parameter is used to &amp;quot;weight&amp;quot; or &amp;quot;standardized&amp;quot; the transform parameters and their effect on the registration objective function.&lt;br /&gt;
* '''Input/Output'''&lt;br /&gt;
** '''Initial transform''' (Optional)  Initial transform for aligning the fixed and moving image.  Maps positions in the fixed coordinate frame to positions in the moving coordinate frame.&lt;br /&gt;
** '''Fixed Image''' The fixed image to register the moving image against.  The transform calculated maps a spatial position within the Fixed Image to a spatial position within the moving image.&lt;br /&gt;
** '''Moving Image''' The moving image to register to the fixed image.&lt;br /&gt;
** '''Output Transform''' Transform calculated that aligns the fixed and moving image. Maps positions in the fixed coordinate frame to the moving coordinate frame. This parameter is optional, and both an output transform and an output volume may be specified.&lt;br /&gt;
** '''Output Volume''' Resampled moving image to the fixed image coordinate frame.  This is output is optional.&lt;br /&gt;
&lt;br /&gt;
== Development ==&lt;br /&gt;
&lt;br /&gt;
===Dependencies===&lt;br /&gt;
&lt;br /&gt;
No other modules are required for this module.&lt;br /&gt;
&lt;br /&gt;
===Limitations===&lt;br /&gt;
&lt;br /&gt;
The module uses an [http://www.itk.org/Doxygen/html/classitk_1_1OrientImageFilter.html itkOrientImageFilter] to realign the fixed and moving images to axial before registration.  This is required due to limitations in [http://www.itk.org/Wiki/Proposals:Orientation ITK's handling] of non-axial images in filters used by registration.&lt;br /&gt;
&lt;br /&gt;
===Known bugs===&lt;br /&gt;
&lt;br /&gt;
None.  To report bugs, follow this [http://na-mic.org/Mantis/main_page.php link] to the Slicer3 bug tracker. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Usability issues===&lt;br /&gt;
&lt;br /&gt;
Follow this [http://na-mic.org/Mantis/main_page.php link] to the Slicer3 bug tracker. Please select the '''usability issue category''' when browsing or contributing.&lt;br /&gt;
&lt;br /&gt;
===Source code &amp;amp; documentation===&lt;br /&gt;
&lt;br /&gt;
Source Code: [http://www.na-mic.org/ViewVC/index.cgi/trunk/Applications/CLI/AffineRegistration.cxx C++ Source] and [http://www.na-mic.org/ViewVC/index.cgi/trunk/Applications/CLI/AffineRegistration.xml XML Description]&lt;br /&gt;
&lt;br /&gt;
Documentation:&lt;br /&gt;
&lt;br /&gt;
== More Information == &lt;br /&gt;
&lt;br /&gt;
===Acknowledgment===&lt;br /&gt;
This work is part of the National Alliance for Medical Image&lt;br /&gt;
Computing (NAMIC), funded by the National Institutes of Health&lt;br /&gt;
through the NIH Roadmap for Medical Research, Grant U54 EB005149.&lt;br /&gt;
Information on the National Centers for Biomedical Computing&lt;br /&gt;
can be obtained from [http://www.ncbcs.org/ National Centers for Biomedical Computing].&lt;br /&gt;
&lt;br /&gt;
===References===&lt;br /&gt;
D. Mattes, D.R. Haynor, H. Vesselle, T.K. Lewellen, and  W. Eubank. PET-CT image registration in the chest using  free-form deformations. ''IEEE Transactions on Medical Imaging'',  22(1):120–128, 2003.&lt;/div&gt;</summary>
		<author><name>Blezek</name></author>
		
	</entry>
	<entry>
		<id>https://www.slicer.org/w/index.php?title=Modules:AffineRegistration-Documentation-3.4&amp;diff=8337</id>
		<title>Modules:AffineRegistration-Documentation-3.4</title>
		<link rel="alternate" type="text/html" href="https://www.slicer.org/w/index.php?title=Modules:AffineRegistration-Documentation-3.4&amp;diff=8337"/>
		<updated>2009-03-03T03:06:04Z</updated>

		<summary type="html">&lt;p&gt;Blezek: /* Parameter Description */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Documentation-3.4|Return to Slicer 3.4 Documentation]]&lt;br /&gt;
__NOTOC__&lt;br /&gt;
===Affine Registration===&lt;br /&gt;
Affine Registration&lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
|[[Image:screenshotBlank.png|thumb|280px|Caption 1]]&lt;br /&gt;
|[[Image:screenshotBlank.png|thumb|280px|Caption 2]]&lt;br /&gt;
|[[Image:screenshotBlank.png|thumb|280px|Caption 3]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== General Information ==&lt;br /&gt;
===Module Type &amp;amp; Category===&lt;br /&gt;
&lt;br /&gt;
Type: CLI&lt;br /&gt;
&lt;br /&gt;
Category: Registration&lt;br /&gt;
&lt;br /&gt;
===Authors, Collaborators &amp;amp; Contact===&lt;br /&gt;
* Author: Daniel Blezek&lt;br /&gt;
* Contact: daniel.blezek at gmail.com&lt;br /&gt;
&lt;br /&gt;
===Module Description===&lt;br /&gt;
This command line module implements a registration algorithm based on the Mattes mutual information registration metric and the affine transformation.  Both the fixed and moving images may be optionally smoothed before registration.&lt;br /&gt;
&lt;br /&gt;
== Usage ==&lt;br /&gt;
&lt;br /&gt;
===Examples, Use Cases &amp;amp; Tutorials===&lt;br /&gt;
&lt;br /&gt;
* This module is often used to align images of different subjects.&lt;br /&gt;
* The affine transformation allows a limited degree of deformation and frequently is used as a pre-processing step for higher order transformations such as the [[Modules:DeformableB-SplineRegistration-Documentation-3.4|BSpline]] and [[Modules:DiffeomorphicDemonsAlgorithm-Documentation03.4| Demons]].&lt;br /&gt;
&lt;br /&gt;
===Quick Tour of Features and Use===&lt;br /&gt;
List all the panels in your interface, their features, what they mean, and how to use them. For instance:&lt;br /&gt;
&lt;br /&gt;
* '''Input panel:'''&lt;br /&gt;
* '''Parameters panel:'''&lt;br /&gt;
* '''Output panel:'''&lt;br /&gt;
* '''Viewing panel:'''&lt;br /&gt;
&lt;br /&gt;
===Parameter Description===&lt;br /&gt;
* '''Preprocessing'''&lt;br /&gt;
** '''Smoothing level for fixed image''' Amount of smoothing applied to fixed image prior to registration. Default is 0 (none). Range is 0-5 (unitless). Consider smoothing the input data if there is considerable amounts of noise or the noise pattern in the fixed and moving images is very different.&lt;br /&gt;
** '''Smoothing level for moving image''' Amount of smoothing applied to moving image prior to registration. Default is 0 (none). Range is 0-5 (unitless). Consider smoothing the input data if there is considerable amounts of noise or the noise pattern in the fixed and moving images is very different.&lt;br /&gt;
* '''Registration Parameters'''&lt;br /&gt;
** '''Histogram Bins''' Number of bins used to generate the joint probability function used for the mutual information calculation.  Generally, 30-100 are used, or roughly 1/3 the number of grey levels in the images.&lt;br /&gt;
** '''Spatial Samples''' Number of sample locations to use in calculating the mutual information.  The Mattes mutual information metric uses this number of samples for stocastic sampling of the images.  2-5% of the number of samples in the image is usually sufficient for registration.&lt;br /&gt;
** '''Iterations''' Number of iterations to run.  The default of 2000 is often sufficient for convergence.&lt;br /&gt;
** '''Transform scaling'''  The relative scaling between rotation and translation parameters, i.e. a value of 100 means 10mm = 1 degree. (Actual scale used is 1/(TranslationScale^2)). This parameter is used to &amp;quot;weight&amp;quot; or &amp;quot;standardized&amp;quot; the transform parameters and their effect on the registration objective function.&lt;br /&gt;
* '''Input/Output'''&lt;br /&gt;
** '''Initial transform''' (Optional)  Initial transform for aligning the fixed and moving image.  Maps positions in the fixed coordinate frame to positions in the moving coordinate frame.&lt;br /&gt;
** '''Fixed Image''' The fixed image to register the moving image against.  The transform calculated maps a spatial position within the Fixed Image to a spatial position within the moving image.&lt;br /&gt;
** '''Moving Image''' The moving image to register to the fixed image.&lt;br /&gt;
** '''Output Transform''' Transform calculated that aligns the fixed and moving image. Maps positions in the fixed coordinate frame to the moving coordinate frame. This parameter is optional, and both an output transform and an output volume may be specified.&lt;br /&gt;
** '''Output Volume''' Resampled moving image to the fixed image coordinate frame.  This is output is optional.&lt;br /&gt;
&lt;br /&gt;
== Development ==&lt;br /&gt;
&lt;br /&gt;
===Dependencies===&lt;br /&gt;
&lt;br /&gt;
No other modules are required for this module.&lt;br /&gt;
&lt;br /&gt;
===Limitations===&lt;br /&gt;
&lt;br /&gt;
The module uses an [http://www.itk.org/Doxygen/html/classitk_1_1OrientImageFilter.html itkOrientImageFilter] to realign the fixed and moving images to axial before registration.  This is required due to limitations in [http://www.itk.org/Wiki/Proposals:Orientation ITK's handling] of non-axial images in filters used by registration.&lt;br /&gt;
&lt;br /&gt;
===Known bugs===&lt;br /&gt;
&lt;br /&gt;
None.  To report bugs, follow this [http://na-mic.org/Mantis/main_page.php link] to the Slicer3 bug tracker. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Usability issues===&lt;br /&gt;
&lt;br /&gt;
Follow this [http://na-mic.org/Mantis/main_page.php link] to the Slicer3 bug tracker. Please select the '''usability issue category''' when browsing or contributing.&lt;br /&gt;
&lt;br /&gt;
===Source code &amp;amp; documentation===&lt;br /&gt;
&lt;br /&gt;
Source Code: [http://www.na-mic.org/ViewVC/index.cgi/trunk/Applications/CLI/AffineRegistration.cxx C++ Source] and [http://www.na-mic.org/ViewVC/index.cgi/trunk/Applications/CLI/AffineRegistration.xml XML Description]&lt;br /&gt;
&lt;br /&gt;
Documentation:&lt;br /&gt;
&lt;br /&gt;
== More Information == &lt;br /&gt;
&lt;br /&gt;
===Acknowledgment===&lt;br /&gt;
This work is part of the National Alliance for Medical Image&lt;br /&gt;
Computing (NAMIC), funded by the National Institutes of Health&lt;br /&gt;
through the NIH Roadmap for Medical Research, Grant U54 EB005149.&lt;br /&gt;
Information on the National Centers for Biomedical Computing&lt;br /&gt;
can be obtained from [http://www.ncbcs.org/ National Centers for Biomedical Computing].&lt;br /&gt;
&lt;br /&gt;
===References===&lt;br /&gt;
D. Mattes, D.R. Haynor, H. Vesselle, T.K. Lewellen, and  W. Eubank. PET-CT image registration in the chest using  free-form deformations. ''IEEE Transactions on Medical Imaging'',  22(1):120–128, 2003.&lt;/div&gt;</summary>
		<author><name>Blezek</name></author>
		
	</entry>
	<entry>
		<id>https://www.slicer.org/w/index.php?title=Modules:AffineRegistration-Documentation-3.4&amp;diff=8336</id>
		<title>Modules:AffineRegistration-Documentation-3.4</title>
		<link rel="alternate" type="text/html" href="https://www.slicer.org/w/index.php?title=Modules:AffineRegistration-Documentation-3.4&amp;diff=8336"/>
		<updated>2009-03-03T03:04:37Z</updated>

		<summary type="html">&lt;p&gt;Blezek: /* Usage */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Documentation-3.4|Return to Slicer 3.4 Documentation]]&lt;br /&gt;
__NOTOC__&lt;br /&gt;
===Affine Registration===&lt;br /&gt;
Affine Registration&lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
|[[Image:screenshotBlank.png|thumb|280px|Caption 1]]&lt;br /&gt;
|[[Image:screenshotBlank.png|thumb|280px|Caption 2]]&lt;br /&gt;
|[[Image:screenshotBlank.png|thumb|280px|Caption 3]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== General Information ==&lt;br /&gt;
===Module Type &amp;amp; Category===&lt;br /&gt;
&lt;br /&gt;
Type: CLI&lt;br /&gt;
&lt;br /&gt;
Category: Registration&lt;br /&gt;
&lt;br /&gt;
===Authors, Collaborators &amp;amp; Contact===&lt;br /&gt;
* Author: Daniel Blezek&lt;br /&gt;
* Contact: daniel.blezek at gmail.com&lt;br /&gt;
&lt;br /&gt;
===Module Description===&lt;br /&gt;
This command line module implements a registration algorithm based on the Mattes mutual information registration metric and the affine transformation.  Both the fixed and moving images may be optionally smoothed before registration.&lt;br /&gt;
&lt;br /&gt;
== Usage ==&lt;br /&gt;
&lt;br /&gt;
===Examples, Use Cases &amp;amp; Tutorials===&lt;br /&gt;
&lt;br /&gt;
* This module is often used to align images of different subjects.&lt;br /&gt;
* The affine transformation allows a limited degree of deformation and frequently is used as a pre-processing step for higher order transformations such as the [[Modules:DeformableB-SplineRegistration-Documentation-3.4|BSpline]] and [[Modules:DiffeomorphicDemonsAlgorithm-Documentation03.4| Demons]].&lt;br /&gt;
&lt;br /&gt;
===Quick Tour of Features and Use===&lt;br /&gt;
List all the panels in your interface, their features, what they mean, and how to use them. For instance:&lt;br /&gt;
&lt;br /&gt;
* '''Input panel:'''&lt;br /&gt;
* '''Parameters panel:'''&lt;br /&gt;
* '''Output panel:'''&lt;br /&gt;
* '''Viewing panel:'''&lt;br /&gt;
&lt;br /&gt;
===Parameter Description===&lt;br /&gt;
* '''Registration Parameters'''&lt;br /&gt;
** '''Histogram Bins''' Number of bins used to generate the joint probability function used for the mutual information calculation.  Generally, 30-100 are used, or roughly 1/3 the number of grey levels in the images.&lt;br /&gt;
** '''Spatial Samples''' Number of sample locations to use in calculating the mutual information.  The Mattes mutual information metric uses this number of samples for stocastic sampling of the images.  2-5% of the number of samples in the image is usually sufficient for registration.&lt;br /&gt;
** '''Iterations''' Number of iterations to run.  The default of 2000 is often sufficient for convergence.&lt;br /&gt;
** '''Transform scaling'''  The relative scaling between rotation and translation parameters, i.e. a value of 100 means 10mm = 1 degree. (Actual scale used is 1/(TranslationScale^2)). This parameter is used to &amp;quot;weight&amp;quot; or &amp;quot;standardized&amp;quot; the transform parameters and their effect on the registration objective function.&lt;br /&gt;
* '''Input/Output'''&lt;br /&gt;
** '''Initial transform''' (Optional)  Initial transform for aligning the fixed and moving image.  Maps positions in the fixed coordinate frame to positions in the moving coordinate frame.&lt;br /&gt;
** '''Fixed Image''' The fixed image to register the moving image against.  The transform calculated maps a spatial position within the Fixed Image to a spatial position within the moving image.&lt;br /&gt;
** '''Moving Image''' The moving image to register to the fixed image.&lt;br /&gt;
** '''Output Transform''' Transform calculated that aligns the fixed and moving image. Maps positions in the fixed coordinate frame to the moving coordinate frame. This parameter is optional, and both an output transform and an output volume may be specified.&lt;br /&gt;
** '''Output Volume''' Resampled moving image to the fixed image coordinate frame.  This is output is optional.&lt;br /&gt;
&lt;br /&gt;
== Development ==&lt;br /&gt;
&lt;br /&gt;
===Dependencies===&lt;br /&gt;
&lt;br /&gt;
No other modules are required for this module.&lt;br /&gt;
&lt;br /&gt;
===Limitations===&lt;br /&gt;
&lt;br /&gt;
The module uses an [http://www.itk.org/Doxygen/html/classitk_1_1OrientImageFilter.html itkOrientImageFilter] to realign the fixed and moving images to axial before registration.  This is required due to limitations in [http://www.itk.org/Wiki/Proposals:Orientation ITK's handling] of non-axial images in filters used by registration.&lt;br /&gt;
&lt;br /&gt;
===Known bugs===&lt;br /&gt;
&lt;br /&gt;
None.  To report bugs, follow this [http://na-mic.org/Mantis/main_page.php link] to the Slicer3 bug tracker. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Usability issues===&lt;br /&gt;
&lt;br /&gt;
Follow this [http://na-mic.org/Mantis/main_page.php link] to the Slicer3 bug tracker. Please select the '''usability issue category''' when browsing or contributing.&lt;br /&gt;
&lt;br /&gt;
===Source code &amp;amp; documentation===&lt;br /&gt;
&lt;br /&gt;
Source Code: [http://www.na-mic.org/ViewVC/index.cgi/trunk/Applications/CLI/AffineRegistration.cxx C++ Source] and [http://www.na-mic.org/ViewVC/index.cgi/trunk/Applications/CLI/AffineRegistration.xml XML Description]&lt;br /&gt;
&lt;br /&gt;
Documentation:&lt;br /&gt;
&lt;br /&gt;
== More Information == &lt;br /&gt;
&lt;br /&gt;
===Acknowledgment===&lt;br /&gt;
This work is part of the National Alliance for Medical Image&lt;br /&gt;
Computing (NAMIC), funded by the National Institutes of Health&lt;br /&gt;
through the NIH Roadmap for Medical Research, Grant U54 EB005149.&lt;br /&gt;
Information on the National Centers for Biomedical Computing&lt;br /&gt;
can be obtained from [http://www.ncbcs.org/ National Centers for Biomedical Computing].&lt;br /&gt;
&lt;br /&gt;
===References===&lt;br /&gt;
D. Mattes, D.R. Haynor, H. Vesselle, T.K. Lewellen, and  W. Eubank. PET-CT image registration in the chest using  free-form deformations. ''IEEE Transactions on Medical Imaging'',  22(1):120–128, 2003.&lt;/div&gt;</summary>
		<author><name>Blezek</name></author>
		
	</entry>
	<entry>
		<id>https://www.slicer.org/w/index.php?title=Modules:AffineRegistration-Documentation-3.4&amp;diff=8265</id>
		<title>Modules:AffineRegistration-Documentation-3.4</title>
		<link rel="alternate" type="text/html" href="https://www.slicer.org/w/index.php?title=Modules:AffineRegistration-Documentation-3.4&amp;diff=8265"/>
		<updated>2009-03-02T03:17:59Z</updated>

		<summary type="html">&lt;p&gt;Blezek: /* Source code &amp;amp; documentation */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Documentation-3.4|Return to Slicer 3.4 Documentation]]&lt;br /&gt;
__NOTOC__&lt;br /&gt;
===Affine Registration===&lt;br /&gt;
Affine Registration&lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
|[[Image:screenshotBlank.png|thumb|280px|Caption 1]]&lt;br /&gt;
|[[Image:screenshotBlank.png|thumb|280px|Caption 2]]&lt;br /&gt;
|[[Image:screenshotBlank.png|thumb|280px|Caption 3]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== General Information ==&lt;br /&gt;
===Module Type &amp;amp; Category===&lt;br /&gt;
&lt;br /&gt;
Type: CLI&lt;br /&gt;
&lt;br /&gt;
Category: Registration&lt;br /&gt;
&lt;br /&gt;
===Authors, Collaborators &amp;amp; Contact===&lt;br /&gt;
* Author: Daniel Blezek&lt;br /&gt;
* Contact: daniel.blezek at gmail.com&lt;br /&gt;
&lt;br /&gt;
===Module Description===&lt;br /&gt;
This command line module implements a registration algorithm based on the Mattes mutual information registration metric and the affine transformation.  Both the fixed and moving images may be optionally smoothed before registration.&lt;br /&gt;
&lt;br /&gt;
== Usage ==&lt;br /&gt;
&lt;br /&gt;
===Examples, Use Cases &amp;amp; Tutorials===&lt;br /&gt;
&lt;br /&gt;
* This module is often used to align images of different subjects.&lt;br /&gt;
* The affine transformation allows a limited degree of deformation and frequently is used as a pre-processing step for higher order transformations such as the [[Modules:DeformableB-SplineRegistration-Documentation-3.4|BSpline]] and [[Modules:DiffeomorphicDemonsAlgorithm-Documentation03.4| Demons]].&lt;br /&gt;
&lt;br /&gt;
===Quick Tour of Features and Use===&lt;br /&gt;
List all the panels in your interface, their features, what they mean, and how to use them. For instance:&lt;br /&gt;
&lt;br /&gt;
* '''Input panel:'''&lt;br /&gt;
* '''Parameters panel:'''&lt;br /&gt;
* '''Output panel:'''&lt;br /&gt;
* '''Viewing panel:'''&lt;br /&gt;
&lt;br /&gt;
== Development ==&lt;br /&gt;
&lt;br /&gt;
===Dependencies===&lt;br /&gt;
&lt;br /&gt;
No other modules are required for this module.&lt;br /&gt;
&lt;br /&gt;
===Limitations===&lt;br /&gt;
&lt;br /&gt;
The module uses an [http://www.itk.org/Doxygen/html/classitk_1_1OrientImageFilter.html itkOrientImageFilter] to realign the fixed and moving images to axial before registration.  This is required due to limitations in [http://www.itk.org/Wiki/Proposals:Orientation ITK's handling] of non-axial images in filters used by registration.&lt;br /&gt;
&lt;br /&gt;
===Known bugs===&lt;br /&gt;
&lt;br /&gt;
None.  To report bugs, follow this [http://na-mic.org/Mantis/main_page.php link] to the Slicer3 bug tracker. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Usability issues===&lt;br /&gt;
&lt;br /&gt;
Follow this [http://na-mic.org/Mantis/main_page.php link] to the Slicer3 bug tracker. Please select the '''usability issue category''' when browsing or contributing.&lt;br /&gt;
&lt;br /&gt;
===Source code &amp;amp; documentation===&lt;br /&gt;
&lt;br /&gt;
Source Code: [http://www.na-mic.org/ViewVC/index.cgi/trunk/Applications/CLI/AffineRegistration.cxx C++ Source] and [http://www.na-mic.org/ViewVC/index.cgi/trunk/Applications/CLI/AffineRegistration.xml XML Description]&lt;br /&gt;
&lt;br /&gt;
Documentation:&lt;br /&gt;
&lt;br /&gt;
== More Information == &lt;br /&gt;
&lt;br /&gt;
===Acknowledgment===&lt;br /&gt;
This work is part of the National Alliance for Medical Image&lt;br /&gt;
Computing (NAMIC), funded by the National Institutes of Health&lt;br /&gt;
through the NIH Roadmap for Medical Research, Grant U54 EB005149.&lt;br /&gt;
Information on the National Centers for Biomedical Computing&lt;br /&gt;
can be obtained from [http://www.ncbcs.org/ National Centers for Biomedical Computing].&lt;br /&gt;
&lt;br /&gt;
===References===&lt;br /&gt;
D. Mattes, D.R. Haynor, H. Vesselle, T.K. Lewellen, and  W. Eubank. PET-CT image registration in the chest using  free-form deformations. ''IEEE Transactions on Medical Imaging'',  22(1):120–128, 2003.&lt;/div&gt;</summary>
		<author><name>Blezek</name></author>
		
	</entry>
	<entry>
		<id>https://www.slicer.org/w/index.php?title=Modules:LinearRegistration-Documentation-3.4&amp;diff=8264</id>
		<title>Modules:LinearRegistration-Documentation-3.4</title>
		<link rel="alternate" type="text/html" href="https://www.slicer.org/w/index.php?title=Modules:LinearRegistration-Documentation-3.4&amp;diff=8264"/>
		<updated>2009-03-02T03:16:04Z</updated>

		<summary type="html">&lt;p&gt;Blezek: New page:  Return to Slicer 3.4 Documentation __NOTOC__ ===Linear Registration=== Linear Registration  {| |Caption 1 |[[Image:screensh...&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt; [[Documentation-3.4|Return to Slicer 3.4 Documentation]]&lt;br /&gt;
__NOTOC__&lt;br /&gt;
===Linear Registration===&lt;br /&gt;
Linear Registration&lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
|[[Image:screenshotBlank.png|thumb|280px|Caption 1]]&lt;br /&gt;
|[[Image:screenshotBlank.png|thumb|280px|Caption 2]]&lt;br /&gt;
|[[Image:screenshotBlank.png|thumb|280px|Caption 3]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== General Information ==&lt;br /&gt;
===Module Type &amp;amp; Category===&lt;br /&gt;
&lt;br /&gt;
Type: CLI&lt;br /&gt;
&lt;br /&gt;
Category: Registration&lt;br /&gt;
&lt;br /&gt;
===Authors, Collaborators &amp;amp; Contact===&lt;br /&gt;
* Author: Daniel Blezek&lt;br /&gt;
* Contact: daniel.blezek at gmail.com&lt;br /&gt;
&lt;br /&gt;
===Module Description===&lt;br /&gt;
This command line module implements a registration algorithm based on the Mattes mutual information registration metric.  The transformation mapping the moving image to the fixed image consists of 3 translations and 3 rotations.  Thus only rigid body transformations are permitted.  Both the fixed and moving images may be optionally smoothed before registration.  The module optionally breaks the optimization into multiple stages, each with a different learning rate and number of iterations.&lt;br /&gt;
&lt;br /&gt;
== Usage ==&lt;br /&gt;
&lt;br /&gt;
===Examples, Use Cases &amp;amp; Tutorials===&lt;br /&gt;
&lt;br /&gt;
* This module is often used to align images of the same subject acquired at different times.&lt;br /&gt;
* The Mattes mutual information metric is suitable for aligning images of the same or different modalities.&lt;br /&gt;
* The rigid body transformation allows a limited degree of deformation and frequently is used as a pre-processing step for higher order transformations such as the [[Modules:DeformableB-SplineRegistration-Documentation-3.4|BSpline]] and [[Modules:DiffeomorphicDemonsAlgorithm-Documentation03.4| Demons]].&lt;br /&gt;
&lt;br /&gt;
===Quick Tour of Features and Use===&lt;br /&gt;
List all the panels in your interface, their features, what they mean, and how to use them. For instance:&lt;br /&gt;
&lt;br /&gt;
* '''Input panel:'''&lt;br /&gt;
* '''Parameters panel:'''&lt;br /&gt;
* '''Output panel:'''&lt;br /&gt;
* '''Viewing panel:'''&lt;br /&gt;
&lt;br /&gt;
== Development ==&lt;br /&gt;
&lt;br /&gt;
===Dependencies===&lt;br /&gt;
&lt;br /&gt;
No other modules are required for this module.&lt;br /&gt;
&lt;br /&gt;
===Limitations===&lt;br /&gt;
&lt;br /&gt;
The module uses an [http://www.itk.org/Doxygen/html/classitk_1_1OrientImageFilter.html itkOrientImageFilter] to realign the fixed and moving images to axial before registration.  This is required due to limitations in [http://www.itk.org/Wiki/Proposals:Orientation ITK's handling] of non-axial images in filters used by registration.&lt;br /&gt;
&lt;br /&gt;
===Known bugs===&lt;br /&gt;
&lt;br /&gt;
None.  To report bugs, follow this [http://na-mic.org/Mantis/main_page.php link] to the Slicer3 bug tracker. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Usability issues===&lt;br /&gt;
&lt;br /&gt;
Follow this [http://na-mic.org/Mantis/main_page.php link] to the Slicer3 bug tracker. Please select the '''usability issue category''' when browsing or contributing.&lt;br /&gt;
&lt;br /&gt;
===Source code &amp;amp; documentation===&lt;br /&gt;
&lt;br /&gt;
Source Code: [http://www.na-mic.org/ViewVC/index.cgi/trunk/Applications/CLI/LinearRegistration.cxx C++ Source] and [http://www.na-mic.org/ViewVC/index.cgi/trunk/Applications/CLI/LinearRegistration.xml XML Description]&lt;br /&gt;
&lt;br /&gt;
Documentation:&lt;br /&gt;
&lt;br /&gt;
== More Information == &lt;br /&gt;
&lt;br /&gt;
===Acknowledgment===&lt;br /&gt;
This work is part of the National Alliance for Medical Image&lt;br /&gt;
Computing (NAMIC), funded by the National Institutes of Health&lt;br /&gt;
through the NIH Roadmap for Medical Research, Grant U54 EB005149.&lt;br /&gt;
Information on the National Centers for Biomedical Computing&lt;br /&gt;
can be obtained from [http://www.ncbcs.org/ National Centers for Biomedical Computing].&lt;br /&gt;
&lt;br /&gt;
===References===&lt;br /&gt;
D. Mattes, D.R. Haynor, H. Vesselle, T.K. Lewellen, and  W. Eubank. PET-CT image registration in the chest using  free-form deformations. ''IEEE Transactions on Medical Imaging'',  22(1):120–128, 2003.&lt;/div&gt;</summary>
		<author><name>Blezek</name></author>
		
	</entry>
	<entry>
		<id>https://www.slicer.org/w/index.php?title=Modules:AffineRegistration-Documentation-3.4&amp;diff=8263</id>
		<title>Modules:AffineRegistration-Documentation-3.4</title>
		<link rel="alternate" type="text/html" href="https://www.slicer.org/w/index.php?title=Modules:AffineRegistration-Documentation-3.4&amp;diff=8263"/>
		<updated>2009-03-02T03:05:00Z</updated>

		<summary type="html">&lt;p&gt;Blezek: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt; [[Documentation-3.4|Return to Slicer 3.4 Documentation]]&lt;br /&gt;
__NOTOC__&lt;br /&gt;
===Affine Registration===&lt;br /&gt;
Affine Registration&lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
|[[Image:screenshotBlank.png|thumb|280px|Caption 1]]&lt;br /&gt;
|[[Image:screenshotBlank.png|thumb|280px|Caption 2]]&lt;br /&gt;
|[[Image:screenshotBlank.png|thumb|280px|Caption 3]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== General Information ==&lt;br /&gt;
===Module Type &amp;amp; Category===&lt;br /&gt;
&lt;br /&gt;
Type: CLI&lt;br /&gt;
&lt;br /&gt;
Category: Registration&lt;br /&gt;
&lt;br /&gt;
===Authors, Collaborators &amp;amp; Contact===&lt;br /&gt;
* Author: Daniel Blezek&lt;br /&gt;
* Contact: daniel.blezek at gmail.com&lt;br /&gt;
&lt;br /&gt;
===Module Description===&lt;br /&gt;
This command line module implements a registration algorithm based on the Mattes mutual information registration metric and the affine transformation.  Both the fixed and moving images may be optionally smoothed before registration.&lt;br /&gt;
&lt;br /&gt;
== Usage ==&lt;br /&gt;
&lt;br /&gt;
===Examples, Use Cases &amp;amp; Tutorials===&lt;br /&gt;
&lt;br /&gt;
* This module is often used to align images of different subjects.&lt;br /&gt;
* The affine transformation allows a limited degree of deformation and frequently is used as a pre-processing step for higher order transformations such as the [[Modules:DeformableB-SplineRegistration-Documentation-3.4|BSpline]] and [[Modules:DiffeomorphicDemonsAlgorithm-Documentation03.4| Demons]].&lt;br /&gt;
&lt;br /&gt;
===Quick Tour of Features and Use===&lt;br /&gt;
List all the panels in your interface, their features, what they mean, and how to use them. For instance:&lt;br /&gt;
&lt;br /&gt;
* '''Input panel:'''&lt;br /&gt;
* '''Parameters panel:'''&lt;br /&gt;
* '''Output panel:'''&lt;br /&gt;
* '''Viewing panel:'''&lt;br /&gt;
&lt;br /&gt;
== Development ==&lt;br /&gt;
&lt;br /&gt;
===Dependencies===&lt;br /&gt;
&lt;br /&gt;
No other modules are required for this module.&lt;br /&gt;
&lt;br /&gt;
===Limitations===&lt;br /&gt;
&lt;br /&gt;
The module uses an [http://www.itk.org/Doxygen/html/classitk_1_1OrientImageFilter.html itkOrientImageFilter] to realign the fixed and moving images to axial before registration.  This is required due to limitations in [http://www.itk.org/Wiki/Proposals:Orientation ITK's handling] of non-axial images in filters used by registration.&lt;br /&gt;
&lt;br /&gt;
===Known bugs===&lt;br /&gt;
&lt;br /&gt;
None.  To report bugs, follow this [http://na-mic.org/Mantis/main_page.php link] to the Slicer3 bug tracker. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Usability issues===&lt;br /&gt;
&lt;br /&gt;
Follow this [http://na-mic.org/Mantis/main_page.php link] to the Slicer3 bug tracker. Please select the '''usability issue category''' when browsing or contributing.&lt;br /&gt;
&lt;br /&gt;
===Source code &amp;amp; documentation===&lt;br /&gt;
&lt;br /&gt;
Source Code: [http://www.na-mic.org/ViewVC/index.cgi/trunk/Applications/CLI/AffineRegistration.cxx | C++ Source] and [http://www.na-mic.org/ViewVC/index.cgi/trunk/Applications/CLI/AffineRegistration.xml | XML Description]&lt;br /&gt;
&lt;br /&gt;
Documentation:&lt;br /&gt;
&lt;br /&gt;
== More Information == &lt;br /&gt;
&lt;br /&gt;
===Acknowledgment===&lt;br /&gt;
This work is part of the National Alliance for Medical Image&lt;br /&gt;
Computing (NAMIC), funded by the National Institutes of Health&lt;br /&gt;
through the NIH Roadmap for Medical Research, Grant U54 EB005149.&lt;br /&gt;
Information on the National Centers for Biomedical Computing&lt;br /&gt;
can be obtained from [http://www.ncbcs.org/ National Centers for Biomedical Computing].&lt;br /&gt;
&lt;br /&gt;
===References===&lt;br /&gt;
D. Mattes, D.R. Haynor, H. Vesselle, T.K. Lewellen, and  W. Eubank. PET-CT image registration in the chest using  free-form deformations. ''IEEE Transactions on Medical Imaging'',  22(1):120–128, 2003.&lt;/div&gt;</summary>
		<author><name>Blezek</name></author>
		
	</entry>
	<entry>
		<id>https://www.slicer.org/w/index.php?title=Modules:AffineRegistration-Documentation-3.4&amp;diff=8262</id>
		<title>Modules:AffineRegistration-Documentation-3.4</title>
		<link rel="alternate" type="text/html" href="https://www.slicer.org/w/index.php?title=Modules:AffineRegistration-Documentation-3.4&amp;diff=8262"/>
		<updated>2009-03-02T03:01:32Z</updated>

		<summary type="html">&lt;p&gt;Blezek: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt; [[Documentation-3.4|Return to Slicer 3.4 Documentation]]&lt;br /&gt;
__NOTOC__&lt;br /&gt;
===Affine Registration===&lt;br /&gt;
Affine Registration&lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
|[[Image:screenshotBlank.png|thumb|280px|Caption 1]]&lt;br /&gt;
|[[Image:screenshotBlank.png|thumb|280px|Caption 2]]&lt;br /&gt;
|[[Image:screenshotBlank.png|thumb|280px|Caption 3]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== General Information ==&lt;br /&gt;
===Module Type &amp;amp; Category===&lt;br /&gt;
&lt;br /&gt;
Type: CLI&lt;br /&gt;
&lt;br /&gt;
Category: Registration&lt;br /&gt;
&lt;br /&gt;
===Authors, Collaborators &amp;amp; Contact===&lt;br /&gt;
* Author: Daniel Blezek&lt;br /&gt;
* Contact: daniel.blezek at gmail.com&lt;br /&gt;
&lt;br /&gt;
===Module Description===&lt;br /&gt;
This command line module implements a registration algorithm based on the Mattes mutual information registration metric and the affine transformation.  Both the fixed and moving images may be optionally smoothed before registration.&lt;br /&gt;
&lt;br /&gt;
== Usage ==&lt;br /&gt;
&lt;br /&gt;
===Examples, Use Cases &amp;amp; Tutorials===&lt;br /&gt;
&lt;br /&gt;
* This module is often used to align images of different subjects.&lt;br /&gt;
* The affine transformation allows a limited degree of deformation and frequently is used as a pre-processing step for higher order transformations such as the [[Modules:DeformableB-SplineRegistration-Documentation-3.4|BSpline]] and [[Modules:DiffeomorphicDemonsAlgorithm-Documentation03.4| Demons]].&lt;br /&gt;
&lt;br /&gt;
===Quick Tour of Features and Use===&lt;br /&gt;
List all the panels in your interface, their features, what they mean, and how to use them. For instance:&lt;br /&gt;
&lt;br /&gt;
* '''Input panel:'''&lt;br /&gt;
* '''Parameters panel:'''&lt;br /&gt;
* '''Output panel:'''&lt;br /&gt;
* '''Viewing panel:'''&lt;br /&gt;
&lt;br /&gt;
== Development ==&lt;br /&gt;
&lt;br /&gt;
===Dependencies===&lt;br /&gt;
&lt;br /&gt;
No other modules are required for this module.&lt;br /&gt;
&lt;br /&gt;
===Limitations===&lt;br /&gt;
&lt;br /&gt;
The module uses an itkOrientImageFilter to realign the fixed and moving images to axial before registration.  This is required due to limitations in ITK's handling of non-axial images in filters used by registration.&lt;br /&gt;
&lt;br /&gt;
===Known bugs===&lt;br /&gt;
&lt;br /&gt;
None.  To report bugs, follow this [http://na-mic.org/Mantis/main_page.php link] to the Slicer3 bug tracker. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Usability issues===&lt;br /&gt;
&lt;br /&gt;
Follow this [http://na-mic.org/Mantis/main_page.php link] to the Slicer3 bug tracker. Please select the '''usability issue category''' when browsing or contributing.&lt;br /&gt;
&lt;br /&gt;
===Source code &amp;amp; documentation===&lt;br /&gt;
&lt;br /&gt;
Source Code: [http://www.na-mic.org/ViewVC/index.cgi/trunk/Applications/CLI/AffineRegistration.cxx | C++ Source] and [http://www.na-mic.org/ViewVC/index.cgi/trunk/Applications/CLI/AffineRegistration.xml | XML Description]&lt;br /&gt;
&lt;br /&gt;
Documentation:&lt;br /&gt;
&lt;br /&gt;
== More Information == &lt;br /&gt;
&lt;br /&gt;
===Acknowledgment===&lt;br /&gt;
This work is part of the National Alliance for Medical Image&lt;br /&gt;
Computing (NAMIC), funded by the National Institutes of Health&lt;br /&gt;
through the NIH Roadmap for Medical Research, Grant U54 EB005149.&lt;br /&gt;
Information on the National Centers for Biomedical Computing&lt;br /&gt;
can be obtained from [http://www.ncbcs.org/ National Centers for Biomedical Computing].&lt;br /&gt;
&lt;br /&gt;
===References===&lt;br /&gt;
D. Mattes, D.R. Haynor, H. Vesselle, T.K. Lewellen, and  W. Eubank. PET-CT image registration in the chest using  free-form deformations. ''IEEE Transactions on Medical Imaging'',  22(1):120–128, 2003.&lt;/div&gt;</summary>
		<author><name>Blezek</name></author>
		
	</entry>
	<entry>
		<id>https://www.slicer.org/w/index.php?title=Modules:AffineRegistration-Documentation-3.4&amp;diff=8261</id>
		<title>Modules:AffineRegistration-Documentation-3.4</title>
		<link rel="alternate" type="text/html" href="https://www.slicer.org/w/index.php?title=Modules:AffineRegistration-Documentation-3.4&amp;diff=8261"/>
		<updated>2009-03-02T02:49:14Z</updated>

		<summary type="html">&lt;p&gt;Blezek: New page:  Return to Slicer 3.4 Documentation __NOTOC__ ===Affine Registration=== Affine Registration  {| |Caption 1 |[[Image:screensh...&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt; [[Documentation-3.4|Return to Slicer 3.4 Documentation]]&lt;br /&gt;
__NOTOC__&lt;br /&gt;
===Affine Registration===&lt;br /&gt;
Affine Registration&lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
|[[Image:screenshotBlank.png|thumb|280px|Caption 1]]&lt;br /&gt;
|[[Image:screenshotBlank.png|thumb|280px|Caption 2]]&lt;br /&gt;
|[[Image:screenshotBlank.png|thumb|280px|Caption 3]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== General Information ==&lt;br /&gt;
===Module Type &amp;amp; Category===&lt;br /&gt;
&lt;br /&gt;
Type: CLI&lt;br /&gt;
&lt;br /&gt;
Category: Registration&lt;br /&gt;
&lt;br /&gt;
===Authors, Collaborators &amp;amp; Contact===&lt;br /&gt;
* Author: Daniel Blezek&lt;br /&gt;
* Contact: daniel.blezek at gmail.com&lt;br /&gt;
&lt;br /&gt;
===Module Description===&lt;br /&gt;
This command line module implements a registration algorithm based on the Mattes mutual information registration metric and the affine transformation.  Both the fixed and moving images may be optionally smoothed before registration.&lt;br /&gt;
&lt;br /&gt;
== Usage ==&lt;br /&gt;
&lt;br /&gt;
===Examples, Use Cases &amp;amp; Tutorials===&lt;br /&gt;
&lt;br /&gt;
* This module is often used to align images of different subjects.&lt;br /&gt;
* The affine transformation allows a limited degree of deformation and frequently is used as a pre-processing step for higher order transformations such as the [[Modules:DeformableB-SplineRegistration-Documentation-3.4 BSpline]] and [[Modules:DiffeomorphicDemonsAlgorithm-Documentation03.4 Demons]].&lt;br /&gt;
&lt;br /&gt;
===Quick Tour of Features and Use===&lt;br /&gt;
List all the panels in your interface, their features, what they mean, and how to use them. For instance:&lt;br /&gt;
&lt;br /&gt;
* '''Input panel:'''&lt;br /&gt;
* '''Parameters panel:'''&lt;br /&gt;
* '''Output panel:'''&lt;br /&gt;
* '''Viewing panel:'''&lt;br /&gt;
&lt;br /&gt;
== Development ==&lt;br /&gt;
&lt;br /&gt;
===Dependencies===&lt;br /&gt;
&lt;br /&gt;
No other modules are required for this module.&lt;br /&gt;
&lt;br /&gt;
===Known bugs===&lt;br /&gt;
&lt;br /&gt;
Follow this [http://na-mic.org/Mantis/main_page.php link] to the Slicer3 bug tracker. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Usability issues===&lt;br /&gt;
&lt;br /&gt;
Follow this [http://na-mic.org/Mantis/main_page.php link] to the Slicer3 bug tracker. Please select the '''usability issue category''' when browsing or contributing.&lt;br /&gt;
&lt;br /&gt;
===Source code &amp;amp; documentation===&lt;br /&gt;
&lt;br /&gt;
Source Code: [http://www.na-mic.org/ViewVC/index.cgi/trunk/Applications/CLI/]&lt;br /&gt;
&lt;br /&gt;
Documentation:&lt;br /&gt;
&lt;br /&gt;
== More Information == &lt;br /&gt;
&lt;br /&gt;
===Acknowledgment===&lt;br /&gt;
This work is part of the National Alliance for Medical Image&lt;br /&gt;
Computing (NAMIC), funded by the National Institutes of Health&lt;br /&gt;
through the NIH Roadmap for Medical Research, Grant U54 EB005149.&lt;br /&gt;
Information on the National Centers for Biomedical Computing&lt;br /&gt;
can be obtained from [http://www.ncbcs.org/ National Centers for Biomedical Computing].&lt;br /&gt;
&lt;br /&gt;
===References===&lt;/div&gt;</summary>
		<author><name>Blezek</name></author>
		
	</entry>
	<entry>
		<id>https://www.slicer.org/w/index.php?title=File:MatplotlibExample.png&amp;diff=6029</id>
		<title>File:MatplotlibExample.png</title>
		<link rel="alternate" type="text/html" href="https://www.slicer.org/w/index.php?title=File:MatplotlibExample.png&amp;diff=6029"/>
		<updated>2008-08-18T03:21:21Z</updated>

		<summary type="html">&lt;p&gt;Blezek: uploaded a new version of &amp;quot;Image:MatplotlibExample.png&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Blezek</name></author>
		
	</entry>
	<entry>
		<id>https://www.slicer.org/w/index.php?title=Slicer3:Python&amp;diff=6028</id>
		<title>Slicer3:Python</title>
		<link rel="alternate" type="text/html" href="https://www.slicer.org/w/index.php?title=Slicer3:Python&amp;diff=6028"/>
		<updated>2008-08-18T03:20:39Z</updated>

		<summary type="html">&lt;p&gt;Blezek: /* Matplotlib plotting functionality */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Status of Python in Slicer ==&lt;br /&gt;
In post-3.2 Slicer3, Python support is currently disabled by default.  However, it is easy to enable and should compile on all tested platform (Mac, Windows, Linux).  Though [http://matplotlib.sourceforge.net/ matplotlib] is still not properly interacting with Slicer3, NumPy and Python support should work well for all platforms.  [[Slicer3:Execution_Model_Documentation:Python | Python command line modules]] are well supported, as is building full [[Modules:Python | GUI modules in Python]].&lt;br /&gt;
&lt;br /&gt;
== Python for scientific computing ==&lt;br /&gt;
Python has a fairly comprehensive package for scientific computing called [http://scipy.org SciPy].  Of main interest to Slicer users/developers is [http://numpy.scipy.org NumPy].  NumPy provides most of the features of the Matlab image processing toolbox and numeric computations, but in an Open Source package.  A compelling reason to use NumPy is the ease of interaction and integration with Slicer3.&lt;br /&gt;
&lt;br /&gt;
== Slicer3 and Python ==&lt;br /&gt;
==== Enabling Python in the Slicer Build====&lt;br /&gt;
# Edit slicer_variables.tcl&lt;br /&gt;
## Change &amp;quot;set ::USE_PYTHON &amp;quot;off&amp;quot;&amp;quot; to &amp;quot;on&amp;quot;&lt;br /&gt;
# '''Optional:''' If you prefer to use your system Python installation, change set ::USE_SYSTEM_PYTHON &amp;quot;false&amp;quot; to &amp;quot;true&amp;quot;&lt;br /&gt;
## This will give an error under Linux and Windows, but it can be easily fixed by adding the system path for Python, just search for &amp;quot;if { $::USE_SYSTEM_PYTHON } {&amp;quot;&lt;br /&gt;
# '''Optional:''' installing SciPy&lt;br /&gt;
## [http://sourceforge.net/project/showfiles.php?group_id=27747 Download] the scipy egg for your platform&lt;br /&gt;
## Unzip the egg in any directory that is part of Slicer's Python path, eg Slicer3-build/lib/Slicer3/Plugins&lt;br /&gt;
## SciPy should now be available in Slicer's Python interpreter&lt;br /&gt;
&lt;br /&gt;
Build Slicer3 using &amp;quot;getbuildtest.tcl&amp;quot;, i.e.:&lt;br /&gt;
&lt;br /&gt;
 Macintosh:Slicer3 blezek$ Scripts/getbuildtest.tcl&lt;br /&gt;
&lt;br /&gt;
A new menu command '''Python Interpreter''' should appear on the Window menu.&lt;br /&gt;
&lt;br /&gt;
[[Image:PythonMenu.png]]&lt;br /&gt;
&lt;br /&gt;
This command should bring up the '''Python Console''' window.&lt;br /&gt;
&lt;br /&gt;
[[Image:PythonConsole.png]]&lt;br /&gt;
&lt;br /&gt;
== Basic Slicer/Python tutorial ==&lt;br /&gt;
''Note: this is initial documentation only, and is subject to change as the API evolves.''&lt;br /&gt;
&lt;br /&gt;
The Slicer Python interpreter has access to all Python modules referenced by the environment variable '''PYTHONPATH''' as well as the '''Slicer''' internal module.  The '''Slicer''' module also supports the interface between Slicer Volume Nodes and NumPy.  It would be instructive for the reader to review the [http://www.scipy.org/Documentation NumPy documentation].  For serious users of NumPy, there is the [http://www.tramy.us/ ''Guide to NumPy''] by Travis Oliphant for purchase.&lt;br /&gt;
&lt;br /&gt;
The main interface to Slicer from Python is through the Slicer Python module.  From there, the Python user can access any of Slicer's global objects and MRML tree.  For example:&lt;br /&gt;
&lt;br /&gt;
  &amp;gt;&amp;gt;&amp;gt; import Slicer&lt;br /&gt;
  &amp;gt;&amp;gt;&amp;gt; Slicer.slicer&lt;br /&gt;
  &amp;lt;Slicer.Slicer object at 0x9f325f0&amp;gt;&lt;br /&gt;
  &amp;gt;&amp;gt;&amp;gt; Slicer.slicer.MRMLScene.GetNumberOfNodesByClass ( 'vtkMRMLVolumeNode' )&lt;br /&gt;
  0&lt;br /&gt;
  &amp;gt;&amp;gt;&amp;gt; &lt;br /&gt;
&lt;br /&gt;
In this case, no 'vtkMRMLVolumeNode's were loaded into Slicer.&lt;br /&gt;
&lt;br /&gt;
VTK objects may be easily constructed.&lt;br /&gt;
&lt;br /&gt;
 &amp;gt;&amp;gt;&amp;gt; a = Slicer.slicer.vtkPolyData()&lt;br /&gt;
 &amp;gt;&amp;gt;&amp;gt; help ( a )&lt;br /&gt;
 Help on vtkPolyData in module Slicer object:&lt;br /&gt;
 &lt;br /&gt;
 class vtkPolyData(vtkPointSet)&lt;br /&gt;
  |  Method resolution order:&lt;br /&gt;
  |      vtkPolyData&lt;br /&gt;
  |      vtkPointSet&lt;br /&gt;
  |      vtkDataSet&lt;br /&gt;
  &amp;lt;output truncated&amp;gt;&lt;br /&gt;
&lt;br /&gt;
VTK objects created in this manner conform as closely as possible to the VTK Python bindings, but must be created through the slicer object inside the Slicer module.  Each object may be fully subclassed following the [http://www.onlamp.com/pub/a/python/2003/04/17/metaclasses.html meta object pattern].&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== NumPy tutorial ====&lt;br /&gt;
Python and NumPy give direct access to the volume data in Slicer by wrapping the image data in a NumPy '''array''' object through the '''.ToArray()''' method on the volume node.  This tutorial assumes you have installed [http://scipy.org/Download SciPy].&lt;br /&gt;
&lt;br /&gt;
 &amp;gt;&amp;gt;&amp;gt; # Access the image data directly&lt;br /&gt;
 &amp;gt;&amp;gt;&amp;gt; data = t2.GetImageData().ToArray()&lt;br /&gt;
 &amp;gt;&amp;gt;&amp;gt; print data&lt;br /&gt;
 [[[ 0  0  0 ...,  0  0  0]&lt;br /&gt;
   [ 0  0  1 ...,  0  1  0]&lt;br /&gt;
   [ 0  0  0 ...,  0  0  0]&lt;br /&gt;
   ..., &lt;br /&gt;
   [ 0  8  0 ...,  0  1  2]&lt;br /&gt;
   [ 0  0  0 ...,  4  1  2]&lt;br /&gt;
   [ 0  0  2 ...,  6  0  2]]&lt;br /&gt;
 &lt;br /&gt;
 &amp;lt;&amp;lt;&amp;lt; Some output truncated &amp;gt;&amp;gt;&amp;gt; &lt;br /&gt;
 &lt;br /&gt;
  [[ 0  0  0 ...,  0  0  0]&lt;br /&gt;
   [ 0  0  0 ...,  0  0  0]&lt;br /&gt;
   [ 0  0  0 ...,  0  0  0]&lt;br /&gt;
   ..., &lt;br /&gt;
   [ 0  3  3 ...,  0  0  8]&lt;br /&gt;
   [ 0  6  0 ...,  5  3 13]&lt;br /&gt;
   [ 0  5  1 ...,  9  3  8]]]&lt;br /&gt;
 &amp;gt;&amp;gt;&amp;gt; # Load the image filtering package from scipy&lt;br /&gt;
 &amp;gt;&amp;gt;&amp;gt; import scipy.ndimage&lt;br /&gt;
 &amp;gt;&amp;gt;&amp;gt; # Filter into a new array&lt;br /&gt;
 &amp;gt;&amp;gt;&amp;gt; temp = scipy.ndimage.gaussian_filter ( data, 2.0 )&lt;br /&gt;
 &amp;gt;&amp;gt;&amp;gt; # Copy back into Slicer&lt;br /&gt;
 &amp;gt;&amp;gt;&amp;gt; data[:] = temp[:]&lt;br /&gt;
 &amp;gt;&amp;gt;&amp;gt; t2.Modified()&lt;br /&gt;
&lt;br /&gt;
Before:&lt;br /&gt;
&lt;br /&gt;
[[Image:PythonBefore.png]]&lt;br /&gt;
&lt;br /&gt;
After:&lt;br /&gt;
&lt;br /&gt;
[[Image:PythonAfter.png]]&lt;br /&gt;
&lt;br /&gt;
== Matplotlib plotting functionality ==&lt;br /&gt;
Matplotlib may be used from within Slicer, but currently (on the Mac) the Tk backend locks up and crashes Slicer.  However, Matplotlib may still be used through one of the non-GUI backends.  More details can be found on the [http://matplotlib.sourceforge.net/ MatPlotLib]&lt;br /&gt;
 pages.&lt;br /&gt;
&lt;br /&gt;
 import matplotlib&lt;br /&gt;
 matplotlib.use ( 'Agg' )&lt;br /&gt;
 from pylab import *&lt;br /&gt;
&lt;br /&gt;
 t1 = arange(0.0, 5.0, 0.1)&lt;br /&gt;
 t2 = arange(0.0, 5.0, 0.02)&lt;br /&gt;
 t3 = arange(0.0, 2.0, 0.01) &lt;br /&gt;
 &lt;br /&gt;
 subplot(211)&lt;br /&gt;
 plot(t1, cos(2*pi*t1)*exp(-t1), 'bo', t2, cos(2*pi*t2)*exp(-t2), 'k')&lt;br /&gt;
 grid(True)&lt;br /&gt;
 title('A tale of 2 subplots')&lt;br /&gt;
 ylabel('Damped')&lt;br /&gt;
 &lt;br /&gt;
 subplot(212)&lt;br /&gt;
 plot(t3, cos(2*pi*t3), 'r--')&lt;br /&gt;
 grid(True)&lt;br /&gt;
 xlabel('time (s)')&lt;br /&gt;
 ylabel('Undamped')&lt;br /&gt;
 savefig ( 'MatplotlibExample.png' )&lt;br /&gt;
&lt;br /&gt;
[[Image:MatplotlibExample.png]]&lt;br /&gt;
&lt;br /&gt;
== Where to go from here ==&lt;br /&gt;
Far from exhaustive, this documentation is intended to whet the appitite of researchers who love the power of Matlab, but feel trapped inside, unable to break out and deploy applications.  This Python interface to Slicer is intended to help!  Here are some selected resources to begin to understand the power of what the combined NumPy - Slicer package offers.&lt;br /&gt;
&lt;br /&gt;
* [http://www.python.org/doc/ Python documentation]&lt;br /&gt;
** [http://www.rexx.com/~dkuhlman/python_101/python_101.html Gentle introduction to Python]&lt;br /&gt;
** [http://www.python.org/doc/Intros.html Python introduction]&lt;br /&gt;
* [http://www.scipy.org/NumPy NumPy documentation]&lt;br /&gt;
** [http://www.trelgol.com/ Comprehensive ''Guide to NumPy''] by the current maintainer&lt;br /&gt;
** [http://numeric.scipy.org/numpydoc/numdoc.htm Old NumPy documentation] ([http://numeric.scipy.org/numpy.pdf pdf])&lt;br /&gt;
* [http://www.scipy.org SciPy] [http://scipy.org/Documentation Documentation]&lt;br /&gt;
* [http://matplotlib.sourceforge.net/ MatPlotLib]&lt;/div&gt;</summary>
		<author><name>Blezek</name></author>
		
	</entry>
	<entry>
		<id>https://www.slicer.org/w/index.php?title=File:MatplotlibExample.png&amp;diff=6027</id>
		<title>File:MatplotlibExample.png</title>
		<link rel="alternate" type="text/html" href="https://www.slicer.org/w/index.php?title=File:MatplotlibExample.png&amp;diff=6027"/>
		<updated>2008-08-18T03:15:45Z</updated>

		<summary type="html">&lt;p&gt;Blezek: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Blezek</name></author>
		
	</entry>
	<entry>
		<id>https://www.slicer.org/w/index.php?title=Slicer3:Python&amp;diff=6026</id>
		<title>Slicer3:Python</title>
		<link rel="alternate" type="text/html" href="https://www.slicer.org/w/index.php?title=Slicer3:Python&amp;diff=6026"/>
		<updated>2008-08-18T03:14:19Z</updated>

		<summary type="html">&lt;p&gt;Blezek: /* Where to go from here */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Status of Python in Slicer ==&lt;br /&gt;
In post-3.2 Slicer3, Python support is currently disabled by default.  However, it is easy to enable and should compile on all tested platform (Mac, Windows, Linux).  Though [http://matplotlib.sourceforge.net/ matplotlib] is still not properly interacting with Slicer3, NumPy and Python support should work well for all platforms.  [[Slicer3:Execution_Model_Documentation:Python | Python command line modules]] are well supported, as is building full [[Modules:Python | GUI modules in Python]].&lt;br /&gt;
&lt;br /&gt;
== Python for scientific computing ==&lt;br /&gt;
Python has a fairly comprehensive package for scientific computing called [http://scipy.org SciPy].  Of main interest to Slicer users/developers is [http://numpy.scipy.org NumPy].  NumPy provides most of the features of the Matlab image processing toolbox and numeric computations, but in an Open Source package.  A compelling reason to use NumPy is the ease of interaction and integration with Slicer3.&lt;br /&gt;
&lt;br /&gt;
== Slicer3 and Python ==&lt;br /&gt;
==== Enabling Python in the Slicer Build====&lt;br /&gt;
# Edit slicer_variables.tcl&lt;br /&gt;
## Change &amp;quot;set ::USE_PYTHON &amp;quot;off&amp;quot;&amp;quot; to &amp;quot;on&amp;quot;&lt;br /&gt;
# '''Optional:''' If you prefer to use your system Python installation, change set ::USE_SYSTEM_PYTHON &amp;quot;false&amp;quot; to &amp;quot;true&amp;quot;&lt;br /&gt;
## This will give an error under Linux and Windows, but it can be easily fixed by adding the system path for Python, just search for &amp;quot;if { $::USE_SYSTEM_PYTHON } {&amp;quot;&lt;br /&gt;
# '''Optional:''' installing SciPy&lt;br /&gt;
## [http://sourceforge.net/project/showfiles.php?group_id=27747 Download] the scipy egg for your platform&lt;br /&gt;
## Unzip the egg in any directory that is part of Slicer's Python path, eg Slicer3-build/lib/Slicer3/Plugins&lt;br /&gt;
## SciPy should now be available in Slicer's Python interpreter&lt;br /&gt;
&lt;br /&gt;
Build Slicer3 using &amp;quot;getbuildtest.tcl&amp;quot;, i.e.:&lt;br /&gt;
&lt;br /&gt;
 Macintosh:Slicer3 blezek$ Scripts/getbuildtest.tcl&lt;br /&gt;
&lt;br /&gt;
A new menu command '''Python Interpreter''' should appear on the Window menu.&lt;br /&gt;
&lt;br /&gt;
[[Image:PythonMenu.png]]&lt;br /&gt;
&lt;br /&gt;
This command should bring up the '''Python Console''' window.&lt;br /&gt;
&lt;br /&gt;
[[Image:PythonConsole.png]]&lt;br /&gt;
&lt;br /&gt;
== Basic Slicer/Python tutorial ==&lt;br /&gt;
''Note: this is initial documentation only, and is subject to change as the API evolves.''&lt;br /&gt;
&lt;br /&gt;
The Slicer Python interpreter has access to all Python modules referenced by the environment variable '''PYTHONPATH''' as well as the '''Slicer''' internal module.  The '''Slicer''' module also supports the interface between Slicer Volume Nodes and NumPy.  It would be instructive for the reader to review the [http://www.scipy.org/Documentation NumPy documentation].  For serious users of NumPy, there is the [http://www.tramy.us/ ''Guide to NumPy''] by Travis Oliphant for purchase.&lt;br /&gt;
&lt;br /&gt;
The main interface to Slicer from Python is through the Slicer Python module.  From there, the Python user can access any of Slicer's global objects and MRML tree.  For example:&lt;br /&gt;
&lt;br /&gt;
  &amp;gt;&amp;gt;&amp;gt; import Slicer&lt;br /&gt;
  &amp;gt;&amp;gt;&amp;gt; Slicer.slicer&lt;br /&gt;
  &amp;lt;Slicer.Slicer object at 0x9f325f0&amp;gt;&lt;br /&gt;
  &amp;gt;&amp;gt;&amp;gt; Slicer.slicer.MRMLScene.GetNumberOfNodesByClass ( 'vtkMRMLVolumeNode' )&lt;br /&gt;
  0&lt;br /&gt;
  &amp;gt;&amp;gt;&amp;gt; &lt;br /&gt;
&lt;br /&gt;
In this case, no 'vtkMRMLVolumeNode's were loaded into Slicer.&lt;br /&gt;
&lt;br /&gt;
VTK objects may be easily constructed.&lt;br /&gt;
&lt;br /&gt;
 &amp;gt;&amp;gt;&amp;gt; a = Slicer.slicer.vtkPolyData()&lt;br /&gt;
 &amp;gt;&amp;gt;&amp;gt; help ( a )&lt;br /&gt;
 Help on vtkPolyData in module Slicer object:&lt;br /&gt;
 &lt;br /&gt;
 class vtkPolyData(vtkPointSet)&lt;br /&gt;
  |  Method resolution order:&lt;br /&gt;
  |      vtkPolyData&lt;br /&gt;
  |      vtkPointSet&lt;br /&gt;
  |      vtkDataSet&lt;br /&gt;
  &amp;lt;output truncated&amp;gt;&lt;br /&gt;
&lt;br /&gt;
VTK objects created in this manner conform as closely as possible to the VTK Python bindings, but must be created through the slicer object inside the Slicer module.  Each object may be fully subclassed following the [http://www.onlamp.com/pub/a/python/2003/04/17/metaclasses.html meta object pattern].&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== NumPy tutorial ====&lt;br /&gt;
Python and NumPy give direct access to the volume data in Slicer by wrapping the image data in a NumPy '''array''' object through the '''.ToArray()''' method on the volume node.  This tutorial assumes you have installed [http://scipy.org/Download SciPy].&lt;br /&gt;
&lt;br /&gt;
 &amp;gt;&amp;gt;&amp;gt; # Access the image data directly&lt;br /&gt;
 &amp;gt;&amp;gt;&amp;gt; data = t2.GetImageData().ToArray()&lt;br /&gt;
 &amp;gt;&amp;gt;&amp;gt; print data&lt;br /&gt;
 [[[ 0  0  0 ...,  0  0  0]&lt;br /&gt;
   [ 0  0  1 ...,  0  1  0]&lt;br /&gt;
   [ 0  0  0 ...,  0  0  0]&lt;br /&gt;
   ..., &lt;br /&gt;
   [ 0  8  0 ...,  0  1  2]&lt;br /&gt;
   [ 0  0  0 ...,  4  1  2]&lt;br /&gt;
   [ 0  0  2 ...,  6  0  2]]&lt;br /&gt;
 &lt;br /&gt;
 &amp;lt;&amp;lt;&amp;lt; Some output truncated &amp;gt;&amp;gt;&amp;gt; &lt;br /&gt;
 &lt;br /&gt;
  [[ 0  0  0 ...,  0  0  0]&lt;br /&gt;
   [ 0  0  0 ...,  0  0  0]&lt;br /&gt;
   [ 0  0  0 ...,  0  0  0]&lt;br /&gt;
   ..., &lt;br /&gt;
   [ 0  3  3 ...,  0  0  8]&lt;br /&gt;
   [ 0  6  0 ...,  5  3 13]&lt;br /&gt;
   [ 0  5  1 ...,  9  3  8]]]&lt;br /&gt;
 &amp;gt;&amp;gt;&amp;gt; # Load the image filtering package from scipy&lt;br /&gt;
 &amp;gt;&amp;gt;&amp;gt; import scipy.ndimage&lt;br /&gt;
 &amp;gt;&amp;gt;&amp;gt; # Filter into a new array&lt;br /&gt;
 &amp;gt;&amp;gt;&amp;gt; temp = scipy.ndimage.gaussian_filter ( data, 2.0 )&lt;br /&gt;
 &amp;gt;&amp;gt;&amp;gt; # Copy back into Slicer&lt;br /&gt;
 &amp;gt;&amp;gt;&amp;gt; data[:] = temp[:]&lt;br /&gt;
 &amp;gt;&amp;gt;&amp;gt; t2.Modified()&lt;br /&gt;
&lt;br /&gt;
Before:&lt;br /&gt;
&lt;br /&gt;
[[Image:PythonBefore.png]]&lt;br /&gt;
&lt;br /&gt;
After:&lt;br /&gt;
&lt;br /&gt;
[[Image:PythonAfter.png]]&lt;br /&gt;
&lt;br /&gt;
== Matplotlib plotting functionality ==&lt;br /&gt;
Matplotlib may be used from within Slicer, but currently (on the Mac) the Tk backend locks up and crashes Slicer.  However, Matplotlib may still be used through one of the non-GUI backends.  More details can be found on the [http://matplotlib.sourceforge.net/ MatPlotLib]&lt;br /&gt;
 pages.&lt;br /&gt;
&lt;br /&gt;
 import matplotlib&lt;br /&gt;
 matplotlib.use ( 'Agg' )&lt;br /&gt;
 from pylab import *&lt;br /&gt;
&lt;br /&gt;
 t1 = arange(0.0, 5.0, 0.1)&lt;br /&gt;
 t2 = arange(0.0, 5.0, 0.02)&lt;br /&gt;
 t3 = arange(0.0, 2.0, 0.01) &lt;br /&gt;
 &lt;br /&gt;
 subplot(211)&lt;br /&gt;
 plot(t1, cos(2*pi*t1)*exp(-t1), 'bo', t2, cos(2*pi*t2)*exp(-t2), 'k')&lt;br /&gt;
 grid(True)&lt;br /&gt;
 title('A tale of 2 subplots')&lt;br /&gt;
 ylabel('Damped')&lt;br /&gt;
 &lt;br /&gt;
 subplot(212)&lt;br /&gt;
 plot(t3, cos(2*pi*t3), 'r--')&lt;br /&gt;
 grid(True)&lt;br /&gt;
 xlabel('time (s)')&lt;br /&gt;
 ylabel('Undamped')&lt;br /&gt;
 savefig ( 'MatplotlibExample.png' )&lt;br /&gt;
&lt;br /&gt;
[[Media:MatplotlibExample.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Where to go from here ==&lt;br /&gt;
Far from exhaustive, this documentation is intended to whet the appitite of researchers who love the power of Matlab, but feel trapped inside, unable to break out and deploy applications.  This Python interface to Slicer is intended to help!  Here are some selected resources to begin to understand the power of what the combined NumPy - Slicer package offers.&lt;br /&gt;
&lt;br /&gt;
* [http://www.python.org/doc/ Python documentation]&lt;br /&gt;
** [http://www.rexx.com/~dkuhlman/python_101/python_101.html Gentle introduction to Python]&lt;br /&gt;
** [http://www.python.org/doc/Intros.html Python introduction]&lt;br /&gt;
* [http://www.scipy.org/NumPy NumPy documentation]&lt;br /&gt;
** [http://www.trelgol.com/ Comprehensive ''Guide to NumPy''] by the current maintainer&lt;br /&gt;
** [http://numeric.scipy.org/numpydoc/numdoc.htm Old NumPy documentation] ([http://numeric.scipy.org/numpy.pdf pdf])&lt;br /&gt;
* [http://www.scipy.org SciPy] [http://scipy.org/Documentation Documentation]&lt;br /&gt;
* [http://matplotlib.sourceforge.net/ MatPlotLib]&lt;/div&gt;</summary>
		<author><name>Blezek</name></author>
		
	</entry>
	<entry>
		<id>https://www.slicer.org/w/index.php?title=Slicer3:Python&amp;diff=6025</id>
		<title>Slicer3:Python</title>
		<link rel="alternate" type="text/html" href="https://www.slicer.org/w/index.php?title=Slicer3:Python&amp;diff=6025"/>
		<updated>2008-08-18T02:55:26Z</updated>

		<summary type="html">&lt;p&gt;Blezek: /* Enabling Python in the Slicer Build */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Status of Python in Slicer ==&lt;br /&gt;
In post-3.2 Slicer3, Python support is currently disabled by default.  However, it is easy to enable and should compile on all tested platform (Mac, Windows, Linux).  Though [http://matplotlib.sourceforge.net/ matplotlib] is still not properly interacting with Slicer3, NumPy and Python support should work well for all platforms.  [[Slicer3:Execution_Model_Documentation:Python | Python command line modules]] are well supported, as is building full [[Modules:Python | GUI modules in Python]].&lt;br /&gt;
&lt;br /&gt;
== Python for scientific computing ==&lt;br /&gt;
Python has a fairly comprehensive package for scientific computing called [http://scipy.org SciPy].  Of main interest to Slicer users/developers is [http://numpy.scipy.org NumPy].  NumPy provides most of the features of the Matlab image processing toolbox and numeric computations, but in an Open Source package.  A compelling reason to use NumPy is the ease of interaction and integration with Slicer3.&lt;br /&gt;
&lt;br /&gt;
== Slicer3 and Python ==&lt;br /&gt;
==== Enabling Python in the Slicer Build====&lt;br /&gt;
# Edit slicer_variables.tcl&lt;br /&gt;
## Change &amp;quot;set ::USE_PYTHON &amp;quot;off&amp;quot;&amp;quot; to &amp;quot;on&amp;quot;&lt;br /&gt;
# '''Optional:''' If you prefer to use your system Python installation, change set ::USE_SYSTEM_PYTHON &amp;quot;false&amp;quot; to &amp;quot;true&amp;quot;&lt;br /&gt;
## This will give an error under Linux and Windows, but it can be easily fixed by adding the system path for Python, just search for &amp;quot;if { $::USE_SYSTEM_PYTHON } {&amp;quot;&lt;br /&gt;
# '''Optional:''' installing SciPy&lt;br /&gt;
## [http://sourceforge.net/project/showfiles.php?group_id=27747 Download] the scipy egg for your platform&lt;br /&gt;
## Unzip the egg in any directory that is part of Slicer's Python path, eg Slicer3-build/lib/Slicer3/Plugins&lt;br /&gt;
## SciPy should now be available in Slicer's Python interpreter&lt;br /&gt;
&lt;br /&gt;
Build Slicer3 using &amp;quot;getbuildtest.tcl&amp;quot;, i.e.:&lt;br /&gt;
&lt;br /&gt;
 Macintosh:Slicer3 blezek$ Scripts/getbuildtest.tcl&lt;br /&gt;
&lt;br /&gt;
A new menu command '''Python Interpreter''' should appear on the Window menu.&lt;br /&gt;
&lt;br /&gt;
[[Image:PythonMenu.png]]&lt;br /&gt;
&lt;br /&gt;
This command should bring up the '''Python Console''' window.&lt;br /&gt;
&lt;br /&gt;
[[Image:PythonConsole.png]]&lt;br /&gt;
&lt;br /&gt;
== Basic Slicer/Python tutorial ==&lt;br /&gt;
''Note: this is initial documentation only, and is subject to change as the API evolves.''&lt;br /&gt;
&lt;br /&gt;
The Slicer Python interpreter has access to all Python modules referenced by the environment variable '''PYTHONPATH''' as well as the '''Slicer''' internal module.  The '''Slicer''' module also supports the interface between Slicer Volume Nodes and NumPy.  It would be instructive for the reader to review the [http://www.scipy.org/Documentation NumPy documentation].  For serious users of NumPy, there is the [http://www.tramy.us/ ''Guide to NumPy''] by Travis Oliphant for purchase.&lt;br /&gt;
&lt;br /&gt;
The main interface to Slicer from Python is through the Slicer Python module.  From there, the Python user can access any of Slicer's global objects and MRML tree.  For example:&lt;br /&gt;
&lt;br /&gt;
  &amp;gt;&amp;gt;&amp;gt; import Slicer&lt;br /&gt;
  &amp;gt;&amp;gt;&amp;gt; Slicer.slicer&lt;br /&gt;
  &amp;lt;Slicer.Slicer object at 0x9f325f0&amp;gt;&lt;br /&gt;
  &amp;gt;&amp;gt;&amp;gt; Slicer.slicer.MRMLScene.GetNumberOfNodesByClass ( 'vtkMRMLVolumeNode' )&lt;br /&gt;
  0&lt;br /&gt;
  &amp;gt;&amp;gt;&amp;gt; &lt;br /&gt;
&lt;br /&gt;
In this case, no 'vtkMRMLVolumeNode's were loaded into Slicer.&lt;br /&gt;
&lt;br /&gt;
VTK objects may be easily constructed.&lt;br /&gt;
&lt;br /&gt;
 &amp;gt;&amp;gt;&amp;gt; a = Slicer.slicer.vtkPolyData()&lt;br /&gt;
 &amp;gt;&amp;gt;&amp;gt; help ( a )&lt;br /&gt;
 Help on vtkPolyData in module Slicer object:&lt;br /&gt;
 &lt;br /&gt;
 class vtkPolyData(vtkPointSet)&lt;br /&gt;
  |  Method resolution order:&lt;br /&gt;
  |      vtkPolyData&lt;br /&gt;
  |      vtkPointSet&lt;br /&gt;
  |      vtkDataSet&lt;br /&gt;
  &amp;lt;output truncated&amp;gt;&lt;br /&gt;
&lt;br /&gt;
VTK objects created in this manner conform as closely as possible to the VTK Python bindings, but must be created through the slicer object inside the Slicer module.  Each object may be fully subclassed following the [http://www.onlamp.com/pub/a/python/2003/04/17/metaclasses.html meta object pattern].&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== NumPy tutorial ====&lt;br /&gt;
Python and NumPy give direct access to the volume data in Slicer by wrapping the image data in a NumPy '''array''' object through the '''.ToArray()''' method on the volume node.  This tutorial assumes you have installed [http://scipy.org/Download SciPy].&lt;br /&gt;
&lt;br /&gt;
 &amp;gt;&amp;gt;&amp;gt; # Access the image data directly&lt;br /&gt;
 &amp;gt;&amp;gt;&amp;gt; data = t2.GetImageData().ToArray()&lt;br /&gt;
 &amp;gt;&amp;gt;&amp;gt; print data&lt;br /&gt;
 [[[ 0  0  0 ...,  0  0  0]&lt;br /&gt;
   [ 0  0  1 ...,  0  1  0]&lt;br /&gt;
   [ 0  0  0 ...,  0  0  0]&lt;br /&gt;
   ..., &lt;br /&gt;
   [ 0  8  0 ...,  0  1  2]&lt;br /&gt;
   [ 0  0  0 ...,  4  1  2]&lt;br /&gt;
   [ 0  0  2 ...,  6  0  2]]&lt;br /&gt;
 &lt;br /&gt;
 &amp;lt;&amp;lt;&amp;lt; Some output truncated &amp;gt;&amp;gt;&amp;gt; &lt;br /&gt;
 &lt;br /&gt;
  [[ 0  0  0 ...,  0  0  0]&lt;br /&gt;
   [ 0  0  0 ...,  0  0  0]&lt;br /&gt;
   [ 0  0  0 ...,  0  0  0]&lt;br /&gt;
   ..., &lt;br /&gt;
   [ 0  3  3 ...,  0  0  8]&lt;br /&gt;
   [ 0  6  0 ...,  5  3 13]&lt;br /&gt;
   [ 0  5  1 ...,  9  3  8]]]&lt;br /&gt;
 &amp;gt;&amp;gt;&amp;gt; # Load the image filtering package from scipy&lt;br /&gt;
 &amp;gt;&amp;gt;&amp;gt; import scipy.ndimage&lt;br /&gt;
 &amp;gt;&amp;gt;&amp;gt; # Filter into a new array&lt;br /&gt;
 &amp;gt;&amp;gt;&amp;gt; temp = scipy.ndimage.gaussian_filter ( data, 2.0 )&lt;br /&gt;
 &amp;gt;&amp;gt;&amp;gt; # Copy back into Slicer&lt;br /&gt;
 &amp;gt;&amp;gt;&amp;gt; data[:] = temp[:]&lt;br /&gt;
 &amp;gt;&amp;gt;&amp;gt; t2.Modified()&lt;br /&gt;
&lt;br /&gt;
Before:&lt;br /&gt;
&lt;br /&gt;
[[Image:PythonBefore.png]]&lt;br /&gt;
&lt;br /&gt;
After:&lt;br /&gt;
&lt;br /&gt;
[[Image:PythonAfter.png]]&lt;br /&gt;
&lt;br /&gt;
== Where to go from here ==&lt;br /&gt;
Far from exhaustive, this documentation is intended to whet the appitite of researchers who love the power of Matlab, but feel trapped inside, unable to break out and deploy applications.  This Python interface to Slicer is intended to help!  Here are some selected resources to begin to understand the power of what the combined NumPy - Slicer package offers.&lt;br /&gt;
&lt;br /&gt;
* [http://www.python.org/doc/ Python documentation]&lt;br /&gt;
** [http://www.rexx.com/~dkuhlman/python_101/python_101.html Gentle introduction to Python]&lt;br /&gt;
** [http://www.python.org/doc/Intros.html Python introduction]&lt;br /&gt;
* [http://www.scipy.org/NumPy NumPy documentation]&lt;br /&gt;
** [http://www.trelgol.com/ Comprehensive ''Guide to NumPy''] by the current maintainer&lt;br /&gt;
** [http://numeric.scipy.org/numpydoc/numdoc.htm Old NumPy documentation] ([http://numeric.scipy.org/numpy.pdf pdf])&lt;br /&gt;
* [http://www.scipy.org SciPy] [http://scipy.org/Documentation Documentation]&lt;br /&gt;
* [http://matplotlib.sourceforge.net/ MatPlotLib]&lt;/div&gt;</summary>
		<author><name>Blezek</name></author>
		
	</entry>
	<entry>
		<id>https://www.slicer.org/w/index.php?title=Slicer3:Python&amp;diff=6024</id>
		<title>Slicer3:Python</title>
		<link rel="alternate" type="text/html" href="https://www.slicer.org/w/index.php?title=Slicer3:Python&amp;diff=6024"/>
		<updated>2008-08-18T02:47:25Z</updated>

		<summary type="html">&lt;p&gt;Blezek: /* Enabling Python in the Slicer Build */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Status of Python in Slicer ==&lt;br /&gt;
In post-3.2 Slicer3, Python support is currently disabled by default.  However, it is easy to enable and should compile on all tested platform (Mac, Windows, Linux).  Though [http://matplotlib.sourceforge.net/ matplotlib] is still not properly interacting with Slicer3, NumPy and Python support should work well for all platforms.  [[Slicer3:Execution_Model_Documentation:Python | Python command line modules]] are well supported, as is building full [[Modules:Python | GUI modules in Python]].&lt;br /&gt;
&lt;br /&gt;
== Python for scientific computing ==&lt;br /&gt;
Python has a fairly comprehensive package for scientific computing called [http://scipy.org SciPy].  Of main interest to Slicer users/developers is [http://numpy.scipy.org NumPy].  NumPy provides most of the features of the Matlab image processing toolbox and numeric computations, but in an Open Source package.  A compelling reason to use NumPy is the ease of interaction and integration with Slicer3.&lt;br /&gt;
&lt;br /&gt;
== Slicer3 and Python ==&lt;br /&gt;
==== Enabling Python in the Slicer Build====&lt;br /&gt;
# Edit slicer_variables.tcl&lt;br /&gt;
## Change &amp;quot;set ::USE_PYTHON &amp;quot;off&amp;quot;&amp;quot; to &amp;quot;on&amp;quot;&lt;br /&gt;
# '''Optional:''' If you prefer to use your system Python installation, change set ::USE_SYSTEM_PYTHON &amp;quot;false&amp;quot; to &amp;quot;true&amp;quot;&lt;br /&gt;
## This will give an error under Linux and Windows, but it can be easily fixed by adding the system path for Python, just search for &amp;quot;if { $::USE_SYSTEM_PYTHON } {&amp;quot;&lt;br /&gt;
# '''Optional:''' installing SciPy&lt;br /&gt;
## Download the scipy egg for your platform from the [http://www.scipy.org SciPy] download [http://sourceforge.net/project/showfiles.php?group_id=27747 site on SourceForge].&lt;br /&gt;
## Unzip the egg in any directory that is part of Slicer's Python path, eg Slicer3-build/lib/Slicer3/Plugins&lt;br /&gt;
## SciPy should now be available in Slicer's Python interpreter&lt;br /&gt;
&lt;br /&gt;
Build Slicer3 using &amp;quot;getbuildtest.tcl&amp;quot;, i.e.:&lt;br /&gt;
&lt;br /&gt;
 Macintosh:Slicer3 blezek$ Scripts/getbuildtest.tcl&lt;br /&gt;
&lt;br /&gt;
A new menu command '''Python Interpreter''' should appear on the Window menu.&lt;br /&gt;
&lt;br /&gt;
[[Image:PythonMenu.png]]&lt;br /&gt;
&lt;br /&gt;
This command should bring up the '''Python Console''' window.&lt;br /&gt;
&lt;br /&gt;
[[Image:PythonConsole.png]]&lt;br /&gt;
&lt;br /&gt;
== Basic Slicer/Python tutorial ==&lt;br /&gt;
''Note: this is initial documentation only, and is subject to change as the API evolves.''&lt;br /&gt;
&lt;br /&gt;
The Slicer Python interpreter has access to all Python modules referenced by the environment variable '''PYTHONPATH''' as well as the '''Slicer''' internal module.  The '''Slicer''' module also supports the interface between Slicer Volume Nodes and NumPy.  It would be instructive for the reader to review the [http://www.scipy.org/Documentation NumPy documentation].  For serious users of NumPy, there is the [http://www.tramy.us/ ''Guide to NumPy''] by Travis Oliphant for purchase.&lt;br /&gt;
&lt;br /&gt;
The main interface to Slicer from Python is through the Slicer Python module.  From there, the Python user can access any of Slicer's global objects and MRML tree.  For example:&lt;br /&gt;
&lt;br /&gt;
  &amp;gt;&amp;gt;&amp;gt; import Slicer&lt;br /&gt;
  &amp;gt;&amp;gt;&amp;gt; Slicer.slicer&lt;br /&gt;
  &amp;lt;Slicer.Slicer object at 0x9f325f0&amp;gt;&lt;br /&gt;
  &amp;gt;&amp;gt;&amp;gt; Slicer.slicer.MRMLScene.GetNumberOfNodesByClass ( 'vtkMRMLVolumeNode' )&lt;br /&gt;
  0&lt;br /&gt;
  &amp;gt;&amp;gt;&amp;gt; &lt;br /&gt;
&lt;br /&gt;
In this case, no 'vtkMRMLVolumeNode's were loaded into Slicer.&lt;br /&gt;
&lt;br /&gt;
VTK objects may be easily constructed.&lt;br /&gt;
&lt;br /&gt;
 &amp;gt;&amp;gt;&amp;gt; a = Slicer.slicer.vtkPolyData()&lt;br /&gt;
 &amp;gt;&amp;gt;&amp;gt; help ( a )&lt;br /&gt;
 Help on vtkPolyData in module Slicer object:&lt;br /&gt;
 &lt;br /&gt;
 class vtkPolyData(vtkPointSet)&lt;br /&gt;
  |  Method resolution order:&lt;br /&gt;
  |      vtkPolyData&lt;br /&gt;
  |      vtkPointSet&lt;br /&gt;
  |      vtkDataSet&lt;br /&gt;
  &amp;lt;output truncated&amp;gt;&lt;br /&gt;
&lt;br /&gt;
VTK objects created in this manner conform as closely as possible to the VTK Python bindings, but must be created through the slicer object inside the Slicer module.  Each object may be fully subclassed following the [http://www.onlamp.com/pub/a/python/2003/04/17/metaclasses.html meta object pattern].&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== NumPy tutorial ====&lt;br /&gt;
Python and NumPy give direct access to the volume data in Slicer by wrapping the image data in a NumPy '''array''' object through the '''.ToArray()''' method on the volume node.  This tutorial assumes you have installed [http://scipy.org/Download SciPy].&lt;br /&gt;
&lt;br /&gt;
 &amp;gt;&amp;gt;&amp;gt; # Access the image data directly&lt;br /&gt;
 &amp;gt;&amp;gt;&amp;gt; data = t2.GetImageData().ToArray()&lt;br /&gt;
 &amp;gt;&amp;gt;&amp;gt; print data&lt;br /&gt;
 [[[ 0  0  0 ...,  0  0  0]&lt;br /&gt;
   [ 0  0  1 ...,  0  1  0]&lt;br /&gt;
   [ 0  0  0 ...,  0  0  0]&lt;br /&gt;
   ..., &lt;br /&gt;
   [ 0  8  0 ...,  0  1  2]&lt;br /&gt;
   [ 0  0  0 ...,  4  1  2]&lt;br /&gt;
   [ 0  0  2 ...,  6  0  2]]&lt;br /&gt;
 &lt;br /&gt;
 &amp;lt;&amp;lt;&amp;lt; Some output truncated &amp;gt;&amp;gt;&amp;gt; &lt;br /&gt;
 &lt;br /&gt;
  [[ 0  0  0 ...,  0  0  0]&lt;br /&gt;
   [ 0  0  0 ...,  0  0  0]&lt;br /&gt;
   [ 0  0  0 ...,  0  0  0]&lt;br /&gt;
   ..., &lt;br /&gt;
   [ 0  3  3 ...,  0  0  8]&lt;br /&gt;
   [ 0  6  0 ...,  5  3 13]&lt;br /&gt;
   [ 0  5  1 ...,  9  3  8]]]&lt;br /&gt;
 &amp;gt;&amp;gt;&amp;gt; # Load the image filtering package from scipy&lt;br /&gt;
 &amp;gt;&amp;gt;&amp;gt; import scipy.ndimage&lt;br /&gt;
 &amp;gt;&amp;gt;&amp;gt; # Filter into a new array&lt;br /&gt;
 &amp;gt;&amp;gt;&amp;gt; temp = scipy.ndimage.gaussian_filter ( data, 2.0 )&lt;br /&gt;
 &amp;gt;&amp;gt;&amp;gt; # Copy back into Slicer&lt;br /&gt;
 &amp;gt;&amp;gt;&amp;gt; data[:] = temp[:]&lt;br /&gt;
 &amp;gt;&amp;gt;&amp;gt; t2.Modified()&lt;br /&gt;
&lt;br /&gt;
Before:&lt;br /&gt;
&lt;br /&gt;
[[Image:PythonBefore.png]]&lt;br /&gt;
&lt;br /&gt;
After:&lt;br /&gt;
&lt;br /&gt;
[[Image:PythonAfter.png]]&lt;br /&gt;
&lt;br /&gt;
== Where to go from here ==&lt;br /&gt;
Far from exhaustive, this documentation is intended to whet the appitite of researchers who love the power of Matlab, but feel trapped inside, unable to break out and deploy applications.  This Python interface to Slicer is intended to help!  Here are some selected resources to begin to understand the power of what the combined NumPy - Slicer package offers.&lt;br /&gt;
&lt;br /&gt;
* [http://www.python.org/doc/ Python documentation]&lt;br /&gt;
** [http://www.rexx.com/~dkuhlman/python_101/python_101.html Gentle introduction to Python]&lt;br /&gt;
** [http://www.python.org/doc/Intros.html Python introduction]&lt;br /&gt;
* [http://www.scipy.org/NumPy NumPy documentation]&lt;br /&gt;
** [http://www.trelgol.com/ Comprehensive ''Guide to NumPy''] by the current maintainer&lt;br /&gt;
** [http://numeric.scipy.org/numpydoc/numdoc.htm Old NumPy documentation] ([http://numeric.scipy.org/numpy.pdf pdf])&lt;br /&gt;
* [http://www.scipy.org SciPy] [http://scipy.org/Documentation Documentation]&lt;br /&gt;
* [http://matplotlib.sourceforge.net/ MatPlotLib]&lt;/div&gt;</summary>
		<author><name>Blezek</name></author>
		
	</entry>
	<entry>
		<id>https://www.slicer.org/w/index.php?title=Modules:Python&amp;diff=6023</id>
		<title>Modules:Python</title>
		<link rel="alternate" type="text/html" href="https://www.slicer.org/w/index.php?title=Modules:Python&amp;diff=6023"/>
		<updated>2008-08-18T02:40:34Z</updated>

		<summary type="html">&lt;p&gt;Blezek: New page: == Basics of building a Python GUI module for Slicer3 ==  Python GUI modules all subclass ScriptedModuleGUI and override selected methods.  Below is a full example of a gradient aniostropi...&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Basics of building a Python GUI module for Slicer3 ==&lt;br /&gt;
&lt;br /&gt;
Python GUI modules all subclass ScriptedModuleGUI and override selected methods.  Below is a full example of a gradient aniostropic diffusion module.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
 from SlicerScriptedModule import ScriptedModuleGUI&lt;br /&gt;
 from Slicer import slicer&lt;br /&gt;
 &lt;br /&gt;
 vtkKWScale_ScaleValueChangedEvent = 10001&lt;br /&gt;
 vtkKWScale_ScaleValueStartChangingEvent = 10002&lt;br /&gt;
 vtkSlicerNodeSelectorWidget_NodeSelectedEvent = 11000&lt;br /&gt;
 vtkKWPushButton_InvokedEvent = 10000&lt;br /&gt;
 &lt;br /&gt;
 class PythonGADScriptedModuleGUI(ScriptedModuleGUI):&lt;br /&gt;
 &lt;br /&gt;
     def __init__(self):&lt;br /&gt;
         ScriptedModuleGUI.__init__(self)&lt;br /&gt;
     &lt;br /&gt;
     def RemoveMRMLNodeObservers(self):&lt;br /&gt;
         pass&lt;br /&gt;
     &lt;br /&gt;
     def RemoveLogicObservers(self):&lt;br /&gt;
         pass&lt;br /&gt;
 &lt;br /&gt;
     def AddGUIObservers(self):&lt;br /&gt;
         pass&lt;br /&gt;
 &lt;br /&gt;
     def RemoveGUIObservers(self):&lt;br /&gt;
         pass&lt;br /&gt;
 &lt;br /&gt;
     def ProcessGUIEvents(self,caller,event):&lt;br /&gt;
         pass&lt;br /&gt;
 &lt;br /&gt;
     def Apply(self):&lt;br /&gt;
         if not self.GetScriptedModuleNode():&lt;br /&gt;
           slicer.Application.ErrorMessage(&amp;quot;No input ScriptedModuleNode found&amp;quot;)&lt;br /&gt;
           return&lt;br /&gt;
        &lt;br /&gt;
         slicer.Application.InformationMessage(&amp;quot;Done applying GradientAnisotropicDiffusion.&amp;quot;)&lt;br /&gt;
 &lt;br /&gt;
     def UpdateMRML(self):&lt;br /&gt;
         pass&lt;br /&gt;
 &lt;br /&gt;
     def UpdateGUI(self):&lt;br /&gt;
         pass&lt;br /&gt;
 &lt;br /&gt;
     def ProcessMRMLEvents(self,caller,event):&lt;br /&gt;
         pass&lt;br /&gt;
 &lt;br /&gt;
     def BuildGUI(self):&lt;br /&gt;
         return&lt;br /&gt;
         self.GetUIPanel().AddPage(&amp;quot;GradientAnisotropicDiffusionFilter&amp;quot;,&amp;quot;GradientAnisotropicDiffusionFilter&amp;quot;,&amp;quot;&amp;quot;)&lt;br /&gt;
         pageWidget = self.GetUIPanel().GetPageWidget(&amp;quot;GradientAnisotropicDiffusionFilter&amp;quot;)&lt;br /&gt;
         helpText = &amp;quot;Flex, dude!&amp;quot;&lt;br /&gt;
         aboutText = &amp;quot;This work is supported by NA-MIC, NAC, BIRN, NCIGT, and the Slicer Community. See http://www.slicer.org for details.&amp;quot;&lt;br /&gt;
         self.BuildHelpAndAboutFrame(pageWidget,helpText,aboutText)&lt;br /&gt;
     &lt;br /&gt;
         moduleFrame = slicer.vtkSlicerModuleCollapsibleFrame()&lt;br /&gt;
         moduleFrame.SetParent(self.GetUIPanel().GetPageWidget(&amp;quot;GradientAnisotropicDiffusionFilter&amp;quot;))&lt;br /&gt;
         moduleFrame.Create()&lt;br /&gt;
         moduleFrame.SetLabelText(&amp;quot;Gradient Anisotropic Diffusion Filter&amp;quot;)&lt;br /&gt;
         moduleFrame.ExpandFrame()&lt;br /&gt;
         widgetName = moduleFrame.GetWidgetName()&lt;br /&gt;
         pageWidgetName = self.GetUIPanel().GetPageWidget(&amp;quot;GradientAnisotropicDiffusionFilter&amp;quot;).GetWidgetName()&lt;br /&gt;
         slicer.TkCall(&amp;quot;pack %s -side top -anchor nw -fill x -padx 2 -pady 2 -in %s&amp;quot; % (widgetName,pageWidgetName))&lt;br /&gt;
 &lt;br /&gt;
     def TearDownGUI(self):&lt;br /&gt;
         return&lt;br /&gt;
         if self.GetUIPanel().GetUserInterfaceManager():&lt;br /&gt;
             pageWidget = self.GetUIPanel().GetPageWidget(&amp;quot;GradientAnisotropicDiffusionFilter&amp;quot;)&lt;br /&gt;
             self.GetUIPanel().RemovePage(&amp;quot;GradientAnisotropicDiffusionFilter&amp;quot;)&lt;/div&gt;</summary>
		<author><name>Blezek</name></author>
		
	</entry>
	<entry>
		<id>https://www.slicer.org/w/index.php?title=Slicer3:Python&amp;diff=6022</id>
		<title>Slicer3:Python</title>
		<link rel="alternate" type="text/html" href="https://www.slicer.org/w/index.php?title=Slicer3:Python&amp;diff=6022"/>
		<updated>2008-08-18T02:39:15Z</updated>

		<summary type="html">&lt;p&gt;Blezek: /* Status of Python in Slicer */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Status of Python in Slicer ==&lt;br /&gt;
In post-3.2 Slicer3, Python support is currently disabled by default.  However, it is easy to enable and should compile on all tested platform (Mac, Windows, Linux).  Though [http://matplotlib.sourceforge.net/ matplotlib] is still not properly interacting with Slicer3, NumPy and Python support should work well for all platforms.  [[Slicer3:Execution_Model_Documentation:Python | Python command line modules]] are well supported, as is building full [[Modules:Python | GUI modules in Python]].&lt;br /&gt;
&lt;br /&gt;
== Python for scientific computing ==&lt;br /&gt;
Python has a fairly comprehensive package for scientific computing called [http://scipy.org SciPy].  Of main interest to Slicer users/developers is [http://numpy.scipy.org NumPy].  NumPy provides most of the features of the Matlab image processing toolbox and numeric computations, but in an Open Source package.  A compelling reason to use NumPy is the ease of interaction and integration with Slicer3.&lt;br /&gt;
&lt;br /&gt;
== Slicer3 and Python ==&lt;br /&gt;
==== Enabling Python in the Slicer Build====&lt;br /&gt;
# Edit slicer_variables.tcl&lt;br /&gt;
## Change &amp;quot;set ::USE_PYTHON &amp;quot;off&amp;quot;&amp;quot; to &amp;quot;on&amp;quot;&lt;br /&gt;
# [Optional:] If you prefer to use your system Python installation, change set ::USE_SYSTEM_PYTHON &amp;quot;false&amp;quot; to &amp;quot;true&amp;quot;&lt;br /&gt;
## This will give an error under Linux and Windows, but it can be easily fixed by adding the system path for Python, just search for &amp;quot;if { $::USE_SYSTEM_PYTHON } {&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Build Slicer3 using &amp;quot;getbuildtest.tcl&amp;quot;, i.e.:&lt;br /&gt;
&lt;br /&gt;
 Macintosh:Slicer3 blezek$ Scripts/getbuildtest.tcl&lt;br /&gt;
&lt;br /&gt;
A new menu command '''Python Interpreter''' should appear on the Window menu.&lt;br /&gt;
&lt;br /&gt;
[[Image:PythonMenu.png]]&lt;br /&gt;
&lt;br /&gt;
This command should bring up the '''Python Console''' window.&lt;br /&gt;
&lt;br /&gt;
[[Image:PythonConsole.png]]&lt;br /&gt;
&lt;br /&gt;
== Basic Slicer/Python tutorial ==&lt;br /&gt;
''Note: this is initial documentation only, and is subject to change as the API evolves.''&lt;br /&gt;
&lt;br /&gt;
The Slicer Python interpreter has access to all Python modules referenced by the environment variable '''PYTHONPATH''' as well as the '''Slicer''' internal module.  The '''Slicer''' module also supports the interface between Slicer Volume Nodes and NumPy.  It would be instructive for the reader to review the [http://www.scipy.org/Documentation NumPy documentation].  For serious users of NumPy, there is the [http://www.tramy.us/ ''Guide to NumPy''] by Travis Oliphant for purchase.&lt;br /&gt;
&lt;br /&gt;
The main interface to Slicer from Python is through the Slicer Python module.  From there, the Python user can access any of Slicer's global objects and MRML tree.  For example:&lt;br /&gt;
&lt;br /&gt;
  &amp;gt;&amp;gt;&amp;gt; import Slicer&lt;br /&gt;
  &amp;gt;&amp;gt;&amp;gt; Slicer.slicer&lt;br /&gt;
  &amp;lt;Slicer.Slicer object at 0x9f325f0&amp;gt;&lt;br /&gt;
  &amp;gt;&amp;gt;&amp;gt; Slicer.slicer.MRMLScene.GetNumberOfNodesByClass ( 'vtkMRMLVolumeNode' )&lt;br /&gt;
  0&lt;br /&gt;
  &amp;gt;&amp;gt;&amp;gt; &lt;br /&gt;
&lt;br /&gt;
In this case, no 'vtkMRMLVolumeNode's were loaded into Slicer.&lt;br /&gt;
&lt;br /&gt;
VTK objects may be easily constructed.&lt;br /&gt;
&lt;br /&gt;
 &amp;gt;&amp;gt;&amp;gt; a = Slicer.slicer.vtkPolyData()&lt;br /&gt;
 &amp;gt;&amp;gt;&amp;gt; help ( a )&lt;br /&gt;
 Help on vtkPolyData in module Slicer object:&lt;br /&gt;
 &lt;br /&gt;
 class vtkPolyData(vtkPointSet)&lt;br /&gt;
  |  Method resolution order:&lt;br /&gt;
  |      vtkPolyData&lt;br /&gt;
  |      vtkPointSet&lt;br /&gt;
  |      vtkDataSet&lt;br /&gt;
  &amp;lt;output truncated&amp;gt;&lt;br /&gt;
&lt;br /&gt;
VTK objects created in this manner conform as closely as possible to the VTK Python bindings, but must be created through the slicer object inside the Slicer module.  Each object may be fully subclassed following the [http://www.onlamp.com/pub/a/python/2003/04/17/metaclasses.html meta object pattern].&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== NumPy tutorial ====&lt;br /&gt;
Python and NumPy give direct access to the volume data in Slicer by wrapping the image data in a NumPy '''array''' object through the '''.ToArray()''' method on the volume node.  This tutorial assumes you have installed [http://scipy.org/Download SciPy].&lt;br /&gt;
&lt;br /&gt;
 &amp;gt;&amp;gt;&amp;gt; # Access the image data directly&lt;br /&gt;
 &amp;gt;&amp;gt;&amp;gt; data = t2.GetImageData().ToArray()&lt;br /&gt;
 &amp;gt;&amp;gt;&amp;gt; print data&lt;br /&gt;
 [[[ 0  0  0 ...,  0  0  0]&lt;br /&gt;
   [ 0  0  1 ...,  0  1  0]&lt;br /&gt;
   [ 0  0  0 ...,  0  0  0]&lt;br /&gt;
   ..., &lt;br /&gt;
   [ 0  8  0 ...,  0  1  2]&lt;br /&gt;
   [ 0  0  0 ...,  4  1  2]&lt;br /&gt;
   [ 0  0  2 ...,  6  0  2]]&lt;br /&gt;
 &lt;br /&gt;
 &amp;lt;&amp;lt;&amp;lt; Some output truncated &amp;gt;&amp;gt;&amp;gt; &lt;br /&gt;
 &lt;br /&gt;
  [[ 0  0  0 ...,  0  0  0]&lt;br /&gt;
   [ 0  0  0 ...,  0  0  0]&lt;br /&gt;
   [ 0  0  0 ...,  0  0  0]&lt;br /&gt;
   ..., &lt;br /&gt;
   [ 0  3  3 ...,  0  0  8]&lt;br /&gt;
   [ 0  6  0 ...,  5  3 13]&lt;br /&gt;
   [ 0  5  1 ...,  9  3  8]]]&lt;br /&gt;
 &amp;gt;&amp;gt;&amp;gt; # Load the image filtering package from scipy&lt;br /&gt;
 &amp;gt;&amp;gt;&amp;gt; import scipy.ndimage&lt;br /&gt;
 &amp;gt;&amp;gt;&amp;gt; # Filter into a new array&lt;br /&gt;
 &amp;gt;&amp;gt;&amp;gt; temp = scipy.ndimage.gaussian_filter ( data, 2.0 )&lt;br /&gt;
 &amp;gt;&amp;gt;&amp;gt; # Copy back into Slicer&lt;br /&gt;
 &amp;gt;&amp;gt;&amp;gt; data[:] = temp[:]&lt;br /&gt;
 &amp;gt;&amp;gt;&amp;gt; t2.Modified()&lt;br /&gt;
&lt;br /&gt;
Before:&lt;br /&gt;
&lt;br /&gt;
[[Image:PythonBefore.png]]&lt;br /&gt;
&lt;br /&gt;
After:&lt;br /&gt;
&lt;br /&gt;
[[Image:PythonAfter.png]]&lt;br /&gt;
&lt;br /&gt;
== Where to go from here ==&lt;br /&gt;
Far from exhaustive, this documentation is intended to whet the appitite of researchers who love the power of Matlab, but feel trapped inside, unable to break out and deploy applications.  This Python interface to Slicer is intended to help!  Here are some selected resources to begin to understand the power of what the combined NumPy - Slicer package offers.&lt;br /&gt;
&lt;br /&gt;
* [http://www.python.org/doc/ Python documentation]&lt;br /&gt;
** [http://www.rexx.com/~dkuhlman/python_101/python_101.html Gentle introduction to Python]&lt;br /&gt;
** [http://www.python.org/doc/Intros.html Python introduction]&lt;br /&gt;
* [http://www.scipy.org/NumPy NumPy documentation]&lt;br /&gt;
** [http://www.trelgol.com/ Comprehensive ''Guide to NumPy''] by the current maintainer&lt;br /&gt;
** [http://numeric.scipy.org/numpydoc/numdoc.htm Old NumPy documentation] ([http://numeric.scipy.org/numpy.pdf pdf])&lt;br /&gt;
* [http://www.scipy.org SciPy] [http://scipy.org/Documentation Documentation]&lt;br /&gt;
* [http://matplotlib.sourceforge.net/ MatPlotLib]&lt;/div&gt;</summary>
		<author><name>Blezek</name></author>
		
	</entry>
	<entry>
		<id>https://www.slicer.org/w/index.php?title=Slicer3:Python&amp;diff=6021</id>
		<title>Slicer3:Python</title>
		<link rel="alternate" type="text/html" href="https://www.slicer.org/w/index.php?title=Slicer3:Python&amp;diff=6021"/>
		<updated>2008-08-18T02:35:30Z</updated>

		<summary type="html">&lt;p&gt;Blezek: /* Listing available datasets */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Status of Python in Slicer ==&lt;br /&gt;
In post-3.2 Slicer3, Python support is currently disabled by default.  However, it is easy to enable and should compile on all tested platform (Mac, Windows, Linux).  Though [http://matplotlib.sourceforge.net/ matplotlib] is still not properly interacting with Slicer3, NumPy and Python support should work well for all platforms.  [[Slicer3:Execution_Model_Documentation:Python | Python command line modules]] are well supported, as is building full GUI modules in Python (documentation coming soon).&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Python for scientific computing ==&lt;br /&gt;
Python has a fairly comprehensive package for scientific computing called [http://scipy.org SciPy].  Of main interest to Slicer users/developers is [http://numpy.scipy.org NumPy].  NumPy provides most of the features of the Matlab image processing toolbox and numeric computations, but in an Open Source package.  A compelling reason to use NumPy is the ease of interaction and integration with Slicer3.&lt;br /&gt;
&lt;br /&gt;
== Slicer3 and Python ==&lt;br /&gt;
==== Enabling Python in the Slicer Build====&lt;br /&gt;
# Edit slicer_variables.tcl&lt;br /&gt;
## Change &amp;quot;set ::USE_PYTHON &amp;quot;off&amp;quot;&amp;quot; to &amp;quot;on&amp;quot;&lt;br /&gt;
# [Optional:] If you prefer to use your system Python installation, change set ::USE_SYSTEM_PYTHON &amp;quot;false&amp;quot; to &amp;quot;true&amp;quot;&lt;br /&gt;
## This will give an error under Linux and Windows, but it can be easily fixed by adding the system path for Python, just search for &amp;quot;if { $::USE_SYSTEM_PYTHON } {&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Build Slicer3 using &amp;quot;getbuildtest.tcl&amp;quot;, i.e.:&lt;br /&gt;
&lt;br /&gt;
 Macintosh:Slicer3 blezek$ Scripts/getbuildtest.tcl&lt;br /&gt;
&lt;br /&gt;
A new menu command '''Python Interpreter''' should appear on the Window menu.&lt;br /&gt;
&lt;br /&gt;
[[Image:PythonMenu.png]]&lt;br /&gt;
&lt;br /&gt;
This command should bring up the '''Python Console''' window.&lt;br /&gt;
&lt;br /&gt;
[[Image:PythonConsole.png]]&lt;br /&gt;
&lt;br /&gt;
== Basic Slicer/Python tutorial ==&lt;br /&gt;
''Note: this is initial documentation only, and is subject to change as the API evolves.''&lt;br /&gt;
&lt;br /&gt;
The Slicer Python interpreter has access to all Python modules referenced by the environment variable '''PYTHONPATH''' as well as the '''Slicer''' internal module.  The '''Slicer''' module also supports the interface between Slicer Volume Nodes and NumPy.  It would be instructive for the reader to review the [http://www.scipy.org/Documentation NumPy documentation].  For serious users of NumPy, there is the [http://www.tramy.us/ ''Guide to NumPy''] by Travis Oliphant for purchase.&lt;br /&gt;
&lt;br /&gt;
The main interface to Slicer from Python is through the Slicer Python module.  From there, the Python user can access any of Slicer's global objects and MRML tree.  For example:&lt;br /&gt;
&lt;br /&gt;
  &amp;gt;&amp;gt;&amp;gt; import Slicer&lt;br /&gt;
  &amp;gt;&amp;gt;&amp;gt; Slicer.slicer&lt;br /&gt;
  &amp;lt;Slicer.Slicer object at 0x9f325f0&amp;gt;&lt;br /&gt;
  &amp;gt;&amp;gt;&amp;gt; Slicer.slicer.MRMLScene.GetNumberOfNodesByClass ( 'vtkMRMLVolumeNode' )&lt;br /&gt;
  0&lt;br /&gt;
  &amp;gt;&amp;gt;&amp;gt; &lt;br /&gt;
&lt;br /&gt;
In this case, no 'vtkMRMLVolumeNode's were loaded into Slicer.&lt;br /&gt;
&lt;br /&gt;
VTK objects may be easily constructed.&lt;br /&gt;
&lt;br /&gt;
 &amp;gt;&amp;gt;&amp;gt; a = Slicer.slicer.vtkPolyData()&lt;br /&gt;
 &amp;gt;&amp;gt;&amp;gt; help ( a )&lt;br /&gt;
 Help on vtkPolyData in module Slicer object:&lt;br /&gt;
 &lt;br /&gt;
 class vtkPolyData(vtkPointSet)&lt;br /&gt;
  |  Method resolution order:&lt;br /&gt;
  |      vtkPolyData&lt;br /&gt;
  |      vtkPointSet&lt;br /&gt;
  |      vtkDataSet&lt;br /&gt;
  &amp;lt;output truncated&amp;gt;&lt;br /&gt;
&lt;br /&gt;
VTK objects created in this manner conform as closely as possible to the VTK Python bindings, but must be created through the slicer object inside the Slicer module.  Each object may be fully subclassed following the [http://www.onlamp.com/pub/a/python/2003/04/17/metaclasses.html meta object pattern].&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== NumPy tutorial ====&lt;br /&gt;
Python and NumPy give direct access to the volume data in Slicer by wrapping the image data in a NumPy '''array''' object through the '''.ToArray()''' method on the volume node.  This tutorial assumes you have installed [http://scipy.org/Download SciPy].&lt;br /&gt;
&lt;br /&gt;
 &amp;gt;&amp;gt;&amp;gt; # Access the image data directly&lt;br /&gt;
 &amp;gt;&amp;gt;&amp;gt; data = t2.GetImageData().ToArray()&lt;br /&gt;
 &amp;gt;&amp;gt;&amp;gt; print data&lt;br /&gt;
 [[[ 0  0  0 ...,  0  0  0]&lt;br /&gt;
   [ 0  0  1 ...,  0  1  0]&lt;br /&gt;
   [ 0  0  0 ...,  0  0  0]&lt;br /&gt;
   ..., &lt;br /&gt;
   [ 0  8  0 ...,  0  1  2]&lt;br /&gt;
   [ 0  0  0 ...,  4  1  2]&lt;br /&gt;
   [ 0  0  2 ...,  6  0  2]]&lt;br /&gt;
 &lt;br /&gt;
 &amp;lt;&amp;lt;&amp;lt; Some output truncated &amp;gt;&amp;gt;&amp;gt; &lt;br /&gt;
 &lt;br /&gt;
  [[ 0  0  0 ...,  0  0  0]&lt;br /&gt;
   [ 0  0  0 ...,  0  0  0]&lt;br /&gt;
   [ 0  0  0 ...,  0  0  0]&lt;br /&gt;
   ..., &lt;br /&gt;
   [ 0  3  3 ...,  0  0  8]&lt;br /&gt;
   [ 0  6  0 ...,  5  3 13]&lt;br /&gt;
   [ 0  5  1 ...,  9  3  8]]]&lt;br /&gt;
 &amp;gt;&amp;gt;&amp;gt; # Load the image filtering package from scipy&lt;br /&gt;
 &amp;gt;&amp;gt;&amp;gt; import scipy.ndimage&lt;br /&gt;
 &amp;gt;&amp;gt;&amp;gt; # Filter into a new array&lt;br /&gt;
 &amp;gt;&amp;gt;&amp;gt; temp = scipy.ndimage.gaussian_filter ( data, 2.0 )&lt;br /&gt;
 &amp;gt;&amp;gt;&amp;gt; # Copy back into Slicer&lt;br /&gt;
 &amp;gt;&amp;gt;&amp;gt; data[:] = temp[:]&lt;br /&gt;
 &amp;gt;&amp;gt;&amp;gt; t2.Modified()&lt;br /&gt;
&lt;br /&gt;
Before:&lt;br /&gt;
&lt;br /&gt;
[[Image:PythonBefore.png]]&lt;br /&gt;
&lt;br /&gt;
After:&lt;br /&gt;
&lt;br /&gt;
[[Image:PythonAfter.png]]&lt;br /&gt;
&lt;br /&gt;
== Where to go from here ==&lt;br /&gt;
Far from exhaustive, this documentation is intended to whet the appitite of researchers who love the power of Matlab, but feel trapped inside, unable to break out and deploy applications.  This Python interface to Slicer is intended to help!  Here are some selected resources to begin to understand the power of what the combined NumPy - Slicer package offers.&lt;br /&gt;
&lt;br /&gt;
* [http://www.python.org/doc/ Python documentation]&lt;br /&gt;
** [http://www.rexx.com/~dkuhlman/python_101/python_101.html Gentle introduction to Python]&lt;br /&gt;
** [http://www.python.org/doc/Intros.html Python introduction]&lt;br /&gt;
* [http://www.scipy.org/NumPy NumPy documentation]&lt;br /&gt;
** [http://www.trelgol.com/ Comprehensive ''Guide to NumPy''] by the current maintainer&lt;br /&gt;
** [http://numeric.scipy.org/numpydoc/numdoc.htm Old NumPy documentation] ([http://numeric.scipy.org/numpy.pdf pdf])&lt;br /&gt;
* [http://www.scipy.org SciPy] [http://scipy.org/Documentation Documentation]&lt;br /&gt;
* [http://matplotlib.sourceforge.net/ MatPlotLib]&lt;/div&gt;</summary>
		<author><name>Blezek</name></author>
		
	</entry>
	<entry>
		<id>https://www.slicer.org/w/index.php?title=Slicer3:Python&amp;diff=6020</id>
		<title>Slicer3:Python</title>
		<link rel="alternate" type="text/html" href="https://www.slicer.org/w/index.php?title=Slicer3:Python&amp;diff=6020"/>
		<updated>2008-08-18T02:34:59Z</updated>

		<summary type="html">&lt;p&gt;Blezek: /* Basic Slicer/Python tutorial */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Status of Python in Slicer ==&lt;br /&gt;
In post-3.2 Slicer3, Python support is currently disabled by default.  However, it is easy to enable and should compile on all tested platform (Mac, Windows, Linux).  Though [http://matplotlib.sourceforge.net/ matplotlib] is still not properly interacting with Slicer3, NumPy and Python support should work well for all platforms.  [[Slicer3:Execution_Model_Documentation:Python | Python command line modules]] are well supported, as is building full GUI modules in Python (documentation coming soon).&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Python for scientific computing ==&lt;br /&gt;
Python has a fairly comprehensive package for scientific computing called [http://scipy.org SciPy].  Of main interest to Slicer users/developers is [http://numpy.scipy.org NumPy].  NumPy provides most of the features of the Matlab image processing toolbox and numeric computations, but in an Open Source package.  A compelling reason to use NumPy is the ease of interaction and integration with Slicer3.&lt;br /&gt;
&lt;br /&gt;
== Slicer3 and Python ==&lt;br /&gt;
==== Enabling Python in the Slicer Build====&lt;br /&gt;
# Edit slicer_variables.tcl&lt;br /&gt;
## Change &amp;quot;set ::USE_PYTHON &amp;quot;off&amp;quot;&amp;quot; to &amp;quot;on&amp;quot;&lt;br /&gt;
# [Optional:] If you prefer to use your system Python installation, change set ::USE_SYSTEM_PYTHON &amp;quot;false&amp;quot; to &amp;quot;true&amp;quot;&lt;br /&gt;
## This will give an error under Linux and Windows, but it can be easily fixed by adding the system path for Python, just search for &amp;quot;if { $::USE_SYSTEM_PYTHON } {&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Build Slicer3 using &amp;quot;getbuildtest.tcl&amp;quot;, i.e.:&lt;br /&gt;
&lt;br /&gt;
 Macintosh:Slicer3 blezek$ Scripts/getbuildtest.tcl&lt;br /&gt;
&lt;br /&gt;
A new menu command '''Python Interpreter''' should appear on the Window menu.&lt;br /&gt;
&lt;br /&gt;
[[Image:PythonMenu.png]]&lt;br /&gt;
&lt;br /&gt;
This command should bring up the '''Python Console''' window.&lt;br /&gt;
&lt;br /&gt;
[[Image:PythonConsole.png]]&lt;br /&gt;
&lt;br /&gt;
== Basic Slicer/Python tutorial ==&lt;br /&gt;
''Note: this is initial documentation only, and is subject to change as the API evolves.''&lt;br /&gt;
&lt;br /&gt;
The Slicer Python interpreter has access to all Python modules referenced by the environment variable '''PYTHONPATH''' as well as the '''Slicer''' internal module.  The '''Slicer''' module also supports the interface between Slicer Volume Nodes and NumPy.  It would be instructive for the reader to review the [http://www.scipy.org/Documentation NumPy documentation].  For serious users of NumPy, there is the [http://www.tramy.us/ ''Guide to NumPy''] by Travis Oliphant for purchase.&lt;br /&gt;
&lt;br /&gt;
The main interface to Slicer from Python is through the Slicer Python module.  From there, the Python user can access any of Slicer's global objects and MRML tree.  For example:&lt;br /&gt;
&lt;br /&gt;
  &amp;gt;&amp;gt;&amp;gt; import Slicer&lt;br /&gt;
  &amp;gt;&amp;gt;&amp;gt; Slicer.slicer&lt;br /&gt;
  &amp;lt;Slicer.Slicer object at 0x9f325f0&amp;gt;&lt;br /&gt;
  &amp;gt;&amp;gt;&amp;gt; Slicer.slicer.MRMLScene.GetNumberOfNodesByClass ( 'vtkMRMLVolumeNode' )&lt;br /&gt;
  0&lt;br /&gt;
  &amp;gt;&amp;gt;&amp;gt; &lt;br /&gt;
&lt;br /&gt;
In this case, no 'vtkMRMLVolumeNode's were loaded into Slicer.&lt;br /&gt;
&lt;br /&gt;
VTK objects may be easily constructed.&lt;br /&gt;
&lt;br /&gt;
 &amp;gt;&amp;gt;&amp;gt; a = Slicer.slicer.vtkPolyData()&lt;br /&gt;
 &amp;gt;&amp;gt;&amp;gt; help ( a )&lt;br /&gt;
 Help on vtkPolyData in module Slicer object:&lt;br /&gt;
 &lt;br /&gt;
 class vtkPolyData(vtkPointSet)&lt;br /&gt;
  |  Method resolution order:&lt;br /&gt;
  |      vtkPolyData&lt;br /&gt;
  |      vtkPointSet&lt;br /&gt;
  |      vtkDataSet&lt;br /&gt;
  &amp;lt;output truncated&amp;gt;&lt;br /&gt;
&lt;br /&gt;
VTK objects created in this manner conform as closely as possible to the VTK Python bindings, but must be created through the slicer object inside the Slicer module.  Each object may be fully subclassed following the [http://www.onlamp.com/pub/a/python/2003/04/17/metaclasses.html meta object pattern].&lt;br /&gt;
&lt;br /&gt;
==== Listing available datasets ====&lt;br /&gt;
In this example, a volume named '''T2_MGH.nhdr''' has been loaded into Slicer.&lt;br /&gt;
&lt;br /&gt;
 &amp;gt;&amp;gt;&amp;gt; import Slicer&lt;br /&gt;
 &amp;gt;&amp;gt;&amp;gt; help ( Slicer.ListVolumeNodes )&lt;br /&gt;
 Help on function ListVolumeNodes in module Slicer:&lt;br /&gt;
 &lt;br /&gt;
 ListVolumeNodes()&lt;br /&gt;
     Returns a dictionary containing the index and&lt;br /&gt;
     vtkMRMLVolumeNodes currently loaded by Slicer&lt;br /&gt;
 &lt;br /&gt;
 &amp;gt;&amp;gt;&amp;gt; nodes = Slicer.ListVolumeNodes()&lt;br /&gt;
 &amp;gt;&amp;gt;&amp;gt; nodes&lt;br /&gt;
 {0: vtkTemp1554}&lt;br /&gt;
 &amp;gt;&amp;gt;&amp;gt; t2 = nodes[0]&lt;br /&gt;
 &amp;gt;&amp;gt;&amp;gt; t2.GetName()&lt;br /&gt;
 'T2_MGH.nhdr'&lt;br /&gt;
 &amp;gt;&amp;gt;&amp;gt; t2.GetSpacing()&lt;br /&gt;
 '0.84375 0.84375 0.84 '&lt;br /&gt;
 &amp;gt;&amp;gt;&amp;gt; print t2.ListMethods()&lt;br /&gt;
 &amp;lt;&amp;lt;&amp;lt;Output truncated&amp;gt;&amp;gt;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Help on most Python functions is available using the built in '''help()''' command.  This example shows how to list the available MRML volumes loaded by Slicer, select the volume you would like to use, and print some information from the volume.  An exhaustive list of methods defined on each volume can be found using the&lt;br /&gt;
'''ListMethods()''' method on the volume node.&lt;br /&gt;
&lt;br /&gt;
==== NumPy tutorial ====&lt;br /&gt;
Python and NumPy give direct access to the volume data in Slicer by wrapping the image data in a NumPy '''array''' object through the '''.ToArray()''' method on the volume node.  This tutorial assumes you have installed [http://scipy.org/Download SciPy].&lt;br /&gt;
&lt;br /&gt;
 &amp;gt;&amp;gt;&amp;gt; # Access the image data directly&lt;br /&gt;
 &amp;gt;&amp;gt;&amp;gt; data = t2.GetImageData().ToArray()&lt;br /&gt;
 &amp;gt;&amp;gt;&amp;gt; print data&lt;br /&gt;
 [[[ 0  0  0 ...,  0  0  0]&lt;br /&gt;
   [ 0  0  1 ...,  0  1  0]&lt;br /&gt;
   [ 0  0  0 ...,  0  0  0]&lt;br /&gt;
   ..., &lt;br /&gt;
   [ 0  8  0 ...,  0  1  2]&lt;br /&gt;
   [ 0  0  0 ...,  4  1  2]&lt;br /&gt;
   [ 0  0  2 ...,  6  0  2]]&lt;br /&gt;
 &lt;br /&gt;
 &amp;lt;&amp;lt;&amp;lt; Some output truncated &amp;gt;&amp;gt;&amp;gt; &lt;br /&gt;
 &lt;br /&gt;
  [[ 0  0  0 ...,  0  0  0]&lt;br /&gt;
   [ 0  0  0 ...,  0  0  0]&lt;br /&gt;
   [ 0  0  0 ...,  0  0  0]&lt;br /&gt;
   ..., &lt;br /&gt;
   [ 0  3  3 ...,  0  0  8]&lt;br /&gt;
   [ 0  6  0 ...,  5  3 13]&lt;br /&gt;
   [ 0  5  1 ...,  9  3  8]]]&lt;br /&gt;
 &amp;gt;&amp;gt;&amp;gt; # Load the image filtering package from scipy&lt;br /&gt;
 &amp;gt;&amp;gt;&amp;gt; import scipy.ndimage&lt;br /&gt;
 &amp;gt;&amp;gt;&amp;gt; # Filter into a new array&lt;br /&gt;
 &amp;gt;&amp;gt;&amp;gt; temp = scipy.ndimage.gaussian_filter ( data, 2.0 )&lt;br /&gt;
 &amp;gt;&amp;gt;&amp;gt; # Copy back into Slicer&lt;br /&gt;
 &amp;gt;&amp;gt;&amp;gt; data[:] = temp[:]&lt;br /&gt;
 &amp;gt;&amp;gt;&amp;gt; t2.Modified()&lt;br /&gt;
&lt;br /&gt;
Before:&lt;br /&gt;
&lt;br /&gt;
[[Image:PythonBefore.png]]&lt;br /&gt;
&lt;br /&gt;
After:&lt;br /&gt;
&lt;br /&gt;
[[Image:PythonAfter.png]]&lt;br /&gt;
&lt;br /&gt;
== Where to go from here ==&lt;br /&gt;
Far from exhaustive, this documentation is intended to whet the appitite of researchers who love the power of Matlab, but feel trapped inside, unable to break out and deploy applications.  This Python interface to Slicer is intended to help!  Here are some selected resources to begin to understand the power of what the combined NumPy - Slicer package offers.&lt;br /&gt;
&lt;br /&gt;
* [http://www.python.org/doc/ Python documentation]&lt;br /&gt;
** [http://www.rexx.com/~dkuhlman/python_101/python_101.html Gentle introduction to Python]&lt;br /&gt;
** [http://www.python.org/doc/Intros.html Python introduction]&lt;br /&gt;
* [http://www.scipy.org/NumPy NumPy documentation]&lt;br /&gt;
** [http://www.trelgol.com/ Comprehensive ''Guide to NumPy''] by the current maintainer&lt;br /&gt;
** [http://numeric.scipy.org/numpydoc/numdoc.htm Old NumPy documentation] ([http://numeric.scipy.org/numpy.pdf pdf])&lt;br /&gt;
* [http://www.scipy.org SciPy] [http://scipy.org/Documentation Documentation]&lt;br /&gt;
* [http://matplotlib.sourceforge.net/ MatPlotLib]&lt;/div&gt;</summary>
		<author><name>Blezek</name></author>
		
	</entry>
	<entry>
		<id>https://www.slicer.org/w/index.php?title=Slicer3:Python&amp;diff=6019</id>
		<title>Slicer3:Python</title>
		<link rel="alternate" type="text/html" href="https://www.slicer.org/w/index.php?title=Slicer3:Python&amp;diff=6019"/>
		<updated>2008-08-18T01:52:47Z</updated>

		<summary type="html">&lt;p&gt;Blezek: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Status of Python in Slicer ==&lt;br /&gt;
In post-3.2 Slicer3, Python support is currently disabled by default.  However, it is easy to enable and should compile on all tested platform (Mac, Windows, Linux).  Though [http://matplotlib.sourceforge.net/ matplotlib] is still not properly interacting with Slicer3, NumPy and Python support should work well for all platforms.  [[Slicer3:Execution_Model_Documentation:Python | Python command line modules]] are well supported, as is building full GUI modules in Python (documentation coming soon).&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Python for scientific computing ==&lt;br /&gt;
Python has a fairly comprehensive package for scientific computing called [http://scipy.org SciPy].  Of main interest to Slicer users/developers is [http://numpy.scipy.org NumPy].  NumPy provides most of the features of the Matlab image processing toolbox and numeric computations, but in an Open Source package.  A compelling reason to use NumPy is the ease of interaction and integration with Slicer3.&lt;br /&gt;
&lt;br /&gt;
== Slicer3 and Python ==&lt;br /&gt;
==== Enabling Python in the Slicer Build====&lt;br /&gt;
# Edit slicer_variables.tcl&lt;br /&gt;
## Change &amp;quot;set ::USE_PYTHON &amp;quot;off&amp;quot;&amp;quot; to &amp;quot;on&amp;quot;&lt;br /&gt;
# [Optional:] If you prefer to use your system Python installation, change set ::USE_SYSTEM_PYTHON &amp;quot;false&amp;quot; to &amp;quot;true&amp;quot;&lt;br /&gt;
## This will give an error under Linux and Windows, but it can be easily fixed by adding the system path for Python, just search for &amp;quot;if { $::USE_SYSTEM_PYTHON } {&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Build Slicer3 using &amp;quot;getbuildtest.tcl&amp;quot;, i.e.:&lt;br /&gt;
&lt;br /&gt;
 Macintosh:Slicer3 blezek$ Scripts/getbuildtest.tcl&lt;br /&gt;
&lt;br /&gt;
A new menu command '''Python Interpreter''' should appear on the Window menu.&lt;br /&gt;
&lt;br /&gt;
[[Image:PythonMenu.png]]&lt;br /&gt;
&lt;br /&gt;
This command should bring up the '''Python Console''' window.&lt;br /&gt;
&lt;br /&gt;
[[Image:PythonConsole.png]]&lt;br /&gt;
&lt;br /&gt;
== Basic Slicer/Python tutorial ==&lt;br /&gt;
''Note: this is initial documentation only, and is subject to change as the API evolves.''&lt;br /&gt;
&lt;br /&gt;
The Slicer Python interpreter has access to all Python modules referenced by the environment variable '''PYTHONPATH''' as well as the '''Slicer''' internal module.  The '''Slicer''' module also supports the interface between Slicer Volume Nodes and NumPy.  It would be instructive for the reader to review the [http://www.scipy.org/Documentation NumPy documentation].  For serious users of NumPy, there is the [http://www.tramy.us/ ''Guide to NumPy''] by Travis Oliphant for purchase.&lt;br /&gt;
&lt;br /&gt;
In this example, a volume named '''T2_MGH.nhdr''' has been loaded into Slicer.&lt;br /&gt;
&lt;br /&gt;
'''Important!''' Currently, Python does not increment the reference counter for the vtkMRMLVolumeNode, thus if the volume is unloaded from within Slicer, NumPy will have a reference to freed memory.  This should be addressed soon.&lt;br /&gt;
&lt;br /&gt;
==== Listing available datasets ====&lt;br /&gt;
&lt;br /&gt;
 &amp;gt;&amp;gt;&amp;gt; import Slicer&lt;br /&gt;
 &amp;gt;&amp;gt;&amp;gt; help ( Slicer.ListVolumeNodes )&lt;br /&gt;
 Help on function ListVolumeNodes in module Slicer:&lt;br /&gt;
 &lt;br /&gt;
 ListVolumeNodes()&lt;br /&gt;
     Returns a dictionary containing the index and&lt;br /&gt;
     vtkMRMLVolumeNodes currently loaded by Slicer&lt;br /&gt;
 &lt;br /&gt;
 &amp;gt;&amp;gt;&amp;gt; nodes = Slicer.ListVolumeNodes()&lt;br /&gt;
 &amp;gt;&amp;gt;&amp;gt; nodes&lt;br /&gt;
 {0: vtkTemp1554}&lt;br /&gt;
 &amp;gt;&amp;gt;&amp;gt; t2 = nodes[0]&lt;br /&gt;
 &amp;gt;&amp;gt;&amp;gt; t2.GetName()&lt;br /&gt;
 'T2_MGH.nhdr'&lt;br /&gt;
 &amp;gt;&amp;gt;&amp;gt; t2.GetSpacing()&lt;br /&gt;
 '0.84375 0.84375 0.84 '&lt;br /&gt;
 &amp;gt;&amp;gt;&amp;gt; print t2.ListMethods()&lt;br /&gt;
 &amp;lt;&amp;lt;&amp;lt;Output truncated&amp;gt;&amp;gt;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Help on most Python functions is available using the built in '''help()''' command.  This example shows how to list the available MRML volumes loaded by Slicer, select the volume you would like to use, and print some information from the volume.  An exhaustive list of methods defined on each volume can be found using the&lt;br /&gt;
'''ListMethods()''' method on the volume node.&lt;br /&gt;
&lt;br /&gt;
==== NumPy tutorial ====&lt;br /&gt;
Python and NumPy give direct access to the volume data in Slicer by wrapping the image data in a NumPy '''array''' object through the '''.ToArray()''' method on the volume node.  This tutorial assumes you have installed [http://scipy.org/Download SciPy].&lt;br /&gt;
&lt;br /&gt;
 &amp;gt;&amp;gt;&amp;gt; # Access the image data directly&lt;br /&gt;
 &amp;gt;&amp;gt;&amp;gt; data = t2.GetImageData().ToArray()&lt;br /&gt;
 &amp;gt;&amp;gt;&amp;gt; print data&lt;br /&gt;
 [[[ 0  0  0 ...,  0  0  0]&lt;br /&gt;
   [ 0  0  1 ...,  0  1  0]&lt;br /&gt;
   [ 0  0  0 ...,  0  0  0]&lt;br /&gt;
   ..., &lt;br /&gt;
   [ 0  8  0 ...,  0  1  2]&lt;br /&gt;
   [ 0  0  0 ...,  4  1  2]&lt;br /&gt;
   [ 0  0  2 ...,  6  0  2]]&lt;br /&gt;
 &lt;br /&gt;
 &amp;lt;&amp;lt;&amp;lt; Some output truncated &amp;gt;&amp;gt;&amp;gt; &lt;br /&gt;
 &lt;br /&gt;
  [[ 0  0  0 ...,  0  0  0]&lt;br /&gt;
   [ 0  0  0 ...,  0  0  0]&lt;br /&gt;
   [ 0  0  0 ...,  0  0  0]&lt;br /&gt;
   ..., &lt;br /&gt;
   [ 0  3  3 ...,  0  0  8]&lt;br /&gt;
   [ 0  6  0 ...,  5  3 13]&lt;br /&gt;
   [ 0  5  1 ...,  9  3  8]]]&lt;br /&gt;
 &amp;gt;&amp;gt;&amp;gt; # Load the image filtering package from scipy&lt;br /&gt;
 &amp;gt;&amp;gt;&amp;gt; import scipy.ndimage&lt;br /&gt;
 &amp;gt;&amp;gt;&amp;gt; # Filter into a new array&lt;br /&gt;
 &amp;gt;&amp;gt;&amp;gt; temp = scipy.ndimage.gaussian_filter ( data, 2.0 )&lt;br /&gt;
 &amp;gt;&amp;gt;&amp;gt; # Copy back into Slicer&lt;br /&gt;
 &amp;gt;&amp;gt;&amp;gt; data[:] = temp[:]&lt;br /&gt;
 &amp;gt;&amp;gt;&amp;gt; t2.Modified()&lt;br /&gt;
&lt;br /&gt;
Before:&lt;br /&gt;
&lt;br /&gt;
[[Image:PythonBefore.png]]&lt;br /&gt;
&lt;br /&gt;
After:&lt;br /&gt;
&lt;br /&gt;
[[Image:PythonAfter.png]]&lt;br /&gt;
&lt;br /&gt;
==== MatPlotLib tutorial ====&lt;br /&gt;
The [http://matplotlib.sourceforge.net/ MatPlotLib] interface should be familiar to Matlab users, as the design philosophy is the same (indeed, MatPlotLib is nearly identical, but free!).  This tutorial assumes you have installed [http://sourceforge.net/projects/matplotlib MatPlotLib] and have followed the tutorials above.&lt;br /&gt;
&lt;br /&gt;
 &amp;gt;&amp;gt;&amp;gt; # import MatPlotLib via pylab functions so we can refer to them directly&lt;br /&gt;
 &amp;gt;&amp;gt;&amp;gt; from pylab import *&lt;br /&gt;
 &amp;gt;&amp;gt;&amp;gt; imshow ( data[128,:,:] )&lt;br /&gt;
 &amp;gt;&amp;gt;&amp;gt; # Instruct pylab to show our plots... hit return to continue entering commands.&lt;br /&gt;
 &amp;gt;&amp;gt;&amp;gt; show()&lt;br /&gt;
&lt;br /&gt;
[[Image:Pythonimshow.png]]&lt;br /&gt;
&lt;br /&gt;
 &amp;gt;&amp;gt;&amp;gt; # Clear the plot&lt;br /&gt;
 &amp;gt;&amp;gt;&amp;gt; clf()&lt;br /&gt;
 &amp;gt;&amp;gt;&amp;gt; # Be warned: hist takes some time on an image&lt;br /&gt;
 &amp;gt;&amp;gt;&amp;gt; hist ( data, 20 )&lt;br /&gt;
 (array([10813255,  1065860,  1106656,   802983,   761897,   730788,&lt;br /&gt;
          637444,   470011,   297534,   152217,    82640,    43318,&lt;br /&gt;
           26781,    16333,    11464,     8095,     6386,     4084,&lt;br /&gt;
            1419,      195]), array([   0. ,   31.5,   63. ,   94.5,  126. ,  157.5,  189. ,  220.5,&lt;br /&gt;
         252. ,  283.5,  315. ,  346.5,  378. ,  409.5,  441. ,  472.5,&lt;br /&gt;
         504. ,  535.5,  567. ,  598.5]), &amp;lt;a list of 20 Patch objects&amp;gt;)&lt;br /&gt;
&lt;br /&gt;
[[Image:Pythonhist.png]]&lt;br /&gt;
&lt;br /&gt;
== Where to go from here ==&lt;br /&gt;
Far from exhaustive, this documentation is intended to whet the appitite of researchers who love the power of Matlab, but feel trapped inside, unable to break out and deploy applications.  This Python interface to Slicer is intended to help!  Here are some selected resources to begin to understand the power of what the combined NumPy - Slicer package offers.&lt;br /&gt;
&lt;br /&gt;
* [http://www.python.org/doc/ Python documentation]&lt;br /&gt;
** [http://www.rexx.com/~dkuhlman/python_101/python_101.html Gentle introduction to Python]&lt;br /&gt;
** [http://www.python.org/doc/Intros.html Python introduction]&lt;br /&gt;
* [http://www.scipy.org/NumPy NumPy documentation]&lt;br /&gt;
** [http://www.trelgol.com/ Comprehensive ''Guide to NumPy''] by the current maintainer&lt;br /&gt;
** [http://numeric.scipy.org/numpydoc/numdoc.htm Old NumPy documentation] ([http://numeric.scipy.org/numpy.pdf pdf])&lt;br /&gt;
* [http://www.scipy.org SciPy] [http://scipy.org/Documentation Documentation]&lt;br /&gt;
* [http://matplotlib.sourceforge.net/ MatPlotLib]&lt;/div&gt;</summary>
		<author><name>Blezek</name></author>
		
	</entry>
	<entry>
		<id>https://www.slicer.org/w/index.php?title=Slicer3:Python&amp;diff=6018</id>
		<title>Slicer3:Python</title>
		<link rel="alternate" type="text/html" href="https://www.slicer.org/w/index.php?title=Slicer3:Python&amp;diff=6018"/>
		<updated>2008-08-18T01:49:06Z</updated>

		<summary type="html">&lt;p&gt;Blezek: /* Status of Python in Slicer */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Status of Python in Slicer ==&lt;br /&gt;
In post-3.2 Slicer3, Python support is currently disabled by default.  However, it is easy to enable and should compile on all tested platform (Mac, Windows, Linux).  Though [http://matplotlib.sourceforge.net/ matplotlib] is still not properly interacting with Slicer3, NumPy and Python support should work well for all platforms.  [[Slicer3:Execution_Model_Documentation:Python | Python command line modules]] are well supported, as is building full GUI modules in Python (documentation coming soon).&lt;br /&gt;
&lt;br /&gt;
==== Enabling Python in the Slicer Build====&lt;br /&gt;
# Edit slicer_variables.tcl&lt;br /&gt;
## Change &amp;quot;set ::USE_PYTHON &amp;quot;off&amp;quot;&amp;quot; to &amp;quot;on&amp;quot;&lt;br /&gt;
# [Optional:] If you prefer to use your system Python installation, change set ::USE_SYSTEM_PYTHON &amp;quot;false&amp;quot; to &amp;quot;true&amp;quot;&lt;br /&gt;
## This will give an error under Linux and Windows, but it can be easily fixed by adding the system path for Python, just search for &amp;quot;if { $::USE_SYSTEM_PYTHON } {&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Build Slicer3 using &amp;quot;getbuildtest.tcl&amp;quot;, i.e.:&lt;br /&gt;
&lt;br /&gt;
 Macintosh:Slicer3 blezek$ Scripts/getbuildtest.tcl&lt;br /&gt;
&lt;br /&gt;
== Python for scientific computing ==&lt;br /&gt;
Python has a fairly comprehensive package for scientific computing called [http://scipy.org SciPy].  Of main interest to Slicer users/developers is [http://numpy.scipy.org NumPy].  NumPy provides most of the features of the Matlab image processing toolbox and numeric computations, but in an Open Source package.  A compelling reason to use NumPy is the ease of interaction and integration with Slicer3.&lt;br /&gt;
&lt;br /&gt;
== Slicer3 and Python ==&lt;br /&gt;
At the recent [[Slicer3:MiniRetreat February 7-8, 2007|Slicer3 Mini-Retreat]], a [http://python.org Python] interpreter was added to the Slicer build.  This may be built by following these steps.&lt;br /&gt;
&lt;br /&gt;
# Install [http://www.python.org/download/ Python 2.4 or later]&lt;br /&gt;
# Install [http://sourceforge.net/project/showfiles.php?group_id=1369&amp;amp;package_id=175103 NumPy], be sure to find the correct installer for your version of Python&lt;br /&gt;
## '''Optional:''' Install [http://www.scipy.org/Download SciPy] which is used in the tutorials below&lt;br /&gt;
## '''Optional:''' Install [http://sourceforge.net/projects/matplotlib MatPlotLib], a NumPy plotting package developed to emulate Matlab's plotting capabilities.  Used in the tutorials.&lt;br /&gt;
# Run CMake setting the &amp;quot;USE_PYTHON&amp;quot; option, and setting the path to your Python installation&lt;br /&gt;
## Check Advanced Options&lt;br /&gt;
## Verify that CMake found your Python installation&lt;br /&gt;
# Compile Slicer&lt;br /&gt;
## It is best to clean the '''SlicerBaseGUI''' project, as this may not be correctly rebuilt.&lt;br /&gt;
## A new build target '''SlicerGUIPython''' should appear&lt;br /&gt;
&lt;br /&gt;
A new menu command '''Python Interpreter''' should appear on the Window menu.&lt;br /&gt;
&lt;br /&gt;
[[Image:PythonMenu.png]]&lt;br /&gt;
&lt;br /&gt;
This command should bring up the '''Python Console''' window.&lt;br /&gt;
&lt;br /&gt;
[[Image:PythonConsole.png]]&lt;br /&gt;
&lt;br /&gt;
== Basic Slicer/Python tutorial ==&lt;br /&gt;
''Note: this is initial documentation only, and is subject to change as the API evolves.''&lt;br /&gt;
&lt;br /&gt;
The Slicer Python interpreter has access to all Python modules referenced by the environment variable '''PYTHONPATH''' as well as the '''Slicer''' internal module.  The '''Slicer''' module also supports the interface between Slicer Volume Nodes and NumPy.  It would be instructive for the reader to review the [http://www.scipy.org/Documentation NumPy documentation].  For serious users of NumPy, there is the [http://www.tramy.us/ ''Guide to NumPy''] by Travis Oliphant for purchase.&lt;br /&gt;
&lt;br /&gt;
In this example, a volume named '''T2_MGH.nhdr''' has been loaded into Slicer.&lt;br /&gt;
&lt;br /&gt;
'''Important!''' Currently, Python does not increment the reference counter for the vtkMRMLVolumeNode, thus if the volume is unloaded from within Slicer, NumPy will have a reference to freed memory.  This should be addressed soon.&lt;br /&gt;
&lt;br /&gt;
==== Listing available datasets ====&lt;br /&gt;
&lt;br /&gt;
 &amp;gt;&amp;gt;&amp;gt; import Slicer&lt;br /&gt;
 &amp;gt;&amp;gt;&amp;gt; help ( Slicer.ListVolumeNodes )&lt;br /&gt;
 Help on function ListVolumeNodes in module Slicer:&lt;br /&gt;
 &lt;br /&gt;
 ListVolumeNodes()&lt;br /&gt;
     Returns a dictionary containing the index and&lt;br /&gt;
     vtkMRMLVolumeNodes currently loaded by Slicer&lt;br /&gt;
 &lt;br /&gt;
 &amp;gt;&amp;gt;&amp;gt; nodes = Slicer.ListVolumeNodes()&lt;br /&gt;
 &amp;gt;&amp;gt;&amp;gt; nodes&lt;br /&gt;
 {0: vtkTemp1554}&lt;br /&gt;
 &amp;gt;&amp;gt;&amp;gt; t2 = nodes[0]&lt;br /&gt;
 &amp;gt;&amp;gt;&amp;gt; t2.GetName()&lt;br /&gt;
 'T2_MGH.nhdr'&lt;br /&gt;
 &amp;gt;&amp;gt;&amp;gt; t2.GetSpacing()&lt;br /&gt;
 '0.84375 0.84375 0.84 '&lt;br /&gt;
 &amp;gt;&amp;gt;&amp;gt; print t2.ListMethods()&lt;br /&gt;
 &amp;lt;&amp;lt;&amp;lt;Output truncated&amp;gt;&amp;gt;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Help on most Python functions is available using the built in '''help()''' command.  This example shows how to list the available MRML volumes loaded by Slicer, select the volume you would like to use, and print some information from the volume.  An exhaustive list of methods defined on each volume can be found using the&lt;br /&gt;
'''ListMethods()''' method on the volume node.&lt;br /&gt;
&lt;br /&gt;
==== NumPy tutorial ====&lt;br /&gt;
Python and NumPy give direct access to the volume data in Slicer by wrapping the image data in a NumPy '''array''' object through the '''.ToArray()''' method on the volume node.  This tutorial assumes you have installed [http://scipy.org/Download SciPy].&lt;br /&gt;
&lt;br /&gt;
 &amp;gt;&amp;gt;&amp;gt; # Access the image data directly&lt;br /&gt;
 &amp;gt;&amp;gt;&amp;gt; data = t2.GetImageData().ToArray()&lt;br /&gt;
 &amp;gt;&amp;gt;&amp;gt; print data&lt;br /&gt;
 [[[ 0  0  0 ...,  0  0  0]&lt;br /&gt;
   [ 0  0  1 ...,  0  1  0]&lt;br /&gt;
   [ 0  0  0 ...,  0  0  0]&lt;br /&gt;
   ..., &lt;br /&gt;
   [ 0  8  0 ...,  0  1  2]&lt;br /&gt;
   [ 0  0  0 ...,  4  1  2]&lt;br /&gt;
   [ 0  0  2 ...,  6  0  2]]&lt;br /&gt;
 &lt;br /&gt;
 &amp;lt;&amp;lt;&amp;lt; Some output truncated &amp;gt;&amp;gt;&amp;gt; &lt;br /&gt;
 &lt;br /&gt;
  [[ 0  0  0 ...,  0  0  0]&lt;br /&gt;
   [ 0  0  0 ...,  0  0  0]&lt;br /&gt;
   [ 0  0  0 ...,  0  0  0]&lt;br /&gt;
   ..., &lt;br /&gt;
   [ 0  3  3 ...,  0  0  8]&lt;br /&gt;
   [ 0  6  0 ...,  5  3 13]&lt;br /&gt;
   [ 0  5  1 ...,  9  3  8]]]&lt;br /&gt;
 &amp;gt;&amp;gt;&amp;gt; # Load the image filtering package from scipy&lt;br /&gt;
 &amp;gt;&amp;gt;&amp;gt; import scipy.ndimage&lt;br /&gt;
 &amp;gt;&amp;gt;&amp;gt; # Filter into a new array&lt;br /&gt;
 &amp;gt;&amp;gt;&amp;gt; temp = scipy.ndimage.gaussian_filter ( data, 2.0 )&lt;br /&gt;
 &amp;gt;&amp;gt;&amp;gt; # Copy back into Slicer&lt;br /&gt;
 &amp;gt;&amp;gt;&amp;gt; data[:] = temp[:]&lt;br /&gt;
 &amp;gt;&amp;gt;&amp;gt; t2.Modified()&lt;br /&gt;
&lt;br /&gt;
Before:&lt;br /&gt;
&lt;br /&gt;
[[Image:PythonBefore.png]]&lt;br /&gt;
&lt;br /&gt;
After:&lt;br /&gt;
&lt;br /&gt;
[[Image:PythonAfter.png]]&lt;br /&gt;
&lt;br /&gt;
==== MatPlotLib tutorial ====&lt;br /&gt;
The [http://matplotlib.sourceforge.net/ MatPlotLib] interface should be familiar to Matlab users, as the design philosophy is the same (indeed, MatPlotLib is nearly identical, but free!).  This tutorial assumes you have installed [http://sourceforge.net/projects/matplotlib MatPlotLib] and have followed the tutorials above.&lt;br /&gt;
&lt;br /&gt;
 &amp;gt;&amp;gt;&amp;gt; # import MatPlotLib via pylab functions so we can refer to them directly&lt;br /&gt;
 &amp;gt;&amp;gt;&amp;gt; from pylab import *&lt;br /&gt;
 &amp;gt;&amp;gt;&amp;gt; imshow ( data[128,:,:] )&lt;br /&gt;
 &amp;gt;&amp;gt;&amp;gt; # Instruct pylab to show our plots... hit return to continue entering commands.&lt;br /&gt;
 &amp;gt;&amp;gt;&amp;gt; show()&lt;br /&gt;
&lt;br /&gt;
[[Image:Pythonimshow.png]]&lt;br /&gt;
&lt;br /&gt;
 &amp;gt;&amp;gt;&amp;gt; # Clear the plot&lt;br /&gt;
 &amp;gt;&amp;gt;&amp;gt; clf()&lt;br /&gt;
 &amp;gt;&amp;gt;&amp;gt; # Be warned: hist takes some time on an image&lt;br /&gt;
 &amp;gt;&amp;gt;&amp;gt; hist ( data, 20 )&lt;br /&gt;
 (array([10813255,  1065860,  1106656,   802983,   761897,   730788,&lt;br /&gt;
          637444,   470011,   297534,   152217,    82640,    43318,&lt;br /&gt;
           26781,    16333,    11464,     8095,     6386,     4084,&lt;br /&gt;
            1419,      195]), array([   0. ,   31.5,   63. ,   94.5,  126. ,  157.5,  189. ,  220.5,&lt;br /&gt;
         252. ,  283.5,  315. ,  346.5,  378. ,  409.5,  441. ,  472.5,&lt;br /&gt;
         504. ,  535.5,  567. ,  598.5]), &amp;lt;a list of 20 Patch objects&amp;gt;)&lt;br /&gt;
&lt;br /&gt;
[[Image:Pythonhist.png]]&lt;br /&gt;
&lt;br /&gt;
== Where to go from here ==&lt;br /&gt;
Far from exhaustive, this documentation is intended to whet the appitite of researchers who love the power of Matlab, but feel trapped inside, unable to break out and deploy applications.  This Python interface to Slicer is intended to help!  Here are some selected resources to begin to understand the power of what the combined NumPy - Slicer package offers.&lt;br /&gt;
&lt;br /&gt;
* [http://www.python.org/doc/ Python documentation]&lt;br /&gt;
** [http://www.rexx.com/~dkuhlman/python_101/python_101.html Gentle introduction to Python]&lt;br /&gt;
** [http://www.python.org/doc/Intros.html Python introduction]&lt;br /&gt;
* [http://www.scipy.org/NumPy NumPy documentation]&lt;br /&gt;
** [http://www.trelgol.com/ Comprehensive ''Guide to NumPy''] by the current maintainer&lt;br /&gt;
** [http://numeric.scipy.org/numpydoc/numdoc.htm Old NumPy documentation] ([http://numeric.scipy.org/numpy.pdf pdf])&lt;br /&gt;
* [http://www.scipy.org SciPy] [http://scipy.org/Documentation Documentation]&lt;br /&gt;
* [http://matplotlib.sourceforge.net/ MatPlotLib]&lt;/div&gt;</summary>
		<author><name>Blezek</name></author>
		
	</entry>
	<entry>
		<id>https://www.slicer.org/w/index.php?title=Slicer3:Python&amp;diff=6017</id>
		<title>Slicer3:Python</title>
		<link rel="alternate" type="text/html" href="https://www.slicer.org/w/index.php?title=Slicer3:Python&amp;diff=6017"/>
		<updated>2008-08-18T01:47:19Z</updated>

		<summary type="html">&lt;p&gt;Blezek: /* Status of Python in Slicer */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Status of Python in Slicer ==&lt;br /&gt;
In post-3.2 Slicer3, Python support is currently disabled by default.  However, it is easy to enable and should compile on all tested platform (Mac, Windows, Linux).  Though [http://matplotlib.sourceforge.net/ matplotlib] is still not properly interacting with Slicer3, NumPy and Python support should work well for all platforms.  Python command line modules are well supported, as is building full GUI modules in Python.&lt;br /&gt;
&lt;br /&gt;
==== Enabling Python in the Slicer Build====&lt;br /&gt;
# Edit slicer_variables.tcl&lt;br /&gt;
## Change &amp;quot;set ::USE_PYTHON &amp;quot;off&amp;quot;&amp;quot; to &amp;quot;on&amp;quot;&lt;br /&gt;
# [Optional:] If you prefer to use your system Python installation, change set ::USE_SYSTEM_PYTHON &amp;quot;false&amp;quot; to &amp;quot;true&amp;quot;&lt;br /&gt;
## This will give an error under Linux and Windows, but it can be easily fixed by adding the system path for Python, just search for &amp;quot;if { $::USE_SYSTEM_PYTHON } {&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Build Slicer3 using &amp;quot;getbuildtest.tcl&amp;quot;, i.e.:&lt;br /&gt;
&lt;br /&gt;
 Macintosh:Slicer3 blezek$ Scripts/getbuildtest.tcl&lt;br /&gt;
&lt;br /&gt;
== Python for scientific computing ==&lt;br /&gt;
Python has a fairly comprehensive package for scientific computing called [http://scipy.org SciPy].  Of main interest to Slicer users/developers is [http://numpy.scipy.org NumPy].  NumPy provides most of the features of the Matlab image processing toolbox and numeric computations, but in an Open Source package.  A compelling reason to use NumPy is the ease of interaction and integration with Slicer3.&lt;br /&gt;
&lt;br /&gt;
== Slicer3 and Python ==&lt;br /&gt;
At the recent [[Slicer3:MiniRetreat February 7-8, 2007|Slicer3 Mini-Retreat]], a [http://python.org Python] interpreter was added to the Slicer build.  This may be built by following these steps.&lt;br /&gt;
&lt;br /&gt;
# Install [http://www.python.org/download/ Python 2.4 or later]&lt;br /&gt;
# Install [http://sourceforge.net/project/showfiles.php?group_id=1369&amp;amp;package_id=175103 NumPy], be sure to find the correct installer for your version of Python&lt;br /&gt;
## '''Optional:''' Install [http://www.scipy.org/Download SciPy] which is used in the tutorials below&lt;br /&gt;
## '''Optional:''' Install [http://sourceforge.net/projects/matplotlib MatPlotLib], a NumPy plotting package developed to emulate Matlab's plotting capabilities.  Used in the tutorials.&lt;br /&gt;
# Run CMake setting the &amp;quot;USE_PYTHON&amp;quot; option, and setting the path to your Python installation&lt;br /&gt;
## Check Advanced Options&lt;br /&gt;
## Verify that CMake found your Python installation&lt;br /&gt;
# Compile Slicer&lt;br /&gt;
## It is best to clean the '''SlicerBaseGUI''' project, as this may not be correctly rebuilt.&lt;br /&gt;
## A new build target '''SlicerGUIPython''' should appear&lt;br /&gt;
&lt;br /&gt;
A new menu command '''Python Interpreter''' should appear on the Window menu.&lt;br /&gt;
&lt;br /&gt;
[[Image:PythonMenu.png]]&lt;br /&gt;
&lt;br /&gt;
This command should bring up the '''Python Console''' window.&lt;br /&gt;
&lt;br /&gt;
[[Image:PythonConsole.png]]&lt;br /&gt;
&lt;br /&gt;
== Basic Slicer/Python tutorial ==&lt;br /&gt;
''Note: this is initial documentation only, and is subject to change as the API evolves.''&lt;br /&gt;
&lt;br /&gt;
The Slicer Python interpreter has access to all Python modules referenced by the environment variable '''PYTHONPATH''' as well as the '''Slicer''' internal module.  The '''Slicer''' module also supports the interface between Slicer Volume Nodes and NumPy.  It would be instructive for the reader to review the [http://www.scipy.org/Documentation NumPy documentation].  For serious users of NumPy, there is the [http://www.tramy.us/ ''Guide to NumPy''] by Travis Oliphant for purchase.&lt;br /&gt;
&lt;br /&gt;
In this example, a volume named '''T2_MGH.nhdr''' has been loaded into Slicer.&lt;br /&gt;
&lt;br /&gt;
'''Important!''' Currently, Python does not increment the reference counter for the vtkMRMLVolumeNode, thus if the volume is unloaded from within Slicer, NumPy will have a reference to freed memory.  This should be addressed soon.&lt;br /&gt;
&lt;br /&gt;
==== Listing available datasets ====&lt;br /&gt;
&lt;br /&gt;
 &amp;gt;&amp;gt;&amp;gt; import Slicer&lt;br /&gt;
 &amp;gt;&amp;gt;&amp;gt; help ( Slicer.ListVolumeNodes )&lt;br /&gt;
 Help on function ListVolumeNodes in module Slicer:&lt;br /&gt;
 &lt;br /&gt;
 ListVolumeNodes()&lt;br /&gt;
     Returns a dictionary containing the index and&lt;br /&gt;
     vtkMRMLVolumeNodes currently loaded by Slicer&lt;br /&gt;
 &lt;br /&gt;
 &amp;gt;&amp;gt;&amp;gt; nodes = Slicer.ListVolumeNodes()&lt;br /&gt;
 &amp;gt;&amp;gt;&amp;gt; nodes&lt;br /&gt;
 {0: vtkTemp1554}&lt;br /&gt;
 &amp;gt;&amp;gt;&amp;gt; t2 = nodes[0]&lt;br /&gt;
 &amp;gt;&amp;gt;&amp;gt; t2.GetName()&lt;br /&gt;
 'T2_MGH.nhdr'&lt;br /&gt;
 &amp;gt;&amp;gt;&amp;gt; t2.GetSpacing()&lt;br /&gt;
 '0.84375 0.84375 0.84 '&lt;br /&gt;
 &amp;gt;&amp;gt;&amp;gt; print t2.ListMethods()&lt;br /&gt;
 &amp;lt;&amp;lt;&amp;lt;Output truncated&amp;gt;&amp;gt;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Help on most Python functions is available using the built in '''help()''' command.  This example shows how to list the available MRML volumes loaded by Slicer, select the volume you would like to use, and print some information from the volume.  An exhaustive list of methods defined on each volume can be found using the&lt;br /&gt;
'''ListMethods()''' method on the volume node.&lt;br /&gt;
&lt;br /&gt;
==== NumPy tutorial ====&lt;br /&gt;
Python and NumPy give direct access to the volume data in Slicer by wrapping the image data in a NumPy '''array''' object through the '''.ToArray()''' method on the volume node.  This tutorial assumes you have installed [http://scipy.org/Download SciPy].&lt;br /&gt;
&lt;br /&gt;
 &amp;gt;&amp;gt;&amp;gt; # Access the image data directly&lt;br /&gt;
 &amp;gt;&amp;gt;&amp;gt; data = t2.GetImageData().ToArray()&lt;br /&gt;
 &amp;gt;&amp;gt;&amp;gt; print data&lt;br /&gt;
 [[[ 0  0  0 ...,  0  0  0]&lt;br /&gt;
   [ 0  0  1 ...,  0  1  0]&lt;br /&gt;
   [ 0  0  0 ...,  0  0  0]&lt;br /&gt;
   ..., &lt;br /&gt;
   [ 0  8  0 ...,  0  1  2]&lt;br /&gt;
   [ 0  0  0 ...,  4  1  2]&lt;br /&gt;
   [ 0  0  2 ...,  6  0  2]]&lt;br /&gt;
 &lt;br /&gt;
 &amp;lt;&amp;lt;&amp;lt; Some output truncated &amp;gt;&amp;gt;&amp;gt; &lt;br /&gt;
 &lt;br /&gt;
  [[ 0  0  0 ...,  0  0  0]&lt;br /&gt;
   [ 0  0  0 ...,  0  0  0]&lt;br /&gt;
   [ 0  0  0 ...,  0  0  0]&lt;br /&gt;
   ..., &lt;br /&gt;
   [ 0  3  3 ...,  0  0  8]&lt;br /&gt;
   [ 0  6  0 ...,  5  3 13]&lt;br /&gt;
   [ 0  5  1 ...,  9  3  8]]]&lt;br /&gt;
 &amp;gt;&amp;gt;&amp;gt; # Load the image filtering package from scipy&lt;br /&gt;
 &amp;gt;&amp;gt;&amp;gt; import scipy.ndimage&lt;br /&gt;
 &amp;gt;&amp;gt;&amp;gt; # Filter into a new array&lt;br /&gt;
 &amp;gt;&amp;gt;&amp;gt; temp = scipy.ndimage.gaussian_filter ( data, 2.0 )&lt;br /&gt;
 &amp;gt;&amp;gt;&amp;gt; # Copy back into Slicer&lt;br /&gt;
 &amp;gt;&amp;gt;&amp;gt; data[:] = temp[:]&lt;br /&gt;
 &amp;gt;&amp;gt;&amp;gt; t2.Modified()&lt;br /&gt;
&lt;br /&gt;
Before:&lt;br /&gt;
&lt;br /&gt;
[[Image:PythonBefore.png]]&lt;br /&gt;
&lt;br /&gt;
After:&lt;br /&gt;
&lt;br /&gt;
[[Image:PythonAfter.png]]&lt;br /&gt;
&lt;br /&gt;
==== MatPlotLib tutorial ====&lt;br /&gt;
The [http://matplotlib.sourceforge.net/ MatPlotLib] interface should be familiar to Matlab users, as the design philosophy is the same (indeed, MatPlotLib is nearly identical, but free!).  This tutorial assumes you have installed [http://sourceforge.net/projects/matplotlib MatPlotLib] and have followed the tutorials above.&lt;br /&gt;
&lt;br /&gt;
 &amp;gt;&amp;gt;&amp;gt; # import MatPlotLib via pylab functions so we can refer to them directly&lt;br /&gt;
 &amp;gt;&amp;gt;&amp;gt; from pylab import *&lt;br /&gt;
 &amp;gt;&amp;gt;&amp;gt; imshow ( data[128,:,:] )&lt;br /&gt;
 &amp;gt;&amp;gt;&amp;gt; # Instruct pylab to show our plots... hit return to continue entering commands.&lt;br /&gt;
 &amp;gt;&amp;gt;&amp;gt; show()&lt;br /&gt;
&lt;br /&gt;
[[Image:Pythonimshow.png]]&lt;br /&gt;
&lt;br /&gt;
 &amp;gt;&amp;gt;&amp;gt; # Clear the plot&lt;br /&gt;
 &amp;gt;&amp;gt;&amp;gt; clf()&lt;br /&gt;
 &amp;gt;&amp;gt;&amp;gt; # Be warned: hist takes some time on an image&lt;br /&gt;
 &amp;gt;&amp;gt;&amp;gt; hist ( data, 20 )&lt;br /&gt;
 (array([10813255,  1065860,  1106656,   802983,   761897,   730788,&lt;br /&gt;
          637444,   470011,   297534,   152217,    82640,    43318,&lt;br /&gt;
           26781,    16333,    11464,     8095,     6386,     4084,&lt;br /&gt;
            1419,      195]), array([   0. ,   31.5,   63. ,   94.5,  126. ,  157.5,  189. ,  220.5,&lt;br /&gt;
         252. ,  283.5,  315. ,  346.5,  378. ,  409.5,  441. ,  472.5,&lt;br /&gt;
         504. ,  535.5,  567. ,  598.5]), &amp;lt;a list of 20 Patch objects&amp;gt;)&lt;br /&gt;
&lt;br /&gt;
[[Image:Pythonhist.png]]&lt;br /&gt;
&lt;br /&gt;
== Where to go from here ==&lt;br /&gt;
Far from exhaustive, this documentation is intended to whet the appitite of researchers who love the power of Matlab, but feel trapped inside, unable to break out and deploy applications.  This Python interface to Slicer is intended to help!  Here are some selected resources to begin to understand the power of what the combined NumPy - Slicer package offers.&lt;br /&gt;
&lt;br /&gt;
* [http://www.python.org/doc/ Python documentation]&lt;br /&gt;
** [http://www.rexx.com/~dkuhlman/python_101/python_101.html Gentle introduction to Python]&lt;br /&gt;
** [http://www.python.org/doc/Intros.html Python introduction]&lt;br /&gt;
* [http://www.scipy.org/NumPy NumPy documentation]&lt;br /&gt;
** [http://www.trelgol.com/ Comprehensive ''Guide to NumPy''] by the current maintainer&lt;br /&gt;
** [http://numeric.scipy.org/numpydoc/numdoc.htm Old NumPy documentation] ([http://numeric.scipy.org/numpy.pdf pdf])&lt;br /&gt;
* [http://www.scipy.org SciPy] [http://scipy.org/Documentation Documentation]&lt;br /&gt;
* [http://matplotlib.sourceforge.net/ MatPlotLib]&lt;/div&gt;</summary>
		<author><name>Blezek</name></author>
		
	</entry>
</feed>