Difference between revisions of "Documentation/Nightly/Developers/FAQ/Python Scripting"

From Slicer Wiki
Jump to: navigation, search
m (Created page with '<noinclude>__TOC__ ={{#titleparts: {{PAGENAME}} | | -1 }}=</noinclude><includeonly> ='''Developer FAQ: {{{1}}}'''= </includeonly> == How to save an image/volume using python ? =…')
 
Line 13: Line 13:
 
* https://github.com/Slicer/Slicer/blob/master/Base/Python/slicer/util.py#L229-267
 
* https://github.com/Slicer/Slicer/blob/master/Base/Python/slicer/util.py#L229-267
 
* https://github.com/Slicer/Slicer/blob/master/Base/Python/slicer/tests/test_slicer_util_save.py
 
* https://github.com/Slicer/Slicer/blob/master/Base/Python/slicer/tests/test_slicer_util_save.py
 +
 +
 +
== How to assign a volume to a Slice view ? ==
 +
 +
Assuming the <code>MRHead</code> sample data has been loaded, you could do the following:
 +
 +
<pre>
 +
>>> red_logic = slicer.app.layoutManager().sliceWidget("Red").sliceLogic()
 +
>>> red_cn = red_logic.GetSliceCompositeNode()
 +
>>> red_logic.GetSliceCompositeNode().SetBackgroundVolumeID(slicer.util.getNode('MRHead').GetID())
 +
</pre>
 +
 +
Discussion: http://slicer-devel.65872.n3.nabble.com/Assign-volumes-to-views-tt4028694.html

Revision as of 22:50, 20 May 2013

Home < Documentation < Nightly < Developers < FAQ < Python Scripting

Python Scripting

How to save an image/volume using python ?

The module slicer.util provides methods allowing to save either a node or an entire scene:

  • saveNode
  • saveScene

For more details see:


How to assign a volume to a Slice view ?

Assuming the MRHead sample data has been loaded, you could do the following:

>>> red_logic = slicer.app.layoutManager().sliceWidget("Red").sliceLogic()
>>> red_cn = red_logic.GetSliceCompositeNode()
>>> red_logic.GetSliceCompositeNode().SetBackgroundVolumeID(slicer.util.getNode('MRHead').GetID())

Discussion: http://slicer-devel.65872.n3.nabble.com/Assign-volumes-to-views-tt4028694.html