<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://www.slicer.org/w/index.php?action=history&amp;feed=atom&amp;title=Documentation%2F4.2%2FDevelopers%2FPython_scripting</id>
	<title>Documentation/4.2/Developers/Python scripting - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://www.slicer.org/w/index.php?action=history&amp;feed=atom&amp;title=Documentation%2F4.2%2FDevelopers%2FPython_scripting"/>
	<link rel="alternate" type="text/html" href="https://www.slicer.org/w/index.php?title=Documentation/4.2/Developers/Python_scripting&amp;action=history"/>
	<updated>2026-05-02T00:33:05Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.33.0</generator>
	<entry>
		<id>https://www.slicer.org/w/index.php?title=Documentation/4.2/Developers/Python_scripting&amp;diff=32753&amp;oldid=prev</id>
		<title>UpdateBot: Prepend documentation/versioncheck template. See http://na-mic.org/Mantis/view.php?id=2887</title>
		<link rel="alternate" type="text/html" href="https://www.slicer.org/w/index.php?title=Documentation/4.2/Developers/Python_scripting&amp;diff=32753&amp;oldid=prev"/>
		<updated>2013-06-14T07:43:41Z</updated>

		<summary type="html">&lt;p&gt;Prepend documentation/versioncheck template. See http://na-mic.org/Mantis/view.php?id=2887&lt;/p&gt;
&lt;table class=&quot;diff diff-contentalign-left&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #222; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #222; text-align: center;&quot;&gt;Revision as of 07:43, 14 June 2013&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l1&quot; &gt;Line 1:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 1:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt; &lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;&amp;lt;noinclude&amp;gt;{{documentation/versioncheck}}&amp;lt;/noinclude&amp;gt;&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;= Background =&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;= Background =&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>UpdateBot</name></author>
		
	</entry>
	<entry>
		<id>https://www.slicer.org/w/index.php?title=Documentation/4.2/Developers/Python_scripting&amp;diff=31086&amp;oldid=prev</id>
		<title>Imphead: /* Python Interactor */ : wrong menu &amp; shortcut, someone still need to address mac shortcut</title>
		<link rel="alternate" type="text/html" href="https://www.slicer.org/w/index.php?title=Documentation/4.2/Developers/Python_scripting&amp;diff=31086&amp;oldid=prev"/>
		<updated>2013-04-07T14:09:40Z</updated>

		<summary type="html">&lt;p&gt;&lt;span dir=&quot;auto&quot;&gt;&lt;span class=&quot;autocomment&quot;&gt;Python Interactor: &lt;/span&gt; : wrong menu &amp;amp; shortcut, someone still need to address mac shortcut&lt;/span&gt;&lt;/p&gt;
&lt;table class=&quot;diff diff-contentalign-left&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #222; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #222; text-align: center;&quot;&gt;Revision as of 14:09, 7 April 2013&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l15&quot; &gt;Line 15:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 15:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;==Python Interactor==&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;==Python Interactor==&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;−&lt;/td&gt;&lt;td style=&quot;color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;Use &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;the Window&lt;/del&gt;-&amp;gt;Python Interactor (Control-&lt;del class=&quot;diffchange diffchange-inline&quot;&gt;P &lt;/del&gt;on window/linux, Command-P on mac) to bring up the Qt-based console with access to the vtk, Qt, and Slicer wrapped APIs.&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;Use &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;View&lt;/ins&gt;-&amp;gt;Python Interactor (Control-&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;3 &lt;/ins&gt;on window/linux, Command-P &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;(?) &lt;/ins&gt;on mac) to bring up the Qt-based console with access to the vtk, Qt, and Slicer wrapped APIs.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;Most python code can be installed and run from this window, but because it exists in the event driven Qt GUI environment, some operations like, like parallel processing or headless operation, are not easily supported.&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;Most python code can be installed and run from this window, but because it exists in the event driven Qt GUI environment, some operations like, like parallel processing or headless operation, are not easily supported.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>Imphead</name></author>
		
	</entry>
	<entry>
		<id>https://www.slicer.org/w/index.php?title=Documentation/4.2/Developers/Python_scripting&amp;diff=31079&amp;oldid=prev</id>
		<title>Imphead: Example didn't actually work. Explain type and print. The new file name is awfully long however. Explained that slicer.utils.* is pre-imported. Also, explained that mouse paste may not work.</title>
		<link rel="alternate" type="text/html" href="https://www.slicer.org/w/index.php?title=Documentation/4.2/Developers/Python_scripting&amp;diff=31079&amp;oldid=prev"/>
		<updated>2013-04-06T01:13:59Z</updated>

		<summary type="html">&lt;p&gt;Example didn&amp;#039;t actually work. Explain type and print. The new file name is awfully long however. Explained that slicer.utils.* is pre-imported. Also, explained that mouse paste may not work.&lt;/p&gt;
&lt;table class=&quot;diff diff-contentalign-left&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #222; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #222; text-align: center;&quot;&gt;Revision as of 01:13, 6 April 2013&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l21&quot; &gt;Line 21:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 21:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;=== Examples ===&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;=== Examples ===&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;−&lt;/td&gt;&lt;td style=&quot;color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;Start slicer4 and bring up python console.  &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;Load a volume like this&lt;/del&gt;:&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;Start slicer4 and bring up python console.  &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;Copy the line below, but omit &amp;quot;&amp;lt;code&amp;gt;&amp;gt;&amp;gt;&amp;gt; &amp;lt;/code&amp;gt;&amp;quot; including the leading space (Python is space sensitive!), and Ctrl-v into the console (mouse paste may not work)&lt;/ins&gt;:&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;lt;pre&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;lt;pre&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;−&lt;/td&gt;&lt;td style=&quot;color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;gt;&amp;gt;&amp;gt; &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;slicer.util.&lt;/del&gt;loadVolume(slicer.app.slicerHome + &amp;quot;/share/&lt;del class=&quot;diffchange diffchange-inline&quot;&gt;MRML&lt;/del&gt;/Testing/TestData/&lt;del class=&quot;diffchange diffchange-inline&quot;&gt;fixed&lt;/del&gt;.nrrd&amp;quot;)&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;gt;&amp;gt;&amp;gt; loadVolume(slicer.app.slicerHome + &amp;quot;/share/&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;Slicer-4.2/qt-loadable-modules/EMSegment&lt;/ins&gt;/Testing/TestData/&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;MRI-Human-Brain/small_MRIHumanBrain_T1_aligned&lt;/ins&gt;.nrrd&amp;quot;)&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;lt;/pre&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;lt;/pre&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt; &lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;If you see &amp;lt;code&amp;gt;True&amp;lt;/code&amp;gt; as the Python answer, you've loaded an MRI volume. Now, get the volume node for that volume:&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;−&lt;/td&gt;&lt;td style=&quot;color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;del class=&quot;diffchange diffchange-inline&quot;&gt;Get &lt;/del&gt;the &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;volume &lt;/del&gt;node for &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;that volume&lt;/del&gt;:&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;&amp;lt;pre&amp;gt;&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt; &lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;&amp;gt;&amp;gt;&amp;gt; n = getNode('small_MRIHumanBrain_T1_aligned')&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt; &lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;&amp;lt;/pre&amp;gt;&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt; &lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt; &lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt; &lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;See the VTK type of &lt;/ins&gt;the node &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;and its address:&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt; &lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt; &lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt; &lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;&amp;lt;pre&amp;gt;&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt; &lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;&amp;gt;&amp;gt;&amp;gt; n&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt; &lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;&amp;lt;/pre&amp;gt;&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt; &lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt; &lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt; &lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;Use the built-in print method of &amp;lt;code&amp;gt;vtkMRMLScalarVolumeNode&amp;lt;/code&amp;gt; &lt;/ins&gt;for &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;a human-readable digest of what it contains&lt;/ins&gt;:&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;lt;pre&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;lt;pre&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;−&lt;/td&gt;&lt;td style=&quot;color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;gt;&amp;gt;&amp;gt; n &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;= getNode('fixed')&lt;/del&gt;&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;gt;&amp;gt;&amp;gt; &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;print &lt;/ins&gt;n&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;lt;/pre&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;lt;/pre&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;−&lt;/td&gt;&lt;td style=&quot;color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;You can use Tab to see lists of methods for a &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;class instance&lt;/del&gt;.&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;You can use Tab &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;completion &lt;/ins&gt;to see lists of methods for a &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;module or object; the Python built-in &amp;lt;code&amp;gt;dir(...)&amp;lt;/code&amp;gt; function is also useful. For example, &amp;lt;code&amp;gt;dir(slicer.util)&amp;lt;/code&amp;gt; includes &amp;lt;code&amp;gt;loadVolume&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;getNode&amp;lt;/code&amp;gt;, which you've just used. Similarly, from &amp;lt;code&amp;gt;dir()&amp;lt;/code&amp;gt;, you can see all that's available in the module, including in fact all contents of &amp;lt;code&amp;gt;slicer.util&amp;lt;/code&amp;gt;, which has already been imported. That's why you can type &amp;lt;code&amp;gt;getNode&amp;lt;/code&amp;gt; instead of &amp;lt;code&amp;gt;slicer.util.getNode&amp;lt;/code&amp;gt;&lt;/ins&gt;.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>Imphead</name></author>
		
	</entry>
	<entry>
		<id>https://www.slicer.org/w/index.php?title=Documentation/4.2/Developers/Python_scripting&amp;diff=31067&amp;oldid=prev</id>
		<title>Pieper: /* In iPython */</title>
		<link rel="alternate" type="text/html" href="https://www.slicer.org/w/index.php?title=Documentation/4.2/Developers/Python_scripting&amp;diff=31067&amp;oldid=prev"/>
		<updated>2013-04-04T16:05:15Z</updated>

		<summary type="html">&lt;p&gt;&lt;span dir=&quot;auto&quot;&gt;&lt;span class=&quot;autocomment&quot;&gt;In iPython&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;table class=&quot;diff diff-contentalign-left&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #222; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #222; text-align: center;&quot;&gt;Revision as of 16:05, 4 April 2013&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l115&quot; &gt;Line 115:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 115:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;== In iPython ==&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;== In iPython ==&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;−&lt;/td&gt;&lt;td style=&quot;color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;''Important: The example below was developed for an early beta version of slicer4 and is not supported in Slicer 4.0 or 4.1''&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;'&lt;/ins&gt;''Important: The example below was developed for an early beta version of slicer4 and is not supported in Slicer 4.0 or 4.1&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;'&lt;/ins&gt;''&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;See [http://slicer-devel.65872.n3.nabble.com/import-slicer-problem-in-using-python-in-the-shell-launched-using-quot-slicer-xterm-amp-quot-td3968880.html this thread for information on adapting this approach to Slicer 4.1].&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;See [http://slicer-devel.65872.n3.nabble.com/import-slicer-problem-in-using-python-in-the-shell-launched-using-quot-slicer-xterm-amp-quot-td3968880.html this thread for information on adapting this approach to Slicer 4.1].&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>Pieper</name></author>
		
	</entry>
	<entry>
		<id>https://www.slicer.org/w/index.php?title=Documentation/4.2/Developers/Python_scripting&amp;diff=28758&amp;oldid=prev</id>
		<title>UpdateBot: Nightly -&gt; 4.2</title>
		<link rel="alternate" type="text/html" href="https://www.slicer.org/w/index.php?title=Documentation/4.2/Developers/Python_scripting&amp;diff=28758&amp;oldid=prev"/>
		<updated>2012-10-31T21:59:09Z</updated>

		<summary type="html">&lt;p&gt;Nightly -&amp;gt; 4.2&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;= Background =&lt;br /&gt;
&lt;br /&gt;
This is an evolution of the [[Slicer3:Python|python implementation in slicer3]].  Slicer's APIs are now natively wrapped in python.  &lt;br /&gt;
&lt;br /&gt;
Topics like plotting are still experimental in slicer4.&lt;br /&gt;
&lt;br /&gt;
See [http://www.na-mic.org/Wiki/index.php/AHM2012-Slicer-Python this 2012 presentation on the state of python in slicer4].&lt;br /&gt;
&lt;br /&gt;
'''See [[4.0/Training#Slicer4_Programming_Tutorial|the python slicer4 tutorial for more examples]].'''&lt;br /&gt;
&lt;br /&gt;
[[Documentation/{{documentation/version}}/Developers/Tutorials/SelfTestModule|Slicer Self Tests]] can be written in python, and provide a good source of examples for manipulating the data, logic, and gui of slicer.&lt;br /&gt;
&lt;br /&gt;
= Usage options =&lt;br /&gt;
&lt;br /&gt;
==Python Interactor==&lt;br /&gt;
&lt;br /&gt;
Use the Window-&amp;gt;Python Interactor (Control-P on window/linux, Command-P on mac) to bring up the Qt-based console with access to the vtk, Qt, and Slicer wrapped APIs.&lt;br /&gt;
&lt;br /&gt;
Most python code can be installed and run from this window, but because it exists in the event driven Qt GUI environment, some operations like, like parallel processing or headless operation, are not easily supported.&lt;br /&gt;
&lt;br /&gt;
=== Examples ===&lt;br /&gt;
&lt;br /&gt;
Start slicer4 and bring up python console.  Load a volume like this:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;gt;&amp;gt;&amp;gt; slicer.util.loadVolume(slicer.app.slicerHome + &amp;quot;/share/MRML/Testing/TestData/fixed.nrrd&amp;quot;)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Get the volume node for that volume:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;gt;&amp;gt;&amp;gt; n = getNode('fixed')&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can use Tab to see lists of methods for a class instance.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Running a CLI from Python ====&lt;br /&gt;
&lt;br /&gt;
Here's an example to create a model from a volume using the [[Documentation/4.0/Modules/GrayscaleModelMaker|Grayscale Model Maker]]&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
def grayModel(volumeNode):&lt;br /&gt;
  parameters = {}&lt;br /&gt;
  parameters[&amp;quot;InputVolume&amp;quot;] = volumeNode.GetID()&lt;br /&gt;
  outModel = slicer.vtkMRMLModelNode()&lt;br /&gt;
  slicer.mrmlScene.AddNode( outModel )&lt;br /&gt;
  parameters[&amp;quot;OutputGeometry&amp;quot;] = outModel.GetID()&lt;br /&gt;
  grayMaker = slicer.modules.grayscalemodelmaker&lt;br /&gt;
  return (slicer.cli.run(grayMaker, None, parameters))&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To try this, download the MRHead dataset from the [[Documentation/4.0/Modules/SampleData|Sample Data]] and paste the code into the python console and then run this:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
v = getNode('MRHead')&lt;br /&gt;
cliNode = grayModel(v)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note that the CLI module runs in a background thread, so the call to grayModel will return right away.  But the slicer.cli.run call returns a cliNode (an instance of [http://slicer.org/doc/html/classvtkMRMLCommandLineModuleNode.html vtkMRMLCommandLineModuleNode]) which can be used to monitor the progress of the module.&lt;br /&gt;
&lt;br /&gt;
'' Passing Fiducials to CLIs via a Python Script ''&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
import SampleData&lt;br /&gt;
sampleDataLogic = SampleData.SampleDataLogic()&lt;br /&gt;
head = sampleDataLogic.downloadMRHead()&lt;br /&gt;
volumesLogic = slicer.modules.volumes.logic()&lt;br /&gt;
headLabel = volumesLogic.CreateLabelVolume(slicer.mrmlScene, head, 'head-label')&lt;br /&gt;
&lt;br /&gt;
fiducialNode = slicer.vtkMRMLAnnotationFiducialNode()&lt;br /&gt;
fiducialNode.SetFiducialWorldCoordinates((1,0,5))&lt;br /&gt;
fiducialNode.SetName('Seed Point')&lt;br /&gt;
fiducialNode.Initialize(slicer.mrmlScene)&lt;br /&gt;
fiducialsList = getNode('Fiducials List')&lt;br /&gt;
&lt;br /&gt;
params = {'inputVolume': head.GetID(), 'outputVolume': headLabel.GetID(), 'seed' : fiducialsList.GetID(), 'iterations' : 2} &lt;br /&gt;
&lt;br /&gt;
cliNode = slicer.cli.run(slicer.modules.simpleregiongrowingsegmentation, None, params , wait_for_completion=True)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'' Checking Status''&lt;br /&gt;
&lt;br /&gt;
In this example we create a simple callback that will be called whenever the cliNode is modified.  The status will tell you if the nodes is Pending, Running, or Completed.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
def printStatus(caller, event):&lt;br /&gt;
  print(&amp;quot;Got a %s from a %s&amp;quot; % (event, caller.GetClassName()))&lt;br /&gt;
  if caller.IsA('vtkMRMLCommandLineModuleNode'):&lt;br /&gt;
    print(&amp;quot;Status is %s&amp;quot; % caller.GetStatusString())&lt;br /&gt;
&lt;br /&gt;
cliNode.AddObserver('ModifiedEvent', printStatus)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Accessing slice vtkRenderWindows from slice views ====&lt;br /&gt;
&lt;br /&gt;
The example below shows how to get the rendered slice window.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
lm = slicer.app.layoutManager()&lt;br /&gt;
redWidget = lm.sliceWidget('Red')&lt;br /&gt;
redView = redWidget.sliceView()&lt;br /&gt;
wti = vtk.vtkWindowToImageFilter()&lt;br /&gt;
wti.SetInput(redView.renderWindow())&lt;br /&gt;
wti.Update()&lt;br /&gt;
v = vtk.vtkImageViewer()&lt;br /&gt;
v.SetColorWindow(255)&lt;br /&gt;
v.SetColorLevel(128)&lt;br /&gt;
v.SetInputConnection(wti.GetOutputPort())&lt;br /&gt;
v.Render()&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
''TODO: some more samples of the Qt console''&lt;br /&gt;
&lt;br /&gt;
== In iPython ==&lt;br /&gt;
&lt;br /&gt;
''Important: The example below was developed for an early beta version of slicer4 and is not supported in Slicer 4.0 or 4.1''&lt;br /&gt;
&lt;br /&gt;
See [http://slicer-devel.65872.n3.nabble.com/import-slicer-problem-in-using-python-in-the-shell-launched-using-quot-slicer-xterm-amp-quot-td3968880.html this thread for information on adapting this approach to Slicer 4.1].&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[http://ipython.scipy.org iPython] is a powerful shell and can also be used to access the vtk and slicer APIs (but not Qt at the moment).&lt;br /&gt;
&lt;br /&gt;
As of Slicer4 beta in February 2011, it is possible to use these steps for installation.  This has only been tested on a ubuntu linux system so far.&lt;br /&gt;
&lt;br /&gt;
These instructions assume you have a Slicer4-superbuild directory created according to the [[Slicer4:Build_Instructions|Slicer4 Build Instructions]].&lt;br /&gt;
&lt;br /&gt;
See the [http://matplotlib.sourceforge.net|matplotlib] website for more example plot types.&lt;br /&gt;
&lt;br /&gt;
=== Prerequisites ===&lt;br /&gt;
&lt;br /&gt;
* Get readline - it will make iPython more useful.&lt;br /&gt;
&lt;br /&gt;
 # do this before building slicer4 - or do &amp;quot;cd Slicer4-superbuild/; rm -rf python* ; make&amp;quot;&lt;br /&gt;
 sudo apt-get install libreadline6-dev&lt;br /&gt;
&lt;br /&gt;
cd to your Slicer4-superbuild directory for the rest of these steps&lt;br /&gt;
&lt;br /&gt;
* Install the vtk package in the python tree&lt;br /&gt;
 # TODO: this should be done in superbuild script&lt;br /&gt;
 (cd ./VTK-build/Wrapping/Python;  ../../../Slicer-build/Slicer4 --launch ../../../python-build/bin/python setup.py install)&lt;br /&gt;
&lt;br /&gt;
* Install ipython:&lt;br /&gt;
&lt;br /&gt;
 git clone git://github.com/ipython/ipython.git&lt;br /&gt;
 (cd ./ipython; git checkout 0.10.2)&lt;br /&gt;
 (cd ./ipython;  ../Slicer-build/Slicer4 --launch ../python-build/bin/python setup.py install)&lt;br /&gt;
&lt;br /&gt;
* Install matplotlib (remove the source after installing so python import will not get confused by it.)&lt;br /&gt;
&lt;br /&gt;
 git clone git://github.com/pieper/matplotlib.git&lt;br /&gt;
 (cd ./matplotlib;  ../Slicer-build/Slicer4 --launch ../python-build/bin/python setup.py install)&lt;br /&gt;
 rm -rf matplotlib&lt;br /&gt;
&lt;br /&gt;
=== Now try it! ===&lt;br /&gt;
[[image:Slicer4-matplotlib-2011-02-26.png|thumb|300px|right|python plotting from ipython using slicer libraries]]&lt;br /&gt;
&lt;br /&gt;
Launch an xterm with all the paths set correctly to find the slicer python packages&lt;br /&gt;
&lt;br /&gt;
 ./Slicer-build/Slicer4 --launch xterm &amp;amp;&lt;br /&gt;
&lt;br /&gt;
Now, ''inside the xterm'' launch ipython&lt;br /&gt;
&lt;br /&gt;
 ./python-build/bin/ipython&lt;br /&gt;
&lt;br /&gt;
Inside ipython you can past the following script that does:&lt;br /&gt;
* create a mrml scene and add a volume&lt;br /&gt;
* make a numpy aray from the image data&lt;br /&gt;
* do calculations in numpy and vtk for comparision&lt;br /&gt;
* make a histogram plot of the data&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
import vtk&lt;br /&gt;
import slicer&lt;br /&gt;
mrml = slicer.vtkMRMLScene()&lt;br /&gt;
vl = slicer.vtkSlicerVolumesLogic()&lt;br /&gt;
vl.SetAndObserveMRMLScene(mrml)&lt;br /&gt;
n = vl.AddArchetypeVolume('../Slicer4/Testing/Data/Input/MRHeadResampled.nhdr', 'CTC')&lt;br /&gt;
i = n.GetImageData()&lt;br /&gt;
print (i.GetScalarRange())&lt;br /&gt;
&lt;br /&gt;
import vtk.util.numpy_support&lt;br /&gt;
a = vtk.util.numpy_support.vtk_to_numpy(i.GetPointData().GetScalars())&lt;br /&gt;
print(a.min(),a.max())&lt;br /&gt;
&lt;br /&gt;
import matplotlib&lt;br /&gt;
import matplotlib.pyplot&lt;br /&gt;
n, bins, patches = matplotlib.pyplot.hist(a, 50, facecolor='g', alpha=0.75)&lt;br /&gt;
matplotlib.pyplot.show()&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If all goes well, you should see an image like the one shown here.&lt;br /&gt;
&lt;br /&gt;
=== Parallel Processing === &lt;br /&gt;
&lt;br /&gt;
In the shell, run this to install [http://packages.python.org/joblib/ joblib]&lt;br /&gt;
&lt;br /&gt;
 wget http://pypi.python.org/packages/source/j/joblib/joblib-0.4.6.dev.tar.gz&lt;br /&gt;
 tar xvfz joblib-0.4.6.dev.tar.gz&lt;br /&gt;
 (cd ./joblib-0.4.6.dev;  ../Slicer-build/Slicer4 --launch ../python-build/bin/python setup.py install)&lt;br /&gt;
&lt;br /&gt;
Then in ipython you can run this example: &lt;br /&gt;
&lt;br /&gt;
 from joblib import *&lt;br /&gt;
 from math import *&lt;br /&gt;
 for jobs in xrange(1,8):&lt;br /&gt;
   print (jobs, Parallel(n_jobs=jobs)(delayed(sqrt)(i**2) for i in range(10000))[-1])&lt;br /&gt;
&lt;br /&gt;
=== Packaging/Saving Scenes ===&lt;br /&gt;
&lt;br /&gt;
A basic example.  The following packages all of the scene's referenced files into one specified folder.  All images, csvs, volumes, etc. (everything except the scene .mrml) are copied into the folder &amp;quot;&amp;lt;package dir&amp;gt;/data.&amp;quot;  The scene .mrml is in the &amp;quot;&amp;lt;package dir&amp;gt;&amp;quot; directory. &lt;br /&gt;
&lt;br /&gt;
 import os &lt;br /&gt;
 # Library for OS specific routines&lt;br /&gt;
 &lt;br /&gt;
 tempDir = os.path.join(slicer.app.slicerHome, ‘testScene’) &lt;br /&gt;
 # Put our temp scene directory into the slicer directory.  os.path.join takes care of slash issues that you may encounter with UNIX-Windows compatibility.    &lt;br /&gt;
 &lt;br /&gt;
 os.mkdir(tempDir) &lt;br /&gt;
&lt;br /&gt;
 l = slicer.app.applicationLogic()&lt;br /&gt;
 l.SaveSceneToSlicerDataBundleDirectory(tempDir, None)&lt;br /&gt;
&lt;br /&gt;
=== Loading DICOM Sets ===&lt;br /&gt;
&lt;br /&gt;
The approach is to point Slicer's DICOM database to the directory of the new files.  The command appends the existing database with the files found in the inputted directory.&lt;br /&gt;
 i = ctk.ctkDICOMIndexer()&lt;br /&gt;
 i.addDirectory(slicer.dicomDatabase, '/yourDICOMdir/')&lt;br /&gt;
&lt;br /&gt;
One approach to begin the load process is to call on the DICOM module, which will automatically open the &amp;quot;DICOM Details&amp;quot; popup.  However, if the popup has been used already in the current Slicer session, a refresh may not occur and a restart may be required.&lt;br /&gt;
 m = slicer.util.mainWindow()&lt;br /&gt;
 m.moduleSelector().selectModule('DICOM')&lt;br /&gt;
&lt;br /&gt;
=Issues=&lt;br /&gt;
* matplotlib currently uses Tk to show the window on Linux and it does not handle pan/zoom events correctly.  Ideally there would be a PythonQt wrapper for the plots and this is probably required for use on windows (and maybe mac).&lt;br /&gt;
&lt;br /&gt;
* the matplotlib window is in the same thread with the ipython window so you cannot keep the plot open while working on the next one.  However you can save the plot to a file (png, pdf, etc...) and look at it with another program while working in ipython.&lt;br /&gt;
&lt;br /&gt;
* in slicer4 the PythonQt package is loaded as 'qt', however matplotlib tries running 'import qt' as a way to determine if it is running in PyQt version 3.  Because of this a patched version of matplotlib is required (see [https://github.com/pieper/matplotlib/commit/23bca600c27924450128bfe6e68196eb87cf0654 this diff])&lt;br /&gt;
&lt;br /&gt;
* Tested in Windows 7: Python 2.6.6 (used in Slicer 4.1) has errors in referencing its XML DOM parsers, such as ElementTree.  This is a Windows-specific issue -- the same code works in Linux Ubuntu.  Solution thus far is to write your own XML parser.&lt;/div&gt;</summary>
		<author><name>UpdateBot</name></author>
		
	</entry>
</feed>