<?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.3%2FDevelopers%2FFAQ%2FPython_Scripting</id>
	<title>Documentation/4.3/Developers/FAQ/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.3%2FDevelopers%2FFAQ%2FPython_Scripting"/>
	<link rel="alternate" type="text/html" href="https://www.slicer.org/w/index.php?title=Documentation/4.3/Developers/FAQ/Python_Scripting&amp;action=history"/>
	<updated>2026-05-05T05:03:49Z</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.3/Developers/FAQ/Python_Scripting&amp;diff=35179&amp;oldid=prev</id>
		<title>UpdateBot: Nightly -&gt; 4.3</title>
		<link rel="alternate" type="text/html" href="https://www.slicer.org/w/index.php?title=Documentation/4.3/Developers/FAQ/Python_Scripting&amp;diff=35179&amp;oldid=prev"/>
		<updated>2013-09-05T03:32:08Z</updated>

		<summary type="html">&lt;p&gt;Nightly -&amp;gt; 4.3&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;
='''Developer FAQ: {{{1}}}'''=&lt;br /&gt;
&amp;lt;/includeonly&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== How to systematically execute custom python code at startup ? ==&lt;br /&gt;
&lt;br /&gt;
Each time Slicer starts, it will look up for a file named &amp;lt;code&amp;gt;.slicerrc.py&amp;lt;/code&amp;gt; into your HOME folder.&lt;br /&gt;
&lt;br /&gt;
See [[Documentation/{{documentation/version}}/FAQ/General#What_is_my_HOME_folder_.3F|What is my HOME folder ?]]&lt;br /&gt;
&lt;br /&gt;
== How to save an image/volume using python ? ==&lt;br /&gt;
&lt;br /&gt;
The module &amp;lt;code&amp;gt;slicer.util&amp;lt;/code&amp;gt; provides methods allowing to save either a node or an entire scene:&lt;br /&gt;
* saveNode&lt;br /&gt;
* saveScene&lt;br /&gt;
&lt;br /&gt;
For more details see:&lt;br /&gt;
* https://github.com/Slicer/Slicer/blob/master/Base/Python/slicer/util.py#L229-267&lt;br /&gt;
* https://github.com/Slicer/Slicer/blob/master/Base/Python/slicer/tests/test_slicer_util_save.py&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== How to assign a volume to a Slice view ? ==&lt;br /&gt;
&lt;br /&gt;
Assuming the &amp;lt;code&amp;gt;MRHead&amp;lt;/code&amp;gt; sample data has been loaded, you could do the following:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
red_logic = slicer.app.layoutManager().sliceWidget(&amp;quot;Red&amp;quot;).sliceLogic()&lt;br /&gt;
red_cn = red_logic.GetSliceCompositeNode()&lt;br /&gt;
red_logic.GetSliceCompositeNode().SetBackgroundVolumeID(slicer.util.getNode('MRHead').GetID())&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Discussion: http://slicer-devel.65872.n3.nabble.com/Assign-volumes-to-views-tt4028694.html&lt;br /&gt;
&lt;br /&gt;
== How to access vtkRenderer in Slicer 3D view ? ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
renderer = slicer.app.layoutManager().threeDWidget(0).threeDView().renderWindow().GetRenderers().GetFirstRenderer()&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Should I used 'old style' or 'new style' python classes in my scripted module ==&lt;br /&gt;
&lt;br /&gt;
When python classes have no superclass specified they are 'old style' as described here [http://docs.python.org/2/reference/datamodel.html#new-style-and-classic-classes].&lt;br /&gt;
&lt;br /&gt;
In general it doesn't matter for the classes in a scripted module, since they won't be subclassed either old or new style should be the same.&lt;br /&gt;
&lt;br /&gt;
For other python code in slicer where you might be subclassing, it's better to use new style classes.  See the class hierarchies in the [https://github.com/Slicer/Slicer/tree/master/Modules/Scripted/EditorLib EditorLib] and the [https://github.com/Slicer/Slicer/tree/master/Modules/Scripted/DICOM/DICOMLib DICOMLib] for examples.&lt;br /&gt;
&lt;br /&gt;
== How to harden a transform ? ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;gt;&amp;gt;&amp;gt; n = getNode('Bone')&lt;br /&gt;
&amp;gt;&amp;gt;&amp;gt; logic = slicer.vtkSlicerTransformLogic()&lt;br /&gt;
&amp;gt;&amp;gt;&amp;gt; logic.hardenTransform(n)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Discussion: http://slicer-devel.65872.n3.nabble.com/Scripting-hardened-transforms-tt4029456.html&lt;br /&gt;
&lt;br /&gt;
== Where can I find example scripts? ==&lt;br /&gt;
&lt;br /&gt;
Have a look at [[Documentation/{{documentation/version}}/ScriptRepository]].&lt;/div&gt;</summary>
		<author><name>UpdateBot</name></author>
		
	</entry>
</feed>