<?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.4%2FFAQ%2FScripting</id>
	<title>Documentation/4.4/FAQ/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.4%2FFAQ%2FScripting"/>
	<link rel="alternate" type="text/html" href="https://www.slicer.org/w/index.php?title=Documentation/4.4/FAQ/Scripting&amp;action=history"/>
	<updated>2026-04-25T10:54:50Z</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.4/FAQ/Scripting&amp;diff=42178&amp;oldid=prev</id>
		<title>JChris.FillionR at 16:23, 15 July 2015</title>
		<link rel="alternate" type="text/html" href="https://www.slicer.org/w/index.php?title=Documentation/4.4/FAQ/Scripting&amp;diff=42178&amp;oldid=prev"/>
		<updated>2015-07-15T16:23:02Z</updated>

		<summary type="html">&lt;p&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:23, 15 July 2015&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-l2&quot; &gt;Line 2:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 2:&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;noinclude&amp;gt;__TOC__&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;noinclude&amp;gt;__TOC__&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;={{#titleparts: {{PAGENAME}} | | -1 }}=&amp;lt;/noinclude&amp;gt;&amp;lt;includeonly&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;={{#titleparts: {{PAGENAME}} | | -1 }}=&amp;lt;/noinclude&amp;gt;&amp;lt;includeonly&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;='''User FAQ: {{{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;{{#ifeq: {{#titleparts: {{PAGENAME}} | 3 }} | Documentation/{{documentation/version}}/Developers | | &lt;/ins&gt;='''User FAQ: {{{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;div&gt;&amp;lt;/includeonly&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;/includeonly&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;/table&gt;</summary>
		<author><name>JChris.FillionR</name></author>
		
	</entry>
	<entry>
		<id>https://www.slicer.org/w/index.php?title=Documentation/4.4/FAQ/Scripting&amp;diff=40228&amp;oldid=prev</id>
		<title>UpdateBot: Nightly -&gt; 4.4</title>
		<link rel="alternate" type="text/html" href="https://www.slicer.org/w/index.php?title=Documentation/4.4/FAQ/Scripting&amp;diff=40228&amp;oldid=prev"/>
		<updated>2014-12-25T06:44:59Z</updated>

		<summary type="html">&lt;p&gt;Nightly -&amp;gt; 4.4&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;&amp;lt;noinclude&amp;gt;{{documentation/versioncheck}}&amp;lt;/noinclude&amp;gt;&lt;br /&gt;
&amp;lt;noinclude&amp;gt;__TOC__&lt;br /&gt;
={{#titleparts: {{PAGENAME}} | | -1 }}=&amp;lt;/noinclude&amp;gt;&amp;lt;includeonly&amp;gt;&lt;br /&gt;
='''User FAQ: {{{1}}}'''=&lt;br /&gt;
&amp;lt;/includeonly&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== How to grab full slice image (+-volume, +-model) ? ==&lt;br /&gt;
&lt;br /&gt;
=== A Few General Approaches ===&lt;br /&gt;
&lt;br /&gt;
There are multiple ways to access image data from one or all of the slice views.  &lt;br /&gt;
&lt;br /&gt;
==== VTK Window to Image Function  (vtk.vtkWindowToImageFilter() ====&lt;br /&gt;
&lt;br /&gt;
: #   Example to grab image from red slice view and output as TIF&lt;br /&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;
: w = vtk.vtkTIFFWriter()&lt;br /&gt;
: w.SetInputConnection(wti.GetOutputPort())&lt;br /&gt;
: w.SetFileName('tmp/test.tif')&lt;br /&gt;
: w.Write()&lt;br /&gt;
&lt;br /&gt;
==== Direct access to widget data using ====&lt;br /&gt;
&lt;br /&gt;
: #    Example grabs image from red slice view and outputs as PNG&lt;br /&gt;
&lt;br /&gt;
: lm = slicer.app.layoutManager()&lt;br /&gt;
: redWidget = lm.sliceWidget('Red')&lt;br /&gt;
: im = redWidget.imageData()&lt;br /&gt;
: w = vtk.vtkPNGWriter()&lt;br /&gt;
: w.SetInput(im)&lt;br /&gt;
: w.SetFileName('tmp/test.png')&lt;br /&gt;
: w.Write()&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== QImages using the qt.QPixmap.grabWidget function ====&lt;br /&gt;
      &lt;br /&gt;
: #   example to grab all views and store in 'image'&lt;br /&gt;
          image = qt.QPixmap.grabWidget(slicer.util.mainWindow()).toImage()&lt;br /&gt;
&lt;br /&gt;
: #   example to grab 3d view, store in tdv, then output as a png image file&lt;br /&gt;
          tdv = lm.threeDWidget(0).threeDView()&lt;br /&gt;
          qt.QPixmap().grabWidget(tdv).toImage().save('/tmp/test.png')&lt;br /&gt;
&lt;br /&gt;
=== Notes ===&lt;br /&gt;
&lt;br /&gt;
This is also useful for slicing up whatever is shown (eg. voxelizing model data) by iterating this over the dimensions of the volume/model &lt;br /&gt;
&lt;br /&gt;
In order to view models in the slice view make sure to activate the &amp;quot;Slice Intersections Visible&amp;quot; property of the model&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Specific Example ===&lt;br /&gt;
&lt;br /&gt;
The following script iterates through the red slice view and outputs each slice as a .png image.  &lt;br /&gt;
It was originally designed to output volume+model data together slice-by-slice&lt;br /&gt;
&lt;br /&gt;
: https://gist.github.com/gortscizz/5060517&lt;/div&gt;</summary>
		<author><name>UpdateBot</name></author>
		
	</entry>
</feed>