<?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=Inorton</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=Inorton"/>
	<link rel="alternate" type="text/html" href="https://www.slicer.org/wiki/Special:Contributions/Inorton"/>
	<updated>2026-08-13T19:30:37Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.33.0</generator>
	<entry>
		<id>https://www.slicer.org/w/index.php?title=Documentation/Nightly/ScriptRepository&amp;diff=60490</id>
		<title>Documentation/Nightly/ScriptRepository</title>
		<link rel="alternate" type="text/html" href="https://www.slicer.org/w/index.php?title=Documentation/Nightly/ScriptRepository&amp;diff=60490"/>
		<updated>2018-10-26T20:20:55Z</updated>

		<summary type="html">&lt;p&gt;Inorton: /* Create custom color table */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;noinclude&amp;gt;{{documentation/versioncheck}}&amp;lt;/noinclude&amp;gt;&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Community-contributed modules=&lt;br /&gt;
&lt;br /&gt;
The examples in this section are [[Documentation/{{documentation/version}}/Developers/Modules#Scripted_Modules| Scripted Modules]] that provide a user interface in the module panel along with specialized implementation logic.&lt;br /&gt;
&lt;br /&gt;
Usage: save the .py file to a directory, add the directory to the additional module paths in the Slicer application settings (choose in the menu: Edit / Application settings, click Modules, click &amp;gt;&amp;gt; next to Additional module paths, click Add, and choose the .py file's location).&lt;br /&gt;
&lt;br /&gt;
==Filters==&lt;br /&gt;
* [https://raw.github.com/pieper/VolumeMasker/master/VolumeMasker.py VolumeMasker.py]: Update a target volume with the results of setting all input volume voxels to 0 except for those that correspond to a selected label value in an input label map (Used for example in the volume rendering in [https://www.youtube.com/watch?v=dfu2gugHLHs this video).&lt;br /&gt;
&lt;br /&gt;
==DICOM==&lt;br /&gt;
* [https://gist.github.com/pieper/6186477 dicom header browser] to easily scroll through dicom files using dcmdump.&lt;br /&gt;
* [https://github.com/SlicerRt/SlicerRT/tree/master/BatchProcessing SlicerRT batch processing] to batch convert RT structure sets to labelmap NRRD files.&lt;br /&gt;
&lt;br /&gt;
==Informatics==&lt;br /&gt;
* [https://gist.github.com/lassoan/bf0954d93cacc8cbe27cd4a3ad503f2f MarkupsInfo.py]: Compute the total length between all the points of a markup list.&lt;br /&gt;
* [https://gist.github.com/lassoan/0e7acfbec36e4577f8b7b0e07ad53a2a LineProfile.py]: Compute intensity profile in a volume along a line.&lt;br /&gt;
&lt;br /&gt;
=Community-contributed examples=&lt;br /&gt;
&lt;br /&gt;
Usage: Copy-paste the shown code lines or linked .py file contents into Python console in Slicer.  Or save them to a file and run them using execfile.&lt;br /&gt;
&lt;br /&gt;
==Capture==&lt;br /&gt;
* Capture the full Slicer screen and save it into a file&lt;br /&gt;
  img = qt.QPixmap.grabWidget(slicer.util.mainWindow()).toImage()&lt;br /&gt;
  img.save('c:/tmp/test.png')&lt;br /&gt;
* Capture all the views save it into a file:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
import ScreenCapture&lt;br /&gt;
cap = ScreenCapture.ScreenCaptureLogic()&lt;br /&gt;
cap.showViewControllers(False)&lt;br /&gt;
cap.captureImageFromView(None,'c:/tmp/test.png')&lt;br /&gt;
cap.showViewControllers(True)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
* Capture a single view:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
viewNodeID = 'vtkMRMLViewNode1'&lt;br /&gt;
import ScreenCapture&lt;br /&gt;
cap = ScreenCapture.ScreenCaptureLogic()&lt;br /&gt;
view = cap.viewFromNode(slicer.mrmlScene.GetNodeByID(viewNodeID))&lt;br /&gt;
cap.captureImageFromView(view,'c:/tmp/test.png')&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Common values for viewNodeID: vtkMRMLSliceNodeRed, vtkMRMLSliceNodeYellow, vtkMRMLSliceNodeGreen, vtkMRMLViewNode1, vtkMRMLViewNode2. &lt;br /&gt;
The ScreenCapture module can also create video animations of rotating views, slice sweeps, etc.&lt;br /&gt;
&lt;br /&gt;
* Capture a slice view sweep into a series of PNG files - for example, Red slice view, 30 images, from position -125.0 to 75.0, into c:/tmp folder, with name image_00001.png, image_00002.png, ...&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
import ScreenCapture&lt;br /&gt;
ScreenCapture.ScreenCaptureLogic().captureSliceSweep(getNode('vtkMRMLSliceNodeRed'), -125.0, 75.0, 30, &amp;quot;c:/tmp&amp;quot;, &amp;quot;image_%05d.png&amp;quot;)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Capture 3D view into PNG file with transparent background&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
renderWindow = slicer.app.layoutManager().threeDWidget(0).threeDView().renderWindow()&lt;br /&gt;
renderWindow.SetAlphaBitPlanes(1)&lt;br /&gt;
wti = vtk.vtkWindowToImageFilter()&lt;br /&gt;
wti.SetInputBufferTypeToRGBA()&lt;br /&gt;
wti.SetInput(renderWindow)&lt;br /&gt;
writer = vtk.vtkPNGWriter()&lt;br /&gt;
writer.SetFileName(&amp;quot;c:/tmp/screenshot.png&amp;quot;)&lt;br /&gt;
writer.SetInputConnection(wti.GetOutputPort())&lt;br /&gt;
writer.Write()&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Launching Slicer==&lt;br /&gt;
* How to open an .mrb file with Slicer at the command line?&lt;br /&gt;
  Slicer.exe --python-code &amp;quot;slicer.util.loadScene( 'f:/2013-08-23-Scene.mrb' )&amp;quot;&lt;br /&gt;
* How to run a script in the Slicer environment in batch mode (without showing any graphical user interface)?&lt;br /&gt;
  Slicer.exe --python-code &amp;quot;doSomething; doSomethingElse; etc.&amp;quot; --testing --no-splash --no-main-window&lt;br /&gt;
&lt;br /&gt;
==Load volume from file==&lt;br /&gt;
When loading a volume from file, it is recommended to set returnNode=True to retrieve the loaded volume node.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
[success, loadedVolumeNode] = slicer.util.loadVolume('c:/Users/abc/Documents/MRHead.nrrd', returnNode=True)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Get a MRML node in the scene based on the node name and call methods of that object. For the MRHead sample data:&lt;br /&gt;
  vol=slicer.util.getNode('MR*')&lt;br /&gt;
  vol.GetImageData().GetDimensions()&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Show volume rendering automatically when a volume is loaded==&lt;br /&gt;
&lt;br /&gt;
To show volume rendering of a volume automatically when it is loaded, add the lines below to your &lt;br /&gt;
[[Documentation/{{documentation/version}}/Developers/Python_scripting#How_to_systematically_execute_custom_python_code_at_startup_.3F|.slicerrc file]].&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
@vtk.calldata_type(vtk.VTK_OBJECT)&lt;br /&gt;
def onNodeAdded(caller, event, calldata):&lt;br /&gt;
  node = calldata&lt;br /&gt;
  if isinstance(node, slicer.vtkMRMLVolumeNode):&lt;br /&gt;
    # Call showVolumeRendering using a timer instead of calling it directly&lt;br /&gt;
    # to allow the volume loading to fully complete.&lt;br /&gt;
    qt.QTimer.singleShot(0, lambda: showVolumeRendering(node))&lt;br /&gt;
&lt;br /&gt;
def showVolumeRendering(volumeNode):&lt;br /&gt;
  print(&amp;quot;Show volume rendering of node &amp;quot;+volumeNode.GetName())&lt;br /&gt;
  volRenLogic = slicer.modules.volumerendering.logic()&lt;br /&gt;
  displayNode = volRenLogic.CreateDefaultVolumeRenderingNodes(volumeNode)&lt;br /&gt;
  displayNode.SetVisibility(True)&lt;br /&gt;
  scalarRange = volumeNode.GetImageData().GetScalarRange()&lt;br /&gt;
  if scalarRange[1]-scalarRange[0] &amp;lt; 1500:&lt;br /&gt;
    # small dynamic range, probably MRI&lt;br /&gt;
    displayNode.GetVolumePropertyNode().Copy(volRenLogic.GetPresetByName('MR-Default'))&lt;br /&gt;
  else:&lt;br /&gt;
    # larger dynamic range, probably CT&lt;br /&gt;
    displayNode.GetVolumePropertyNode().Copy(volRenLogic.GetPresetByName('CT-Chest-Contrast-Enhanced'))&lt;br /&gt;
    &lt;br /&gt;
slicer.mrmlScene.AddObserver(slicer.vtkMRMLScene.NodeAddedEvent, onNodeAdded)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==DICOM==&lt;br /&gt;
=== How to access tags of DICOM images imported into Slicer? For example, to print the first patient's first study's first series' &amp;quot;0020,0032&amp;quot; field:===&lt;br /&gt;
  db=slicer.dicomDatabase&lt;br /&gt;
  patientList=db.patients()&lt;br /&gt;
  studyList=db.studiesForPatient(patientList[0])&lt;br /&gt;
  seriesList=db.seriesForStudy(studyList[0])&lt;br /&gt;
  fileList=db.filesForSeries(seriesList[0])&lt;br /&gt;
  print db.fileValue(fileList[0],'0020,0032')&lt;br /&gt;
&lt;br /&gt;
=== How to access tag of a volume loaded from DICOM? For example, get the patient position stored in a volume:===&lt;br /&gt;
  volumeName='2: ENT IMRT'&lt;br /&gt;
  n=slicer.util.getNode(volumeName)&lt;br /&gt;
  instUids=n.GetAttribute('DICOM.instanceUIDs').split()&lt;br /&gt;
  filename=slicer.dicomDatabase.fileForInstance(instUids[0])&lt;br /&gt;
  print slicer.dicomDatabase.fileValue(filename,'0018,5100')&lt;br /&gt;
&lt;br /&gt;
=== How to access tag of an item in the Subject Hierachy tree? For example, get the content time tag of a structure set:===&lt;br /&gt;
  rtStructName = '3: RTSTRUCT: PROS'&lt;br /&gt;
  rtStructNode = slicer.util.getNode(rtStructName)&lt;br /&gt;
  shNode = slicer.vtkMRMLSubjectHierarchyNode.GetSubjectHierarchyNode(slicer.mrmlScene)&lt;br /&gt;
  rtStructShItemID = shNode.GetItemByDataNode(rtStructNode)&lt;br /&gt;
  ctSliceInstanceUids = shNode.GetItemAttribute(rtStructShItemID, 'DICOM.ReferencedInstanceUIDs').split()&lt;br /&gt;
  filename = slicer.dicomDatabase.fileForInstance(ctSliceInstanceUids[0])&lt;br /&gt;
  print slicer.dicomDatabase.fileValue(filename,'0008,0033')&lt;br /&gt;
&lt;br /&gt;
=== How to get path and filename of a loaded DICOM volume?===&lt;br /&gt;
  def pathFromNode(node):&lt;br /&gt;
    storageNode=node.GetStorageNode()&lt;br /&gt;
    if storageNode is not None: # loaded via drag-drop&lt;br /&gt;
        filepath=storageNode.GetFullNameFromFileName()&lt;br /&gt;
    else: # loaded via DICOM browser&lt;br /&gt;
        instanceUIDs=node.GetAttribute('DICOM.instanceUIDs').split()&lt;br /&gt;
        filepath=slicer.dicomDatabase.fileForInstance(instUids[0])&lt;br /&gt;
    return filepath&lt;br /&gt;
  &lt;br /&gt;
  # example:&lt;br /&gt;
  node=slicer.util.getNode('volume1')&lt;br /&gt;
  path=self.pathFromNode(node)&lt;br /&gt;
  print(&amp;quot;DICOM path=%s&amp;quot; % path)&lt;br /&gt;
&lt;br /&gt;
=== How can I convert DICOM to NRRD on the command line?===&lt;br /&gt;
&lt;br /&gt;
 /Applications/Slicer-4.6.2.app/Contents/MacOS/Slicer --no-main-window --python-code &amp;quot;node=slicer.util.loadVolume('/tmp/series/im0.dcm', returnNode=True)[1]; slicer.util.saveNode(node, '/tmp/output.nrrd'); exit()&amp;quot;&lt;br /&gt;
&lt;br /&gt;
The same can be done on windows by using the top level Slicer.exe.  Be sure to use forward slashes in the pathnames within quotes on the command line.&lt;br /&gt;
&lt;br /&gt;
=== Export a volume to DICOM file format ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
volumeNode = getNode('CTChest')&lt;br /&gt;
outputFolder = &amp;quot;c:/tmp/dicom-output&amp;quot;&lt;br /&gt;
&lt;br /&gt;
# Create patient and study and put the volume under the study&lt;br /&gt;
shNode = slicer.vtkMRMLSubjectHierarchyNode.GetSubjectHierarchyNode(slicer.mrmlScene)&lt;br /&gt;
patientItemID = shNode.CreateSubjectItem(shNode.GetSceneItemID(), &amp;quot;test patient&amp;quot;)&lt;br /&gt;
studyItemID = shNode.CreateStudyItem(patientItemID, &amp;quot;test study&amp;quot;)&lt;br /&gt;
volumeShItemID = shNode.GetItemByDataNode(volumeNode)&lt;br /&gt;
shNode.SetItemParent(volumeShItemID, studyItemID)&lt;br /&gt;
&lt;br /&gt;
import DICOMScalarVolumePlugin&lt;br /&gt;
exporter = DICOMScalarVolumePlugin.DICOMScalarVolumePluginClass()&lt;br /&gt;
exportables = exporter.examineForExport(volumeShItemID)&lt;br /&gt;
for exp in exportables:&lt;br /&gt;
  exp.directory = outputFolder&lt;br /&gt;
&lt;br /&gt;
exporter.export(exportables)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Toolbar functions==&lt;br /&gt;
* How to turn on slice intersections in the crosshair menu on the toolbar:&lt;br /&gt;
  viewNodes = slicer.mrmlScene.GetNodesByClass('vtkMRMLSliceCompositeNode')&lt;br /&gt;
  viewNodes.UnRegister(slicer.mrmlScene)&lt;br /&gt;
  viewNodes.InitTraversal()&lt;br /&gt;
  viewNode = viewNodes.GetNextItemAsObject()&lt;br /&gt;
  while viewNode:&lt;br /&gt;
    viewNode.SetSliceIntersectionVisibility(1)&lt;br /&gt;
    viewNode = viewNodes.GetNextItemAsObject()&lt;br /&gt;
&lt;br /&gt;
How to find similar functions? For this one I searched for &amp;quot;slice intersections&amp;quot; text in the whole slicer source code, found that the function is implemented in Base\QTGUI\qSlicerViewersToolBar.cxx, then translated the qSlicerViewersToolBarPrivate::setSliceIntersectionVisible(bool visible) method to Python.&lt;br /&gt;
&lt;br /&gt;
==Manipulating objects in the slice viewer==&lt;br /&gt;
* How to define/edit a circular region of interest in a slice viewer?&lt;br /&gt;
&lt;br /&gt;
Drop two markup points on a slice view and copy-paste the code below into the Python console. After this, as you move the markups you’ll see a circle following the markups.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Update the sphere from the fiducial points&lt;br /&gt;
def UpdateSphere(param1, param2):  &lt;br /&gt;
  import math&lt;br /&gt;
  centerPointCoord = [0.0, 0.0, 0.0]&lt;br /&gt;
  markups.GetNthFiducialPosition(0,centerPointCoord)&lt;br /&gt;
  circumferencePointCoord = [0.0, 0.0, 0.0]&lt;br /&gt;
  markups.GetNthFiducialPosition(1,circumferencePointCoord)&lt;br /&gt;
  sphere.SetCenter(centerPointCoord)&lt;br /&gt;
  radius=math.sqrt((centerPointCoord[0]-circumferencePointCoord[0])**2+(centerPointCoord[1]-circumferencePointCoord[1])**2+(centerPointCoord[2]-circumferencePointCoord[2])**2)&lt;br /&gt;
  sphere.SetRadius(radius)&lt;br /&gt;
  sphere.SetPhiResolution(30)&lt;br /&gt;
  sphere.SetThetaResolution(30)&lt;br /&gt;
  sphere.Update()&lt;br /&gt;
&lt;br /&gt;
# Get markup node from scene&lt;br /&gt;
markups=slicer.util.getNode('F')&lt;br /&gt;
sphere = vtk.vtkSphereSource()&lt;br /&gt;
UpdateSphere(0,0)&lt;br /&gt;
 &lt;br /&gt;
# Create model node and add to scene&lt;br /&gt;
modelsLogic = slicer.modules.models.logic()&lt;br /&gt;
model = modelsLogic.AddModel(sphere.GetOutput())&lt;br /&gt;
model.GetDisplayNode().SetSliceIntersectionVisibility(True)&lt;br /&gt;
model.GetDisplayNode().SetSliceIntersectionThickness(3)&lt;br /&gt;
model.GetDisplayNode().SetColor(1,1,0)&lt;br /&gt;
 &lt;br /&gt;
# Call UpdateSphere whenever the fiducials are changed&lt;br /&gt;
markups.AddObserver(&amp;quot;ModifiedEvent&amp;quot;, UpdateSphere, 2)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Set slice position and orientation from 3 markup fiducials==&lt;br /&gt;
&lt;br /&gt;
Drop 3 markup points in the scene and copy-paste the code below into the Python console. After this, as you move the markups you’ll see the red slice view position and orientation will be set to make it fit to the 3 points.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Update plane from fiducial points&lt;br /&gt;
def UpdateSlicePlane(param1=None, param2=None):&lt;br /&gt;
  # Get point positions as numpy array&lt;br /&gt;
  import numpy as np&lt;br /&gt;
  nOfFiduciallPoints = markups.GetNumberOfFiducials()&lt;br /&gt;
  if nOfFiduciallPoints &amp;lt; 3:&lt;br /&gt;
    return  # not enough points&lt;br /&gt;
  points = np.zeros([3,nOfFiduciallPoints])&lt;br /&gt;
  for i in range(0, nOfFiduciallPoints):&lt;br /&gt;
    markups.GetNthFiducialPosition(i, points[:,i])&lt;br /&gt;
  # Compute plane position and normal&lt;br /&gt;
  planePosition = points.mean(axis=1)&lt;br /&gt;
  planeNormal = np.cross(points[:,1] - points[:,0], points[:,2] - points[:,0])&lt;br /&gt;
  planeX = points[:,1] - points[:,0]&lt;br /&gt;
  sliceNode.SetSliceToRASByNTP(planeNormal[0], planeNormal[1], planeNormal[2],&lt;br /&gt;
    planeX[0], planeX[1], planeX[2],&lt;br /&gt;
    planePosition[0], planePosition[1], planePosition[2], 0)&lt;br /&gt;
&lt;br /&gt;
# Get markup node from scene&lt;br /&gt;
sliceNode = slicer.app.layoutManager().sliceWidget('Red').mrmlSliceNode()&lt;br /&gt;
markups = slicer.util.getNode('F')&lt;br /&gt;
&lt;br /&gt;
# Update slice plane manually&lt;br /&gt;
UpdateSlicePlane()&lt;br /&gt;
&lt;br /&gt;
# Update slice plane automatically whenever points are changed&lt;br /&gt;
markupObservation = [markups, markups.AddObserver(&amp;quot;ModifiedEvent&amp;quot;, UpdateSlicePlane, 2)]&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To stop automatic updates, run this:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
markupObservation[0].RemoveObserver(markupObservation[1])&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Switching to markup fiducial placement mode ==&lt;br /&gt;
&lt;br /&gt;
To activate a fiducial placement mode, both interaction mode has to be set and a fiducial node has to be selected:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
interactionNode = slicer.app.applicationLogic().GetInteractionNode()&lt;br /&gt;
selectionNode = slicer.app.applicationLogic().GetSelectionNode()&lt;br /&gt;
selectionNode.SetReferenceActivePlaceNodeClassName(&amp;quot;vtkMRMLMarkupsFiducialNode&amp;quot;)&lt;br /&gt;
fiducialNode = slicer.vtkMRMLMarkupsFiducialNode()&lt;br /&gt;
slicer.mrmlScene.AddNode(fiducialNode)&lt;br /&gt;
fiducialNode.CreateDefaultDisplayNodes() &lt;br /&gt;
selectionNode.SetActivePlaceNodeID(fiducialNode.GetID())&lt;br /&gt;
interactionNode.SetCurrentInteractionMode(interactionNode.Place)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Get a notification if a markup point position is modified ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
def onMarkupsNodeModified(markupsNode, unusedArg2=None, unusedArg3=None):&lt;br /&gt;
  sliceView = markupsNode.GetAttribute('Markups.MovingInSliceView')&lt;br /&gt;
  if not sliceView:&lt;br /&gt;
    print(&amp;quot;Markup list was modified&amp;quot;)&lt;br /&gt;
    return&lt;br /&gt;
  movingMarkupIndex = markupsNode.GetAttribute('Markups.MovingMarkupIndex')&lt;br /&gt;
  pos = [0,0,0]&lt;br /&gt;
  markupsNode.GetNthFiducialPosition(int(movingMarkupIndex), pos)  &lt;br /&gt;
  print(&amp;quot;Markup {0} was moved in slice view {1} to {2}&amp;quot;.format(movingMarkupIndex, sliceView, pos))&lt;br /&gt;
&lt;br /&gt;
markupsNode = slicer.mrmlScene.AddNewNodeByClass(&amp;quot;vtkMRMLMarkupsFiducialNode&amp;quot;)&lt;br /&gt;
markupsNode.CreateDefaultDisplayNodes()&lt;br /&gt;
markupsNode.AddFiducial(0,0,0)&lt;br /&gt;
markupsNode.AddObserver(vtk.vtkCommand.ModifiedEvent, onMarkupsNodeModified)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Show a context menu when a markup point is clicked in a slice or 3D view ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
# Example actions to perform&lt;br /&gt;
&lt;br /&gt;
def action1():&lt;br /&gt;
  print('Action1 on markup '+str(slicer.clickedMarkupIndex))&lt;br /&gt;
&lt;br /&gt;
def action2():&lt;br /&gt;
  print('Action2 on markup '+str(slicer.clickedMarkupIndex))&lt;br /&gt;
&lt;br /&gt;
def action3():&lt;br /&gt;
  print('Action3 on markup '+str(slicer.clickedMarkupIndex))&lt;br /&gt;
&lt;br /&gt;
# Clicked markup index is saved here to let the action&lt;br /&gt;
# know which markup needs to be manipulated.&lt;br /&gt;
slicer.clickedMarkupIndex = -1&lt;br /&gt;
  &lt;br /&gt;
# Create a simple menu&lt;br /&gt;
&lt;br /&gt;
menu = qt.QMenu()&lt;br /&gt;
a1 = qt.QAction(&amp;quot;Test&amp;quot;, slicer.util.mainWindow())&lt;br /&gt;
a1.connect('triggered()', action1)&lt;br /&gt;
menu.addAction(a1)&lt;br /&gt;
a2 = qt.QAction(&amp;quot;Action&amp;quot;, slicer.util.mainWindow())&lt;br /&gt;
a2.connect('triggered()', action1)&lt;br /&gt;
menu.addAction(a2)&lt;br /&gt;
a3 = qt.QAction(&amp;quot;Here&amp;quot;, slicer.util.mainWindow())&lt;br /&gt;
a3.connect('triggered()', action1)&lt;br /&gt;
menu.addAction(a3)&lt;br /&gt;
&lt;br /&gt;
# Add observer to a markup fiducial list&lt;br /&gt;
&lt;br /&gt;
@vtk.calldata_type(vtk.VTK_INT)&lt;br /&gt;
def markupClickedCallback(caller, eventId, callData):&lt;br /&gt;
  slicer.clickedMarkupIndex = callData&lt;br /&gt;
  print('Open menu on markup '+str(slicer.clickedMarkupIndex))&lt;br /&gt;
  menu.move(qt.QCursor.pos())&lt;br /&gt;
  menu.show()&lt;br /&gt;
&lt;br /&gt;
markupsNode = getNode('F')&lt;br /&gt;
observerTag = markupsNode.AddObserver(slicer.vtkMRMLMarkupsNode.PointClickedEvent, markupClickedCallback)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Add a texture mapped plane to the scene as a model ==&lt;br /&gt;
Note that model textures are not exposed in the GUI and are not saved in the scene&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# use dummy image data here&lt;br /&gt;
e = vtk.vtkImageEllipsoidSource()&lt;br /&gt;
&lt;br /&gt;
scene = slicer.mrmlScene&lt;br /&gt;
&lt;br /&gt;
# Create model node&lt;br /&gt;
model = slicer.vtkMRMLModelNode()&lt;br /&gt;
model.SetScene(scene)&lt;br /&gt;
model.SetName(scene.GenerateUniqueName(&amp;quot;2DImageModel&amp;quot;))&lt;br /&gt;
&lt;br /&gt;
planeSource = vtk.vtkPlaneSource()&lt;br /&gt;
model.SetAndObservePolyData(planeSource.GetOutput())&lt;br /&gt;
&lt;br /&gt;
# Create display node&lt;br /&gt;
modelDisplay = slicer.vtkMRMLModelDisplayNode()&lt;br /&gt;
modelDisplay.SetColor(1,1,0) # yellow&lt;br /&gt;
modelDisplay.SetBackfaceCulling(0)&lt;br /&gt;
modelDisplay.SetScene(scene)&lt;br /&gt;
scene.AddNode(modelDisplay)&lt;br /&gt;
model.SetAndObserveDisplayNodeID(modelDisplay.GetID())&lt;br /&gt;
&lt;br /&gt;
# Add to scene&lt;br /&gt;
modelDisplay.SetAndObserveTextureImageData(e.GetOutput())&lt;br /&gt;
scene.AddNode(model) &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
transform = slicer.vtkMRMLLinearTransformNode()&lt;br /&gt;
scene.AddNode(transform) &lt;br /&gt;
model.SetAndObserveTransformNodeID(transform.GetID())&lt;br /&gt;
&lt;br /&gt;
vTransform = vtk.vtkTransform()&lt;br /&gt;
vTransform.Scale(50,50,50)&lt;br /&gt;
vTransform.RotateX(30)&lt;br /&gt;
transform.SetAndObserveMatrixTransformToParent(vTransform.GetMatrix())&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Export entire scene as VRML ==&lt;br /&gt;
&lt;br /&gt;
Save all surface meshes displayed in the scene (models, markups, etc). Solid colors and coloring by scalar is preserved. Textures are not supported.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
exporter = vtk.vtkVRMLExporter()&lt;br /&gt;
exporter.SetRenderWindow(slicer.app.layoutManager().threeDWidget(0).threeDView().renderWindow())&lt;br /&gt;
exporter.SetFileName('C:/tmp/something.wrl')&lt;br /&gt;
exporter.Write()&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Export model to Blender, including color by scalar ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
modelNode = getNode(&amp;quot;Model&amp;quot;)&lt;br /&gt;
plyFilePath = &amp;quot;c:/tmp/model.ply&amp;quot;&lt;br /&gt;
&lt;br /&gt;
modelDisplayNode = modelNode.GetDisplayNode()&lt;br /&gt;
triangles = vtk.vtkTriangleFilter()&lt;br /&gt;
triangles.SetInputConnection(modelDisplayNode.GetOutputPolyDataConnection())&lt;br /&gt;
&lt;br /&gt;
plyWriter = vtk.vtkPLYWriter()&lt;br /&gt;
plyWriter.SetInputConnection(triangles.GetOutputPort())&lt;br /&gt;
lut = vtk.vtkLookupTable()&lt;br /&gt;
lut.DeepCopy(modelDisplayNode.GetColorNode().GetLookupTable())&lt;br /&gt;
lut.SetRange(modelDisplayNode.GetScalarRange())&lt;br /&gt;
plyWriter.SetLookupTable(lut)&lt;br /&gt;
plyWriter.SetArrayName(modelDisplayNode.GetActiveScalarName())&lt;br /&gt;
&lt;br /&gt;
plyWriter.SetFileName(plyFilePath)&lt;br /&gt;
plyWriter.Write()&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Export a tract (FiberBundle) to Blender, including color ==&lt;br /&gt;
&amp;lt;div id=&amp;quot;Export_a_fiber_tracts_to_Blender.2C_including_color&amp;quot;&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
Note: an interactive version of this script is now included in the [http://dmri.slicer.org/ SlicerDMRI extension] ([https://github.com/SlicerDMRI/SlicerDMRI/tree/master/Modules/Scripted/TractographyExportPLY module code]). &lt;br /&gt;
After installing SlicerDMRI, go to ''Modules -&amp;gt; Diffusion -&amp;gt; Import and Export -&amp;gt; Export tractography to PLY (mesh)''.&lt;br /&gt;
&lt;br /&gt;
The example below shows how to export a tractography &amp;quot;FiberBundleNode&amp;quot; to a PLY file:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
lineDisplayNode = getNode(&amp;quot;*LineDisplay*&amp;quot;)&lt;br /&gt;
plyFilePath = &amp;quot;/tmp/fibers.ply&amp;quot;&lt;br /&gt;
&lt;br /&gt;
tuber = vtk.vtkTubeFilter()&lt;br /&gt;
tuber.SetInputData(lineDisplayNode.GetOutputPolyData())&lt;br /&gt;
tuber.Update()&lt;br /&gt;
tubes = tuber.GetOutputDataObject(0)&lt;br /&gt;
scalars = tubes.GetPointData().GetArray(0)&lt;br /&gt;
scalars.SetName(&amp;quot;scalars&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
triangles = vtk.vtkTriangleFilter()&lt;br /&gt;
triangles.SetInputData(tubes)&lt;br /&gt;
triangles.Update()&lt;br /&gt;
&lt;br /&gt;
colorNode = lineDisplayNode.GetColorNode()&lt;br /&gt;
lookupTable = vtk.vtkLookupTable()&lt;br /&gt;
lookupTable.DeepCopy(colorNode.GetLookupTable())&lt;br /&gt;
lookupTable.SetTableRange(0,1)&lt;br /&gt;
&lt;br /&gt;
plyWriter = vtk.vtkPLYWriter()&lt;br /&gt;
plyWriter.SetInputData(triangles.GetOutput())&lt;br /&gt;
plyWriter.SetLookupTable(lookupTable)&lt;br /&gt;
plyWriter.SetArrayName(&amp;quot;scalars&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
plyWriter.SetFileName(plyFilePath)&lt;br /&gt;
plyWriter.Write()&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Iterate over tract (FiberBundle) streamline points ==&lt;br /&gt;
&lt;br /&gt;
This example shows how to access the points in each line of a FiberBundle as a numpy array (view).&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
from vtk.util.numpy_support import vtk_to_numpy&lt;br /&gt;
&lt;br /&gt;
fb = getNode(&amp;quot;FiberBundle_F&amp;quot;) # &amp;lt;- fill in node ID here&lt;br /&gt;
&lt;br /&gt;
# get point data as 1d array&lt;br /&gt;
points = slicer.util.arrayFromModelPoints(fb)&lt;br /&gt;
&lt;br /&gt;
# get line cell ids as 1d array&lt;br /&gt;
line_ids = vtk_to_numpy(fb.GetPolyData().GetLines().GetData())&lt;br /&gt;
&lt;br /&gt;
# VTK cell ids are stored as&lt;br /&gt;
#   [ N0 c0_id0 ... c0_id0&lt;br /&gt;
#     N1 c1_id0 ... c1_idN1 ]&lt;br /&gt;
# so we need to&lt;br /&gt;
# - read point count for each line (cell)&lt;br /&gt;
# - grab the ids in that range from `line_ids` array defined above&lt;br /&gt;
# - index the `points` array by those ids&lt;br /&gt;
cur_idx = 1&lt;br /&gt;
for _ in range(pd.GetLines().GetNumberOfCells()):&lt;br /&gt;
    # - read point count for this line (cell)&lt;br /&gt;
    count = lines[cur_idx - 1]&lt;br /&gt;
&lt;br /&gt;
    # - grab the ids in that range from `lines`&lt;br /&gt;
    index_array = line_ids[ cur_idx : cur_idx + count]&lt;br /&gt;
    # update to the next range &lt;br /&gt;
    cur_idx += count + 1&lt;br /&gt;
&lt;br /&gt;
    # - index the point array by those ids&lt;br /&gt;
    line_points = points[index_array]&lt;br /&gt;
&lt;br /&gt;
    # do work here&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Clone a node ==&lt;br /&gt;
&lt;br /&gt;
This example shows how to make a copy of any node that appears in Subject Hierarchy (in Data module).&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Get a node from SampleData that we will clone&lt;br /&gt;
import SampleData&lt;br /&gt;
nodeToClone = SampleData.SampleDataLogic().downloadMRHead()&lt;br /&gt;
&lt;br /&gt;
# Clone the node&lt;br /&gt;
shNode = slicer.vtkMRMLSubjectHierarchyNode.GetSubjectHierarchyNode(slicer.mrmlScene)&lt;br /&gt;
itemIDToClone = shNode.GetItemByDataNode(nodeToClone)&lt;br /&gt;
clonedItemID = slicer.modules.subjecthierarchy.logic().CloneSubjectHierarchyItem(shNode, itemIDToClone)&lt;br /&gt;
clonedNode = shNode.GetItemDataNode(clonedItemID)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Clone a volume ==&lt;br /&gt;
This example shows how to clone the MRHead sample volume, including its pixel data and display settings.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sourceVolumeNode = slicer.util.getNode('MRHead')&lt;br /&gt;
volumesLogic = slicer.modules.volumes.logic()&lt;br /&gt;
clonedVolumeNode = volumesLogic.CloneVolume(slicer.mrmlScene, sourceVolumeNode, 'Cloned volume')&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Create a new volume ==&lt;br /&gt;
This example shows how to create a new empty volume.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
nodeName = &amp;quot;MyNewVolume&amp;quot;&lt;br /&gt;
imageSize = [512, 512, 512]&lt;br /&gt;
voxelType=vtk.VTK_UNSIGNED_CHAR&lt;br /&gt;
imageOrigin = [0.0, 0.0, 0.0]&lt;br /&gt;
imageSpacing = [1.0, 1.0, 1.0]&lt;br /&gt;
imageDirections = [[1,0,0], [0,1,0], [0,0,1]]&lt;br /&gt;
fillVoxelValue = 0&lt;br /&gt;
&lt;br /&gt;
# Create an empty image volume, filled with fillVoxelValue&lt;br /&gt;
imageData = vtk.vtkImageData()&lt;br /&gt;
imageData.SetDimensions(imageSize)&lt;br /&gt;
imageData.AllocateScalars(voxelType, 1)&lt;br /&gt;
thresholder = vtk.vtkImageThreshold()&lt;br /&gt;
thresholder.SetInputData(imageData)&lt;br /&gt;
thresholder.SetInValue(fillVoxelValue)&lt;br /&gt;
thresholder.SetOutValue(fillVoxelValue)&lt;br /&gt;
thresholder.Update()&lt;br /&gt;
# Create volume node&lt;br /&gt;
volumeNode = slicer.mrmlScene.AddNewNodeByClass(&amp;quot;vtkMRMLScalarVolumeNode&amp;quot;, nodeName)&lt;br /&gt;
volumeNode.SetOrigin(imageOrigin)&lt;br /&gt;
volumeNode.SetSpacing(imageSpacing)&lt;br /&gt;
volumeNode.SetIJKToRASDirections(imageDirections)&lt;br /&gt;
volumeNode.SetAndObserveImageData(thresholder.GetOutput())&lt;br /&gt;
volumeNode.CreateDefaultDisplayNodes()&lt;br /&gt;
volumeNode.CreateDefaultStorageNode()&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Modify voxels in a volume ==&lt;br /&gt;
&lt;br /&gt;
Typically the fastest and simplest way of modifying voxels is by using numpy operators. Voxels can be retrieved in a numpy array using the `array` method and modified using standard numpy methods. For example, threshold a volume:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
nodeName = 'MRHead'&lt;br /&gt;
thresholdValue = 100&lt;br /&gt;
voxelArray = array(nodeName) # get voxels as numpy array&lt;br /&gt;
voxelArray[voxelArray &amp;lt; thresholdValue] = 0 # modify voxel values&lt;br /&gt;
getNode(nodeName).Modified() # at the end of all processing, notify Slicer that the image modification is completed&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This example shows how to change voxels values of the MRHead sample volume.&lt;br /&gt;
The values will be computed by function f(r,a,s,) = (r-10)*(r-10)+(a+15)*(a+15)+s*s.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
volumeNode=slicer.util.getNode('MRHead')&lt;br /&gt;
ijkToRas = vtk.vtkMatrix4x4()&lt;br /&gt;
volumeNode.GetIJKToRASMatrix(ijkToRas)&lt;br /&gt;
imageData=volumeNode.GetImageData()&lt;br /&gt;
extent = imageData.GetExtent()&lt;br /&gt;
for k in xrange(extent[4], extent[5]+1):&lt;br /&gt;
  for j in xrange(extent[2], extent[3]+1):&lt;br /&gt;
    for i in xrange(extent[0], extent[1]+1):&lt;br /&gt;
      position_Ijk=[i, j, k, 1]&lt;br /&gt;
      position_Ras=ijkToRas.MultiplyPoint(position_Ijk)&lt;br /&gt;
      r=position_Ras[0]&lt;br /&gt;
      a=position_Ras[1]&lt;br /&gt;
      s=position_Ras[2]      &lt;br /&gt;
      functionValue=(r-10)*(r-10)+(a+15)*(a+15)+s*s&lt;br /&gt;
      imageData.SetScalarComponentFromDouble(i,j,k,0,functionValue)&lt;br /&gt;
imageData.SetScalarComponentFromFloat(distortionVectorPosition_Ijk[0], distortionVectorPosition_Ijk[1], distortionVectorPosition_Ijk[2], 0, fillValue)&lt;br /&gt;
imageData.Modified()&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Get volume voxel coordinates from markup fiducial RAS coordinates ==&lt;br /&gt;
&lt;br /&gt;
This example shows how to get voxel coordinate of a volume corresponding to a markup fiducial point position.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Inputs&lt;br /&gt;
volumeNode = getNode('MRHead')&lt;br /&gt;
markupsNode = getNode('F')&lt;br /&gt;
markupsIndex = 0&lt;br /&gt;
&lt;br /&gt;
# Get point coordinate in RAS&lt;br /&gt;
point_Ras = [0, 0, 0, 1]&lt;br /&gt;
markupsNode.GetNthFiducialWorldCoordinates(markupsIndex, point_Ras)&lt;br /&gt;
&lt;br /&gt;
# If volume node is transformed, apply that transform to get volume's RAS coordinates&lt;br /&gt;
transformRasToVolumeRas = vtk.vtkGeneralTransform()&lt;br /&gt;
slicer.vtkMRMLTransformNode.GetTransformBetweenNodes(None, volumeNode.GetParentTransformNode(), transformRasToVolumeRas)&lt;br /&gt;
point_VolumeRas = transformRasToVolumeRas.TransformPoint(point_Ras[0:3])&lt;br /&gt;
&lt;br /&gt;
# Get voxel coordinates from physical coordinates&lt;br /&gt;
volumeRasToIjk = vtk.vtkMatrix4x4()&lt;br /&gt;
volumeNode.GetRASToIJKMatrix(volumeRasToIjk)&lt;br /&gt;
point_Ijk = [0, 0, 0, 1]&lt;br /&gt;
volumeRasToIjk.MultiplyPoint(np.append(point_VolumeRas,1.0), point_Ijk)&lt;br /&gt;
point_Ijk = [ int(round(c)) for c in point_Ijk[0:3] ]&lt;br /&gt;
&lt;br /&gt;
# Print output&lt;br /&gt;
print(point_Ijk)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Get markup fiducial RAS coordinates from volume voxel coordinates ==&lt;br /&gt;
&lt;br /&gt;
This example shows how to get position of maximum intensity voxel of a volume (determined by numpy, in IJK coordinates) in RAS coordinates so that it can be marked with a markup fiducial.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Inputs&lt;br /&gt;
volumeNode = getNode('MRHead')&lt;br /&gt;
markupsNode = getNode('F')&lt;br /&gt;
&lt;br /&gt;
# Get voxel position in IJK coordinate system&lt;br /&gt;
import numpy as np&lt;br /&gt;
volumeArray = slicer.util.arrayFromVolume(volumeNode)&lt;br /&gt;
# Get position of highest voxel value&lt;br /&gt;
point_Kji = np.where(volumeArray == volumeArray.max())&lt;br /&gt;
point_Ijk = [point_Kji[2][0], point_Kji[1][0], point_Kji[0][0]]&lt;br /&gt;
&lt;br /&gt;
# Get physical coordinates from voxel coordinates&lt;br /&gt;
volumeIjkToRas = vtk.vtkMatrix4x4()&lt;br /&gt;
volumeNode.GetIJKToRASMatrix(volumeIjkToRas)&lt;br /&gt;
point_VolumeRas = [0, 0, 0, 1]&lt;br /&gt;
volumeIjkToRas.MultiplyPoint(np.append(point_Ijk,1.0), point_VolumeRas)&lt;br /&gt;
&lt;br /&gt;
# If volume node is transformed, apply that transform to get volume's RAS coordinates&lt;br /&gt;
transformVolumeRasToRas = vtk.vtkGeneralTransform()&lt;br /&gt;
slicer.vtkMRMLTransformNode.GetTransformBetweenNodes(volumeNode.GetParentTransformNode(), None, transformVolumeRasToRas)&lt;br /&gt;
point_Ras = transformVolumeRasToRas.TransformPoint(point_VolumeRas[0:3])&lt;br /&gt;
&lt;br /&gt;
# Add a markup at the computed position and print its coordinates&lt;br /&gt;
markupsNode.AddFiducial(point_Ras[0], point_Ras[1], point_Ras[2], &amp;quot;max&amp;quot;)&lt;br /&gt;
print(point_Ras)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Get the values of all voxels for a label value  ==&lt;br /&gt;
&lt;br /&gt;
If you have a background image called ‘Volume’ and a mask called ‘Volume-label’ created with the Editor you could do something like this:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
import numpy&lt;br /&gt;
volume = array(‘Volume’)&lt;br /&gt;
label = array(‘Volume-label’)&lt;br /&gt;
points  = numpy.where( label == 1 )  # or use another label number depending on what you segmented&lt;br /&gt;
values  = volume[points] # this will be a list of the label values&lt;br /&gt;
values.mean() # should match the mean value of LabelStatistics calculation as a double-check&lt;br /&gt;
numpy.savetxt(‘values.txt’, values)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Access values in a DTI tensor volume ==&lt;br /&gt;
This example shows how to access individual tensors at the voxel level.&lt;br /&gt;
&lt;br /&gt;
First load your DWI volume and estimate tensors to produce a DTI volume called ‘Output DTI Volume’&lt;br /&gt;
&lt;br /&gt;
Then open the python window: View-&amp;gt;Python interactor&lt;br /&gt;
&lt;br /&gt;
Use this command to access tensors through numpy:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
tensors = array('Output DTI Volume')&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Type the following code into the Python window to access all tensor components using vtk commands:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
volumeNode=slicer.util.getNode('Output DTI Volume')&lt;br /&gt;
imageData=volumeNode.GetImageData()&lt;br /&gt;
tensors = imageData.GetPointData().GetTensors()&lt;br /&gt;
extent = imageData.GetExtent()&lt;br /&gt;
idx = 0&lt;br /&gt;
for k in xrange(extent[4], extent[5]+1):&lt;br /&gt;
  for j in xrange(extent[2], extent[3]+1):&lt;br /&gt;
    for i in xrange(extent[0], extent[1]+1):&lt;br /&gt;
      tensors.GetTuple9(idx)&lt;br /&gt;
      idx += 1&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Change window/level (brightness/contrast) or colormap of a volume ==&lt;br /&gt;
This example shows how to change window/level of the MRHead sample volume.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
volumeNode = getNode('MRHead')&lt;br /&gt;
displayNode = volumeNode.GetDisplayNode()&lt;br /&gt;
displayNode.AutoWindowLevelOff()&lt;br /&gt;
displayNode.SetWindow(50)&lt;br /&gt;
displayNode.SetLevel(100)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Change color mapping from grayscale to rainbow:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
displayNode.SetAndObserveColorNodeID('vtkMRMLColorTableNodeRainbow')&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Create custom color table ==&lt;br /&gt;
This example shows how to create a new color table, for example with inverted color range from the default Ocean color table.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
invertedocean = slicer.vtkMRMLColorTableNode()&lt;br /&gt;
invertedocean.SetTypeToUser()&lt;br /&gt;
invertedocean.SetNumberOfColors(256)&lt;br /&gt;
invertedocean.SetName(&amp;quot;InvertedOcean&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
for i in range(0,255):&lt;br /&gt;
    invertedocean.SetColor(i, 0.0, 1 - (i+1e-16)/255.0, 1.0, 1.0)&lt;br /&gt;
&lt;br /&gt;
slicer.mrmlScene.AddNode(invertedocean)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Manipulate a Slice View ==&lt;br /&gt;
&lt;br /&gt;
=== Change the slice offset ===&lt;br /&gt;
&lt;br /&gt;
Equivalent to moving the slider in slice view controller.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
layoutManager = slicer.app.layoutManager()&lt;br /&gt;
red = layoutManager.sliceWidget('Red')&lt;br /&gt;
redLogic = red.sliceLogic()&lt;br /&gt;
# Print current slice offset position&lt;br /&gt;
print redLogic.GetSliceOffset()&lt;br /&gt;
# Change slice position&lt;br /&gt;
redLogic.SetSliceOffset(20)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Show slice views in 3D window ===&lt;br /&gt;
&lt;br /&gt;
Equivalent to clicking 'eye' icon in the slice view controller.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
layoutManager = slicer.app.layoutManager()&lt;br /&gt;
for sliceViewName in layoutManager.sliceViewNames():&lt;br /&gt;
  controller = layoutManager.sliceWidget(sliceViewName).sliceController()&lt;br /&gt;
  controller.setSliceVisible(True)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Reset field of view to show background volume maximized ===&lt;br /&gt;
&lt;br /&gt;
Equivalent to click small rectangle button (&amp;quot;Adjust the slice viewer's field of view...&amp;quot;) in the slice view controller.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
slicer.util.resetSliceViews()&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Rotate slice views to volume plane ===&lt;br /&gt;
&lt;br /&gt;
Aligns slice views to volume axes, shows original image acquisition planes in slice views.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
volumeNode = slicer.util.getNode('MRHead')&lt;br /&gt;
layoutManager = slicer.app.layoutManager()&lt;br /&gt;
for sliceViewName in layoutManager.sliceViewNames():&lt;br /&gt;
  layoutManager.sliceWidget(sliceViewName).mrmlSliceNode().RotateToVolumePlane(volumeNode)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Iterate over current visible slice views, and set foreground and background images ===&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
for sliceViewName in layoutManager.sliceViewNames():&lt;br /&gt;
     sliceWidget = layoutManager.sliceWidget(sliceViewName)&lt;br /&gt;
     &lt;br /&gt;
     # setup background volume&lt;br /&gt;
     compositeNode.SetBackgroundVolumeID(MRVolume.GetID())&lt;br /&gt;
     # setup foreground volume&lt;br /&gt;
     compositeNode.SetForegroundVolumeID(CTVolume.GetID())&lt;br /&gt;
     # change opacity&lt;br /&gt;
     compositeNode.SetForegroundOpacity(0.3)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Show a volume in slice views ==&lt;br /&gt;
&lt;br /&gt;
Recommended:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
volumeNode = slicer.util.getNode('YourVolumeNode')&lt;br /&gt;
slicer.util.setSliceViewerLayers(background=volumeNode)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
or&lt;br /&gt;
&lt;br /&gt;
Show volume in all visible views where volume selection propagation is enabled:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
volumeNode = slicer.util.getNode('YourVolumeNode')&lt;br /&gt;
applicationLogic = slicer.app.applicationLogic()&lt;br /&gt;
selectionNode = applicationLogic.GetSelectionNode()&lt;br /&gt;
selectionNode.SetSecondaryVolumeID(volumeNode.GetID())&lt;br /&gt;
applicationLogic.PropagateForegroundVolumeSelection(0) &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
or&lt;br /&gt;
&lt;br /&gt;
Show volume in selected views:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
n =  slicer.util.getNode('YourVolumeNode')&lt;br /&gt;
for color in ['Red', 'Yellow', 'Green']:&lt;br /&gt;
    slicer.app.layoutManager().sliceWidget(color).sliceLogic().GetSliceCompositeNode().SetForegroundVolumeID(n.GetID())&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Change opacity of foreground volume in slice views ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
slicer.util.setSliceViewerLayers(foregroundOpacity=0.4)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
or&lt;br /&gt;
&lt;br /&gt;
Change opacity in a selected view&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
lm = slicer.app.layoutManager()&lt;br /&gt;
sliceLogic = lm.sliceWidget('Red').sliceLogic()&lt;br /&gt;
compositeNode = sliceLogic.GetSliceCompositeNode()&lt;br /&gt;
compositeNode.SetForegroundOpacity(0.4)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Fit slice plane to markup fiducials ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sliceNode = slicer.mrmlScene.GetNodeByID(&amp;quot;vtkMRMLSliceNodeRed&amp;quot;)&lt;br /&gt;
markupsNode = slicer.mrmlScene.GetFirstNodeByName(&amp;quot;F&amp;quot;)&lt;br /&gt;
# Get markup point positions as numpy arrays&lt;br /&gt;
import numpy as np&lt;br /&gt;
p1 = np.array([0,0,0])&lt;br /&gt;
p2 = np.array([0,0,0])&lt;br /&gt;
p3 = np.array([0,0,0])&lt;br /&gt;
markupsNode.GetNthFiducialPosition(0, p1)&lt;br /&gt;
markupsNode.GetNthFiducialPosition(1, p2)&lt;br /&gt;
markupsNode.GetNthFiducialPosition(2, p3)&lt;br /&gt;
# Get plane axis directions&lt;br /&gt;
n = np.cross(p2-p1, p2-p3) # plane normal direction&lt;br /&gt;
n = n/np.linalg.norm(n)&lt;br /&gt;
t = np.cross([0, 0, 1], n) # plane transverse direction&lt;br /&gt;
t = t/np.linalg.norm(t)&lt;br /&gt;
# Set slice plane orientation and position&lt;br /&gt;
sliceNode.SetSliceToRASByNTP(n[0], n[1], n[2], t[0], t[1], t[2], p1[0], p1[1], p1[2], 0)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Save a series of images from a Slice View ==&lt;br /&gt;
&lt;br /&gt;
You can use ScreenCapture module to capture series of images. To do it programmatically, save the following into a file such as '/tmp/record.py' and then in the slicer python console type &amp;quot;execfile('/tmp/record.py')&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
layoutName = 'Green'&lt;br /&gt;
imagePathPattern = '/tmp/image-%03d.png'&lt;br /&gt;
steps = 10&lt;br /&gt;
&lt;br /&gt;
widget = slicer.app.layoutManager().sliceWidget(layoutName)&lt;br /&gt;
view = widget.sliceView()&lt;br /&gt;
logic = widget.sliceLogic()&lt;br /&gt;
bounds = [0,]*6&lt;br /&gt;
logic.GetSliceBounds(bounds)&lt;br /&gt;
&lt;br /&gt;
for step in range(steps):&lt;br /&gt;
    offset = bounds[4] + step/(1.*steps) * (bounds[5]-bounds[4])&lt;br /&gt;
    logic.SetSliceOffset(offset)&lt;br /&gt;
    view.forceRender()&lt;br /&gt;
    image = qt.QPixmap.grabWidget(view).toImage()&lt;br /&gt;
    image.save(imagePathPattern % step)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Save the scene into a new directory ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Create a new directory where the scene will be saved into&lt;br /&gt;
import time&lt;br /&gt;
sceneSaveDirectory = slicer.app.temporaryPath + &amp;quot;/saved-scene-&amp;quot; + time.strftime(&amp;quot;%Y%m%d-%H%M%S&amp;quot;)&lt;br /&gt;
if not os.access(sceneSaveDirectory, os.F_OK):&lt;br /&gt;
  os.makedirs(sceneSaveDirectory)&lt;br /&gt;
&lt;br /&gt;
# Save the scene&lt;br /&gt;
if slicer.app.applicationLogic().SaveSceneToSlicerDataBundleDirectory(sceneSaveDirectory, None):&lt;br /&gt;
  logging.info(&amp;quot;Scene saved to: {0}&amp;quot;.format(sceneSaveDirectory))&lt;br /&gt;
else:&lt;br /&gt;
  logging.error(&amp;quot;Scene saving failed&amp;quot;) &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Save the scene into a single MRB file ==&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Generate file name&lt;br /&gt;
import time&lt;br /&gt;
sceneSaveFilename = slicer.app.temporaryPath + &amp;quot;/saved-scene-&amp;quot; + time.strftime(&amp;quot;%Y%m%d-%H%M%S&amp;quot;) + &amp;quot;.mrb&amp;quot;&lt;br /&gt;
&lt;br /&gt;
# Save scene&lt;br /&gt;
if slicer.util.saveScene(sceneSaveFilename):&lt;br /&gt;
  logging.info(&amp;quot;Scene saved to: {0}&amp;quot;.format(sceneSaveFilename))&lt;br /&gt;
else:&lt;br /&gt;
  logging.error(&amp;quot;Scene saving failed&amp;quot;) &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Save a node to file ==&lt;br /&gt;
&lt;br /&gt;
Save a transform node to file (should work with any other node type, if file extension is set to a supported one):&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
myNode = getNode(&amp;quot;LinearTransform_3&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
myStorageNode = myNode.CreateDefaultStorageNode()&lt;br /&gt;
myStorageNode.SetFileName(&amp;quot;c:/tmp/something.tfm&amp;quot;)&lt;br /&gt;
myStorageNode.WriteData(myNode)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Center the 3D View on the Scene ==&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
layoutManager = slicer.app.layoutManager()&lt;br /&gt;
threeDWidget = layoutManager.threeDWidget(0)&lt;br /&gt;
threeDView = threeDWidget.threeDView()&lt;br /&gt;
threeDView.resetFocalPoint()&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Rotate the 3D View==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
layoutManager = slicer.app.layoutManager()&lt;br /&gt;
threeDWidget = layoutManager.threeDWidget(0)&lt;br /&gt;
threeDView = threeDWidget.threeDView()&lt;br /&gt;
threeDView.yaw()&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Display text in a 3D view or slice view ==&lt;br /&gt;
&lt;br /&gt;
The easiest way to show information overlaid on a viewer is to use corner annotations.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
view=slicer.app.layoutManager().threeDWidget(0).threeDView()&lt;br /&gt;
# Set text to &amp;quot;Something&amp;quot;&lt;br /&gt;
view.cornerAnnotation().SetText(vtk.vtkCornerAnnotation.UpperRight,&amp;quot;Something&amp;quot;)&lt;br /&gt;
# Set color to red&lt;br /&gt;
view.cornerAnnotation().GetTextProperty().SetColor(1,0,0)&lt;br /&gt;
# Update the view&lt;br /&gt;
view.forceRender()&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Hide slice view annotations (DataProbe) ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Disable slice annotations immediately&lt;br /&gt;
slicer.modules.DataProbeInstance.infoWidget.sliceAnnotations.sliceViewAnnotationsEnabled=False&lt;br /&gt;
slicer.modules.DataProbeInstance.infoWidget.sliceAnnotations.updateSliceViewFromGUI()&lt;br /&gt;
# Disable slice annotations persistently (after Slicer restarts)&lt;br /&gt;
settings = qt.QSettings()&lt;br /&gt;
settings.setValue('DataProbe/sliceViewAnnotations.enabled', 0)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Turning off interpolation ==&lt;br /&gt;
&lt;br /&gt;
You can turn off interpolation for newly loaded volumes with this script from Steve Pieper.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
def NoInterpolate(caller,event):&lt;br /&gt;
  for node in slicer.util.getNodes('*').values():&lt;br /&gt;
    if node.IsA('vtkMRMLScalarVolumeDisplayNode'):&lt;br /&gt;
      node.SetInterpolate(0)&lt;br /&gt;
	&lt;br /&gt;
slicer.mrmlScene.AddObserver(slicer.mrmlScene.NodeAddedEvent, NoInterpolate)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The below link explains how to put this in your startup script.&lt;br /&gt;
&lt;br /&gt;
http://www.na-mic.org/Wiki/index.php/AHM2012-Slicer-Python#Refining_the_code_and_UI_with_slicerrc&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Customize viewer layout ==&lt;br /&gt;
&lt;br /&gt;
Show a custom layout of a 3D view on top of the red slice view:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
customLayout = (&amp;quot;&amp;lt;layout type=\&amp;quot;vertical\&amp;quot; split=\&amp;quot;true\&amp;quot; &amp;gt;&amp;quot;&lt;br /&gt;
  &amp;quot; &amp;lt;item&amp;gt;&amp;quot;&lt;br /&gt;
  &amp;quot;  &amp;lt;view class=\&amp;quot;vtkMRMLViewNode\&amp;quot; singletontag=\&amp;quot;1\&amp;quot;&amp;gt;&amp;quot;&lt;br /&gt;
  &amp;quot;    &amp;lt;property name=\&amp;quot;viewlabel\&amp;quot; action=\&amp;quot;default\&amp;quot;&amp;gt;1&amp;lt;/property&amp;gt;&amp;quot;&lt;br /&gt;
  &amp;quot;  &amp;lt;/view&amp;gt;&amp;quot;&lt;br /&gt;
  &amp;quot; &amp;lt;/item&amp;gt;&amp;quot;&lt;br /&gt;
  &amp;quot; &amp;lt;item&amp;gt;&amp;quot;&lt;br /&gt;
  &amp;quot;  &amp;lt;view class=\&amp;quot;vtkMRMLSliceNode\&amp;quot; singletontag=\&amp;quot;Red\&amp;quot;&amp;gt;&amp;quot;&lt;br /&gt;
  &amp;quot;   &amp;lt;property name=\&amp;quot;orientation\&amp;quot; action=\&amp;quot;default\&amp;quot;&amp;gt;Axial&amp;lt;/property&amp;gt;&amp;quot;&lt;br /&gt;
  &amp;quot;   &amp;lt;property name=\&amp;quot;viewlabel\&amp;quot; action=\&amp;quot;default\&amp;quot;&amp;gt;R&amp;lt;/property&amp;gt;&amp;quot;&lt;br /&gt;
  &amp;quot;   &amp;lt;property name=\&amp;quot;viewcolor\&amp;quot; action=\&amp;quot;default\&amp;quot;&amp;gt;#F34A33&amp;lt;/property&amp;gt;&amp;quot;&lt;br /&gt;
  &amp;quot;  &amp;lt;/view&amp;gt;&amp;quot;&lt;br /&gt;
  &amp;quot; &amp;lt;/item&amp;gt;&amp;quot;&lt;br /&gt;
  &amp;quot;&amp;lt;/layout&amp;gt;&amp;quot;)&lt;br /&gt;
  &lt;br /&gt;
customLayoutId=501&lt;br /&gt;
&lt;br /&gt;
layoutManager = slicer.app.layoutManager()&lt;br /&gt;
layoutManager.layoutLogic().GetLayoutNode().AddLayoutDescription(customLayoutId, customLayout)                                         &lt;br /&gt;
layoutManager.setLayout(customLayoutId)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
See description of standard layouts (that can be used as examples) here:&lt;br /&gt;
https://github.com/Slicer/Slicer/blob/master/Libs/MRML/Logic/vtkMRMLLayoutLogic.cxx&lt;br /&gt;
&lt;br /&gt;
== Customize keyboard shortcuts ==&lt;br /&gt;
&lt;br /&gt;
Keyboard shortcuts can be specified for activating any Slicer feature by adding a couple of lines to your &lt;br /&gt;
[[Documentation/{{documentation/version}}/Developers/Python_scripting#How_to_systematically_execute_custom_python_code_at_startup_.3F|.slicerrc file]].&lt;br /&gt;
&lt;br /&gt;
For example, this script registers ''Ctrl+b'', ''Ctrl+n'', ''Ctrl+m'', ''Ctrl+,'' keyboard shortcuts to switch between red, yellow, green, and 4-up view layouts.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
shortcuts = [&lt;br /&gt;
    ('Ctrl+b', lambda: slicer.app.layoutManager().setLayout(slicer.vtkMRMLLayoutNode.SlicerLayoutOneUpRedSliceView)),&lt;br /&gt;
    ('Ctrl+n', lambda: slicer.app.layoutManager().setLayout(slicer.vtkMRMLLayoutNode.SlicerLayoutOneUpYellowSliceView)),&lt;br /&gt;
    ('Ctrl+m', lambda: slicer.app.layoutManager().setLayout(slicer.vtkMRMLLayoutNode.SlicerLayoutOneUpGreenSliceView)),&lt;br /&gt;
    ('Ctrl+,', lambda: slicer.app.layoutManager().setLayout(slicer.vtkMRMLLayoutNode.SlicerLayoutFourUpView))&lt;br /&gt;
    ]&lt;br /&gt;
&lt;br /&gt;
for (shortcutKey, callback) in shortcuts:&lt;br /&gt;
    shortcut = qt.QShortcut(slicer.util.mainWindow())&lt;br /&gt;
    shortcut.setKey(qt.QKeySequence(shortcutKey))&lt;br /&gt;
    shortcut.connect( 'activated()', callback)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Disable certain user interactions in slice views ==&lt;br /&gt;
&lt;br /&gt;
For example, disable slice browsing using mouse wheel and keyboard shortcuts in the red slice viewer:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
interactorStyle = slicer.app.layoutManager().sliceWidget('Red').sliceView().sliceViewInteractorStyle()&lt;br /&gt;
interactorStyle.SetActionEnabled(interactorStyle.BrowseSlice, False)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Hide all slice view controllers:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
lm = slicer.app.layoutManager()&lt;br /&gt;
for sliceViewName in lm.sliceViewNames():&lt;br /&gt;
  lm.sliceWidget(sliceViewName).sliceController().setVisible(False)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Hide all 3D view controllers:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
lm = slicer.app.layoutManager()&lt;br /&gt;
for viewIndex in range(slicer.app.layoutManager().threeDViewCount):&lt;br /&gt;
  lm.threeDWidget(0).threeDController().setVisible(False)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Change default slice view orientation ==&lt;br /&gt;
&lt;br /&gt;
You can left-right &amp;quot;flip&amp;quot; slice view orientation presets (show patient left side on left/right side of the screen) by copy-pasting the script below to your [[Documentation/{{documentation/version}}/Developers/FAQ/Python_Scripting#How_to_systematically_execute_custom_python_code_at_startup_.3F| .slicerrc.py file]].&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Axial slice axes:&lt;br /&gt;
#  1 0 0&lt;br /&gt;
#  0 1 0&lt;br /&gt;
#  0 0 1&lt;br /&gt;
axialSliceToRas=vtk.vtkMatrix3x3()&lt;br /&gt;
&lt;br /&gt;
# Coronal slice axes:&lt;br /&gt;
#  1 0 0 &lt;br /&gt;
#  0 0 -1&lt;br /&gt;
#  0 1 0&lt;br /&gt;
coronalSliceToRas=vtk.vtkMatrix3x3()&lt;br /&gt;
coronalSliceToRas.SetElement(1,1, 0)&lt;br /&gt;
coronalSliceToRas.SetElement(1,2, -1)&lt;br /&gt;
coronalSliceToRas.SetElement(2,1, 1)&lt;br /&gt;
coronalSliceToRas.SetElement(2,2, 0)&lt;br /&gt;
&lt;br /&gt;
# Replace orientation presets in all existing slice nodes and in the default slice node&lt;br /&gt;
sliceNodes = slicer.util.getNodesByClass('vtkMRMLSliceNode')&lt;br /&gt;
sliceNodes.append(slicer.mrmlScene.GetDefaultNodeByClass('vtkMRMLSliceNode'))&lt;br /&gt;
for sliceNode in sliceNodes:&lt;br /&gt;
  orientationPresetName = sliceNode.GetOrientation()&lt;br /&gt;
  sliceNode.RemoveSliceOrientationPreset(&amp;quot;Axial&amp;quot;)&lt;br /&gt;
  sliceNode.AddSliceOrientationPreset(&amp;quot;Axial&amp;quot;, axialSliceToRas)&lt;br /&gt;
  sliceNode.RemoveSliceOrientationPreset(&amp;quot;Coronal&amp;quot;)&lt;br /&gt;
  sliceNode.AddSliceOrientationPreset(&amp;quot;Coronal&amp;quot;, coronalSliceToRas)&lt;br /&gt;
  sliceNode.SetOrientation(orientationPresetName)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Set all slice views linked by default ==&lt;br /&gt;
&lt;br /&gt;
You can make slice views linked by default (when application starts or the scene is cleared) by copy-pasting the script below to your [[Documentation/{{documentation/version}}/Developers/FAQ/Python_Scripting#How_to_systematically_execute_custom_python_code_at_startup_.3F| .slicerrc.py file]].&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Set linked slice views  in all existing slice composite nodes and in the default node&lt;br /&gt;
sliceCompositeNodes = slicer.util.getNodesByClass('vtkMRMLSliceCompositeNode')&lt;br /&gt;
defaultSliceCompositeNode = slicer.mrmlScene.GetDefaultNodeByClass('vtkMRMLSliceCompositeNode')&lt;br /&gt;
if not defaultSliceCompositeNode:&lt;br /&gt;
  defaultSliceCompositeNode = slicer.mrmlScene.CreateNodeByClass('vtkMRMLSliceCompositeNode')&lt;br /&gt;
  slicer.mrmlScene.AddDefaultNode(defaultSliceCompositeNode)&lt;br /&gt;
sliceCompositeNodes.append(defaultSliceCompositeNode)&lt;br /&gt;
for sliceCompositeNode in sliceCompositeNodes:&lt;br /&gt;
  sliceCompositeNode.SetLinkedControl(True)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Set up custom units in slice view ruler ==&lt;br /&gt;
&lt;br /&gt;
For microscopy or micro-CT images you may want to switch unit to micrometer instead of the default mm. To do that, 1. change the unit in Application settings / Units and 2. update ruler display settings using the script below (it can be copied to your Application startup script):&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
lm = slicer.app.layoutManager()&lt;br /&gt;
for sliceViewName in lm.sliceViewNames():&lt;br /&gt;
  sliceView = lm.sliceWidget(sliceViewName).sliceView()&lt;br /&gt;
  displayableManagerCollection = vtk.vtkCollection()&lt;br /&gt;
  sliceView.getDisplayableManagers(displayableManagerCollection)&lt;br /&gt;
  for dmIndex in xrange(displayableManagerCollection.GetNumberOfItems()):&lt;br /&gt;
    displayableManager = displayableManagerCollection.GetItemAsObject(dmIndex)&lt;br /&gt;
    if not displayableManager.IsA(&amp;quot;vtkMRMLRulerDisplayableManager&amp;quot;):&lt;br /&gt;
      continue&lt;br /&gt;
    displayableManager.RemoveAllRulerScalePresets()&lt;br /&gt;
    displayableManager.AddRulerScalePreset(   0.001, 5, 2, &amp;quot;nm&amp;quot;, 1000.0)&lt;br /&gt;
    displayableManager.AddRulerScalePreset(   0.010, 5, 2, &amp;quot;nm&amp;quot;, 1000.0)&lt;br /&gt;
    displayableManager.AddRulerScalePreset(   0.100, 5, 2, &amp;quot;nm&amp;quot;, 1000.0)&lt;br /&gt;
    displayableManager.AddRulerScalePreset(   0.500, 5, 1, &amp;quot;nm&amp;quot;, 1000.0)&lt;br /&gt;
    displayableManager.AddRulerScalePreset(   1.0,   5, 2, &amp;quot;um&amp;quot;,    1.0)&lt;br /&gt;
    displayableManager.AddRulerScalePreset(   5.0,   5, 1, &amp;quot;um&amp;quot;,    1.0)&lt;br /&gt;
    displayableManager.AddRulerScalePreset(  10.0,   5, 2, &amp;quot;um&amp;quot;,    1.0)&lt;br /&gt;
    displayableManager.AddRulerScalePreset(  50.0,   5, 1, &amp;quot;um&amp;quot;,    1.0)&lt;br /&gt;
    displayableManager.AddRulerScalePreset( 100.0,   5, 2, &amp;quot;um&amp;quot;,    1.0)&lt;br /&gt;
    displayableManager.AddRulerScalePreset( 500.0,   5, 1, &amp;quot;um&amp;quot;,    1.0)&lt;br /&gt;
    displayableManager.AddRulerScalePreset(1000.0,   5, 2, &amp;quot;mm&amp;quot;,    0.001)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Show a slice view outside the view layout ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sliceLayoutName = &amp;quot;TestSlice&amp;quot;&lt;br /&gt;
sliceLayoutLabel = &amp;quot;T&amp;quot;&lt;br /&gt;
# ownerNode manages this view instead of the layout manager (it can be any node in the scene)&lt;br /&gt;
viewOwnerNode = slicer.mrmlScene.AddNewNodeByClass(&amp;quot;vtkMRMLScriptedModuleNode&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
# Create MRML nodes&lt;br /&gt;
sliceNode = slicer.vtkMRMLSliceNode()&lt;br /&gt;
sliceNode.SetName(sliceLayoutName)&lt;br /&gt;
sliceNode.SetLayoutName(sliceLayoutName)&lt;br /&gt;
sliceNode.SetLayoutLabel(sliceLayoutLabel)&lt;br /&gt;
sliceNode.SetLayoutColor(1, 1, 0)&lt;br /&gt;
sliceNode.SetAndObserveParentLayoutNodeID(viewOwnerNode.GetID())&lt;br /&gt;
sliceNode = slicer.mrmlScene.AddNode(sliceNode)&lt;br /&gt;
sliceCompositeNode = slicer.mrmlScene.AddNewNodeByClass(&amp;quot;vtkMRMLSliceCompositeNode&amp;quot;)&lt;br /&gt;
sliceCompositeNode.SetLayoutName(sliceLayoutName)&lt;br /&gt;
&lt;br /&gt;
# Create widget&lt;br /&gt;
sliceWidget = slicer.qMRMLSliceWidget()&lt;br /&gt;
sliceWidget.sliceViewName = sliceLayoutName&lt;br /&gt;
sliceWidget.sliceViewLabel = sliceLayoutLabel&lt;br /&gt;
c = sliceNode.GetLayoutColor()&lt;br /&gt;
sliceWidget.sliceViewColor = qt.QColor.fromRgbF(c[0],c[1],c[2])&lt;br /&gt;
sliceWidget.setMRMLScene(slicer.mrmlScene)&lt;br /&gt;
sliceWidget.setMRMLSliceNode(sliceNode)&lt;br /&gt;
sliceWidget.show()&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Running an ITK filter in Python using SimpleITK ==&lt;br /&gt;
Open the &amp;quot;Sample Data&amp;quot; module and download &amp;quot;MR Head&amp;quot;, then paste the following snippet in Python interactor:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
import SimpleITK as sitk&lt;br /&gt;
import sitkUtils&lt;br /&gt;
inputImage = sitkUtils.PullFromSlicer('MRHead')&lt;br /&gt;
filter = sitk.SignedMaurerDistanceMapImageFilter()&lt;br /&gt;
outputImage = filter.Execute(inputImage)&lt;br /&gt;
sitkUtils.PushToSlicer(outputImage,'outputImage')&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
More information:&lt;br /&gt;
* See the SimpleITK documentation for SimpleITK examples: http://www.itk.org/SimpleITKDoxygen/html/examples.html&lt;br /&gt;
* sitkUtils in Slicer is used for pushing and pulling images from Slicer to SimpleITK: https://github.com/Slicer/Slicer/blob/master/Base/Python/sitkUtils.py&lt;br /&gt;
&lt;br /&gt;
== Get current mouse coordinates in a slice view ==&lt;br /&gt;
&lt;br /&gt;
You can get 3D (RAS) coordinates of the current mouse cursor from the crosshair singleton node as shown in the example below:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
def onMouseMoved(observer,eventid):  &lt;br /&gt;
  ras=[0,0,0]&lt;br /&gt;
  crosshairNode.GetCursorPositionRAS(ras)&lt;br /&gt;
  print(ras)&lt;br /&gt;
&lt;br /&gt;
crosshairNode=slicer.util.getNode('Crosshair') &lt;br /&gt;
crosshairNode.AddObserver(slicer.vtkMRMLCrosshairNode.CursorPositionModifiedEvent, onMouseMoved)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Get DataProbe text ==&lt;br /&gt;
&lt;br /&gt;
You can get the mouse location in pixel coordinates along with the pixel value at the mouse by hitting the '.' (period) key in a slice view after pasting in the following code.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
def printDataProbe():&lt;br /&gt;
  infoWidget = slicer.modules.DataProbeInstance.infoWidget&lt;br /&gt;
  for layer in ('B', 'F', 'L'):&lt;br /&gt;
    print(infoWidget.layerNames[layer].text, infoWidget.layerIJKs[layer].text, infoWidget.layerValues[layer].text)&lt;br /&gt;
&lt;br /&gt;
s = qt.QShortcut(qt.QKeySequence('.'), mainWindow())&lt;br /&gt;
s.connect('activated()', printDataProbe)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Thick slab reconstruction and maximum/minimum intensity volume projections ==&lt;br /&gt;
&lt;br /&gt;
Set up 'red' slice viewer to show thick slab reconstructed from 3 slices:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sliceNode = slicer.mrmlScene.GetNodeByID('vtkMRMLSliceNodeRed')&lt;br /&gt;
appLogic = slicer.app.applicationLogic()&lt;br /&gt;
sliceLogic = appLogic.GetSliceLogic(sliceNode)&lt;br /&gt;
sliceLayerLogic = sliceLogic.GetBackgroundLayer()&lt;br /&gt;
reslice = sliceLayerLogic.GetReslice()&lt;br /&gt;
reslice.SetSlabModeToMean()&lt;br /&gt;
reslice.SetSlabNumberOfSlices(10) # mean of 10 slices will computed&lt;br /&gt;
reslice.SetSlabSliceSpacingFraction(0.3) # spacing between each slice is 0.3 pixel (total 10 * 0.3 = 3 pixel neighborhood)&lt;br /&gt;
sliceNode.Modified()&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Set up 'red' slice viewer to show maximum intensity projection (MIP):&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sliceNode = slicer.mrmlScene.GetNodeByID('vtkMRMLSliceNodeRed')&lt;br /&gt;
appLogic = slicer.app.applicationLogic()&lt;br /&gt;
sliceLogic = appLogic.GetSliceLogic(sliceNode)&lt;br /&gt;
sliceLayerLogic = sliceLogic.GetBackgroundLayer()&lt;br /&gt;
reslice = sliceLayerLogic.GetReslice()&lt;br /&gt;
reslice.SetSlabModeToMax()&lt;br /&gt;
reslice.SetSlabNumberOfSlices(600) # use a large number of slices (600) to cover the entire volume&lt;br /&gt;
reslice.SetSlabSliceSpacingFraction(0.5) # spacing between slices are 0.5 pixel (supersampling is useful to reduce interpolation artifacts)&lt;br /&gt;
sliceNode.Modified()&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The projected image is available in a ''vtkImageData'' object by calling ''reslice.GetOutput()''.&lt;br /&gt;
&lt;br /&gt;
== Change default file type for nodes (that have never been saved yet) ==&lt;br /&gt;
Default node can be specified that will be used as a basis of all new storage nodes. This can be used for setting default file extension. For example, change file format to STL for model nodes:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
defaultModelStorageNode = slicer.vtkMRMLModelStorageNode()&lt;br /&gt;
defaultModelStorageNode.SetDefaultWriteFileExtension('stl')&lt;br /&gt;
slicer.mrmlScene.AddDefaultNode(defaultModelStorageNode)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To permanently change default file extension on your computer, copy-paste the code above into your application startup script (you can find its location in menu: Edit / Application settings / General / Application startup script).&lt;br /&gt;
&lt;br /&gt;
== Change file type for saving for all volumes (with already existing storage nodes) ==&lt;br /&gt;
&lt;br /&gt;
If it is not necessary to preserve file paths then the simplest is to configure default storage node (as shown in the example above), then delete all existing storage nodes. When save dialog is opened, default storage nodes will be recreated.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Delete existing model storage nodes so that they will be recreated with default settings&lt;br /&gt;
existingModelStorageNodes = slicer.util.getNodesByClass('vtkMRMLModelStorageNode')&lt;br /&gt;
for modelStorageNode in existingModelStorageNodes:&lt;br /&gt;
  slicer.mrmlScene.RemoveNode(modelStorageNode)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To update existing storage nodes to use new file extension (but keep all other parameters unchanged) you can use this approach (example is for volume storage):&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
requiredFileExtension = '.nia'&lt;br /&gt;
originalFileExtension = '.nrrd'&lt;br /&gt;
volumeNodes = slicer.util.getNodesByClass('vtkMRMLScalarVolumeNode')&lt;br /&gt;
for volumeNode in volumeNodes:&lt;br /&gt;
  volumeStorageNode = volumeNode.GetStorageNode()&lt;br /&gt;
  if not volumeStorageNode:&lt;br /&gt;
    volumeNode.AddDefaultStorageNode()&lt;br /&gt;
    volumeStorageNode = volumeNode.GetStorageNode()&lt;br /&gt;
    volumeStorageNode.SetFileName(volumeNode.GetName()+requiredFileExtension)&lt;br /&gt;
  else:&lt;br /&gt;
    volumeStorageNode.SetFileName(volumeStorageNode.GetFileName().replace(originalFileExtension, requiredFileExtension))&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To set all volume nodes to save uncompressed by default (add this to .slicerrc.py so it takes effect for the whole session):&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#set the default volume storage to not compress by default&lt;br /&gt;
defaultVolumeStorageNode = slicer.vtkMRMLVolumeArchetypeStorageNode()&lt;br /&gt;
defaultVolumeStorageNode.SetUseCompression(0)&lt;br /&gt;
slicer.mrmlScene.AddDefaultNode(defaultVolumeStorageNode)&lt;br /&gt;
logging.info(&amp;quot;Volume nodes will be stored uncompressed by default&amp;quot;)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Same thing as above, but applied to all  segmentations instead of volumes:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#set the default volume storage to not compress by default&lt;br /&gt;
defaultVolumeStorageNode = slicer.vtkMRMLSegmentationStorageNode()&lt;br /&gt;
defaultVolumeStorageNode.SetUseCompression(0)&lt;br /&gt;
slicer.mrmlScene.AddDefaultNode(defaultVolumeStorageNode)&lt;br /&gt;
logging.info(&amp;quot;Segmentation nodes will be stored uncompressed &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Segmentations ==&lt;br /&gt;
&lt;br /&gt;
=== Create a segmentation from a labelmap volume and display in 3D ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
labelmapVolumeNode = getNode('label')&lt;br /&gt;
seg = slicer.mrmlScene.AddNewNodeByClass('vtkMRMLSegmentationNode')&lt;br /&gt;
slicer.modules.segmentations.logic().ImportLabelmapToSegmentationNode(labelmapVolumeNode, seg)&lt;br /&gt;
seg.CreateClosedSurfaceRepresentation()&lt;br /&gt;
slicer.mrmlScene.RemoveNode(labelmapVolumeNode)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The last line is optional. It removes the original labelmap volume so that the same information is not shown twice.&lt;br /&gt;
&lt;br /&gt;
=== Export labelmap node from segmentation node ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
seg = getNode('Segmentation')&lt;br /&gt;
labelmapVolumeNode = slicer.mrmlScene.AddNewNodeByClass('vtkMRMLLabelMapVolumeNode')&lt;br /&gt;
slicer.modules.segmentations.logic().ExportAllSegmentsToLabelmapNode(seg, labelmapVolumeNode)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Export model nodes from segmentation node ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
seg = getNode('Segmentation')&lt;br /&gt;
exportedModelsNode = slicer.mrmlScene.AddNewNodeByClass('vtkMRMLModelHierarchyNode')&lt;br /&gt;
slicer.modules.segmentations.logic().ExportAllSegmentsToModelHierarchy(seg, exportedModelsNode)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Show a segmentation in 3D ===&lt;br /&gt;
Segmentation can only be shown in 3D if closed surface representation (or other 3D-displayable representation) is available. To create closed surface representation:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
segmentation.CreateClosedSurfaceRepresentation()&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Get a representation of a segment ===&lt;br /&gt;
Access binary labelmap stored in a segmentation node (without exporting it to a volume node) - if it does not exist, it will return None:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
image = segmentationNode.GetBinaryLabelmapRepresentation(segmentID)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Get closed surface, if it does not exist, it will return None:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
polydata = segmentationNode.GetClosedSurfaceRepresentation(segmentID)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Get binary labelmap representation. If it does not exist then it will be created for that single segment. Applies parent transforms by default (if not desired, another argument needs to be added to the end: false):&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
import vtkSegmentationCorePython as vtkSegmentationCore&lt;br /&gt;
outputOrientedImageData = vtkSegmentationCore.vtkOrientedImageData()&lt;br /&gt;
slicer.vtkSlicerSegmentationsModuleLogic.GetSegmentBinaryLabelmapRepresentation(segmentationNode, segmentID, outputOrientedImageData)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Same as above, for closed surface representation:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
outputPolyData = vtk.vtkPolyData()&lt;br /&gt;
slicer.vtkSlicerSegmentationsModuleLogic.GetSegmentClosedSurfaceRepresentation(segmentationNode, segmentID, outputPolyData)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Convert all segments using default path and conversion parameters ===&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
segmentationNode.CreateBinaryLabelmapRepresentation()&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Convert all segments using custom path or conversion parameters ===&lt;br /&gt;
Change reference image geometry parameter based on an existing referenceImageData image:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
import vtkSegmentationCorePython as vtkSegmentationCore&lt;br /&gt;
referenceGeometry = vtkSegmentationCore.vtkSegmentationConverter.SerializeImageGeometry(referenceImageData)&lt;br /&gt;
segmentation.SetConversionParameter(vtkSegmentationCore.vtkSegmentationConverter.GetReferenceImageGeometryParameterName(), referenceGeometry)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Re-convert using a modified conversion parameter ===&lt;br /&gt;
Changing smoothing factor for closed surface generation:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
import vtkSegmentationCorePython as vtkSegmentationCore&lt;br /&gt;
segmentation = getNode('Segmentation').GetSegmentation()&lt;br /&gt;
&lt;br /&gt;
# Turn of surface smoothing&lt;br /&gt;
segmentation.SetConversionParameter('Smoothing factor','0.0')&lt;br /&gt;
&lt;br /&gt;
# Recreate representation using modified parameters (and default conversion path)&lt;br /&gt;
segmentation.RemoveRepresentation(vtkSegmentationCore.vtkSegmentationConverter.GetSegmentationClosedSurfaceRepresentationName())&lt;br /&gt;
segmentation.CreateRepresentation(vtkSegmentationCore.vtkSegmentationConverter.GetSegmentationClosedSurfaceRepresentationName())&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Get centroid of a segment in world (RAS) coordinates ===&lt;br /&gt;
&lt;br /&gt;
This example shows how to get centroid of a segment in world coordinates and show that position in all slice views.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
segmentationNode = getNode('Segmentation')&lt;br /&gt;
segmentId = 'Segment_1'&lt;br /&gt;
&lt;br /&gt;
# Get array voxel coordinates&lt;br /&gt;
import numpy as np&lt;br /&gt;
seg=arrayFromSegment(segmentation_node, segmentId)&lt;br /&gt;
# numpy array has voxel coordinates in reverse order (KJI instead of IJK)&lt;br /&gt;
# and the array is cropped to minimum size in the segmentation&lt;br /&gt;
mean_KjiCropped = [coords.mean() for coords in np.nonzero(seg)]&lt;br /&gt;
&lt;br /&gt;
# Get segmentation voxel coordinates&lt;br /&gt;
segImage = segmentationNode.GetBinaryLabelmapRepresentation(segmentId)&lt;br /&gt;
segImageExtent = segImage.GetExtent()&lt;br /&gt;
# origin of the array in voxel coordinates is determined by the start extent&lt;br /&gt;
mean_Ijk = [mean_KjiCropped[2], mean_KjiCropped[1], mean_KjiCropped[0]] + np.array([segImageExtent[0], segImageExtent[2], segImageExtent[4]])&lt;br /&gt;
&lt;br /&gt;
# Get segmentation physical coordinates&lt;br /&gt;
ijkToWorld = vtk.vtkMatrix4x4()&lt;br /&gt;
segImage.GetImageToWorldMatrix(ijkToWorld)&lt;br /&gt;
mean_World = [0, 0, 0, 1]&lt;br /&gt;
ijkToRas.MultiplyPoint(np.append(mean_Ijk,1.0), mean_World)&lt;br /&gt;
mean_World = mean_World[0:3]&lt;br /&gt;
&lt;br /&gt;
# If segmentation node is transformed, apply that transform to get RAS coordinates&lt;br /&gt;
transformWorldToRas = vtk.vtkGeneralTransform()&lt;br /&gt;
slicer.vtkMRMLTransformNode.GetTransformBetweenNodes(segmentationNode.GetParentTransformNode(), None, transformWorldToRas)&lt;br /&gt;
mean_Ras = transformWorldToRas.TransformPoint(mean_World)&lt;br /&gt;
&lt;br /&gt;
# Show mean position value and jump to it in all slice viewers&lt;br /&gt;
print(mean_Ras)&lt;br /&gt;
slicer.modules.markups.logic().JumpSlicesToLocation(mean_Ras[0], mean_Ras[1], mean_Ras[2], True)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== How to run segment editor effects from a script ===&lt;br /&gt;
&lt;br /&gt;
Editor effects are complex because they need to handle changing master volumes, undo/redo, masking operations, etc. Therefore, instead of using a segment editor effect, it is simpler to run the underlying filters directly from script.&lt;br /&gt;
&lt;br /&gt;
This example demonstrates how to use Segment editor effects (without GUI, using qMRMLSegmentEditorWidget):&lt;br /&gt;
&lt;br /&gt;
* [https://gist.github.com/lassoan/2d5a5b73645f65a5eb6f8d5f97abf31b brain tumor segmentation using grow from seeds effect]&lt;br /&gt;
* [https://gist.github.com/lassoan/1673b25d8e7913cbc245b4f09ed853f9 skin surface extraction using thresholding and smoothing]&lt;br /&gt;
* [https://gist.github.com/lassoan/2f5071c562108dac8efe277c78f2620f mask a volume with segments and compute histogram for each region]&lt;br /&gt;
&lt;br /&gt;
This example shows how to perform operations on segmentations using VTK filters:&lt;br /&gt;
* [https://gist.github.com/lassoan/7c94c334653010696b2bf96abc0ac8e7 brain tumor segmentation using grow from seeds effect]&lt;br /&gt;
&lt;br /&gt;
== Accessing views, renderers, and cameras ==&lt;br /&gt;
&lt;br /&gt;
Iterate through all 3D views in current layout:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
layoutManager = slicer.app.layoutManager()&lt;br /&gt;
for threeDViewIndex in range(layoutManager.threeDViewCount) :&lt;br /&gt;
  view = layoutManager.threeDWidget(threeDViewIndex).threeDView()&lt;br /&gt;
  threeDViewNode = view.mrmlViewNode()&lt;br /&gt;
  cameraNode = slicer.modules.cameras.logic().GetViewActiveCameraNode(threeDViewNode)&lt;br /&gt;
  print('View node for 3D widget ' + str(threeDViewIndex))&lt;br /&gt;
  print('  Name: ' + threeDViewNode .GetName())&lt;br /&gt;
  print('  ID: ' + threeDViewNode .GetID())&lt;br /&gt;
  print('  Camera ID: ' + cameraNode.GetID())&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Iterate through all slice views in current layout:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
layoutManager = slicer.app.layoutManager()&lt;br /&gt;
for sliceViewName in layoutManager.sliceViewNames():&lt;br /&gt;
  view = layoutManager.sliceWidget(sliceViewName).sliceView()&lt;br /&gt;
  sliceNode = view.mrmlSliceNode()&lt;br /&gt;
  sliceLogic = slicer.app.applicationLogic().GetSliceLogic(sliceNode)&lt;br /&gt;
  compositeNode = sliceLogic.GetSliceCompositeNode()&lt;br /&gt;
  print('Slice view ' + str(sliceViewName))&lt;br /&gt;
  print('  Name: ' + sliceNode.GetName())&lt;br /&gt;
  print('  ID: ' + sliceNode.GetID())&lt;br /&gt;
  print('  Background volume: {0}'.format(compositeNode.GetBackgroundVolumeID()))&lt;br /&gt;
  print('  Foreground volume: {0} (opacity: {1})'.format(compositeNode.GetForegroundVolumeID(), compositeNode.GetForegroundOpacity()))&lt;br /&gt;
  print('  Label volume: {0} (opacity: {1})'.format(compositeNode.GetLabelVolumeID(), compositeNode.GetLabelOpacity()))&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
For low-level manipulation of views, it is possible to access VTK render windows, renderers and cameras of views in the current layout.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
renderWindow = view.renderWindow()&lt;br /&gt;
renderers = renderWindow.GetRenderers()&lt;br /&gt;
renderer = renderers.GetItemAsObject(0)&lt;br /&gt;
camera = cameraNode.GetCamera()&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Change 3D view background color ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
renderWindow = slicer.app.layoutManager().threeDWidget(0).threeDView().renderWindow()&lt;br /&gt;
renderer = renderWindow.GetRenderers().GetFirstRenderer()&lt;br /&gt;
renderer.SetBackground(1,0,0)&lt;br /&gt;
renderer.SetBackground2(1,0,0)&lt;br /&gt;
renderWindow.Render()&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Subject hierarchy == &lt;br /&gt;
==== Get the pseudo-singleton subject hierarchy node ====&lt;br /&gt;
It manages the whole hierarchy and provides functions to access and manipulate&lt;br /&gt;
  shNode = slicer.vtkMRMLSubjectHierarchyNode.GetSubjectHierarchyNode(slicer.mrmlScene)&lt;br /&gt;
&lt;br /&gt;
==== Create subject hierarchy item ====&lt;br /&gt;
  # If it is for a data node, it is automatically created, but the create function can be used to set parent:&lt;br /&gt;
  shNode.CreateItem(parentItemID, dataNode)&lt;br /&gt;
  # If it is a hierarchy item without a data node, then the create function must be used:&lt;br /&gt;
  shNode.CreateSubjectItem(parentItemID, name)&lt;br /&gt;
  shNode.CreateFolderItem(parentItemID, name)&lt;br /&gt;
  shNode.CreateHierarchyItem(parentItemID, name, level) # Advanced method to set level attribute manually (usually subject, study, or folder, but it can be a virtual branch for example)&lt;br /&gt;
&lt;br /&gt;
==== Get subject hierarchy item ====&lt;br /&gt;
Items in subject hierarchy are uniquely identified by integer IDs&lt;br /&gt;
  # Get scene item ID first because it is the root item:&lt;br /&gt;
  sceneItemID = shNode.GetSceneItemID()&lt;br /&gt;
  # Get direct child by name&lt;br /&gt;
  subjectItemID = shNode.GetItemChildWithName(sceneItemID, 'Subject_1')&lt;br /&gt;
  # Get item for data node&lt;br /&gt;
  itemID = shNode.GetItemByDataNode(dataNode)&lt;br /&gt;
  # Get item by UID (such as DICOM)&lt;br /&gt;
  itemID = shNode.GetItemByUID(slicer.vtkMRMLSubjectHierarchyConstants.GetDICOMUIDName(), seriesInstanceUid)&lt;br /&gt;
  itemID = shNode.GetItemByUIDList(slicer.vtkMRMLSubjectHierarchyConstants.GetDICOMInstanceUIDName(), instanceUID)&lt;br /&gt;
  # Invalid item ID for checking validity of a given ID (most functions return the invalid ID when item is not found)&lt;br /&gt;
  invalidItemID = slicer.vtkMRMLSubjectHierarchyNode.GetInvalidItemID()&lt;br /&gt;
&lt;br /&gt;
==== Traverse children of a subject hierarchy item ====&lt;br /&gt;
  children = vtk.vtkIdList()&lt;br /&gt;
  shNode.GetItemChildren(parent, children)&lt;br /&gt;
  for i in xrange(children.GetNumberOfIds()):&lt;br /&gt;
    child = children.GetId(i)&lt;br /&gt;
    ...&lt;br /&gt;
&lt;br /&gt;
==== Manipulate subject hierarchy item ====&lt;br /&gt;
Instead of node operations on the individual subject hierarchy nodes, item operations are performed on the one subject hierarchy node.&lt;br /&gt;
  # Set item name&lt;br /&gt;
  shNode.SetItemName(itemID, 'NewName')&lt;br /&gt;
  # Set item parent (reparent)&lt;br /&gt;
  shNode.SetItemParent(itemID, newParentItemID)&lt;br /&gt;
  # Set visibility of data nodes associated to items in a branch (or a leaf item)&lt;br /&gt;
  shNode.SetDisplayVisibilityForBranch(itemID, 1)&lt;br /&gt;
&lt;br /&gt;
==== Filter items in TreeView or ComboBox ====&lt;br /&gt;
Displayed items can be filtered using ''setAttributeFilter'' method. An example of the usage can be found in the  [https://github.com/Slicer/Slicer/blob/e66e3b08e35384526528e6ae678e9ec9f079f286/Applications/SlicerApp/Testing/Python/SubjectHierarchyGenericSelfTest.py#L352-L360 unit test]. Modified version here:&lt;br /&gt;
    print shTreeView.displayedItemCount() # 5&lt;br /&gt;
    shTreeView.setAttributeFilter('DICOM.Modality') # Nodes must have this attribute&lt;br /&gt;
    print shTreeView.displayedItemCount() # 3&lt;br /&gt;
    shTreeView.setAttributeFilter('DICOM.Modality','CT') # Have attribute and equal 'CT'&lt;br /&gt;
    print shTreeView.displayedItemCount() # 1&lt;br /&gt;
    shTreeView.removeAttributeFilter()&lt;br /&gt;
    print shTreeView.displayedItemCount() # 5&lt;br /&gt;
&lt;br /&gt;
=== Listen to subject hierarchy item events ===&lt;br /&gt;
The subject hierarchy node sends the node item id as calldata. Item IDs are vtkIdType, which are NOT vtkObjects. You need to use vtk.calldata_type(vtk.VTK_LONG) (otherwise the application crashes).&lt;br /&gt;
  &lt;br /&gt;
  class MyListenerClass(VTKObservationMixin):&lt;br /&gt;
    def __init__(self):&lt;br /&gt;
      VTKObservationMixin.__init__(self)&lt;br /&gt;
      &lt;br /&gt;
      shNode = slicer.vtkMRMLSubjectHierarchyNode.GetSubjectHierarchyNode(slicer.mrmlScene)&lt;br /&gt;
      self.addObserver(shNode, shNode.SubjectHierarchyItemModifiedEvent, self.shItemModifiedEvent)&lt;br /&gt;
     &lt;br /&gt;
    @vtk.calldata_type(vtk.VTK_LONG) &lt;br /&gt;
    def shItemModifiedEvent(self, caller, eventId, callData):&lt;br /&gt;
      print(&amp;quot;SH Node modified&amp;quot;)&lt;br /&gt;
      print(&amp;quot;SH item ID: {0}&amp;quot;.format(callData))&lt;br /&gt;
&lt;br /&gt;
== Plotting ==&lt;br /&gt;
&lt;br /&gt;
=== Create histogram plot of a volume ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Get a volume from SampleData&lt;br /&gt;
import SampleData&lt;br /&gt;
volumeNode = SampleData.SampleDataLogic().downloadMRHead()&lt;br /&gt;
&lt;br /&gt;
# Compute histogram values&lt;br /&gt;
import numpy as np&lt;br /&gt;
histogram = np.histogram(arrayFromVolume(volumeNode), bins=50)&lt;br /&gt;
&lt;br /&gt;
# Save results to a new table node&lt;br /&gt;
tableNode=slicer.mrmlScene.AddNewNodeByClass(&amp;quot;vtkMRMLTableNode&amp;quot;)&lt;br /&gt;
updateTableFromArray(tableNode, histogram)&lt;br /&gt;
tableNode.GetTable().GetColumn(0).SetName(&amp;quot;Count&amp;quot;)&lt;br /&gt;
tableNode.GetTable().GetColumn(1).SetName(&amp;quot;Intensity&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
# Create plot&lt;br /&gt;
plotSeriesNode = slicer.mrmlScene.AddNewNodeByClass(&amp;quot;vtkMRMLPlotSeriesNode&amp;quot;, volumeNode.GetName() + ' histogram')&lt;br /&gt;
plotSeriesNode.SetAndObserveTableNodeID(tableNode.GetID())&lt;br /&gt;
plotSeriesNode.SetXColumnName(&amp;quot;Intensity&amp;quot;)&lt;br /&gt;
plotSeriesNode.SetYColumnName(&amp;quot;Count&amp;quot;)&lt;br /&gt;
plotSeriesNode.SetPlotType(plotSeriesNode.PlotTypeScatterBar)&lt;br /&gt;
plotSeriesNode.SetColor(0, 0.6, 1.0)&lt;br /&gt;
&lt;br /&gt;
# Create chart and add plot&lt;br /&gt;
plotChartNode = slicer.mrmlScene.AddNewNodeByClass(&amp;quot;vtkMRMLPlotChartNode&amp;quot;)&lt;br /&gt;
plotChartNode.AddAndObservePlotSeriesNodeID(plotSeriesNode.GetID())&lt;br /&gt;
plotChartNode.YAxisRangeAutoOff()&lt;br /&gt;
plotChartNode.SetYAxisRange(0, 500000)&lt;br /&gt;
&lt;br /&gt;
# Show plot in layout&lt;br /&gt;
slicer.modules.plots.logic().ShowChartInLayout(plotChartNode)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Execute external applications ==&lt;br /&gt;
&lt;br /&gt;
How to run external applications from Slicer.&lt;br /&gt;
&lt;br /&gt;
=== Run process in default environment ===&lt;br /&gt;
&lt;br /&gt;
When a process is launched from Slicer then by default Slicer's ITK, VTK, Qt, etc. libraries are used. If an external application has its own version of these libraries, then the application is expected to crash. To prevent crashing, the application must be run in the environment where Slicer started up (without all Slicer-specific library paths). This startup environment can be retrieved using ''slicer.util.startupEnvironment()''.&lt;br /&gt;
&lt;br /&gt;
Example: run Python3 script from Slicer:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
command_to_execute = [&amp;quot;/usr/bin/python3&amp;quot;, &amp;quot;-c&amp;quot;, &amp;quot;print('hola')&amp;quot;]&lt;br /&gt;
from subprocess import check_output&lt;br /&gt;
check_output(&lt;br /&gt;
  command_to_execute, &lt;br /&gt;
  env=slicer.util.startupEnvironment()&lt;br /&gt;
  )&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
will output:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
'hola\n'&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
On some systems, ''shell=True'' must be specified as well.&lt;/div&gt;</summary>
		<author><name>Inorton</name></author>
		
	</entry>
	<entry>
		<id>https://www.slicer.org/w/index.php?title=Documentation/Nightly/ScriptRepository&amp;diff=60489</id>
		<title>Documentation/Nightly/ScriptRepository</title>
		<link rel="alternate" type="text/html" href="https://www.slicer.org/w/index.php?title=Documentation/Nightly/ScriptRepository&amp;diff=60489"/>
		<updated>2018-10-26T20:15:30Z</updated>

		<summary type="html">&lt;p&gt;Inorton: /* Change window/level (brightness/contrast) or colormap of a volume */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;noinclude&amp;gt;{{documentation/versioncheck}}&amp;lt;/noinclude&amp;gt;&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Community-contributed modules=&lt;br /&gt;
&lt;br /&gt;
The examples in this section are [[Documentation/{{documentation/version}}/Developers/Modules#Scripted_Modules| Scripted Modules]] that provide a user interface in the module panel along with specialized implementation logic.&lt;br /&gt;
&lt;br /&gt;
Usage: save the .py file to a directory, add the directory to the additional module paths in the Slicer application settings (choose in the menu: Edit / Application settings, click Modules, click &amp;gt;&amp;gt; next to Additional module paths, click Add, and choose the .py file's location).&lt;br /&gt;
&lt;br /&gt;
==Filters==&lt;br /&gt;
* [https://raw.github.com/pieper/VolumeMasker/master/VolumeMasker.py VolumeMasker.py]: Update a target volume with the results of setting all input volume voxels to 0 except for those that correspond to a selected label value in an input label map (Used for example in the volume rendering in [https://www.youtube.com/watch?v=dfu2gugHLHs this video).&lt;br /&gt;
&lt;br /&gt;
==DICOM==&lt;br /&gt;
* [https://gist.github.com/pieper/6186477 dicom header browser] to easily scroll through dicom files using dcmdump.&lt;br /&gt;
* [https://github.com/SlicerRt/SlicerRT/tree/master/BatchProcessing SlicerRT batch processing] to batch convert RT structure sets to labelmap NRRD files.&lt;br /&gt;
&lt;br /&gt;
==Informatics==&lt;br /&gt;
* [https://gist.github.com/lassoan/bf0954d93cacc8cbe27cd4a3ad503f2f MarkupsInfo.py]: Compute the total length between all the points of a markup list.&lt;br /&gt;
* [https://gist.github.com/lassoan/0e7acfbec36e4577f8b7b0e07ad53a2a LineProfile.py]: Compute intensity profile in a volume along a line.&lt;br /&gt;
&lt;br /&gt;
=Community-contributed examples=&lt;br /&gt;
&lt;br /&gt;
Usage: Copy-paste the shown code lines or linked .py file contents into Python console in Slicer.  Or save them to a file and run them using execfile.&lt;br /&gt;
&lt;br /&gt;
==Capture==&lt;br /&gt;
* Capture the full Slicer screen and save it into a file&lt;br /&gt;
  img = qt.QPixmap.grabWidget(slicer.util.mainWindow()).toImage()&lt;br /&gt;
  img.save('c:/tmp/test.png')&lt;br /&gt;
* Capture all the views save it into a file:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
import ScreenCapture&lt;br /&gt;
cap = ScreenCapture.ScreenCaptureLogic()&lt;br /&gt;
cap.showViewControllers(False)&lt;br /&gt;
cap.captureImageFromView(None,'c:/tmp/test.png')&lt;br /&gt;
cap.showViewControllers(True)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
* Capture a single view:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
viewNodeID = 'vtkMRMLViewNode1'&lt;br /&gt;
import ScreenCapture&lt;br /&gt;
cap = ScreenCapture.ScreenCaptureLogic()&lt;br /&gt;
view = cap.viewFromNode(slicer.mrmlScene.GetNodeByID(viewNodeID))&lt;br /&gt;
cap.captureImageFromView(view,'c:/tmp/test.png')&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Common values for viewNodeID: vtkMRMLSliceNodeRed, vtkMRMLSliceNodeYellow, vtkMRMLSliceNodeGreen, vtkMRMLViewNode1, vtkMRMLViewNode2. &lt;br /&gt;
The ScreenCapture module can also create video animations of rotating views, slice sweeps, etc.&lt;br /&gt;
&lt;br /&gt;
* Capture a slice view sweep into a series of PNG files - for example, Red slice view, 30 images, from position -125.0 to 75.0, into c:/tmp folder, with name image_00001.png, image_00002.png, ...&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
import ScreenCapture&lt;br /&gt;
ScreenCapture.ScreenCaptureLogic().captureSliceSweep(getNode('vtkMRMLSliceNodeRed'), -125.0, 75.0, 30, &amp;quot;c:/tmp&amp;quot;, &amp;quot;image_%05d.png&amp;quot;)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Capture 3D view into PNG file with transparent background&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
renderWindow = slicer.app.layoutManager().threeDWidget(0).threeDView().renderWindow()&lt;br /&gt;
renderWindow.SetAlphaBitPlanes(1)&lt;br /&gt;
wti = vtk.vtkWindowToImageFilter()&lt;br /&gt;
wti.SetInputBufferTypeToRGBA()&lt;br /&gt;
wti.SetInput(renderWindow)&lt;br /&gt;
writer = vtk.vtkPNGWriter()&lt;br /&gt;
writer.SetFileName(&amp;quot;c:/tmp/screenshot.png&amp;quot;)&lt;br /&gt;
writer.SetInputConnection(wti.GetOutputPort())&lt;br /&gt;
writer.Write()&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Launching Slicer==&lt;br /&gt;
* How to open an .mrb file with Slicer at the command line?&lt;br /&gt;
  Slicer.exe --python-code &amp;quot;slicer.util.loadScene( 'f:/2013-08-23-Scene.mrb' )&amp;quot;&lt;br /&gt;
* How to run a script in the Slicer environment in batch mode (without showing any graphical user interface)?&lt;br /&gt;
  Slicer.exe --python-code &amp;quot;doSomething; doSomethingElse; etc.&amp;quot; --testing --no-splash --no-main-window&lt;br /&gt;
&lt;br /&gt;
==Load volume from file==&lt;br /&gt;
When loading a volume from file, it is recommended to set returnNode=True to retrieve the loaded volume node.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
[success, loadedVolumeNode] = slicer.util.loadVolume('c:/Users/abc/Documents/MRHead.nrrd', returnNode=True)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Get a MRML node in the scene based on the node name and call methods of that object. For the MRHead sample data:&lt;br /&gt;
  vol=slicer.util.getNode('MR*')&lt;br /&gt;
  vol.GetImageData().GetDimensions()&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Show volume rendering automatically when a volume is loaded==&lt;br /&gt;
&lt;br /&gt;
To show volume rendering of a volume automatically when it is loaded, add the lines below to your &lt;br /&gt;
[[Documentation/{{documentation/version}}/Developers/Python_scripting#How_to_systematically_execute_custom_python_code_at_startup_.3F|.slicerrc file]].&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
@vtk.calldata_type(vtk.VTK_OBJECT)&lt;br /&gt;
def onNodeAdded(caller, event, calldata):&lt;br /&gt;
  node = calldata&lt;br /&gt;
  if isinstance(node, slicer.vtkMRMLVolumeNode):&lt;br /&gt;
    # Call showVolumeRendering using a timer instead of calling it directly&lt;br /&gt;
    # to allow the volume loading to fully complete.&lt;br /&gt;
    qt.QTimer.singleShot(0, lambda: showVolumeRendering(node))&lt;br /&gt;
&lt;br /&gt;
def showVolumeRendering(volumeNode):&lt;br /&gt;
  print(&amp;quot;Show volume rendering of node &amp;quot;+volumeNode.GetName())&lt;br /&gt;
  volRenLogic = slicer.modules.volumerendering.logic()&lt;br /&gt;
  displayNode = volRenLogic.CreateDefaultVolumeRenderingNodes(volumeNode)&lt;br /&gt;
  displayNode.SetVisibility(True)&lt;br /&gt;
  scalarRange = volumeNode.GetImageData().GetScalarRange()&lt;br /&gt;
  if scalarRange[1]-scalarRange[0] &amp;lt; 1500:&lt;br /&gt;
    # small dynamic range, probably MRI&lt;br /&gt;
    displayNode.GetVolumePropertyNode().Copy(volRenLogic.GetPresetByName('MR-Default'))&lt;br /&gt;
  else:&lt;br /&gt;
    # larger dynamic range, probably CT&lt;br /&gt;
    displayNode.GetVolumePropertyNode().Copy(volRenLogic.GetPresetByName('CT-Chest-Contrast-Enhanced'))&lt;br /&gt;
    &lt;br /&gt;
slicer.mrmlScene.AddObserver(slicer.vtkMRMLScene.NodeAddedEvent, onNodeAdded)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==DICOM==&lt;br /&gt;
=== How to access tags of DICOM images imported into Slicer? For example, to print the first patient's first study's first series' &amp;quot;0020,0032&amp;quot; field:===&lt;br /&gt;
  db=slicer.dicomDatabase&lt;br /&gt;
  patientList=db.patients()&lt;br /&gt;
  studyList=db.studiesForPatient(patientList[0])&lt;br /&gt;
  seriesList=db.seriesForStudy(studyList[0])&lt;br /&gt;
  fileList=db.filesForSeries(seriesList[0])&lt;br /&gt;
  print db.fileValue(fileList[0],'0020,0032')&lt;br /&gt;
&lt;br /&gt;
=== How to access tag of a volume loaded from DICOM? For example, get the patient position stored in a volume:===&lt;br /&gt;
  volumeName='2: ENT IMRT'&lt;br /&gt;
  n=slicer.util.getNode(volumeName)&lt;br /&gt;
  instUids=n.GetAttribute('DICOM.instanceUIDs').split()&lt;br /&gt;
  filename=slicer.dicomDatabase.fileForInstance(instUids[0])&lt;br /&gt;
  print slicer.dicomDatabase.fileValue(filename,'0018,5100')&lt;br /&gt;
&lt;br /&gt;
=== How to access tag of an item in the Subject Hierachy tree? For example, get the content time tag of a structure set:===&lt;br /&gt;
  rtStructName = '3: RTSTRUCT: PROS'&lt;br /&gt;
  rtStructNode = slicer.util.getNode(rtStructName)&lt;br /&gt;
  shNode = slicer.vtkMRMLSubjectHierarchyNode.GetSubjectHierarchyNode(slicer.mrmlScene)&lt;br /&gt;
  rtStructShItemID = shNode.GetItemByDataNode(rtStructNode)&lt;br /&gt;
  ctSliceInstanceUids = shNode.GetItemAttribute(rtStructShItemID, 'DICOM.ReferencedInstanceUIDs').split()&lt;br /&gt;
  filename = slicer.dicomDatabase.fileForInstance(ctSliceInstanceUids[0])&lt;br /&gt;
  print slicer.dicomDatabase.fileValue(filename,'0008,0033')&lt;br /&gt;
&lt;br /&gt;
=== How to get path and filename of a loaded DICOM volume?===&lt;br /&gt;
  def pathFromNode(node):&lt;br /&gt;
    storageNode=node.GetStorageNode()&lt;br /&gt;
    if storageNode is not None: # loaded via drag-drop&lt;br /&gt;
        filepath=storageNode.GetFullNameFromFileName()&lt;br /&gt;
    else: # loaded via DICOM browser&lt;br /&gt;
        instanceUIDs=node.GetAttribute('DICOM.instanceUIDs').split()&lt;br /&gt;
        filepath=slicer.dicomDatabase.fileForInstance(instUids[0])&lt;br /&gt;
    return filepath&lt;br /&gt;
  &lt;br /&gt;
  # example:&lt;br /&gt;
  node=slicer.util.getNode('volume1')&lt;br /&gt;
  path=self.pathFromNode(node)&lt;br /&gt;
  print(&amp;quot;DICOM path=%s&amp;quot; % path)&lt;br /&gt;
&lt;br /&gt;
=== How can I convert DICOM to NRRD on the command line?===&lt;br /&gt;
&lt;br /&gt;
 /Applications/Slicer-4.6.2.app/Contents/MacOS/Slicer --no-main-window --python-code &amp;quot;node=slicer.util.loadVolume('/tmp/series/im0.dcm', returnNode=True)[1]; slicer.util.saveNode(node, '/tmp/output.nrrd'); exit()&amp;quot;&lt;br /&gt;
&lt;br /&gt;
The same can be done on windows by using the top level Slicer.exe.  Be sure to use forward slashes in the pathnames within quotes on the command line.&lt;br /&gt;
&lt;br /&gt;
=== Export a volume to DICOM file format ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
volumeNode = getNode('CTChest')&lt;br /&gt;
outputFolder = &amp;quot;c:/tmp/dicom-output&amp;quot;&lt;br /&gt;
&lt;br /&gt;
# Create patient and study and put the volume under the study&lt;br /&gt;
shNode = slicer.vtkMRMLSubjectHierarchyNode.GetSubjectHierarchyNode(slicer.mrmlScene)&lt;br /&gt;
patientItemID = shNode.CreateSubjectItem(shNode.GetSceneItemID(), &amp;quot;test patient&amp;quot;)&lt;br /&gt;
studyItemID = shNode.CreateStudyItem(patientItemID, &amp;quot;test study&amp;quot;)&lt;br /&gt;
volumeShItemID = shNode.GetItemByDataNode(volumeNode)&lt;br /&gt;
shNode.SetItemParent(volumeShItemID, studyItemID)&lt;br /&gt;
&lt;br /&gt;
import DICOMScalarVolumePlugin&lt;br /&gt;
exporter = DICOMScalarVolumePlugin.DICOMScalarVolumePluginClass()&lt;br /&gt;
exportables = exporter.examineForExport(volumeShItemID)&lt;br /&gt;
for exp in exportables:&lt;br /&gt;
  exp.directory = outputFolder&lt;br /&gt;
&lt;br /&gt;
exporter.export(exportables)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Toolbar functions==&lt;br /&gt;
* How to turn on slice intersections in the crosshair menu on the toolbar:&lt;br /&gt;
  viewNodes = slicer.mrmlScene.GetNodesByClass('vtkMRMLSliceCompositeNode')&lt;br /&gt;
  viewNodes.UnRegister(slicer.mrmlScene)&lt;br /&gt;
  viewNodes.InitTraversal()&lt;br /&gt;
  viewNode = viewNodes.GetNextItemAsObject()&lt;br /&gt;
  while viewNode:&lt;br /&gt;
    viewNode.SetSliceIntersectionVisibility(1)&lt;br /&gt;
    viewNode = viewNodes.GetNextItemAsObject()&lt;br /&gt;
&lt;br /&gt;
How to find similar functions? For this one I searched for &amp;quot;slice intersections&amp;quot; text in the whole slicer source code, found that the function is implemented in Base\QTGUI\qSlicerViewersToolBar.cxx, then translated the qSlicerViewersToolBarPrivate::setSliceIntersectionVisible(bool visible) method to Python.&lt;br /&gt;
&lt;br /&gt;
==Manipulating objects in the slice viewer==&lt;br /&gt;
* How to define/edit a circular region of interest in a slice viewer?&lt;br /&gt;
&lt;br /&gt;
Drop two markup points on a slice view and copy-paste the code below into the Python console. After this, as you move the markups you’ll see a circle following the markups.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Update the sphere from the fiducial points&lt;br /&gt;
def UpdateSphere(param1, param2):  &lt;br /&gt;
  import math&lt;br /&gt;
  centerPointCoord = [0.0, 0.0, 0.0]&lt;br /&gt;
  markups.GetNthFiducialPosition(0,centerPointCoord)&lt;br /&gt;
  circumferencePointCoord = [0.0, 0.0, 0.0]&lt;br /&gt;
  markups.GetNthFiducialPosition(1,circumferencePointCoord)&lt;br /&gt;
  sphere.SetCenter(centerPointCoord)&lt;br /&gt;
  radius=math.sqrt((centerPointCoord[0]-circumferencePointCoord[0])**2+(centerPointCoord[1]-circumferencePointCoord[1])**2+(centerPointCoord[2]-circumferencePointCoord[2])**2)&lt;br /&gt;
  sphere.SetRadius(radius)&lt;br /&gt;
  sphere.SetPhiResolution(30)&lt;br /&gt;
  sphere.SetThetaResolution(30)&lt;br /&gt;
  sphere.Update()&lt;br /&gt;
&lt;br /&gt;
# Get markup node from scene&lt;br /&gt;
markups=slicer.util.getNode('F')&lt;br /&gt;
sphere = vtk.vtkSphereSource()&lt;br /&gt;
UpdateSphere(0,0)&lt;br /&gt;
 &lt;br /&gt;
# Create model node and add to scene&lt;br /&gt;
modelsLogic = slicer.modules.models.logic()&lt;br /&gt;
model = modelsLogic.AddModel(sphere.GetOutput())&lt;br /&gt;
model.GetDisplayNode().SetSliceIntersectionVisibility(True)&lt;br /&gt;
model.GetDisplayNode().SetSliceIntersectionThickness(3)&lt;br /&gt;
model.GetDisplayNode().SetColor(1,1,0)&lt;br /&gt;
 &lt;br /&gt;
# Call UpdateSphere whenever the fiducials are changed&lt;br /&gt;
markups.AddObserver(&amp;quot;ModifiedEvent&amp;quot;, UpdateSphere, 2)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Set slice position and orientation from 3 markup fiducials==&lt;br /&gt;
&lt;br /&gt;
Drop 3 markup points in the scene and copy-paste the code below into the Python console. After this, as you move the markups you’ll see the red slice view position and orientation will be set to make it fit to the 3 points.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Update plane from fiducial points&lt;br /&gt;
def UpdateSlicePlane(param1=None, param2=None):&lt;br /&gt;
  # Get point positions as numpy array&lt;br /&gt;
  import numpy as np&lt;br /&gt;
  nOfFiduciallPoints = markups.GetNumberOfFiducials()&lt;br /&gt;
  if nOfFiduciallPoints &amp;lt; 3:&lt;br /&gt;
    return  # not enough points&lt;br /&gt;
  points = np.zeros([3,nOfFiduciallPoints])&lt;br /&gt;
  for i in range(0, nOfFiduciallPoints):&lt;br /&gt;
    markups.GetNthFiducialPosition(i, points[:,i])&lt;br /&gt;
  # Compute plane position and normal&lt;br /&gt;
  planePosition = points.mean(axis=1)&lt;br /&gt;
  planeNormal = np.cross(points[:,1] - points[:,0], points[:,2] - points[:,0])&lt;br /&gt;
  planeX = points[:,1] - points[:,0]&lt;br /&gt;
  sliceNode.SetSliceToRASByNTP(planeNormal[0], planeNormal[1], planeNormal[2],&lt;br /&gt;
    planeX[0], planeX[1], planeX[2],&lt;br /&gt;
    planePosition[0], planePosition[1], planePosition[2], 0)&lt;br /&gt;
&lt;br /&gt;
# Get markup node from scene&lt;br /&gt;
sliceNode = slicer.app.layoutManager().sliceWidget('Red').mrmlSliceNode()&lt;br /&gt;
markups = slicer.util.getNode('F')&lt;br /&gt;
&lt;br /&gt;
# Update slice plane manually&lt;br /&gt;
UpdateSlicePlane()&lt;br /&gt;
&lt;br /&gt;
# Update slice plane automatically whenever points are changed&lt;br /&gt;
markupObservation = [markups, markups.AddObserver(&amp;quot;ModifiedEvent&amp;quot;, UpdateSlicePlane, 2)]&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To stop automatic updates, run this:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
markupObservation[0].RemoveObserver(markupObservation[1])&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Switching to markup fiducial placement mode ==&lt;br /&gt;
&lt;br /&gt;
To activate a fiducial placement mode, both interaction mode has to be set and a fiducial node has to be selected:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
interactionNode = slicer.app.applicationLogic().GetInteractionNode()&lt;br /&gt;
selectionNode = slicer.app.applicationLogic().GetSelectionNode()&lt;br /&gt;
selectionNode.SetReferenceActivePlaceNodeClassName(&amp;quot;vtkMRMLMarkupsFiducialNode&amp;quot;)&lt;br /&gt;
fiducialNode = slicer.vtkMRMLMarkupsFiducialNode()&lt;br /&gt;
slicer.mrmlScene.AddNode(fiducialNode)&lt;br /&gt;
fiducialNode.CreateDefaultDisplayNodes() &lt;br /&gt;
selectionNode.SetActivePlaceNodeID(fiducialNode.GetID())&lt;br /&gt;
interactionNode.SetCurrentInteractionMode(interactionNode.Place)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Get a notification if a markup point position is modified ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
def onMarkupsNodeModified(markupsNode, unusedArg2=None, unusedArg3=None):&lt;br /&gt;
  sliceView = markupsNode.GetAttribute('Markups.MovingInSliceView')&lt;br /&gt;
  if not sliceView:&lt;br /&gt;
    print(&amp;quot;Markup list was modified&amp;quot;)&lt;br /&gt;
    return&lt;br /&gt;
  movingMarkupIndex = markupsNode.GetAttribute('Markups.MovingMarkupIndex')&lt;br /&gt;
  pos = [0,0,0]&lt;br /&gt;
  markupsNode.GetNthFiducialPosition(int(movingMarkupIndex), pos)  &lt;br /&gt;
  print(&amp;quot;Markup {0} was moved in slice view {1} to {2}&amp;quot;.format(movingMarkupIndex, sliceView, pos))&lt;br /&gt;
&lt;br /&gt;
markupsNode = slicer.mrmlScene.AddNewNodeByClass(&amp;quot;vtkMRMLMarkupsFiducialNode&amp;quot;)&lt;br /&gt;
markupsNode.CreateDefaultDisplayNodes()&lt;br /&gt;
markupsNode.AddFiducial(0,0,0)&lt;br /&gt;
markupsNode.AddObserver(vtk.vtkCommand.ModifiedEvent, onMarkupsNodeModified)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Show a context menu when a markup point is clicked in a slice or 3D view ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
# Example actions to perform&lt;br /&gt;
&lt;br /&gt;
def action1():&lt;br /&gt;
  print('Action1 on markup '+str(slicer.clickedMarkupIndex))&lt;br /&gt;
&lt;br /&gt;
def action2():&lt;br /&gt;
  print('Action2 on markup '+str(slicer.clickedMarkupIndex))&lt;br /&gt;
&lt;br /&gt;
def action3():&lt;br /&gt;
  print('Action3 on markup '+str(slicer.clickedMarkupIndex))&lt;br /&gt;
&lt;br /&gt;
# Clicked markup index is saved here to let the action&lt;br /&gt;
# know which markup needs to be manipulated.&lt;br /&gt;
slicer.clickedMarkupIndex = -1&lt;br /&gt;
  &lt;br /&gt;
# Create a simple menu&lt;br /&gt;
&lt;br /&gt;
menu = qt.QMenu()&lt;br /&gt;
a1 = qt.QAction(&amp;quot;Test&amp;quot;, slicer.util.mainWindow())&lt;br /&gt;
a1.connect('triggered()', action1)&lt;br /&gt;
menu.addAction(a1)&lt;br /&gt;
a2 = qt.QAction(&amp;quot;Action&amp;quot;, slicer.util.mainWindow())&lt;br /&gt;
a2.connect('triggered()', action1)&lt;br /&gt;
menu.addAction(a2)&lt;br /&gt;
a3 = qt.QAction(&amp;quot;Here&amp;quot;, slicer.util.mainWindow())&lt;br /&gt;
a3.connect('triggered()', action1)&lt;br /&gt;
menu.addAction(a3)&lt;br /&gt;
&lt;br /&gt;
# Add observer to a markup fiducial list&lt;br /&gt;
&lt;br /&gt;
@vtk.calldata_type(vtk.VTK_INT)&lt;br /&gt;
def markupClickedCallback(caller, eventId, callData):&lt;br /&gt;
  slicer.clickedMarkupIndex = callData&lt;br /&gt;
  print('Open menu on markup '+str(slicer.clickedMarkupIndex))&lt;br /&gt;
  menu.move(qt.QCursor.pos())&lt;br /&gt;
  menu.show()&lt;br /&gt;
&lt;br /&gt;
markupsNode = getNode('F')&lt;br /&gt;
observerTag = markupsNode.AddObserver(slicer.vtkMRMLMarkupsNode.PointClickedEvent, markupClickedCallback)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Add a texture mapped plane to the scene as a model ==&lt;br /&gt;
Note that model textures are not exposed in the GUI and are not saved in the scene&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# use dummy image data here&lt;br /&gt;
e = vtk.vtkImageEllipsoidSource()&lt;br /&gt;
&lt;br /&gt;
scene = slicer.mrmlScene&lt;br /&gt;
&lt;br /&gt;
# Create model node&lt;br /&gt;
model = slicer.vtkMRMLModelNode()&lt;br /&gt;
model.SetScene(scene)&lt;br /&gt;
model.SetName(scene.GenerateUniqueName(&amp;quot;2DImageModel&amp;quot;))&lt;br /&gt;
&lt;br /&gt;
planeSource = vtk.vtkPlaneSource()&lt;br /&gt;
model.SetAndObservePolyData(planeSource.GetOutput())&lt;br /&gt;
&lt;br /&gt;
# Create display node&lt;br /&gt;
modelDisplay = slicer.vtkMRMLModelDisplayNode()&lt;br /&gt;
modelDisplay.SetColor(1,1,0) # yellow&lt;br /&gt;
modelDisplay.SetBackfaceCulling(0)&lt;br /&gt;
modelDisplay.SetScene(scene)&lt;br /&gt;
scene.AddNode(modelDisplay)&lt;br /&gt;
model.SetAndObserveDisplayNodeID(modelDisplay.GetID())&lt;br /&gt;
&lt;br /&gt;
# Add to scene&lt;br /&gt;
modelDisplay.SetAndObserveTextureImageData(e.GetOutput())&lt;br /&gt;
scene.AddNode(model) &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
transform = slicer.vtkMRMLLinearTransformNode()&lt;br /&gt;
scene.AddNode(transform) &lt;br /&gt;
model.SetAndObserveTransformNodeID(transform.GetID())&lt;br /&gt;
&lt;br /&gt;
vTransform = vtk.vtkTransform()&lt;br /&gt;
vTransform.Scale(50,50,50)&lt;br /&gt;
vTransform.RotateX(30)&lt;br /&gt;
transform.SetAndObserveMatrixTransformToParent(vTransform.GetMatrix())&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Export entire scene as VRML ==&lt;br /&gt;
&lt;br /&gt;
Save all surface meshes displayed in the scene (models, markups, etc). Solid colors and coloring by scalar is preserved. Textures are not supported.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
exporter = vtk.vtkVRMLExporter()&lt;br /&gt;
exporter.SetRenderWindow(slicer.app.layoutManager().threeDWidget(0).threeDView().renderWindow())&lt;br /&gt;
exporter.SetFileName('C:/tmp/something.wrl')&lt;br /&gt;
exporter.Write()&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Export model to Blender, including color by scalar ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
modelNode = getNode(&amp;quot;Model&amp;quot;)&lt;br /&gt;
plyFilePath = &amp;quot;c:/tmp/model.ply&amp;quot;&lt;br /&gt;
&lt;br /&gt;
modelDisplayNode = modelNode.GetDisplayNode()&lt;br /&gt;
triangles = vtk.vtkTriangleFilter()&lt;br /&gt;
triangles.SetInputConnection(modelDisplayNode.GetOutputPolyDataConnection())&lt;br /&gt;
&lt;br /&gt;
plyWriter = vtk.vtkPLYWriter()&lt;br /&gt;
plyWriter.SetInputConnection(triangles.GetOutputPort())&lt;br /&gt;
lut = vtk.vtkLookupTable()&lt;br /&gt;
lut.DeepCopy(modelDisplayNode.GetColorNode().GetLookupTable())&lt;br /&gt;
lut.SetRange(modelDisplayNode.GetScalarRange())&lt;br /&gt;
plyWriter.SetLookupTable(lut)&lt;br /&gt;
plyWriter.SetArrayName(modelDisplayNode.GetActiveScalarName())&lt;br /&gt;
&lt;br /&gt;
plyWriter.SetFileName(plyFilePath)&lt;br /&gt;
plyWriter.Write()&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Export a tract (FiberBundle) to Blender, including color ==&lt;br /&gt;
&amp;lt;div id=&amp;quot;Export_a_fiber_tracts_to_Blender.2C_including_color&amp;quot;&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
Note: an interactive version of this script is now included in the [http://dmri.slicer.org/ SlicerDMRI extension] ([https://github.com/SlicerDMRI/SlicerDMRI/tree/master/Modules/Scripted/TractographyExportPLY module code]). &lt;br /&gt;
After installing SlicerDMRI, go to ''Modules -&amp;gt; Diffusion -&amp;gt; Import and Export -&amp;gt; Export tractography to PLY (mesh)''.&lt;br /&gt;
&lt;br /&gt;
The example below shows how to export a tractography &amp;quot;FiberBundleNode&amp;quot; to a PLY file:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
lineDisplayNode = getNode(&amp;quot;*LineDisplay*&amp;quot;)&lt;br /&gt;
plyFilePath = &amp;quot;/tmp/fibers.ply&amp;quot;&lt;br /&gt;
&lt;br /&gt;
tuber = vtk.vtkTubeFilter()&lt;br /&gt;
tuber.SetInputData(lineDisplayNode.GetOutputPolyData())&lt;br /&gt;
tuber.Update()&lt;br /&gt;
tubes = tuber.GetOutputDataObject(0)&lt;br /&gt;
scalars = tubes.GetPointData().GetArray(0)&lt;br /&gt;
scalars.SetName(&amp;quot;scalars&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
triangles = vtk.vtkTriangleFilter()&lt;br /&gt;
triangles.SetInputData(tubes)&lt;br /&gt;
triangles.Update()&lt;br /&gt;
&lt;br /&gt;
colorNode = lineDisplayNode.GetColorNode()&lt;br /&gt;
lookupTable = vtk.vtkLookupTable()&lt;br /&gt;
lookupTable.DeepCopy(colorNode.GetLookupTable())&lt;br /&gt;
lookupTable.SetTableRange(0,1)&lt;br /&gt;
&lt;br /&gt;
plyWriter = vtk.vtkPLYWriter()&lt;br /&gt;
plyWriter.SetInputData(triangles.GetOutput())&lt;br /&gt;
plyWriter.SetLookupTable(lookupTable)&lt;br /&gt;
plyWriter.SetArrayName(&amp;quot;scalars&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
plyWriter.SetFileName(plyFilePath)&lt;br /&gt;
plyWriter.Write()&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Iterate over tract (FiberBundle) streamline points ==&lt;br /&gt;
&lt;br /&gt;
This example shows how to access the points in each line of a FiberBundle as a numpy array (view).&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
from vtk.util.numpy_support import vtk_to_numpy&lt;br /&gt;
&lt;br /&gt;
fb = getNode(&amp;quot;FiberBundle_F&amp;quot;) # &amp;lt;- fill in node ID here&lt;br /&gt;
&lt;br /&gt;
# get point data as 1d array&lt;br /&gt;
points = slicer.util.arrayFromModelPoints(fb)&lt;br /&gt;
&lt;br /&gt;
# get line cell ids as 1d array&lt;br /&gt;
line_ids = vtk_to_numpy(fb.GetPolyData().GetLines().GetData())&lt;br /&gt;
&lt;br /&gt;
# VTK cell ids are stored as&lt;br /&gt;
#   [ N0 c0_id0 ... c0_id0&lt;br /&gt;
#     N1 c1_id0 ... c1_idN1 ]&lt;br /&gt;
# so we need to&lt;br /&gt;
# - read point count for each line (cell)&lt;br /&gt;
# - grab the ids in that range from `line_ids` array defined above&lt;br /&gt;
# - index the `points` array by those ids&lt;br /&gt;
cur_idx = 1&lt;br /&gt;
for _ in range(pd.GetLines().GetNumberOfCells()):&lt;br /&gt;
    # - read point count for this line (cell)&lt;br /&gt;
    count = lines[cur_idx - 1]&lt;br /&gt;
&lt;br /&gt;
    # - grab the ids in that range from `lines`&lt;br /&gt;
    index_array = line_ids[ cur_idx : cur_idx + count]&lt;br /&gt;
    # update to the next range &lt;br /&gt;
    cur_idx += count + 1&lt;br /&gt;
&lt;br /&gt;
    # - index the point array by those ids&lt;br /&gt;
    line_points = points[index_array]&lt;br /&gt;
&lt;br /&gt;
    # do work here&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Clone a node ==&lt;br /&gt;
&lt;br /&gt;
This example shows how to make a copy of any node that appears in Subject Hierarchy (in Data module).&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Get a node from SampleData that we will clone&lt;br /&gt;
import SampleData&lt;br /&gt;
nodeToClone = SampleData.SampleDataLogic().downloadMRHead()&lt;br /&gt;
&lt;br /&gt;
# Clone the node&lt;br /&gt;
shNode = slicer.vtkMRMLSubjectHierarchyNode.GetSubjectHierarchyNode(slicer.mrmlScene)&lt;br /&gt;
itemIDToClone = shNode.GetItemByDataNode(nodeToClone)&lt;br /&gt;
clonedItemID = slicer.modules.subjecthierarchy.logic().CloneSubjectHierarchyItem(shNode, itemIDToClone)&lt;br /&gt;
clonedNode = shNode.GetItemDataNode(clonedItemID)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Clone a volume ==&lt;br /&gt;
This example shows how to clone the MRHead sample volume, including its pixel data and display settings.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sourceVolumeNode = slicer.util.getNode('MRHead')&lt;br /&gt;
volumesLogic = slicer.modules.volumes.logic()&lt;br /&gt;
clonedVolumeNode = volumesLogic.CloneVolume(slicer.mrmlScene, sourceVolumeNode, 'Cloned volume')&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Create a new volume ==&lt;br /&gt;
This example shows how to create a new empty volume.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
nodeName = &amp;quot;MyNewVolume&amp;quot;&lt;br /&gt;
imageSize = [512, 512, 512]&lt;br /&gt;
voxelType=vtk.VTK_UNSIGNED_CHAR&lt;br /&gt;
imageOrigin = [0.0, 0.0, 0.0]&lt;br /&gt;
imageSpacing = [1.0, 1.0, 1.0]&lt;br /&gt;
imageDirections = [[1,0,0], [0,1,0], [0,0,1]]&lt;br /&gt;
fillVoxelValue = 0&lt;br /&gt;
&lt;br /&gt;
# Create an empty image volume, filled with fillVoxelValue&lt;br /&gt;
imageData = vtk.vtkImageData()&lt;br /&gt;
imageData.SetDimensions(imageSize)&lt;br /&gt;
imageData.AllocateScalars(voxelType, 1)&lt;br /&gt;
thresholder = vtk.vtkImageThreshold()&lt;br /&gt;
thresholder.SetInputData(imageData)&lt;br /&gt;
thresholder.SetInValue(fillVoxelValue)&lt;br /&gt;
thresholder.SetOutValue(fillVoxelValue)&lt;br /&gt;
thresholder.Update()&lt;br /&gt;
# Create volume node&lt;br /&gt;
volumeNode = slicer.mrmlScene.AddNewNodeByClass(&amp;quot;vtkMRMLScalarVolumeNode&amp;quot;, nodeName)&lt;br /&gt;
volumeNode.SetOrigin(imageOrigin)&lt;br /&gt;
volumeNode.SetSpacing(imageSpacing)&lt;br /&gt;
volumeNode.SetIJKToRASDirections(imageDirections)&lt;br /&gt;
volumeNode.SetAndObserveImageData(thresholder.GetOutput())&lt;br /&gt;
volumeNode.CreateDefaultDisplayNodes()&lt;br /&gt;
volumeNode.CreateDefaultStorageNode()&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Modify voxels in a volume ==&lt;br /&gt;
&lt;br /&gt;
Typically the fastest and simplest way of modifying voxels is by using numpy operators. Voxels can be retrieved in a numpy array using the `array` method and modified using standard numpy methods. For example, threshold a volume:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
nodeName = 'MRHead'&lt;br /&gt;
thresholdValue = 100&lt;br /&gt;
voxelArray = array(nodeName) # get voxels as numpy array&lt;br /&gt;
voxelArray[voxelArray &amp;lt; thresholdValue] = 0 # modify voxel values&lt;br /&gt;
getNode(nodeName).Modified() # at the end of all processing, notify Slicer that the image modification is completed&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This example shows how to change voxels values of the MRHead sample volume.&lt;br /&gt;
The values will be computed by function f(r,a,s,) = (r-10)*(r-10)+(a+15)*(a+15)+s*s.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
volumeNode=slicer.util.getNode('MRHead')&lt;br /&gt;
ijkToRas = vtk.vtkMatrix4x4()&lt;br /&gt;
volumeNode.GetIJKToRASMatrix(ijkToRas)&lt;br /&gt;
imageData=volumeNode.GetImageData()&lt;br /&gt;
extent = imageData.GetExtent()&lt;br /&gt;
for k in xrange(extent[4], extent[5]+1):&lt;br /&gt;
  for j in xrange(extent[2], extent[3]+1):&lt;br /&gt;
    for i in xrange(extent[0], extent[1]+1):&lt;br /&gt;
      position_Ijk=[i, j, k, 1]&lt;br /&gt;
      position_Ras=ijkToRas.MultiplyPoint(position_Ijk)&lt;br /&gt;
      r=position_Ras[0]&lt;br /&gt;
      a=position_Ras[1]&lt;br /&gt;
      s=position_Ras[2]      &lt;br /&gt;
      functionValue=(r-10)*(r-10)+(a+15)*(a+15)+s*s&lt;br /&gt;
      imageData.SetScalarComponentFromDouble(i,j,k,0,functionValue)&lt;br /&gt;
imageData.SetScalarComponentFromFloat(distortionVectorPosition_Ijk[0], distortionVectorPosition_Ijk[1], distortionVectorPosition_Ijk[2], 0, fillValue)&lt;br /&gt;
imageData.Modified()&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Get volume voxel coordinates from markup fiducial RAS coordinates ==&lt;br /&gt;
&lt;br /&gt;
This example shows how to get voxel coordinate of a volume corresponding to a markup fiducial point position.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Inputs&lt;br /&gt;
volumeNode = getNode('MRHead')&lt;br /&gt;
markupsNode = getNode('F')&lt;br /&gt;
markupsIndex = 0&lt;br /&gt;
&lt;br /&gt;
# Get point coordinate in RAS&lt;br /&gt;
point_Ras = [0, 0, 0, 1]&lt;br /&gt;
markupsNode.GetNthFiducialWorldCoordinates(markupsIndex, point_Ras)&lt;br /&gt;
&lt;br /&gt;
# If volume node is transformed, apply that transform to get volume's RAS coordinates&lt;br /&gt;
transformRasToVolumeRas = vtk.vtkGeneralTransform()&lt;br /&gt;
slicer.vtkMRMLTransformNode.GetTransformBetweenNodes(None, volumeNode.GetParentTransformNode(), transformRasToVolumeRas)&lt;br /&gt;
point_VolumeRas = transformRasToVolumeRas.TransformPoint(point_Ras[0:3])&lt;br /&gt;
&lt;br /&gt;
# Get voxel coordinates from physical coordinates&lt;br /&gt;
volumeRasToIjk = vtk.vtkMatrix4x4()&lt;br /&gt;
volumeNode.GetRASToIJKMatrix(volumeRasToIjk)&lt;br /&gt;
point_Ijk = [0, 0, 0, 1]&lt;br /&gt;
volumeRasToIjk.MultiplyPoint(np.append(point_VolumeRas,1.0), point_Ijk)&lt;br /&gt;
point_Ijk = [ int(round(c)) for c in point_Ijk[0:3] ]&lt;br /&gt;
&lt;br /&gt;
# Print output&lt;br /&gt;
print(point_Ijk)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Get markup fiducial RAS coordinates from volume voxel coordinates ==&lt;br /&gt;
&lt;br /&gt;
This example shows how to get position of maximum intensity voxel of a volume (determined by numpy, in IJK coordinates) in RAS coordinates so that it can be marked with a markup fiducial.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Inputs&lt;br /&gt;
volumeNode = getNode('MRHead')&lt;br /&gt;
markupsNode = getNode('F')&lt;br /&gt;
&lt;br /&gt;
# Get voxel position in IJK coordinate system&lt;br /&gt;
import numpy as np&lt;br /&gt;
volumeArray = slicer.util.arrayFromVolume(volumeNode)&lt;br /&gt;
# Get position of highest voxel value&lt;br /&gt;
point_Kji = np.where(volumeArray == volumeArray.max())&lt;br /&gt;
point_Ijk = [point_Kji[2][0], point_Kji[1][0], point_Kji[0][0]]&lt;br /&gt;
&lt;br /&gt;
# Get physical coordinates from voxel coordinates&lt;br /&gt;
volumeIjkToRas = vtk.vtkMatrix4x4()&lt;br /&gt;
volumeNode.GetIJKToRASMatrix(volumeIjkToRas)&lt;br /&gt;
point_VolumeRas = [0, 0, 0, 1]&lt;br /&gt;
volumeIjkToRas.MultiplyPoint(np.append(point_Ijk,1.0), point_VolumeRas)&lt;br /&gt;
&lt;br /&gt;
# If volume node is transformed, apply that transform to get volume's RAS coordinates&lt;br /&gt;
transformVolumeRasToRas = vtk.vtkGeneralTransform()&lt;br /&gt;
slicer.vtkMRMLTransformNode.GetTransformBetweenNodes(volumeNode.GetParentTransformNode(), None, transformVolumeRasToRas)&lt;br /&gt;
point_Ras = transformVolumeRasToRas.TransformPoint(point_VolumeRas[0:3])&lt;br /&gt;
&lt;br /&gt;
# Add a markup at the computed position and print its coordinates&lt;br /&gt;
markupsNode.AddFiducial(point_Ras[0], point_Ras[1], point_Ras[2], &amp;quot;max&amp;quot;)&lt;br /&gt;
print(point_Ras)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Get the values of all voxels for a label value  ==&lt;br /&gt;
&lt;br /&gt;
If you have a background image called ‘Volume’ and a mask called ‘Volume-label’ created with the Editor you could do something like this:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
import numpy&lt;br /&gt;
volume = array(‘Volume’)&lt;br /&gt;
label = array(‘Volume-label’)&lt;br /&gt;
points  = numpy.where( label == 1 )  # or use another label number depending on what you segmented&lt;br /&gt;
values  = volume[points] # this will be a list of the label values&lt;br /&gt;
values.mean() # should match the mean value of LabelStatistics calculation as a double-check&lt;br /&gt;
numpy.savetxt(‘values.txt’, values)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Access values in a DTI tensor volume ==&lt;br /&gt;
This example shows how to access individual tensors at the voxel level.&lt;br /&gt;
&lt;br /&gt;
First load your DWI volume and estimate tensors to produce a DTI volume called ‘Output DTI Volume’&lt;br /&gt;
&lt;br /&gt;
Then open the python window: View-&amp;gt;Python interactor&lt;br /&gt;
&lt;br /&gt;
Use this command to access tensors through numpy:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
tensors = array('Output DTI Volume')&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Type the following code into the Python window to access all tensor components using vtk commands:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
volumeNode=slicer.util.getNode('Output DTI Volume')&lt;br /&gt;
imageData=volumeNode.GetImageData()&lt;br /&gt;
tensors = imageData.GetPointData().GetTensors()&lt;br /&gt;
extent = imageData.GetExtent()&lt;br /&gt;
idx = 0&lt;br /&gt;
for k in xrange(extent[4], extent[5]+1):&lt;br /&gt;
  for j in xrange(extent[2], extent[3]+1):&lt;br /&gt;
    for i in xrange(extent[0], extent[1]+1):&lt;br /&gt;
      tensors.GetTuple9(idx)&lt;br /&gt;
      idx += 1&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Change window/level (brightness/contrast) or colormap of a volume ==&lt;br /&gt;
This example shows how to change window/level of the MRHead sample volume.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
volumeNode = getNode('MRHead')&lt;br /&gt;
displayNode = volumeNode.GetDisplayNode()&lt;br /&gt;
displayNode.AutoWindowLevelOff()&lt;br /&gt;
displayNode.SetWindow(50)&lt;br /&gt;
displayNode.SetLevel(100)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Change color mapping from grayscale to rainbow:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
displayNode.SetAndObserveColorNodeID('vtkMRMLColorTableNodeRainbow')&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Create custom color table ==&lt;br /&gt;
This example shows how to create a new color table, for example with inverted color range from the default Ocean color table.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
ocean = getNode(&amp;quot;Ocean&amp;quot;)&lt;br /&gt;
invertedocean = slicer.vtkMRMLColorTableNode()&lt;br /&gt;
invertedocean.CopyWithScene(ocean)&lt;br /&gt;
invertedocean.SetTypeToUser()&lt;br /&gt;
invertedocean.SetNumberOfColors(256)&lt;br /&gt;
invertedocean.SetName(&amp;quot;InvertedOcean&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
for i in range(0,255):&lt;br /&gt;
    invertedocean.SetColor(i, 0.0, 1 - (i+1e-16)/255.0, 1.0, 1.0)&lt;br /&gt;
&lt;br /&gt;
slicer.mrmlScene.AddNode(invertedocean)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Manipulate a Slice View ==&lt;br /&gt;
&lt;br /&gt;
=== Change the slice offset ===&lt;br /&gt;
&lt;br /&gt;
Equivalent to moving the slider in slice view controller.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
layoutManager = slicer.app.layoutManager()&lt;br /&gt;
red = layoutManager.sliceWidget('Red')&lt;br /&gt;
redLogic = red.sliceLogic()&lt;br /&gt;
# Print current slice offset position&lt;br /&gt;
print redLogic.GetSliceOffset()&lt;br /&gt;
# Change slice position&lt;br /&gt;
redLogic.SetSliceOffset(20)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Show slice views in 3D window ===&lt;br /&gt;
&lt;br /&gt;
Equivalent to clicking 'eye' icon in the slice view controller.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
layoutManager = slicer.app.layoutManager()&lt;br /&gt;
for sliceViewName in layoutManager.sliceViewNames():&lt;br /&gt;
  controller = layoutManager.sliceWidget(sliceViewName).sliceController()&lt;br /&gt;
  controller.setSliceVisible(True)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Reset field of view to show background volume maximized ===&lt;br /&gt;
&lt;br /&gt;
Equivalent to click small rectangle button (&amp;quot;Adjust the slice viewer's field of view...&amp;quot;) in the slice view controller.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
slicer.util.resetSliceViews()&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Rotate slice views to volume plane ===&lt;br /&gt;
&lt;br /&gt;
Aligns slice views to volume axes, shows original image acquisition planes in slice views.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
volumeNode = slicer.util.getNode('MRHead')&lt;br /&gt;
layoutManager = slicer.app.layoutManager()&lt;br /&gt;
for sliceViewName in layoutManager.sliceViewNames():&lt;br /&gt;
  layoutManager.sliceWidget(sliceViewName).mrmlSliceNode().RotateToVolumePlane(volumeNode)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Iterate over current visible slice views, and set foreground and background images ===&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
for sliceViewName in layoutManager.sliceViewNames():&lt;br /&gt;
     sliceWidget = layoutManager.sliceWidget(sliceViewName)&lt;br /&gt;
     &lt;br /&gt;
     # setup background volume&lt;br /&gt;
     compositeNode.SetBackgroundVolumeID(MRVolume.GetID())&lt;br /&gt;
     # setup foreground volume&lt;br /&gt;
     compositeNode.SetForegroundVolumeID(CTVolume.GetID())&lt;br /&gt;
     # change opacity&lt;br /&gt;
     compositeNode.SetForegroundOpacity(0.3)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Show a volume in slice views ==&lt;br /&gt;
&lt;br /&gt;
Recommended:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
volumeNode = slicer.util.getNode('YourVolumeNode')&lt;br /&gt;
slicer.util.setSliceViewerLayers(background=volumeNode)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
or&lt;br /&gt;
&lt;br /&gt;
Show volume in all visible views where volume selection propagation is enabled:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
volumeNode = slicer.util.getNode('YourVolumeNode')&lt;br /&gt;
applicationLogic = slicer.app.applicationLogic()&lt;br /&gt;
selectionNode = applicationLogic.GetSelectionNode()&lt;br /&gt;
selectionNode.SetSecondaryVolumeID(volumeNode.GetID())&lt;br /&gt;
applicationLogic.PropagateForegroundVolumeSelection(0) &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
or&lt;br /&gt;
&lt;br /&gt;
Show volume in selected views:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
n =  slicer.util.getNode('YourVolumeNode')&lt;br /&gt;
for color in ['Red', 'Yellow', 'Green']:&lt;br /&gt;
    slicer.app.layoutManager().sliceWidget(color).sliceLogic().GetSliceCompositeNode().SetForegroundVolumeID(n.GetID())&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Change opacity of foreground volume in slice views ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
slicer.util.setSliceViewerLayers(foregroundOpacity=0.4)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
or&lt;br /&gt;
&lt;br /&gt;
Change opacity in a selected view&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
lm = slicer.app.layoutManager()&lt;br /&gt;
sliceLogic = lm.sliceWidget('Red').sliceLogic()&lt;br /&gt;
compositeNode = sliceLogic.GetSliceCompositeNode()&lt;br /&gt;
compositeNode.SetForegroundOpacity(0.4)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Fit slice plane to markup fiducials ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sliceNode = slicer.mrmlScene.GetNodeByID(&amp;quot;vtkMRMLSliceNodeRed&amp;quot;)&lt;br /&gt;
markupsNode = slicer.mrmlScene.GetFirstNodeByName(&amp;quot;F&amp;quot;)&lt;br /&gt;
# Get markup point positions as numpy arrays&lt;br /&gt;
import numpy as np&lt;br /&gt;
p1 = np.array([0,0,0])&lt;br /&gt;
p2 = np.array([0,0,0])&lt;br /&gt;
p3 = np.array([0,0,0])&lt;br /&gt;
markupsNode.GetNthFiducialPosition(0, p1)&lt;br /&gt;
markupsNode.GetNthFiducialPosition(1, p2)&lt;br /&gt;
markupsNode.GetNthFiducialPosition(2, p3)&lt;br /&gt;
# Get plane axis directions&lt;br /&gt;
n = np.cross(p2-p1, p2-p3) # plane normal direction&lt;br /&gt;
n = n/np.linalg.norm(n)&lt;br /&gt;
t = np.cross([0, 0, 1], n) # plane transverse direction&lt;br /&gt;
t = t/np.linalg.norm(t)&lt;br /&gt;
# Set slice plane orientation and position&lt;br /&gt;
sliceNode.SetSliceToRASByNTP(n[0], n[1], n[2], t[0], t[1], t[2], p1[0], p1[1], p1[2], 0)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Save a series of images from a Slice View ==&lt;br /&gt;
&lt;br /&gt;
You can use ScreenCapture module to capture series of images. To do it programmatically, save the following into a file such as '/tmp/record.py' and then in the slicer python console type &amp;quot;execfile('/tmp/record.py')&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
layoutName = 'Green'&lt;br /&gt;
imagePathPattern = '/tmp/image-%03d.png'&lt;br /&gt;
steps = 10&lt;br /&gt;
&lt;br /&gt;
widget = slicer.app.layoutManager().sliceWidget(layoutName)&lt;br /&gt;
view = widget.sliceView()&lt;br /&gt;
logic = widget.sliceLogic()&lt;br /&gt;
bounds = [0,]*6&lt;br /&gt;
logic.GetSliceBounds(bounds)&lt;br /&gt;
&lt;br /&gt;
for step in range(steps):&lt;br /&gt;
    offset = bounds[4] + step/(1.*steps) * (bounds[5]-bounds[4])&lt;br /&gt;
    logic.SetSliceOffset(offset)&lt;br /&gt;
    view.forceRender()&lt;br /&gt;
    image = qt.QPixmap.grabWidget(view).toImage()&lt;br /&gt;
    image.save(imagePathPattern % step)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Save the scene into a new directory ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Create a new directory where the scene will be saved into&lt;br /&gt;
import time&lt;br /&gt;
sceneSaveDirectory = slicer.app.temporaryPath + &amp;quot;/saved-scene-&amp;quot; + time.strftime(&amp;quot;%Y%m%d-%H%M%S&amp;quot;)&lt;br /&gt;
if not os.access(sceneSaveDirectory, os.F_OK):&lt;br /&gt;
  os.makedirs(sceneSaveDirectory)&lt;br /&gt;
&lt;br /&gt;
# Save the scene&lt;br /&gt;
if slicer.app.applicationLogic().SaveSceneToSlicerDataBundleDirectory(sceneSaveDirectory, None):&lt;br /&gt;
  logging.info(&amp;quot;Scene saved to: {0}&amp;quot;.format(sceneSaveDirectory))&lt;br /&gt;
else:&lt;br /&gt;
  logging.error(&amp;quot;Scene saving failed&amp;quot;) &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Save the scene into a single MRB file ==&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Generate file name&lt;br /&gt;
import time&lt;br /&gt;
sceneSaveFilename = slicer.app.temporaryPath + &amp;quot;/saved-scene-&amp;quot; + time.strftime(&amp;quot;%Y%m%d-%H%M%S&amp;quot;) + &amp;quot;.mrb&amp;quot;&lt;br /&gt;
&lt;br /&gt;
# Save scene&lt;br /&gt;
if slicer.util.saveScene(sceneSaveFilename):&lt;br /&gt;
  logging.info(&amp;quot;Scene saved to: {0}&amp;quot;.format(sceneSaveFilename))&lt;br /&gt;
else:&lt;br /&gt;
  logging.error(&amp;quot;Scene saving failed&amp;quot;) &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Save a node to file ==&lt;br /&gt;
&lt;br /&gt;
Save a transform node to file (should work with any other node type, if file extension is set to a supported one):&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
myNode = getNode(&amp;quot;LinearTransform_3&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
myStorageNode = myNode.CreateDefaultStorageNode()&lt;br /&gt;
myStorageNode.SetFileName(&amp;quot;c:/tmp/something.tfm&amp;quot;)&lt;br /&gt;
myStorageNode.WriteData(myNode)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Center the 3D View on the Scene ==&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
layoutManager = slicer.app.layoutManager()&lt;br /&gt;
threeDWidget = layoutManager.threeDWidget(0)&lt;br /&gt;
threeDView = threeDWidget.threeDView()&lt;br /&gt;
threeDView.resetFocalPoint()&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Rotate the 3D View==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
layoutManager = slicer.app.layoutManager()&lt;br /&gt;
threeDWidget = layoutManager.threeDWidget(0)&lt;br /&gt;
threeDView = threeDWidget.threeDView()&lt;br /&gt;
threeDView.yaw()&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Display text in a 3D view or slice view ==&lt;br /&gt;
&lt;br /&gt;
The easiest way to show information overlaid on a viewer is to use corner annotations.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
view=slicer.app.layoutManager().threeDWidget(0).threeDView()&lt;br /&gt;
# Set text to &amp;quot;Something&amp;quot;&lt;br /&gt;
view.cornerAnnotation().SetText(vtk.vtkCornerAnnotation.UpperRight,&amp;quot;Something&amp;quot;)&lt;br /&gt;
# Set color to red&lt;br /&gt;
view.cornerAnnotation().GetTextProperty().SetColor(1,0,0)&lt;br /&gt;
# Update the view&lt;br /&gt;
view.forceRender()&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Hide slice view annotations (DataProbe) ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Disable slice annotations immediately&lt;br /&gt;
slicer.modules.DataProbeInstance.infoWidget.sliceAnnotations.sliceViewAnnotationsEnabled=False&lt;br /&gt;
slicer.modules.DataProbeInstance.infoWidget.sliceAnnotations.updateSliceViewFromGUI()&lt;br /&gt;
# Disable slice annotations persistently (after Slicer restarts)&lt;br /&gt;
settings = qt.QSettings()&lt;br /&gt;
settings.setValue('DataProbe/sliceViewAnnotations.enabled', 0)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Turning off interpolation ==&lt;br /&gt;
&lt;br /&gt;
You can turn off interpolation for newly loaded volumes with this script from Steve Pieper.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
def NoInterpolate(caller,event):&lt;br /&gt;
  for node in slicer.util.getNodes('*').values():&lt;br /&gt;
    if node.IsA('vtkMRMLScalarVolumeDisplayNode'):&lt;br /&gt;
      node.SetInterpolate(0)&lt;br /&gt;
	&lt;br /&gt;
slicer.mrmlScene.AddObserver(slicer.mrmlScene.NodeAddedEvent, NoInterpolate)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The below link explains how to put this in your startup script.&lt;br /&gt;
&lt;br /&gt;
http://www.na-mic.org/Wiki/index.php/AHM2012-Slicer-Python#Refining_the_code_and_UI_with_slicerrc&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Customize viewer layout ==&lt;br /&gt;
&lt;br /&gt;
Show a custom layout of a 3D view on top of the red slice view:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
customLayout = (&amp;quot;&amp;lt;layout type=\&amp;quot;vertical\&amp;quot; split=\&amp;quot;true\&amp;quot; &amp;gt;&amp;quot;&lt;br /&gt;
  &amp;quot; &amp;lt;item&amp;gt;&amp;quot;&lt;br /&gt;
  &amp;quot;  &amp;lt;view class=\&amp;quot;vtkMRMLViewNode\&amp;quot; singletontag=\&amp;quot;1\&amp;quot;&amp;gt;&amp;quot;&lt;br /&gt;
  &amp;quot;    &amp;lt;property name=\&amp;quot;viewlabel\&amp;quot; action=\&amp;quot;default\&amp;quot;&amp;gt;1&amp;lt;/property&amp;gt;&amp;quot;&lt;br /&gt;
  &amp;quot;  &amp;lt;/view&amp;gt;&amp;quot;&lt;br /&gt;
  &amp;quot; &amp;lt;/item&amp;gt;&amp;quot;&lt;br /&gt;
  &amp;quot; &amp;lt;item&amp;gt;&amp;quot;&lt;br /&gt;
  &amp;quot;  &amp;lt;view class=\&amp;quot;vtkMRMLSliceNode\&amp;quot; singletontag=\&amp;quot;Red\&amp;quot;&amp;gt;&amp;quot;&lt;br /&gt;
  &amp;quot;   &amp;lt;property name=\&amp;quot;orientation\&amp;quot; action=\&amp;quot;default\&amp;quot;&amp;gt;Axial&amp;lt;/property&amp;gt;&amp;quot;&lt;br /&gt;
  &amp;quot;   &amp;lt;property name=\&amp;quot;viewlabel\&amp;quot; action=\&amp;quot;default\&amp;quot;&amp;gt;R&amp;lt;/property&amp;gt;&amp;quot;&lt;br /&gt;
  &amp;quot;   &amp;lt;property name=\&amp;quot;viewcolor\&amp;quot; action=\&amp;quot;default\&amp;quot;&amp;gt;#F34A33&amp;lt;/property&amp;gt;&amp;quot;&lt;br /&gt;
  &amp;quot;  &amp;lt;/view&amp;gt;&amp;quot;&lt;br /&gt;
  &amp;quot; &amp;lt;/item&amp;gt;&amp;quot;&lt;br /&gt;
  &amp;quot;&amp;lt;/layout&amp;gt;&amp;quot;)&lt;br /&gt;
  &lt;br /&gt;
customLayoutId=501&lt;br /&gt;
&lt;br /&gt;
layoutManager = slicer.app.layoutManager()&lt;br /&gt;
layoutManager.layoutLogic().GetLayoutNode().AddLayoutDescription(customLayoutId, customLayout)                                         &lt;br /&gt;
layoutManager.setLayout(customLayoutId)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
See description of standard layouts (that can be used as examples) here:&lt;br /&gt;
https://github.com/Slicer/Slicer/blob/master/Libs/MRML/Logic/vtkMRMLLayoutLogic.cxx&lt;br /&gt;
&lt;br /&gt;
== Customize keyboard shortcuts ==&lt;br /&gt;
&lt;br /&gt;
Keyboard shortcuts can be specified for activating any Slicer feature by adding a couple of lines to your &lt;br /&gt;
[[Documentation/{{documentation/version}}/Developers/Python_scripting#How_to_systematically_execute_custom_python_code_at_startup_.3F|.slicerrc file]].&lt;br /&gt;
&lt;br /&gt;
For example, this script registers ''Ctrl+b'', ''Ctrl+n'', ''Ctrl+m'', ''Ctrl+,'' keyboard shortcuts to switch between red, yellow, green, and 4-up view layouts.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
shortcuts = [&lt;br /&gt;
    ('Ctrl+b', lambda: slicer.app.layoutManager().setLayout(slicer.vtkMRMLLayoutNode.SlicerLayoutOneUpRedSliceView)),&lt;br /&gt;
    ('Ctrl+n', lambda: slicer.app.layoutManager().setLayout(slicer.vtkMRMLLayoutNode.SlicerLayoutOneUpYellowSliceView)),&lt;br /&gt;
    ('Ctrl+m', lambda: slicer.app.layoutManager().setLayout(slicer.vtkMRMLLayoutNode.SlicerLayoutOneUpGreenSliceView)),&lt;br /&gt;
    ('Ctrl+,', lambda: slicer.app.layoutManager().setLayout(slicer.vtkMRMLLayoutNode.SlicerLayoutFourUpView))&lt;br /&gt;
    ]&lt;br /&gt;
&lt;br /&gt;
for (shortcutKey, callback) in shortcuts:&lt;br /&gt;
    shortcut = qt.QShortcut(slicer.util.mainWindow())&lt;br /&gt;
    shortcut.setKey(qt.QKeySequence(shortcutKey))&lt;br /&gt;
    shortcut.connect( 'activated()', callback)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Disable certain user interactions in slice views ==&lt;br /&gt;
&lt;br /&gt;
For example, disable slice browsing using mouse wheel and keyboard shortcuts in the red slice viewer:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
interactorStyle = slicer.app.layoutManager().sliceWidget('Red').sliceView().sliceViewInteractorStyle()&lt;br /&gt;
interactorStyle.SetActionEnabled(interactorStyle.BrowseSlice, False)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Hide all slice view controllers:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
lm = slicer.app.layoutManager()&lt;br /&gt;
for sliceViewName in lm.sliceViewNames():&lt;br /&gt;
  lm.sliceWidget(sliceViewName).sliceController().setVisible(False)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Hide all 3D view controllers:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
lm = slicer.app.layoutManager()&lt;br /&gt;
for viewIndex in range(slicer.app.layoutManager().threeDViewCount):&lt;br /&gt;
  lm.threeDWidget(0).threeDController().setVisible(False)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Change default slice view orientation ==&lt;br /&gt;
&lt;br /&gt;
You can left-right &amp;quot;flip&amp;quot; slice view orientation presets (show patient left side on left/right side of the screen) by copy-pasting the script below to your [[Documentation/{{documentation/version}}/Developers/FAQ/Python_Scripting#How_to_systematically_execute_custom_python_code_at_startup_.3F| .slicerrc.py file]].&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Axial slice axes:&lt;br /&gt;
#  1 0 0&lt;br /&gt;
#  0 1 0&lt;br /&gt;
#  0 0 1&lt;br /&gt;
axialSliceToRas=vtk.vtkMatrix3x3()&lt;br /&gt;
&lt;br /&gt;
# Coronal slice axes:&lt;br /&gt;
#  1 0 0 &lt;br /&gt;
#  0 0 -1&lt;br /&gt;
#  0 1 0&lt;br /&gt;
coronalSliceToRas=vtk.vtkMatrix3x3()&lt;br /&gt;
coronalSliceToRas.SetElement(1,1, 0)&lt;br /&gt;
coronalSliceToRas.SetElement(1,2, -1)&lt;br /&gt;
coronalSliceToRas.SetElement(2,1, 1)&lt;br /&gt;
coronalSliceToRas.SetElement(2,2, 0)&lt;br /&gt;
&lt;br /&gt;
# Replace orientation presets in all existing slice nodes and in the default slice node&lt;br /&gt;
sliceNodes = slicer.util.getNodesByClass('vtkMRMLSliceNode')&lt;br /&gt;
sliceNodes.append(slicer.mrmlScene.GetDefaultNodeByClass('vtkMRMLSliceNode'))&lt;br /&gt;
for sliceNode in sliceNodes:&lt;br /&gt;
  orientationPresetName = sliceNode.GetOrientation()&lt;br /&gt;
  sliceNode.RemoveSliceOrientationPreset(&amp;quot;Axial&amp;quot;)&lt;br /&gt;
  sliceNode.AddSliceOrientationPreset(&amp;quot;Axial&amp;quot;, axialSliceToRas)&lt;br /&gt;
  sliceNode.RemoveSliceOrientationPreset(&amp;quot;Coronal&amp;quot;)&lt;br /&gt;
  sliceNode.AddSliceOrientationPreset(&amp;quot;Coronal&amp;quot;, coronalSliceToRas)&lt;br /&gt;
  sliceNode.SetOrientation(orientationPresetName)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Set all slice views linked by default ==&lt;br /&gt;
&lt;br /&gt;
You can make slice views linked by default (when application starts or the scene is cleared) by copy-pasting the script below to your [[Documentation/{{documentation/version}}/Developers/FAQ/Python_Scripting#How_to_systematically_execute_custom_python_code_at_startup_.3F| .slicerrc.py file]].&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Set linked slice views  in all existing slice composite nodes and in the default node&lt;br /&gt;
sliceCompositeNodes = slicer.util.getNodesByClass('vtkMRMLSliceCompositeNode')&lt;br /&gt;
defaultSliceCompositeNode = slicer.mrmlScene.GetDefaultNodeByClass('vtkMRMLSliceCompositeNode')&lt;br /&gt;
if not defaultSliceCompositeNode:&lt;br /&gt;
  defaultSliceCompositeNode = slicer.mrmlScene.CreateNodeByClass('vtkMRMLSliceCompositeNode')&lt;br /&gt;
  slicer.mrmlScene.AddDefaultNode(defaultSliceCompositeNode)&lt;br /&gt;
sliceCompositeNodes.append(defaultSliceCompositeNode)&lt;br /&gt;
for sliceCompositeNode in sliceCompositeNodes:&lt;br /&gt;
  sliceCompositeNode.SetLinkedControl(True)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Set up custom units in slice view ruler ==&lt;br /&gt;
&lt;br /&gt;
For microscopy or micro-CT images you may want to switch unit to micrometer instead of the default mm. To do that, 1. change the unit in Application settings / Units and 2. update ruler display settings using the script below (it can be copied to your Application startup script):&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
lm = slicer.app.layoutManager()&lt;br /&gt;
for sliceViewName in lm.sliceViewNames():&lt;br /&gt;
  sliceView = lm.sliceWidget(sliceViewName).sliceView()&lt;br /&gt;
  displayableManagerCollection = vtk.vtkCollection()&lt;br /&gt;
  sliceView.getDisplayableManagers(displayableManagerCollection)&lt;br /&gt;
  for dmIndex in xrange(displayableManagerCollection.GetNumberOfItems()):&lt;br /&gt;
    displayableManager = displayableManagerCollection.GetItemAsObject(dmIndex)&lt;br /&gt;
    if not displayableManager.IsA(&amp;quot;vtkMRMLRulerDisplayableManager&amp;quot;):&lt;br /&gt;
      continue&lt;br /&gt;
    displayableManager.RemoveAllRulerScalePresets()&lt;br /&gt;
    displayableManager.AddRulerScalePreset(   0.001, 5, 2, &amp;quot;nm&amp;quot;, 1000.0)&lt;br /&gt;
    displayableManager.AddRulerScalePreset(   0.010, 5, 2, &amp;quot;nm&amp;quot;, 1000.0)&lt;br /&gt;
    displayableManager.AddRulerScalePreset(   0.100, 5, 2, &amp;quot;nm&amp;quot;, 1000.0)&lt;br /&gt;
    displayableManager.AddRulerScalePreset(   0.500, 5, 1, &amp;quot;nm&amp;quot;, 1000.0)&lt;br /&gt;
    displayableManager.AddRulerScalePreset(   1.0,   5, 2, &amp;quot;um&amp;quot;,    1.0)&lt;br /&gt;
    displayableManager.AddRulerScalePreset(   5.0,   5, 1, &amp;quot;um&amp;quot;,    1.0)&lt;br /&gt;
    displayableManager.AddRulerScalePreset(  10.0,   5, 2, &amp;quot;um&amp;quot;,    1.0)&lt;br /&gt;
    displayableManager.AddRulerScalePreset(  50.0,   5, 1, &amp;quot;um&amp;quot;,    1.0)&lt;br /&gt;
    displayableManager.AddRulerScalePreset( 100.0,   5, 2, &amp;quot;um&amp;quot;,    1.0)&lt;br /&gt;
    displayableManager.AddRulerScalePreset( 500.0,   5, 1, &amp;quot;um&amp;quot;,    1.0)&lt;br /&gt;
    displayableManager.AddRulerScalePreset(1000.0,   5, 2, &amp;quot;mm&amp;quot;,    0.001)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Show a slice view outside the view layout ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sliceLayoutName = &amp;quot;TestSlice&amp;quot;&lt;br /&gt;
sliceLayoutLabel = &amp;quot;T&amp;quot;&lt;br /&gt;
# ownerNode manages this view instead of the layout manager (it can be any node in the scene)&lt;br /&gt;
viewOwnerNode = slicer.mrmlScene.AddNewNodeByClass(&amp;quot;vtkMRMLScriptedModuleNode&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
# Create MRML nodes&lt;br /&gt;
sliceNode = slicer.vtkMRMLSliceNode()&lt;br /&gt;
sliceNode.SetName(sliceLayoutName)&lt;br /&gt;
sliceNode.SetLayoutName(sliceLayoutName)&lt;br /&gt;
sliceNode.SetLayoutLabel(sliceLayoutLabel)&lt;br /&gt;
sliceNode.SetLayoutColor(1, 1, 0)&lt;br /&gt;
sliceNode.SetAndObserveParentLayoutNodeID(viewOwnerNode.GetID())&lt;br /&gt;
sliceNode = slicer.mrmlScene.AddNode(sliceNode)&lt;br /&gt;
sliceCompositeNode = slicer.mrmlScene.AddNewNodeByClass(&amp;quot;vtkMRMLSliceCompositeNode&amp;quot;)&lt;br /&gt;
sliceCompositeNode.SetLayoutName(sliceLayoutName)&lt;br /&gt;
&lt;br /&gt;
# Create widget&lt;br /&gt;
sliceWidget = slicer.qMRMLSliceWidget()&lt;br /&gt;
sliceWidget.sliceViewName = sliceLayoutName&lt;br /&gt;
sliceWidget.sliceViewLabel = sliceLayoutLabel&lt;br /&gt;
c = sliceNode.GetLayoutColor()&lt;br /&gt;
sliceWidget.sliceViewColor = qt.QColor.fromRgbF(c[0],c[1],c[2])&lt;br /&gt;
sliceWidget.setMRMLScene(slicer.mrmlScene)&lt;br /&gt;
sliceWidget.setMRMLSliceNode(sliceNode)&lt;br /&gt;
sliceWidget.show()&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Running an ITK filter in Python using SimpleITK ==&lt;br /&gt;
Open the &amp;quot;Sample Data&amp;quot; module and download &amp;quot;MR Head&amp;quot;, then paste the following snippet in Python interactor:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
import SimpleITK as sitk&lt;br /&gt;
import sitkUtils&lt;br /&gt;
inputImage = sitkUtils.PullFromSlicer('MRHead')&lt;br /&gt;
filter = sitk.SignedMaurerDistanceMapImageFilter()&lt;br /&gt;
outputImage = filter.Execute(inputImage)&lt;br /&gt;
sitkUtils.PushToSlicer(outputImage,'outputImage')&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
More information:&lt;br /&gt;
* See the SimpleITK documentation for SimpleITK examples: http://www.itk.org/SimpleITKDoxygen/html/examples.html&lt;br /&gt;
* sitkUtils in Slicer is used for pushing and pulling images from Slicer to SimpleITK: https://github.com/Slicer/Slicer/blob/master/Base/Python/sitkUtils.py&lt;br /&gt;
&lt;br /&gt;
== Get current mouse coordinates in a slice view ==&lt;br /&gt;
&lt;br /&gt;
You can get 3D (RAS) coordinates of the current mouse cursor from the crosshair singleton node as shown in the example below:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
def onMouseMoved(observer,eventid):  &lt;br /&gt;
  ras=[0,0,0]&lt;br /&gt;
  crosshairNode.GetCursorPositionRAS(ras)&lt;br /&gt;
  print(ras)&lt;br /&gt;
&lt;br /&gt;
crosshairNode=slicer.util.getNode('Crosshair') &lt;br /&gt;
crosshairNode.AddObserver(slicer.vtkMRMLCrosshairNode.CursorPositionModifiedEvent, onMouseMoved)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Get DataProbe text ==&lt;br /&gt;
&lt;br /&gt;
You can get the mouse location in pixel coordinates along with the pixel value at the mouse by hitting the '.' (period) key in a slice view after pasting in the following code.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
def printDataProbe():&lt;br /&gt;
  infoWidget = slicer.modules.DataProbeInstance.infoWidget&lt;br /&gt;
  for layer in ('B', 'F', 'L'):&lt;br /&gt;
    print(infoWidget.layerNames[layer].text, infoWidget.layerIJKs[layer].text, infoWidget.layerValues[layer].text)&lt;br /&gt;
&lt;br /&gt;
s = qt.QShortcut(qt.QKeySequence('.'), mainWindow())&lt;br /&gt;
s.connect('activated()', printDataProbe)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Thick slab reconstruction and maximum/minimum intensity volume projections ==&lt;br /&gt;
&lt;br /&gt;
Set up 'red' slice viewer to show thick slab reconstructed from 3 slices:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sliceNode = slicer.mrmlScene.GetNodeByID('vtkMRMLSliceNodeRed')&lt;br /&gt;
appLogic = slicer.app.applicationLogic()&lt;br /&gt;
sliceLogic = appLogic.GetSliceLogic(sliceNode)&lt;br /&gt;
sliceLayerLogic = sliceLogic.GetBackgroundLayer()&lt;br /&gt;
reslice = sliceLayerLogic.GetReslice()&lt;br /&gt;
reslice.SetSlabModeToMean()&lt;br /&gt;
reslice.SetSlabNumberOfSlices(10) # mean of 10 slices will computed&lt;br /&gt;
reslice.SetSlabSliceSpacingFraction(0.3) # spacing between each slice is 0.3 pixel (total 10 * 0.3 = 3 pixel neighborhood)&lt;br /&gt;
sliceNode.Modified()&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Set up 'red' slice viewer to show maximum intensity projection (MIP):&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sliceNode = slicer.mrmlScene.GetNodeByID('vtkMRMLSliceNodeRed')&lt;br /&gt;
appLogic = slicer.app.applicationLogic()&lt;br /&gt;
sliceLogic = appLogic.GetSliceLogic(sliceNode)&lt;br /&gt;
sliceLayerLogic = sliceLogic.GetBackgroundLayer()&lt;br /&gt;
reslice = sliceLayerLogic.GetReslice()&lt;br /&gt;
reslice.SetSlabModeToMax()&lt;br /&gt;
reslice.SetSlabNumberOfSlices(600) # use a large number of slices (600) to cover the entire volume&lt;br /&gt;
reslice.SetSlabSliceSpacingFraction(0.5) # spacing between slices are 0.5 pixel (supersampling is useful to reduce interpolation artifacts)&lt;br /&gt;
sliceNode.Modified()&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The projected image is available in a ''vtkImageData'' object by calling ''reslice.GetOutput()''.&lt;br /&gt;
&lt;br /&gt;
== Change default file type for nodes (that have never been saved yet) ==&lt;br /&gt;
Default node can be specified that will be used as a basis of all new storage nodes. This can be used for setting default file extension. For example, change file format to STL for model nodes:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
defaultModelStorageNode = slicer.vtkMRMLModelStorageNode()&lt;br /&gt;
defaultModelStorageNode.SetDefaultWriteFileExtension('stl')&lt;br /&gt;
slicer.mrmlScene.AddDefaultNode(defaultModelStorageNode)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To permanently change default file extension on your computer, copy-paste the code above into your application startup script (you can find its location in menu: Edit / Application settings / General / Application startup script).&lt;br /&gt;
&lt;br /&gt;
== Change file type for saving for all volumes (with already existing storage nodes) ==&lt;br /&gt;
&lt;br /&gt;
If it is not necessary to preserve file paths then the simplest is to configure default storage node (as shown in the example above), then delete all existing storage nodes. When save dialog is opened, default storage nodes will be recreated.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Delete existing model storage nodes so that they will be recreated with default settings&lt;br /&gt;
existingModelStorageNodes = slicer.util.getNodesByClass('vtkMRMLModelStorageNode')&lt;br /&gt;
for modelStorageNode in existingModelStorageNodes:&lt;br /&gt;
  slicer.mrmlScene.RemoveNode(modelStorageNode)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To update existing storage nodes to use new file extension (but keep all other parameters unchanged) you can use this approach (example is for volume storage):&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
requiredFileExtension = '.nia'&lt;br /&gt;
originalFileExtension = '.nrrd'&lt;br /&gt;
volumeNodes = slicer.util.getNodesByClass('vtkMRMLScalarVolumeNode')&lt;br /&gt;
for volumeNode in volumeNodes:&lt;br /&gt;
  volumeStorageNode = volumeNode.GetStorageNode()&lt;br /&gt;
  if not volumeStorageNode:&lt;br /&gt;
    volumeNode.AddDefaultStorageNode()&lt;br /&gt;
    volumeStorageNode = volumeNode.GetStorageNode()&lt;br /&gt;
    volumeStorageNode.SetFileName(volumeNode.GetName()+requiredFileExtension)&lt;br /&gt;
  else:&lt;br /&gt;
    volumeStorageNode.SetFileName(volumeStorageNode.GetFileName().replace(originalFileExtension, requiredFileExtension))&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To set all volume nodes to save uncompressed by default (add this to .slicerrc.py so it takes effect for the whole session):&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#set the default volume storage to not compress by default&lt;br /&gt;
defaultVolumeStorageNode = slicer.vtkMRMLVolumeArchetypeStorageNode()&lt;br /&gt;
defaultVolumeStorageNode.SetUseCompression(0)&lt;br /&gt;
slicer.mrmlScene.AddDefaultNode(defaultVolumeStorageNode)&lt;br /&gt;
logging.info(&amp;quot;Volume nodes will be stored uncompressed by default&amp;quot;)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Same thing as above, but applied to all  segmentations instead of volumes:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#set the default volume storage to not compress by default&lt;br /&gt;
defaultVolumeStorageNode = slicer.vtkMRMLSegmentationStorageNode()&lt;br /&gt;
defaultVolumeStorageNode.SetUseCompression(0)&lt;br /&gt;
slicer.mrmlScene.AddDefaultNode(defaultVolumeStorageNode)&lt;br /&gt;
logging.info(&amp;quot;Segmentation nodes will be stored uncompressed &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Segmentations ==&lt;br /&gt;
&lt;br /&gt;
=== Create a segmentation from a labelmap volume and display in 3D ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
labelmapVolumeNode = getNode('label')&lt;br /&gt;
seg = slicer.mrmlScene.AddNewNodeByClass('vtkMRMLSegmentationNode')&lt;br /&gt;
slicer.modules.segmentations.logic().ImportLabelmapToSegmentationNode(labelmapVolumeNode, seg)&lt;br /&gt;
seg.CreateClosedSurfaceRepresentation()&lt;br /&gt;
slicer.mrmlScene.RemoveNode(labelmapVolumeNode)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The last line is optional. It removes the original labelmap volume so that the same information is not shown twice.&lt;br /&gt;
&lt;br /&gt;
=== Export labelmap node from segmentation node ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
seg = getNode('Segmentation')&lt;br /&gt;
labelmapVolumeNode = slicer.mrmlScene.AddNewNodeByClass('vtkMRMLLabelMapVolumeNode')&lt;br /&gt;
slicer.modules.segmentations.logic().ExportAllSegmentsToLabelmapNode(seg, labelmapVolumeNode)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Export model nodes from segmentation node ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
seg = getNode('Segmentation')&lt;br /&gt;
exportedModelsNode = slicer.mrmlScene.AddNewNodeByClass('vtkMRMLModelHierarchyNode')&lt;br /&gt;
slicer.modules.segmentations.logic().ExportAllSegmentsToModelHierarchy(seg, exportedModelsNode)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Show a segmentation in 3D ===&lt;br /&gt;
Segmentation can only be shown in 3D if closed surface representation (or other 3D-displayable representation) is available. To create closed surface representation:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
segmentation.CreateClosedSurfaceRepresentation()&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Get a representation of a segment ===&lt;br /&gt;
Access binary labelmap stored in a segmentation node (without exporting it to a volume node) - if it does not exist, it will return None:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
image = segmentationNode.GetBinaryLabelmapRepresentation(segmentID)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Get closed surface, if it does not exist, it will return None:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
polydata = segmentationNode.GetClosedSurfaceRepresentation(segmentID)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Get binary labelmap representation. If it does not exist then it will be created for that single segment. Applies parent transforms by default (if not desired, another argument needs to be added to the end: false):&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
import vtkSegmentationCorePython as vtkSegmentationCore&lt;br /&gt;
outputOrientedImageData = vtkSegmentationCore.vtkOrientedImageData()&lt;br /&gt;
slicer.vtkSlicerSegmentationsModuleLogic.GetSegmentBinaryLabelmapRepresentation(segmentationNode, segmentID, outputOrientedImageData)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Same as above, for closed surface representation:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
outputPolyData = vtk.vtkPolyData()&lt;br /&gt;
slicer.vtkSlicerSegmentationsModuleLogic.GetSegmentClosedSurfaceRepresentation(segmentationNode, segmentID, outputPolyData)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Convert all segments using default path and conversion parameters ===&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
segmentationNode.CreateBinaryLabelmapRepresentation()&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Convert all segments using custom path or conversion parameters ===&lt;br /&gt;
Change reference image geometry parameter based on an existing referenceImageData image:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
import vtkSegmentationCorePython as vtkSegmentationCore&lt;br /&gt;
referenceGeometry = vtkSegmentationCore.vtkSegmentationConverter.SerializeImageGeometry(referenceImageData)&lt;br /&gt;
segmentation.SetConversionParameter(vtkSegmentationCore.vtkSegmentationConverter.GetReferenceImageGeometryParameterName(), referenceGeometry)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Re-convert using a modified conversion parameter ===&lt;br /&gt;
Changing smoothing factor for closed surface generation:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
import vtkSegmentationCorePython as vtkSegmentationCore&lt;br /&gt;
segmentation = getNode('Segmentation').GetSegmentation()&lt;br /&gt;
&lt;br /&gt;
# Turn of surface smoothing&lt;br /&gt;
segmentation.SetConversionParameter('Smoothing factor','0.0')&lt;br /&gt;
&lt;br /&gt;
# Recreate representation using modified parameters (and default conversion path)&lt;br /&gt;
segmentation.RemoveRepresentation(vtkSegmentationCore.vtkSegmentationConverter.GetSegmentationClosedSurfaceRepresentationName())&lt;br /&gt;
segmentation.CreateRepresentation(vtkSegmentationCore.vtkSegmentationConverter.GetSegmentationClosedSurfaceRepresentationName())&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Get centroid of a segment in world (RAS) coordinates ===&lt;br /&gt;
&lt;br /&gt;
This example shows how to get centroid of a segment in world coordinates and show that position in all slice views.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
segmentationNode = getNode('Segmentation')&lt;br /&gt;
segmentId = 'Segment_1'&lt;br /&gt;
&lt;br /&gt;
# Get array voxel coordinates&lt;br /&gt;
import numpy as np&lt;br /&gt;
seg=arrayFromSegment(segmentation_node, segmentId)&lt;br /&gt;
# numpy array has voxel coordinates in reverse order (KJI instead of IJK)&lt;br /&gt;
# and the array is cropped to minimum size in the segmentation&lt;br /&gt;
mean_KjiCropped = [coords.mean() for coords in np.nonzero(seg)]&lt;br /&gt;
&lt;br /&gt;
# Get segmentation voxel coordinates&lt;br /&gt;
segImage = segmentationNode.GetBinaryLabelmapRepresentation(segmentId)&lt;br /&gt;
segImageExtent = segImage.GetExtent()&lt;br /&gt;
# origin of the array in voxel coordinates is determined by the start extent&lt;br /&gt;
mean_Ijk = [mean_KjiCropped[2], mean_KjiCropped[1], mean_KjiCropped[0]] + np.array([segImageExtent[0], segImageExtent[2], segImageExtent[4]])&lt;br /&gt;
&lt;br /&gt;
# Get segmentation physical coordinates&lt;br /&gt;
ijkToWorld = vtk.vtkMatrix4x4()&lt;br /&gt;
segImage.GetImageToWorldMatrix(ijkToWorld)&lt;br /&gt;
mean_World = [0, 0, 0, 1]&lt;br /&gt;
ijkToRas.MultiplyPoint(np.append(mean_Ijk,1.0), mean_World)&lt;br /&gt;
mean_World = mean_World[0:3]&lt;br /&gt;
&lt;br /&gt;
# If segmentation node is transformed, apply that transform to get RAS coordinates&lt;br /&gt;
transformWorldToRas = vtk.vtkGeneralTransform()&lt;br /&gt;
slicer.vtkMRMLTransformNode.GetTransformBetweenNodes(segmentationNode.GetParentTransformNode(), None, transformWorldToRas)&lt;br /&gt;
mean_Ras = transformWorldToRas.TransformPoint(mean_World)&lt;br /&gt;
&lt;br /&gt;
# Show mean position value and jump to it in all slice viewers&lt;br /&gt;
print(mean_Ras)&lt;br /&gt;
slicer.modules.markups.logic().JumpSlicesToLocation(mean_Ras[0], mean_Ras[1], mean_Ras[2], True)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== How to run segment editor effects from a script ===&lt;br /&gt;
&lt;br /&gt;
Editor effects are complex because they need to handle changing master volumes, undo/redo, masking operations, etc. Therefore, instead of using a segment editor effect, it is simpler to run the underlying filters directly from script.&lt;br /&gt;
&lt;br /&gt;
This example demonstrates how to use Segment editor effects (without GUI, using qMRMLSegmentEditorWidget):&lt;br /&gt;
&lt;br /&gt;
* [https://gist.github.com/lassoan/2d5a5b73645f65a5eb6f8d5f97abf31b brain tumor segmentation using grow from seeds effect]&lt;br /&gt;
* [https://gist.github.com/lassoan/1673b25d8e7913cbc245b4f09ed853f9 skin surface extraction using thresholding and smoothing]&lt;br /&gt;
* [https://gist.github.com/lassoan/2f5071c562108dac8efe277c78f2620f mask a volume with segments and compute histogram for each region]&lt;br /&gt;
&lt;br /&gt;
This example shows how to perform operations on segmentations using VTK filters:&lt;br /&gt;
* [https://gist.github.com/lassoan/7c94c334653010696b2bf96abc0ac8e7 brain tumor segmentation using grow from seeds effect]&lt;br /&gt;
&lt;br /&gt;
== Accessing views, renderers, and cameras ==&lt;br /&gt;
&lt;br /&gt;
Iterate through all 3D views in current layout:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
layoutManager = slicer.app.layoutManager()&lt;br /&gt;
for threeDViewIndex in range(layoutManager.threeDViewCount) :&lt;br /&gt;
  view = layoutManager.threeDWidget(threeDViewIndex).threeDView()&lt;br /&gt;
  threeDViewNode = view.mrmlViewNode()&lt;br /&gt;
  cameraNode = slicer.modules.cameras.logic().GetViewActiveCameraNode(threeDViewNode)&lt;br /&gt;
  print('View node for 3D widget ' + str(threeDViewIndex))&lt;br /&gt;
  print('  Name: ' + threeDViewNode .GetName())&lt;br /&gt;
  print('  ID: ' + threeDViewNode .GetID())&lt;br /&gt;
  print('  Camera ID: ' + cameraNode.GetID())&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Iterate through all slice views in current layout:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
layoutManager = slicer.app.layoutManager()&lt;br /&gt;
for sliceViewName in layoutManager.sliceViewNames():&lt;br /&gt;
  view = layoutManager.sliceWidget(sliceViewName).sliceView()&lt;br /&gt;
  sliceNode = view.mrmlSliceNode()&lt;br /&gt;
  sliceLogic = slicer.app.applicationLogic().GetSliceLogic(sliceNode)&lt;br /&gt;
  compositeNode = sliceLogic.GetSliceCompositeNode()&lt;br /&gt;
  print('Slice view ' + str(sliceViewName))&lt;br /&gt;
  print('  Name: ' + sliceNode.GetName())&lt;br /&gt;
  print('  ID: ' + sliceNode.GetID())&lt;br /&gt;
  print('  Background volume: {0}'.format(compositeNode.GetBackgroundVolumeID()))&lt;br /&gt;
  print('  Foreground volume: {0} (opacity: {1})'.format(compositeNode.GetForegroundVolumeID(), compositeNode.GetForegroundOpacity()))&lt;br /&gt;
  print('  Label volume: {0} (opacity: {1})'.format(compositeNode.GetLabelVolumeID(), compositeNode.GetLabelOpacity()))&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
For low-level manipulation of views, it is possible to access VTK render windows, renderers and cameras of views in the current layout.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
renderWindow = view.renderWindow()&lt;br /&gt;
renderers = renderWindow.GetRenderers()&lt;br /&gt;
renderer = renderers.GetItemAsObject(0)&lt;br /&gt;
camera = cameraNode.GetCamera()&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Change 3D view background color ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
renderWindow = slicer.app.layoutManager().threeDWidget(0).threeDView().renderWindow()&lt;br /&gt;
renderer = renderWindow.GetRenderers().GetFirstRenderer()&lt;br /&gt;
renderer.SetBackground(1,0,0)&lt;br /&gt;
renderer.SetBackground2(1,0,0)&lt;br /&gt;
renderWindow.Render()&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Subject hierarchy == &lt;br /&gt;
==== Get the pseudo-singleton subject hierarchy node ====&lt;br /&gt;
It manages the whole hierarchy and provides functions to access and manipulate&lt;br /&gt;
  shNode = slicer.vtkMRMLSubjectHierarchyNode.GetSubjectHierarchyNode(slicer.mrmlScene)&lt;br /&gt;
&lt;br /&gt;
==== Create subject hierarchy item ====&lt;br /&gt;
  # If it is for a data node, it is automatically created, but the create function can be used to set parent:&lt;br /&gt;
  shNode.CreateItem(parentItemID, dataNode)&lt;br /&gt;
  # If it is a hierarchy item without a data node, then the create function must be used:&lt;br /&gt;
  shNode.CreateSubjectItem(parentItemID, name)&lt;br /&gt;
  shNode.CreateFolderItem(parentItemID, name)&lt;br /&gt;
  shNode.CreateHierarchyItem(parentItemID, name, level) # Advanced method to set level attribute manually (usually subject, study, or folder, but it can be a virtual branch for example)&lt;br /&gt;
&lt;br /&gt;
==== Get subject hierarchy item ====&lt;br /&gt;
Items in subject hierarchy are uniquely identified by integer IDs&lt;br /&gt;
  # Get scene item ID first because it is the root item:&lt;br /&gt;
  sceneItemID = shNode.GetSceneItemID()&lt;br /&gt;
  # Get direct child by name&lt;br /&gt;
  subjectItemID = shNode.GetItemChildWithName(sceneItemID, 'Subject_1')&lt;br /&gt;
  # Get item for data node&lt;br /&gt;
  itemID = shNode.GetItemByDataNode(dataNode)&lt;br /&gt;
  # Get item by UID (such as DICOM)&lt;br /&gt;
  itemID = shNode.GetItemByUID(slicer.vtkMRMLSubjectHierarchyConstants.GetDICOMUIDName(), seriesInstanceUid)&lt;br /&gt;
  itemID = shNode.GetItemByUIDList(slicer.vtkMRMLSubjectHierarchyConstants.GetDICOMInstanceUIDName(), instanceUID)&lt;br /&gt;
  # Invalid item ID for checking validity of a given ID (most functions return the invalid ID when item is not found)&lt;br /&gt;
  invalidItemID = slicer.vtkMRMLSubjectHierarchyNode.GetInvalidItemID()&lt;br /&gt;
&lt;br /&gt;
==== Traverse children of a subject hierarchy item ====&lt;br /&gt;
  children = vtk.vtkIdList()&lt;br /&gt;
  shNode.GetItemChildren(parent, children)&lt;br /&gt;
  for i in xrange(children.GetNumberOfIds()):&lt;br /&gt;
    child = children.GetId(i)&lt;br /&gt;
    ...&lt;br /&gt;
&lt;br /&gt;
==== Manipulate subject hierarchy item ====&lt;br /&gt;
Instead of node operations on the individual subject hierarchy nodes, item operations are performed on the one subject hierarchy node.&lt;br /&gt;
  # Set item name&lt;br /&gt;
  shNode.SetItemName(itemID, 'NewName')&lt;br /&gt;
  # Set item parent (reparent)&lt;br /&gt;
  shNode.SetItemParent(itemID, newParentItemID)&lt;br /&gt;
  # Set visibility of data nodes associated to items in a branch (or a leaf item)&lt;br /&gt;
  shNode.SetDisplayVisibilityForBranch(itemID, 1)&lt;br /&gt;
&lt;br /&gt;
==== Filter items in TreeView or ComboBox ====&lt;br /&gt;
Displayed items can be filtered using ''setAttributeFilter'' method. An example of the usage can be found in the  [https://github.com/Slicer/Slicer/blob/e66e3b08e35384526528e6ae678e9ec9f079f286/Applications/SlicerApp/Testing/Python/SubjectHierarchyGenericSelfTest.py#L352-L360 unit test]. Modified version here:&lt;br /&gt;
    print shTreeView.displayedItemCount() # 5&lt;br /&gt;
    shTreeView.setAttributeFilter('DICOM.Modality') # Nodes must have this attribute&lt;br /&gt;
    print shTreeView.displayedItemCount() # 3&lt;br /&gt;
    shTreeView.setAttributeFilter('DICOM.Modality','CT') # Have attribute and equal 'CT'&lt;br /&gt;
    print shTreeView.displayedItemCount() # 1&lt;br /&gt;
    shTreeView.removeAttributeFilter()&lt;br /&gt;
    print shTreeView.displayedItemCount() # 5&lt;br /&gt;
&lt;br /&gt;
=== Listen to subject hierarchy item events ===&lt;br /&gt;
The subject hierarchy node sends the node item id as calldata. Item IDs are vtkIdType, which are NOT vtkObjects. You need to use vtk.calldata_type(vtk.VTK_LONG) (otherwise the application crashes).&lt;br /&gt;
  &lt;br /&gt;
  class MyListenerClass(VTKObservationMixin):&lt;br /&gt;
    def __init__(self):&lt;br /&gt;
      VTKObservationMixin.__init__(self)&lt;br /&gt;
      &lt;br /&gt;
      shNode = slicer.vtkMRMLSubjectHierarchyNode.GetSubjectHierarchyNode(slicer.mrmlScene)&lt;br /&gt;
      self.addObserver(shNode, shNode.SubjectHierarchyItemModifiedEvent, self.shItemModifiedEvent)&lt;br /&gt;
     &lt;br /&gt;
    @vtk.calldata_type(vtk.VTK_LONG) &lt;br /&gt;
    def shItemModifiedEvent(self, caller, eventId, callData):&lt;br /&gt;
      print(&amp;quot;SH Node modified&amp;quot;)&lt;br /&gt;
      print(&amp;quot;SH item ID: {0}&amp;quot;.format(callData))&lt;br /&gt;
&lt;br /&gt;
== Plotting ==&lt;br /&gt;
&lt;br /&gt;
=== Create histogram plot of a volume ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Get a volume from SampleData&lt;br /&gt;
import SampleData&lt;br /&gt;
volumeNode = SampleData.SampleDataLogic().downloadMRHead()&lt;br /&gt;
&lt;br /&gt;
# Compute histogram values&lt;br /&gt;
import numpy as np&lt;br /&gt;
histogram = np.histogram(arrayFromVolume(volumeNode), bins=50)&lt;br /&gt;
&lt;br /&gt;
# Save results to a new table node&lt;br /&gt;
tableNode=slicer.mrmlScene.AddNewNodeByClass(&amp;quot;vtkMRMLTableNode&amp;quot;)&lt;br /&gt;
updateTableFromArray(tableNode, histogram)&lt;br /&gt;
tableNode.GetTable().GetColumn(0).SetName(&amp;quot;Count&amp;quot;)&lt;br /&gt;
tableNode.GetTable().GetColumn(1).SetName(&amp;quot;Intensity&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
# Create plot&lt;br /&gt;
plotSeriesNode = slicer.mrmlScene.AddNewNodeByClass(&amp;quot;vtkMRMLPlotSeriesNode&amp;quot;, volumeNode.GetName() + ' histogram')&lt;br /&gt;
plotSeriesNode.SetAndObserveTableNodeID(tableNode.GetID())&lt;br /&gt;
plotSeriesNode.SetXColumnName(&amp;quot;Intensity&amp;quot;)&lt;br /&gt;
plotSeriesNode.SetYColumnName(&amp;quot;Count&amp;quot;)&lt;br /&gt;
plotSeriesNode.SetPlotType(plotSeriesNode.PlotTypeScatterBar)&lt;br /&gt;
plotSeriesNode.SetColor(0, 0.6, 1.0)&lt;br /&gt;
&lt;br /&gt;
# Create chart and add plot&lt;br /&gt;
plotChartNode = slicer.mrmlScene.AddNewNodeByClass(&amp;quot;vtkMRMLPlotChartNode&amp;quot;)&lt;br /&gt;
plotChartNode.AddAndObservePlotSeriesNodeID(plotSeriesNode.GetID())&lt;br /&gt;
plotChartNode.YAxisRangeAutoOff()&lt;br /&gt;
plotChartNode.SetYAxisRange(0, 500000)&lt;br /&gt;
&lt;br /&gt;
# Show plot in layout&lt;br /&gt;
slicer.modules.plots.logic().ShowChartInLayout(plotChartNode)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Execute external applications ==&lt;br /&gt;
&lt;br /&gt;
How to run external applications from Slicer.&lt;br /&gt;
&lt;br /&gt;
=== Run process in default environment ===&lt;br /&gt;
&lt;br /&gt;
When a process is launched from Slicer then by default Slicer's ITK, VTK, Qt, etc. libraries are used. If an external application has its own version of these libraries, then the application is expected to crash. To prevent crashing, the application must be run in the environment where Slicer started up (without all Slicer-specific library paths). This startup environment can be retrieved using ''slicer.util.startupEnvironment()''.&lt;br /&gt;
&lt;br /&gt;
Example: run Python3 script from Slicer:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
command_to_execute = [&amp;quot;/usr/bin/python3&amp;quot;, &amp;quot;-c&amp;quot;, &amp;quot;print('hola')&amp;quot;]&lt;br /&gt;
from subprocess import check_output&lt;br /&gt;
check_output(&lt;br /&gt;
  command_to_execute, &lt;br /&gt;
  env=slicer.util.startupEnvironment()&lt;br /&gt;
  )&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
will output:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
'hola\n'&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
On some systems, ''shell=True'' must be specified as well.&lt;/div&gt;</summary>
		<author><name>Inorton</name></author>
		
	</entry>
	<entry>
		<id>https://www.slicer.org/w/index.php?title=Documentation/Nightly/Modules/Transforms&amp;diff=59461</id>
		<title>Documentation/Nightly/Modules/Transforms</title>
		<link rel="alternate" type="text/html" href="https://www.slicer.org/w/index.php?title=Documentation/Nightly/Modules/Transforms&amp;diff=59461"/>
		<updated>2018-09-25T20:04:43Z</updated>

		<summary type="html">&lt;p&gt;Inorton: /* Transform files */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;noinclude&amp;gt;{{documentation/versioncheck}}&amp;lt;/noinclude&amp;gt;&lt;br /&gt;
&amp;lt;!-- ---------------------------- --&amp;gt;&lt;br /&gt;
{{documentation/{{documentation/version}}/module-header}}&lt;br /&gt;
&amp;lt;!-- ---------------------------- --&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{TOC_right}}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- ---------------------------- --&amp;gt;&lt;br /&gt;
{{documentation/{{documentation/version}}/module-section|Introduction and Acknowledgements}}&lt;br /&gt;
{{documentation/{{documentation/version}}/module-introduction-start|{{documentation/modulename}}}}&lt;br /&gt;
{{documentation/{{documentation/version}}/module-introduction-row}}&lt;br /&gt;
:'''Author(s)/Contributor(s):''' Alex Yarmarkovich (Isomics, SPL), Jean-Christophe Fillion-Robin (Kitware), Julien Finet (Kitware), Andras Lasso (PerkLab, Queen's), Franklin King (PerkLab, Queen's)&amp;lt;br&amp;gt;&lt;br /&gt;
:'''Acknowledgements:''' This work is part of the [http://www.na-mic.org/ National Alliance for Medical Image Computing] (NA-MIC), funded by the National Institutes of Health through the NIH Roadmap for Medical Research, Grant U54 EB005149.&amp;lt;br&amp;gt;&lt;br /&gt;
:'''Contact:''' Alex Yarmarkovich, &amp;lt;email&amp;gt;alexy@bwh.harvard.edu&amp;lt;/email&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
{{documentation/{{documentation/version}}/module-introduction-row}}&lt;br /&gt;
{{documentation/{{documentation/version}}/module-introduction-logo-gallery&lt;br /&gt;
|{{collaborator|logo|isomics}}|{{collaborator|longname|isomics}}&lt;br /&gt;
|{{collaborator|logo|kitware}}|{{collaborator|longname|kitware}}&lt;br /&gt;
|{{collaborator|logo|namic}}|{{collaborator|longname|namic}}&lt;br /&gt;
|{{collaborator|logo|nac}}|{{collaborator|longname|nac}}&lt;br /&gt;
}}&lt;br /&gt;
{{documentation/{{documentation/version}}/module-introduction-end}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- ---------------------------- --&amp;gt;&lt;br /&gt;
{{documentation/{{documentation/version}}/module-section|Module Description}}&lt;br /&gt;
{{documentation/{{documentation/version}}/module-description}}&lt;br /&gt;
&lt;br /&gt;
Features: &lt;br /&gt;
&lt;br /&gt;
* '''Short video demonstrating the main features:''' http://screencast.com/t/Z6dQVjK3m&lt;br /&gt;
* Support non-linear transforms in the Transforms module: allow Apply, Harden, Invert transform&lt;br /&gt;
* Transform information displayed in the Transforms module (type of transform, basic properties)&lt;br /&gt;
* Transform visualization:&lt;br /&gt;
** Built into the Transforms module&lt;br /&gt;
** Three main modes: Glyphs (show an array of arrows, cones, spheres), Grid (show a deformed grid), or Contour (show isolines/isosurfaces for specified displacement magnitude values)&lt;br /&gt;
** All transform types are supported (chains of transforms as well)&lt;br /&gt;
** Visualization in the slice viewers&lt;br /&gt;
** Visualization in the 3D viewers, in the specified region (region can be a slice viewer, a volume, or a ROI widget)&lt;br /&gt;
** Real-time update: if the transform (or any visualization parameter) is changed then the visualization is updated immediately (interactive visualization while editing the transform)&lt;br /&gt;
** Built-in colormap editor&lt;br /&gt;
* MetaImage (mha), NIFTI (nii) vector volumes can be loaded as displacement field (grid) transform &lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- ---------------------------- --&amp;gt;&lt;br /&gt;
{{documentation/{{documentation/version}}/module-section|Use Cases}}&lt;br /&gt;
Most frequently Transform module is used for these scenarios:&lt;br /&gt;
&lt;br /&gt;
* Manual Registration: You can insert a transformation node into your scene, and in the Data module drag a volume or a model under it, making them children of the transformation node. After that any changes to the transformation matrix of this node will be applied to the display of children volumes and models.&lt;br /&gt;
&lt;br /&gt;
* Visualize the displacement that transforms specify: Transforms can be visualized in both 2D and 3D views, as glyphs representing the displacement vectors as arrows, cones, or spheres; regular grids that are deformed by the transform; or contours that represent lines or surfaces where the displacement magnitude has a specific value.&lt;br /&gt;
&lt;br /&gt;
* Apply transforms: You can dynamically transform a node by selecting them in the ''Transformable'' list and clicking the ''right arrow'' button. Whenever the transform changes, the transformed nodes are updated accordingly. The ''Harden Transform'' (its button is below the ''left arrow'' button) can be used for applying the transform to nodes permanently. Transforms themselves can be transformed, therefore chain of transforms can be constructed. Non-linear transforms can be concatenated too, but to to the lack of standard file format for storing concatenated inverted transforms, such composite non-linear transforms cannot be saved to file.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- ---------------------------- --&amp;gt;&lt;br /&gt;
{{documentation/{{documentation/version}}/module-section|Tutorials}}&lt;br /&gt;
* Please use tutorial about [http://www.slicer.org/slicerWiki/index.php/Documentation/4.0/Training loading and viewing data]. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- ---------------------------- --&amp;gt;&lt;br /&gt;
{{documentation/{{documentation/version}}/module-section|Panels and their use}}&lt;br /&gt;
&lt;br /&gt;
===Transform editing and application===&lt;br /&gt;
{|&lt;br /&gt;
|-&lt;br /&gt;
| [[Image:TransformsModule-43.png|thumb|280px|Transforms module panel]]&lt;br /&gt;
| [[Image:QSlicerTransformsModule.png|thumb|660px|''LinearTransform'' applied to ''Meningioma2''&amp;lt;br&amp;gt;Rotation along IS 44º&amp;lt;br&amp;gt;Translations: LR -65mm, PA -14mm, IS 56mm]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
{{documentation/{{documentation/version}}/module-parametersdescription}}&lt;br /&gt;
&lt;br /&gt;
===Transform display options===&lt;br /&gt;
{|&lt;br /&gt;
|-&lt;br /&gt;
| [[Image:GlyphArrow2d.png|thumb|280px|Glyph visualization (arrow, 2D): the arrow shows the displacement vector at the arrow starting point, projected to the slice]]&lt;br /&gt;
| [[Image:GlyphCone2d.png|thumb|280px|Glyph visualization (cone, 2D): the cone shows the displacement vector at the cone centerpoint, projected to the slice]]&lt;br /&gt;
| [[Image:GlyphSphere2d.png|thumb|280px|Glyph visualization (sphere, 2D): the circle diameter shows the displacement vector magnitude at the circle centerpoint]]&lt;br /&gt;
|-&lt;br /&gt;
| [[Image:GlyphArrow3dSlice.png|thumb|280px|Glyph visualization (arrow, 3D, slice region): the arrow shows the displacement vector at the arrow starting point]]&lt;br /&gt;
| [[Image:GlyphCone3dVolumeRoi.png|thumb|280px|Glyph visualization (cone, 3D, annotation ROI region): the cone shows the displacement vector at the cone centerpoint]]&lt;br /&gt;
| [[Image:GlyphSphere3dVolume.png|thumb|280px|Glyph visualization (sphere, 3D, volume region, with glyph magnitude filtering): the sphere diameter shows the displacement vector magnitude at the circle centerpoint]]&lt;br /&gt;
|-&lt;br /&gt;
| [[Image:Grid2d.png|thumb|280px|Grid visualization (2D): shows a regular grid, deformed by the displacement vector projected to the slice]]&lt;br /&gt;
| [[Image:Grid3dSlice.png‎|thumb|280px|Grid visualization (3D, slice region): shows a regular grid, deformed by the displacement vector]]&lt;br /&gt;
| [[Image:Grid3dVolume.png|thumb|280px|Grid visualization (3D, annotation ROI region): shows a regular grid, deformed by the displacement vector]]&lt;br /&gt;
|-&lt;br /&gt;
| [[Image:Contour2d.png|thumb|280px|Contour visualization (2D): iso-lines corresponding to selected displacement magnitude values]]&lt;br /&gt;
| [[Image:Contour3dVolume.png|thumb|280px|Grid visualization (3D, volume region): iso-surfaces corresponding to selected displacement magnitude values]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==== Coloring ====&lt;br /&gt;
&lt;br /&gt;
Open Transforms module / Display section / Colors section.&lt;br /&gt;
If you click on a small circle then above the color bar you can see the small color swatch. On its left side is the points index (an integer that tells which point is being edited and that can be used to jump to the previous/next point), and on its right side is the mm value corresponding to that color.&lt;br /&gt;
&lt;br /&gt;
The default colormap is:&lt;br /&gt;
* 1mm (or below) = gray&lt;br /&gt;
* 2mm = green&lt;br /&gt;
* 5mm = yellow&lt;br /&gt;
* 10mm (or above) = red&lt;br /&gt;
&lt;br /&gt;
You can drag-and-drop any of the small circles or modify the mm value in the editbox. You can also add more color values by clicking on the color bar. Then, you can assign a color and/or adjust the mm value. If you click on a circle and press the DEL key then the color value is deleted.&lt;br /&gt;
&lt;br /&gt;
If you need to know accurate displacement values at specific positions then switch to contour mode and in the “Levels” list enter all the mm values that you are interested in. For example, if you enter only a single value “3” in the Levels field you will see a curve going through the points where the displacement is exactly 3 mm; on one side of the curve the displacements are smaller, on the other side the displacements are larger.&lt;br /&gt;
&lt;br /&gt;
You can show both contours and grid or glyph representations by loading the same transform twice and choosing a different representation for each.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- ---------------------------- --&amp;gt;&lt;br /&gt;
{{documentation/{{documentation/version}}/module-section|Similar Modules}}&lt;br /&gt;
* Related modules: [[Documentation/{{documentation/version}}/Modules/Data|Data module]], [[:Category:Documentation/{{documentation/version}}/Modules/Registration|Registration modules]].&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- ---------------------------- --&amp;gt;&lt;br /&gt;
{{documentation/{{documentation/version}}/module-section|References}}&lt;br /&gt;
N/A&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- ---------------------------- --&amp;gt;&lt;br /&gt;
{{documentation/{{documentation/version}}/module-section|Information for Developers}}&lt;br /&gt;
&lt;br /&gt;
===Key [[Documentation/{{documentation/version}}/Developers/MRML|MRML]] nodes===&lt;br /&gt;
* [http://slicer.org/doc/html/classvtkMRMLTransformableNode.html vtkMRMLTransformableNode]: any node that can be transformed&lt;br /&gt;
* [http://slicer.org/doc/html/classvtkMRMLTransformNode.html vtkMRMLTransformNode]: it can store any linear or deformable transform or composite of multiple transforms&lt;br /&gt;
** [http://slicer.org/doc/html/classvtkMRMLLinearTransformNode.html vtkMRMLLinearTransformNode]: Deprecated. The transform does exactly the same as vtkMRMLTransformNode but has a different class name, which are still used for showing only certain transform types in node selectors. In the future this class will be removed. A vtkMRMLLinearTransformNode may contain non-linear components after a non-linear transform is hardened on it. Therefore, to check linearity of a transform the vtkMRMLTransformNode::IsLinear() and vtkMRMLTransformNode::IsTransformToWorldLinear() and vtkMRMLTransformNode::IsTransformToNodeLinear() methods must be used instead of using vtkMRMLLinearTransformNode::SafeDownCast(transform)!=NULL. &lt;br /&gt;
** [http://slicer.org/doc/html/classvtkMRMLBSplineTransformNode.html vtkMRMLBSplineTransformNode]: Deprecated. The transform does exactly the same as vtkMRMLTransformNode but has a different class name, which are still used for showing only certain transform types in node selectors. In the future this class will be removed.&lt;br /&gt;
** [http://slicer.org/doc/html/classvtkMRMLGridTransformNode.html vtkMRMLGridTransformNode]: Deprecated. The transform does exactly the same as vtkMRMLTransformNode but has a different class name, which are still used for showing only certain transform types in node selectors. In the future this class will be removed.&lt;br /&gt;
&lt;br /&gt;
===Examples===&lt;br /&gt;
&lt;br /&gt;
How to programmatically apply a transform to a transformable node:&lt;br /&gt;
 vtkNew&amp;lt;[http://slicer.org/doc/html/classvtkMRMLTransformNode.html vtkMRMLTransformNode]&amp;gt; transformNode;&lt;br /&gt;
 scene-&amp;gt;AddNode(transformNode.GetPointer());&lt;br /&gt;
 ...&lt;br /&gt;
 vtkNew&amp;lt;vtkMatrix4x4&amp;gt; matrix;&lt;br /&gt;
 ...&lt;br /&gt;
 transform-&amp;gt;SetMatrixTransformToParent( matrix.GetPointer() );&lt;br /&gt;
 ...&lt;br /&gt;
 vtkMRMLVolumeNode* transformableNode = ...; // or vtkMRMLModelNode*...&lt;br /&gt;
 transformableNode-&amp;gt;SetAndObserveTransformNodeID( transformNode-&amp;gt;GetID() );&lt;br /&gt;
&lt;br /&gt;
Example of moving a volume along a trajectory using a transform&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Load sample volume&lt;br /&gt;
import SampleData&lt;br /&gt;
sampleDataLogic = SampleData.SampleDataLogic()&lt;br /&gt;
mrHead = sampleDataLogic.downloadMRHead()&lt;br /&gt;
&lt;br /&gt;
# Create transform and apply to sample volume&lt;br /&gt;
transformNode = slicer.vtkMRMLTransformNode()&lt;br /&gt;
slicer.mrmlScene.AddNode(transformNode)&lt;br /&gt;
mrHead.SetAndObserveTransformNodeID(transformNode.GetID())&lt;br /&gt;
&lt;br /&gt;
# How to move a volume along a trajectory using a transform:&lt;br /&gt;
import time&lt;br /&gt;
import math&lt;br /&gt;
transformMatrix = vtk.vtkMatrix4x4()&lt;br /&gt;
for xPos in range(-30,30):&lt;br /&gt;
  transformMatrix.SetElement(0,3, xPos)&lt;br /&gt;
  transformMatrix.SetElement(1,3, math.sin(xPos)*10)&lt;br /&gt;
  transformNode.SetMatrixTransformToParent(transformMatrix)&lt;br /&gt;
  slicer.app.processEvents()&lt;br /&gt;
  time.sleep(0.02)&lt;br /&gt;
# Note: for longer animations use qt.QTimer.singleShot(100, callbackFunction)&lt;br /&gt;
# instead of a for loop.&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Because a ''transform'' node is also a ''transformable'' node, it is possible to concatenate transforms with each others:&lt;br /&gt;
 [http://slicer.org/doc/html/classvtkMRMLTransformNode.html vtkMRMLTransformNode*] transformNode = ...;&lt;br /&gt;
 [http://slicer.org/doc/html/classvtkMRMLTransformNode.html vtkMRMLTransformNode*] transformNode2 = ...;&lt;br /&gt;
 transformNode2-&amp;gt;SetAndObserveTransformNodeID( transformNode-&amp;gt;GetID() );&lt;br /&gt;
 ...&lt;br /&gt;
 transformable-&amp;gt;SetAndObserveTransformNodeID( transformNode2-&amp;gt;GetID() );&lt;br /&gt;
&lt;br /&gt;
How to convert the transform to a grid transform (also known as displacement field transform)?&lt;br /&gt;
&lt;br /&gt;
 transformNode=slicer.util.getNode('LinearTransform_3')&lt;br /&gt;
 referenceVolumeNode=slicer.util.getNode('MRHead')&lt;br /&gt;
 slicer.modules.transforms.logic().ConvertToGridTransform(transformNode, referenceVolumeNode)&lt;br /&gt;
&lt;br /&gt;
* Conversion to grid transform is useful because some software cannot use inverse transforms or can only use grid transforms.&lt;br /&gt;
* Displacement field transforms are saved to file differently than displacement field volumes: displacement vectors in transforms are converted to LPS coordinate system on saving, displacement vectors in volumes are saved to file unchanged.&lt;br /&gt;
&lt;br /&gt;
How to export the displacement magnitude of the transform as a volume?&lt;br /&gt;
&lt;br /&gt;
 transformNode=slicer.util.getNode('LinearTransform_3')&lt;br /&gt;
 referenceVolumeNode=slicer.util.getNode('MRHead')&lt;br /&gt;
 slicer.modules.transforms.logic().CreateDisplacementVolumeFromTransform(transformNode, referenceVolumeNode, False)&lt;br /&gt;
&lt;br /&gt;
How to visualize the displacement magnitude as a color volume?&lt;br /&gt;
&lt;br /&gt;
 transformNode=slicer.util.getNode('LinearTransform_3')&lt;br /&gt;
 referenceVolumeNode=slicer.util.getNode('MRHead')&lt;br /&gt;
 slicer.modules.transforms.logic().CreateDisplacementVolumeFromTransform(transformNode, referenceVolumeNode, True)&lt;br /&gt;
&lt;br /&gt;
===Transform files===&lt;br /&gt;
* Slicer stores transforms in VTK classes in memory, but uses ITK transform IO classes to read/write transforms to files. ITK's convention is to use LPS coordinate system as opposed to RAS coordinate system in Slicer (see [[Coordinate systems]] page for details). Conversion between VTK and ITK transform classes are implemented in [https://github.com/Slicer/Slicer/blob/master/Libs/MRML/Core/vtkITKTransformConverter.h vtkITKTransformConverter].&lt;br /&gt;
* ITK stores the transform in resampling (a.k.a., image processing) convention, i.e., that transforms points from fixed to moving coordinate system. This transform is usable as is for resampling a moving image in the coordinate system of a fixed image. For transforming points and surface models to the fixed coordinate system, one needs the transform in the modeling (a.k.a. computer graphics) convention, i.e., transform from moving to fixed coordinate system (which is the inverse of the &amp;quot;image processing&amp;quot; convention).&lt;br /&gt;
* Transform nodes in Slicer can store transforms in both modeling (when ToParent transform is set) and resampling way (when FromParent transform is set). When writing transform to ITK files, linear transforms are inverted as needed and written as an AffineTransform. Non-linear transforms cannot be inverted without losing information (in general), therefore if a non-linear transform is defined in resampling convention in Slicer then it is written to ITK file using special &amp;quot;Inverse&amp;quot; transform types (e.g., InverseDisplacementFieldTransform instead of DisplacementFieldTransform). Definition of the inverse classes are available in [https://github.com/Slicer/Slicer/blob/master/Libs/MRML/Core/vtkITKTransformInverse.h vtkITKTransformInverse]. The inverse classes are only usable for file IO, because currently ITK does not provide a generic inverse transform computation method. Options to manage inverse transforms in applications:&lt;br /&gt;
** Create VTK transforms from ITK transforms: VTK transforms can compute their inverse, transform can be changed dynamically, the inverse will be always updated automatically in real-time (this approach is used by Slicer)&lt;br /&gt;
** Invert transform in ITK statically: by converting to displacement field and inverting the displacement field; whenever the forward transform changes, the complete inverse transform has to be computed again (which is typically very time consuming)&lt;br /&gt;
** Avoid inverse non-linear transforms: make sure that non-linear transforms are only set as FromParent&lt;br /&gt;
* Transforms module in Slicer shows linear transform matrix values in RAS coordinate system, according to resampling convention. Therefore to retrieve the same values from an ITK transforms as shown in Slicer GUI, one has switch between RAS/LPS and modeling/resampling:&lt;br /&gt;
&lt;br /&gt;
'''C++''':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
// Convert from LPS (ITK) to RAS (Slicer)&lt;br /&gt;
// input: transformVtk_LPS matrix in vtkMatrix4x4 in resampling convention in LPS&lt;br /&gt;
// output: transformVtk_RAS matrix in vtkMatri4x4 in modeling convention in RAS&lt;br /&gt;
&lt;br /&gt;
// Tras = lps2ras * Tlps * ras2lps&lt;br /&gt;
vtkSmartPointer&amp;lt;vtkMatrix4x4&amp;gt; lps2ras = vtkSmartPointer&amp;lt;vtkMatrix4x4&amp;gt;::New();&lt;br /&gt;
lps2ras-&amp;gt;SetElement(0,0,-1);&lt;br /&gt;
lps2ras-&amp;gt;SetElement(1,1,-1);&lt;br /&gt;
vtkMatrix4x4* ras2lps = lps2ras; // lps2ras is diagonal therefore the inverse is identical&lt;br /&gt;
vtkMatrix4x4::Multiply4x4(lps2ras, transformVtk_LPS, transformVtk_LPS);&lt;br /&gt;
vtkMatrix4x4::Multiply4x4(transformVtk_LPS, ras2lps, transformVtk_RAS); &lt;br /&gt;
&lt;br /&gt;
// Convert the sense of the transform (from ITK resampling to Slicer modeling transform)&lt;br /&gt;
vtkMatrix4x4::Invert(transformVtk_RAS);&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Python''':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Copy the content between the following triple-quotes to a file called 'LinearTransform.tfm', and load into Slicer&lt;br /&gt;
&lt;br /&gt;
tfm_file = &amp;quot;&amp;quot;&amp;quot;#Insight Transform File V1.0&lt;br /&gt;
#Transform 0&lt;br /&gt;
Transform: AffineTransform_double_3_3&lt;br /&gt;
Parameters: 0.929794207512361 0.03834792453582355 -0.3660767246906854 -0.2694570325150706 0.7484457003494506 -0.6059884002657121 0.2507501531497781 0.6620864522947292 0.7062335947709847 -46.99999999999999 49 17.00000000000002&lt;br /&gt;
FixedParameters: 0 0 0&amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
&lt;br /&gt;
import numpy as np&lt;br /&gt;
&lt;br /&gt;
# get the upper 3x4 transform matrix&lt;br /&gt;
m = np.array( tfm_file.splitlines()[3].split()[1:], dtype=np.float64 )&lt;br /&gt;
&lt;br /&gt;
# pad to a 4x4 matrix&lt;br /&gt;
m2 = np.vstack((m.reshape(4,3).T, [0,0,0,1]))&lt;br /&gt;
&lt;br /&gt;
def itktfm_to_slicer(tfm):&lt;br /&gt;
     ras2lps = np.diag([-1, -1, 1, 1])&lt;br /&gt;
     mt = ras2lps @ m2 @ ras2lps&lt;br /&gt;
     mt[:3,3] = mt[:3,:3] @ mt[:3,3]&lt;br /&gt;
     return mt&lt;br /&gt;
&lt;br /&gt;
print( itktfm_to_slicer(m2) )&lt;br /&gt;
&lt;br /&gt;
# Running the code above in Python should print the following output.&lt;br /&gt;
# This output should match the display the loaded .tfm file in the Transforms module:&lt;br /&gt;
# [[  0.92979  -0.26946  -0.25075  52.64097]&lt;br /&gt;
# [  0.03835   0.74845  -0.66209 -46.12696]&lt;br /&gt;
# [  0.36608   0.60599   0.70623  -0.48185]&lt;br /&gt;
# [  0.        0.        0.        1.     ]]&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Events===&lt;br /&gt;
When a transform  node is observed by a transformable node, [http://slicer.org/doc/html/classvtkMRMLTransformableNode.html#ace1c30fc9df552543f00d51a20c038a6a4993bf6e23a6dfc138cb2efc1b9ce43b vtkMRMLTransformableNode::TransformModifiedEvent] is fired on the transformable node at observation time.&lt;br /&gt;
Anytime a transform is modified, vtkCommand::ModifiedEvent is fired on the transform node and  [http://slicer.org/doc/html/classvtkMRMLTransformableNode.html#ace1c30fc9df552543f00d51a20c038a6a4993bf6e23a6dfc138cb2efc1b9ce43b vtkMRMLTransformableNode::TransformModifiedEvent] is fired on the transformable node.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- ---------------------------- --&amp;gt;&lt;br /&gt;
{{documentation/{{documentation/version}}/module-footer}}&lt;br /&gt;
&amp;lt;!-- ---------------------------- --&amp;gt;&lt;/div&gt;</summary>
		<author><name>Inorton</name></author>
		
	</entry>
	<entry>
		<id>https://www.slicer.org/w/index.php?title=Documentation/Nightly/Modules/Transforms&amp;diff=59460</id>
		<title>Documentation/Nightly/Modules/Transforms</title>
		<link rel="alternate" type="text/html" href="https://www.slicer.org/w/index.php?title=Documentation/Nightly/Modules/Transforms&amp;diff=59460"/>
		<updated>2018-09-25T19:51:58Z</updated>

		<summary type="html">&lt;p&gt;Inorton: /* Transform files */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;noinclude&amp;gt;{{documentation/versioncheck}}&amp;lt;/noinclude&amp;gt;&lt;br /&gt;
&amp;lt;!-- ---------------------------- --&amp;gt;&lt;br /&gt;
{{documentation/{{documentation/version}}/module-header}}&lt;br /&gt;
&amp;lt;!-- ---------------------------- --&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{TOC_right}}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- ---------------------------- --&amp;gt;&lt;br /&gt;
{{documentation/{{documentation/version}}/module-section|Introduction and Acknowledgements}}&lt;br /&gt;
{{documentation/{{documentation/version}}/module-introduction-start|{{documentation/modulename}}}}&lt;br /&gt;
{{documentation/{{documentation/version}}/module-introduction-row}}&lt;br /&gt;
:'''Author(s)/Contributor(s):''' Alex Yarmarkovich (Isomics, SPL), Jean-Christophe Fillion-Robin (Kitware), Julien Finet (Kitware), Andras Lasso (PerkLab, Queen's), Franklin King (PerkLab, Queen's)&amp;lt;br&amp;gt;&lt;br /&gt;
:'''Acknowledgements:''' This work is part of the [http://www.na-mic.org/ National Alliance for Medical Image Computing] (NA-MIC), funded by the National Institutes of Health through the NIH Roadmap for Medical Research, Grant U54 EB005149.&amp;lt;br&amp;gt;&lt;br /&gt;
:'''Contact:''' Alex Yarmarkovich, &amp;lt;email&amp;gt;alexy@bwh.harvard.edu&amp;lt;/email&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
{{documentation/{{documentation/version}}/module-introduction-row}}&lt;br /&gt;
{{documentation/{{documentation/version}}/module-introduction-logo-gallery&lt;br /&gt;
|{{collaborator|logo|isomics}}|{{collaborator|longname|isomics}}&lt;br /&gt;
|{{collaborator|logo|kitware}}|{{collaborator|longname|kitware}}&lt;br /&gt;
|{{collaborator|logo|namic}}|{{collaborator|longname|namic}}&lt;br /&gt;
|{{collaborator|logo|nac}}|{{collaborator|longname|nac}}&lt;br /&gt;
}}&lt;br /&gt;
{{documentation/{{documentation/version}}/module-introduction-end}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- ---------------------------- --&amp;gt;&lt;br /&gt;
{{documentation/{{documentation/version}}/module-section|Module Description}}&lt;br /&gt;
{{documentation/{{documentation/version}}/module-description}}&lt;br /&gt;
&lt;br /&gt;
Features: &lt;br /&gt;
&lt;br /&gt;
* '''Short video demonstrating the main features:''' http://screencast.com/t/Z6dQVjK3m&lt;br /&gt;
* Support non-linear transforms in the Transforms module: allow Apply, Harden, Invert transform&lt;br /&gt;
* Transform information displayed in the Transforms module (type of transform, basic properties)&lt;br /&gt;
* Transform visualization:&lt;br /&gt;
** Built into the Transforms module&lt;br /&gt;
** Three main modes: Glyphs (show an array of arrows, cones, spheres), Grid (show a deformed grid), or Contour (show isolines/isosurfaces for specified displacement magnitude values)&lt;br /&gt;
** All transform types are supported (chains of transforms as well)&lt;br /&gt;
** Visualization in the slice viewers&lt;br /&gt;
** Visualization in the 3D viewers, in the specified region (region can be a slice viewer, a volume, or a ROI widget)&lt;br /&gt;
** Real-time update: if the transform (or any visualization parameter) is changed then the visualization is updated immediately (interactive visualization while editing the transform)&lt;br /&gt;
** Built-in colormap editor&lt;br /&gt;
* MetaImage (mha), NIFTI (nii) vector volumes can be loaded as displacement field (grid) transform &lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- ---------------------------- --&amp;gt;&lt;br /&gt;
{{documentation/{{documentation/version}}/module-section|Use Cases}}&lt;br /&gt;
Most frequently Transform module is used for these scenarios:&lt;br /&gt;
&lt;br /&gt;
* Manual Registration: You can insert a transformation node into your scene, and in the Data module drag a volume or a model under it, making them children of the transformation node. After that any changes to the transformation matrix of this node will be applied to the display of children volumes and models.&lt;br /&gt;
&lt;br /&gt;
* Visualize the displacement that transforms specify: Transforms can be visualized in both 2D and 3D views, as glyphs representing the displacement vectors as arrows, cones, or spheres; regular grids that are deformed by the transform; or contours that represent lines or surfaces where the displacement magnitude has a specific value.&lt;br /&gt;
&lt;br /&gt;
* Apply transforms: You can dynamically transform a node by selecting them in the ''Transformable'' list and clicking the ''right arrow'' button. Whenever the transform changes, the transformed nodes are updated accordingly. The ''Harden Transform'' (its button is below the ''left arrow'' button) can be used for applying the transform to nodes permanently. Transforms themselves can be transformed, therefore chain of transforms can be constructed. Non-linear transforms can be concatenated too, but to to the lack of standard file format for storing concatenated inverted transforms, such composite non-linear transforms cannot be saved to file.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- ---------------------------- --&amp;gt;&lt;br /&gt;
{{documentation/{{documentation/version}}/module-section|Tutorials}}&lt;br /&gt;
* Please use tutorial about [http://www.slicer.org/slicerWiki/index.php/Documentation/4.0/Training loading and viewing data]. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- ---------------------------- --&amp;gt;&lt;br /&gt;
{{documentation/{{documentation/version}}/module-section|Panels and their use}}&lt;br /&gt;
&lt;br /&gt;
===Transform editing and application===&lt;br /&gt;
{|&lt;br /&gt;
|-&lt;br /&gt;
| [[Image:TransformsModule-43.png|thumb|280px|Transforms module panel]]&lt;br /&gt;
| [[Image:QSlicerTransformsModule.png|thumb|660px|''LinearTransform'' applied to ''Meningioma2''&amp;lt;br&amp;gt;Rotation along IS 44º&amp;lt;br&amp;gt;Translations: LR -65mm, PA -14mm, IS 56mm]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
{{documentation/{{documentation/version}}/module-parametersdescription}}&lt;br /&gt;
&lt;br /&gt;
===Transform display options===&lt;br /&gt;
{|&lt;br /&gt;
|-&lt;br /&gt;
| [[Image:GlyphArrow2d.png|thumb|280px|Glyph visualization (arrow, 2D): the arrow shows the displacement vector at the arrow starting point, projected to the slice]]&lt;br /&gt;
| [[Image:GlyphCone2d.png|thumb|280px|Glyph visualization (cone, 2D): the cone shows the displacement vector at the cone centerpoint, projected to the slice]]&lt;br /&gt;
| [[Image:GlyphSphere2d.png|thumb|280px|Glyph visualization (sphere, 2D): the circle diameter shows the displacement vector magnitude at the circle centerpoint]]&lt;br /&gt;
|-&lt;br /&gt;
| [[Image:GlyphArrow3dSlice.png|thumb|280px|Glyph visualization (arrow, 3D, slice region): the arrow shows the displacement vector at the arrow starting point]]&lt;br /&gt;
| [[Image:GlyphCone3dVolumeRoi.png|thumb|280px|Glyph visualization (cone, 3D, annotation ROI region): the cone shows the displacement vector at the cone centerpoint]]&lt;br /&gt;
| [[Image:GlyphSphere3dVolume.png|thumb|280px|Glyph visualization (sphere, 3D, volume region, with glyph magnitude filtering): the sphere diameter shows the displacement vector magnitude at the circle centerpoint]]&lt;br /&gt;
|-&lt;br /&gt;
| [[Image:Grid2d.png|thumb|280px|Grid visualization (2D): shows a regular grid, deformed by the displacement vector projected to the slice]]&lt;br /&gt;
| [[Image:Grid3dSlice.png‎|thumb|280px|Grid visualization (3D, slice region): shows a regular grid, deformed by the displacement vector]]&lt;br /&gt;
| [[Image:Grid3dVolume.png|thumb|280px|Grid visualization (3D, annotation ROI region): shows a regular grid, deformed by the displacement vector]]&lt;br /&gt;
|-&lt;br /&gt;
| [[Image:Contour2d.png|thumb|280px|Contour visualization (2D): iso-lines corresponding to selected displacement magnitude values]]&lt;br /&gt;
| [[Image:Contour3dVolume.png|thumb|280px|Grid visualization (3D, volume region): iso-surfaces corresponding to selected displacement magnitude values]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==== Coloring ====&lt;br /&gt;
&lt;br /&gt;
Open Transforms module / Display section / Colors section.&lt;br /&gt;
If you click on a small circle then above the color bar you can see the small color swatch. On its left side is the points index (an integer that tells which point is being edited and that can be used to jump to the previous/next point), and on its right side is the mm value corresponding to that color.&lt;br /&gt;
&lt;br /&gt;
The default colormap is:&lt;br /&gt;
* 1mm (or below) = gray&lt;br /&gt;
* 2mm = green&lt;br /&gt;
* 5mm = yellow&lt;br /&gt;
* 10mm (or above) = red&lt;br /&gt;
&lt;br /&gt;
You can drag-and-drop any of the small circles or modify the mm value in the editbox. You can also add more color values by clicking on the color bar. Then, you can assign a color and/or adjust the mm value. If you click on a circle and press the DEL key then the color value is deleted.&lt;br /&gt;
&lt;br /&gt;
If you need to know accurate displacement values at specific positions then switch to contour mode and in the “Levels” list enter all the mm values that you are interested in. For example, if you enter only a single value “3” in the Levels field you will see a curve going through the points where the displacement is exactly 3 mm; on one side of the curve the displacements are smaller, on the other side the displacements are larger.&lt;br /&gt;
&lt;br /&gt;
You can show both contours and grid or glyph representations by loading the same transform twice and choosing a different representation for each.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- ---------------------------- --&amp;gt;&lt;br /&gt;
{{documentation/{{documentation/version}}/module-section|Similar Modules}}&lt;br /&gt;
* Related modules: [[Documentation/{{documentation/version}}/Modules/Data|Data module]], [[:Category:Documentation/{{documentation/version}}/Modules/Registration|Registration modules]].&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- ---------------------------- --&amp;gt;&lt;br /&gt;
{{documentation/{{documentation/version}}/module-section|References}}&lt;br /&gt;
N/A&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- ---------------------------- --&amp;gt;&lt;br /&gt;
{{documentation/{{documentation/version}}/module-section|Information for Developers}}&lt;br /&gt;
&lt;br /&gt;
===Key [[Documentation/{{documentation/version}}/Developers/MRML|MRML]] nodes===&lt;br /&gt;
* [http://slicer.org/doc/html/classvtkMRMLTransformableNode.html vtkMRMLTransformableNode]: any node that can be transformed&lt;br /&gt;
* [http://slicer.org/doc/html/classvtkMRMLTransformNode.html vtkMRMLTransformNode]: it can store any linear or deformable transform or composite of multiple transforms&lt;br /&gt;
** [http://slicer.org/doc/html/classvtkMRMLLinearTransformNode.html vtkMRMLLinearTransformNode]: Deprecated. The transform does exactly the same as vtkMRMLTransformNode but has a different class name, which are still used for showing only certain transform types in node selectors. In the future this class will be removed. A vtkMRMLLinearTransformNode may contain non-linear components after a non-linear transform is hardened on it. Therefore, to check linearity of a transform the vtkMRMLTransformNode::IsLinear() and vtkMRMLTransformNode::IsTransformToWorldLinear() and vtkMRMLTransformNode::IsTransformToNodeLinear() methods must be used instead of using vtkMRMLLinearTransformNode::SafeDownCast(transform)!=NULL. &lt;br /&gt;
** [http://slicer.org/doc/html/classvtkMRMLBSplineTransformNode.html vtkMRMLBSplineTransformNode]: Deprecated. The transform does exactly the same as vtkMRMLTransformNode but has a different class name, which are still used for showing only certain transform types in node selectors. In the future this class will be removed.&lt;br /&gt;
** [http://slicer.org/doc/html/classvtkMRMLGridTransformNode.html vtkMRMLGridTransformNode]: Deprecated. The transform does exactly the same as vtkMRMLTransformNode but has a different class name, which are still used for showing only certain transform types in node selectors. In the future this class will be removed.&lt;br /&gt;
&lt;br /&gt;
===Examples===&lt;br /&gt;
&lt;br /&gt;
How to programmatically apply a transform to a transformable node:&lt;br /&gt;
 vtkNew&amp;lt;[http://slicer.org/doc/html/classvtkMRMLTransformNode.html vtkMRMLTransformNode]&amp;gt; transformNode;&lt;br /&gt;
 scene-&amp;gt;AddNode(transformNode.GetPointer());&lt;br /&gt;
 ...&lt;br /&gt;
 vtkNew&amp;lt;vtkMatrix4x4&amp;gt; matrix;&lt;br /&gt;
 ...&lt;br /&gt;
 transform-&amp;gt;SetMatrixTransformToParent( matrix.GetPointer() );&lt;br /&gt;
 ...&lt;br /&gt;
 vtkMRMLVolumeNode* transformableNode = ...; // or vtkMRMLModelNode*...&lt;br /&gt;
 transformableNode-&amp;gt;SetAndObserveTransformNodeID( transformNode-&amp;gt;GetID() );&lt;br /&gt;
&lt;br /&gt;
Example of moving a volume along a trajectory using a transform&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Load sample volume&lt;br /&gt;
import SampleData&lt;br /&gt;
sampleDataLogic = SampleData.SampleDataLogic()&lt;br /&gt;
mrHead = sampleDataLogic.downloadMRHead()&lt;br /&gt;
&lt;br /&gt;
# Create transform and apply to sample volume&lt;br /&gt;
transformNode = slicer.vtkMRMLTransformNode()&lt;br /&gt;
slicer.mrmlScene.AddNode(transformNode)&lt;br /&gt;
mrHead.SetAndObserveTransformNodeID(transformNode.GetID())&lt;br /&gt;
&lt;br /&gt;
# How to move a volume along a trajectory using a transform:&lt;br /&gt;
import time&lt;br /&gt;
import math&lt;br /&gt;
transformMatrix = vtk.vtkMatrix4x4()&lt;br /&gt;
for xPos in range(-30,30):&lt;br /&gt;
  transformMatrix.SetElement(0,3, xPos)&lt;br /&gt;
  transformMatrix.SetElement(1,3, math.sin(xPos)*10)&lt;br /&gt;
  transformNode.SetMatrixTransformToParent(transformMatrix)&lt;br /&gt;
  slicer.app.processEvents()&lt;br /&gt;
  time.sleep(0.02)&lt;br /&gt;
# Note: for longer animations use qt.QTimer.singleShot(100, callbackFunction)&lt;br /&gt;
# instead of a for loop.&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Because a ''transform'' node is also a ''transformable'' node, it is possible to concatenate transforms with each others:&lt;br /&gt;
 [http://slicer.org/doc/html/classvtkMRMLTransformNode.html vtkMRMLTransformNode*] transformNode = ...;&lt;br /&gt;
 [http://slicer.org/doc/html/classvtkMRMLTransformNode.html vtkMRMLTransformNode*] transformNode2 = ...;&lt;br /&gt;
 transformNode2-&amp;gt;SetAndObserveTransformNodeID( transformNode-&amp;gt;GetID() );&lt;br /&gt;
 ...&lt;br /&gt;
 transformable-&amp;gt;SetAndObserveTransformNodeID( transformNode2-&amp;gt;GetID() );&lt;br /&gt;
&lt;br /&gt;
How to convert the transform to a grid transform (also known as displacement field transform)?&lt;br /&gt;
&lt;br /&gt;
 transformNode=slicer.util.getNode('LinearTransform_3')&lt;br /&gt;
 referenceVolumeNode=slicer.util.getNode('MRHead')&lt;br /&gt;
 slicer.modules.transforms.logic().ConvertToGridTransform(transformNode, referenceVolumeNode)&lt;br /&gt;
&lt;br /&gt;
* Conversion to grid transform is useful because some software cannot use inverse transforms or can only use grid transforms.&lt;br /&gt;
* Displacement field transforms are saved to file differently than displacement field volumes: displacement vectors in transforms are converted to LPS coordinate system on saving, displacement vectors in volumes are saved to file unchanged.&lt;br /&gt;
&lt;br /&gt;
How to export the displacement magnitude of the transform as a volume?&lt;br /&gt;
&lt;br /&gt;
 transformNode=slicer.util.getNode('LinearTransform_3')&lt;br /&gt;
 referenceVolumeNode=slicer.util.getNode('MRHead')&lt;br /&gt;
 slicer.modules.transforms.logic().CreateDisplacementVolumeFromTransform(transformNode, referenceVolumeNode, False)&lt;br /&gt;
&lt;br /&gt;
How to visualize the displacement magnitude as a color volume?&lt;br /&gt;
&lt;br /&gt;
 transformNode=slicer.util.getNode('LinearTransform_3')&lt;br /&gt;
 referenceVolumeNode=slicer.util.getNode('MRHead')&lt;br /&gt;
 slicer.modules.transforms.logic().CreateDisplacementVolumeFromTransform(transformNode, referenceVolumeNode, True)&lt;br /&gt;
&lt;br /&gt;
===Transform files===&lt;br /&gt;
* Slicer stores tansform in VTK classes in memory but uses ITK transform IO classes to read/write transforms to files. ITK's convention is to use LPS coordinate system as opposed to RAS coordinate system in Slicer (see [[Coordinate systems]] page for details). Conversion between VTK and ITK transform classes are implemented in [https://github.com/Slicer/Slicer/blob/master/Libs/MRML/Core/vtkITKTransformConverter.h vtkITKTransformConverter].&lt;br /&gt;
* ITK stores the transform in resampling (a.k.a., image processing) convention, i.e., that transforms points from fixed to moving coordinate system. This transform is usable as is for resampling a moving image in the coordinate system of a fixed image. For transforming points and surface models to the fixed coordinate system, one needs the transform in the modeling (a.k.a. computer graphics) convention, i.e., transform from moving to fixed coordinate system (which is the inverse of the &amp;quot;image processing&amp;quot; convention).&lt;br /&gt;
* Transform nodes in Slicer can store transforms in both modeling (when ToParent transform is set) and resampling way (when FromParent transform is set). When writing transform to ITK files, linear transforms are inverted as needed and written as an AffineTransform. Non-linear transforms cannot be inverted without losing information (in general), therefore if a non-linear transform is defined in resampling convention in Slicer then it is written to ITK file using special &amp;quot;Inverse&amp;quot; transform types (e.g., InverseDisplacementFieldTransform instead of DisplacementFieldTransform). Definition of the inverse classes are available in [https://github.com/Slicer/Slicer/blob/master/Libs/MRML/Core/vtkITKTransformInverse.h vtkITKTransformInverse]. The inverse classes are only usable for file IO, because currently ITK does not provide a generic inverse transform computation method. Options to manage inverse transforms in applications:&lt;br /&gt;
** Create VTK transforms from ITK transforms: VTK transforms can compute their inverse, transform can be changed dynamically, the inverse will be always updated automatically in real-time (this approach is used by Slicer)&lt;br /&gt;
** Invert transform in ITK statically: by converting to displacement field and inverting the displacement field; whenever the forward transform changes, the complete inverse transform has to be computed again (which is typically very time consuming)&lt;br /&gt;
** Avoid inverse non-linear transforms: make sure that non-linear transforms are only set as FromParent&lt;br /&gt;
* Transforms module in Slicer shows linear transform matrix values in RAS coordinate system, according to resampling convention. Therefore to retrieve the same values from an ITK transforms as shown in Slicer GUI, one has switch between RAS/LPS and modeling/resampling:&lt;br /&gt;
&lt;br /&gt;
'''C++''':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
// Convert from LPS (ITK) to RAS (Slicer)&lt;br /&gt;
// input: transformVtk_LPS matrix in vtkMatrix4x4 in resampling convention in LPS&lt;br /&gt;
// output: transformVtk_RAS matrix in vtkMatri4x4 in modeling convention in RAS&lt;br /&gt;
&lt;br /&gt;
// Tras = lps2ras * Tlps * ras2lps&lt;br /&gt;
vtkSmartPointer&amp;lt;vtkMatrix4x4&amp;gt; lps2ras = vtkSmartPointer&amp;lt;vtkMatrix4x4&amp;gt;::New();&lt;br /&gt;
lps2ras-&amp;gt;SetElement(0,0,-1);&lt;br /&gt;
lps2ras-&amp;gt;SetElement(1,1,-1);&lt;br /&gt;
vtkMatrix4x4* ras2lps = lps2ras; // lps2ras is diagonal therefore the inverse is identical&lt;br /&gt;
vtkMatrix4x4::Multiply4x4(lps2ras, transformVtk_LPS, transformVtk_LPS);&lt;br /&gt;
vtkMatrix4x4::Multiply4x4(transformVtk_LPS, ras2lps, transformVtk_RAS); &lt;br /&gt;
&lt;br /&gt;
// Convert the sense of the transform (from ITK resampling to Slicer modeling transform)&lt;br /&gt;
vtkMatrix4x4::Invert(transformVtk_RAS);&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Python''':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Copy the content between the following triple-quotes to a file called 'LinearTransform.tfm', and load into Slicer&lt;br /&gt;
&lt;br /&gt;
tfm_file = &amp;quot;&amp;quot;&amp;quot;#Insight Transform File V1.0&lt;br /&gt;
#Transform 0&lt;br /&gt;
Transform: AffineTransform_double_3_3&lt;br /&gt;
Parameters: 0.929794207512361 0.03834792453582355 -0.3660767246906854 -0.2694570325150706 0.7484457003494506 -0.6059884002657121 0.2507501531497781 0.6620864522947292 0.7062335947709847 -46.99999999999999 49 17.00000000000002&lt;br /&gt;
FixedParameters: 0 0 0&amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
&lt;br /&gt;
import numpy as np&lt;br /&gt;
&lt;br /&gt;
# get the upper 3x4 transform matrix&lt;br /&gt;
m = np.array( tfm_file.splitlines()[3].split()[1:], dtype=np.float64 )&lt;br /&gt;
&lt;br /&gt;
# pad to a 4x4 matrix&lt;br /&gt;
m2 = np.vstack((m.reshape(4,3).T, [0,0,0,1]))&lt;br /&gt;
&lt;br /&gt;
def itktfm_to_slicer(tfm):&lt;br /&gt;
     ras2lps = np.diag([-1, -1, 1, 1])&lt;br /&gt;
     mt = ras2lps @ m2 @ ras2lps&lt;br /&gt;
     mt[:3,3] = mt[:3,:3] @ mt[:3,3]&lt;br /&gt;
     return mt&lt;br /&gt;
&lt;br /&gt;
print( itktfm_to_slicer(m2) )&lt;br /&gt;
&lt;br /&gt;
# Running the code above in Python should print the following output.&lt;br /&gt;
# This output should match the display the loaded .tfm file in the Transforms module:&lt;br /&gt;
# [[  0.92979  -0.26946  -0.25075  52.64097]&lt;br /&gt;
# [  0.03835   0.74845  -0.66209 -46.12696]&lt;br /&gt;
# [  0.36608   0.60599   0.70623  -0.48185]&lt;br /&gt;
# [  0.        0.        0.        1.     ]]&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Events===&lt;br /&gt;
When a transform  node is observed by a transformable node, [http://slicer.org/doc/html/classvtkMRMLTransformableNode.html#ace1c30fc9df552543f00d51a20c038a6a4993bf6e23a6dfc138cb2efc1b9ce43b vtkMRMLTransformableNode::TransformModifiedEvent] is fired on the transformable node at observation time.&lt;br /&gt;
Anytime a transform is modified, vtkCommand::ModifiedEvent is fired on the transform node and  [http://slicer.org/doc/html/classvtkMRMLTransformableNode.html#ace1c30fc9df552543f00d51a20c038a6a4993bf6e23a6dfc138cb2efc1b9ce43b vtkMRMLTransformableNode::TransformModifiedEvent] is fired on the transformable node.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- ---------------------------- --&amp;gt;&lt;br /&gt;
{{documentation/{{documentation/version}}/module-footer}}&lt;br /&gt;
&amp;lt;!-- ---------------------------- --&amp;gt;&lt;/div&gt;</summary>
		<author><name>Inorton</name></author>
		
	</entry>
	<entry>
		<id>https://www.slicer.org/w/index.php?title=Documentation/Nightly/FAQ/Registration&amp;diff=59459</id>
		<title>Documentation/Nightly/FAQ/Registration</title>
		<link rel="alternate" type="text/html" href="https://www.slicer.org/w/index.php?title=Documentation/Nightly/FAQ/Registration&amp;diff=59459"/>
		<updated>2018-09-25T19:28:55Z</updated>

		<summary type="html">&lt;p&gt;Inorton: /* The registration transform file saved by Slicer does not seem to match what is shown */&lt;/p&gt;
&lt;hr /&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;
{{#ifeq: {{#titleparts: {{PAGENAME}} | 3 }} | Documentation/{{documentation/version}}/Developers | | ='''User FAQ: {{{1}}}'''=}}&lt;br /&gt;
&amp;lt;/includeonly&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Spatial Orientation, Header, Image Size ==&lt;br /&gt;
=== How do I fix incorrect axis directions? Can I flip an image (left/right, anterior/posterior etc) ? === &lt;br /&gt;
&lt;br /&gt;
Sometimes the header information that describes the orientation and size of the image in physical space is incorrect or missing. Slicer displays images in physical space, in a RAS orientation. If images appear flipped or upside down, the transform that describes how the image grid relates to the physical world is incorrect. In proper RAS orientation, a head should have anterior end at the top in the axial view, look to the left in a sagittal view, and have the superior end at the top in sagittal and coronal views.&amp;lt;br&amp;gt; &lt;br /&gt;
Yes, you can flip images and change the axis orientation of images in slicer. But we urge to use great caution when doing so, since this can introduce subtantial problems if done wrong. Worse than no information is wrong information. '''Below the steps to flip the LR axis of an image''':&amp;lt;br&amp;gt; You may skip steps 5-8 below and download [[Media:Slicer4_FlipAxisTransforms.zip|'''predefined transforms''']]  here. To apply those unzip, drag &amp;amp; drop into Slicer and drag your volume inside the transform.&lt;br /&gt;
#Go to the [[Documentation/{{documentation/version}}/Modules/Data|''Data'' module]], right click on the node labeled &amp;quot;Scene&amp;quot; and select &amp;quot;Insert Transform&amp;quot; from the pulldown menu&lt;br /&gt;
#You should see a new transform node being added to the tree, named &amp;quot;LinearTransform_1&amp;quot; or similar.&lt;br /&gt;
#left click on the volume you wish to flip, and drag it onto the new transform node. You should see a &amp;quot;+&amp;quot; appear in front of the transform node, and clicking on it should reveal the volume now inside/under that transform.&lt;br /&gt;
#make sure you have the image you wish to flip selected and visible in the slice views, preferably all 3 views (sagittal, coronal, axial).&lt;br /&gt;
#Switch to the [[Documentation/{{documentation/version}}/Modules/Transforms|''Transforms'' module]] and (if not selected already) select the newly created transform from the ''Active Transform'' menu.&lt;br /&gt;
#Under ''Transform Matrix'' you see a 4x4 array of ones and zeros. Each row represents an axis direction. We will switch the axis direction by changing the sign of one of the 1s.&lt;br /&gt;
#e.g. to flip left/right: double-click inside the top left field where you see a 1. The number should be high-lighted and change to 1.0&lt;br /&gt;
#replace the 1.0 with &amp;quot;-1.0&amp;quot;, then hit the RETURN key. You should see a flip immediately, assuming you have the volume in the proper view. Depending on which of the axes you want flipped, select the 1 in one of the other rows.&lt;br /&gt;
#When you have the result you want, return to the  [[Documentation/{{documentation/version}}/Modules/Data|''Data'' module]], there '''right''' click on your image and select ''Harden Transform'' from the pulldown menu.&lt;br /&gt;
#The image will move back outside the transform onto the main level, indicating that your change of axis orientation has now been applied. Note there is no Undo for this step. If you change your mind you have to apply the same flip again or reload your volume.&lt;br /&gt;
#Note that the flip will likely also cause a shift, depending on your image origin. You may choose to recenter your image. To do so go to the [[Documentation/{{documentation/version}}/Modules/Volumes|''Volumes'' module]], open the ''Volume Information'' tab and click on the ''Center Volume'' button&lt;br /&gt;
#Note that this change was applied to the header information that stores the physical orientation, '''not''' the image data itself. Hence you will only see this flip in software that reads and accounts this header orientation info.&lt;br /&gt;
#Save your image under a new name, do ''not'' use a format that doesn't store physical orientation info in the header (jpg, gif etc).; also consider saving the transform as documentation to what change you have applied. You can also use these saved transforms as templates to quickly flip an image.&lt;br /&gt;
#Again: the change is saved as part of the image orientation info and not as an actual resampling of the image, i.e. if you save your image and reload it in another software that does not read the image orientation info in the header (or displays in image space only), you will not see the change you just applied.&lt;br /&gt;
To flip the other axes do the same as above but edit the diagonal entries in the 2nd and 3rd row, for flipping anterior-posterior and inferior-superior directions, respectively.&lt;br /&gt;
&lt;br /&gt;
=== How do I fix a wrong image orientation in the header? / My image appears upside down / facing the wrong way / I have incorrect/missing axis orientation ===&lt;br /&gt;
&lt;br /&gt;
*'''Problem:''' My image appears upside down / flipped / facing the wrong way / I have incorrect/missing axis orientation&lt;br /&gt;
*'''Explanation:''' Slicer presents and interacts with images in ''physical'' space, which differs from the way the image is stored by a separate ''transform'' that defines how large the voxels are and how the image is oriented in space, e.g. which side is left or right.  This information is stored in the image header, and different image file formats have different ways of storing this information. If Slicer supports the image format, it should read the information in the header and display the image correctly. If the image appears upside down or with distorted aspect ratio etc, then the image header information is either missing or incorrect. &lt;br /&gt;
*'''Fix:''' See the FAQ above on how to flip an image axis within Slicer. You can also correct the voxel dimensions and the image origin in the ''Volume Information'' tab of the [[Documentation/{{documentation/version}}/Modules/Volumes|''Volumes'' module]], and you can reorient images via the  [[Documentation/{{documentation/version}}/Modules/Transforms|''Transforms'' module]].&lt;br /&gt;
*To fix an axis orientation directly in the header info of an image file:&lt;br /&gt;
:1. load the image into slicer (File: Add Volume, Add Data, Load Scene..)&lt;br /&gt;
:2. save the image back out as ''NRRD (.nhdr)'' format.&lt;br /&gt;
:3. open the ''.nhdr'' with a text editor of your choice. You should see a line that looks like this:&lt;br /&gt;
  space: left-posterior-superior&lt;br /&gt;
  sizes: 448 448 128&lt;br /&gt;
  space directions: (0.5,0,0) (0,0.5,0) (0,0,0.8)&lt;br /&gt;
:4. the three brackets ( ) represent the coordinate axes as defined in the ''space'' line above, i.e. the first one is left-right, the second anterior-posterior, and the last inferior-superior. To flip an axis place a minus sign in front of the respective number, which is the voxel dimension. E.g. to flip left-right, change the line to&lt;br /&gt;
  space directions: ('''-'''0.5,0,0) (0,0.5,0) (0,0,0.8)&lt;br /&gt;
:5. alternatively if the entire orientation is wrong, i.e. coronal slices appear in the axial view etc., you may easier just change the ''space'' field to the proper orientation. Note that Slicer uses ''RAS'' space by default, i.e. first (x) axis = left-'''r'''ight, second (y) axis = posterior-'''a'''nterior, third (z) axis = inferior-'''s'''uperior&lt;br /&gt;
:6. save &amp;amp; close the edited ''.nhdr'' file and reload the image in slicer to see if the orientation is now correct.&lt;br /&gt;
=== Can I undo the &amp;quot;centering&amp;quot; of an image ===&lt;br /&gt;
When importing images, there's a &amp;quot;Center&amp;quot; checkbox, which if checked will reset the image origin to the center of the image grid, and ignore the image origin stored in the header. The same function is available to loaded images in the [[Documentation/{{documentation/version}}/Modules/Volumes|''Volumes'' module]] (Volume Information Tab). Results derived from images have their spatial info stored '''relative''' to that image origin. So fiducial points or label maps obtained from centered images will also be centered, which means they will align with a centered version of the image but not the original one. '''Is there a way to return such data to the original ''uncentered'' position?'''  &amp;lt;br&amp;gt;&lt;br /&gt;
There is no dedicated module or function for that purpose currently implemented, but there are several ways to return data to the position before centering, provided the original image with the old origin is still available. Options are:&lt;br /&gt;
*copy the image origin (or entire spatial orientation info) from the original reference image into the header of the &amp;quot;centered&amp;quot; image. For images stored in a format where the header data is accessible in text format this is fairly straightforward. For other formats with binary headers it will require dedicated software to read the header and re-save the image.&lt;br /&gt;
*create a transform that embodies the shift and apply it to the data. This is probably the most accessible solution. It will work for all forms of data, i.e. fiducial points, labelmaps, surface models etc. To manually obtain such a transform:&lt;br /&gt;
#Load both original and centered image&lt;br /&gt;
#Go to the  [[Documentation/{{documentation/version}}/Modules/Volumes|''Volumes'' module]], open the Volume Information Tab, then select either image and record the &amp;quot;Image Origin&amp;quot; information displayed.  Calculate the difference of the two origins (x1-x2, y1-y2, z1-z2).&lt;br /&gt;
#Go to the  [[Documentation/{{documentation/version}}/Modules/Transforms|''Transforms'' module]] , create a new transform, then enter the origin difference calculated above into the fields for translation (LR= left-right, PA=posterior-anterios, IS=inferior-superior). Note that to replicate the effect of centring the translation vector is centered-uncentered; to go back from centered to uncentered is the inverse of that transform, i.e. uncentered-centered. The &amp;quot;Invert Transform&amp;quot; button in the transforms module lets you switch between the two.&lt;br /&gt;
#Go to the  [[Documentation/{{documentation/version}}/Modules/Data|''Data'' module]]. Drag the centered image and any data derived from it '''into'' the transform.&lt;br /&gt;
#Set fore- &amp;amp; background to original and centered image to verify, set the fade slider halfway so you can see both images. Verify that the two images align once the &amp;quot;centered&amp;quot; image has been placed into the transform.&lt;br /&gt;
#Right click on the meta data (e.g. fiducials) inside the transform, select '''Harden Transform''' from the pulldown menu. The data node will move back out of the transform to the main level to indicate the transform has been applied.&lt;br /&gt;
#Rename the data node (double click) to document that it has shifted. Then save it as a new file. &lt;br /&gt;
[[Media:Slicer_UncenterFiducials.mov‎|'''See here for a screencast describing this procedure to &amp;quot;uncenter&amp;quot; and shift meta data back to the original position''']]. &amp;lt;br&amp;gt;&lt;br /&gt;
For large sets of images calculating the offset manually may not be feasible. Below is a rudimentary python script that will read two or more images (NIfTI format) , calculate the offset and save it as an ITK transform (.tfm) file. You can then import this transform into Slicer and apply it to the data that needs shifting.&lt;br /&gt;
*As another alternative you can also run a quick automated registration of the centered to the uncentered image to obtain a transform. Note that this will look for a match based on image similarity and will not be 100% precise, but likely very close.&lt;br /&gt;
 #! /usr/bin/env python&lt;br /&gt;
 # reads 2 or more NIfTI images and extracts the image center offset to the first as an ITK transform file v1.0&lt;br /&gt;
 # usage: NIICenterOffset2ITK.py RefImg.nii CenteredImg1.nii CenteredImg2.nii ...&lt;br /&gt;
 # output: CenteredImg1_center.tfm CenteredImg2_center.tfm ...&lt;br /&gt;
&lt;br /&gt;
 import nibabel as nib&lt;br /&gt;
 import numpy&lt;br /&gt;
 import sys&lt;br /&gt;
    &lt;br /&gt;
 refimg = nib.load(sys.argv[1]) &lt;br /&gt;
 refhdr = refimg.get_header()&lt;br /&gt;
 reforigin=refhdr.get_qform()[([0,1,2],3)].astype(float)&lt;br /&gt;
 for aImgName in sys.argv[2:]:&lt;br /&gt;
    img = nib.load(aImgName)&lt;br /&gt;
    hdr = img.get_header()&lt;br /&gt;
    origin=hdr.get_qform()[([0,1,2],3)].astype(float)&lt;br /&gt;
    offset=reforigin-origin&lt;br /&gt;
    itk_file = open(aImgName+'.centered.tfm', &amp;quot;w&amp;quot;)&lt;br /&gt;
    itk_file.write('#Insight Transform File V1.0\n#Transform 0\nTransform: AffineTransform_double_3_3\n' )&lt;br /&gt;
    itk_file.write('Parameters: 1 0 0 0 1 0 0 0 1 %f %f %f\n' %( tuple( (reforigin-origin).tolist())) )&lt;br /&gt;
    itk_file.write('FixedParameters: 0 0 0\n')&lt;br /&gt;
    itk_file.close()&lt;br /&gt;
&lt;br /&gt;
=== I have some DICOM images that I want to reslice at an arbitrary angle ===&lt;br /&gt;
There's several ways to go about this. If you wish to register your image to another reference/target image, run one of the automated registration methods. If you wish to realign manually, most efficient way is to use the [[Documentation/{{documentation/version}}/Modules/Transforms|''Transforms'' module]]. Once you have the desired orientation,  you need to apply the new orientation to the image. You can do this in 2 ways:  1) without or 2) with resampling the image data. &lt;br /&gt;
#Without resampling: In the Data module, select the image (inside the transforms node) and select &amp;quot;Harden Transforms&amp;quot; from the pulldown menu. This will write the new orientation in physical space into the image header. This will work only if other software you use and the image format you save it as support this form of orientation information in the image header. &lt;br /&gt;
# With resampling: Go to the  [[Documentation/{{documentation/version}}/Modules/ResampleScalarVectorDWIVolume| ''ResampleScalarVectorDWIVolume'' module]] and create a new image by resampling the original with the new transform. This will incur interpolation blurring but is guaranteed to transfer for all image formats or software.&lt;br /&gt;
For more details on manual transform, see [[Slicer-3-6-FAQ#Can_I_manually_adjust_or_correct_a_registration.3F| this FAQ]] and the [[Slicer_3.6:Training Manual RegistrationTutorial|here]].&lt;br /&gt;
&lt;br /&gt;
=== How do I fix incorrect voxel size / aspect ratio of a loaded image volume? ===&lt;br /&gt;
&lt;br /&gt;
*'''Problem:''' My image appears distorted / stretched / with incorrect aspect ratio&lt;br /&gt;
*'''Explanation:''' Slicer presents and interacts with images in ''physical'' space, which differs from the way the image is stored by a set of separate information that represents the physical &amp;quot;voxel size&amp;quot; and the direction/spatial orientation of the axes. If the voxel dimensions are incorrect or missing, the image will be displayed in a distorted fashion.  This information is stored in the image header. If the information is missing, a default of isotropic 1 x 1 x 1 mm size is assumed for the voxel.&lt;br /&gt;
*'''Fix:''' You can correct the voxel dimensions and the image origin in the Info tab of the [[Documentation/{{documentation/version}}/Modules/Volumes|''Volumes'' module]]. If you know the correct voxel size, enter it in the fields provided (double click to edit). You should see the display update immediately. Ideally you should try to maintain the original image header information from the point of acquisition. Sometimes this information is lost in format conversion. Try an alternative converter or image format if you know that the voxel size is correctly stored in the original image. Alternatively you can try to edit the information in the image header, e.g. save the volume as (NRRD (.nhdr) format and open the &amp;quot;.nhdr&amp;quot; file with a text editor. See FAQ above.&lt;br /&gt;
&lt;br /&gt;
=== The registration transform file saved by Slicer does not seem to match what is shown ===&lt;br /&gt;
When executing the following procedure:&lt;br /&gt;
# Create a transform.&lt;br /&gt;
# Adjust it by adjusting the 6 slider bars in the Transforms module.&lt;br /&gt;
# Save the transform as a .tfm file.&lt;br /&gt;
# Inspect the contents of the .tfm file in a text editor, and compare them to what is shown in the 4x4 matrix in the Transforms module.&lt;br /&gt;
# re-load the .tfm back into slicer and confirm you have the same data as you saved from Slicer.  &lt;br /&gt;
&lt;br /&gt;
You will notice that the original and re-loaded Transforms are identical, but do not match the content of the .tfm file. The issue relates to the difference between Slicer, which uses a &amp;quot;computer graphics&amp;quot; view of the world, and ITK, which uses an &amp;quot;image processing&amp;quot; view of the world. The Slicer transform hierarchy models movement of an object from one spot to another. For example, a transform that has a positive &amp;quot;superior&amp;quot; value wrapped around a volume moves the volume up in patient space.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Conversely, ITK transforms map &amp;quot;backwards&amp;quot;: from the display space back to the original image.  Imagine stepping sequentially through the output pixels: ITK wants to know the transform back to the input pixels ''used to calculate the output''. Additionally ITK transforms are saved in LPS, whereas the Slicer Transform widget uses RAS coordinates.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In Summary:&lt;br /&gt;
#The transform represented in the widget is in RAS.&lt;br /&gt;
#The transform represented in the tfm file is in LPS.&lt;br /&gt;
#The transform represented in the file is the inverse of the transform in the widget, and has the LPS/RAS conversion applied.&lt;br /&gt;
#The order of the parameters in the tfm are the elements of the upper 3x3 of the transform displayed in the widget followed by the elements in the last column of the widget.&lt;br /&gt;
&lt;br /&gt;
Please see this discussion for more information, and code examples:&lt;br /&gt;
&lt;br /&gt;
https://www.slicer.org/wiki/Documentation/Nightly/Modules/Transforms#Transform_files&lt;br /&gt;
&lt;br /&gt;
=== I don't understand your coordinate system. What do the coordinate labels R,A,S and (negative numbers) mean? ===&lt;br /&gt;
&lt;br /&gt;
*It's very important to realize that Slicer displays all images in ''physical'' space, i.e. in mm. This requires orientation and size information that is stored in the image header. How that header info is set and read from the header will determine how the image appears in Slicer. RAS is the abbreviation for ''right'', ''anterior'', ''superior''; indicating in order the relation of the physical axis directions to how the image data is stored. &lt;br /&gt;
*For a detailed description on coordinate systems [[Coordinate_systems|see here]].&lt;br /&gt;
&lt;br /&gt;
=== My image is very large, how do I downsample to a smaller size? ===&lt;br /&gt;
&lt;br /&gt;
Several Resampling modules provide this functionality. If you also have a transform you wish to apply to the volume, we recommend the [[Documentation/{{documentation/version}}/Modules/ResampleScalarVectorDWIVolume|''ResampleScalarVectorDWIVolume'' module]], or the simpler [[Documentation/{{documentation/version}}/Modules/ResampleScalarVolume|''ResampleScalarVolume'' module]]. See [[Documentation/{{documentation/version}}/Modules/Resampling|here for an explanation and overview of '''Resampling''' tools]].&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
'''Resampling in place (changing voxel size)''':&lt;br /&gt;
:1. Go to the [[Documentation/{{documentation/version}}/Modules/Volumes|''Volumes'' module]]&lt;br /&gt;
:2. from the ''Active Volume'' pulldown menu, select the image you wish to downsample&lt;br /&gt;
:3. Open the ''Volume Information'' tab. Write down the voxel dimensions (''Image Spacing'')  and overall image size  (''Image Dimensions''), e.g. 1.2 x 1.2 x 3 mm voxel size, 512 x 512 x 86. You will need this information to determine the amount of down-/up-sampling you wish to apply&lt;br /&gt;
:4. Go to the [[Documentation/{{documentation/version}}/Modules/ResampleScalarVolume|''ResampleScalarVolume'' module]] (found under ''All modules'')&lt;br /&gt;
:5. In the ''Spacing'' field, enter the new desired voxel size. This is the above original voxel size multiplied with your downsampling factor. For example, if you wish to reduce the image to half (in plane), but leave the number of slices,  you would enter a new voxel size of 2.4,2.4,3.&lt;br /&gt;
:6. For ''Interpolation'', check the box most appropriate for your input data: for labelmaps check ''nearest Neighbor'', for 3D MRI or other bandlimited signals check ''hamming''. For most others leave the ''linear'' default.  The sinc interpolator (''hamming, cosine, welch'') and bspline (cubic) interpolators  tend to produce less blurring than ''linear', but may cause overshoot near high contrast edges (e.g. negative intensity values for background pixels)&lt;br /&gt;
:7.''Input Volume'': Select the image you wish to resample&lt;br /&gt;
:8. ''Output Volume'':Select ''Create New Volume'' for output volume, then rename to something meaningful, like your input + suffix &amp;quot;_resampled&amp;quot;&lt;br /&gt;
:9. Click Apply&lt;br /&gt;
:10. For labelmaps: go to the Volumes module and check the Labelmap box in the info tab to turn the resampled volume into a labelmap.&lt;br /&gt;
'''Resampling in place to match another image in size''':&lt;br /&gt;
:1. Go to the  [[Documentation/{{documentation/version}}/Modules/ResampleScalarVectorDWIVolume|''ResampleScalarVectorDWIVolume'' module]]&lt;br /&gt;
:2. ''Input Volume'': Select the image you wish to resample&lt;br /&gt;
:3. ''Output Volume'': Select ''Create New Volume'' for output volume, and rename to something meaningful, like your input + suffix &amp;quot;_resampled&amp;quot;&lt;br /&gt;
:4. ''Reference Volume'': Select the reference image whose size/dimensions you want to match to.&lt;br /&gt;
:5. ''Interpolation Type'': check the box most appropriate for your input data: for labelmaps check ''nn=nearest Neighbor'', for 3D MRI or other bandlimited signals check ''ws=windowed sinc''. For most others leave the ''linear'' default.  The ws and bspline (cubic) interpolators (''hamming, cosine, welch'') tend to produce less blurring than ''linear', but may cause overshoot near high contrast edges (e.g. negative intensity values for background pixels)&lt;br /&gt;
:6. Click Apply. Note that if the input and reference volume do not overlap in physical space, i.e. are roughly co-registered, the resampled result may not contain any or all of the input image. This is because the program will resample in the space defined by the reference image and will fill in with zeros if there is nothing at that location. If you get an empty or clipped result, that is most likely the cause. In that case try to re-center the two volumes before resampling.&lt;br /&gt;
:7. For labelmaps: go to the Volumes module and check the Labelmap box in the info tab to turn the resampled volume into a labelmap.&lt;br /&gt;
'''Resampling in place by specifying new dimensions''':&lt;br /&gt;
:1. Go to the  [[Documentation/{{documentation/version}}/Modules/ResampleScalarVectorDWIVolume|''ResampleScalarVectorDWIVolume'' module]]&lt;br /&gt;
:2. ''Input Volume'': Select the image you wish to resample&lt;br /&gt;
:3. ''Output Volume'': Select ''Create New Volume'' for output volume, and rename to something meaningful, like your input + suffix &amp;quot;_resampled&amp;quot;&lt;br /&gt;
:4. ''Reference Volume'': leave at &amp;quot;none&amp;quot;&lt;br /&gt;
:5. ''Interpolation Type'': check the box most appropriate for your input data: for labelmaps check ''nn=nearest Neighbor'', for 3D MRI or other bandlimited signals check ''ws=windowed sinc''. For most others leave the ''linear'' default.  The ws and bspline (cubic) interpolators (''hamming, cosine, welch'') tend to produce less blurring than ''linear', but may cause overshoot near high contrast edges (e.g. negative intensity values for background pixels)&lt;br /&gt;
:6. Click Apply. Note that if the input and reference volume do not overlap in physical space, i.e. are roughly co-registered, the resampled result may not contain any or all of the input image. This is &lt;br /&gt;
:6. ''Manual Output Parameters'': here you specify the new voxel size / spacing '''and''' dimensions. Note that you need to set both. If only the voxel size is specified, the image is resampled but retains its  original dimensions (i.e. empty/zero space). If only the dimensions are specified the image will be resampled starting at the origin and cropped but not resized.&lt;br /&gt;
::*new voxel size: calculate the new voxel size and enter in the ''Spacing'' field, as described above in in '''Resampling in place'' above, see step #5&lt;br /&gt;
::*new image dimensions: enter new dimensions under ''Size''. To prevent clipping, the output field of view FOV = voxel size * image dimensions, should match the input&lt;br /&gt;
:7. leave rest at default and click ''Apply''&lt;br /&gt;
:8. For labelmaps: go to the Volumes module and check the Labelmap box in the info tab to turn the resampled volume into a labelmap.&lt;br /&gt;
&lt;br /&gt;
== Errors ==&lt;br /&gt;
=== Registration failed with an error. What should I try next? ===&lt;br /&gt;
&lt;br /&gt;
*'''Problem:''' automated registration fails, status message says &amp;quot;completed with error&amp;quot; or similar.&lt;br /&gt;
*'''Explanation:''' Registration methods are mostly implemented as commandline modules, where the input to the algorithm is provided as temporary files and the algorithm then seeks a solution independently from the activity of the Slicer GUI. you will notice that you're free to continue using other Slicer functions while a registration is running. Several reasons can lead to failure, most commonly they are wrong or inconsistent input or lack of convergence if images are too far apart initially.&lt;br /&gt;
#check your input: &lt;br /&gt;
##did you provide both a fixed and a moving image? &lt;br /&gt;
##did you select an output (transform and/or new output volume)?&lt;br /&gt;
##do the two images have any overlap? Can you see them both in the slice views? If not try to [[Documentation/{{documentation/version}}/FAQ#How_do_I_initialize.2Falign_images_with_very_different_orientations_and_no_overlap.3F|recenter (see &amp;quot;Manual Recenter&amp;quot; in FAQ above)]]. When rerunning the registration, try selecting an initializer&lt;br /&gt;
##are inputs consistent? E.g. [[Documentation/{{documentation/version}}/Modules/BRAINSFit|''General Registration (BRAINS)'' module]] will complain if you check a &amp;quot;BSpline&amp;quot; registration phase but do not select a BSpline output transform, or if you request masking and do not specify masking input or output.&lt;br /&gt;
#if above checks reveal nothing, open the ''Error Log'' window (Window Menu) and scroll to the bottom to see the most recent entries related to the registration. Usually you will see a ''commandline'' entry that shows which arguments were given to the algorithm, and a ''standard output'' or similar that lists what the algorithm returned. More detailed error info can be found in either this entry, or in the ''ERROR: ...&amp;quot; line at the top of the list. Click on the corresponding line and look for explanation in the provided text. If there was a problem with the input arguments or the that would be reported here.&lt;br /&gt;
#If the Error log does not provide useful clues, try varying some of the parameters. Note that if the algorithm aborts/fails right away and returns immediately with an error, most likely some input is wrong/inconsistent or missing.&lt;br /&gt;
#check the initial misalignment, if images are too far apart and there is no overlap, registration may fail. Consider initialization with a prior manual alignment, centering the images or using one of the initialization methods provided by the modules&lt;br /&gt;
#write to the  [mailto:slicer-users@bwh.harvard.edu '''Slicer user group''' (slicer-users@bwh.harvard.edu)] and inform them of the error. We're keen on learning so we can improve the program. The fastest and best reply you will get if you copy and paste the error messages found in the Error Log into your mail.&lt;br /&gt;
&lt;br /&gt;
=== Registration result is wrong or worse than before? ===&lt;br /&gt;
&lt;br /&gt;
*'''Problem:''' automated registration provides an alignment that is insufficient, possibly worse than the initial position&lt;br /&gt;
*'''Explanation:''' The automated registration algorithms (except for fiducial and manual registration) in Slicer operate on image intensity and try to move images so that similar image content is aligned. This is influenced by many factors such as image contrast, resolution, voxel anisotropy, artifacts such as motion or intensity inhomogeneity, pathology etc, the initial misalignment and the parameters selected for the registration.&lt;br /&gt;
#re-run the registration with parameter modifications:&lt;br /&gt;
##if images have little initial overlap or are far apart in orientation, try a (different) initializer: e.g. [[Documentation/{{documentation/version}}/Modules/BRAINSFit|''General Registration (BRAINS)'' module]]  has several initializers, details in their documentation and also [[Documentation/{{documentation/version}}/FAQ#How_do_I_initialize.2Falign_images_with_very_different_orientations_and_no_overlap.3F|in this FAQ above]].&lt;br /&gt;
##do the two images have any overlap? Can you see them both in the slice views? If not try to [[Documentation/{{documentation/version}}/FAQ#How_do_I_initialize.2Falign_images_with_very_different_orientations_and_no_overlap.3F|recenter (see &amp;quot;Manual Recenter&amp;quot; in FAQ above)]]. When &lt;br /&gt;
##try a lower DOF registration first to see if that fails. If the lower DOF fails, subsequent ones will also. For nonrigid registration, try adding intermediate steps, such as a similarity (7 DOF) or Affine (12 DOF) transform.&lt;br /&gt;
##if automated initializers do not help, try a [[Documentation/{{documentation/version}}/FAQ#Can_I_manually_adjust_or_correct_a_registration.3F|manual initial alignment (see FAQ above)]]. This need not be perfect, as long as it establishes good overlap and roughly same direction. Then try rerunning the registration using the manual transform as a starting point. (''Initialization Transform'') in the  [[Documentation/{{documentation/version}}/Modules/BRAINSFit|''General Registration (BRAINS)'' module]].&lt;br /&gt;
##if initial overlap is ok but registration &amp;quot;drifts away&amp;quot;, there is either insufficient sample data or distracting image content. Try increasing the number of sample points. See [[Documentation/{{documentation/version}}/FAQ#How_many_sample_points_should_I_choose_for_my_registration.3F|FAQ below for estimates of sample points]].&lt;br /&gt;
##'''insufficient contrast:''' consider adjusting the ''Histogram Bins'' (where avail.) to tune the algorithm to weigh small intensity variations more or less heavily&lt;br /&gt;
##''strong anisotropy:''' if one or both of the images have strong voxel anisotropy of ratios 5 or more, rotational alignment may become increasingly difficult for an automated method. Consider increasing the sample points and reducing the ''Histogram Bins''. &lt;br /&gt;
##'''distracting image content:''' pathology, strong edges, clipped FOV with image content at the border of the image can easily dominate the cost function driving the registration algorithm. '''Masking''' is a powerful remedy for this problem: create a mask (binary labelmap/segmentation) that excludes the distracting parts and includes only those areas of the image where matching content exists. This requires one of the modules that supports masking input, such as [[Documentation/{{documentation/version}}/Modules/BRAINSFit|''General Registration (BRAINS)'' module]]  or  [[Documentation/{{documentation/version}}/Modules/ExpertAutomatedRegistration|''Expert Automated Registration'' module]] . Next best thing to use with modules that do not support masking is to mask the image manually and create a temporary masked image where the excluded content is set to 0 intensity; the [[Documentation/{{documentation/version}}/Modules/MaskScalarVolume|''MaskScalarVolume'' module]] performs this task.&lt;br /&gt;
##you can adjust/correct an obtained registration manually, within limits, as outlined  [[Documentation/{{documentation/version}}/FAQ#Can_I_manually_adjust_or_correct_a_registration.3F|manual initial alignment in this FAQ above]].&lt;br /&gt;
&lt;br /&gt;
=== Registration results are inconsistent and don't work on some image pairs. Are there ways to make registration more robust? ===&lt;br /&gt;
&lt;br /&gt;
The key parameters that influence registration robustness are the number of sample points, the initial degrees of freedom of the transform, the type of similarity metric and the initial misalignment and image contrast/content differences.  particularly initialization methods that seek a first alignment before beginning the optimization can make things worse. If initial position is already sufficiently close (i.e. more than 70% overlap and less than 20% rotational misalignment), consider turning off initialization if available (e.g. in  [[Documentation/{{documentation/version}}/Modules/BRAINSFit|''General Registration (BRAINS)'' module]] (under Registration menu) and the [[Documentation/{{documentation/version}}/Modules/ExpertAutomatedRegistration|''Expert Automated Registration'' module]] )&lt;br /&gt;
Try increasing the sample points. [[Documentation/{{documentation/version}}/FAQ#How_many_sample_points_should_I_choose_for_my_registration.3F|Guidelines on selecting sample points are given here]]. The degrees of freedom usually are given by the overall task and not subject to variation, but depending on initial misalignment,  robustness can greatly improve by an iterative approach that gradually increases DOF rather than starting with a high DOF setting. The [[Documentation/{{documentation/version}}/Modules/BRAINSFit|''General Registration (BRAINS)'' module]] and [[Documentation/{{documentation/version}}/Modules/ExpertAutomatedRegistration|''Expert Automated Registration'' module]] both allow prescriptions of iterative DOF. &amp;lt;br&amp;gt;&lt;br /&gt;
If using a cost/criterion function other than mutual information (MI), note that MI tends to be the most forgiving/robust toward differences in image contrast. &amp;lt;br&amp;gt;&lt;br /&gt;
Also see the [[Category:Documentation/{{documentation/version}}/Modules/Registration|''Slicer Registration Overview Page'' for help on selecting registration methods]].&lt;br /&gt;
&lt;br /&gt;
=== How do I register images that are very far apart / do not overlap ===&lt;br /&gt;
&lt;br /&gt;
*'''Problem:''' when you place one image in the background and another in the foreground, the one in the foreground will not be visible (entirely) when switching bak &amp;amp; forth&lt;br /&gt;
*'''Explanation:'''Slicer chooses the field of view (FOV) for the display based on the image selected for the background. The FOV will therefore be centered around what is defined in that image's origin. If two images have origins that differ significantly, they cannot be viewed well simultaneously.&lt;br /&gt;
*'''Fix:''' recenter one or both images as follows:&lt;br /&gt;
:1. Go to the [[Documentation/{{documentation/version}}/Modules/Volumes|''Volumes'' module]]&lt;br /&gt;
:2. Select the image to recenter from the ''Active Volume'' menu&lt;br /&gt;
:3. Select/open the ''Volume Information'' tab.&lt;br /&gt;
:4. Click the ''Center Volume'' button. You will notice how the ''Image Origin'' numbers displayed above the button change. If you have the image selected as foreground or background, you may see it move to a new location.&lt;br /&gt;
:5. Repeat steps 2-4 for the other image volumes &lt;br /&gt;
:6. In the slice view menu, click on the ''Fit to Window'' button (a small square next to the pin in the top left corner of each view) [[Image:FitToWindowIcon.png|30px|right]]&lt;br /&gt;
:7. Images should now be roughly in the same space. Note that this re-centering is considered a change to the image volume, and Slicer will mark the image for saving next time you select ''Save''.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== How do I initialize/align images with very different orientations and no overlap? ===&lt;br /&gt;
&lt;br /&gt;
I would like to register two datasets, but the centers of the two images are so different that they don't overlap at all. Is there a way to pre-register them automatically or manually to create an initial starting transformation?&amp;lt;br&amp;gt;&lt;br /&gt;
*'''Manual Recenter:''' See the [[Documentation/{{documentation/version}}/FAQ#How_do_I_register_images_that_are_very_far_apart_.2F_do_not_overlap|FAQ above for re-centering images]]&lt;br /&gt;
:1. Go to the [[Documentation/{{documentation/version}}/Modules/Volumes|''Volumes'' module]]&lt;br /&gt;
:2. Select the image to recenter from the ''Active Volume'' menu&lt;br /&gt;
:3. Select/open the ''Volume Information'' tab.&lt;br /&gt;
:4. Click the ''Center Volume'' button. You will notice how the ''Image Origin'' numbers displayed above the button change. If you have the image selected as foreground or background, you may see it move to a new location.&lt;br /&gt;
:5. Repeat steps 2-4 for the other image volumes &lt;br /&gt;
:6. In the slice view menu, click on the ''Fit to Window'' button (a small square next to the pin in the top left corner of each view) &lt;br /&gt;
:7. Images should now be roughly in the same space. Note that this re-centering is considered a change to the image volume, and Slicer will mark the image for saving next time you select ''Save''.&lt;br /&gt;
&lt;br /&gt;
*'''Automatic Initialization:''' Most registration tools have initializers that should take care of the initial alignment in a scenario you described. However since they often are based on heuristics they may work well in some cases and not in others. The two modules that offer the most initializer options are  [[Documentation/{{documentation/version}}/Modules/BRAINSFit|''General Registration (BRAINS)'' module]] (under Registration menu) and the [[Documentation/{{documentation/version}}/Modules/ExpertAutomatedRegistration|''Expert Automated Registration'' module]].&amp;lt;br&amp;gt;&lt;br /&gt;
* [[Documentation/{{documentation/version}}/Modules/BRAINSFit|''General Registration (BRAINS)'' module]]  initializers:&lt;br /&gt;
**''Initialization Transform:''  here you can specify a transform from which to start. You can perform a manual alignment (see here for tutorial) and then feed this as initializer here.&lt;br /&gt;
**''Initialization Transform Mode:''  these options generate automated initializations for you:&lt;br /&gt;
***&amp;quot;Off''  assumes that the physical space of the images are close, and that centering in terms of the image Origins is a good starting point.&lt;br /&gt;
***''useCenterOfHeadAlign'': recommended for registering brain MRI where all or most of the head is within the FOV&lt;br /&gt;
***''useMomentsAlign'': recommended for image pairs with similar contrast, scale and content.&lt;br /&gt;
***''useGeometryAlign'': recommended for image pairs with similar FOV for both objects. This aligns the image grid volumes disregarding of content.&lt;br /&gt;
***''useCenterOfROIAlign&amp;quot;: recommended if you have a mask for each image that defines the regions you want registered. This will initialize based on those two masks.&lt;br /&gt;
***Tip: yo can run the registration with just the initializer to see what kind of transformation it produces. In that case select a ''Slicer Linear Transform'' output but leave all boxes under ''Registration Phases'' unchecked.&lt;br /&gt;
*  [[Documentation/{{documentation/version}}/Modules/ExpertAutomatedRegistration|''ExpertAutomatedRegistration'' module]] initializers:&lt;br /&gt;
***&amp;quot;None'' directly starts with optimization from the current position&lt;br /&gt;
***''CentersOfMass'': recommended for image pairs with similar contrast, scale and content. Similar to ''useMomentsAlign'' above.&lt;br /&gt;
***''SecondMoments'': same as above, but also calculating  (principal) axis directions&lt;br /&gt;
***''Image Centers&amp;quot;: similar to ''useGeometryAlign'' above: recommended for image pairs with similar FOV for both objects. This aligns the image grid volumes disregarding of content.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Can I manually adjust or correct a registration? ===&lt;br /&gt;
&lt;br /&gt;
Yes for linear (rigid to affine) transforms; not without resampling for nonrigid transforms.&amp;lt;br&amp;gt;&lt;br /&gt;
The automated registration algorithms (except for  fiducial and surface registration) in Slicer operate on image intensity and try to move images so that similar image content is aligned. This is influenced by many factors such as image contrast, resolution, voxel anisotropy, artifacts such as motion or intensity inhomogeneity, pathology etc, the initial misalignment and the parameters selected for the registration. Before attempting manual correction, it is usually advisable to retry an automated run with modified parameters, additional initializers or masks.&lt;br /&gt;
you can adjust/correct an obtained registration manually, within limits.  There's a brief (no sound) video that demonstrates the procedure here:[[Media:Slicer4_ManualRegistration.mov‎| '''Manual Registration Movie''' (2 min)]]  &lt;br /&gt;
If the transform is linear, i.e. a rigid or affine transform, you can access the rigid components (translation and rotation) of that transform via the [[Documentation/{{documentation/version}}/Modules/Transforms|''Transforms'' module]]. Or (maybe safer) you can create an additional new transform and nest the old one inside it. Then once you approve of the adjustment merge the two (via ''Harden Transform'')&lt;br /&gt;
#Go to the [[Documentation/{{documentation/version}}/Modules/Data|''Data'' module]], right click on the node labeled &amp;quot;Scene&amp;quot; and select &amp;quot;Insert Transform&amp;quot; from the pulldown menu&lt;br /&gt;
#You should see a new transform node being added to the tree, named &amp;quot;LinearTransform_1&amp;quot; or similar.&lt;br /&gt;
#left click on the volume you wish to register, and drag it onto the new transform node. You should see a &amp;quot;+&amp;quot; appear in front of the transform node, and clicking on it should reveal the volume now inside/under that transform.&lt;br /&gt;
#make sure you have the image for which you wish to adjust the registration selected and visible in the slice views, preferably all 3 views (sagittal, coronal, axial).&lt;br /&gt;
#Switch to the [[Documentation/{{documentation/version}}/Modules/Transforms|''Transforms'' module]] and (if not selected already) select the newly created transform from the ''Active Transform'' menu.&lt;br /&gt;
#adjust the translation and rotation sliders to adjust the current position. To get a finer degree of control, enter smaller numbers for the translation limits and enter rotation angles numerically in increments of a few degrees at a time&lt;br /&gt;
&lt;br /&gt;
== Diffusion ==&lt;br /&gt;
&lt;br /&gt;
=== How do I register a DWI image dataset to a structural reference scan? (Cookbook) ===&lt;br /&gt;
&lt;br /&gt;
*'''Problem:''' The DWI/DTI image is not in the same orientation as the reference image that I would like to use to locate particular anatomy; the DWI image is distorted and does not line up well with the structural images&lt;br /&gt;
*'''Explanation:''' DWI images are often acquired as EPI sequences that contain significant distortions, particularly in the frontal areas. Also because the image is acquired before or after the structural scans, the subject may have moved in between and the position is no longer the same. &lt;br /&gt;
*'''Fix:''' obtain a baseline image from the DWI sequence, register that with the structural image and then apply the obtained transform to the DTI tensor. The two chief issues with this procedure deal with the difference in image contrast between the DWI and the structural scan, and with the common anisotropy of DWI data.&lt;br /&gt;
* Overall Strategy and detailed instructions for registration &amp;amp; resampling can be found in our [[Documentation/{{documentation/version}}/FAQ:DWI_Registration|'''DWI registration cookbook''']]&lt;br /&gt;
* you can find example cases in the [http://na-mic.org/Wiki/index.php/Projects:RegistrationDocumentation:UseCaseInventory:BrainIntraDTI '''DWI chapter of the Slicer Registration Case Library'''], which includes example datasets and step-by-step instructions. Find an example closest to your scenario and Slicer version and perform the registration steps recommended there.&lt;br /&gt;
&lt;br /&gt;
=== Is there a way to perform an Eddy current correction on DWI in Slicer ===&lt;br /&gt;
There is a way, you need to download the GTRACT extension (you can get it from the menu View-&amp;gt;Extension Manager)&lt;br /&gt;
Once you have it you will see a new module category under the diffusion one called &amp;quot;GTRACT&amp;quot;.&lt;br /&gt;
Within this category there is a module called &amp;quot;Coregister B-values&amp;quot;.&lt;br /&gt;
This module takes a DWI image and outputs a DWI image in which every DWI is co-registered to one of the B0 images (by default the first one), this can be regarded as motion correction. Within this module there is a checkbox in the &amp;quot;Registration Parameters&amp;quot; section: &amp;quot;Eddy Current Correction&amp;quot;. This will tune some of the registration parameters such that some Eddy Current artifacts are corrected.&lt;br /&gt;
&lt;br /&gt;
== Masking ==&lt;br /&gt;
&lt;br /&gt;
=== What's the purpose of masking / VOI in registration? / What does the masking option in registration accomplish ?===&lt;br /&gt;
&lt;br /&gt;
The masking option is a very effective tool to focus the registration onto the image content that is most important. It is often the case that the  alignment of the two images is more important in some areas than others. Automated registration based on image intensity is easily dominated by the portions in the image that contain the most contrast/content. If you have much content that is present in only one image, masking that area out will prevent it from leading the registration astray. ''Masking'' provides the opportunity to specify the important regions and make the algorithm ignore the image content outside the mask. This does not mean that the rest is not registered, but rather that it moves along passively, i.e. areas outside the mask do not actively contribute to the cost function that determines the quality of the match. Note the mask defines the areas to ''include'', i.e. to exclude a particular region, build a mask that contains the entire object/image except that region.&lt;br /&gt;
*'''Note:''' masking within the registration is different from feeding a masked/stripped image as input, where areas of no interest have been erased. Such masking can still produce valuable results and is a viable option if the module in question does not provide a direct masking option. But direct masking by erasing portions of the image content can produce sharp edges that registration methods can lock onto. If the edge becomes dominant then the resulting registration will be only as good as the accuracy of the masking. That problem does not occur when using masking option within the module.&lt;br /&gt;
*The following modules currently (v.3.6.1) provide masking:&lt;br /&gt;
** [[Documentation/{{documentation/version}}/Modules/BRAINSFit|''General Registration (BRAINS)'' module]] : in the ''Mask Option'' tab, you can specify a mask for both fixed and moving image. Note that you need to specify both and that both need to be labelmaps with value 1 in areas you wish included and 0 elsewhere. Also both mask images must be the same size (image dimensions) as the image being registered; i.e. if you register two images of different size you cannot use the same mask for both, because the mask for the fixed image must match the fixed image size and the mask for the moving image must match the moving image size. But you can use the  [[Documentation/{{documentation/version}}/Modules/ResampleScalarVectorDWIVolume|''ResampleScalarVectorDWIVolume'' module]] to resample one mask to the resolution of the other (use the appropriate image as ''Reference'') and then you can use it.&lt;br /&gt;
**  [[Documentation/{{documentation/version}}/Modules/ExpertAutomatedRegistration|''Expert Automated Registration'' module]] see in the ''Advanced Registration Parameters'' tab:you can specify 1 mask for the fixed image only. Mask should be a labelmap with value 1 in areas you wish included and 0 elsewhere.&lt;br /&gt;
&lt;br /&gt;
=== How do I generate a mask and what should it look like ? ===&lt;br /&gt;
The purpose of masking (see above) is to exclude any parts of the image that are present in only one of the images yet large enough to distract the registration algorithm as it is trying to find a match for something that doesn't exist. So your mask should focus on excluding those (irrelevant) aspects of the image. Also if you have deformations in the image and care about accuracy in one region more than another you would center the mask around that region. There is a set of screencasts dedicated to quick mask building here:&lt;br /&gt;
[http://wiki.slicer.org/slicerWiki/index.php/Documentation/Nightly/RegistrationVideoTutorials Registration Video Tutorials]&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Basically you can use any segmentation tool in Slicer that produces a labelmap.&lt;br /&gt;
Some important things to remember with masking are:&lt;br /&gt;
* masks need not be super accurate, since in most cases only a subset of points inside the mask is used to drive the registration.&lt;br /&gt;
*increase the number of sample points from what you would use for the entire image, since you will loose points that fall outside the mask&lt;br /&gt;
* there must be a good amount of initial overlap between the masks for the registration algorithm to find a match&lt;br /&gt;
*if there are prominent edges important for the registration, make sure they are inside the mask. The dilation tool in the editor is a good way to enlarge masks. The video tutorials above do show how to do that. There's a special video comparing registration with and without the dilation (&amp;quot;B-spline registration with masking&amp;quot;)&lt;br /&gt;
* you need a mask for both the fixed and the moving image.&lt;br /&gt;
&lt;br /&gt;
There are many example cases in the [http://wiki.slicer.org/slicerWiki/index.php/Documentation:Nightly:Registration:RegistrationLibrary '''Slicer Registration Library'''] that demonstrate the use of masks, e.g.:&lt;br /&gt;
*[http://wiki.slicer.org/slicerWiki/index.php/Documentation:Nightly:Registration:RegistrationLibrary:RegLib_C06 Case 06 (Breast MRI)]&lt;br /&gt;
*[http://wiki.slicer.org/slicerWiki/index.php/Documentation:Nightly:Registration:RegistrationLibrary:RegLib_C07 Case 07 (prostate MRI)]&lt;br /&gt;
*[http://wiki.slicer.org/slicerWiki/index.php/Documentation:Nightly:Registration:RegistrationLibrary:RegLib_C12 Case 12 (abdominal CT)]&lt;br /&gt;
*[http://wiki.slicer.org/slicerWiki/index.php/Documentation:Nightly:Registration:RegistrationLibrary:RegLib_C17 Case 17 (interventional MRI-CT)]&lt;br /&gt;
&lt;br /&gt;
=== Which registration methods offer masking? ===&lt;br /&gt;
[[Image:Slicer41VerifiedIcon.png|40px|left]]&lt;br /&gt;
By masking we mean to selectively include only parts of an image to &amp;lt;br&amp;gt; selectively participate (i.e contribute to the optimization) . Masking is supported directly by&lt;br /&gt;
*the [[Documentation/{{documentation/version}}/Modules/BRAINSFit|''General Registration (BRAINS)'' module]]&lt;br /&gt;
*the [[Documentation/{{documentation/version}}/Modules/ExpertAutomatedRegistration|''Expert Automated Registration'']] )module&lt;br /&gt;
Note that the use of masks differs among these: &amp;quot;Expert Auto&amp;quot; requires a binary mask for fixed image only, while &amp;quot;General BRAINS&amp;quot; requires masks for both fixed and moving image. Expected is a label map with values 0 and 1, 1 being the regions to include.&lt;br /&gt;
&lt;br /&gt;
=== Is there a function to convert a box ROI into a volume labelmap? ===&lt;br /&gt;
&lt;br /&gt;
The [[Documentation/{{documentation/version}}/Extensions/VolumeClip ''Volume clip with ROI box'' module]] can fill a volume inside a region and outside the region with two different values.&lt;br /&gt;
&lt;br /&gt;
Slicer version 3.6 supports conversion of a box ROI into a labelmap via the [[Documentation/{{documentation/version}}/Modules/CropVolume|''Crop Volume'' module]]. This function has not (yet) been ported to Slicer4.  You can create a new ROI box or select an existing one. You must select an image volume to crop for the operation, even if you're only interested in the ROI labelmap. You need not select a dedicated output for the labelmap, it is generated automatically when the cropped volume is produced, and will be called ''Subvolume_ROI_Label'' in the MRML tree. After creating the box ROI labelmap, simply delete the cropped volume and other output like the &amp;quot;''...resample-scale-1.0&amp;quot;'' volume.&amp;lt;br&amp;gt;&lt;br /&gt;
Likely you will need the volume with the same dimension and pixel spacing as the reference image. The box volume produced above has the correct dimension, but is only 1 voxel in size. Hence there is a second step required, which is to resample the ''Subvolume_ROI_Label'' to the same resolution: use the [[Documentation/{{documentation/version}}/Modules/ResampleScalarVectorDWIVolume|''ResampleScalarVectorDWIVolume'' module]] and select the appropriate reference and ''Nearest Neighbor'' as interpolation method. Finally go to the ''Volumes'' module and check the ''Labelmap'' box in the info tab to turn the volume into a labelmap.&lt;br /&gt;
&lt;br /&gt;
=== I have to manually segment a large number of slices. How can I make the process faster? ===&lt;br /&gt;
Contour every other slice, then run a Dilate and an Erode operation.&lt;br /&gt;
For further speed increase (at the cost of losing more details), you may contour just every 3rd or 4th slice and then run Dilate multiple times (until all the holes are filled in) and then run Erode as many times as you ran Dilate. You can also subsample your image first, then edit, and finally upsample again and use the SmoothLabelmap module to reduce artifacts. See FAQ below for examples on quick segmentation methods.&lt;br /&gt;
&lt;br /&gt;
=== How can I quickly generate a mask image ? ===&lt;br /&gt;
Several tools exist to interactively segment structures. A collection of short video examples demonstrating the methods can be found here : [[Documentation/{{documentation/version}}/RegistrationVideoTutorials#Registration_Masking:_How_do_I_quickly_generate_a_mask_for_use_in_registration.3F|'''Video Tutorials on Mask generation''']]&lt;br /&gt;
&lt;br /&gt;
== Parameters &amp;amp; Concept ==&lt;br /&gt;
&lt;br /&gt;
=== What's the difference between Rigid and Affine registration? ===&lt;br /&gt;
&lt;br /&gt;
Rigid registration is a transform with 6 degrees of freedom (DOF): 3 translations (one along each axis) and 3 rotations (one around each axis). An affine registration includes 12 DOF, i.e. 3 additional DOF for scaling (along each axis) and shearing. So strictly speaking an affine transform is a non-rigid transform, even though linear, because the volume can distort. However in practice by ''non-rigid'' transform one usually refers to nonlinear transforms with more than 12 DOF, e.g. BSpline or polynomial models.&lt;br /&gt;
&lt;br /&gt;
=== What's the difference between Affine and BSpline registration? ===&lt;br /&gt;
&lt;br /&gt;
An affine registration includes 12 DOF, i.e. 3 for translations (one along each axis),  3 rotations (one around each axis), 3  for scaling (along each axis) and 3 for shearing. So strictly speaking an affine transform is a non-rigid transform, even though linear, because the volume can distort. However in practice by non-rigid transform one usually refers to nonlinear transforms with more than 12 DOF, e.g. BSpline or polynomial models. A BSpline registration employs a nonlinear nonrigid model that allows individual regions of the image to distort independently, but enforcing smooth transitions between them.  A BSpline transform is not described by a 4x4 matrix like the affine model, but by a list of displacement vectors for each point along a prescribed grid. E.g. a 3x3x3 BSpline grid has 27 points that can move independently, yielding 27 DOF; a 5x5x5 grid analogously has 125 DOF etc.&lt;br /&gt;
&lt;br /&gt;
=== What's the difference between the various registration methods listed in Slicer? ===&lt;br /&gt;
&lt;br /&gt;
Most of the registration modules use the same underlying ITK registration algorithm for cost function and optimization, but differ in implementation on parameter selection, initialization and the type of image toward which they have been tailored. To help choose the best one for you '''based on the method or available options''', an [[Category:Documentation/{{documentation/version}}/Modules/Registration|overview of registration methods can be found here]]. &amp;lt;br&amp;gt;&lt;br /&gt;
To help choose '''based on a particular image type and content''', you will find many example cases incl. step-by-step instructions and discussions on the particular registration challenges in the [http://na-mic.org/Wiki/index.php/Projects:RegistrationDocumentation:UseCaseInventory '''Slicer Registration Library''']. The library is organized in several different ways, e.g. consult this [http://na-mic.org/Wiki/index.php/Projects:RegistrationDocumentation:RegLibTable '''sortable table''' with all cases and the method used].&amp;lt;br&amp;gt;&lt;br /&gt;
Note that registration methods are in continuous development, and not all cases in the [http://na-mic.org/Wiki/index.php/Projects:RegistrationDocumentation:UseCaseInventory ''Registration Library''], may be updated for the latest version. To see which version they were verified on, check the icon in the title of the case page.&lt;br /&gt;
&lt;br /&gt;
=== How many sample points should I choose for my registration? ===&lt;br /&gt;
&lt;br /&gt;
*'''Problem:''' unsure what the ''Sample Points'' setting means or how I could use it to improve my registration.&lt;br /&gt;
*'''Explanation:'''All registration modules contain a parameter field that controls how much of the image is sampled when performing an automated registration. The unit is often an absolute count, but in some cases also a percentage. Default settings also vary among modules. The number of samples is an important setting that determines both registration speed and quality. If the sample number is too small, registration may fail because it is driven by image content that insufficiently represents the image. If sample number is too large, registration can slow down significantly.&lt;br /&gt;
*'''Fix:''' If registration speed is not a major issue, better to err on the side of larger samples. Most default settings are chosen to yield relatively fast registrations and for most of today's image represent only a small percentage.  Below the defaults for the different registration modules, for version 3.6.1:&lt;br /&gt;
:'''Defaults Used in Slicer Modules v.3.6.1'''&lt;br /&gt;
:*[[Documentation/{{documentation/version}}/Modules/BSplineDeformableRegistration|''BSpline Deformable Registration'' module]]: 50,000&lt;br /&gt;
:*[[Documentation/{{documentation/version}}/Modules/ExpertAutomatedRegistration|''Expert Automated'' module]] Rigid 1%;  Affine 2%,  BSpline 10%&lt;br /&gt;
:*[[Documentation/{{documentation/version}}/Modules/BRAINSFit|''General Registration (BRAINS)'' module]]: 100,000&lt;br /&gt;
 &lt;br /&gt;
The table below relates total sample points and percentages to the most common image sizes. Also consider that sample points are chosen randomly so that some points may fall outside the actual object to be registered. That is not a bad thing per se, some background points are important, but not if they are too far from the edges of the object. So consider both total image size as well as the percentage of the image field of view that your object of interest obtains. E.g. if your object fills only half the image, double the sample points to get the desired amount of points within the object.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable sortable labelpage labelpagetable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Image Size&lt;br /&gt;
! Total Points	&lt;br /&gt;
! 10,000&lt;br /&gt;
! 50,000&lt;br /&gt;
! 100,000&lt;br /&gt;
! 200,000&lt;br /&gt;
! 1%&lt;br /&gt;
! 2%	&lt;br /&gt;
! 5%	&lt;br /&gt;
! 10%	&lt;br /&gt;
! 20%&lt;br /&gt;
|-&lt;br /&gt;
| 128 x 128 x 64&lt;br /&gt;
|1048576&lt;br /&gt;
|1.0%&lt;br /&gt;
|4.8%&lt;br /&gt;
|9.5%&lt;br /&gt;
|19.1%&lt;br /&gt;
|~10000&lt;br /&gt;
|~20000&lt;br /&gt;
|~52500&lt;br /&gt;
|~100000&lt;br /&gt;
|~200000&lt;br /&gt;
|-&lt;br /&gt;
|-&lt;br /&gt;
| 256 x 256 x 30&lt;br /&gt;
|1966080&lt;br /&gt;
|0.5%&lt;br /&gt;
|2.5%&lt;br /&gt;
|5.1%&lt;br /&gt;
|10.2%&lt;br /&gt;
|~20000&lt;br /&gt;
|~40000&lt;br /&gt;
|~97500&lt;br /&gt;
|~200000&lt;br /&gt;
|~400000&lt;br /&gt;
|-&lt;br /&gt;
|-&lt;br /&gt;
| 256 x 256 x 120&lt;br /&gt;
|7864320&lt;br /&gt;
|0.1%&lt;br /&gt;
|0.6%&lt;br /&gt;
|1.3%&lt;br /&gt;
|2.5%&lt;br /&gt;
|~77500&lt;br /&gt;
|~150000&lt;br /&gt;
|~400000&lt;br /&gt;
|~775000&lt;br /&gt;
|~1500000&lt;br /&gt;
|-&lt;br /&gt;
|-&lt;br /&gt;
| 192 x 192 x 192&lt;br /&gt;
|7077888&lt;br /&gt;
|0.1%&lt;br /&gt;
|0.7%&lt;br /&gt;
|1.4%&lt;br /&gt;
|2.8%&lt;br /&gt;
|~70000&lt;br /&gt;
|~150000&lt;br /&gt;
|~350000&lt;br /&gt;
|~700000&lt;br /&gt;
|~1500000&lt;br /&gt;
|-&lt;br /&gt;
|-&lt;br /&gt;
| 512 x 512 x 48&lt;br /&gt;
|12582912&lt;br /&gt;
|0.1%&lt;br /&gt;
|0.4%&lt;br /&gt;
|0.8%&lt;br /&gt;
|1.6%&lt;br /&gt;
|~125000&lt;br /&gt;
|~250000&lt;br /&gt;
|~625000&lt;br /&gt;
|~1250000&lt;br /&gt;
|~2500000&lt;br /&gt;
|-&lt;br /&gt;
|-&lt;br /&gt;
| 256 x 256 x 256&lt;br /&gt;
|16777216&lt;br /&gt;
|0.1%&lt;br /&gt;
|0.3%&lt;br /&gt;
|0.6%&lt;br /&gt;
|1.2%&lt;br /&gt;
|~175000&lt;br /&gt;
|~325000&lt;br /&gt;
|~850000&lt;br /&gt;
|~1750000&lt;br /&gt;
|~3250000&lt;br /&gt;
|-&lt;br /&gt;
|-&lt;br /&gt;
| 512 x 512 x 160&lt;br /&gt;
|41943040&lt;br /&gt;
|0.0%&lt;br /&gt;
|0.1%&lt;br /&gt;
|0.2%&lt;br /&gt;
|0.5%&lt;br /&gt;
|~425000&lt;br /&gt;
|~850000&lt;br /&gt;
|~2000000&lt;br /&gt;
|~4250000&lt;br /&gt;
|~8500000&lt;br /&gt;
|}&lt;br /&gt;
The image below shows sample point densities on one slice of a brain MRI with 256x256x130 voxels.  For robust registration, we recommend a useful coverage requires at least 1% coverage for affine, more (at least 5%)  for nonrigid (BSpline) as DOF increase:&amp;lt;br&amp;gt;&lt;br /&gt;
[[Image:RegLib SamplePointsBrain.png|600px|sample point densities on one slice of a brain MRI with 256x256x130 voxels; for robust registration, we recommend a useful coverage requires at least 1% coverage for affine, more (at least 5%)  for nonrigid (BSpline) as DOF increase]]&lt;br /&gt;
&lt;br /&gt;
=== Can I register 2D images with Slicer? ===&lt;br /&gt;
Slicer is designed to work with 3D images. Since it operates in physical space, all objects must have a physical dimension (e.g. thickness). &lt;br /&gt;
It is possible to still run a 2D registration with the 3D tools, with limitations. The two options are: &amp;lt;br&amp;gt;&lt;br /&gt;
'''1.manual registration:''' the manual registration can easily be restricted to 2D. Simply do not use the sliders that control out-of plane rotation or translation. For more info on manual registration see  [http://wiki.slicer.org/slicerWiki/index.php/Documentation/Nightly/FAQ#Can_I_manually_adjust_or_correct_a_registration.3F '''FAQ on manual registration'''] and also [http://wiki.slicer.org/slicerWiki/index.php/Documentation/Nightly/Registration/RegistrationLibrary the '''Registration Library''']&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
'''2.Automated registration:''' the basic concept here is to pad the image with duplicated slices in the 3rd dimension to provide the appearance of a 3D object (e.g. using the Resample module), and  then try to lock all degrees of freedom pertaining to the 3rd dimension (e.g. by masking), i.e. out-of-plane rotation or translation. Because the amount of data is very limited in 2D, automated registration is likely going to fail if the images are too far apart or to dissimilar in content. &lt;br /&gt;
An example of 2D registration can be found in our case library:&lt;br /&gt;
http://wiki.slicer.org/slicerWiki/index.php/Documentation:Nightly:Registration:RegistrationLibrary:RegLib_C46&lt;br /&gt;
&lt;br /&gt;
=== What's the BSpline Grid Size? ===&lt;br /&gt;
The BSpline grid is the basic structure of the deformation model applied when transforming one image to match the other. A uniform grid is placed over the entire image and the grid-points are allowed to move freely. These node displacements are then interpolated over the remainder of the grid. The image below shows an example of a 3x3x3 grid. An additional row of grid points is created at the boundary of the image (red). Those points are locked and do not move. They provide a boundary constraint to keep the grid from shifting. The interior points (green) are free to move in any direction (blue arrows), which gives 3 degrees of freedom (DOF) per grid-point. So a 3x3x3 grid translates into a transform with 27 DOF, a 5x5x5 grid will have 125 DOF. For comparison a rigid transform has 6 DOF, an affine transform has 12. &lt;br /&gt;
When specifying a grid, be aware of your image resolution and anisotropy. For example if your image has substantially fewer voxels in one direction, it may be wise to also request fewer grid-points in that dimension, to avoid over fitting.&amp;lt;br&amp;gt;&lt;br /&gt;
[[Image:RegLib_BSplineGridModel.png|600px|Example of a 3x3x3 BSpline grid placed over the entire image. Note that the 3x3x3 grid refers to the green center points, which are allowed to move freely. The additional (red) boundary points do not move.]]&lt;br /&gt;
&lt;br /&gt;
=== I want to register two images with different intensity/contrast. ===&lt;br /&gt;
&lt;br /&gt;
The two most critical image features that determine automated registration accuracy and robustness are image contrast and resolution. Differences in image contrast are best addressed with the appropriate cost function. The cost function that has proven most reliable for registering images with different contrast (e.g. a T1 MRI to a T2 or an MRI to CT or PET) is '''mutual information'''. All intensity-based registration modules use mutual information as the default cost function. Only the [[Documentation/{{documentation/version}}/Modules/ExpertAutomatedRegistration|''Expert Automated Registration'' module]] (under ''All Modules'') lets you choose alternative cost function.&lt;br /&gt;
No extra adjustment is therefore needed in terms of adjusting parameters to register images of different contrast. Depending on  the amount of differences you may consider masking to exclude distracting image content or adjusting the ''Histogram Bins'' setting to increase/decrease the level of intensity detail the algorithm is aware of. &lt;br /&gt;
*Modules that allow control of ''Histogram Bins'':&lt;br /&gt;
**[[Documentation/{{documentation/version}}/Modules/LinearRegistration|''Linear Registration'' module]]&lt;br /&gt;
**[[Documentation/{{documentation/version}}/Modules/AffineRegistration|''Affine Registration'' module]]&lt;br /&gt;
**[[Documentation/{{documentation/version}}/Modules/BSplineDeformableRegistration|''BSpline Deformable Registration'' module]]&lt;br /&gt;
&lt;br /&gt;
=== How important is bias field correction / intensity inhomogeneity correction? ===&lt;br /&gt;
&lt;br /&gt;
While registration may still succeed with mild cases of inhomogeneity, moderate to severe inhomogeneity can negatively affect automated registration quality. It is recommended to run an automated bias-field correction on both images before registration.This becomes more relevant the more degrees of freedom you have in your registration, i.e. a BSpline registration is more likely to be affected by an intensity bias than an Affine. The image here (click to enlarge) [[Image:BSplineRegWithVsWithoutBiasCorrection.gif|150px|BSpline deformation with/without bias-correction, click to enlarge]]  shows an example of a low-level BSpline deformation applied once with and once without preceeding bias-correction. You can see how the lack of signal at the bottom of the uncorrected image causes the image to be &amp;quot;pulled downward:m which is incorrect.&lt;br /&gt;
[[Documentation/{{documentation/version}}/Modules/N4ITKBiasFieldCorrection|see here for documentation on the BiasCorrection module]]. Masking of non-essential peripheral structures can also help to reduce distracting image content. See the FAQ on masking for more details.&lt;br /&gt;
&lt;br /&gt;
=== Have the Slicer registration methods been validated? ===&lt;br /&gt;
&lt;br /&gt;
The Slicer3.6 registration modules share the same same underlying ITK registration engines. For validation of those basic algorithms refer to the ITK software guide or the Insight Journal.  Slicer registration of images and surfaces has been applied successfully in many cases, some of which are documented here [http://na-mic.org/Wiki/index.php/Projects:RegistrationDocumentation:UseCaseInventory here]. For ongoing efforts on improving/validating Slicer registration performance please contact the [mailto:slicer-users@bwh.harvard.edu Slicer User Mailing List]   or the  [mailto:slicer-devel@bwh.harvard.edu Slicer Developer Mailing List].&lt;br /&gt;
&lt;br /&gt;
=== How can I save the parameter settings I have selected for later use or sharing? ===&lt;br /&gt;
&lt;br /&gt;
The ''Parameter Set'' menu at the top tab of each module serves this purpose of saving and recalling instances of parameter settings. To save the current settings select ''Rename'' from the menu, give it a descriptive name and then select ''Create New Commandline Module'' from the menu. New settings are added to the menu as created. These settings are saved together with the Slicer Scene.mrml file. To save only the presets without any associate data, first save your entire scene, then delete all nodes in the MRML tree except the top ''Scene'' node, and then save this under a new name like &amp;quot;Slicer_Presets.mrml&amp;quot; etc.  To load the presets in, use ''Import'' from the File menu, which will add the MRML entries to the existing scene.  Do '''not''' load presets via &amp;quot;Load Scene&amp;quot;, since that will replace the loaded data rather than add to it. [http://na-mic.org/Wiki/index.php/Projects:RegistrationDocumentation:ParameterPresetsTutorial A detailed user guide on loading presets can be found here]. Note that the content and format of the Slicer Scene file tends to change and evolve with newer versions, and presets may not be compatible across very different versions.&lt;br /&gt;
&lt;br /&gt;
=== Registration is too slow. How can I speed up my registration? ===&lt;br /&gt;
&lt;br /&gt;
The key parameters that influence registration speed are the number of sample points, the degrees of freedom of the transform, the type of similarity metric and the initial misalignment and image contrast/content differences. If registration quality is ok, try reducing the sample points first. [[Documentation/{{documentation/version}}/FAQ#How_many_sample_points_should_I_choose_for_my_registration.3F|Guidelines on selecting sample points are given here]]. The degrees of freedom usually are given by the overall task and not subject to variation, but depending on initial misalignment, both speed and robustness can improve by an iterative approach that gradually increases DOF rather than starting with a high DOF setting. The [[Documentation/{{documentation/version}}/Modules/BRAINSFit|''General Registration (BRAINS)'' module]] and  [[Documentation/{{documentation/version}}/Modules/ExpertAutomatedRegistration|''Expert Automated Registration'' module]] both allow prescriptions of iterative DOF.&amp;lt;br&amp;gt;&lt;br /&gt;
If using a cost/criterion function other than mutual information, note that the corresponding ITK implementation may not have been parallelized and hence may not be taking advantage of multi-threading/multi-CPU cores on your computer. This can slow down performance significantly. &lt;br /&gt;
[[Category:Documentation/{{documentation/version}}/Modules/Registration|Also see the ''Slicer Registration Page'' for help on selecting registration methods based on criteria of speed, precision etc.]]. &amp;lt;br&amp;gt; General tips:&lt;br /&gt;
*the [[Documentation/{{documentation/version}}/Modules/BRAINSFit|''General Registration (BRAINS)'' module]]  is parallelized and tends to be fastest&lt;br /&gt;
*try reducing the number of sample points; see  [[Documentation/{{documentation/version}}/FAQ#How_many_sample_points_should_I_choose_for_my_registration.3F|here for guidelines on selecting sample points]]&lt;br /&gt;
*try a lower DOF registration first to determine if initial position differences are causing excessive search that slows down registration. &lt;br /&gt;
*use mutual information as cost function (default)&lt;br /&gt;
*if your image is very large (512x512 in plane or greater) try a lower resolution version of your image. You can use the [[Documentation/{{documentation/version}}/Modules/ResampleScalarVolume|''ResampleScalarVolume'' module]] to subsample your image.&lt;br /&gt;
&lt;br /&gt;
=== How do I register images via landmarks/fiducials? ===&lt;br /&gt;
There are two fiducial registration tools available within Slicer. The default is within the Registration menu, and an alternative version is found in the SlicerIGT extension as &amp;quot;Fiducial Registration Wizard&amp;quot;. A detailed case example using both tools is available in the [http://wiki.slicer.org/slicerWiki/index.php/Documentation:Nightly:Registration:RegistrationLibrary:RegLib_C48 Case 48 in the Registration Case Library]. A brief screencast on selecting landmarks and running either tools are also here:&lt;br /&gt;
#[[Media:RegLib_C48_FiducialRegistration.mov|'''fiducial-based registration''']]&lt;br /&gt;
#[[Media:RegLib_C48_FiducialRegistration_IGT.mov|'''alternative tool: using SlicerIGT's fiducial-based registration''']] (shows extension download and module execution only, for the landmark selection see movie above)&lt;br /&gt;
&lt;br /&gt;
=== Is the BRAINSfit registration for brain images only? ===&lt;br /&gt;
&lt;br /&gt;
No, it is applicable and has been used successfully on non-brain image data. See the [http://na-mic.org/Wiki/index.php/Projects:RegistrationDocumentation:RegLibTable Registration Case Library for examples]. The ''BRAINS'' name is derived from the ICTS at program at the University of Iowa, where it was developed, details of which you will find [http://www.icts.uiowa.edu/confluence/display/BRAINSPUBLIC/Home here].&lt;br /&gt;
&lt;br /&gt;
=== One of my images has a clipped field of view. Can I still use automated registration? ===&lt;br /&gt;
&lt;br /&gt;
Probably yes. Best remedy is to apply a mask that excludes the missing portion in the other image. Also initialization is critical, more so than with full FOV images. If images have large amount of initial misalignment, try to center both first ([[Documentation/{{documentation/version}}/FAQ#How_do_I_register_images_that_are_very_far_apart_.2F_do_not_overlap|see here for details]]) or perform a cursory manual alignment ([[Documentation/{{documentation/version}}/FAQ#Can_I_manually_adjust_or_correct_a_registration.3F|see here for details)]] and use that as initialization. An example of registrations with clipped FOV can be found in the [http://www.na-mic.org/Wiki/index.php/Projects:RegistrationDocumentation:RegLibTable Slicer Registration Library] , e.g. [http://na-mic.org/Wiki/index.php/Projects:RegistrationDocumentation:RegLib_04_MultipleSclerosis case 4], [http://www.na-mic.org/Wiki/index.php/Projects:RegistrationLibrary:RegLib_C09 case9]; [http://www.na-mic.org/Wiki/index.php/Projects:RegistrationLibrary:RegLib_C13 case 13]; [http://na-mic.org/Wiki/index.php/Projects:RegistrationLibrary:RegLib_C30 case 30] and others.&lt;br /&gt;
&lt;br /&gt;
=== Can I combine multiple registrations? ===&lt;br /&gt;
&lt;br /&gt;
Yes, you can nest multiple (affine) registrations inside eachother. You can generate combined ones via the right-click context menu in the ''Data'' module and selecting ''Harden Transform''. Note that the original transform or volume is replaced when selecting ''Harden Transform'', so it is recommended to rename the node afterwards to document the fact. &amp;lt;br&amp;gt;&lt;br /&gt;
Currently (v.4.1) BSpline transforms cannot be combined with other transforms, so if you have combinations of Affine and BSpline or multiple BSpline transforms you need to resample multiple times to apply them all. We recommend to supersample the volume beforehand to counteract interpolation blurring.&lt;br /&gt;
&lt;br /&gt;
=== Is there a module for surface registration? ===&lt;br /&gt;
The current (4.5) Slicer core does not include a surface registration, but available in extensions.&lt;br /&gt;
* Rigid, similarity or affine registration of model to model: SlicerIGT extension, Model registration module (in IGT category)&lt;br /&gt;
* Rigid, similarity or affine registration of markups fiducials to model: SlicerIGT extension, Fiducials-Model registration module (in IGT category)&lt;br /&gt;
&lt;br /&gt;
=== Can I combine image and surface registration? ===&lt;br /&gt;
Not simultaneously. You can run surface and image registrations separately and then combine the transforms, but there is currently no support to combine both surface and intensity data into a single cost function.&lt;br /&gt;
&lt;br /&gt;
== Apply, Resample, Export ==&lt;br /&gt;
&lt;br /&gt;
=== I ran a registration but cannot see the result. How do I visualize the result transform? ===&lt;br /&gt;
&lt;br /&gt;
There are 2 ways to see the result of a registration: 1) by creating a new resampled volume that represents the moving image in the new orientation , 2) by direct (dynamic) rendering of the original image in a new space when placed inside a transform.  The latter is '''not''' available for non-rigid transforms, hence a registration that includes nonlinear components (BSpline, Warp) must be visualized by first resampling the entire volume with the new transform. If you ran a registration yet see no effect, the reason could be one of the following:&lt;br /&gt;
*you did not request an output. In the module parameters section, you must specify either an output transform or an output image/volume. Select one or both (for nonrigid registration).&lt;br /&gt;
*you requested a result transform but the moving volume is not placed inside the transform in the MRML tree. Not all modules automatically place the moving image inside the result transform node. To see the effect do the following:&lt;br /&gt;
:#Go to the [[Documentation/{{documentation/version}}/Modules/Data|''Data'' module]]&lt;br /&gt;
:#left click on the volume you wish to register, and drag &amp;amp; drop it onto the new transform node created by your registration. After dropping it once the transform, you should see a &amp;quot;+&amp;quot; appear in front of the transform node, and clicking on it should reveal the volume now inside/under that transform.&lt;br /&gt;
:#make sure you have the image for which you wish to adjust the registration selected and visible in the slice views, preferably all 3 views (sagittal, coronal, axial). If the image is visible in the Slicer views, you should see a change immediately when the volume is placed inside the transform&lt;br /&gt;
*registration completed with an error. Check for status messages at the top of the module and look at the ''Error Log''  in the window menu to see if there were any errors reported.&lt;br /&gt;
*registration completed with a result that is too small to be noticeable: For linear transforms (rigid to affine) you can look at and edit the transform directly in Slicer: go to the  [[Documentation/{{documentation/version}}/Modules/Transforms|''Transforms'' module]] and select the transform. You should see the parameters in the 4x4 matrix displayed. If diagonal numbers are very close to 1 and all others very close to 0, you have a transform that barely moves the object at all. Nonrigid transforms you have to save to a file first; you can then view the .tfm file with any text editor.&lt;br /&gt;
*you performed a non-rigid (BSpline) transform but did not yet request an output volume.&lt;br /&gt;
&lt;br /&gt;
=== My reoriented image returns to original position when saved; Problem with the ''Harden Transform'' function  === &lt;br /&gt;
[[Image:HardenTransform.png|200px|left|right click on the image and select &amp;quot;Harden Transform&amp;quot; from the popup menu to reorient an image]]&lt;br /&gt;
You can apply an affine transform to an image by creating a transform, placing the volume inside that transform in the ''Data'' module, and then selecting ''Harden Transform'' via the context-menu (right click on the image volume). This will move the image back out to the main level and &amp;quot;apply&amp;quot; the transform. It will, however, '''not resample''' the image data, but rather place the information about the new orientation into the image header. When the image is saved, this information is saved also as part of the file header, as long as orientation data is supported by the file format. If the saved volume is now loaded by another software that does not consider this header orientation (e.g. ImageJ) or does not visualize the image in physical space, then the image will appear in its old position. &amp;lt;br&amp;gt;&lt;br /&gt;
While resampling of data is best avoided if possible, a hard resampling is possible through the [[Documentation/{{documentation/version}}/Modules/ResampleScalarVectorDWIVolume|''ResampleScalarVectorDWIVolume'' module]]: select your image and transform as input, create a new volume as output and click Apply. This new volume will now be in the new orientation that will be retained if saved and reloaded elsewhere.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
'''Resampling with the Resample Image BRAINS module:'''&amp;lt;br&amp;gt;&lt;br /&gt;
To get your moving image in the same orientation AND the same pixel matrix as your fixed/target image, you need to resample it with the fixed image as reference:&lt;br /&gt;
#go to the Registration / Resample Image (BRAINS) module&lt;br /&gt;
#for &amp;quot;Image To Warp&amp;quot; , select your moving image&lt;br /&gt;
#for &amp;quot;Reference Image&amp;quot; select your fixed image (i.e. the image whose resolution you wish to match)&lt;br /&gt;
#for &amp;quot;Output Image&amp;quot; select&amp;quot; create new &amp;amp; rename&lt;br /&gt;
#for &amp;quot;Transform file&amp;quot;: select the manual registration transform file you created&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== What is the Meaning of 'Fixed Parameters' in the transform file (.tfm) of a BSpline registration ? === &lt;br /&gt;
A typical BSpline transform file will contain 2 transforms, an affine portion (commonly saved as &amp;quot;Transform 1&amp;quot; at the end of the file), and a nonrigid BSpline portion (commonly saved as &amp;quot;Transform 0&amp;quot;).  The bulk of the BSpline part are 3D displacement vectors for each of the BSpline grid-nodes in physical space, i.e. for each grid-node, there will be three blocks of displacements defining dx,dy,dz for all grid nodes. After this field is a &amp;quot;Fixed Parameters&amp;quot; section that may look like this:&lt;br /&gt;
  FixedParameters: 8 8 8 -54.1406 -54.1406 -35 54.1406 54.1406 35 1 0 0 0 1 0 0 0 1&lt;br /&gt;
The first 3 numbers are the actual grid size (number of knots in each dimension), which is always larger than your requested grid because the grid is extended beyond the image margin to prevent clipping. The next 3 numbers is the origin of the grid, spacing of the grid, and the direction cosines of the grid. More details on the format in the [http://www.itk.org/ItkSoftwareGuide.pdf  ITK documentation (ITKSoftwareGuide.pdf)]&lt;br /&gt;
&lt;br /&gt;
=== After registration the registered image appears cropped. How can I increase the field of view to see/include the entire image ===&lt;br /&gt;
Problem: The registration results seems to be correct but the output volume shows only the overlapping region. Is there a way that to show the whole registered volume including the parts which are not overlapping?&lt;br /&gt;
There's two answers to this problem: one is a visualization issue related to how Slicer chooses the field of view (FOV), and one is how the FOV is chosen for resampling.&lt;br /&gt;
Slice views: Slicer sets the overall field of view based on the image selected as &amp;quot;background&amp;quot;. If the image in the foreground extends beyond that region it will be clipped. You can easily fix/test that by switching foreground and background volumes.&lt;br /&gt;
If you already created a resampled version of the registered image, that may also have been cropped,because it sets the field of view based on the reference image (which is the fixed image usually). If you place your resampled image in the background and still see cropped edges, then that's what happened. In that case either use a different reference image for resampling or no reference at all and specify the result sizes manually, or use the  crop tool to expand the FOV as described below:&lt;br /&gt;
#use the [http://www.slicer.org/slicerWiki/index.php/Documentation/Nightly/Modules/Crop_Volume CropVolume module] to over-crop the reference image (define ROI to cover the field of view you want to have in the resampled volume). You will need to use interpolated crop mode, so the resolution will not match the original reference volume.&lt;br /&gt;
#Use the result of the cropping operation as the reference for [http://www.slicer.org/slicerWiki/index.php/Documentation/Nightly/Modules/BRAINSResample BRAINSResample module] (you will need to specify the moving volume, output volume, and the transform produced by the BRAINS registration module).&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== How can I see the parameters of the function that describe a BSpline registration/deformation? === &lt;br /&gt;
To see the parameters of the transform, you have to write it to file and investigate by other means. The BSpline transform is saved as a ITK .tfm which is a text file containing the displacement vectors of each grid-point, plus any initial affine transform (if present). One nice way to visualize is to create a grid image of the same dimensions as your target, and then apply the transform to this grid image, you can then see the deformations as deformations in the gridlines. [http://na-mic.org/Wiki/index.php/Projects:RegistrationDocumentation:UseCaseInventory:Auxiliary Example Grid images can be downloaded here].&lt;br /&gt;
Use the [[Documentation/{{documentation/version}}/Modules/ResampleScalarVectorDWIVolume|''ResampleScalarVectorDWIVolume'' module]] for the resampling.&lt;br /&gt;
&lt;br /&gt;
A quick way directly in slicer is to place the undeformed and deformed volumes into back- and foreground and fade back and forth with the fading slider.&lt;br /&gt;
Another alternative is to convert the transform into a 4-D deformation field directly and visualize it in slicer using RGB color. [[Documentation/{{documentation/version}}/FAQ#How_can_I_convert_a_BSpline_transform_into_a_deformation_field.3F|See FAQ below on how to convert.]]&lt;br /&gt;
&lt;br /&gt;
=== How to export the displacement magnitude of the transform as a volume? ===&lt;br /&gt;
This is possible but requires use of the interactive python console:&lt;br /&gt;
 transformNode=slicer.util.getNode('LinearTransform_3')&lt;br /&gt;
 referenceVolumeNode=slicer.util.getNode('MRHead')&lt;br /&gt;
 slicer.modules.transforms.logic().CreateDisplacementVolumeFromTransform(transformNode, referenceVolumeNode, False)&lt;br /&gt;
The new volume can then be saved or used for ROI analysis with the [https://www.slicer.org/slicerWiki/index.php/Documentation/Nightly/Modules/LabelStatistics Label Statistics module].&lt;br /&gt;
&lt;br /&gt;
=== Physical Space vs. Image Space: how do I align two registered images to the same image grid? ===&lt;br /&gt;
Slicer displays all data in a physical coordinate system. Hence an image can only be displayed correctly if it contains sufficient header information to relate the image voxel grid with physical space. This includes voxel size, axis orientation and scan order.  It is therefore possible for two images to be aligned when viewed in Slicer, even though their underlying image grid is oriented very differently. To match the two images in image as well as physical space, the abovementioned axis direction, voxel size and image grid orientation must match. The procedure will depend on the image data, but the main tools at your disposal are the [[Documentation/{{documentation/version}}/Modules/ResampleScalarVectorDWIVolume|''ResampleScalarVectorDWIVolume'' module]] and  [[Documentation/{{documentation/version}}/Modules/OrientImages|''OrientImages'' module]].&lt;br /&gt;
&lt;br /&gt;
== Nonrigid / BSpline Registration ==&lt;br /&gt;
&lt;br /&gt;
=== The nonrigid (BSpline) registration transform does not seem to be nonrigid or does not show up correctly. ===&lt;br /&gt;
&lt;br /&gt;
See FAQ on viewing registration results [[Documentation/{{documentation/version}}/FAQ#I_ran_a_registration_but_cannot_see_the_result._How_do_I_visualize_the_result_transform.3F|here]].&lt;br /&gt;
BSpline transforms are '''not''' available for immediate rendering by placing volumes or models inside the transforms. Only linear transforms can be viewed that way. A BSpline transform must be visualized by resampling the entire volume with the new transform. If you did not yet an output volume when running the registration, you can do so after the fact, use the [[Documentation/{{documentation/version}}/Modules/ResampleScalarVectorDWIVolume|''ResampleScalarVectorDWIVolume'' module]].&lt;br /&gt;
&lt;br /&gt;
=== What's the difference between BRAINSfit and BRAINSDemonWarp? ===&lt;br /&gt;
&lt;br /&gt;
[[Documentation/{{documentation/version}}/Modules/BRAINSFit|''General Registration (BRAINS)'' module]] performs Rigid to Affine and BSpline registration that commonly will have at the most a few hundred degrees of freedom (DOF), whereas the [[Documentation/{{documentation/version}}/Modules/BRAINSDemonWarp|''Demon Registration (BRAINS)'' module]] performs a optic flow high-DOF warping scheme that has many thousands of DOF and is significantly less constrained.&lt;br /&gt;
&lt;br /&gt;
=== How can I convert a BSpline transform into a deformation field? === &lt;br /&gt;
There is a dedicated module to convert a  BSpline ITK transform  file (.tfm) into a deformation field volume. &amp;lt;br&amp;gt;&lt;br /&gt;
Modules -&amp;gt; all Modules -&amp;gt; '''BSpline to deformation field'''&amp;lt;br&amp;gt;&lt;br /&gt;
provide your BSpline transform and a reference image that defines the size of the deformation field.&lt;br /&gt;
&amp;lt;br&amp;gt;For Slicer 3.6 this functionality was available as command line functionality only:&lt;br /&gt;
To execute, type (exchange ''/Applications/Slicer3.6.3'' with the path of your Slicer installation):&lt;br /&gt;
  /Applications/Slicer3.6.3/Slicer3 --launch /Applications/Slicer3.6.3/lib/Slicer3/Plugins/BSplineToDeformationField --tfm InputBSpline.tfm &lt;br /&gt;
   --refImage ReferenceImage.nrrd   --defImage Output_DeformationField.nrrd  &lt;br /&gt;
for more details try:&lt;br /&gt;
  /Applications/Slicer3.6.3/Slicer3 --launch /Applications/Slicer3.6.3/lib/Slicer3/Plugins/BSplineToDeformationField --help&lt;br /&gt;
&lt;br /&gt;
=== Where can I check the reference color map for the transform visualizer? i.e. how can I know the magnitude of transform vectors? ===&lt;br /&gt;
The &amp;quot;Transform Visualizer&amp;quot; is a tool that in earlier Slicer versions (4.2 and before) was an extension module, but in newer versions has been integrated into the  [[Documentation/{{documentation/version}}/Modules/Transforms|'''Transforms''' module]]] (under the ''Display'' tab). It enables visualisation of transform vectors that are particularly useful to help understand complex non-rigid deformations such as B-Spline registrations.&lt;br /&gt;
You can find the referenced color table in the [[Documentation/{{documentation/version}}/Modules/Colors|'''Colors''' module]] . There is a category called “Transform Display” and under that there is the “Displacement to color” color table. To display the scalar value represented by a color, you need to turn on the “Display scalar bar” option in Scalar Bar section under “Colors” module. Currently it only shows the scalar bar in the 3D window. &amp;lt;br&amp;gt;&lt;br /&gt;
Alternatlively, you can see the deformation vector under current cursor in Transform module in the Information section, when you move your cursor, it will display the current vector.&lt;/div&gt;</summary>
		<author><name>Inorton</name></author>
		
	</entry>
	<entry>
		<id>https://www.slicer.org/w/index.php?title=Documentation/Nightly/ScriptRepository&amp;diff=59412</id>
		<title>Documentation/Nightly/ScriptRepository</title>
		<link rel="alternate" type="text/html" href="https://www.slicer.org/w/index.php?title=Documentation/Nightly/ScriptRepository&amp;diff=59412"/>
		<updated>2018-09-12T17:10:55Z</updated>

		<summary type="html">&lt;p&gt;Inorton: /* Iterate over tract (FiberBundle) streamline points */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;noinclude&amp;gt;{{documentation/versioncheck}}&amp;lt;/noinclude&amp;gt;&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Community-contributed modules=&lt;br /&gt;
&lt;br /&gt;
The examples in this section are [[Documentation/{{documentation/version}}/Developers/Modules#Scripted_Modules| Scripted Modules]] that provide a user interface in the module panel along with specialized implementation logic.&lt;br /&gt;
&lt;br /&gt;
Usage: save the .py file to a directory, add the directory to the additional module paths in the Slicer application settings (choose in the menu: Edit / Application settings, click Modules, click &amp;gt;&amp;gt; next to Additional module paths, click Add, and choose the .py file's location).&lt;br /&gt;
&lt;br /&gt;
==Filters==&lt;br /&gt;
* [https://raw.github.com/pieper/VolumeMasker/master/VolumeMasker.py VolumeMasker.py]: Update a target volume with the results of setting all input volume voxels to 0 except for those that correspond to a selected label value in an input label map (Used for example in the volume rendering in [https://www.youtube.com/watch?v=dfu2gugHLHs this video).&lt;br /&gt;
&lt;br /&gt;
==DICOM==&lt;br /&gt;
* [https://gist.github.com/pieper/6186477 dicom header browser] to easily scroll through dicom files using dcmdump.&lt;br /&gt;
* [https://github.com/SlicerRt/SlicerRT/tree/master/BatchProcessing SlicerRT batch processing] to batch convert RT structure sets to labelmap NRRD files.&lt;br /&gt;
&lt;br /&gt;
==Informatics==&lt;br /&gt;
* [https://gist.github.com/lassoan/bf0954d93cacc8cbe27cd4a3ad503f2f MarkupsInfo.py]: Compute the total length between all the points of a markup list.&lt;br /&gt;
* [https://gist.github.com/lassoan/0e7acfbec36e4577f8b7b0e07ad53a2a LineProfile.py]: Compute intensity profile in a volume along a line.&lt;br /&gt;
&lt;br /&gt;
=Community-contributed examples=&lt;br /&gt;
&lt;br /&gt;
Usage: Copy-paste the shown code lines or linked .py file contents into Python console in Slicer.  Or save them to a file and run them using execfile.&lt;br /&gt;
&lt;br /&gt;
==Capture==&lt;br /&gt;
* Capture the full Slicer screen and save it into a file&lt;br /&gt;
  img = qt.QPixmap.grabWidget(slicer.util.mainWindow()).toImage()&lt;br /&gt;
  img.save('c:/tmp/test.png')&lt;br /&gt;
* Capture all the views save it into a file:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
import ScreenCapture&lt;br /&gt;
cap = ScreenCapture.ScreenCaptureLogic()&lt;br /&gt;
cap.showViewControllers(False)&lt;br /&gt;
cap.captureImageFromView(None,'c:/tmp/test.png')&lt;br /&gt;
cap.showViewControllers(True)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
* Capture a single view:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
viewNodeID = 'vtkMRMLViewNode1'&lt;br /&gt;
import ScreenCapture&lt;br /&gt;
cap = ScreenCapture.ScreenCaptureLogic()&lt;br /&gt;
view = cap.viewFromNode(slicer.mrmlScene.GetNodeByID(viewNodeID))&lt;br /&gt;
cap.captureImageFromView(view,'c:/tmp/test.png')&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Common values for viewNodeID: vtkMRMLSliceNodeRed, vtkMRMLSliceNodeYellow, vtkMRMLSliceNodeGreen, vtkMRMLViewNode1, vtkMRMLViewNode2. &lt;br /&gt;
The ScreenCapture module can also create video animations of rotating views, slice sweeps, etc.&lt;br /&gt;
&lt;br /&gt;
* Capture a slice view sweep into a series of PNG files - for example, Red slice view, 30 images, from position -125.0 to 75.0, into c:/tmp folder, with name image_00001.png, image_00002.png, ...&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
import ScreenCapture&lt;br /&gt;
ScreenCapture.ScreenCaptureLogic().captureSliceSweep(getNode('vtkMRMLSliceNodeRed'), -125.0, 75.0, 30, &amp;quot;c:/tmp&amp;quot;, &amp;quot;image_%05d.png&amp;quot;)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Capture 3D view into PNG file with transparent background&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
renderWindow = slicer.app.layoutManager().threeDWidget(0).threeDView().renderWindow()&lt;br /&gt;
renderWindow.SetAlphaBitPlanes(1)&lt;br /&gt;
wti = vtk.vtkWindowToImageFilter()&lt;br /&gt;
wti.SetInputBufferTypeToRGBA()&lt;br /&gt;
wti.SetInput(renderWindow)&lt;br /&gt;
writer = vtk.vtkPNGWriter()&lt;br /&gt;
writer.SetFileName(&amp;quot;c:/tmp/screenshot.png&amp;quot;)&lt;br /&gt;
writer.SetInputConnection(wti.GetOutputPort())&lt;br /&gt;
writer.Write()&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Launching Slicer==&lt;br /&gt;
* How to open an .mrb file with Slicer at the command line?&lt;br /&gt;
  Slicer.exe --python-code &amp;quot;slicer.util.loadScene( 'f:/2013-08-23-Scene.mrb' )&amp;quot;&lt;br /&gt;
* How to run a script in the Slicer environment in batch mode (without showing any graphical user interface)?&lt;br /&gt;
  Slicer.exe --python-code &amp;quot;doSomething; doSomethingElse; etc.&amp;quot; --testing --no-splash --no-main-window&lt;br /&gt;
&lt;br /&gt;
==Load volume from file==&lt;br /&gt;
When loading a volume from file, it is recommended to set returnNode=True to retrieve the loaded volume node.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
[success, loadedVolumeNode] = slicer.util.loadVolume('c:/Users/abc/Documents/MRHead.nrrd', returnNode=True)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Get a MRML node in the scene based on the node name and call methods of that object. For the MRHead sample data:&lt;br /&gt;
  vol=slicer.util.getNode('MR*')&lt;br /&gt;
  vol.GetImageData().GetDimensions()&lt;br /&gt;
&lt;br /&gt;
==DICOM==&lt;br /&gt;
=== How to access tags of DICOM images imported into Slicer? For example, to print the first patient's first study's first series' &amp;quot;0020,0032&amp;quot; field:===&lt;br /&gt;
  db=slicer.dicomDatabase&lt;br /&gt;
  patientList=db.patients()&lt;br /&gt;
  studyList=db.studiesForPatient(patientList[0])&lt;br /&gt;
  seriesList=db.seriesForStudy(studyList[0])&lt;br /&gt;
  fileList=db.filesForSeries(seriesList[0])&lt;br /&gt;
  print db.fileValue(fileList[0],'0020,0032')&lt;br /&gt;
&lt;br /&gt;
=== How to access tag of a volume loaded from DICOM? For example, get the patient position stored in a volume:===&lt;br /&gt;
  volumeName='2: ENT IMRT'&lt;br /&gt;
  n=slicer.util.getNode(volumeName)&lt;br /&gt;
  instUids=n.GetAttribute('DICOM.instanceUIDs').split()&lt;br /&gt;
  filename=slicer.dicomDatabase.fileForInstance(instUids[0])&lt;br /&gt;
  print slicer.dicomDatabase.fileValue(filename,'0018,5100')&lt;br /&gt;
&lt;br /&gt;
=== How to access tag of an item in the Subject Hierachy tree? For example, get the content time tag of a structure set:===&lt;br /&gt;
  rtStructName = '3: RTSTRUCT: PROS'&lt;br /&gt;
  rtStructNode = slicer.util.getNode(rtStructName)&lt;br /&gt;
  shNode = slicer.vtkMRMLSubjectHierarchyNode.GetSubjectHierarchyNode(slicer.mrmlScene)&lt;br /&gt;
  rtStructShItemID = shNode.GetItemByDataNode(rtStructNode)&lt;br /&gt;
  ctSliceInstanceUids = shNode.GetItemAttribute(rtStructShItemID, 'DICOM.ReferencedInstanceUIDs').split()&lt;br /&gt;
  filename = slicer.dicomDatabase.fileForInstance(ctSliceInstanceUids[0])&lt;br /&gt;
  print slicer.dicomDatabase.fileValue(filename,'0008,0033')&lt;br /&gt;
&lt;br /&gt;
=== How to get path and filename of a loaded DICOM volume?===&lt;br /&gt;
  def pathFromNode(node):&lt;br /&gt;
    storageNode=node.GetStorageNode()&lt;br /&gt;
    if storageNode is not None: # loaded via drag-drop&lt;br /&gt;
        filepath=storageNode.GetFullNameFromFileName()&lt;br /&gt;
    else: # loaded via DICOM browser&lt;br /&gt;
        instanceUIDs=node.GetAttribute('DICOM.instanceUIDs').split()&lt;br /&gt;
        filepath=slicer.dicomDatabase.fileForInstance(instUids[0])&lt;br /&gt;
    return filepath&lt;br /&gt;
  &lt;br /&gt;
  # example:&lt;br /&gt;
  node=slicer.util.getNode('volume1')&lt;br /&gt;
  path=self.pathFromNode(node)&lt;br /&gt;
  print(&amp;quot;DICOM path=%s&amp;quot; % path)&lt;br /&gt;
&lt;br /&gt;
=== How can I convert DICOM to NRRD on the command line?===&lt;br /&gt;
&lt;br /&gt;
 /Applications/Slicer-4.6.2.app/Contents/MacOS/Slicer --no-main-window --python-code &amp;quot;node=slicer.util.loadVolume('/tmp/series/im0.dcm', returnNode=True)[1]; slicer.util.saveNode(node, '/tmp/output.nrrd'); exit()&amp;quot;&lt;br /&gt;
&lt;br /&gt;
The same can be done on windows by using the top level Slicer.exe.  Be sure to use forward slashes in the pathnames within quotes on the command line.&lt;br /&gt;
&lt;br /&gt;
=== Export a volume to DICOM file format ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
volumeNode = getNode('CTChest')&lt;br /&gt;
outputFolder = &amp;quot;c:/tmp/dicom-output&amp;quot;&lt;br /&gt;
&lt;br /&gt;
# Create patient and study and put the volume under the study&lt;br /&gt;
shNode = slicer.vtkMRMLSubjectHierarchyNode.GetSubjectHierarchyNode(slicer.mrmlScene)&lt;br /&gt;
patientItemID = shNode.CreateSubjectItem(shNode.GetSceneItemID(), &amp;quot;test patient&amp;quot;)&lt;br /&gt;
studyItemID = shNode.CreateStudyItem(patientItemID, &amp;quot;test study&amp;quot;)&lt;br /&gt;
volumeShItemID = shNode.GetItemByDataNode(volumeNode)&lt;br /&gt;
shNode.SetItemParent(volumeShItemID, studyItemID)&lt;br /&gt;
&lt;br /&gt;
import DICOMScalarVolumePlugin&lt;br /&gt;
exporter = DICOMScalarVolumePlugin.DICOMScalarVolumePluginClass()&lt;br /&gt;
exportables = exporter.examineForExport(volumeShItemID)&lt;br /&gt;
for exp in exportables:&lt;br /&gt;
  exp.directory = outputFolder&lt;br /&gt;
&lt;br /&gt;
exporter.export(exportables)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Toolbar functions==&lt;br /&gt;
* How to turn on slice intersections in the crosshair menu on the toolbar:&lt;br /&gt;
  viewNodes = slicer.mrmlScene.GetNodesByClass('vtkMRMLSliceCompositeNode')&lt;br /&gt;
  viewNodes.UnRegister(slicer.mrmlScene)&lt;br /&gt;
  viewNodes.InitTraversal()&lt;br /&gt;
  viewNode = viewNodes.GetNextItemAsObject()&lt;br /&gt;
  while viewNode:&lt;br /&gt;
    viewNode.SetSliceIntersectionVisibility(1)&lt;br /&gt;
    viewNode = viewNodes.GetNextItemAsObject()&lt;br /&gt;
&lt;br /&gt;
How to find similar functions? For this one I searched for &amp;quot;slice intersections&amp;quot; text in the whole slicer source code, found that the function is implemented in Base\QTGUI\qSlicerViewersToolBar.cxx, then translated the qSlicerViewersToolBarPrivate::setSliceIntersectionVisible(bool visible) method to Python.&lt;br /&gt;
&lt;br /&gt;
==Manipulating objects in the slice viewer==&lt;br /&gt;
* How to define/edit a circular region of interest in a slice viewer?&lt;br /&gt;
&lt;br /&gt;
Drop two markup points on a slice view and copy-paste the code below into the Python console. After this, as you move the markups you’ll see a circle following the markups.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Update the sphere from the fiducial points&lt;br /&gt;
def UpdateSphere(param1, param2):  &lt;br /&gt;
  import math&lt;br /&gt;
  centerPointCoord = [0.0, 0.0, 0.0]&lt;br /&gt;
  markups.GetNthFiducialPosition(0,centerPointCoord)&lt;br /&gt;
  circumferencePointCoord = [0.0, 0.0, 0.0]&lt;br /&gt;
  markups.GetNthFiducialPosition(1,circumferencePointCoord)&lt;br /&gt;
  sphere.SetCenter(centerPointCoord)&lt;br /&gt;
  radius=math.sqrt((centerPointCoord[0]-circumferencePointCoord[0])**2+(centerPointCoord[1]-circumferencePointCoord[1])**2+(centerPointCoord[2]-circumferencePointCoord[2])**2)&lt;br /&gt;
  sphere.SetRadius(radius)&lt;br /&gt;
  sphere.SetPhiResolution(30)&lt;br /&gt;
  sphere.SetThetaResolution(30)&lt;br /&gt;
  sphere.Update()&lt;br /&gt;
&lt;br /&gt;
# Get markup node from scene&lt;br /&gt;
markups=slicer.util.getNode('F')&lt;br /&gt;
sphere = vtk.vtkSphereSource()&lt;br /&gt;
UpdateSphere(0,0)&lt;br /&gt;
 &lt;br /&gt;
# Create model node and add to scene&lt;br /&gt;
modelsLogic = slicer.modules.models.logic()&lt;br /&gt;
model = modelsLogic.AddModel(sphere.GetOutput())&lt;br /&gt;
model.GetDisplayNode().SetSliceIntersectionVisibility(True)&lt;br /&gt;
model.GetDisplayNode().SetSliceIntersectionThickness(3)&lt;br /&gt;
model.GetDisplayNode().SetColor(1,1,0)&lt;br /&gt;
 &lt;br /&gt;
# Call UpdateSphere whenever the fiducials are changed&lt;br /&gt;
markups.AddObserver(&amp;quot;ModifiedEvent&amp;quot;, UpdateSphere, 2)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Set slice position and orientation from 3 markup fiducials==&lt;br /&gt;
&lt;br /&gt;
Drop 3 markup points in the scene and copy-paste the code below into the Python console. After this, as you move the markups you’ll see the red slice view position and orientation will be set to make it fit to the 3 points.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Update plane from fiducial points&lt;br /&gt;
def UpdateSlicePlane(param1=None, param2=None):&lt;br /&gt;
  # Get point positions as numpy array&lt;br /&gt;
  import numpy as np&lt;br /&gt;
  nOfFiduciallPoints = markups.GetNumberOfFiducials()&lt;br /&gt;
  if nOfFiduciallPoints &amp;lt; 3:&lt;br /&gt;
    return  # not enough points&lt;br /&gt;
  points = np.zeros([3,nOfFiduciallPoints])&lt;br /&gt;
  for i in range(0, nOfFiduciallPoints):&lt;br /&gt;
    markups.GetNthFiducialPosition(i, points[:,i])&lt;br /&gt;
  # Compute plane position and normal&lt;br /&gt;
  planePosition = points.mean(axis=1)&lt;br /&gt;
  planeNormal = np.cross(points[:,1] - points[:,0], points[:,2] - points[:,0])&lt;br /&gt;
  planeX = points[:,1] - points[:,0]&lt;br /&gt;
  sliceNode.SetSliceToRASByNTP(planeNormal[0], planeNormal[1], planeNormal[2],&lt;br /&gt;
    planeX[0], planeX[1], planeX[2],&lt;br /&gt;
    planePosition[0], planePosition[1], planePosition[2], 0)&lt;br /&gt;
&lt;br /&gt;
# Get markup node from scene&lt;br /&gt;
sliceNode = slicer.app.layoutManager().sliceWidget('Red').mrmlSliceNode()&lt;br /&gt;
markups = slicer.util.getNode('F')&lt;br /&gt;
&lt;br /&gt;
# Update slice plane manually&lt;br /&gt;
UpdateSlicePlane()&lt;br /&gt;
&lt;br /&gt;
# Update slice plane automatically whenever points are changed&lt;br /&gt;
markupObservation = [markups, markups.AddObserver(&amp;quot;ModifiedEvent&amp;quot;, UpdateSlicePlane, 2)]&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To stop automatic updates, run this:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
markupObservation[0].RemoveObserver(markupObservation[1])&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Switching to markup fiducial placement mode ==&lt;br /&gt;
&lt;br /&gt;
To activate a fiducial placement mode, both interaction mode has to be set and a fiducial node has to be selected:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
interactionNode = slicer.app.applicationLogic().GetInteractionNode()&lt;br /&gt;
selectionNode = slicer.app.applicationLogic().GetSelectionNode()&lt;br /&gt;
selectionNode.SetReferenceActivePlaceNodeClassName(&amp;quot;vtkMRMLMarkupsFiducialNode&amp;quot;)&lt;br /&gt;
fiducialNode = slicer.vtkMRMLMarkupsFiducialNode()&lt;br /&gt;
slicer.mrmlScene.AddNode(fiducialNode)&lt;br /&gt;
fiducialNode.CreateDefaultDisplayNodes() &lt;br /&gt;
selectionNode.SetActivePlaceNodeID(fiducialNode.GetID())&lt;br /&gt;
interactionNode.SetCurrentInteractionMode(interactionNode.Place)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Get a notification if a markup point position is modified ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
def onMarkupsNodeModified(markupsNode, unusedArg2=None, unusedArg3=None):&lt;br /&gt;
  sliceView = markupsNode.GetAttribute('Markups.MovingInSliceView')&lt;br /&gt;
  if not sliceView:&lt;br /&gt;
    print(&amp;quot;Markup list was modified&amp;quot;)&lt;br /&gt;
    return&lt;br /&gt;
  movingMarkupIndex = markupsNode.GetAttribute('Markups.MovingMarkupIndex')&lt;br /&gt;
  pos = [0,0,0]&lt;br /&gt;
  markupsNode.GetNthFiducialPosition(int(movingMarkupIndex), pos)  &lt;br /&gt;
  print(&amp;quot;Markup {0} was moved in slice view {1} to {2}&amp;quot;.format(movingMarkupIndex, sliceView, pos))&lt;br /&gt;
&lt;br /&gt;
markupsNode = slicer.mrmlScene.AddNewNodeByClass(&amp;quot;vtkMRMLMarkupsFiducialNode&amp;quot;)&lt;br /&gt;
markupsNode.CreateDefaultDisplayNodes()&lt;br /&gt;
markupsNode.AddFiducial(0,0,0)&lt;br /&gt;
markupsNode.AddObserver(vtk.vtkCommand.ModifiedEvent, onMarkupsNodeModified)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Show a context menu when a markup point is clicked in a slice or 3D view ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
# Example actions to perform&lt;br /&gt;
&lt;br /&gt;
def action1():&lt;br /&gt;
  print('Action1 on markup '+str(slicer.clickedMarkupIndex))&lt;br /&gt;
&lt;br /&gt;
def action2():&lt;br /&gt;
  print('Action2 on markup '+str(slicer.clickedMarkupIndex))&lt;br /&gt;
&lt;br /&gt;
def action3():&lt;br /&gt;
  print('Action3 on markup '+str(slicer.clickedMarkupIndex))&lt;br /&gt;
&lt;br /&gt;
# Clicked markup index is saved here to let the action&lt;br /&gt;
# know which markup needs to be manipulated.&lt;br /&gt;
slicer.clickedMarkupIndex = -1&lt;br /&gt;
  &lt;br /&gt;
# Create a simple menu&lt;br /&gt;
&lt;br /&gt;
menu = qt.QMenu()&lt;br /&gt;
a1 = qt.QAction(&amp;quot;Test&amp;quot;, slicer.util.mainWindow())&lt;br /&gt;
a1.connect('triggered()', action1)&lt;br /&gt;
menu.addAction(a1)&lt;br /&gt;
a2 = qt.QAction(&amp;quot;Action&amp;quot;, slicer.util.mainWindow())&lt;br /&gt;
a2.connect('triggered()', action1)&lt;br /&gt;
menu.addAction(a2)&lt;br /&gt;
a3 = qt.QAction(&amp;quot;Here&amp;quot;, slicer.util.mainWindow())&lt;br /&gt;
a3.connect('triggered()', action1)&lt;br /&gt;
menu.addAction(a3)&lt;br /&gt;
&lt;br /&gt;
# Add observer to a markup fiducial list&lt;br /&gt;
&lt;br /&gt;
@vtk.calldata_type(vtk.VTK_INT)&lt;br /&gt;
def markupClickedCallback(caller, eventId, callData):&lt;br /&gt;
  slicer.clickedMarkupIndex = callData&lt;br /&gt;
  print('Open menu on markup '+str(slicer.clickedMarkupIndex))&lt;br /&gt;
  menu.move(qt.QCursor.pos())&lt;br /&gt;
  menu.show()&lt;br /&gt;
&lt;br /&gt;
markupsNode = getNode('F')&lt;br /&gt;
observerTag = markupsNode.AddObserver(slicer.vtkMRMLMarkupsNode.PointClickedEvent, markupClickedCallback)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Add a texture mapped plane to the scene as a model ==&lt;br /&gt;
Note that model textures are not exposed in the GUI and are not saved in the scene&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# use dummy image data here&lt;br /&gt;
e = vtk.vtkImageEllipsoidSource()&lt;br /&gt;
&lt;br /&gt;
scene = slicer.mrmlScene&lt;br /&gt;
&lt;br /&gt;
# Create model node&lt;br /&gt;
model = slicer.vtkMRMLModelNode()&lt;br /&gt;
model.SetScene(scene)&lt;br /&gt;
model.SetName(scene.GenerateUniqueName(&amp;quot;2DImageModel&amp;quot;))&lt;br /&gt;
&lt;br /&gt;
planeSource = vtk.vtkPlaneSource()&lt;br /&gt;
model.SetAndObservePolyData(planeSource.GetOutput())&lt;br /&gt;
&lt;br /&gt;
# Create display node&lt;br /&gt;
modelDisplay = slicer.vtkMRMLModelDisplayNode()&lt;br /&gt;
modelDisplay.SetColor(1,1,0) # yellow&lt;br /&gt;
modelDisplay.SetBackfaceCulling(0)&lt;br /&gt;
modelDisplay.SetScene(scene)&lt;br /&gt;
scene.AddNode(modelDisplay)&lt;br /&gt;
model.SetAndObserveDisplayNodeID(modelDisplay.GetID())&lt;br /&gt;
&lt;br /&gt;
# Add to scene&lt;br /&gt;
modelDisplay.SetAndObserveTextureImageData(e.GetOutput())&lt;br /&gt;
scene.AddNode(model) &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
transform = slicer.vtkMRMLLinearTransformNode()&lt;br /&gt;
scene.AddNode(transform) &lt;br /&gt;
model.SetAndObserveTransformNodeID(transform.GetID())&lt;br /&gt;
&lt;br /&gt;
vTransform = vtk.vtkTransform()&lt;br /&gt;
vTransform.Scale(50,50,50)&lt;br /&gt;
vTransform.RotateX(30)&lt;br /&gt;
transform.SetAndObserveMatrixTransformToParent(vTransform.GetMatrix())&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Export entire scene as VRML ==&lt;br /&gt;
&lt;br /&gt;
Save all surface meshes displayed in the scene (models, markups, etc). Solid colors and coloring by scalar is preserved. Textures are not supported.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
exporter = vtk.vtkVRMLExporter()&lt;br /&gt;
exporter.SetRenderWindow(slicer.app.layoutManager().threeDWidget(0).threeDView().renderWindow())&lt;br /&gt;
exporter.SetFileName('C:/tmp/something.wrl')&lt;br /&gt;
exporter.Write()&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Export model to Blender, including color by scalar ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
modelNode = getNode(&amp;quot;Model&amp;quot;)&lt;br /&gt;
plyFilePath = &amp;quot;c:/tmp/model.ply&amp;quot;&lt;br /&gt;
&lt;br /&gt;
modelDisplayNode = modelNode.GetDisplayNode()&lt;br /&gt;
triangles = vtk.vtkTriangleFilter()&lt;br /&gt;
triangles.SetInputConnection(modelDisplayNode.GetOutputPolyDataConnection())&lt;br /&gt;
&lt;br /&gt;
plyWriter = vtk.vtkPLYWriter()&lt;br /&gt;
plyWriter.SetInputConnection(triangles.GetOutputPort())&lt;br /&gt;
lut = vtk.vtkLookupTable()&lt;br /&gt;
lut.DeepCopy(modelDisplayNode.GetColorNode().GetLookupTable())&lt;br /&gt;
lut.SetRange(modelDisplayNode.GetScalarRange())&lt;br /&gt;
plyWriter.SetLookupTable(lut)&lt;br /&gt;
plyWriter.SetArrayName(modelDisplayNode.GetActiveScalarName())&lt;br /&gt;
&lt;br /&gt;
plyWriter.SetFileName(plyFilePath)&lt;br /&gt;
plyWriter.Write()&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Export a tract (FiberBundle) to Blender, including color ==&lt;br /&gt;
&amp;lt;div id=&amp;quot;Export_a_fiber_tracts_to_Blender.2C_including_color&amp;quot;&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
Note: an interactive version of this script is now included in the [http://dmri.slicer.org/ SlicerDMRI extension] ([https://github.com/SlicerDMRI/SlicerDMRI/tree/master/Modules/Scripted/TractographyExportPLY module code]). &lt;br /&gt;
After installing SlicerDMRI, go to ''Modules -&amp;gt; Diffusion -&amp;gt; Import and Export -&amp;gt; Export tractography to PLY (mesh)''.&lt;br /&gt;
&lt;br /&gt;
The example below shows how to export a tractography &amp;quot;FiberBundleNode&amp;quot; to a PLY file:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
lineDisplayNode = getNode(&amp;quot;*LineDisplay*&amp;quot;)&lt;br /&gt;
plyFilePath = &amp;quot;/tmp/fibers.ply&amp;quot;&lt;br /&gt;
&lt;br /&gt;
tuber = vtk.vtkTubeFilter()&lt;br /&gt;
tuber.SetInputData(lineDisplayNode.GetOutputPolyData())&lt;br /&gt;
tuber.Update()&lt;br /&gt;
tubes = tuber.GetOutputDataObject(0)&lt;br /&gt;
scalars = tubes.GetPointData().GetArray(0)&lt;br /&gt;
scalars.SetName(&amp;quot;scalars&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
triangles = vtk.vtkTriangleFilter()&lt;br /&gt;
triangles.SetInputData(tubes)&lt;br /&gt;
triangles.Update()&lt;br /&gt;
&lt;br /&gt;
colorNode = lineDisplayNode.GetColorNode()&lt;br /&gt;
lookupTable = vtk.vtkLookupTable()&lt;br /&gt;
lookupTable.DeepCopy(colorNode.GetLookupTable())&lt;br /&gt;
lookupTable.SetTableRange(0,1)&lt;br /&gt;
&lt;br /&gt;
plyWriter = vtk.vtkPLYWriter()&lt;br /&gt;
plyWriter.SetInputData(triangles.GetOutput())&lt;br /&gt;
plyWriter.SetLookupTable(lookupTable)&lt;br /&gt;
plyWriter.SetArrayName(&amp;quot;scalars&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
plyWriter.SetFileName(plyFilePath)&lt;br /&gt;
plyWriter.Write()&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Iterate over tract (FiberBundle) streamline points ==&lt;br /&gt;
&lt;br /&gt;
This example shows how to access the points in each line of a FiberBundle as a numpy array (view).&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
from vtk.util.numpy_support import vtk_to_numpy&lt;br /&gt;
&lt;br /&gt;
fb = getNode(&amp;quot;FiberBundle_F&amp;quot;) # &amp;lt;- fill in node ID here&lt;br /&gt;
&lt;br /&gt;
# get point data as 1d array&lt;br /&gt;
points = slicer.util.arrayFromModelPoints(fb)&lt;br /&gt;
&lt;br /&gt;
# get line cell ids as 1d array&lt;br /&gt;
line_ids = vtk_to_numpy(fb.GetPolyData().GetLines().GetData())&lt;br /&gt;
&lt;br /&gt;
# VTK cell ids are stored as&lt;br /&gt;
#   [ N0 c0_id0 ... c0_id0&lt;br /&gt;
#     N1 c1_id0 ... c1_idN1 ]&lt;br /&gt;
# so we need to&lt;br /&gt;
# - read point count for each line (cell)&lt;br /&gt;
# - grab the ids in that range from `line_ids` array defined above&lt;br /&gt;
# - index the `points` array by those ids&lt;br /&gt;
cur_idx = 1&lt;br /&gt;
for _ in range(pd.GetLines().GetNumberOfCells()):&lt;br /&gt;
    # - read point count for this line (cell)&lt;br /&gt;
    count = lines[cur_idx - 1]&lt;br /&gt;
&lt;br /&gt;
    # - grab the ids in that range from `lines`&lt;br /&gt;
    index_array = line_ids[ cur_idx : cur_idx + count]&lt;br /&gt;
    # update to the next range &lt;br /&gt;
    cur_idx += count + 1&lt;br /&gt;
&lt;br /&gt;
    # - index the point array by those ids&lt;br /&gt;
    line_points = points[index_array]&lt;br /&gt;
&lt;br /&gt;
    # do work here&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Clone a volume ==&lt;br /&gt;
This example shows how to clone the MRHead sample volume, including its pixel data and display settings.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sourceVolumeNode = slicer.util.getNode('MRHead')&lt;br /&gt;
volumesLogic = slicer.modules.volumes.logic()&lt;br /&gt;
clonedVolumeNode = volumesLogic.CloneVolume(slicer.mrmlScene, sourceVolumeNode, 'Cloned volume')&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Create a new volume ==&lt;br /&gt;
This example shows how to create a new empty volume.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
nodeName = &amp;quot;MyNewVolume&amp;quot;&lt;br /&gt;
imageSize = [512, 512, 512]&lt;br /&gt;
voxelType=vtk.VTK_UNSIGNED_CHAR&lt;br /&gt;
imageOrigin = [0.0, 0.0, 0.0]&lt;br /&gt;
imageSpacing = [1.0, 1.0, 1.0]&lt;br /&gt;
imageDirections = [[1,0,0], [0,1,0], [0,0,1]]&lt;br /&gt;
fillVoxelValue = 0&lt;br /&gt;
&lt;br /&gt;
# Create an empty image volume, filled with fillVoxelValue&lt;br /&gt;
imageData = vtk.vtkImageData()&lt;br /&gt;
imageData.SetDimensions(imageSize)&lt;br /&gt;
imageData.AllocateScalars(voxelType, 1)&lt;br /&gt;
thresholder = vtk.vtkImageThreshold()&lt;br /&gt;
thresholder.SetInputData(imageData)&lt;br /&gt;
thresholder.SetInValue(fillVoxelValue)&lt;br /&gt;
thresholder.SetOutValue(fillVoxelValue)&lt;br /&gt;
thresholder.Update()&lt;br /&gt;
# Create volume node&lt;br /&gt;
volumeNode = slicer.mrmlScene.AddNewNodeByClass(&amp;quot;vtkMRMLScalarVolumeNode&amp;quot;, nodeName)&lt;br /&gt;
volumeNode.SetOrigin(imageOrigin)&lt;br /&gt;
volumeNode.SetSpacing(imageSpacing)&lt;br /&gt;
volumeNode.SetIJKToRASDirections(imageDirections)&lt;br /&gt;
volumeNode.SetAndObserveImageData(thresholder.GetOutput())&lt;br /&gt;
volumeNode.CreateDefaultDisplayNodes()&lt;br /&gt;
volumeNode.CreateDefaultStorageNode()&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Modify voxels in a volume ==&lt;br /&gt;
&lt;br /&gt;
Typically the fastest and simplest way of modifying voxels is by using numpy operators. Voxels can be retrieved in a numpy array using the `array` method and modified using standard numpy methods. For example, threshold a volume:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
nodeName = 'MRHead'&lt;br /&gt;
thresholdValue = 100&lt;br /&gt;
voxelArray = array(nodeName) # get voxels as numpy array&lt;br /&gt;
voxelArray[voxelArray &amp;lt; thresholdValue] = 0 # modify voxel values&lt;br /&gt;
getNode(nodeName).Modified() # at the end of all processing, notify Slicer that the image modification is completed&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This example shows how to change voxels values of the MRHead sample volume.&lt;br /&gt;
The values will be computed by function f(r,a,s,) = (r-10)*(r-10)+(a+15)*(a+15)+s*s.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
volumeNode=slicer.util.getNode('MRHead')&lt;br /&gt;
ijkToRas = vtk.vtkMatrix4x4()&lt;br /&gt;
volumeNode.GetIJKToRASMatrix(ijkToRas)&lt;br /&gt;
imageData=volumeNode.GetImageData()&lt;br /&gt;
extent = imageData.GetExtent()&lt;br /&gt;
for k in xrange(extent[4], extent[5]+1):&lt;br /&gt;
  for j in xrange(extent[2], extent[3]+1):&lt;br /&gt;
    for i in xrange(extent[0], extent[1]+1):&lt;br /&gt;
      position_Ijk=[i, j, k, 1]&lt;br /&gt;
      position_Ras=ijkToRas.MultiplyPoint(position_Ijk)&lt;br /&gt;
      r=position_Ras[0]&lt;br /&gt;
      a=position_Ras[1]&lt;br /&gt;
      s=position_Ras[2]      &lt;br /&gt;
      functionValue=(r-10)*(r-10)+(a+15)*(a+15)+s*s&lt;br /&gt;
      imageData.SetScalarComponentFromDouble(i,j,k,0,functionValue)&lt;br /&gt;
imageData.SetScalarComponentFromFloat(distortionVectorPosition_Ijk[0], distortionVectorPosition_Ijk[1], distortionVectorPosition_Ijk[2], 0, fillValue)&lt;br /&gt;
imageData.Modified()&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Get volume voxel coordinates from markup fiducial RAS coordinates ==&lt;br /&gt;
&lt;br /&gt;
This example shows how to get voxel coordinate of a volume corresponding to a markup fiducial point position.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Inputs&lt;br /&gt;
volumeNode = getNode('MRHead')&lt;br /&gt;
markupsNode = getNode('F')&lt;br /&gt;
markupsIndex = 1&lt;br /&gt;
&lt;br /&gt;
# Get point coordinate in RAS&lt;br /&gt;
point_Ras = [0, 0, 0, 1]&lt;br /&gt;
markupsNode.GetNthFiducialWorldCoordinates(markupsIndex, point_Ras)&lt;br /&gt;
&lt;br /&gt;
# If volume node is transformed, apply that transform to get volume's RAS coordinates&lt;br /&gt;
transformRasToVolumeRas = vtk.vtkGeneralTransform()&lt;br /&gt;
slicer.vtkMRMLTransformNode.GetTransformBetweenNodes(None, volumeNode.GetParentTransformNode(), transformRasToVolumeRas)&lt;br /&gt;
point_VolumeRas = transformRasToVolumeRas.TransformPoint(point_Ras[0:3])&lt;br /&gt;
&lt;br /&gt;
# Get voxel coordinates from physical coordinates&lt;br /&gt;
volumeRasToIjk = vtk.vtkMatrix4x4()&lt;br /&gt;
volumeNode.GetRASToIJKMatrix(volumeRasToIjk)&lt;br /&gt;
point_Ijk = [0, 0, 0, 1]&lt;br /&gt;
volumeRasToIjk.MultiplyPoint(np.append(point_VolumeRas,1.0), point_Ijk)&lt;br /&gt;
point_Ijk = [ int(round(c)) for c in point_Ijk[0:3] ]&lt;br /&gt;
&lt;br /&gt;
# Print output&lt;br /&gt;
print(point_Ijk)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Get the values of all voxels for a label value  ==&lt;br /&gt;
&lt;br /&gt;
If you have a background image called ‘Volume’ and a mask called ‘Volume-label’ created with the Editor you could do something like this:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
import numpy&lt;br /&gt;
volume = array(‘Volume’)&lt;br /&gt;
label = array(‘Volume-label’)&lt;br /&gt;
points  = numpy.where( label == 1 )  # or use another label number depending on what you segmented&lt;br /&gt;
values  = volume[points] # this will be a list of the label values&lt;br /&gt;
values.mean() # should match the mean value of LabelStatistics calculation as a double-check&lt;br /&gt;
numpy.savetxt(‘values.txt’, values)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Access values in a DTI tensor volume ==&lt;br /&gt;
This example shows how to access individual tensors at the voxel level.&lt;br /&gt;
&lt;br /&gt;
First load your DWI volume and estimate tensors to produce a DTI volume called ‘Output DTI Volume’&lt;br /&gt;
&lt;br /&gt;
Then open the python window: View-&amp;gt;Python interactor&lt;br /&gt;
&lt;br /&gt;
Use this command to access tensors through numpy:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
tensors = array('Output DTI Volume')&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Type the following code into the Python window to access all tensor components using vtk commands:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
volumeNode=slicer.util.getNode('Output DTI Volume')&lt;br /&gt;
imageData=volumeNode.GetImageData()&lt;br /&gt;
tensors = imageData.GetPointData().GetTensors()&lt;br /&gt;
extent = imageData.GetExtent()&lt;br /&gt;
idx = 0&lt;br /&gt;
for k in xrange(extent[4], extent[5]+1):&lt;br /&gt;
  for j in xrange(extent[2], extent[3]+1):&lt;br /&gt;
    for i in xrange(extent[0], extent[1]+1):&lt;br /&gt;
      tensors.GetTuple9(idx)&lt;br /&gt;
      idx += 1&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Change window/level (brightness/contrast) or colormap of a volume ==&lt;br /&gt;
This example shows how to change window/level of the MRHead sample volume.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
volumeNode = getNode('MRHead')&lt;br /&gt;
displayNode = volumeNode.GetDisplayNode()&lt;br /&gt;
displayNode.AutoWindowLevelOff()&lt;br /&gt;
displayNode.SetWindow(50)&lt;br /&gt;
displayNode.SetLevel(100)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Change color mapping from grayscale to rainbow:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
displayNode.SetAndObserveColorNodeID('vtkMRMLColorTableNodeRainbow')&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Manipulate a Slice View ==&lt;br /&gt;
&lt;br /&gt;
=== Change the slice offset ===&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
lm = slicer.app.layoutManager()&lt;br /&gt;
red = lm.sliceWidget('Red')&lt;br /&gt;
redLogic = red.sliceLogic()&lt;br /&gt;
# Print current slice offset position&lt;br /&gt;
print redLogic.GetSliceOffset()&lt;br /&gt;
# Change slice position&lt;br /&gt;
redLogic.SetSliceOffset(20)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Iterate over current visible slice views, and modify 3D visibility ===&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
for sliceViewName in layoutManager.sliceViewNames():&lt;br /&gt;
     sliceWidget = layoutManager.sliceWidget(sliceViewName)&lt;br /&gt;
     &lt;br /&gt;
     controller = sliceWidget.sliceController()&lt;br /&gt;
     controller.setSliceVisible(True)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Iterate over current visible slice views, and set foreground and background images ===&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
for sliceViewName in layoutManager.sliceViewNames():&lt;br /&gt;
     sliceWidget = layoutManager.sliceWidget(sliceViewName)&lt;br /&gt;
     &lt;br /&gt;
     # setup background volume&lt;br /&gt;
     compositeNode.SetBackgroundVolumeID(MRVolume.GetID())&lt;br /&gt;
     # setup foreground volume&lt;br /&gt;
     compositeNode.SetForegroundVolumeID(CTVolume.GetID())&lt;br /&gt;
     # change opacity&lt;br /&gt;
     compositeNode.SetForegroundOpacity(0.3)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Fit slice plane to markup fiducials ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sliceNode = slicer.mrmlScene.GetNodeByID(&amp;quot;vtkMRMLSliceNodeRed&amp;quot;)&lt;br /&gt;
markupsNode = slicer.mrmlScene.GetFirstNodeByName(&amp;quot;F&amp;quot;)&lt;br /&gt;
# Get markup point positions as numpy arrays&lt;br /&gt;
import numpy as np&lt;br /&gt;
p1 = np.array([0,0,0])&lt;br /&gt;
p2 = np.array([0,0,0])&lt;br /&gt;
p3 = np.array([0,0,0])&lt;br /&gt;
markupsNode.GetNthFiducialPosition(0, p1)&lt;br /&gt;
markupsNode.GetNthFiducialPosition(1, p2)&lt;br /&gt;
markupsNode.GetNthFiducialPosition(2, p3)&lt;br /&gt;
# Get plane axis directions&lt;br /&gt;
n = np.cross(p2-p1, p2-p3) # plane normal direction&lt;br /&gt;
n = n/np.linalg.norm(n)&lt;br /&gt;
t = np.cross([0, 0, 1], n) # plane transverse direction&lt;br /&gt;
t = t/np.linalg.norm(t)&lt;br /&gt;
# Set slice plane orientation and position&lt;br /&gt;
sliceNode.SetSliceToRASByNTP(n[0], n[1], n[2], t[0], t[1], t[2], p1[0], p1[1], p1[2], 0)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Save a series of images from a Slice View ==&lt;br /&gt;
&lt;br /&gt;
You can use ScreenCapture module to capture series of images. To do it programmatically, save the following into a file such as '/tmp/record.py' and then in the slicer python console type &amp;quot;execfile('/tmp/record.py')&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
layoutName = 'Green'&lt;br /&gt;
imagePathPattern = '/tmp/image-%03d.png'&lt;br /&gt;
steps = 10&lt;br /&gt;
&lt;br /&gt;
widget = slicer.app.layoutManager().sliceWidget(layoutName)&lt;br /&gt;
view = widget.sliceView()&lt;br /&gt;
logic = widget.sliceLogic()&lt;br /&gt;
bounds = [0,]*6&lt;br /&gt;
logic.GetSliceBounds(bounds)&lt;br /&gt;
&lt;br /&gt;
for step in range(steps):&lt;br /&gt;
    offset = bounds[4] + step/(1.*steps) * (bounds[5]-bounds[4])&lt;br /&gt;
    logic.SetSliceOffset(offset)&lt;br /&gt;
    view.forceRender()&lt;br /&gt;
    image = qt.QPixmap.grabWidget(view).toImage()&lt;br /&gt;
    image.save(imagePathPattern % step)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Save the scene into a new directory ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Create a new directory where the scene will be saved into&lt;br /&gt;
import time&lt;br /&gt;
sceneSaveDirectory = slicer.app.temporaryPath + &amp;quot;/saved-scene-&amp;quot; + time.strftime(&amp;quot;%Y%m%d-%H%M%S&amp;quot;)&lt;br /&gt;
if not os.access(sceneSaveDirectory, os.F_OK):&lt;br /&gt;
  os.makedirs(sceneSaveDirectory)&lt;br /&gt;
&lt;br /&gt;
# Save the scene&lt;br /&gt;
if slicer.app.applicationLogic().SaveSceneToSlicerDataBundleDirectory(sceneSaveDirectory, None):&lt;br /&gt;
  logging.info(&amp;quot;Scene saved to: {0}&amp;quot;.format(sceneSaveDirectory))&lt;br /&gt;
else:&lt;br /&gt;
  logging.error(&amp;quot;Scene saving failed&amp;quot;) &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Save the scene into a single MRB file ==&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Generate file name&lt;br /&gt;
import time&lt;br /&gt;
sceneSaveFilename = slicer.app.temporaryPath + &amp;quot;/saved-scene-&amp;quot; + time.strftime(&amp;quot;%Y%m%d-%H%M%S&amp;quot;) + &amp;quot;.mrb&amp;quot;&lt;br /&gt;
&lt;br /&gt;
# Save scene&lt;br /&gt;
if slicer.util.saveScene(sceneSaveFilename):&lt;br /&gt;
  logging.info(&amp;quot;Scene saved to: {0}&amp;quot;.format(sceneSaveFilename))&lt;br /&gt;
else:&lt;br /&gt;
  logging.error(&amp;quot;Scene saving failed&amp;quot;) &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Save a node to file ==&lt;br /&gt;
&lt;br /&gt;
Save a transform node to file (should work with any other node type, if file extension is set to a supported one):&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
myNode = getNode(&amp;quot;LinearTransform_3&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
myStorageNode = myNode.CreateDefaultStorageNode()&lt;br /&gt;
myStorageNode.SetFileName(&amp;quot;c:/tmp/something.tfm&amp;quot;)&lt;br /&gt;
myStorageNode.WriteData(myNode)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Show a volume in the Slice Views ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
volumeNode = slicer.util.getNode('YourVolumeNode')&lt;br /&gt;
applicationLogic = slicer.app.applicationLogic()&lt;br /&gt;
selectionNode = applicationLogic.GetSelectionNode()&lt;br /&gt;
selectionNode.SetSecondaryVolumeID(volumeNode.GetID())&lt;br /&gt;
applicationLogic.PropagateForegroundVolumeSelection(0) &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
or&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
n =  slicer.util.getNode('YourVolumeNode')&lt;br /&gt;
for color in ['Red', 'Yellow', 'Green']:&lt;br /&gt;
    slicer.app.layoutManager().sliceWidget(color).sliceLogic().GetSliceCompositeNode().SetForegroundVolumeID(n.GetID())&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Change opacity of foreground volume in the Slice Views ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
lm = slicer.app.layoutManager()&lt;br /&gt;
sliceLogic = lm.sliceWidget('Red').sliceLogic()&lt;br /&gt;
compositeNode = sliceLogic.GetSliceCompositeNode()&lt;br /&gt;
compositeNode.SetForegroundOpacity(0.4)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Center the 3D View on the Scene ==&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
layoutManager = slicer.app.layoutManager()&lt;br /&gt;
threeDWidget = layoutManager.threeDWidget(0)&lt;br /&gt;
threeDView = threeDWidget.threeDView()&lt;br /&gt;
threeDView.resetFocalPoint()&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Rotate the 3D View==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
layoutManager = slicer.app.layoutManager()&lt;br /&gt;
threeDWidget = layoutManager.threeDWidget(0)&lt;br /&gt;
threeDView = threeDWidget.threeDView()&lt;br /&gt;
threeDView.yaw()&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Display text in a 3D view or slice view ==&lt;br /&gt;
&lt;br /&gt;
The easiest way to show information overlaid on a viewer is to use corner annotations.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
view=slicer.app.layoutManager().threeDWidget(0).threeDView()&lt;br /&gt;
# Set text to &amp;quot;Something&amp;quot;&lt;br /&gt;
view.cornerAnnotation().SetText(vtk.vtkCornerAnnotation.UpperRight,&amp;quot;Something&amp;quot;)&lt;br /&gt;
# Set color to red&lt;br /&gt;
view.cornerAnnotation().GetTextProperty().SetColor(1,0,0)&lt;br /&gt;
# Update the view&lt;br /&gt;
view.forceRender()&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Hide slice view annotations (DataProbe) ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Disable slice annotations immediately&lt;br /&gt;
slicer.modules.DataProbeInstance.infoWidget.sliceAnnotations.sliceViewAnnotationsEnabled=False&lt;br /&gt;
slicer.modules.DataProbeInstance.infoWidget.sliceAnnotations.updateSliceViewFromGUI()&lt;br /&gt;
# Disable slice annotations persistently (after Slicer restarts)&lt;br /&gt;
settings = qt.QSettings()&lt;br /&gt;
settings.setValue('DataProbe/sliceViewAnnotations.enabled', 0)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Turning off interpolation ==&lt;br /&gt;
&lt;br /&gt;
You can turn off interpolation for newly loaded volumes with this script from Steve Pieper.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
def NoInterpolate(caller,event):&lt;br /&gt;
  for node in slicer.util.getNodes('*').values():&lt;br /&gt;
    if node.IsA('vtkMRMLScalarVolumeDisplayNode'):&lt;br /&gt;
      node.SetInterpolate(0)&lt;br /&gt;
	&lt;br /&gt;
slicer.mrmlScene.AddObserver(slicer.mrmlScene.NodeAddedEvent, NoInterpolate)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The below link explains how to put this in your startup script.&lt;br /&gt;
&lt;br /&gt;
http://www.na-mic.org/Wiki/index.php/AHM2012-Slicer-Python#Refining_the_code_and_UI_with_slicerrc&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Customize viewer layout ==&lt;br /&gt;
&lt;br /&gt;
Show a custom layout of a 3D view on top of the red slice view:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
customLayout = (&amp;quot;&amp;lt;layout type=\&amp;quot;vertical\&amp;quot; split=\&amp;quot;true\&amp;quot; &amp;gt;&amp;quot;&lt;br /&gt;
  &amp;quot; &amp;lt;item&amp;gt;&amp;quot;&lt;br /&gt;
  &amp;quot;  &amp;lt;view class=\&amp;quot;vtkMRMLViewNode\&amp;quot; singletontag=\&amp;quot;1\&amp;quot;&amp;gt;&amp;quot;&lt;br /&gt;
  &amp;quot;    &amp;lt;property name=\&amp;quot;viewlabel\&amp;quot; action=\&amp;quot;default\&amp;quot;&amp;gt;1&amp;lt;/property&amp;gt;&amp;quot;&lt;br /&gt;
  &amp;quot;  &amp;lt;/view&amp;gt;&amp;quot;&lt;br /&gt;
  &amp;quot; &amp;lt;/item&amp;gt;&amp;quot;&lt;br /&gt;
  &amp;quot; &amp;lt;item&amp;gt;&amp;quot;&lt;br /&gt;
  &amp;quot;  &amp;lt;view class=\&amp;quot;vtkMRMLSliceNode\&amp;quot; singletontag=\&amp;quot;Red\&amp;quot;&amp;gt;&amp;quot;&lt;br /&gt;
  &amp;quot;   &amp;lt;property name=\&amp;quot;orientation\&amp;quot; action=\&amp;quot;default\&amp;quot;&amp;gt;Axial&amp;lt;/property&amp;gt;&amp;quot;&lt;br /&gt;
  &amp;quot;   &amp;lt;property name=\&amp;quot;viewlabel\&amp;quot; action=\&amp;quot;default\&amp;quot;&amp;gt;R&amp;lt;/property&amp;gt;&amp;quot;&lt;br /&gt;
  &amp;quot;   &amp;lt;property name=\&amp;quot;viewcolor\&amp;quot; action=\&amp;quot;default\&amp;quot;&amp;gt;#F34A33&amp;lt;/property&amp;gt;&amp;quot;&lt;br /&gt;
  &amp;quot;  &amp;lt;/view&amp;gt;&amp;quot;&lt;br /&gt;
  &amp;quot; &amp;lt;/item&amp;gt;&amp;quot;&lt;br /&gt;
  &amp;quot;&amp;lt;/layout&amp;gt;&amp;quot;)&lt;br /&gt;
  &lt;br /&gt;
customLayoutId=501&lt;br /&gt;
&lt;br /&gt;
layoutManager = slicer.app.layoutManager()&lt;br /&gt;
layoutManager.layoutLogic().GetLayoutNode().AddLayoutDescription(customLayoutId, customLayout)                                         &lt;br /&gt;
layoutManager.setLayout(customLayoutId)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
See description of standard layouts (that can be used as examples) here:&lt;br /&gt;
https://github.com/Slicer/Slicer/blob/master/Libs/MRML/Logic/vtkMRMLLayoutLogic.cxx&lt;br /&gt;
&lt;br /&gt;
== Customize keyboard shortcuts ==&lt;br /&gt;
&lt;br /&gt;
Keyboard shortcuts can be specified for activating any Slicer feature by adding a couple of lines to your &lt;br /&gt;
[[Documentation/{{documentation/version}}/Developers/Python_scripting#How_to_systematically_execute_custom_python_code_at_startup_.3F|.slicerrc file]].&lt;br /&gt;
&lt;br /&gt;
For example, this script registers ''Ctrl+b'', ''Ctrl+n'', ''Ctrl+m'', ''Ctrl+,'' keyboard shortcuts to switch between red, yellow, green, and 4-up view layouts.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
shortcuts = [&lt;br /&gt;
    ('Ctrl+b', lambda: slicer.app.layoutManager().setLayout(slicer.vtkMRMLLayoutNode.SlicerLayoutOneUpRedSliceView)),&lt;br /&gt;
    ('Ctrl+n', lambda: slicer.app.layoutManager().setLayout(slicer.vtkMRMLLayoutNode.SlicerLayoutOneUpYellowSliceView)),&lt;br /&gt;
    ('Ctrl+m', lambda: slicer.app.layoutManager().setLayout(slicer.vtkMRMLLayoutNode.SlicerLayoutOneUpGreenSliceView)),&lt;br /&gt;
    ('Ctrl+,', lambda: slicer.app.layoutManager().setLayout(slicer.vtkMRMLLayoutNode.SlicerLayoutFourUpView))&lt;br /&gt;
    ]&lt;br /&gt;
&lt;br /&gt;
for (shortcutKey, callback) in shortcuts:&lt;br /&gt;
    shortcut = qt.QShortcut(slicer.util.mainWindow())&lt;br /&gt;
    shortcut.setKey(qt.QKeySequence(shortcutKey))&lt;br /&gt;
    shortcut.connect( 'activated()', callback)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Disable certain user interactions in slice views ==&lt;br /&gt;
&lt;br /&gt;
For example, disable slice browsing using mouse wheel and keyboard shortcuts in the red slice viewer:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
interactorStyle = slicer.app.layoutManager().sliceWidget('Red').sliceView().sliceViewInteractorStyle()&lt;br /&gt;
interactorStyle.SetActionEnabled(interactorStyle.BrowseSlice, False)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Hide all slice view controllers:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
lm = slicer.app.layoutManager()&lt;br /&gt;
for sliceViewName in lm.sliceViewNames():&lt;br /&gt;
  lm.sliceWidget(sliceViewName).sliceController().setVisible(False)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Hide all 3D view controllers:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
lm = slicer.app.layoutManager()&lt;br /&gt;
for viewIndex in range(slicer.app.layoutManager().threeDViewCount):&lt;br /&gt;
  lm.threeDWidget(0).threeDController().setVisible(False)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Change default slice view orientation ==&lt;br /&gt;
&lt;br /&gt;
You can left-right &amp;quot;flip&amp;quot; slice view orientation presets (show patient left side on left/right side of the screen) by copy-pasting the script below to your [[Documentation/{{documentation/version}}/Developers/FAQ/Python_Scripting#How_to_systematically_execute_custom_python_code_at_startup_.3F| .slicerrc.py file]].&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Axial slice axes:&lt;br /&gt;
#  1 0 0&lt;br /&gt;
#  0 1 0&lt;br /&gt;
#  0 0 1&lt;br /&gt;
axialSliceToRas=vtk.vtkMatrix3x3()&lt;br /&gt;
&lt;br /&gt;
# Coronal slice axes:&lt;br /&gt;
#  1 0 0 &lt;br /&gt;
#  0 0 -1&lt;br /&gt;
#  0 1 0&lt;br /&gt;
coronalSliceToRas=vtk.vtkMatrix3x3()&lt;br /&gt;
coronalSliceToRas.SetElement(1,1, 0)&lt;br /&gt;
coronalSliceToRas.SetElement(1,2, -1)&lt;br /&gt;
coronalSliceToRas.SetElement(2,1, 1)&lt;br /&gt;
coronalSliceToRas.SetElement(2,2, 0)&lt;br /&gt;
&lt;br /&gt;
# Replace orientation presets in all existing slice nodes and in the default slice node&lt;br /&gt;
sliceNodes = slicer.util.getNodesByClass('vtkMRMLSliceNode')&lt;br /&gt;
sliceNodes.append(slicer.mrmlScene.GetDefaultNodeByClass('vtkMRMLSliceNode'))&lt;br /&gt;
for sliceNode in sliceNodes:&lt;br /&gt;
  orientationPresetName = sliceNode.GetOrientation()&lt;br /&gt;
  sliceNode.RemoveSliceOrientationPreset(&amp;quot;Axial&amp;quot;)&lt;br /&gt;
  sliceNode.AddSliceOrientationPreset(&amp;quot;Axial&amp;quot;, axialSliceToRas)&lt;br /&gt;
  sliceNode.RemoveSliceOrientationPreset(&amp;quot;Coronal&amp;quot;)&lt;br /&gt;
  sliceNode.AddSliceOrientationPreset(&amp;quot;Coronal&amp;quot;, coronalSliceToRas)&lt;br /&gt;
  sliceNode.SetOrientation(orientationPresetName)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Set all slice views linked by default ==&lt;br /&gt;
&lt;br /&gt;
You can make slice views linked by default (when application starts or the scene is cleared) by copy-pasting the script below to your [[Documentation/{{documentation/version}}/Developers/FAQ/Python_Scripting#How_to_systematically_execute_custom_python_code_at_startup_.3F| .slicerrc.py file]].&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Set linked slice views  in all existing slice composite nodes and in the default node&lt;br /&gt;
sliceCompositeNodes = slicer.util.getNodesByClass('vtkMRMLSliceCompositeNode')&lt;br /&gt;
defaultSliceCompositeNode = slicer.mrmlScene.GetDefaultNodeByClass('vtkMRMLSliceCompositeNode')&lt;br /&gt;
if not defaultSliceCompositeNode:&lt;br /&gt;
  defaultSliceCompositeNode = slicer.mrmlScene.CreateNodeByClass('vtkMRMLSliceCompositeNode')&lt;br /&gt;
  slicer.mrmlScene.AddDefaultNode(defaultSliceCompositeNode)&lt;br /&gt;
sliceCompositeNodes.append(defaultSliceCompositeNode)&lt;br /&gt;
for sliceCompositeNode in sliceCompositeNodes:&lt;br /&gt;
  sliceCompositeNode.SetLinkedControl(True)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Set up custom units in slice view ruler ==&lt;br /&gt;
&lt;br /&gt;
For microscopy or micro-CT images you may want to switch unit to micrometer instead of the default mm. To do that, 1. change the unit in Application settings / Units and 2. update ruler display settings using the script below (it can be copied to your Application startup script):&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
lm = slicer.app.layoutManager()&lt;br /&gt;
for sliceViewName in lm.sliceViewNames():&lt;br /&gt;
  sliceView = lm.sliceWidget(sliceViewName).sliceView()&lt;br /&gt;
  displayableManagerCollection = vtk.vtkCollection()&lt;br /&gt;
  sliceView.getDisplayableManagers(displayableManagerCollection)&lt;br /&gt;
  for dmIndex in xrange(displayableManagerCollection.GetNumberOfItems()):&lt;br /&gt;
    displayableManager = displayableManagerCollection.GetItemAsObject(dmIndex)&lt;br /&gt;
    if not displayableManager.IsA(&amp;quot;vtkMRMLRulerDisplayableManager&amp;quot;):&lt;br /&gt;
      continue&lt;br /&gt;
    displayableManager.RemoveAllRulerScalePresets()&lt;br /&gt;
    displayableManager.AddRulerScalePreset(   0.001, 5, 2, &amp;quot;nm&amp;quot;, 1000.0)&lt;br /&gt;
    displayableManager.AddRulerScalePreset(   0.010, 5, 2, &amp;quot;nm&amp;quot;, 1000.0)&lt;br /&gt;
    displayableManager.AddRulerScalePreset(   0.100, 5, 2, &amp;quot;nm&amp;quot;, 1000.0)&lt;br /&gt;
    displayableManager.AddRulerScalePreset(   0.500, 5, 1, &amp;quot;nm&amp;quot;, 1000.0)&lt;br /&gt;
    displayableManager.AddRulerScalePreset(   1.0,   5, 2, &amp;quot;um&amp;quot;,    1.0)&lt;br /&gt;
    displayableManager.AddRulerScalePreset(   5.0,   5, 1, &amp;quot;um&amp;quot;,    1.0)&lt;br /&gt;
    displayableManager.AddRulerScalePreset(  10.0,   5, 2, &amp;quot;um&amp;quot;,    1.0)&lt;br /&gt;
    displayableManager.AddRulerScalePreset(  50.0,   5, 1, &amp;quot;um&amp;quot;,    1.0)&lt;br /&gt;
    displayableManager.AddRulerScalePreset( 100.0,   5, 2, &amp;quot;um&amp;quot;,    1.0)&lt;br /&gt;
    displayableManager.AddRulerScalePreset( 500.0,   5, 1, &amp;quot;um&amp;quot;,    1.0)&lt;br /&gt;
    displayableManager.AddRulerScalePreset(1000.0,   5, 2, &amp;quot;mm&amp;quot;,    0.001)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Show a slice view outside the view layout ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sliceLayoutName = &amp;quot;TestSlice&amp;quot;&lt;br /&gt;
sliceLayoutLabel = &amp;quot;T&amp;quot;&lt;br /&gt;
# ownerNode manages this view instead of the layout manager (it can be any node in the scene)&lt;br /&gt;
viewOwnerNode = slicer.mrmlScene.AddNewNodeByClass(&amp;quot;vtkMRMLScriptedModuleNode&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
# Create MRML nodes&lt;br /&gt;
sliceNode = slicer.vtkMRMLSliceNode()&lt;br /&gt;
sliceNode.SetName(sliceLayoutName)&lt;br /&gt;
sliceNode.SetLayoutName(sliceLayoutName)&lt;br /&gt;
sliceNode.SetLayoutLabel(sliceLayoutLabel)&lt;br /&gt;
sliceNode.SetLayoutColor(1, 1, 0)&lt;br /&gt;
sliceNode.SetAndObserveParentLayoutNodeID(viewOwnerNode.GetID())&lt;br /&gt;
sliceNode = slicer.mrmlScene.AddNode(sliceNode)&lt;br /&gt;
sliceCompositeNode = slicer.mrmlScene.AddNewNodeByClass(&amp;quot;vtkMRMLSliceCompositeNode&amp;quot;)&lt;br /&gt;
sliceCompositeNode.SetLayoutName(sliceLayoutName)&lt;br /&gt;
&lt;br /&gt;
# Create widget&lt;br /&gt;
sliceWidget = slicer.qMRMLSliceWidget()&lt;br /&gt;
sliceWidget.sliceViewName = sliceLayoutName&lt;br /&gt;
sliceWidget.sliceViewLabel = sliceLayoutLabel&lt;br /&gt;
c = sliceNode.GetLayoutColor()&lt;br /&gt;
sliceWidget.sliceViewColor = qt.QColor.fromRgbF(c[0],c[1],c[2])&lt;br /&gt;
sliceWidget.setMRMLScene(slicer.mrmlScene)&lt;br /&gt;
sliceWidget.setMRMLSliceNode(sliceNode)&lt;br /&gt;
sliceWidget.show()&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Running an ITK filter in Python using SimpleITK ==&lt;br /&gt;
Open the &amp;quot;Sample Data&amp;quot; module and download &amp;quot;MR Head&amp;quot;, then paste the following snippet in Python interactor:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
import SimpleITK as sitk&lt;br /&gt;
import sitkUtils&lt;br /&gt;
inputImage = sitkUtils.PullFromSlicer('MRHead')&lt;br /&gt;
filter = sitk.SignedMaurerDistanceMapImageFilter()&lt;br /&gt;
outputImage = filter.Execute(inputImage)&lt;br /&gt;
sitkUtils.PushToSlicer(outputImage,'outputImage')&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
More information:&lt;br /&gt;
* See the SimpleITK documentation for SimpleITK examples: http://www.itk.org/SimpleITKDoxygen/html/examples.html&lt;br /&gt;
* sitkUtils in Slicer is used for pushing and pulling images from Slicer to SimpleITK: https://github.com/Slicer/Slicer/blob/master/Base/Python/sitkUtils.py&lt;br /&gt;
&lt;br /&gt;
== Get current mouse coordinates in a slice view ==&lt;br /&gt;
&lt;br /&gt;
You can get 3D (RAS) coordinates of the current mouse cursor from the crosshair singleton node as shown in the example below:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
def onMouseMoved(observer,eventid):  &lt;br /&gt;
  ras=[0,0,0]&lt;br /&gt;
  crosshairNode.GetCursorPositionRAS(ras)&lt;br /&gt;
  print(ras)&lt;br /&gt;
&lt;br /&gt;
crosshairNode=slicer.util.getNode('Crosshair') &lt;br /&gt;
crosshairNode.AddObserver(slicer.vtkMRMLCrosshairNode.CursorPositionModifiedEvent, onMouseMoved)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Get DataProbe text ==&lt;br /&gt;
&lt;br /&gt;
You can get the mouse location in pixel coordinates along with the pixel value at the mouse by hitting the '.' (period) key in a slice view after pasting in the following code.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
def printDataProbe():&lt;br /&gt;
  infoWidget = slicer.modules.DataProbeInstance.infoWidget&lt;br /&gt;
  for layer in ('B', 'F', 'L'):&lt;br /&gt;
    print(infoWidget.layerNames[layer].text, infoWidget.layerIJKs[layer].text, infoWidget.layerValues[layer].text)&lt;br /&gt;
&lt;br /&gt;
s = qt.QShortcut(qt.QKeySequence('.'), mainWindow())&lt;br /&gt;
s.connect('activated()', printDataProbe)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Thick slab reconstruction and maximum/minimum intensity volume projections ==&lt;br /&gt;
&lt;br /&gt;
Set up 'red' slice viewer to show thick slab reconstructed from 3 slices:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sliceNode = slicer.mrmlScene.GetNodeByID('vtkMRMLSliceNodeRed')&lt;br /&gt;
appLogic = slicer.app.applicationLogic()&lt;br /&gt;
sliceLogic = appLogic.GetSliceLogic(sliceNode)&lt;br /&gt;
sliceLayerLogic = sliceLogic.GetBackgroundLayer()&lt;br /&gt;
reslice = sliceLayerLogic.GetReslice()&lt;br /&gt;
reslice.SetSlabModeToMean()&lt;br /&gt;
reslice.SetSlabNumberOfSlices(10) # mean of 10 slices will computed&lt;br /&gt;
reslice.SetSlabSliceSpacingFraction(0.3) # spacing between each slice is 0.3 pixel (total 10 * 0.3 = 3 pixel neighborhood)&lt;br /&gt;
sliceNode.Modified()&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Set up 'red' slice viewer to show maximum intensity projection (MIP):&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sliceNode = slicer.mrmlScene.GetNodeByID('vtkMRMLSliceNodeRed')&lt;br /&gt;
appLogic = slicer.app.applicationLogic()&lt;br /&gt;
sliceLogic = appLogic.GetSliceLogic(sliceNode)&lt;br /&gt;
sliceLayerLogic = sliceLogic.GetBackgroundLayer()&lt;br /&gt;
reslice = sliceLayerLogic.GetReslice()&lt;br /&gt;
reslice.SetSlabModeToMax()&lt;br /&gt;
reslice.SetSlabNumberOfSlices(600) # use a large number of slices (600) to cover the entire volume&lt;br /&gt;
reslice.SetSlabSliceSpacingFraction(0.5) # spacing between slices are 0.5 pixel (supersampling is useful to reduce interpolation artifacts)&lt;br /&gt;
sliceNode.Modified()&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The projected image is available in a ''vtkImageData'' object by calling ''reslice.GetOutput()''.&lt;br /&gt;
&lt;br /&gt;
== Change default file type for nodes (that have never been saved yet) ==&lt;br /&gt;
Default node can be specified that will be used as a basis of all new storage nodes. This can be used for setting default file extension. For example, change file format to STL for model nodes:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
defaultModelStorageNode = slicer.vtkMRMLModelStorageNode()&lt;br /&gt;
defaultModelStorageNode.SetDefaultWriteFileExtension('stl')&lt;br /&gt;
slicer.mrmlScene.AddDefaultNode(defaultModelStorageNode)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To permanently change default file extension on your computer, copy-paste the code above into your application startup script (you can find its location in menu: Edit / Application settings / General / Application startup script).&lt;br /&gt;
&lt;br /&gt;
== Change file type for saving for all volumes (with already existing storage nodes) ==&lt;br /&gt;
&lt;br /&gt;
If it is not necessary to preserve file paths then the simplest is to configure default storage node (as shown in the example above), then delete all existing storage nodes. When save dialog is opened, default storage nodes will be recreated.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Delete existing model storage nodes so that they will be recreated with default settings&lt;br /&gt;
existingModelStorageNodes = slicer.util.getNodesByClass('vtkMRMLModelStorageNode')&lt;br /&gt;
for modelStorageNode in existingModelStorageNodes:&lt;br /&gt;
  slicer.mrmlScene.RemoveNode(modelStorageNode)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To update existing storage nodes to use new file extension (but keep all other parameters unchanged) you can use this approach (example is for volume storage):&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
requiredFileExtension = '.nia'&lt;br /&gt;
originalFileExtension = '.nrrd'&lt;br /&gt;
volumeNodes = slicer.util.getNodesByClass('vtkMRMLScalarVolumeNode')&lt;br /&gt;
for volumeNode in volumeNodes:&lt;br /&gt;
  volumeStorageNode = volumeNode.GetStorageNode()&lt;br /&gt;
  if not volumeStorageNode:&lt;br /&gt;
    volumeNode.AddDefaultStorageNode()&lt;br /&gt;
    volumeStorageNode = volumeNode.GetStorageNode()&lt;br /&gt;
    volumeStorageNode.SetFileName(volumeNode.GetName()+requiredFileExtension)&lt;br /&gt;
  else:&lt;br /&gt;
    volumeStorageNode.SetFileName(volumeStorageNode.GetFileName().replace(originalFileExtension, requiredFileExtension))&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Segmentations ==&lt;br /&gt;
&lt;br /&gt;
=== Create a segmentation from a labelmap volume and display in 3D ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
labelmapVolumeNode = getNode('label')&lt;br /&gt;
seg = slicer.mrmlScene.AddNewNodeByClass('vtkMRMLSegmentationNode')&lt;br /&gt;
slicer.modules.segmentations.logic().ImportLabelmapToSegmentationNode(labelmapVolumeNode, seg)&lt;br /&gt;
seg.CreateClosedSurfaceRepresentation()&lt;br /&gt;
slicer.mrmlScene.RemoveNode(labelmapVolumeNode)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The last line is optional. It removes the original labelmap volume so that the same information is not shown twice.&lt;br /&gt;
&lt;br /&gt;
=== Export labelmap node from segmentation node ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
seg = getNode('Segmentation')&lt;br /&gt;
labelmapVolumeNode = slicer.mrmlScene.AddNewNodeByClass('vtkMRMLLabelMapVolumeNode')&lt;br /&gt;
slicer.modules.segmentations.logic().ExportAllSegmentsToLabelmapNode(seg, labelmapVolumeNode)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Export model nodes from segmentation node ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
seg = getNode('Segmentation')&lt;br /&gt;
exportedModelsNode = slicer.mrmlScene.AddNewNodeByClass('vtkMRMLModelHierarchyNode')&lt;br /&gt;
slicer.modules.segmentations.logic().ExportAllSegmentsToModelHierarchy(seg, exportedModelsNode)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Show a segmentation in 3D ===&lt;br /&gt;
Segmentation can only be shown in 3D if closed surface representation (or other 3D-displayable representation) is available. To create closed surface representation:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
segmentation.CreateClosedSurfaceRepresentation()&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Get a representation of a segment ===&lt;br /&gt;
Access binary labelmap stored in a segmentation node (without exporting it to a volume node) - if it does not exist, it will return None:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
image = segmentationNode.GetBinaryLabelmapRepresentation(segmentID)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Get closed surface, if it does not exist, it will return None:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
polydata = segmentationNode.GetClosedSurfaceRepresentation(segmentID)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Get binary labelmap representation. If it does not exist then it will be created for that single segment. Applies parent transforms by default (if not desired, another argument needs to be added to the end: false):&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
import vtkSegmentationCorePython as vtkSegmentationCore&lt;br /&gt;
outputOrientedImageData = vtkSegmentationCore.vtkOrientedImageData()&lt;br /&gt;
slicer.vtkSlicerSegmentationsModuleLogic.GetSegmentBinaryLabelmapRepresentation(segmentationNode, segmentID, outputOrientedImageData)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Same as above, for closed surface representation:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
outputPolyData = vtk.vtkPolyData()&lt;br /&gt;
slicer.vtkSlicerSegmentationsModuleLogic.GetSegmentClosedSurfaceRepresentation(segmentationNode, segmentID, outputPolyData)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Convert all segments using default path and conversion parameters ===&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
segmentationNode.CreateBinaryLabelmapRepresentation()&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Convert all segments using custom path or conversion parameters ===&lt;br /&gt;
Change reference image geometry parameter based on an existing referenceImageData image:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
import vtkSegmentationCorePython as vtkSegmentationCore&lt;br /&gt;
referenceGeometry = vtkSegmentationCore.vtkSegmentationConverter.SerializeImageGeometry(referenceImageData)&lt;br /&gt;
segmentation.SetConversionParameter(vtkSegmentationCore.vtkSegmentationConverter.GetReferenceImageGeometryParameterName(), referenceGeometry)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Re-convert using a modified conversion parameter ===&lt;br /&gt;
Changing smoothing factor for closed surface generation:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
import vtkSegmentationCorePython as vtkSegmentationCore&lt;br /&gt;
segmentation = getNode('Segmentation').GetSegmentation()&lt;br /&gt;
&lt;br /&gt;
# Turn of surface smoothing&lt;br /&gt;
segmentation.SetConversionParameter('Smoothing factor','0.0')&lt;br /&gt;
&lt;br /&gt;
# Recreate representation using modified parameters (and default conversion path)&lt;br /&gt;
segmentation.RemoveRepresentation(vtkSegmentationCore.vtkSegmentationConverter.GetSegmentationClosedSurfaceRepresentationName())&lt;br /&gt;
segmentation.CreateRepresentation(vtkSegmentationCore.vtkSegmentationConverter.GetSegmentationClosedSurfaceRepresentationName())&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Get centroid of a segment in world (RAS) coordinates ===&lt;br /&gt;
&lt;br /&gt;
This example shows how to get centroid of a segment in world coordinates and show that position in all slice views.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
segmentationNode = getNode('Segmentation')&lt;br /&gt;
segmentId = 'Segment_1'&lt;br /&gt;
&lt;br /&gt;
# Get array voxel coordinates&lt;br /&gt;
import numpy as np&lt;br /&gt;
seg=arrayFromSegment(segmentation_node, segmentId)&lt;br /&gt;
# numpy array has voxel coordinates in reverse order (KJI instead of IJK)&lt;br /&gt;
# and the array is cropped to minimum size in the segmentation&lt;br /&gt;
mean_KjiCropped = [coords.mean() for coords in np.nonzero(seg)]&lt;br /&gt;
&lt;br /&gt;
# Get segmentation voxel coordinates&lt;br /&gt;
segImage = segmentationNode.GetBinaryLabelmapRepresentation(segmentId)&lt;br /&gt;
segImageExtent = segImage.GetExtent()&lt;br /&gt;
# origin of the array in voxel coordinates is determined by the start extent&lt;br /&gt;
mean_Ijk = [mean_KjiCropped[2], mean_KjiCropped[1], mean_KjiCropped[0]] + np.array([segImageExtent[0], segImageExtent[2], segImageExtent[4]])&lt;br /&gt;
&lt;br /&gt;
# Get segmentation physical coordinates&lt;br /&gt;
ijkToWorld = vtk.vtkMatrix4x4()&lt;br /&gt;
segImage.GetImageToWorldMatrix(ijkToWorld)&lt;br /&gt;
mean_World = [0, 0, 0, 1]&lt;br /&gt;
ijkToRas.MultiplyPoint(np.append(mean_Ijk,1.0), mean_World)&lt;br /&gt;
mean_World = mean_World[0:3]&lt;br /&gt;
&lt;br /&gt;
# If segmentation node is transformed, apply that transform to get RAS coordinates&lt;br /&gt;
transformWorldToRas = vtk.vtkGeneralTransform()&lt;br /&gt;
slicer.vtkMRMLTransformNode.GetTransformBetweenNodes(segmentationNode.GetParentTransformNode(), None, transformWorldToRas)&lt;br /&gt;
mean_Ras = transformWorldToRas.TransformPoint(mean_World)&lt;br /&gt;
&lt;br /&gt;
# Show mean position value and jump to it in all slice viewers&lt;br /&gt;
print(mean_Ras)&lt;br /&gt;
slicer.modules.markups.logic().JumpSlicesToLocation(mean_Ras[0], mean_Ras[1], mean_Ras[2], True)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== How to run segment editor effects from a script ===&lt;br /&gt;
&lt;br /&gt;
Editor effects are complex because they need to handle changing master volumes, undo/redo, masking operations, etc. Therefore, instead of using a segment editor effect, it is simpler to run the underlying filters directly from script.&lt;br /&gt;
&lt;br /&gt;
This example demonstrates how to use Segment editor effects (without GUI, using qMRMLSegmentEditorWidget):&lt;br /&gt;
&lt;br /&gt;
* [https://gist.github.com/lassoan/2d5a5b73645f65a5eb6f8d5f97abf31b brain tumor segmentation using grow from seeds effect]&lt;br /&gt;
* [https://gist.github.com/lassoan/1673b25d8e7913cbc245b4f09ed853f9 skin surface extraction using thresholding and smoothing]&lt;br /&gt;
* [https://gist.github.com/lassoan/2f5071c562108dac8efe277c78f2620f mask a volume with segments and compute histogram for each region]&lt;br /&gt;
&lt;br /&gt;
This example shows how to perform operations on segmentations using VTK filters:&lt;br /&gt;
* [https://gist.github.com/lassoan/7c94c334653010696b2bf96abc0ac8e7 brain tumor segmentation using grow from seeds effect]&lt;br /&gt;
&lt;br /&gt;
== Accessing views, renderers, and cameras ==&lt;br /&gt;
&lt;br /&gt;
Iterate through all 3D views in current layout:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
layoutManager = slicer.app.layoutManager()&lt;br /&gt;
for threeDViewIndex in range(layoutManager.threeDViewCount) :&lt;br /&gt;
  view = layoutManager.threeDWidget(threeDViewIndex).threeDView()&lt;br /&gt;
  threeDViewNode = view.mrmlViewNode()&lt;br /&gt;
  cameraNode = slicer.modules.cameras.logic().GetViewActiveCameraNode(threeDViewNode)&lt;br /&gt;
  print('View node for 3D widget ' + str(threeDViewIndex))&lt;br /&gt;
  print('  Name: ' + threeDViewNode .GetName())&lt;br /&gt;
  print('  ID: ' + threeDViewNode .GetID())&lt;br /&gt;
  print('  Camera ID: ' + cameraNode.GetID())&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Iterate through all slice views in current layout:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
layoutManager = slicer.app.layoutManager()&lt;br /&gt;
for sliceViewName in layoutManager.sliceViewNames():&lt;br /&gt;
  view = layoutManager.sliceWidget(sliceViewName).sliceView()&lt;br /&gt;
  sliceNode = view.mrmlSliceNode()&lt;br /&gt;
  sliceLogic = slicer.app.applicationLogic().GetSliceLogic(sliceNode)&lt;br /&gt;
  compositeNode = sliceLogic.GetSliceCompositeNode()&lt;br /&gt;
  print('Slice view ' + str(sliceViewName))&lt;br /&gt;
  print('  Name: ' + sliceNode.GetName())&lt;br /&gt;
  print('  ID: ' + sliceNode.GetID())&lt;br /&gt;
  print('  Background volume: {0}'.format(compositeNode.GetBackgroundVolumeID()))&lt;br /&gt;
  print('  Foreground volume: {0} (opacity: {1})'.format(compositeNode.GetForegroundVolumeID(), compositeNode.GetForegroundOpacity()))&lt;br /&gt;
  print('  Label volume: {0} (opacity: {1})'.format(compositeNode.GetLabelVolumeID(), compositeNode.GetLabelOpacity()))&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
For low-level manipulation of views, it is possible to access VTK render windows, renderers and cameras of views in the current layout.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
renderWindow = view.renderWindow()&lt;br /&gt;
renderers = renderWindow.GetRenderers()&lt;br /&gt;
renderer = renderers.GetItemAsObject(0)&lt;br /&gt;
camera = cameraNode.GetCamera()&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Change 3D view background color ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
renderWindow = slicer.app.layoutManager().threeDWidget(0).threeDView().renderWindow()&lt;br /&gt;
renderer = renderWindow.GetRenderers().GetFirstRenderer()&lt;br /&gt;
renderer.SetBackground(1,0,0)&lt;br /&gt;
renderer.SetBackground2(1,0,0)&lt;br /&gt;
renderWindow.Render()&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Subject hierarchy == &lt;br /&gt;
==== Get the pseudo-singleton subject hierarchy node ====&lt;br /&gt;
It manages the whole hierarchy and provides functions to access and manipulate&lt;br /&gt;
  shNode = slicer.vtkMRMLSubjectHierarchyNode.GetSubjectHierarchyNode(slicer.mrmlScene)&lt;br /&gt;
&lt;br /&gt;
==== Create subject hierarchy item ====&lt;br /&gt;
  # If it is for a data node, it is automatically created, but the create function can be used to set parent:&lt;br /&gt;
  shNode.CreateItem(parentItemID, dataNode)&lt;br /&gt;
  # If it is a hierarchy item without a data node, then the create function must be used:&lt;br /&gt;
  shNode.CreateSubjectItem(parentItemID, name)&lt;br /&gt;
  shNode.CreateFolderItem(parentItemID, name)&lt;br /&gt;
  shNode.CreateHierarchyItem(parentItemID, name, level) # Advanced method to set level attribute manually (usually subject, study, or folder, but it can be a virtual branch for example)&lt;br /&gt;
&lt;br /&gt;
==== Get subject hierarchy item ====&lt;br /&gt;
Items in subject hierarchy are uniquely identified by integer IDs&lt;br /&gt;
  # Get scene item ID first because it is the root item:&lt;br /&gt;
  sceneItemID = shNode.GetSceneItemID()&lt;br /&gt;
  # Get direct child by name&lt;br /&gt;
  subjectItemID = shNode.GetItemChildWithName(sceneItemID, 'Subject_1')&lt;br /&gt;
  # Get item for data node&lt;br /&gt;
  itemID = shNode.GetItemByDataNode(dataNode)&lt;br /&gt;
  # Get item by UID (such as DICOM)&lt;br /&gt;
  itemID = shNode.GetItemByUID(slicer.vtkMRMLSubjectHierarchyConstants.GetDICOMUIDName(), seriesInstanceUid)&lt;br /&gt;
  itemID = shNode.GetItemByUIDList(slicer.vtkMRMLSubjectHierarchyConstants.GetDICOMInstanceUIDName(), instanceUID)&lt;br /&gt;
  # Invalid item ID for checking validity of a given ID (most functions return the invalid ID when item is not found)&lt;br /&gt;
  invalidItemID = slicer.vtkMRMLSubjectHierarchyNode.GetInvalidItemID()&lt;br /&gt;
&lt;br /&gt;
==== Traverse children of a subject hierarchy item ====&lt;br /&gt;
  children = vtk.vtkIdList()&lt;br /&gt;
  shNode.GetItemChildren(parent, children)&lt;br /&gt;
  for i in xrange(children.GetNumberOfIds()):&lt;br /&gt;
    child = children.GetId(i)&lt;br /&gt;
    ...&lt;br /&gt;
&lt;br /&gt;
==== Manipulate subject hierarchy item ====&lt;br /&gt;
Instead of node operations on the individual subject hierarchy nodes, item operations are performed on the one subject hierarchy node.&lt;br /&gt;
  # Set item name&lt;br /&gt;
  shNode.SetItemName(itemID, 'NewName')&lt;br /&gt;
  # Set item parent (reparent)&lt;br /&gt;
  shNode.SetItemParent(itemID, newParentItemID)&lt;br /&gt;
  # Set visibility of data nodes associated to items in a branch (or a leaf item)&lt;br /&gt;
  shNode.SetDisplayVisibilityForBranch(itemID, 1)&lt;br /&gt;
&lt;br /&gt;
==== Filter items in TreeView or ComboBox ====&lt;br /&gt;
Displayed items can be filtered using ''setAttributeFilter'' method. An example of the usage can be found in the  [https://github.com/Slicer/Slicer/blob/e66e3b08e35384526528e6ae678e9ec9f079f286/Applications/SlicerApp/Testing/Python/SubjectHierarchyGenericSelfTest.py#L352-L360 unit test]. Modified version here:&lt;br /&gt;
    print shTreeView.displayedItemCount() # 5&lt;br /&gt;
    shTreeView.setAttributeFilter('DICOM.Modality') # Nodes must have this attribute&lt;br /&gt;
    print shTreeView.displayedItemCount() # 3&lt;br /&gt;
    shTreeView.setAttributeFilter('DICOM.Modality','CT') # Have attribute and equal 'CT'&lt;br /&gt;
    print shTreeView.displayedItemCount() # 1&lt;br /&gt;
    shTreeView.removeAttributeFilter()&lt;br /&gt;
    print shTreeView.displayedItemCount() # 5&lt;br /&gt;
&lt;br /&gt;
=== Listen to subject hierarchy item events ===&lt;br /&gt;
The subject hierarchy node sends the node item id as calldata. Item IDs are vtkIdType, which are NOT vtkObjects. You need to use vtk.calldata_type(vtk.VTK_LONG) (otherwise the application crashes).&lt;br /&gt;
  &lt;br /&gt;
  class MyListenerClass(VTKObservationMixin):&lt;br /&gt;
    def __init__(self):&lt;br /&gt;
      VTKObservationMixin.__init__(self)&lt;br /&gt;
      &lt;br /&gt;
      shNode = slicer.vtkMRMLSubjectHierarchyNode.GetSubjectHierarchyNode(slicer.mrmlScene)&lt;br /&gt;
      self.addObserver(shNode, shNode.SubjectHierarchyItemModifiedEvent, self.shItemModifiedEvent)&lt;br /&gt;
     &lt;br /&gt;
    @vtk.calldata_type(vtk.VTK_LONG) &lt;br /&gt;
    def shItemModifiedEvent(self, caller, eventId, callData):&lt;br /&gt;
      print(&amp;quot;SH Node modified&amp;quot;)&lt;br /&gt;
      print(&amp;quot;SH item ID: {0}&amp;quot;.format(callData))&lt;br /&gt;
&lt;br /&gt;
== Plotting ==&lt;br /&gt;
&lt;br /&gt;
=== Create histogram plot of a volume ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Get a volume from SampleData&lt;br /&gt;
import SampleData&lt;br /&gt;
volumeNode = SampleData.SampleDataLogic().downloadMRHead()&lt;br /&gt;
&lt;br /&gt;
# Compute histogram values&lt;br /&gt;
import numpy as np&lt;br /&gt;
histogram = np.histogram(arrayFromVolume(volumeNode), bins=50)&lt;br /&gt;
&lt;br /&gt;
# Save results to a new table node&lt;br /&gt;
tableNode=slicer.mrmlScene.AddNewNodeByClass(&amp;quot;vtkMRMLTableNode&amp;quot;)&lt;br /&gt;
updateTableFromArray(tableNode, histogram)&lt;br /&gt;
tableNode.GetTable().GetColumn(0).SetName(&amp;quot;Count&amp;quot;)&lt;br /&gt;
tableNode.GetTable().GetColumn(1).SetName(&amp;quot;Intensity&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
# Create plot&lt;br /&gt;
plotSeriesNode = slicer.mrmlScene.AddNewNodeByClass(&amp;quot;vtkMRMLPlotSeriesNode&amp;quot;, volumeNode.GetName() + ' histogram')&lt;br /&gt;
plotSeriesNode.SetAndObserveTableNodeID(tableNode.GetID())&lt;br /&gt;
plotSeriesNode.SetXColumnName(&amp;quot;Intensity&amp;quot;)&lt;br /&gt;
plotSeriesNode.SetYColumnName(&amp;quot;Count&amp;quot;)&lt;br /&gt;
plotSeriesNode.SetPlotType(plotSeriesNode.PlotTypeScatterBar)&lt;br /&gt;
plotSeriesNode.SetColor(0, 0.6, 1.0)&lt;br /&gt;
&lt;br /&gt;
# Create chart and add plot&lt;br /&gt;
plotChartNode = slicer.mrmlScene.AddNewNodeByClass(&amp;quot;vtkMRMLPlotChartNode&amp;quot;)&lt;br /&gt;
plotChartNode.AddAndObservePlotSeriesNodeID(plotSeriesNode.GetID())&lt;br /&gt;
plotChartNode.YAxisRangeAutoOff()&lt;br /&gt;
plotChartNode.SetYAxisRange(0, 500000)&lt;br /&gt;
&lt;br /&gt;
# Show plot in layout&lt;br /&gt;
slicer.modules.plots.logic().ShowChartInLayout(plotChartNode)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Execute external applications ==&lt;br /&gt;
&lt;br /&gt;
How to run external applications from Slicer.&lt;br /&gt;
&lt;br /&gt;
=== Run process in default environment ===&lt;br /&gt;
&lt;br /&gt;
When a process is launched from Slicer then by default Slicer's ITK, VTK, Qt, etc. libraries are used. If an external application has its own version of these libraries, then the application is expected to crash. To prevent crashing, the application must be run in the environment where Slicer started up (without all Slicer-specific library paths). This startup environment can be retrieved using ''slicer.util.startupEnvironment()''.&lt;br /&gt;
&lt;br /&gt;
Example: run Python3 script from Slicer:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
command_to_execute = [&amp;quot;/usr/bin/python3&amp;quot;, &amp;quot;-c&amp;quot;, &amp;quot;print('hola')&amp;quot;]&lt;br /&gt;
from subprocess import check_output&lt;br /&gt;
check_output(&lt;br /&gt;
  command_to_execute, &lt;br /&gt;
  env=slicer.util.startupEnvironment()&lt;br /&gt;
  )&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
will output:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
'hola\n'&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
On some systems, ''shell=True'' must be specified as well.&lt;/div&gt;</summary>
		<author><name>Inorton</name></author>
		
	</entry>
	<entry>
		<id>https://www.slicer.org/w/index.php?title=Documentation/Nightly/ScriptRepository&amp;diff=59411</id>
		<title>Documentation/Nightly/ScriptRepository</title>
		<link rel="alternate" type="text/html" href="https://www.slicer.org/w/index.php?title=Documentation/Nightly/ScriptRepository&amp;diff=59411"/>
		<updated>2018-09-12T17:07:13Z</updated>

		<summary type="html">&lt;p&gt;Inorton: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;noinclude&amp;gt;{{documentation/versioncheck}}&amp;lt;/noinclude&amp;gt;&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Community-contributed modules=&lt;br /&gt;
&lt;br /&gt;
The examples in this section are [[Documentation/{{documentation/version}}/Developers/Modules#Scripted_Modules| Scripted Modules]] that provide a user interface in the module panel along with specialized implementation logic.&lt;br /&gt;
&lt;br /&gt;
Usage: save the .py file to a directory, add the directory to the additional module paths in the Slicer application settings (choose in the menu: Edit / Application settings, click Modules, click &amp;gt;&amp;gt; next to Additional module paths, click Add, and choose the .py file's location).&lt;br /&gt;
&lt;br /&gt;
==Filters==&lt;br /&gt;
* [https://raw.github.com/pieper/VolumeMasker/master/VolumeMasker.py VolumeMasker.py]: Update a target volume with the results of setting all input volume voxels to 0 except for those that correspond to a selected label value in an input label map (Used for example in the volume rendering in [https://www.youtube.com/watch?v=dfu2gugHLHs this video).&lt;br /&gt;
&lt;br /&gt;
==DICOM==&lt;br /&gt;
* [https://gist.github.com/pieper/6186477 dicom header browser] to easily scroll through dicom files using dcmdump.&lt;br /&gt;
* [https://github.com/SlicerRt/SlicerRT/tree/master/BatchProcessing SlicerRT batch processing] to batch convert RT structure sets to labelmap NRRD files.&lt;br /&gt;
&lt;br /&gt;
==Informatics==&lt;br /&gt;
* [https://gist.github.com/lassoan/bf0954d93cacc8cbe27cd4a3ad503f2f MarkupsInfo.py]: Compute the total length between all the points of a markup list.&lt;br /&gt;
* [https://gist.github.com/lassoan/0e7acfbec36e4577f8b7b0e07ad53a2a LineProfile.py]: Compute intensity profile in a volume along a line.&lt;br /&gt;
&lt;br /&gt;
=Community-contributed examples=&lt;br /&gt;
&lt;br /&gt;
Usage: Copy-paste the shown code lines or linked .py file contents into Python console in Slicer.  Or save them to a file and run them using execfile.&lt;br /&gt;
&lt;br /&gt;
==Capture==&lt;br /&gt;
* Capture the full Slicer screen and save it into a file&lt;br /&gt;
  img = qt.QPixmap.grabWidget(slicer.util.mainWindow()).toImage()&lt;br /&gt;
  img.save('c:/tmp/test.png')&lt;br /&gt;
* Capture all the views save it into a file:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
import ScreenCapture&lt;br /&gt;
cap = ScreenCapture.ScreenCaptureLogic()&lt;br /&gt;
cap.showViewControllers(False)&lt;br /&gt;
cap.captureImageFromView(None,'c:/tmp/test.png')&lt;br /&gt;
cap.showViewControllers(True)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
* Capture a single view:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
viewNodeID = 'vtkMRMLViewNode1'&lt;br /&gt;
import ScreenCapture&lt;br /&gt;
cap = ScreenCapture.ScreenCaptureLogic()&lt;br /&gt;
view = cap.viewFromNode(slicer.mrmlScene.GetNodeByID(viewNodeID))&lt;br /&gt;
cap.captureImageFromView(view,'c:/tmp/test.png')&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Common values for viewNodeID: vtkMRMLSliceNodeRed, vtkMRMLSliceNodeYellow, vtkMRMLSliceNodeGreen, vtkMRMLViewNode1, vtkMRMLViewNode2. &lt;br /&gt;
The ScreenCapture module can also create video animations of rotating views, slice sweeps, etc.&lt;br /&gt;
&lt;br /&gt;
* Capture a slice view sweep into a series of PNG files - for example, Red slice view, 30 images, from position -125.0 to 75.0, into c:/tmp folder, with name image_00001.png, image_00002.png, ...&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
import ScreenCapture&lt;br /&gt;
ScreenCapture.ScreenCaptureLogic().captureSliceSweep(getNode('vtkMRMLSliceNodeRed'), -125.0, 75.0, 30, &amp;quot;c:/tmp&amp;quot;, &amp;quot;image_%05d.png&amp;quot;)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Capture 3D view into PNG file with transparent background&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
renderWindow = slicer.app.layoutManager().threeDWidget(0).threeDView().renderWindow()&lt;br /&gt;
renderWindow.SetAlphaBitPlanes(1)&lt;br /&gt;
wti = vtk.vtkWindowToImageFilter()&lt;br /&gt;
wti.SetInputBufferTypeToRGBA()&lt;br /&gt;
wti.SetInput(renderWindow)&lt;br /&gt;
writer = vtk.vtkPNGWriter()&lt;br /&gt;
writer.SetFileName(&amp;quot;c:/tmp/screenshot.png&amp;quot;)&lt;br /&gt;
writer.SetInputConnection(wti.GetOutputPort())&lt;br /&gt;
writer.Write()&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Launching Slicer==&lt;br /&gt;
* How to open an .mrb file with Slicer at the command line?&lt;br /&gt;
  Slicer.exe --python-code &amp;quot;slicer.util.loadScene( 'f:/2013-08-23-Scene.mrb' )&amp;quot;&lt;br /&gt;
* How to run a script in the Slicer environment in batch mode (without showing any graphical user interface)?&lt;br /&gt;
  Slicer.exe --python-code &amp;quot;doSomething; doSomethingElse; etc.&amp;quot; --testing --no-splash --no-main-window&lt;br /&gt;
&lt;br /&gt;
==Load volume from file==&lt;br /&gt;
When loading a volume from file, it is recommended to set returnNode=True to retrieve the loaded volume node.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
[success, loadedVolumeNode] = slicer.util.loadVolume('c:/Users/abc/Documents/MRHead.nrrd', returnNode=True)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Get a MRML node in the scene based on the node name and call methods of that object. For the MRHead sample data:&lt;br /&gt;
  vol=slicer.util.getNode('MR*')&lt;br /&gt;
  vol.GetImageData().GetDimensions()&lt;br /&gt;
&lt;br /&gt;
==DICOM==&lt;br /&gt;
=== How to access tags of DICOM images imported into Slicer? For example, to print the first patient's first study's first series' &amp;quot;0020,0032&amp;quot; field:===&lt;br /&gt;
  db=slicer.dicomDatabase&lt;br /&gt;
  patientList=db.patients()&lt;br /&gt;
  studyList=db.studiesForPatient(patientList[0])&lt;br /&gt;
  seriesList=db.seriesForStudy(studyList[0])&lt;br /&gt;
  fileList=db.filesForSeries(seriesList[0])&lt;br /&gt;
  print db.fileValue(fileList[0],'0020,0032')&lt;br /&gt;
&lt;br /&gt;
=== How to access tag of a volume loaded from DICOM? For example, get the patient position stored in a volume:===&lt;br /&gt;
  volumeName='2: ENT IMRT'&lt;br /&gt;
  n=slicer.util.getNode(volumeName)&lt;br /&gt;
  instUids=n.GetAttribute('DICOM.instanceUIDs').split()&lt;br /&gt;
  filename=slicer.dicomDatabase.fileForInstance(instUids[0])&lt;br /&gt;
  print slicer.dicomDatabase.fileValue(filename,'0018,5100')&lt;br /&gt;
&lt;br /&gt;
=== How to access tag of an item in the Subject Hierachy tree? For example, get the content time tag of a structure set:===&lt;br /&gt;
  rtStructName = '3: RTSTRUCT: PROS'&lt;br /&gt;
  rtStructNode = slicer.util.getNode(rtStructName)&lt;br /&gt;
  shNode = slicer.vtkMRMLSubjectHierarchyNode.GetSubjectHierarchyNode(slicer.mrmlScene)&lt;br /&gt;
  rtStructShItemID = shNode.GetItemByDataNode(rtStructNode)&lt;br /&gt;
  ctSliceInstanceUids = shNode.GetItemAttribute(rtStructShItemID, 'DICOM.ReferencedInstanceUIDs').split()&lt;br /&gt;
  filename = slicer.dicomDatabase.fileForInstance(ctSliceInstanceUids[0])&lt;br /&gt;
  print slicer.dicomDatabase.fileValue(filename,'0008,0033')&lt;br /&gt;
&lt;br /&gt;
=== How to get path and filename of a loaded DICOM volume?===&lt;br /&gt;
  def pathFromNode(node):&lt;br /&gt;
    storageNode=node.GetStorageNode()&lt;br /&gt;
    if storageNode is not None: # loaded via drag-drop&lt;br /&gt;
        filepath=storageNode.GetFullNameFromFileName()&lt;br /&gt;
    else: # loaded via DICOM browser&lt;br /&gt;
        instanceUIDs=node.GetAttribute('DICOM.instanceUIDs').split()&lt;br /&gt;
        filepath=slicer.dicomDatabase.fileForInstance(instUids[0])&lt;br /&gt;
    return filepath&lt;br /&gt;
  &lt;br /&gt;
  # example:&lt;br /&gt;
  node=slicer.util.getNode('volume1')&lt;br /&gt;
  path=self.pathFromNode(node)&lt;br /&gt;
  print(&amp;quot;DICOM path=%s&amp;quot; % path)&lt;br /&gt;
&lt;br /&gt;
=== How can I convert DICOM to NRRD on the command line?===&lt;br /&gt;
&lt;br /&gt;
 /Applications/Slicer-4.6.2.app/Contents/MacOS/Slicer --no-main-window --python-code &amp;quot;node=slicer.util.loadVolume('/tmp/series/im0.dcm', returnNode=True)[1]; slicer.util.saveNode(node, '/tmp/output.nrrd'); exit()&amp;quot;&lt;br /&gt;
&lt;br /&gt;
The same can be done on windows by using the top level Slicer.exe.  Be sure to use forward slashes in the pathnames within quotes on the command line.&lt;br /&gt;
&lt;br /&gt;
=== Export a volume to DICOM file format ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
volumeNode = getNode('CTChest')&lt;br /&gt;
outputFolder = &amp;quot;c:/tmp/dicom-output&amp;quot;&lt;br /&gt;
&lt;br /&gt;
# Create patient and study and put the volume under the study&lt;br /&gt;
shNode = slicer.vtkMRMLSubjectHierarchyNode.GetSubjectHierarchyNode(slicer.mrmlScene)&lt;br /&gt;
patientItemID = shNode.CreateSubjectItem(shNode.GetSceneItemID(), &amp;quot;test patient&amp;quot;)&lt;br /&gt;
studyItemID = shNode.CreateStudyItem(patientItemID, &amp;quot;test study&amp;quot;)&lt;br /&gt;
volumeShItemID = shNode.GetItemByDataNode(volumeNode)&lt;br /&gt;
shNode.SetItemParent(volumeShItemID, studyItemID)&lt;br /&gt;
&lt;br /&gt;
import DICOMScalarVolumePlugin&lt;br /&gt;
exporter = DICOMScalarVolumePlugin.DICOMScalarVolumePluginClass()&lt;br /&gt;
exportables = exporter.examineForExport(volumeShItemID)&lt;br /&gt;
for exp in exportables:&lt;br /&gt;
  exp.directory = outputFolder&lt;br /&gt;
&lt;br /&gt;
exporter.export(exportables)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Toolbar functions==&lt;br /&gt;
* How to turn on slice intersections in the crosshair menu on the toolbar:&lt;br /&gt;
  viewNodes = slicer.mrmlScene.GetNodesByClass('vtkMRMLSliceCompositeNode')&lt;br /&gt;
  viewNodes.UnRegister(slicer.mrmlScene)&lt;br /&gt;
  viewNodes.InitTraversal()&lt;br /&gt;
  viewNode = viewNodes.GetNextItemAsObject()&lt;br /&gt;
  while viewNode:&lt;br /&gt;
    viewNode.SetSliceIntersectionVisibility(1)&lt;br /&gt;
    viewNode = viewNodes.GetNextItemAsObject()&lt;br /&gt;
&lt;br /&gt;
How to find similar functions? For this one I searched for &amp;quot;slice intersections&amp;quot; text in the whole slicer source code, found that the function is implemented in Base\QTGUI\qSlicerViewersToolBar.cxx, then translated the qSlicerViewersToolBarPrivate::setSliceIntersectionVisible(bool visible) method to Python.&lt;br /&gt;
&lt;br /&gt;
==Manipulating objects in the slice viewer==&lt;br /&gt;
* How to define/edit a circular region of interest in a slice viewer?&lt;br /&gt;
&lt;br /&gt;
Drop two markup points on a slice view and copy-paste the code below into the Python console. After this, as you move the markups you’ll see a circle following the markups.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Update the sphere from the fiducial points&lt;br /&gt;
def UpdateSphere(param1, param2):  &lt;br /&gt;
  import math&lt;br /&gt;
  centerPointCoord = [0.0, 0.0, 0.0]&lt;br /&gt;
  markups.GetNthFiducialPosition(0,centerPointCoord)&lt;br /&gt;
  circumferencePointCoord = [0.0, 0.0, 0.0]&lt;br /&gt;
  markups.GetNthFiducialPosition(1,circumferencePointCoord)&lt;br /&gt;
  sphere.SetCenter(centerPointCoord)&lt;br /&gt;
  radius=math.sqrt((centerPointCoord[0]-circumferencePointCoord[0])**2+(centerPointCoord[1]-circumferencePointCoord[1])**2+(centerPointCoord[2]-circumferencePointCoord[2])**2)&lt;br /&gt;
  sphere.SetRadius(radius)&lt;br /&gt;
  sphere.SetPhiResolution(30)&lt;br /&gt;
  sphere.SetThetaResolution(30)&lt;br /&gt;
  sphere.Update()&lt;br /&gt;
&lt;br /&gt;
# Get markup node from scene&lt;br /&gt;
markups=slicer.util.getNode('F')&lt;br /&gt;
sphere = vtk.vtkSphereSource()&lt;br /&gt;
UpdateSphere(0,0)&lt;br /&gt;
 &lt;br /&gt;
# Create model node and add to scene&lt;br /&gt;
modelsLogic = slicer.modules.models.logic()&lt;br /&gt;
model = modelsLogic.AddModel(sphere.GetOutput())&lt;br /&gt;
model.GetDisplayNode().SetSliceIntersectionVisibility(True)&lt;br /&gt;
model.GetDisplayNode().SetSliceIntersectionThickness(3)&lt;br /&gt;
model.GetDisplayNode().SetColor(1,1,0)&lt;br /&gt;
 &lt;br /&gt;
# Call UpdateSphere whenever the fiducials are changed&lt;br /&gt;
markups.AddObserver(&amp;quot;ModifiedEvent&amp;quot;, UpdateSphere, 2)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Set slice position and orientation from 3 markup fiducials==&lt;br /&gt;
&lt;br /&gt;
Drop 3 markup points in the scene and copy-paste the code below into the Python console. After this, as you move the markups you’ll see the red slice view position and orientation will be set to make it fit to the 3 points.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Update plane from fiducial points&lt;br /&gt;
def UpdateSlicePlane(param1=None, param2=None):&lt;br /&gt;
  # Get point positions as numpy array&lt;br /&gt;
  import numpy as np&lt;br /&gt;
  nOfFiduciallPoints = markups.GetNumberOfFiducials()&lt;br /&gt;
  if nOfFiduciallPoints &amp;lt; 3:&lt;br /&gt;
    return  # not enough points&lt;br /&gt;
  points = np.zeros([3,nOfFiduciallPoints])&lt;br /&gt;
  for i in range(0, nOfFiduciallPoints):&lt;br /&gt;
    markups.GetNthFiducialPosition(i, points[:,i])&lt;br /&gt;
  # Compute plane position and normal&lt;br /&gt;
  planePosition = points.mean(axis=1)&lt;br /&gt;
  planeNormal = np.cross(points[:,1] - points[:,0], points[:,2] - points[:,0])&lt;br /&gt;
  planeX = points[:,1] - points[:,0]&lt;br /&gt;
  sliceNode.SetSliceToRASByNTP(planeNormal[0], planeNormal[1], planeNormal[2],&lt;br /&gt;
    planeX[0], planeX[1], planeX[2],&lt;br /&gt;
    planePosition[0], planePosition[1], planePosition[2], 0)&lt;br /&gt;
&lt;br /&gt;
# Get markup node from scene&lt;br /&gt;
sliceNode = slicer.app.layoutManager().sliceWidget('Red').mrmlSliceNode()&lt;br /&gt;
markups = slicer.util.getNode('F')&lt;br /&gt;
&lt;br /&gt;
# Update slice plane manually&lt;br /&gt;
UpdateSlicePlane()&lt;br /&gt;
&lt;br /&gt;
# Update slice plane automatically whenever points are changed&lt;br /&gt;
markupObservation = [markups, markups.AddObserver(&amp;quot;ModifiedEvent&amp;quot;, UpdateSlicePlane, 2)]&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To stop automatic updates, run this:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
markupObservation[0].RemoveObserver(markupObservation[1])&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Switching to markup fiducial placement mode ==&lt;br /&gt;
&lt;br /&gt;
To activate a fiducial placement mode, both interaction mode has to be set and a fiducial node has to be selected:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
interactionNode = slicer.app.applicationLogic().GetInteractionNode()&lt;br /&gt;
selectionNode = slicer.app.applicationLogic().GetSelectionNode()&lt;br /&gt;
selectionNode.SetReferenceActivePlaceNodeClassName(&amp;quot;vtkMRMLMarkupsFiducialNode&amp;quot;)&lt;br /&gt;
fiducialNode = slicer.vtkMRMLMarkupsFiducialNode()&lt;br /&gt;
slicer.mrmlScene.AddNode(fiducialNode)&lt;br /&gt;
fiducialNode.CreateDefaultDisplayNodes() &lt;br /&gt;
selectionNode.SetActivePlaceNodeID(fiducialNode.GetID())&lt;br /&gt;
interactionNode.SetCurrentInteractionMode(interactionNode.Place)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Get a notification if a markup point position is modified ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
def onMarkupsNodeModified(markupsNode, unusedArg2=None, unusedArg3=None):&lt;br /&gt;
  sliceView = markupsNode.GetAttribute('Markups.MovingInSliceView')&lt;br /&gt;
  if not sliceView:&lt;br /&gt;
    print(&amp;quot;Markup list was modified&amp;quot;)&lt;br /&gt;
    return&lt;br /&gt;
  movingMarkupIndex = markupsNode.GetAttribute('Markups.MovingMarkupIndex')&lt;br /&gt;
  pos = [0,0,0]&lt;br /&gt;
  markupsNode.GetNthFiducialPosition(int(movingMarkupIndex), pos)  &lt;br /&gt;
  print(&amp;quot;Markup {0} was moved in slice view {1} to {2}&amp;quot;.format(movingMarkupIndex, sliceView, pos))&lt;br /&gt;
&lt;br /&gt;
markupsNode = slicer.mrmlScene.AddNewNodeByClass(&amp;quot;vtkMRMLMarkupsFiducialNode&amp;quot;)&lt;br /&gt;
markupsNode.CreateDefaultDisplayNodes()&lt;br /&gt;
markupsNode.AddFiducial(0,0,0)&lt;br /&gt;
markupsNode.AddObserver(vtk.vtkCommand.ModifiedEvent, onMarkupsNodeModified)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Show a context menu when a markup point is clicked in a slice or 3D view ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
# Example actions to perform&lt;br /&gt;
&lt;br /&gt;
def action1():&lt;br /&gt;
  print('Action1 on markup '+str(slicer.clickedMarkupIndex))&lt;br /&gt;
&lt;br /&gt;
def action2():&lt;br /&gt;
  print('Action2 on markup '+str(slicer.clickedMarkupIndex))&lt;br /&gt;
&lt;br /&gt;
def action3():&lt;br /&gt;
  print('Action3 on markup '+str(slicer.clickedMarkupIndex))&lt;br /&gt;
&lt;br /&gt;
# Clicked markup index is saved here to let the action&lt;br /&gt;
# know which markup needs to be manipulated.&lt;br /&gt;
slicer.clickedMarkupIndex = -1&lt;br /&gt;
  &lt;br /&gt;
# Create a simple menu&lt;br /&gt;
&lt;br /&gt;
menu = qt.QMenu()&lt;br /&gt;
a1 = qt.QAction(&amp;quot;Test&amp;quot;, slicer.util.mainWindow())&lt;br /&gt;
a1.connect('triggered()', action1)&lt;br /&gt;
menu.addAction(a1)&lt;br /&gt;
a2 = qt.QAction(&amp;quot;Action&amp;quot;, slicer.util.mainWindow())&lt;br /&gt;
a2.connect('triggered()', action1)&lt;br /&gt;
menu.addAction(a2)&lt;br /&gt;
a3 = qt.QAction(&amp;quot;Here&amp;quot;, slicer.util.mainWindow())&lt;br /&gt;
a3.connect('triggered()', action1)&lt;br /&gt;
menu.addAction(a3)&lt;br /&gt;
&lt;br /&gt;
# Add observer to a markup fiducial list&lt;br /&gt;
&lt;br /&gt;
@vtk.calldata_type(vtk.VTK_INT)&lt;br /&gt;
def markupClickedCallback(caller, eventId, callData):&lt;br /&gt;
  slicer.clickedMarkupIndex = callData&lt;br /&gt;
  print('Open menu on markup '+str(slicer.clickedMarkupIndex))&lt;br /&gt;
  menu.move(qt.QCursor.pos())&lt;br /&gt;
  menu.show()&lt;br /&gt;
&lt;br /&gt;
markupsNode = getNode('F')&lt;br /&gt;
observerTag = markupsNode.AddObserver(slicer.vtkMRMLMarkupsNode.PointClickedEvent, markupClickedCallback)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Add a texture mapped plane to the scene as a model ==&lt;br /&gt;
Note that model textures are not exposed in the GUI and are not saved in the scene&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# use dummy image data here&lt;br /&gt;
e = vtk.vtkImageEllipsoidSource()&lt;br /&gt;
&lt;br /&gt;
scene = slicer.mrmlScene&lt;br /&gt;
&lt;br /&gt;
# Create model node&lt;br /&gt;
model = slicer.vtkMRMLModelNode()&lt;br /&gt;
model.SetScene(scene)&lt;br /&gt;
model.SetName(scene.GenerateUniqueName(&amp;quot;2DImageModel&amp;quot;))&lt;br /&gt;
&lt;br /&gt;
planeSource = vtk.vtkPlaneSource()&lt;br /&gt;
model.SetAndObservePolyData(planeSource.GetOutput())&lt;br /&gt;
&lt;br /&gt;
# Create display node&lt;br /&gt;
modelDisplay = slicer.vtkMRMLModelDisplayNode()&lt;br /&gt;
modelDisplay.SetColor(1,1,0) # yellow&lt;br /&gt;
modelDisplay.SetBackfaceCulling(0)&lt;br /&gt;
modelDisplay.SetScene(scene)&lt;br /&gt;
scene.AddNode(modelDisplay)&lt;br /&gt;
model.SetAndObserveDisplayNodeID(modelDisplay.GetID())&lt;br /&gt;
&lt;br /&gt;
# Add to scene&lt;br /&gt;
modelDisplay.SetAndObserveTextureImageData(e.GetOutput())&lt;br /&gt;
scene.AddNode(model) &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
transform = slicer.vtkMRMLLinearTransformNode()&lt;br /&gt;
scene.AddNode(transform) &lt;br /&gt;
model.SetAndObserveTransformNodeID(transform.GetID())&lt;br /&gt;
&lt;br /&gt;
vTransform = vtk.vtkTransform()&lt;br /&gt;
vTransform.Scale(50,50,50)&lt;br /&gt;
vTransform.RotateX(30)&lt;br /&gt;
transform.SetAndObserveMatrixTransformToParent(vTransform.GetMatrix())&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Export entire scene as VRML ==&lt;br /&gt;
&lt;br /&gt;
Save all surface meshes displayed in the scene (models, markups, etc). Solid colors and coloring by scalar is preserved. Textures are not supported.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
exporter = vtk.vtkVRMLExporter()&lt;br /&gt;
exporter.SetRenderWindow(slicer.app.layoutManager().threeDWidget(0).threeDView().renderWindow())&lt;br /&gt;
exporter.SetFileName('C:/tmp/something.wrl')&lt;br /&gt;
exporter.Write()&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Export model to Blender, including color by scalar ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
modelNode = getNode(&amp;quot;Model&amp;quot;)&lt;br /&gt;
plyFilePath = &amp;quot;c:/tmp/model.ply&amp;quot;&lt;br /&gt;
&lt;br /&gt;
modelDisplayNode = modelNode.GetDisplayNode()&lt;br /&gt;
triangles = vtk.vtkTriangleFilter()&lt;br /&gt;
triangles.SetInputConnection(modelDisplayNode.GetOutputPolyDataConnection())&lt;br /&gt;
&lt;br /&gt;
plyWriter = vtk.vtkPLYWriter()&lt;br /&gt;
plyWriter.SetInputConnection(triangles.GetOutputPort())&lt;br /&gt;
lut = vtk.vtkLookupTable()&lt;br /&gt;
lut.DeepCopy(modelDisplayNode.GetColorNode().GetLookupTable())&lt;br /&gt;
lut.SetRange(modelDisplayNode.GetScalarRange())&lt;br /&gt;
plyWriter.SetLookupTable(lut)&lt;br /&gt;
plyWriter.SetArrayName(modelDisplayNode.GetActiveScalarName())&lt;br /&gt;
&lt;br /&gt;
plyWriter.SetFileName(plyFilePath)&lt;br /&gt;
plyWriter.Write()&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Export a tract (FiberBundle) to Blender, including color ==&lt;br /&gt;
&amp;lt;div id=&amp;quot;Export_a_fiber_tracts_to_Blender.2C_including_color&amp;quot;&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
Note: an interactive version of this script is now included in the [http://dmri.slicer.org/ SlicerDMRI extension] ([https://github.com/SlicerDMRI/SlicerDMRI/tree/master/Modules/Scripted/TractographyExportPLY module code]). &lt;br /&gt;
After installing SlicerDMRI, go to ''Modules -&amp;gt; Diffusion -&amp;gt; Import and Export -&amp;gt; Export tractography to PLY (mesh)''.&lt;br /&gt;
&lt;br /&gt;
The example below shows how to export a tractography &amp;quot;FiberBundleNode&amp;quot; to a PLY file:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
lineDisplayNode = getNode(&amp;quot;*LineDisplay*&amp;quot;)&lt;br /&gt;
plyFilePath = &amp;quot;/tmp/fibers.ply&amp;quot;&lt;br /&gt;
&lt;br /&gt;
tuber = vtk.vtkTubeFilter()&lt;br /&gt;
tuber.SetInputData(lineDisplayNode.GetOutputPolyData())&lt;br /&gt;
tuber.Update()&lt;br /&gt;
tubes = tuber.GetOutputDataObject(0)&lt;br /&gt;
scalars = tubes.GetPointData().GetArray(0)&lt;br /&gt;
scalars.SetName(&amp;quot;scalars&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
triangles = vtk.vtkTriangleFilter()&lt;br /&gt;
triangles.SetInputData(tubes)&lt;br /&gt;
triangles.Update()&lt;br /&gt;
&lt;br /&gt;
colorNode = lineDisplayNode.GetColorNode()&lt;br /&gt;
lookupTable = vtk.vtkLookupTable()&lt;br /&gt;
lookupTable.DeepCopy(colorNode.GetLookupTable())&lt;br /&gt;
lookupTable.SetTableRange(0,1)&lt;br /&gt;
&lt;br /&gt;
plyWriter = vtk.vtkPLYWriter()&lt;br /&gt;
plyWriter.SetInputData(triangles.GetOutput())&lt;br /&gt;
plyWriter.SetLookupTable(lookupTable)&lt;br /&gt;
plyWriter.SetArrayName(&amp;quot;scalars&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
plyWriter.SetFileName(plyFilePath)&lt;br /&gt;
plyWriter.Write()&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Iterate over tract (FiberBundle) streamline points ==&lt;br /&gt;
&lt;br /&gt;
This example shows how to access the points in each line of a FiberBundle as a numpy array (view).&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
from vtk.util.numpy_support import vtk_to_numpy&lt;br /&gt;
&lt;br /&gt;
fb = getNode(&amp;quot;FiberBundle_F&amp;quot;) # &amp;lt;- fill in node ID here&lt;br /&gt;
&lt;br /&gt;
# get point data as 1d array&lt;br /&gt;
points = slicer.util.arrayFromModelPoints(fb)&lt;br /&gt;
&lt;br /&gt;
# get line cell ids as 1d array&lt;br /&gt;
line_ids = vtk_to_numpy(fb.GetPolyData().GetLines().GetData())&lt;br /&gt;
&lt;br /&gt;
# VTK cell ids are stored as&lt;br /&gt;
#   [ N0 c0_id0 ... c0_id0&lt;br /&gt;
#     N1 c1_id0 ... c1_idN1 ]&lt;br /&gt;
# so we need to&lt;br /&gt;
# - read cell count&lt;br /&gt;
# - grab the ids in that range from `lines`&lt;br /&gt;
# - index the point array by those ids&lt;br /&gt;
cur_idx = 1&lt;br /&gt;
for _ in range(pd.GetLines().GetNumberOfCells()):&lt;br /&gt;
    # - read cell count&lt;br /&gt;
    count = lines[cur_idx - 1]&lt;br /&gt;
&lt;br /&gt;
    # - grab the ids in that range from `lines`&lt;br /&gt;
    index_array = line_ids[ cur_idx : cur_idx + count]&lt;br /&gt;
    # update to the next range &lt;br /&gt;
    cur_idx += count + 1&lt;br /&gt;
&lt;br /&gt;
    # - index the point array by those ids&lt;br /&gt;
    line_points = points[index_array]&lt;br /&gt;
&lt;br /&gt;
    # do work here&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Clone a volume ==&lt;br /&gt;
This example shows how to clone the MRHead sample volume, including its pixel data and display settings.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sourceVolumeNode = slicer.util.getNode('MRHead')&lt;br /&gt;
volumesLogic = slicer.modules.volumes.logic()&lt;br /&gt;
clonedVolumeNode = volumesLogic.CloneVolume(slicer.mrmlScene, sourceVolumeNode, 'Cloned volume')&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Create a new volume ==&lt;br /&gt;
This example shows how to create a new empty volume.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
nodeName = &amp;quot;MyNewVolume&amp;quot;&lt;br /&gt;
imageSize = [512, 512, 512]&lt;br /&gt;
voxelType=vtk.VTK_UNSIGNED_CHAR&lt;br /&gt;
imageOrigin = [0.0, 0.0, 0.0]&lt;br /&gt;
imageSpacing = [1.0, 1.0, 1.0]&lt;br /&gt;
imageDirections = [[1,0,0], [0,1,0], [0,0,1]]&lt;br /&gt;
fillVoxelValue = 0&lt;br /&gt;
&lt;br /&gt;
# Create an empty image volume, filled with fillVoxelValue&lt;br /&gt;
imageData = vtk.vtkImageData()&lt;br /&gt;
imageData.SetDimensions(imageSize)&lt;br /&gt;
imageData.AllocateScalars(voxelType, 1)&lt;br /&gt;
thresholder = vtk.vtkImageThreshold()&lt;br /&gt;
thresholder.SetInputData(imageData)&lt;br /&gt;
thresholder.SetInValue(fillVoxelValue)&lt;br /&gt;
thresholder.SetOutValue(fillVoxelValue)&lt;br /&gt;
thresholder.Update()&lt;br /&gt;
# Create volume node&lt;br /&gt;
volumeNode = slicer.mrmlScene.AddNewNodeByClass(&amp;quot;vtkMRMLScalarVolumeNode&amp;quot;, nodeName)&lt;br /&gt;
volumeNode.SetOrigin(imageOrigin)&lt;br /&gt;
volumeNode.SetSpacing(imageSpacing)&lt;br /&gt;
volumeNode.SetIJKToRASDirections(imageDirections)&lt;br /&gt;
volumeNode.SetAndObserveImageData(thresholder.GetOutput())&lt;br /&gt;
volumeNode.CreateDefaultDisplayNodes()&lt;br /&gt;
volumeNode.CreateDefaultStorageNode()&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Modify voxels in a volume ==&lt;br /&gt;
&lt;br /&gt;
Typically the fastest and simplest way of modifying voxels is by using numpy operators. Voxels can be retrieved in a numpy array using the `array` method and modified using standard numpy methods. For example, threshold a volume:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
nodeName = 'MRHead'&lt;br /&gt;
thresholdValue = 100&lt;br /&gt;
voxelArray = array(nodeName) # get voxels as numpy array&lt;br /&gt;
voxelArray[voxelArray &amp;lt; thresholdValue] = 0 # modify voxel values&lt;br /&gt;
getNode(nodeName).Modified() # at the end of all processing, notify Slicer that the image modification is completed&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This example shows how to change voxels values of the MRHead sample volume.&lt;br /&gt;
The values will be computed by function f(r,a,s,) = (r-10)*(r-10)+(a+15)*(a+15)+s*s.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
volumeNode=slicer.util.getNode('MRHead')&lt;br /&gt;
ijkToRas = vtk.vtkMatrix4x4()&lt;br /&gt;
volumeNode.GetIJKToRASMatrix(ijkToRas)&lt;br /&gt;
imageData=volumeNode.GetImageData()&lt;br /&gt;
extent = imageData.GetExtent()&lt;br /&gt;
for k in xrange(extent[4], extent[5]+1):&lt;br /&gt;
  for j in xrange(extent[2], extent[3]+1):&lt;br /&gt;
    for i in xrange(extent[0], extent[1]+1):&lt;br /&gt;
      position_Ijk=[i, j, k, 1]&lt;br /&gt;
      position_Ras=ijkToRas.MultiplyPoint(position_Ijk)&lt;br /&gt;
      r=position_Ras[0]&lt;br /&gt;
      a=position_Ras[1]&lt;br /&gt;
      s=position_Ras[2]      &lt;br /&gt;
      functionValue=(r-10)*(r-10)+(a+15)*(a+15)+s*s&lt;br /&gt;
      imageData.SetScalarComponentFromDouble(i,j,k,0,functionValue)&lt;br /&gt;
imageData.SetScalarComponentFromFloat(distortionVectorPosition_Ijk[0], distortionVectorPosition_Ijk[1], distortionVectorPosition_Ijk[2], 0, fillValue)&lt;br /&gt;
imageData.Modified()&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Get volume voxel coordinates from markup fiducial RAS coordinates ==&lt;br /&gt;
&lt;br /&gt;
This example shows how to get voxel coordinate of a volume corresponding to a markup fiducial point position.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Inputs&lt;br /&gt;
volumeNode = getNode('MRHead')&lt;br /&gt;
markupsNode = getNode('F')&lt;br /&gt;
markupsIndex = 1&lt;br /&gt;
&lt;br /&gt;
# Get point coordinate in RAS&lt;br /&gt;
point_Ras = [0, 0, 0, 1]&lt;br /&gt;
markupsNode.GetNthFiducialWorldCoordinates(markupsIndex, point_Ras)&lt;br /&gt;
&lt;br /&gt;
# If volume node is transformed, apply that transform to get volume's RAS coordinates&lt;br /&gt;
transformRasToVolumeRas = vtk.vtkGeneralTransform()&lt;br /&gt;
slicer.vtkMRMLTransformNode.GetTransformBetweenNodes(None, volumeNode.GetParentTransformNode(), transformRasToVolumeRas)&lt;br /&gt;
point_VolumeRas = transformRasToVolumeRas.TransformPoint(point_Ras[0:3])&lt;br /&gt;
&lt;br /&gt;
# Get voxel coordinates from physical coordinates&lt;br /&gt;
volumeRasToIjk = vtk.vtkMatrix4x4()&lt;br /&gt;
volumeNode.GetRASToIJKMatrix(volumeRasToIjk)&lt;br /&gt;
point_Ijk = [0, 0, 0, 1]&lt;br /&gt;
volumeRasToIjk.MultiplyPoint(np.append(point_VolumeRas,1.0), point_Ijk)&lt;br /&gt;
point_Ijk = [ int(round(c)) for c in point_Ijk[0:3] ]&lt;br /&gt;
&lt;br /&gt;
# Print output&lt;br /&gt;
print(point_Ijk)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Get the values of all voxels for a label value  ==&lt;br /&gt;
&lt;br /&gt;
If you have a background image called ‘Volume’ and a mask called ‘Volume-label’ created with the Editor you could do something like this:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
import numpy&lt;br /&gt;
volume = array(‘Volume’)&lt;br /&gt;
label = array(‘Volume-label’)&lt;br /&gt;
points  = numpy.where( label == 1 )  # or use another label number depending on what you segmented&lt;br /&gt;
values  = volume[points] # this will be a list of the label values&lt;br /&gt;
values.mean() # should match the mean value of LabelStatistics calculation as a double-check&lt;br /&gt;
numpy.savetxt(‘values.txt’, values)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Access values in a DTI tensor volume ==&lt;br /&gt;
This example shows how to access individual tensors at the voxel level.&lt;br /&gt;
&lt;br /&gt;
First load your DWI volume and estimate tensors to produce a DTI volume called ‘Output DTI Volume’&lt;br /&gt;
&lt;br /&gt;
Then open the python window: View-&amp;gt;Python interactor&lt;br /&gt;
&lt;br /&gt;
Use this command to access tensors through numpy:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
tensors = array('Output DTI Volume')&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Type the following code into the Python window to access all tensor components using vtk commands:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
volumeNode=slicer.util.getNode('Output DTI Volume')&lt;br /&gt;
imageData=volumeNode.GetImageData()&lt;br /&gt;
tensors = imageData.GetPointData().GetTensors()&lt;br /&gt;
extent = imageData.GetExtent()&lt;br /&gt;
idx = 0&lt;br /&gt;
for k in xrange(extent[4], extent[5]+1):&lt;br /&gt;
  for j in xrange(extent[2], extent[3]+1):&lt;br /&gt;
    for i in xrange(extent[0], extent[1]+1):&lt;br /&gt;
      tensors.GetTuple9(idx)&lt;br /&gt;
      idx += 1&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Change window/level (brightness/contrast) or colormap of a volume ==&lt;br /&gt;
This example shows how to change window/level of the MRHead sample volume.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
volumeNode = getNode('MRHead')&lt;br /&gt;
displayNode = volumeNode.GetDisplayNode()&lt;br /&gt;
displayNode.AutoWindowLevelOff()&lt;br /&gt;
displayNode.SetWindow(50)&lt;br /&gt;
displayNode.SetLevel(100)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Change color mapping from grayscale to rainbow:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
displayNode.SetAndObserveColorNodeID('vtkMRMLColorTableNodeRainbow')&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Manipulate a Slice View ==&lt;br /&gt;
&lt;br /&gt;
=== Change the slice offset ===&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
lm = slicer.app.layoutManager()&lt;br /&gt;
red = lm.sliceWidget('Red')&lt;br /&gt;
redLogic = red.sliceLogic()&lt;br /&gt;
# Print current slice offset position&lt;br /&gt;
print redLogic.GetSliceOffset()&lt;br /&gt;
# Change slice position&lt;br /&gt;
redLogic.SetSliceOffset(20)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Iterate over current visible slice views, and modify 3D visibility ===&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
for sliceViewName in layoutManager.sliceViewNames():&lt;br /&gt;
     sliceWidget = layoutManager.sliceWidget(sliceViewName)&lt;br /&gt;
     &lt;br /&gt;
     controller = sliceWidget.sliceController()&lt;br /&gt;
     controller.setSliceVisible(True)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Iterate over current visible slice views, and set foreground and background images ===&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
for sliceViewName in layoutManager.sliceViewNames():&lt;br /&gt;
     sliceWidget = layoutManager.sliceWidget(sliceViewName)&lt;br /&gt;
     &lt;br /&gt;
     # setup background volume&lt;br /&gt;
     compositeNode.SetBackgroundVolumeID(MRVolume.GetID())&lt;br /&gt;
     # setup foreground volume&lt;br /&gt;
     compositeNode.SetForegroundVolumeID(CTVolume.GetID())&lt;br /&gt;
     # change opacity&lt;br /&gt;
     compositeNode.SetForegroundOpacity(0.3)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Fit slice plane to markup fiducials ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sliceNode = slicer.mrmlScene.GetNodeByID(&amp;quot;vtkMRMLSliceNodeRed&amp;quot;)&lt;br /&gt;
markupsNode = slicer.mrmlScene.GetFirstNodeByName(&amp;quot;F&amp;quot;)&lt;br /&gt;
# Get markup point positions as numpy arrays&lt;br /&gt;
import numpy as np&lt;br /&gt;
p1 = np.array([0,0,0])&lt;br /&gt;
p2 = np.array([0,0,0])&lt;br /&gt;
p3 = np.array([0,0,0])&lt;br /&gt;
markupsNode.GetNthFiducialPosition(0, p1)&lt;br /&gt;
markupsNode.GetNthFiducialPosition(1, p2)&lt;br /&gt;
markupsNode.GetNthFiducialPosition(2, p3)&lt;br /&gt;
# Get plane axis directions&lt;br /&gt;
n = np.cross(p2-p1, p2-p3) # plane normal direction&lt;br /&gt;
n = n/np.linalg.norm(n)&lt;br /&gt;
t = np.cross([0, 0, 1], n) # plane transverse direction&lt;br /&gt;
t = t/np.linalg.norm(t)&lt;br /&gt;
# Set slice plane orientation and position&lt;br /&gt;
sliceNode.SetSliceToRASByNTP(n[0], n[1], n[2], t[0], t[1], t[2], p1[0], p1[1], p1[2], 0)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Save a series of images from a Slice View ==&lt;br /&gt;
&lt;br /&gt;
You can use ScreenCapture module to capture series of images. To do it programmatically, save the following into a file such as '/tmp/record.py' and then in the slicer python console type &amp;quot;execfile('/tmp/record.py')&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
layoutName = 'Green'&lt;br /&gt;
imagePathPattern = '/tmp/image-%03d.png'&lt;br /&gt;
steps = 10&lt;br /&gt;
&lt;br /&gt;
widget = slicer.app.layoutManager().sliceWidget(layoutName)&lt;br /&gt;
view = widget.sliceView()&lt;br /&gt;
logic = widget.sliceLogic()&lt;br /&gt;
bounds = [0,]*6&lt;br /&gt;
logic.GetSliceBounds(bounds)&lt;br /&gt;
&lt;br /&gt;
for step in range(steps):&lt;br /&gt;
    offset = bounds[4] + step/(1.*steps) * (bounds[5]-bounds[4])&lt;br /&gt;
    logic.SetSliceOffset(offset)&lt;br /&gt;
    view.forceRender()&lt;br /&gt;
    image = qt.QPixmap.grabWidget(view).toImage()&lt;br /&gt;
    image.save(imagePathPattern % step)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Save the scene into a new directory ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Create a new directory where the scene will be saved into&lt;br /&gt;
import time&lt;br /&gt;
sceneSaveDirectory = slicer.app.temporaryPath + &amp;quot;/saved-scene-&amp;quot; + time.strftime(&amp;quot;%Y%m%d-%H%M%S&amp;quot;)&lt;br /&gt;
if not os.access(sceneSaveDirectory, os.F_OK):&lt;br /&gt;
  os.makedirs(sceneSaveDirectory)&lt;br /&gt;
&lt;br /&gt;
# Save the scene&lt;br /&gt;
if slicer.app.applicationLogic().SaveSceneToSlicerDataBundleDirectory(sceneSaveDirectory, None):&lt;br /&gt;
  logging.info(&amp;quot;Scene saved to: {0}&amp;quot;.format(sceneSaveDirectory))&lt;br /&gt;
else:&lt;br /&gt;
  logging.error(&amp;quot;Scene saving failed&amp;quot;) &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Save the scene into a single MRB file ==&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Generate file name&lt;br /&gt;
import time&lt;br /&gt;
sceneSaveFilename = slicer.app.temporaryPath + &amp;quot;/saved-scene-&amp;quot; + time.strftime(&amp;quot;%Y%m%d-%H%M%S&amp;quot;) + &amp;quot;.mrb&amp;quot;&lt;br /&gt;
&lt;br /&gt;
# Save scene&lt;br /&gt;
if slicer.util.saveScene(sceneSaveFilename):&lt;br /&gt;
  logging.info(&amp;quot;Scene saved to: {0}&amp;quot;.format(sceneSaveFilename))&lt;br /&gt;
else:&lt;br /&gt;
  logging.error(&amp;quot;Scene saving failed&amp;quot;) &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Save a node to file ==&lt;br /&gt;
&lt;br /&gt;
Save a transform node to file (should work with any other node type, if file extension is set to a supported one):&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
myNode = getNode(&amp;quot;LinearTransform_3&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
myStorageNode = myNode.CreateDefaultStorageNode()&lt;br /&gt;
myStorageNode.SetFileName(&amp;quot;c:/tmp/something.tfm&amp;quot;)&lt;br /&gt;
myStorageNode.WriteData(myNode)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Show a volume in the Slice Views ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
volumeNode = slicer.util.getNode('YourVolumeNode')&lt;br /&gt;
applicationLogic = slicer.app.applicationLogic()&lt;br /&gt;
selectionNode = applicationLogic.GetSelectionNode()&lt;br /&gt;
selectionNode.SetSecondaryVolumeID(volumeNode.GetID())&lt;br /&gt;
applicationLogic.PropagateForegroundVolumeSelection(0) &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
or&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
n =  slicer.util.getNode('YourVolumeNode')&lt;br /&gt;
for color in ['Red', 'Yellow', 'Green']:&lt;br /&gt;
    slicer.app.layoutManager().sliceWidget(color).sliceLogic().GetSliceCompositeNode().SetForegroundVolumeID(n.GetID())&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Change opacity of foreground volume in the Slice Views ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
lm = slicer.app.layoutManager()&lt;br /&gt;
sliceLogic = lm.sliceWidget('Red').sliceLogic()&lt;br /&gt;
compositeNode = sliceLogic.GetSliceCompositeNode()&lt;br /&gt;
compositeNode.SetForegroundOpacity(0.4)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Center the 3D View on the Scene ==&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
layoutManager = slicer.app.layoutManager()&lt;br /&gt;
threeDWidget = layoutManager.threeDWidget(0)&lt;br /&gt;
threeDView = threeDWidget.threeDView()&lt;br /&gt;
threeDView.resetFocalPoint()&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Rotate the 3D View==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
layoutManager = slicer.app.layoutManager()&lt;br /&gt;
threeDWidget = layoutManager.threeDWidget(0)&lt;br /&gt;
threeDView = threeDWidget.threeDView()&lt;br /&gt;
threeDView.yaw()&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Display text in a 3D view or slice view ==&lt;br /&gt;
&lt;br /&gt;
The easiest way to show information overlaid on a viewer is to use corner annotations.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
view=slicer.app.layoutManager().threeDWidget(0).threeDView()&lt;br /&gt;
# Set text to &amp;quot;Something&amp;quot;&lt;br /&gt;
view.cornerAnnotation().SetText(vtk.vtkCornerAnnotation.UpperRight,&amp;quot;Something&amp;quot;)&lt;br /&gt;
# Set color to red&lt;br /&gt;
view.cornerAnnotation().GetTextProperty().SetColor(1,0,0)&lt;br /&gt;
# Update the view&lt;br /&gt;
view.forceRender()&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Hide slice view annotations (DataProbe) ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Disable slice annotations immediately&lt;br /&gt;
slicer.modules.DataProbeInstance.infoWidget.sliceAnnotations.sliceViewAnnotationsEnabled=False&lt;br /&gt;
slicer.modules.DataProbeInstance.infoWidget.sliceAnnotations.updateSliceViewFromGUI()&lt;br /&gt;
# Disable slice annotations persistently (after Slicer restarts)&lt;br /&gt;
settings = qt.QSettings()&lt;br /&gt;
settings.setValue('DataProbe/sliceViewAnnotations.enabled', 0)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Turning off interpolation ==&lt;br /&gt;
&lt;br /&gt;
You can turn off interpolation for newly loaded volumes with this script from Steve Pieper.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
def NoInterpolate(caller,event):&lt;br /&gt;
  for node in slicer.util.getNodes('*').values():&lt;br /&gt;
    if node.IsA('vtkMRMLScalarVolumeDisplayNode'):&lt;br /&gt;
      node.SetInterpolate(0)&lt;br /&gt;
	&lt;br /&gt;
slicer.mrmlScene.AddObserver(slicer.mrmlScene.NodeAddedEvent, NoInterpolate)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The below link explains how to put this in your startup script.&lt;br /&gt;
&lt;br /&gt;
http://www.na-mic.org/Wiki/index.php/AHM2012-Slicer-Python#Refining_the_code_and_UI_with_slicerrc&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Customize viewer layout ==&lt;br /&gt;
&lt;br /&gt;
Show a custom layout of a 3D view on top of the red slice view:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
customLayout = (&amp;quot;&amp;lt;layout type=\&amp;quot;vertical\&amp;quot; split=\&amp;quot;true\&amp;quot; &amp;gt;&amp;quot;&lt;br /&gt;
  &amp;quot; &amp;lt;item&amp;gt;&amp;quot;&lt;br /&gt;
  &amp;quot;  &amp;lt;view class=\&amp;quot;vtkMRMLViewNode\&amp;quot; singletontag=\&amp;quot;1\&amp;quot;&amp;gt;&amp;quot;&lt;br /&gt;
  &amp;quot;    &amp;lt;property name=\&amp;quot;viewlabel\&amp;quot; action=\&amp;quot;default\&amp;quot;&amp;gt;1&amp;lt;/property&amp;gt;&amp;quot;&lt;br /&gt;
  &amp;quot;  &amp;lt;/view&amp;gt;&amp;quot;&lt;br /&gt;
  &amp;quot; &amp;lt;/item&amp;gt;&amp;quot;&lt;br /&gt;
  &amp;quot; &amp;lt;item&amp;gt;&amp;quot;&lt;br /&gt;
  &amp;quot;  &amp;lt;view class=\&amp;quot;vtkMRMLSliceNode\&amp;quot; singletontag=\&amp;quot;Red\&amp;quot;&amp;gt;&amp;quot;&lt;br /&gt;
  &amp;quot;   &amp;lt;property name=\&amp;quot;orientation\&amp;quot; action=\&amp;quot;default\&amp;quot;&amp;gt;Axial&amp;lt;/property&amp;gt;&amp;quot;&lt;br /&gt;
  &amp;quot;   &amp;lt;property name=\&amp;quot;viewlabel\&amp;quot; action=\&amp;quot;default\&amp;quot;&amp;gt;R&amp;lt;/property&amp;gt;&amp;quot;&lt;br /&gt;
  &amp;quot;   &amp;lt;property name=\&amp;quot;viewcolor\&amp;quot; action=\&amp;quot;default\&amp;quot;&amp;gt;#F34A33&amp;lt;/property&amp;gt;&amp;quot;&lt;br /&gt;
  &amp;quot;  &amp;lt;/view&amp;gt;&amp;quot;&lt;br /&gt;
  &amp;quot; &amp;lt;/item&amp;gt;&amp;quot;&lt;br /&gt;
  &amp;quot;&amp;lt;/layout&amp;gt;&amp;quot;)&lt;br /&gt;
  &lt;br /&gt;
customLayoutId=501&lt;br /&gt;
&lt;br /&gt;
layoutManager = slicer.app.layoutManager()&lt;br /&gt;
layoutManager.layoutLogic().GetLayoutNode().AddLayoutDescription(customLayoutId, customLayout)                                         &lt;br /&gt;
layoutManager.setLayout(customLayoutId)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
See description of standard layouts (that can be used as examples) here:&lt;br /&gt;
https://github.com/Slicer/Slicer/blob/master/Libs/MRML/Logic/vtkMRMLLayoutLogic.cxx&lt;br /&gt;
&lt;br /&gt;
== Customize keyboard shortcuts ==&lt;br /&gt;
&lt;br /&gt;
Keyboard shortcuts can be specified for activating any Slicer feature by adding a couple of lines to your &lt;br /&gt;
[[Documentation/{{documentation/version}}/Developers/Python_scripting#How_to_systematically_execute_custom_python_code_at_startup_.3F|.slicerrc file]].&lt;br /&gt;
&lt;br /&gt;
For example, this script registers ''Ctrl+b'', ''Ctrl+n'', ''Ctrl+m'', ''Ctrl+,'' keyboard shortcuts to switch between red, yellow, green, and 4-up view layouts.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
shortcuts = [&lt;br /&gt;
    ('Ctrl+b', lambda: slicer.app.layoutManager().setLayout(slicer.vtkMRMLLayoutNode.SlicerLayoutOneUpRedSliceView)),&lt;br /&gt;
    ('Ctrl+n', lambda: slicer.app.layoutManager().setLayout(slicer.vtkMRMLLayoutNode.SlicerLayoutOneUpYellowSliceView)),&lt;br /&gt;
    ('Ctrl+m', lambda: slicer.app.layoutManager().setLayout(slicer.vtkMRMLLayoutNode.SlicerLayoutOneUpGreenSliceView)),&lt;br /&gt;
    ('Ctrl+,', lambda: slicer.app.layoutManager().setLayout(slicer.vtkMRMLLayoutNode.SlicerLayoutFourUpView))&lt;br /&gt;
    ]&lt;br /&gt;
&lt;br /&gt;
for (shortcutKey, callback) in shortcuts:&lt;br /&gt;
    shortcut = qt.QShortcut(slicer.util.mainWindow())&lt;br /&gt;
    shortcut.setKey(qt.QKeySequence(shortcutKey))&lt;br /&gt;
    shortcut.connect( 'activated()', callback)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Disable certain user interactions in slice views ==&lt;br /&gt;
&lt;br /&gt;
For example, disable slice browsing using mouse wheel and keyboard shortcuts in the red slice viewer:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
interactorStyle = slicer.app.layoutManager().sliceWidget('Red').sliceView().sliceViewInteractorStyle()&lt;br /&gt;
interactorStyle.SetActionEnabled(interactorStyle.BrowseSlice, False)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Hide all slice view controllers:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
lm = slicer.app.layoutManager()&lt;br /&gt;
for sliceViewName in lm.sliceViewNames():&lt;br /&gt;
  lm.sliceWidget(sliceViewName).sliceController().setVisible(False)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Hide all 3D view controllers:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
lm = slicer.app.layoutManager()&lt;br /&gt;
for viewIndex in range(slicer.app.layoutManager().threeDViewCount):&lt;br /&gt;
  lm.threeDWidget(0).threeDController().setVisible(False)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Change default slice view orientation ==&lt;br /&gt;
&lt;br /&gt;
You can left-right &amp;quot;flip&amp;quot; slice view orientation presets (show patient left side on left/right side of the screen) by copy-pasting the script below to your [[Documentation/{{documentation/version}}/Developers/FAQ/Python_Scripting#How_to_systematically_execute_custom_python_code_at_startup_.3F| .slicerrc.py file]].&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Axial slice axes:&lt;br /&gt;
#  1 0 0&lt;br /&gt;
#  0 1 0&lt;br /&gt;
#  0 0 1&lt;br /&gt;
axialSliceToRas=vtk.vtkMatrix3x3()&lt;br /&gt;
&lt;br /&gt;
# Coronal slice axes:&lt;br /&gt;
#  1 0 0 &lt;br /&gt;
#  0 0 -1&lt;br /&gt;
#  0 1 0&lt;br /&gt;
coronalSliceToRas=vtk.vtkMatrix3x3()&lt;br /&gt;
coronalSliceToRas.SetElement(1,1, 0)&lt;br /&gt;
coronalSliceToRas.SetElement(1,2, -1)&lt;br /&gt;
coronalSliceToRas.SetElement(2,1, 1)&lt;br /&gt;
coronalSliceToRas.SetElement(2,2, 0)&lt;br /&gt;
&lt;br /&gt;
# Replace orientation presets in all existing slice nodes and in the default slice node&lt;br /&gt;
sliceNodes = slicer.util.getNodesByClass('vtkMRMLSliceNode')&lt;br /&gt;
sliceNodes.append(slicer.mrmlScene.GetDefaultNodeByClass('vtkMRMLSliceNode'))&lt;br /&gt;
for sliceNode in sliceNodes:&lt;br /&gt;
  orientationPresetName = sliceNode.GetOrientation()&lt;br /&gt;
  sliceNode.RemoveSliceOrientationPreset(&amp;quot;Axial&amp;quot;)&lt;br /&gt;
  sliceNode.AddSliceOrientationPreset(&amp;quot;Axial&amp;quot;, axialSliceToRas)&lt;br /&gt;
  sliceNode.RemoveSliceOrientationPreset(&amp;quot;Coronal&amp;quot;)&lt;br /&gt;
  sliceNode.AddSliceOrientationPreset(&amp;quot;Coronal&amp;quot;, coronalSliceToRas)&lt;br /&gt;
  sliceNode.SetOrientation(orientationPresetName)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Set all slice views linked by default ==&lt;br /&gt;
&lt;br /&gt;
You can make slice views linked by default (when application starts or the scene is cleared) by copy-pasting the script below to your [[Documentation/{{documentation/version}}/Developers/FAQ/Python_Scripting#How_to_systematically_execute_custom_python_code_at_startup_.3F| .slicerrc.py file]].&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Set linked slice views  in all existing slice composite nodes and in the default node&lt;br /&gt;
sliceCompositeNodes = slicer.util.getNodesByClass('vtkMRMLSliceCompositeNode')&lt;br /&gt;
defaultSliceCompositeNode = slicer.mrmlScene.GetDefaultNodeByClass('vtkMRMLSliceCompositeNode')&lt;br /&gt;
if not defaultSliceCompositeNode:&lt;br /&gt;
  defaultSliceCompositeNode = slicer.mrmlScene.CreateNodeByClass('vtkMRMLSliceCompositeNode')&lt;br /&gt;
  slicer.mrmlScene.AddDefaultNode(defaultSliceCompositeNode)&lt;br /&gt;
sliceCompositeNodes.append(defaultSliceCompositeNode)&lt;br /&gt;
for sliceCompositeNode in sliceCompositeNodes:&lt;br /&gt;
  sliceCompositeNode.SetLinkedControl(True)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Set up custom units in slice view ruler ==&lt;br /&gt;
&lt;br /&gt;
For microscopy or micro-CT images you may want to switch unit to micrometer instead of the default mm. To do that, 1. change the unit in Application settings / Units and 2. update ruler display settings using the script below (it can be copied to your Application startup script):&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
lm = slicer.app.layoutManager()&lt;br /&gt;
for sliceViewName in lm.sliceViewNames():&lt;br /&gt;
  sliceView = lm.sliceWidget(sliceViewName).sliceView()&lt;br /&gt;
  displayableManagerCollection = vtk.vtkCollection()&lt;br /&gt;
  sliceView.getDisplayableManagers(displayableManagerCollection)&lt;br /&gt;
  for dmIndex in xrange(displayableManagerCollection.GetNumberOfItems()):&lt;br /&gt;
    displayableManager = displayableManagerCollection.GetItemAsObject(dmIndex)&lt;br /&gt;
    if not displayableManager.IsA(&amp;quot;vtkMRMLRulerDisplayableManager&amp;quot;):&lt;br /&gt;
      continue&lt;br /&gt;
    displayableManager.RemoveAllRulerScalePresets()&lt;br /&gt;
    displayableManager.AddRulerScalePreset(   0.001, 5, 2, &amp;quot;nm&amp;quot;, 1000.0)&lt;br /&gt;
    displayableManager.AddRulerScalePreset(   0.010, 5, 2, &amp;quot;nm&amp;quot;, 1000.0)&lt;br /&gt;
    displayableManager.AddRulerScalePreset(   0.100, 5, 2, &amp;quot;nm&amp;quot;, 1000.0)&lt;br /&gt;
    displayableManager.AddRulerScalePreset(   0.500, 5, 1, &amp;quot;nm&amp;quot;, 1000.0)&lt;br /&gt;
    displayableManager.AddRulerScalePreset(   1.0,   5, 2, &amp;quot;um&amp;quot;,    1.0)&lt;br /&gt;
    displayableManager.AddRulerScalePreset(   5.0,   5, 1, &amp;quot;um&amp;quot;,    1.0)&lt;br /&gt;
    displayableManager.AddRulerScalePreset(  10.0,   5, 2, &amp;quot;um&amp;quot;,    1.0)&lt;br /&gt;
    displayableManager.AddRulerScalePreset(  50.0,   5, 1, &amp;quot;um&amp;quot;,    1.0)&lt;br /&gt;
    displayableManager.AddRulerScalePreset( 100.0,   5, 2, &amp;quot;um&amp;quot;,    1.0)&lt;br /&gt;
    displayableManager.AddRulerScalePreset( 500.0,   5, 1, &amp;quot;um&amp;quot;,    1.0)&lt;br /&gt;
    displayableManager.AddRulerScalePreset(1000.0,   5, 2, &amp;quot;mm&amp;quot;,    0.001)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Show a slice view outside the view layout ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sliceLayoutName = &amp;quot;TestSlice&amp;quot;&lt;br /&gt;
sliceLayoutLabel = &amp;quot;T&amp;quot;&lt;br /&gt;
# ownerNode manages this view instead of the layout manager (it can be any node in the scene)&lt;br /&gt;
viewOwnerNode = slicer.mrmlScene.AddNewNodeByClass(&amp;quot;vtkMRMLScriptedModuleNode&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
# Create MRML nodes&lt;br /&gt;
sliceNode = slicer.vtkMRMLSliceNode()&lt;br /&gt;
sliceNode.SetName(sliceLayoutName)&lt;br /&gt;
sliceNode.SetLayoutName(sliceLayoutName)&lt;br /&gt;
sliceNode.SetLayoutLabel(sliceLayoutLabel)&lt;br /&gt;
sliceNode.SetLayoutColor(1, 1, 0)&lt;br /&gt;
sliceNode.SetAndObserveParentLayoutNodeID(viewOwnerNode.GetID())&lt;br /&gt;
sliceNode = slicer.mrmlScene.AddNode(sliceNode)&lt;br /&gt;
sliceCompositeNode = slicer.mrmlScene.AddNewNodeByClass(&amp;quot;vtkMRMLSliceCompositeNode&amp;quot;)&lt;br /&gt;
sliceCompositeNode.SetLayoutName(sliceLayoutName)&lt;br /&gt;
&lt;br /&gt;
# Create widget&lt;br /&gt;
sliceWidget = slicer.qMRMLSliceWidget()&lt;br /&gt;
sliceWidget.sliceViewName = sliceLayoutName&lt;br /&gt;
sliceWidget.sliceViewLabel = sliceLayoutLabel&lt;br /&gt;
c = sliceNode.GetLayoutColor()&lt;br /&gt;
sliceWidget.sliceViewColor = qt.QColor.fromRgbF(c[0],c[1],c[2])&lt;br /&gt;
sliceWidget.setMRMLScene(slicer.mrmlScene)&lt;br /&gt;
sliceWidget.setMRMLSliceNode(sliceNode)&lt;br /&gt;
sliceWidget.show()&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Running an ITK filter in Python using SimpleITK ==&lt;br /&gt;
Open the &amp;quot;Sample Data&amp;quot; module and download &amp;quot;MR Head&amp;quot;, then paste the following snippet in Python interactor:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
import SimpleITK as sitk&lt;br /&gt;
import sitkUtils&lt;br /&gt;
inputImage = sitkUtils.PullFromSlicer('MRHead')&lt;br /&gt;
filter = sitk.SignedMaurerDistanceMapImageFilter()&lt;br /&gt;
outputImage = filter.Execute(inputImage)&lt;br /&gt;
sitkUtils.PushToSlicer(outputImage,'outputImage')&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
More information:&lt;br /&gt;
* See the SimpleITK documentation for SimpleITK examples: http://www.itk.org/SimpleITKDoxygen/html/examples.html&lt;br /&gt;
* sitkUtils in Slicer is used for pushing and pulling images from Slicer to SimpleITK: https://github.com/Slicer/Slicer/blob/master/Base/Python/sitkUtils.py&lt;br /&gt;
&lt;br /&gt;
== Get current mouse coordinates in a slice view ==&lt;br /&gt;
&lt;br /&gt;
You can get 3D (RAS) coordinates of the current mouse cursor from the crosshair singleton node as shown in the example below:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
def onMouseMoved(observer,eventid):  &lt;br /&gt;
  ras=[0,0,0]&lt;br /&gt;
  crosshairNode.GetCursorPositionRAS(ras)&lt;br /&gt;
  print(ras)&lt;br /&gt;
&lt;br /&gt;
crosshairNode=slicer.util.getNode('Crosshair') &lt;br /&gt;
crosshairNode.AddObserver(slicer.vtkMRMLCrosshairNode.CursorPositionModifiedEvent, onMouseMoved)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Get DataProbe text ==&lt;br /&gt;
&lt;br /&gt;
You can get the mouse location in pixel coordinates along with the pixel value at the mouse by hitting the '.' (period) key in a slice view after pasting in the following code.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
def printDataProbe():&lt;br /&gt;
  infoWidget = slicer.modules.DataProbeInstance.infoWidget&lt;br /&gt;
  for layer in ('B', 'F', 'L'):&lt;br /&gt;
    print(infoWidget.layerNames[layer].text, infoWidget.layerIJKs[layer].text, infoWidget.layerValues[layer].text)&lt;br /&gt;
&lt;br /&gt;
s = qt.QShortcut(qt.QKeySequence('.'), mainWindow())&lt;br /&gt;
s.connect('activated()', printDataProbe)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Thick slab reconstruction and maximum/minimum intensity volume projections ==&lt;br /&gt;
&lt;br /&gt;
Set up 'red' slice viewer to show thick slab reconstructed from 3 slices:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sliceNode = slicer.mrmlScene.GetNodeByID('vtkMRMLSliceNodeRed')&lt;br /&gt;
appLogic = slicer.app.applicationLogic()&lt;br /&gt;
sliceLogic = appLogic.GetSliceLogic(sliceNode)&lt;br /&gt;
sliceLayerLogic = sliceLogic.GetBackgroundLayer()&lt;br /&gt;
reslice = sliceLayerLogic.GetReslice()&lt;br /&gt;
reslice.SetSlabModeToMean()&lt;br /&gt;
reslice.SetSlabNumberOfSlices(10) # mean of 10 slices will computed&lt;br /&gt;
reslice.SetSlabSliceSpacingFraction(0.3) # spacing between each slice is 0.3 pixel (total 10 * 0.3 = 3 pixel neighborhood)&lt;br /&gt;
sliceNode.Modified()&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Set up 'red' slice viewer to show maximum intensity projection (MIP):&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sliceNode = slicer.mrmlScene.GetNodeByID('vtkMRMLSliceNodeRed')&lt;br /&gt;
appLogic = slicer.app.applicationLogic()&lt;br /&gt;
sliceLogic = appLogic.GetSliceLogic(sliceNode)&lt;br /&gt;
sliceLayerLogic = sliceLogic.GetBackgroundLayer()&lt;br /&gt;
reslice = sliceLayerLogic.GetReslice()&lt;br /&gt;
reslice.SetSlabModeToMax()&lt;br /&gt;
reslice.SetSlabNumberOfSlices(600) # use a large number of slices (600) to cover the entire volume&lt;br /&gt;
reslice.SetSlabSliceSpacingFraction(0.5) # spacing between slices are 0.5 pixel (supersampling is useful to reduce interpolation artifacts)&lt;br /&gt;
sliceNode.Modified()&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The projected image is available in a ''vtkImageData'' object by calling ''reslice.GetOutput()''.&lt;br /&gt;
&lt;br /&gt;
== Change default file type for nodes (that have never been saved yet) ==&lt;br /&gt;
Default node can be specified that will be used as a basis of all new storage nodes. This can be used for setting default file extension. For example, change file format to STL for model nodes:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
defaultModelStorageNode = slicer.vtkMRMLModelStorageNode()&lt;br /&gt;
defaultModelStorageNode.SetDefaultWriteFileExtension('stl')&lt;br /&gt;
slicer.mrmlScene.AddDefaultNode(defaultModelStorageNode)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To permanently change default file extension on your computer, copy-paste the code above into your application startup script (you can find its location in menu: Edit / Application settings / General / Application startup script).&lt;br /&gt;
&lt;br /&gt;
== Change file type for saving for all volumes (with already existing storage nodes) ==&lt;br /&gt;
&lt;br /&gt;
If it is not necessary to preserve file paths then the simplest is to configure default storage node (as shown in the example above), then delete all existing storage nodes. When save dialog is opened, default storage nodes will be recreated.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Delete existing model storage nodes so that they will be recreated with default settings&lt;br /&gt;
existingModelStorageNodes = slicer.util.getNodesByClass('vtkMRMLModelStorageNode')&lt;br /&gt;
for modelStorageNode in existingModelStorageNodes:&lt;br /&gt;
  slicer.mrmlScene.RemoveNode(modelStorageNode)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To update existing storage nodes to use new file extension (but keep all other parameters unchanged) you can use this approach (example is for volume storage):&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
requiredFileExtension = '.nia'&lt;br /&gt;
originalFileExtension = '.nrrd'&lt;br /&gt;
volumeNodes = slicer.util.getNodesByClass('vtkMRMLScalarVolumeNode')&lt;br /&gt;
for volumeNode in volumeNodes:&lt;br /&gt;
  volumeStorageNode = volumeNode.GetStorageNode()&lt;br /&gt;
  if not volumeStorageNode:&lt;br /&gt;
    volumeNode.AddDefaultStorageNode()&lt;br /&gt;
    volumeStorageNode = volumeNode.GetStorageNode()&lt;br /&gt;
    volumeStorageNode.SetFileName(volumeNode.GetName()+requiredFileExtension)&lt;br /&gt;
  else:&lt;br /&gt;
    volumeStorageNode.SetFileName(volumeStorageNode.GetFileName().replace(originalFileExtension, requiredFileExtension))&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Segmentations ==&lt;br /&gt;
&lt;br /&gt;
=== Create a segmentation from a labelmap volume and display in 3D ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
labelmapVolumeNode = getNode('label')&lt;br /&gt;
seg = slicer.mrmlScene.AddNewNodeByClass('vtkMRMLSegmentationNode')&lt;br /&gt;
slicer.modules.segmentations.logic().ImportLabelmapToSegmentationNode(labelmapVolumeNode, seg)&lt;br /&gt;
seg.CreateClosedSurfaceRepresentation()&lt;br /&gt;
slicer.mrmlScene.RemoveNode(labelmapVolumeNode)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The last line is optional. It removes the original labelmap volume so that the same information is not shown twice.&lt;br /&gt;
&lt;br /&gt;
=== Export labelmap node from segmentation node ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
seg = getNode('Segmentation')&lt;br /&gt;
labelmapVolumeNode = slicer.mrmlScene.AddNewNodeByClass('vtkMRMLLabelMapVolumeNode')&lt;br /&gt;
slicer.modules.segmentations.logic().ExportAllSegmentsToLabelmapNode(seg, labelmapVolumeNode)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Export model nodes from segmentation node ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
seg = getNode('Segmentation')&lt;br /&gt;
exportedModelsNode = slicer.mrmlScene.AddNewNodeByClass('vtkMRMLModelHierarchyNode')&lt;br /&gt;
slicer.modules.segmentations.logic().ExportAllSegmentsToModelHierarchy(seg, exportedModelsNode)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Show a segmentation in 3D ===&lt;br /&gt;
Segmentation can only be shown in 3D if closed surface representation (or other 3D-displayable representation) is available. To create closed surface representation:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
segmentation.CreateClosedSurfaceRepresentation()&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Get a representation of a segment ===&lt;br /&gt;
Access binary labelmap stored in a segmentation node (without exporting it to a volume node) - if it does not exist, it will return None:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
image = segmentationNode.GetBinaryLabelmapRepresentation(segmentID)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Get closed surface, if it does not exist, it will return None:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
polydata = segmentationNode.GetClosedSurfaceRepresentation(segmentID)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Get binary labelmap representation. If it does not exist then it will be created for that single segment. Applies parent transforms by default (if not desired, another argument needs to be added to the end: false):&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
import vtkSegmentationCorePython as vtkSegmentationCore&lt;br /&gt;
outputOrientedImageData = vtkSegmentationCore.vtkOrientedImageData()&lt;br /&gt;
slicer.vtkSlicerSegmentationsModuleLogic.GetSegmentBinaryLabelmapRepresentation(segmentationNode, segmentID, outputOrientedImageData)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Same as above, for closed surface representation:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
outputPolyData = vtk.vtkPolyData()&lt;br /&gt;
slicer.vtkSlicerSegmentationsModuleLogic.GetSegmentClosedSurfaceRepresentation(segmentationNode, segmentID, outputPolyData)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Convert all segments using default path and conversion parameters ===&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
segmentationNode.CreateBinaryLabelmapRepresentation()&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Convert all segments using custom path or conversion parameters ===&lt;br /&gt;
Change reference image geometry parameter based on an existing referenceImageData image:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
import vtkSegmentationCorePython as vtkSegmentationCore&lt;br /&gt;
referenceGeometry = vtkSegmentationCore.vtkSegmentationConverter.SerializeImageGeometry(referenceImageData)&lt;br /&gt;
segmentation.SetConversionParameter(vtkSegmentationCore.vtkSegmentationConverter.GetReferenceImageGeometryParameterName(), referenceGeometry)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Re-convert using a modified conversion parameter ===&lt;br /&gt;
Changing smoothing factor for closed surface generation:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
import vtkSegmentationCorePython as vtkSegmentationCore&lt;br /&gt;
segmentation = getNode('Segmentation').GetSegmentation()&lt;br /&gt;
&lt;br /&gt;
# Turn of surface smoothing&lt;br /&gt;
segmentation.SetConversionParameter('Smoothing factor','0.0')&lt;br /&gt;
&lt;br /&gt;
# Recreate representation using modified parameters (and default conversion path)&lt;br /&gt;
segmentation.RemoveRepresentation(vtkSegmentationCore.vtkSegmentationConverter.GetSegmentationClosedSurfaceRepresentationName())&lt;br /&gt;
segmentation.CreateRepresentation(vtkSegmentationCore.vtkSegmentationConverter.GetSegmentationClosedSurfaceRepresentationName())&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Get centroid of a segment in world (RAS) coordinates ===&lt;br /&gt;
&lt;br /&gt;
This example shows how to get centroid of a segment in world coordinates and show that position in all slice views.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
segmentationNode = getNode('Segmentation')&lt;br /&gt;
segmentId = 'Segment_1'&lt;br /&gt;
&lt;br /&gt;
# Get array voxel coordinates&lt;br /&gt;
import numpy as np&lt;br /&gt;
seg=arrayFromSegment(segmentation_node, segmentId)&lt;br /&gt;
# numpy array has voxel coordinates in reverse order (KJI instead of IJK)&lt;br /&gt;
# and the array is cropped to minimum size in the segmentation&lt;br /&gt;
mean_KjiCropped = [coords.mean() for coords in np.nonzero(seg)]&lt;br /&gt;
&lt;br /&gt;
# Get segmentation voxel coordinates&lt;br /&gt;
segImage = segmentationNode.GetBinaryLabelmapRepresentation(segmentId)&lt;br /&gt;
segImageExtent = segImage.GetExtent()&lt;br /&gt;
# origin of the array in voxel coordinates is determined by the start extent&lt;br /&gt;
mean_Ijk = [mean_KjiCropped[2], mean_KjiCropped[1], mean_KjiCropped[0]] + np.array([segImageExtent[0], segImageExtent[2], segImageExtent[4]])&lt;br /&gt;
&lt;br /&gt;
# Get segmentation physical coordinates&lt;br /&gt;
ijkToWorld = vtk.vtkMatrix4x4()&lt;br /&gt;
segImage.GetImageToWorldMatrix(ijkToWorld)&lt;br /&gt;
mean_World = [0, 0, 0, 1]&lt;br /&gt;
ijkToRas.MultiplyPoint(np.append(mean_Ijk,1.0), mean_World)&lt;br /&gt;
mean_World = mean_World[0:3]&lt;br /&gt;
&lt;br /&gt;
# If segmentation node is transformed, apply that transform to get RAS coordinates&lt;br /&gt;
transformWorldToRas = vtk.vtkGeneralTransform()&lt;br /&gt;
slicer.vtkMRMLTransformNode.GetTransformBetweenNodes(segmentationNode.GetParentTransformNode(), None, transformWorldToRas)&lt;br /&gt;
mean_Ras = transformWorldToRas.TransformPoint(mean_World)&lt;br /&gt;
&lt;br /&gt;
# Show mean position value and jump to it in all slice viewers&lt;br /&gt;
print(mean_Ras)&lt;br /&gt;
slicer.modules.markups.logic().JumpSlicesToLocation(mean_Ras[0], mean_Ras[1], mean_Ras[2], True)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== How to run segment editor effects from a script ===&lt;br /&gt;
&lt;br /&gt;
Editor effects are complex because they need to handle changing master volumes, undo/redo, masking operations, etc. Therefore, instead of using a segment editor effect, it is simpler to run the underlying filters directly from script.&lt;br /&gt;
&lt;br /&gt;
This example demonstrates how to use Segment editor effects (without GUI, using qMRMLSegmentEditorWidget):&lt;br /&gt;
&lt;br /&gt;
* [https://gist.github.com/lassoan/2d5a5b73645f65a5eb6f8d5f97abf31b brain tumor segmentation using grow from seeds effect]&lt;br /&gt;
* [https://gist.github.com/lassoan/1673b25d8e7913cbc245b4f09ed853f9 skin surface extraction using thresholding and smoothing]&lt;br /&gt;
* [https://gist.github.com/lassoan/2f5071c562108dac8efe277c78f2620f mask a volume with segments and compute histogram for each region]&lt;br /&gt;
&lt;br /&gt;
This example shows how to perform operations on segmentations using VTK filters:&lt;br /&gt;
* [https://gist.github.com/lassoan/7c94c334653010696b2bf96abc0ac8e7 brain tumor segmentation using grow from seeds effect]&lt;br /&gt;
&lt;br /&gt;
== Accessing views, renderers, and cameras ==&lt;br /&gt;
&lt;br /&gt;
Iterate through all 3D views in current layout:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
layoutManager = slicer.app.layoutManager()&lt;br /&gt;
for threeDViewIndex in range(layoutManager.threeDViewCount) :&lt;br /&gt;
  view = layoutManager.threeDWidget(threeDViewIndex).threeDView()&lt;br /&gt;
  threeDViewNode = view.mrmlViewNode()&lt;br /&gt;
  cameraNode = slicer.modules.cameras.logic().GetViewActiveCameraNode(threeDViewNode)&lt;br /&gt;
  print('View node for 3D widget ' + str(threeDViewIndex))&lt;br /&gt;
  print('  Name: ' + threeDViewNode .GetName())&lt;br /&gt;
  print('  ID: ' + threeDViewNode .GetID())&lt;br /&gt;
  print('  Camera ID: ' + cameraNode.GetID())&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Iterate through all slice views in current layout:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
layoutManager = slicer.app.layoutManager()&lt;br /&gt;
for sliceViewName in layoutManager.sliceViewNames():&lt;br /&gt;
  view = layoutManager.sliceWidget(sliceViewName).sliceView()&lt;br /&gt;
  sliceNode = view.mrmlSliceNode()&lt;br /&gt;
  sliceLogic = slicer.app.applicationLogic().GetSliceLogic(sliceNode)&lt;br /&gt;
  compositeNode = sliceLogic.GetSliceCompositeNode()&lt;br /&gt;
  print('Slice view ' + str(sliceViewName))&lt;br /&gt;
  print('  Name: ' + sliceNode.GetName())&lt;br /&gt;
  print('  ID: ' + sliceNode.GetID())&lt;br /&gt;
  print('  Background volume: {0}'.format(compositeNode.GetBackgroundVolumeID()))&lt;br /&gt;
  print('  Foreground volume: {0} (opacity: {1})'.format(compositeNode.GetForegroundVolumeID(), compositeNode.GetForegroundOpacity()))&lt;br /&gt;
  print('  Label volume: {0} (opacity: {1})'.format(compositeNode.GetLabelVolumeID(), compositeNode.GetLabelOpacity()))&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
For low-level manipulation of views, it is possible to access VTK render windows, renderers and cameras of views in the current layout.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
renderWindow = view.renderWindow()&lt;br /&gt;
renderers = renderWindow.GetRenderers()&lt;br /&gt;
renderer = renderers.GetItemAsObject(0)&lt;br /&gt;
camera = cameraNode.GetCamera()&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Change 3D view background color ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
renderWindow = slicer.app.layoutManager().threeDWidget(0).threeDView().renderWindow()&lt;br /&gt;
renderer = renderWindow.GetRenderers().GetFirstRenderer()&lt;br /&gt;
renderer.SetBackground(1,0,0)&lt;br /&gt;
renderer.SetBackground2(1,0,0)&lt;br /&gt;
renderWindow.Render()&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Subject hierarchy == &lt;br /&gt;
==== Get the pseudo-singleton subject hierarchy node ====&lt;br /&gt;
It manages the whole hierarchy and provides functions to access and manipulate&lt;br /&gt;
  shNode = slicer.vtkMRMLSubjectHierarchyNode.GetSubjectHierarchyNode(slicer.mrmlScene)&lt;br /&gt;
&lt;br /&gt;
==== Create subject hierarchy item ====&lt;br /&gt;
  # If it is for a data node, it is automatically created, but the create function can be used to set parent:&lt;br /&gt;
  shNode.CreateItem(parentItemID, dataNode)&lt;br /&gt;
  # If it is a hierarchy item without a data node, then the create function must be used:&lt;br /&gt;
  shNode.CreateSubjectItem(parentItemID, name)&lt;br /&gt;
  shNode.CreateFolderItem(parentItemID, name)&lt;br /&gt;
  shNode.CreateHierarchyItem(parentItemID, name, level) # Advanced method to set level attribute manually (usually subject, study, or folder, but it can be a virtual branch for example)&lt;br /&gt;
&lt;br /&gt;
==== Get subject hierarchy item ====&lt;br /&gt;
Items in subject hierarchy are uniquely identified by integer IDs&lt;br /&gt;
  # Get scene item ID first because it is the root item:&lt;br /&gt;
  sceneItemID = shNode.GetSceneItemID()&lt;br /&gt;
  # Get direct child by name&lt;br /&gt;
  subjectItemID = shNode.GetItemChildWithName(sceneItemID, 'Subject_1')&lt;br /&gt;
  # Get item for data node&lt;br /&gt;
  itemID = shNode.GetItemByDataNode(dataNode)&lt;br /&gt;
  # Get item by UID (such as DICOM)&lt;br /&gt;
  itemID = shNode.GetItemByUID(slicer.vtkMRMLSubjectHierarchyConstants.GetDICOMUIDName(), seriesInstanceUid)&lt;br /&gt;
  itemID = shNode.GetItemByUIDList(slicer.vtkMRMLSubjectHierarchyConstants.GetDICOMInstanceUIDName(), instanceUID)&lt;br /&gt;
  # Invalid item ID for checking validity of a given ID (most functions return the invalid ID when item is not found)&lt;br /&gt;
  invalidItemID = slicer.vtkMRMLSubjectHierarchyNode.GetInvalidItemID()&lt;br /&gt;
&lt;br /&gt;
==== Traverse children of a subject hierarchy item ====&lt;br /&gt;
  children = vtk.vtkIdList()&lt;br /&gt;
  shNode.GetItemChildren(parent, children)&lt;br /&gt;
  for i in xrange(children.GetNumberOfIds()):&lt;br /&gt;
    child = children.GetId(i)&lt;br /&gt;
    ...&lt;br /&gt;
&lt;br /&gt;
==== Manipulate subject hierarchy item ====&lt;br /&gt;
Instead of node operations on the individual subject hierarchy nodes, item operations are performed on the one subject hierarchy node.&lt;br /&gt;
  # Set item name&lt;br /&gt;
  shNode.SetItemName(itemID, 'NewName')&lt;br /&gt;
  # Set item parent (reparent)&lt;br /&gt;
  shNode.SetItemParent(itemID, newParentItemID)&lt;br /&gt;
  # Set visibility of data nodes associated to items in a branch (or a leaf item)&lt;br /&gt;
  shNode.SetDisplayVisibilityForBranch(itemID, 1)&lt;br /&gt;
&lt;br /&gt;
==== Filter items in TreeView or ComboBox ====&lt;br /&gt;
Displayed items can be filtered using ''setAttributeFilter'' method. An example of the usage can be found in the  [https://github.com/Slicer/Slicer/blob/e66e3b08e35384526528e6ae678e9ec9f079f286/Applications/SlicerApp/Testing/Python/SubjectHierarchyGenericSelfTest.py#L352-L360 unit test]. Modified version here:&lt;br /&gt;
    print shTreeView.displayedItemCount() # 5&lt;br /&gt;
    shTreeView.setAttributeFilter('DICOM.Modality') # Nodes must have this attribute&lt;br /&gt;
    print shTreeView.displayedItemCount() # 3&lt;br /&gt;
    shTreeView.setAttributeFilter('DICOM.Modality','CT') # Have attribute and equal 'CT'&lt;br /&gt;
    print shTreeView.displayedItemCount() # 1&lt;br /&gt;
    shTreeView.removeAttributeFilter()&lt;br /&gt;
    print shTreeView.displayedItemCount() # 5&lt;br /&gt;
&lt;br /&gt;
=== Listen to subject hierarchy item events ===&lt;br /&gt;
The subject hierarchy node sends the node item id as calldata. Item IDs are vtkIdType, which are NOT vtkObjects. You need to use vtk.calldata_type(vtk.VTK_LONG) (otherwise the application crashes).&lt;br /&gt;
  &lt;br /&gt;
  class MyListenerClass(VTKObservationMixin):&lt;br /&gt;
    def __init__(self):&lt;br /&gt;
      VTKObservationMixin.__init__(self)&lt;br /&gt;
      &lt;br /&gt;
      shNode = slicer.vtkMRMLSubjectHierarchyNode.GetSubjectHierarchyNode(slicer.mrmlScene)&lt;br /&gt;
      self.addObserver(shNode, shNode.SubjectHierarchyItemModifiedEvent, self.shItemModifiedEvent)&lt;br /&gt;
     &lt;br /&gt;
    @vtk.calldata_type(vtk.VTK_LONG) &lt;br /&gt;
    def shItemModifiedEvent(self, caller, eventId, callData):&lt;br /&gt;
      print(&amp;quot;SH Node modified&amp;quot;)&lt;br /&gt;
      print(&amp;quot;SH item ID: {0}&amp;quot;.format(callData))&lt;br /&gt;
&lt;br /&gt;
== Plotting ==&lt;br /&gt;
&lt;br /&gt;
=== Create histogram plot of a volume ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Get a volume from SampleData&lt;br /&gt;
import SampleData&lt;br /&gt;
volumeNode = SampleData.SampleDataLogic().downloadMRHead()&lt;br /&gt;
&lt;br /&gt;
# Compute histogram values&lt;br /&gt;
import numpy as np&lt;br /&gt;
histogram = np.histogram(arrayFromVolume(volumeNode), bins=50)&lt;br /&gt;
&lt;br /&gt;
# Save results to a new table node&lt;br /&gt;
tableNode=slicer.mrmlScene.AddNewNodeByClass(&amp;quot;vtkMRMLTableNode&amp;quot;)&lt;br /&gt;
updateTableFromArray(tableNode, histogram)&lt;br /&gt;
tableNode.GetTable().GetColumn(0).SetName(&amp;quot;Count&amp;quot;)&lt;br /&gt;
tableNode.GetTable().GetColumn(1).SetName(&amp;quot;Intensity&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
# Create plot&lt;br /&gt;
plotSeriesNode = slicer.mrmlScene.AddNewNodeByClass(&amp;quot;vtkMRMLPlotSeriesNode&amp;quot;, volumeNode.GetName() + ' histogram')&lt;br /&gt;
plotSeriesNode.SetAndObserveTableNodeID(tableNode.GetID())&lt;br /&gt;
plotSeriesNode.SetXColumnName(&amp;quot;Intensity&amp;quot;)&lt;br /&gt;
plotSeriesNode.SetYColumnName(&amp;quot;Count&amp;quot;)&lt;br /&gt;
plotSeriesNode.SetPlotType(plotSeriesNode.PlotTypeScatterBar)&lt;br /&gt;
plotSeriesNode.SetColor(0, 0.6, 1.0)&lt;br /&gt;
&lt;br /&gt;
# Create chart and add plot&lt;br /&gt;
plotChartNode = slicer.mrmlScene.AddNewNodeByClass(&amp;quot;vtkMRMLPlotChartNode&amp;quot;)&lt;br /&gt;
plotChartNode.AddAndObservePlotSeriesNodeID(plotSeriesNode.GetID())&lt;br /&gt;
plotChartNode.YAxisRangeAutoOff()&lt;br /&gt;
plotChartNode.SetYAxisRange(0, 500000)&lt;br /&gt;
&lt;br /&gt;
# Show plot in layout&lt;br /&gt;
slicer.modules.plots.logic().ShowChartInLayout(plotChartNode)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Execute external applications ==&lt;br /&gt;
&lt;br /&gt;
How to run external applications from Slicer.&lt;br /&gt;
&lt;br /&gt;
=== Run process in default environment ===&lt;br /&gt;
&lt;br /&gt;
When a process is launched from Slicer then by default Slicer's ITK, VTK, Qt, etc. libraries are used. If an external application has its own version of these libraries, then the application is expected to crash. To prevent crashing, the application must be run in the environment where Slicer started up (without all Slicer-specific library paths). This startup environment can be retrieved using ''slicer.util.startupEnvironment()''.&lt;br /&gt;
&lt;br /&gt;
Example: run Python3 script from Slicer:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
command_to_execute = [&amp;quot;/usr/bin/python3&amp;quot;, &amp;quot;-c&amp;quot;, &amp;quot;print('hola')&amp;quot;]&lt;br /&gt;
from subprocess import check_output&lt;br /&gt;
check_output(&lt;br /&gt;
  command_to_execute, &lt;br /&gt;
  env=slicer.util.startupEnvironment()&lt;br /&gt;
  )&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
will output:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
'hola\n'&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
On some systems, ''shell=True'' must be specified as well.&lt;/div&gt;</summary>
		<author><name>Inorton</name></author>
		
	</entry>
	<entry>
		<id>https://www.slicer.org/w/index.php?title=Documentation/Nightly/Developers/FAQ/Python_Scripting&amp;diff=59410</id>
		<title>Documentation/Nightly/Developers/FAQ/Python Scripting</title>
		<link rel="alternate" type="text/html" href="https://www.slicer.org/w/index.php?title=Documentation/Nightly/Developers/FAQ/Python_Scripting&amp;diff=59410"/>
		<updated>2018-09-12T13:21:27Z</updated>

		<summary type="html">&lt;p&gt;Inorton: /* Enable or disable compression while saving a volume */&lt;/p&gt;
&lt;hr /&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 access a scripted module from python scripts ==&lt;br /&gt;
&lt;br /&gt;
All slicer modules are accessible in the &amp;lt;code&amp;gt;slicer.modules&amp;lt;/code&amp;gt; namespace. For example, ''sampledata'' module can be accessed as &amp;lt;code&amp;gt;slicer.modules.sampledata&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
To access a module's widget, use &amp;lt;code&amp;gt;widgetRepresentation()&amp;lt;/code&amp;gt; method to get the C++ base class and its &amp;lt;code&amp;gt;self()&amp;lt;/code&amp;gt; method to get the Python class. For example, &amp;lt;code&amp;gt;slicer.modules.sampledata.widgetRepresentation().self()&amp;lt;/code&amp;gt; returns the Python widget object of ''sampledata'' module.&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; in your HOME folder. (See [[Documentation/{{documentation/version}}/FAQ/General#What_is_my_HOME_folder_.3F|What is my HOME folder ?]])&lt;br /&gt;
&lt;br /&gt;
Alternatively, set an environment variable named &amp;lt;tt&amp;gt;SLICERRC&amp;lt;/tt&amp;gt; to the full path of a Python file to run at startup.&lt;br /&gt;
&lt;br /&gt;
You can see the path to your &amp;lt;code&amp;gt;.slicerrc.py&amp;lt;/code&amp;gt; file and edit it if you start Slicer and open in the menu: Edit / Application Settings. ''Application startup script'' is in the General section.&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;
=== Enable or disable compression while saving a volume ===&lt;br /&gt;
&lt;br /&gt;
While volumes can be accessed in Slicer Python modules as vtkMRMLVolumeNode, compression preference (or any other property for that matter) should be passed to slicer.util.saveNode function. The property will be passed to Slicer's storage node. For compression set the &amp;lt;code&amp;gt;useCompression&amp;lt;/code&amp;gt; to 0 or 1. Example script:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
properties = {'useCompression': 0}; #do not compress&lt;br /&gt;
file_path = os.path.join(case_dir, file_name)&lt;br /&gt;
slicer.util.saveNode(node, file_path, properties)&lt;br /&gt;
&amp;lt;/pre&amp;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;
== How to get VTK rendering backend ? ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
backend = slicer.app.layoutManager().threeDWidget(0).threeDView().renderWindow().GetRenderingBackend()&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== How to access displayable manager associated with a Slicer 2D or 3D view ? ==&lt;br /&gt;
&lt;br /&gt;
As originally explained [http://slicer-devel.65872.n3.nabble.com/How-to-get-the-point-of-a-3D-model-based-on-the-fiducial-position-td4031760.html#a4031762 here], you could use the method &amp;lt;code&amp;gt;getDisplayableManagers()&amp;lt;/code&amp;gt; available in any [{{doxygen-class-url|qMRMLThreeDView}} qMRMLThreeDView] and [{{doxygen-class-url|qMRMLSliceView}} qMRMLSliceView].&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
lm = slicer.app.layoutManager()&lt;br /&gt;
for v in range(lm.threeDViewCount):&lt;br /&gt;
  td = lm.threeDWidget(v)&lt;br /&gt;
  ms = vtk.vtkCollection()&lt;br /&gt;
  td.getDisplayableManagers(ms)&lt;br /&gt;
  for i in range(ms.GetNumberOfItems()):&lt;br /&gt;
   m = ms.GetItemAsObject(i)&lt;br /&gt;
   if m.GetClassName() == &amp;quot;vtkMRMLModelDisplayableManager&amp;quot;:&lt;br /&gt;
     print(m)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== How to center the 3D view on the scene ? ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
layoutManager = slicer.app.layoutManager()&lt;br /&gt;
threeDWidget = layoutManager.threeDWidget(0)&lt;br /&gt;
threeDView = threeDWidget.threeDView()&lt;br /&gt;
threeDView.resetFocalPoint()&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Should I use '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;br /&gt;
&lt;br /&gt;
== How can I use a visual debugger for step-by-step debugging ==&lt;br /&gt;
&lt;br /&gt;
===Debugging using PyCharm or PyDev===&lt;br /&gt;
Visual debugging (setting breakpoints, execute code step-by-step, view variables, stack, etc.) of Python scripted module is possible by using [https://www.jetbrains.com/pycharm/ PyCharm] or [http://pydev.org/ PyDev] by using the ''Python debugger'' module [[Documentation/{{documentation/version}}/Extensions/DebuggingTools|Debugging tools]] extension.&lt;br /&gt;
&lt;br /&gt;
'''See detailed instructions at the [[Documentation/{{documentation/version}}/Extensions/DebuggingTools|Debugging tools extension page]].'''&lt;br /&gt;
[[File:PyDevRemoteDebugSlicer.png|800px|thumb|center|Visual debugging of Python modules in Slicer]]&lt;br /&gt;
&lt;br /&gt;
===Debugging using Visual Studio===&lt;br /&gt;
On Windows, [https://github.com/Microsoft/PTVS Python Tools for Visual Studio] (PTVS) enables debugging Python inside Visual Studio. Its remote debugging capability allows attaching the debugger to Slicer's embedded Python environment.&lt;br /&gt;
&lt;br /&gt;
See [[Documentation/{{documentation/version}}/Developers/Tutorials/Debugging_Python_in_Visual_Studio | Debugging Python in Visual Studio]] for details.&lt;br /&gt;
&lt;br /&gt;
===Debugging using remote-pdb===&lt;br /&gt;
&lt;br /&gt;
A command line debugging session with a [https://docs.python.org/3/library/pdb.html pdb] interface can be achieved with [https://github.com/ionelmc/python-remote-pdb python-remote-pdb].&lt;br /&gt;
&lt;br /&gt;
Install python-remote-pdb into Slicer's Python:&lt;br /&gt;
&lt;br /&gt;
  git clone https://github.com/ionelmc/python-remote-pdb.git&lt;br /&gt;
  cd python-remote-pdb&lt;br /&gt;
  /path/to/Slicer-build/Slicer-build/Slicer ./setup.py install&lt;br /&gt;
&lt;br /&gt;
Then, call ''set_trace()'' where you want to start the debugger.&lt;br /&gt;
&lt;br /&gt;
  from remote_pdb import set_trace; set_trace()&lt;br /&gt;
&lt;br /&gt;
In the console where Slicer was started, a message like the following will be printed:&lt;br /&gt;
&lt;br /&gt;
  RemotePdb session open at 127.0.0.1:1234, waiting for connection&lt;br /&gt;
&lt;br /&gt;
In another terminal, connect with telnet:&lt;br /&gt;
&lt;br /&gt;
  telnet 127.0.0.1 1234&lt;br /&gt;
&lt;br /&gt;
or socat (has history, readline support):&lt;br /&gt;
&lt;br /&gt;
  socat readline tcp:127.0.0.1:1234&lt;br /&gt;
&lt;br /&gt;
== Why can't I access my C++ Qt class from python ==&lt;br /&gt;
* Python wrapping of a Qt class requires a Qt style constructor with QObject as argument (it can be defaulted to null though), which is public. If one of these are missing, python wrapping will fail for that class&lt;br /&gt;
* You cannot access your custom C++ Qt classes from python outside of the scope of your instantiated python class. These will not work:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
BarIDRole = slicer.qFooItemDelegate.LastRole + 1&lt;br /&gt;
&lt;br /&gt;
class BarTableWidget(qt.QTableWidget, VTKObservationMixin):&lt;br /&gt;
&lt;br /&gt;
    def __init__(self, *args, **kwargs):&lt;br /&gt;
        [...]&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
class BarTableWidget(qt.QTableWidget, VTKObservationMixin):&lt;br /&gt;
&lt;br /&gt;
    BarIDRole = slicer.qFooItemDelegate.LastRole + 1&lt;br /&gt;
&lt;br /&gt;
    def __init__(self, *args, **kwargs):&lt;br /&gt;
        [...]&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Instead, do:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
class BarTableWidget(qt.QTableWidget, VTKObservationMixin):&lt;br /&gt;
&lt;br /&gt;
    def __init__(self, *args, **kwargs):&lt;br /&gt;
        self.BarIDRole = slicer.qFooItemDelegate.LastRole + 1&lt;br /&gt;
        [...]&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* [Other reasons go here]&lt;br /&gt;
&lt;br /&gt;
== Can I use factory method like CreateNodeByClass or GetNodesByClass ? ==&lt;br /&gt;
&lt;br /&gt;
See [[Documentation/{{documentation/version}}/Developers/Tutorials/MemoryManagement#Factory_methods]]&lt;br /&gt;
&lt;br /&gt;
== How can I access callData argument in a VTK object observer callback function ==&lt;br /&gt;
&lt;br /&gt;
To get notification about an event emitted by a VTK object you can simply use the AddObserver method, for example:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
def sceneModifiedCallback(caller, eventId):&lt;br /&gt;
  print(&amp;quot;Scene modified&amp;quot;)&lt;br /&gt;
  print(&amp;quot;There are {0} nodes in the scene&amp;quot;. format(slicer.mrmlScene.GetNumberOfNodes()))&lt;br /&gt;
&lt;br /&gt;
sceneModifiedObserverTag = slicer.mrmlScene.AddObserver(vtk.vtkCommand.ModifiedEvent, sceneModifiedCallback)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If an event also contains additional information as CallData then the type of this argument has to be specified as well, for example:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
@vtk.calldata_type(vtk.VTK_OBJECT)&lt;br /&gt;
def nodeAddedCallback(caller, eventId, callData):&lt;br /&gt;
  print(&amp;quot;Node added&amp;quot;)&lt;br /&gt;
  print(&amp;quot;New node: {0}&amp;quot;.format(callData.GetName()))&lt;br /&gt;
&lt;br /&gt;
nodeAddedModifiedObserverTag = slicer.mrmlScene.AddObserver(slicer.vtkMRMLScene.NodeAddedEvent, nodeAddedCallback)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note: @vtk.calldata_type is a Python decorator, which modifies properties of a function that is declared right after the decorator. The decorator is defined in VTK (in Wrapping\Python\vtk\util\misc.py).&lt;br /&gt;
&lt;br /&gt;
Usage from a class requires an extra step of creating the callback in the class __init__ function, as Python2 by default does some extra wrapping (http://stackoverflow.com/questions/9523370/adding-attributes-to-instance-methods-in-python):&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
class MyClass:&lt;br /&gt;
  def __init__(self):&lt;br /&gt;
    from functools import partial&lt;br /&gt;
    def nodeAddedCallback(self, caller, eventId, callData):&lt;br /&gt;
      print(&amp;quot;Node added&amp;quot;)&lt;br /&gt;
      print(&amp;quot;New node: {0}&amp;quot;.format(callData.GetName()))&lt;br /&gt;
    self.nodeAddedCallback = partial(nodeAddedCallback, self)&lt;br /&gt;
    self.nodeAddedCallback.CallDataType = vtk.VTK_OBJECT&lt;br /&gt;
  def registerCallbacks(self):&lt;br /&gt;
    self.nodeAddedModifiedObserverTag = slicer.mrmlScene.AddObserver(slicer.vtkMRMLScene.NodeAddedEvent, self.nodeAddedCallback)&lt;br /&gt;
  def unregisterCallbacks(self):&lt;br /&gt;
    slicer.mrmlScene.RemoveObserver(self.nodeAddedModifiedObserverTag)&lt;br /&gt;
        &lt;br /&gt;
myObject = MyClass()&lt;br /&gt;
myObject.registerCallbacks()&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Allowed CallDataType values:  VTK_STRING, VTK_OBJECT, VTK_INT, VTK_LONG, VTK_DOUBLE, VTK_FLOAT, &amp;quot;string0&amp;quot;. See more information here:&lt;br /&gt;
https://github.com/Kitware/VTK/blob/master/Wrapping/PythonCore/vtkPythonCommand.cxx&lt;br /&gt;
&lt;br /&gt;
A simplified syntax is available by using a mix-in:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
from slicer.util import VTKObservationMixin&lt;br /&gt;
&lt;br /&gt;
class MyClass(VTKObservationMixin):&lt;br /&gt;
  def __init__(self):&lt;br /&gt;
    VTKObservationMixin.__init__(self)&lt;br /&gt;
    self.addObserver(slicer.mrmlScene, slicer.vtkMRMLScene.NodeAddedEvent, self.nodeAddedCallback)&lt;br /&gt;
  &lt;br /&gt;
  @vtk.calldata_type(vtk.VTK_OBJECT)&lt;br /&gt;
  def nodeAddedCallback(self, caller, eventId, callData):&lt;br /&gt;
    print(&amp;quot;Node added&amp;quot;)&lt;br /&gt;
    print(&amp;quot;New node: {0}&amp;quot;.format(callData.GetName()))&lt;br /&gt;
&lt;br /&gt;
myObject = MyClass()&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note: VTKObservationMixin is a Python mix-in that allows adding a set of methods to a class by inheritance. VTKObservationMixin includes addObserver, hasObserver, observer, removeObserver, removeObservers methods, defined in Slicer (in Base\Python\slicer\util.py). For example of usage, see [https://github.com/Slicer/Slicer/blob/master/Base/Python/slicer/tests/test_slicer_util_VTKObservationMixin.py test_slicer_util_VTKObservationMixin.py]&lt;br /&gt;
&lt;br /&gt;
== Slicer crashes if I try to access a non-existing item in an array ==&lt;br /&gt;
&lt;br /&gt;
For example, this code makes Slicer crash:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
s = vtk.vtkStringArray()&lt;br /&gt;
s.GetValue(0)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This behavior is expected, as all VTK objects are implemented in C++ that offers much faster operation but developers have to take care of addressing only valid array elements, for example by checking the number of elements in the array:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
if itemIndex &amp;lt; 0 or itemIndex &amp;gt;= s.GetNumberOfValues()&lt;br /&gt;
  raise IndexError(&amp;quot;index out of bounds&amp;quot;)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== How to run CLI module from Python? ==&lt;br /&gt;
&lt;br /&gt;
See [[Documentation/{{documentation/version}}/Developers/Python_scripting#Running_a_CLI_from_Python|here]].&lt;br /&gt;
&lt;br /&gt;
== How can I run slicer operations from a batch script? ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Slicer --no-main-window --python-script /tmp/test.py&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Contents of /tmp/test.py&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# use a slicer scripted module logic&lt;br /&gt;
from SampleData import SampleDataLogic&lt;br /&gt;
SampleDataLogic().downloadMRHead()&lt;br /&gt;
head = slicer.util.getNode('MRHead')&lt;br /&gt;
&lt;br /&gt;
# use a vtk class&lt;br /&gt;
threshold = vtk.vtkImageThreshold()&lt;br /&gt;
threshold.SetInputData(head.GetImageData())&lt;br /&gt;
threshold.ThresholdBetween(100, 200)&lt;br /&gt;
threshold.SetInValue(255)&lt;br /&gt;
threshold.SetOutValue(0)&lt;br /&gt;
&lt;br /&gt;
#  use a slicer-specific C++ class&lt;br /&gt;
erode = slicer.vtkImageErode()&lt;br /&gt;
erode.SetInputConnection(threshold.GetOutputPort())&lt;br /&gt;
erode.SetNeighborTo4()  &lt;br /&gt;
erode.Update()          &lt;br /&gt;
&lt;br /&gt;
head.SetAndObserveImageData(erode.GetOutputDataObject(0))&lt;br /&gt;
&lt;br /&gt;
slicer.util.saveNode(head, &amp;quot;/tmp/eroded.nrrd&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
exit()&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== How can I run Slicer on a headless compute node? ==&lt;br /&gt;
&lt;br /&gt;
Many cluster nodes are installed with minimal linux systems that don't include X servers.  X servers, particularly those with hardware acceleration traditionally needed to be installed with root privileges, making it impossible to run applications that rendered using X or OpenGL.&lt;br /&gt;
&lt;br /&gt;
But there is a workaround which allows everything in slicer to work normally so you could even do headless rendering.&lt;br /&gt;
&lt;br /&gt;
You can use a modern version of X that supports running a dummy framebuffer.  This can be installed in user mode so you don't even need to have root on the system.&lt;br /&gt;
&lt;br /&gt;
See [https://www.xpra.org/trac/wiki/Xdummy] for details.&lt;br /&gt;
&lt;br /&gt;
There's a thread here with more discussion: [http://massmail.spl.harvard.edu/public-archives/slicer-devel/2015/017317.html]&lt;br /&gt;
&lt;br /&gt;
Here is a working example of the approach running on a headless compute node running CTK tests (which also use Qt and VTK)&lt;br /&gt;
&lt;br /&gt;
[https://github.com/pieper/CTK/blob/master/.travis.yml]&lt;br /&gt;
&lt;br /&gt;
== How to save user's selection of parameters and nodes in the scene? ==&lt;br /&gt;
&lt;br /&gt;
It is preferable to save all the parameter values and nodes selections that the user made on the user interface into the MRML scene. This allows the user to load a scene and continue from where he left off. These information can be saved in a ''slicer.vtkMRMLScriptedModuleNode()'' node.&lt;br /&gt;
&lt;br /&gt;
For example:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
parameterNode=slicer.vtkMRMLScriptedModuleNode()&lt;br /&gt;
&lt;br /&gt;
# Save parameter values and node references to parameter node&lt;br /&gt;
&lt;br /&gt;
alpha = 5.0&lt;br /&gt;
beta = &amp;quot;abc&amp;quot;&lt;br /&gt;
inputNode = slicer.util.getNode(&amp;quot;InputNode&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
parameterNode.SetParameter(&amp;quot;Alpha&amp;quot;,str(alpha))&lt;br /&gt;
parameterNode.SetParameter(&amp;quot;Beta&amp;quot;, beta)&lt;br /&gt;
parameterNode.SetNodeReferenceID(&amp;quot;InputNode&amp;quot;, inputNode.GetID())&lt;br /&gt;
&lt;br /&gt;
# Retrieve parameter values and node references from parameter node&lt;br /&gt;
&lt;br /&gt;
alpha = float(parameterNode.GetParameter(&amp;quot;Alpha&amp;quot;))&lt;br /&gt;
beta = parameterNode.GetParameter(&amp;quot;Beta&amp;quot;)&lt;br /&gt;
inputNode = parameterNode.GetNodeReference(&amp;quot;InputNode&amp;quot;)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Scripted module's logic class have a helper function, ''getParameterNode'', which returns a parameter node that is unique for a specific module. The function creates the parameter node if it has not been created yet. By default, the parameter node is a singleton node, which means that there is only a single instance of the node in the scene. If it is preferable to allow multiple instances of the parameter node, set ''isSingletonParameterNode'' member of the logic object to ''False''.&lt;br /&gt;
&lt;br /&gt;
== How to load a UI file ? ==&lt;br /&gt;
&lt;br /&gt;
See [[Documentation/Nightly/Developers/Tutorials/PythonAndUIFile]]&lt;br /&gt;
&lt;br /&gt;
== How to update progress bar in scripted (Python, or other) CLI modules ==&lt;br /&gt;
&lt;br /&gt;
As detailed in the [https://www.slicer.org/wiki/Documentation/Nightly/Developers/SlicerExecutionModel#Showing_Progress_in_an_Application|Slicer Execution Model documentation], Slicer parses specifically-formatted XML commands printed on stdout, to allow any out-of-process CLI program to report progress back to the main Slicer application (which will causing the progress bar to update). However, it is very important to note that the output must be flushed after each print statement, or else Slicer will not parse the progress sections until the process ends. See the calls to &amp;lt;pre&amp;gt;sys.stdout.flush()&amp;lt;/pre&amp;gt; in the example Python CLI shown below:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#!/usr/bin/env python-real&lt;br /&gt;
&lt;br /&gt;
if __name__ == '__main__':&lt;br /&gt;
  import time&lt;br /&gt;
  import sys&lt;br /&gt;
  &lt;br /&gt;
  print(&amp;quot;&amp;quot;&amp;quot;&amp;lt;filter-start&amp;gt;&amp;lt;filter-name&amp;gt;TestFilter&amp;lt;/filter-name&amp;gt;&amp;lt;filter-comment&amp;gt;ibid&amp;lt;/filter-comment&amp;gt;&amp;lt;/filter-start&amp;gt;&amp;quot;&amp;quot;&amp;quot;)&lt;br /&gt;
  sys.stdout.flush()&lt;br /&gt;
&lt;br /&gt;
  for i in range(0,10):&lt;br /&gt;
      print(&amp;quot;&amp;quot;&amp;quot;&amp;lt;filter-progress&amp;gt;{}&amp;lt;/filter-progress&amp;gt;&amp;quot;&amp;quot;&amp;quot;.format(i/10.0))&lt;br /&gt;
      sys.stdout.flush()&lt;br /&gt;
      time.sleep(0.5)&lt;br /&gt;
&lt;br /&gt;
  print(&amp;quot;&amp;quot;&amp;quot;&amp;lt;filter-end&amp;gt;&amp;lt;filter-name&amp;gt;TestFilter&amp;lt;/filter-name&amp;gt;&amp;lt;filter-time&amp;gt;10&amp;lt;/filter-time&amp;gt;&amp;lt;/filter-end&amp;gt;&amp;quot;&amp;quot;&amp;quot;)&lt;br /&gt;
  sys.stdout.flush()&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>Inorton</name></author>
		
	</entry>
	<entry>
		<id>https://www.slicer.org/w/index.php?title=Documentation/Nightly/Developers/Python_scripting&amp;diff=59409</id>
		<title>Documentation/Nightly/Developers/Python scripting</title>
		<link rel="alternate" type="text/html" href="https://www.slicer.org/w/index.php?title=Documentation/Nightly/Developers/Python_scripting&amp;diff=59409"/>
		<updated>2018-09-12T13:20:33Z</updated>

		<summary type="html">&lt;p&gt;Inorton: /* Script Repository */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;noinclude&amp;gt;{{documentation/versioncheck}}&amp;lt;/noinclude&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Start Here =&lt;br /&gt;
&lt;br /&gt;
Please read [https://docs.google.com/presentation/d/1JXIfs0rAM7DwZAho57Jqz14MRn2BIMrjB17Uj_7Yztc/edit?usp=sharing these slides] and work through the example code.&lt;br /&gt;
&lt;br /&gt;
Refer to [http://www.na-mic.org/Wiki/index.php/2013_Project_Week_Breakout_Session:Slicer4Python this description that includes links to all the documentation].&lt;br /&gt;
&lt;br /&gt;
&lt;br /&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 [[Documentation/{{documentation/currentversion}}/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;
= Start Here for Scripted Module and Extension Development=&lt;br /&gt;
An extensive tutorial and reference page was created [http://www.na-mic.org/Wiki/index.php/2013_Project_Week_Breakout_Session:Slicer4Python for the Slicer/Python breakout session at the NA-MIC 2013 Summer Project Week].&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-3 on window/linux, Command-3 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 Slicer and bring up python console.  Load a sample volume like this:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
import SampleData&lt;br /&gt;
sampleDataLogic = SampleData.SampleDataLogic()&lt;br /&gt;
sampleDataLogic.downloadMRHead()&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;
n = getNode('MRHead')&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;
==== Accessing Volume data as numpy array ====&lt;br /&gt;
&lt;br /&gt;
You can easily inspect and manipulate volume data using numpy and related code.  In slicer you can do this:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
a = array('MRHead')&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
and 'a' will be a pointer to the appropriate data (no data copying). If you get an error that 'array' is not defined then run 'import slicer.util' and use 'slicer.util.array'. Scalar volumes become three-dimensional arrays, while vector volumes become 4D, and tensor volumes are 5D.  All arrays can be manipulated directly. After modification is completed, call Modified() method of the volume node to indicate that the image is modified and trigger display update.&lt;br /&gt;
&lt;br /&gt;
The '''array''' method is intended for quick testing only, as multiple nodes may have the same name and various arrays may be retrieved from MRML nodes. In Slicer modules, it is recommended to use '''arrayFromVolume''' instead, which takes a MRML node as input.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
volumeNode = getNode('MRHead')&lt;br /&gt;
a = arrayFromVolume(volumeNode)&lt;br /&gt;
# Increase image contrast&lt;br /&gt;
a[:] = a * 2.0&lt;br /&gt;
arrayFromVolumeModified(volumeNode)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you don't process the data in-place but you have computation results in a numpy array, then you have to copy the contents of a numpy array into a volume, using '''updateVolumeFromArray''':&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
import numpy as np&lt;br /&gt;
import math&lt;br /&gt;
&lt;br /&gt;
def some_func(x, y, z):&lt;br /&gt;
  return 0.5*x*x + 0.3*y*y + 0.5*z*z&lt;br /&gt;
&lt;br /&gt;
a = np.fromfunction(some_func,(30,20,15))&lt;br /&gt;
&lt;br /&gt;
volumeNode = slicer.mrmlScene.AddNewNodeByClass('vtkMRMLScalarVolumeNode')&lt;br /&gt;
volumeNode.CreateDefaultDisplayNodes()&lt;br /&gt;
updateVolumeFromArray(volumeNode, a)&lt;br /&gt;
setSliceViewerLayers(background=volumeNode)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Accessing Model data as numpy array ====&lt;br /&gt;
&lt;br /&gt;
You can easily inspect and manipulate point coordinates of a model using numpy and related code by calling `arrayFromModelPoints`. After modification is completed, call Modified() method on the polydata to indicate that the model is modified and trigger display update.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Create a model containing a sphere&lt;br /&gt;
sphere = vtk.vtkSphereSource()&lt;br /&gt;
sphere.SetRadius(30.0)&lt;br /&gt;
sphere.Update()&lt;br /&gt;
modelNode = slicer.mrmlScene.AddNewNodeByClass('vtkMRMLModelNode')&lt;br /&gt;
modelNode.SetAndObservePolyData(sphere.GetOutput())&lt;br /&gt;
modelNode.CreateDefaultDisplayNodes()&lt;br /&gt;
a = arrayFromModelPoints(modelNode)&lt;br /&gt;
# change Y scaling&lt;br /&gt;
a[:,2] = a[:,2] * 2.5&lt;br /&gt;
arrayFromModelPointsModified(modelNode)&lt;br /&gt;
&amp;lt;/pre&amp;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.runSync(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;
Here is an example for running a CLI module from a scripted module:&lt;br /&gt;
https://github.com/fedorov/ChangeTrackerPy/blob/master/ChangeTracker/ChangeTrackerWizard/ChangeTrackerRegistrationStep.py#L56-L67&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.runSync(slicer.modules.simpleregiongrowingsegmentation, None, params)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
''Running CLI in the background''&lt;br /&gt;
&lt;br /&gt;
If the CLI module is executed using slicer.cli.run method then the CLI module runs in a background thread, so the call to grayModel will return right away and the user interface will not be blocked. 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;
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;
If you need to cancel the CLI, call&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cliNode.Cance()&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To get the log info for the process you can call &amp;lt;pre&amp;gt;cliNode.GetOutputText()&amp;lt;/pre&amp;gt; and &amp;lt;pre&amp;gt;cliNode.GetErrorText()&amp;lt;/pre&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
''Get list of parameter names''&lt;br /&gt;
&lt;br /&gt;
The following script prints all the parameter names of a CLI parameter node:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cliModule = slicer.modules.grayscalemodelmaker&lt;br /&gt;
n=cliModule.cliModuleLogic().CreateNode()&lt;br /&gt;
for groupIndex in xrange(0,n.GetNumberOfParameterGroups()):&lt;br /&gt;
  for parameterIndex in xrange(0,n.GetNumberOfParametersInGroup(groupIndex)):&lt;br /&gt;
    print '  Parameter ({0}/{1}): {2} ({3})'.format(groupIndex, parameterIndex, n.GetParameterName(groupIndex, parameterIndex), n.GetParameterLabel(groupIndex, parameterIndex))&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;
= Script Repository = &lt;br /&gt;
&lt;br /&gt;
See [[Documentation/Nightly/ScriptRepository|ScriptRepository]] for a larger collection of example code.&lt;br /&gt;
&lt;br /&gt;
{{:Documentation/{{documentation/version}}/Developers/FAQ/Python Scripting|Python Scripting}}&lt;/div&gt;</summary>
		<author><name>Inorton</name></author>
		
	</entry>
	<entry>
		<id>https://www.slicer.org/w/index.php?title=Documentation/Nightly/Developers/FAQ/Python_Scripting&amp;diff=59278</id>
		<title>Documentation/Nightly/Developers/FAQ/Python Scripting</title>
		<link rel="alternate" type="text/html" href="https://www.slicer.org/w/index.php?title=Documentation/Nightly/Developers/FAQ/Python_Scripting&amp;diff=59278"/>
		<updated>2018-08-15T20:48:20Z</updated>

		<summary type="html">&lt;p&gt;Inorton: /* How to update progress bar in scripted (Python, or other) CLI modules */&lt;/p&gt;
&lt;hr /&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 access a scripted module from python scripts ==&lt;br /&gt;
&lt;br /&gt;
All slicer modules are accessible in the &amp;lt;code&amp;gt;slicer.modules&amp;lt;/code&amp;gt; namespace. For example, ''sampledata'' module can be accessed as &amp;lt;code&amp;gt;slicer.modules.sampledata&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
To access a module's widget, use &amp;lt;code&amp;gt;widgetRepresentation()&amp;lt;/code&amp;gt; method to get the C++ base class and its &amp;lt;code&amp;gt;self()&amp;lt;/code&amp;gt; method to get the Python class. For example, &amp;lt;code&amp;gt;slicer.modules.sampledata.widgetRepresentation().self()&amp;lt;/code&amp;gt; returns the Python widget object of ''sampledata'' module.&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; in your HOME folder. (See [[Documentation/{{documentation/version}}/FAQ/General#What_is_my_HOME_folder_.3F|What is my HOME folder ?]])&lt;br /&gt;
&lt;br /&gt;
Alternatively, set an environment variable named &amp;lt;tt&amp;gt;SLICERRC&amp;lt;/tt&amp;gt; to the full path of a Python file to run at startup.&lt;br /&gt;
&lt;br /&gt;
You can see the path to your &amp;lt;code&amp;gt;.slicerrc.py&amp;lt;/code&amp;gt; file and edit it if you start Slicer and open in the menu: Edit / Application Settings. ''Application startup script'' is in the General section.&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;
=== Enable or disable compression while saving a volume ===&lt;br /&gt;
&lt;br /&gt;
While volumes can be accessed in Slicer Python modules as vtkMRMLVolumeNode, compression preference (or any other property for that matter) should be passed to slicer.util.saveNode function. The property will be passed to Slicer's storage node. For compression set the &amp;lt;code&amp;gt;useCompression&amp;lt;/code&amp;gt; to 0 or 1. Example script:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
properties['useCompression'] = 0; #do not compress&lt;br /&gt;
file_path = os.path.join(case_dir, file_name)&lt;br /&gt;
slicer.util.saveNode(node, file_path, properties)&lt;br /&gt;
&amp;lt;/pre&amp;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;
== How to get VTK rendering backend ? ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
backend = slicer.app.layoutManager().threeDWidget(0).threeDView().renderWindow().GetRenderingBackend()&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== How to access displayable manager associated with a Slicer 2D or 3D view ? ==&lt;br /&gt;
&lt;br /&gt;
As originally explained [http://slicer-devel.65872.n3.nabble.com/How-to-get-the-point-of-a-3D-model-based-on-the-fiducial-position-td4031760.html#a4031762 here], you could use the method &amp;lt;code&amp;gt;getDisplayableManagers()&amp;lt;/code&amp;gt; available in any [{{doxygen-class-url|qMRMLThreeDView}} qMRMLThreeDView] and [{{doxygen-class-url|qMRMLSliceView}} qMRMLSliceView].&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
lm = slicer.app.layoutManager()&lt;br /&gt;
for v in range(lm.threeDViewCount):&lt;br /&gt;
  td = lm.threeDWidget(v)&lt;br /&gt;
  ms = vtk.vtkCollection()&lt;br /&gt;
  td.getDisplayableManagers(ms)&lt;br /&gt;
  for i in range(ms.GetNumberOfItems()):&lt;br /&gt;
   m = ms.GetItemAsObject(i)&lt;br /&gt;
   if m.GetClassName() == &amp;quot;vtkMRMLModelDisplayableManager&amp;quot;:&lt;br /&gt;
     print(m)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== How to center the 3D view on the scene ? ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
layoutManager = slicer.app.layoutManager()&lt;br /&gt;
threeDWidget = layoutManager.threeDWidget(0)&lt;br /&gt;
threeDView = threeDWidget.threeDView()&lt;br /&gt;
threeDView.resetFocalPoint()&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Should I use '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;br /&gt;
&lt;br /&gt;
== How can I use a visual debugger for step-by-step debugging ==&lt;br /&gt;
&lt;br /&gt;
===Debugging using PyCharm or PyDev===&lt;br /&gt;
Visual debugging (setting breakpoints, execute code step-by-step, view variables, stack, etc.) of Python scripted module is possible by using [https://www.jetbrains.com/pycharm/ PyCharm] or [http://pydev.org/ PyDev] by using the ''Python debugger'' module [[Documentation/{{documentation/version}}/Extensions/DebuggingTools|Debugging tools]] extension.&lt;br /&gt;
&lt;br /&gt;
'''See detailed instructions at the [[Documentation/{{documentation/version}}/Extensions/DebuggingTools|Debugging tools extension page]].'''&lt;br /&gt;
[[File:PyDevRemoteDebugSlicer.png|800px|thumb|center|Visual debugging of Python modules in Slicer]]&lt;br /&gt;
&lt;br /&gt;
===Debugging using Visual Studio===&lt;br /&gt;
On Windows, [https://github.com/Microsoft/PTVS Python Tools for Visual Studio] (PTVS) enables debugging Python inside Visual Studio. Its remote debugging capability allows attaching the debugger to Slicer's embedded Python environment.&lt;br /&gt;
&lt;br /&gt;
See [[Documentation/{{documentation/version}}/Developers/Tutorials/Debugging_Python_in_Visual_Studio | Debugging Python in Visual Studio]] for details.&lt;br /&gt;
&lt;br /&gt;
===Debugging using remote-pdb===&lt;br /&gt;
&lt;br /&gt;
A command line debugging session with a [https://docs.python.org/3/library/pdb.html pdb] interface can be achieved with [https://github.com/ionelmc/python-remote-pdb python-remote-pdb].&lt;br /&gt;
&lt;br /&gt;
Install python-remote-pdb into Slicer's Python:&lt;br /&gt;
&lt;br /&gt;
  git clone https://github.com/ionelmc/python-remote-pdb.git&lt;br /&gt;
  cd python-remote-pdb&lt;br /&gt;
  /path/to/Slicer-build/Slicer-build/Slicer ./setup.py install&lt;br /&gt;
&lt;br /&gt;
Then, call ''set_trace()'' where you want to start the debugger.&lt;br /&gt;
&lt;br /&gt;
  from remote_pdb import set_trace; set_trace()&lt;br /&gt;
&lt;br /&gt;
In the console where Slicer was started, a message like the following will be printed:&lt;br /&gt;
&lt;br /&gt;
  RemotePdb session open at 127.0.0.1:1234, waiting for connection&lt;br /&gt;
&lt;br /&gt;
In another terminal, connect with telnet:&lt;br /&gt;
&lt;br /&gt;
  telnet 127.0.0.1 1234&lt;br /&gt;
&lt;br /&gt;
or socat (has history, readline support):&lt;br /&gt;
&lt;br /&gt;
  socat readline tcp:127.0.0.1:1234&lt;br /&gt;
&lt;br /&gt;
== Why can't I access my C++ Qt class from python ==&lt;br /&gt;
* Python wrapping of a Qt class requires a Qt style constructor with QObject as argument (it can be defaulted to null though), which is public. If one of these are missing, python wrapping will fail for that class&lt;br /&gt;
* You cannot access your custom C++ Qt classes from python outside of the scope of your instantiated python class. These will not work:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
BarIDRole = slicer.qFooItemDelegate.LastRole + 1&lt;br /&gt;
&lt;br /&gt;
class BarTableWidget(qt.QTableWidget, VTKObservationMixin):&lt;br /&gt;
&lt;br /&gt;
    def __init__(self, *args, **kwargs):&lt;br /&gt;
        [...]&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
class BarTableWidget(qt.QTableWidget, VTKObservationMixin):&lt;br /&gt;
&lt;br /&gt;
    BarIDRole = slicer.qFooItemDelegate.LastRole + 1&lt;br /&gt;
&lt;br /&gt;
    def __init__(self, *args, **kwargs):&lt;br /&gt;
        [...]&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Instead, do:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
class BarTableWidget(qt.QTableWidget, VTKObservationMixin):&lt;br /&gt;
&lt;br /&gt;
    def __init__(self, *args, **kwargs):&lt;br /&gt;
        self.BarIDRole = slicer.qFooItemDelegate.LastRole + 1&lt;br /&gt;
        [...]&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* [Other reasons go here]&lt;br /&gt;
&lt;br /&gt;
== Can I use factory method like CreateNodeByClass or GetNodesByClass ? ==&lt;br /&gt;
&lt;br /&gt;
See [[Documentation/{{documentation/version}}/Developers/Tutorials/MemoryManagement#Factory_methods]]&lt;br /&gt;
&lt;br /&gt;
== How can I access callData argument in a VTK object observer callback function ==&lt;br /&gt;
&lt;br /&gt;
To get notification about an event emitted by a VTK object you can simply use the AddObserver method, for example:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
def sceneModifiedCallback(caller, eventId):&lt;br /&gt;
  print(&amp;quot;Scene modified&amp;quot;)&lt;br /&gt;
  print(&amp;quot;There are {0} nodes in the scene&amp;quot;. format(slicer.mrmlScene.GetNumberOfNodes()))&lt;br /&gt;
&lt;br /&gt;
sceneModifiedObserverTag = slicer.mrmlScene.AddObserver(vtk.vtkCommand.ModifiedEvent, sceneModifiedCallback)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If an event also contains additional information as CallData then the type of this argument has to be specified as well, for example:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
@vtk.calldata_type(vtk.VTK_OBJECT)&lt;br /&gt;
def nodeAddedCallback(caller, eventId, callData):&lt;br /&gt;
  print(&amp;quot;Node added&amp;quot;)&lt;br /&gt;
  print(&amp;quot;New node: {0}&amp;quot;.format(callData.GetName()))&lt;br /&gt;
&lt;br /&gt;
nodeAddedModifiedObserverTag = slicer.mrmlScene.AddObserver(slicer.vtkMRMLScene.NodeAddedEvent, nodeAddedCallback)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note: @vtk.calldata_type is a Python decorator, which modifies properties of a function that is declared right after the decorator. The decorator is defined in VTK (in Wrapping\Python\vtk\util\misc.py).&lt;br /&gt;
&lt;br /&gt;
Usage from a class requires an extra step of creating the callback in the class __init__ function, as Python2 by default does some extra wrapping (http://stackoverflow.com/questions/9523370/adding-attributes-to-instance-methods-in-python):&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
class MyClass:&lt;br /&gt;
  def __init__(self):&lt;br /&gt;
    from functools import partial&lt;br /&gt;
    def nodeAddedCallback(self, caller, eventId, callData):&lt;br /&gt;
      print(&amp;quot;Node added&amp;quot;)&lt;br /&gt;
      print(&amp;quot;New node: {0}&amp;quot;.format(callData.GetName()))&lt;br /&gt;
    self.nodeAddedCallback = partial(nodeAddedCallback, self)&lt;br /&gt;
    self.nodeAddedCallback.CallDataType = vtk.VTK_OBJECT&lt;br /&gt;
  def registerCallbacks(self):&lt;br /&gt;
    self.nodeAddedModifiedObserverTag = slicer.mrmlScene.AddObserver(slicer.vtkMRMLScene.NodeAddedEvent, self.nodeAddedCallback)&lt;br /&gt;
  def unregisterCallbacks(self):&lt;br /&gt;
    slicer.mrmlScene.RemoveObserver(self.nodeAddedModifiedObserverTag)&lt;br /&gt;
        &lt;br /&gt;
myObject = MyClass()&lt;br /&gt;
myObject.registerCallbacks()&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Allowed CallDataType values:  VTK_STRING, VTK_OBJECT, VTK_INT, VTK_LONG, VTK_DOUBLE, VTK_FLOAT, &amp;quot;string0&amp;quot;. See more information here:&lt;br /&gt;
https://github.com/Kitware/VTK/blob/master/Wrapping/PythonCore/vtkPythonCommand.cxx&lt;br /&gt;
&lt;br /&gt;
A simplified syntax is available by using a mix-in:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
from slicer.util import VTKObservationMixin&lt;br /&gt;
&lt;br /&gt;
class MyClass(VTKObservationMixin):&lt;br /&gt;
  def __init__(self):&lt;br /&gt;
    VTKObservationMixin.__init__(self)&lt;br /&gt;
    self.addObserver(slicer.mrmlScene, slicer.vtkMRMLScene.NodeAddedEvent, self.nodeAddedCallback)&lt;br /&gt;
  &lt;br /&gt;
  @vtk.calldata_type(vtk.VTK_OBJECT)&lt;br /&gt;
  def nodeAddedCallback(self, caller, eventId, callData):&lt;br /&gt;
    print(&amp;quot;Node added&amp;quot;)&lt;br /&gt;
    print(&amp;quot;New node: {0}&amp;quot;.format(callData.GetName()))&lt;br /&gt;
&lt;br /&gt;
myObject = MyClass()&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note: VTKObservationMixin is a Python mix-in that allows adding a set of methods to a class by inheritance. VTKObservationMixin includes addObserver, hasObserver, observer, removeObserver, removeObservers methods, defined in Slicer (in Base\Python\slicer\util.py). For example of usage, see [https://github.com/Slicer/Slicer/blob/master/Base/Python/slicer/tests/test_slicer_util_VTKObservationMixin.py test_slicer_util_VTKObservationMixin.py]&lt;br /&gt;
&lt;br /&gt;
== Slicer crashes if I try to access a non-existing item in an array ==&lt;br /&gt;
&lt;br /&gt;
For example, this code makes Slicer crash:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
s = vtk.vtkStringArray()&lt;br /&gt;
s.GetValue(0)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This behavior is expected, as all VTK objects are implemented in C++ that offers much faster operation but developers have to take care of addressing only valid array elements, for example by checking the number of elements in the array:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
if itemIndex &amp;lt; 0 or itemIndex &amp;gt;= s.GetNumberOfValues()&lt;br /&gt;
  raise IndexError(&amp;quot;index out of bounds&amp;quot;)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== How to run CLI module from Python? ==&lt;br /&gt;
&lt;br /&gt;
See [[Documentation/{{documentation/version}}/Developers/Python_scripting#Running_a_CLI_from_Python|here]].&lt;br /&gt;
&lt;br /&gt;
== How can I run slicer operations from a batch script? ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Slicer --no-main-window --python-script /tmp/test.py&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Contents of /tmp/test.py&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# use a slicer scripted module logic&lt;br /&gt;
from SampleData import SampleDataLogic&lt;br /&gt;
SampleDataLogic().downloadMRHead()&lt;br /&gt;
head = slicer.util.getNode('MRHead')&lt;br /&gt;
&lt;br /&gt;
# use a vtk class&lt;br /&gt;
threshold = vtk.vtkImageThreshold()&lt;br /&gt;
threshold.SetInputData(head.GetImageData())&lt;br /&gt;
threshold.ThresholdBetween(100, 200)&lt;br /&gt;
threshold.SetInValue(255)&lt;br /&gt;
threshold.SetOutValue(0)&lt;br /&gt;
&lt;br /&gt;
#  use a slicer-specific C++ class&lt;br /&gt;
erode = slicer.vtkImageErode()&lt;br /&gt;
erode.SetInputConnection(threshold.GetOutputPort())&lt;br /&gt;
erode.SetNeighborTo4()  &lt;br /&gt;
erode.Update()          &lt;br /&gt;
&lt;br /&gt;
head.SetAndObserveImageData(erode.GetOutputDataObject(0))&lt;br /&gt;
&lt;br /&gt;
slicer.util.saveNode(head, &amp;quot;/tmp/eroded.nrrd&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
exit()&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== How can I run Slicer on a headless compute node? ==&lt;br /&gt;
&lt;br /&gt;
Many cluster nodes are installed with minimal linux systems that don't include X servers.  X servers, particularly those with hardware acceleration traditionally needed to be installed with root privileges, making it impossible to run applications that rendered using X or OpenGL.&lt;br /&gt;
&lt;br /&gt;
But there is a workaround which allows everything in slicer to work normally so you could even do headless rendering.&lt;br /&gt;
&lt;br /&gt;
You can use a modern version of X that supports running a dummy framebuffer.  This can be installed in user mode so you don't even need to have root on the system.&lt;br /&gt;
&lt;br /&gt;
See [https://www.xpra.org/trac/wiki/Xdummy] for details.&lt;br /&gt;
&lt;br /&gt;
There's a thread here with more discussion: [http://massmail.spl.harvard.edu/public-archives/slicer-devel/2015/017317.html]&lt;br /&gt;
&lt;br /&gt;
Here is a working example of the approach running on a headless compute node running CTK tests (which also use Qt and VTK)&lt;br /&gt;
&lt;br /&gt;
[https://github.com/pieper/CTK/blob/master/.travis.yml]&lt;br /&gt;
&lt;br /&gt;
== How to save user's selection of parameters and nodes in the scene? ==&lt;br /&gt;
&lt;br /&gt;
It is preferable to save all the parameter values and nodes selections that the user made on the user interface into the MRML scene. This allows the user to load a scene and continue from where he left off. These information can be saved in a ''slicer.vtkMRMLScriptedModuleNode()'' node.&lt;br /&gt;
&lt;br /&gt;
For example:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
parameterNode=slicer.vtkMRMLScriptedModuleNode()&lt;br /&gt;
&lt;br /&gt;
# Save parameter values and node references to parameter node&lt;br /&gt;
&lt;br /&gt;
alpha = 5.0&lt;br /&gt;
beta = &amp;quot;abc&amp;quot;&lt;br /&gt;
inputNode = slicer.util.getNode(&amp;quot;InputNode&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
parameterNode.SetParameter(&amp;quot;Alpha&amp;quot;,str(alpha))&lt;br /&gt;
parameterNode.SetParameter(&amp;quot;Beta&amp;quot;, beta)&lt;br /&gt;
parameterNode.SetNodeReferenceID(&amp;quot;InputNode&amp;quot;, inputNode.GetID())&lt;br /&gt;
&lt;br /&gt;
# Retrieve parameter values and node references from parameter node&lt;br /&gt;
&lt;br /&gt;
alpha = float(parameterNode.GetParameter(&amp;quot;Alpha&amp;quot;))&lt;br /&gt;
beta = parameterNode.GetParameter(&amp;quot;Beta&amp;quot;)&lt;br /&gt;
inputNode = parameterNode.GetNodeReference(&amp;quot;InputNode&amp;quot;)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Scripted module's logic class have a helper function, ''getParameterNode'', which returns a parameter node that is unique for a specific module. The function creates the parameter node if it has not been created yet. By default, the parameter node is a singleton node, which means that there is only a single instance of the node in the scene. If it is preferable to allow multiple instances of the parameter node, set ''isSingletonParameterNode'' member of the logic object to ''False''.&lt;br /&gt;
&lt;br /&gt;
== How to load a UI file ? ==&lt;br /&gt;
&lt;br /&gt;
See [[Documentation/Nightly/Developers/Tutorials/PythonAndUIFile]]&lt;br /&gt;
&lt;br /&gt;
== How to update progress bar in scripted (Python, or other) CLI modules ==&lt;br /&gt;
&lt;br /&gt;
As detailed in the [https://www.slicer.org/wiki/Documentation/Nightly/Developers/SlicerExecutionModel#Showing_Progress_in_an_Application|Slicer Execution Model documentation], Slicer parses specifically-formatted XML commands printed on stdout, to allow any out-of-process CLI program to report progress back to the main Slicer application (which will causing the progress bar to update). However, it is very important to note that the output must be flushed after each print statement, or else Slicer will not parse the progress sections until the process ends. See the calls to &amp;lt;pre&amp;gt;sys.stdout.flush()&amp;lt;/pre&amp;gt; in the example Python CLI shown below:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#!/usr/bin/env python-real&lt;br /&gt;
&lt;br /&gt;
if __name__ == '__main__':&lt;br /&gt;
  import time&lt;br /&gt;
  import sys&lt;br /&gt;
  &lt;br /&gt;
  print(&amp;quot;&amp;quot;&amp;quot;&amp;lt;filter-start&amp;gt;&amp;lt;filter-name&amp;gt;TestFilter&amp;lt;/filter-name&amp;gt;&amp;lt;filter-comment&amp;gt;ibid&amp;lt;/filter-comment&amp;gt;&amp;lt;/filter-start&amp;gt;&amp;quot;&amp;quot;&amp;quot;)&lt;br /&gt;
  sys.stdout.flush()&lt;br /&gt;
&lt;br /&gt;
  for i in range(0,10):&lt;br /&gt;
      print(&amp;quot;&amp;quot;&amp;quot;&amp;lt;filter-progress&amp;gt;{}&amp;lt;/filter-progress&amp;gt;&amp;quot;&amp;quot;&amp;quot;.format(i/10.0))&lt;br /&gt;
      sys.stdout.flush()&lt;br /&gt;
      time.sleep(0.5)&lt;br /&gt;
&lt;br /&gt;
  print(&amp;quot;&amp;quot;&amp;quot;&amp;lt;filter-end&amp;gt;&amp;lt;filter-name&amp;gt;TestFilter&amp;lt;/filter-name&amp;gt;&amp;lt;filter-time&amp;gt;10&amp;lt;/filter-time&amp;gt;&amp;lt;/filter-end&amp;gt;&amp;quot;&amp;quot;&amp;quot;)&lt;br /&gt;
  sys.stdout.flush()&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>Inorton</name></author>
		
	</entry>
	<entry>
		<id>https://www.slicer.org/w/index.php?title=Documentation/Nightly/Developers/FAQ/Python_Scripting&amp;diff=59277</id>
		<title>Documentation/Nightly/Developers/FAQ/Python Scripting</title>
		<link rel="alternate" type="text/html" href="https://www.slicer.org/w/index.php?title=Documentation/Nightly/Developers/FAQ/Python_Scripting&amp;diff=59277"/>
		<updated>2018-08-15T20:15:56Z</updated>

		<summary type="html">&lt;p&gt;Inorton: /* Developer FAQ: {{{1}}} */&lt;/p&gt;
&lt;hr /&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 access a scripted module from python scripts ==&lt;br /&gt;
&lt;br /&gt;
All slicer modules are accessible in the &amp;lt;code&amp;gt;slicer.modules&amp;lt;/code&amp;gt; namespace. For example, ''sampledata'' module can be accessed as &amp;lt;code&amp;gt;slicer.modules.sampledata&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
To access a module's widget, use &amp;lt;code&amp;gt;widgetRepresentation()&amp;lt;/code&amp;gt; method to get the C++ base class and its &amp;lt;code&amp;gt;self()&amp;lt;/code&amp;gt; method to get the Python class. For example, &amp;lt;code&amp;gt;slicer.modules.sampledata.widgetRepresentation().self()&amp;lt;/code&amp;gt; returns the Python widget object of ''sampledata'' module.&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; in your HOME folder. (See [[Documentation/{{documentation/version}}/FAQ/General#What_is_my_HOME_folder_.3F|What is my HOME folder ?]])&lt;br /&gt;
&lt;br /&gt;
Alternatively, set an environment variable named &amp;lt;tt&amp;gt;SLICERRC&amp;lt;/tt&amp;gt; to the full path of a Python file to run at startup.&lt;br /&gt;
&lt;br /&gt;
You can see the path to your &amp;lt;code&amp;gt;.slicerrc.py&amp;lt;/code&amp;gt; file and edit it if you start Slicer and open in the menu: Edit / Application Settings. ''Application startup script'' is in the General section.&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;
=== Enable or disable compression while saving a volume ===&lt;br /&gt;
&lt;br /&gt;
While volumes can be accessed in Slicer Python modules as vtkMRMLVolumeNode, compression preference (or any other property for that matter) should be passed to slicer.util.saveNode function. The property will be passed to Slicer's storage node. For compression set the &amp;lt;code&amp;gt;useCompression&amp;lt;/code&amp;gt; to 0 or 1. Example script:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
properties['useCompression'] = 0; #do not compress&lt;br /&gt;
file_path = os.path.join(case_dir, file_name)&lt;br /&gt;
slicer.util.saveNode(node, file_path, properties)&lt;br /&gt;
&amp;lt;/pre&amp;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;
== How to get VTK rendering backend ? ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
backend = slicer.app.layoutManager().threeDWidget(0).threeDView().renderWindow().GetRenderingBackend()&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== How to access displayable manager associated with a Slicer 2D or 3D view ? ==&lt;br /&gt;
&lt;br /&gt;
As originally explained [http://slicer-devel.65872.n3.nabble.com/How-to-get-the-point-of-a-3D-model-based-on-the-fiducial-position-td4031760.html#a4031762 here], you could use the method &amp;lt;code&amp;gt;getDisplayableManagers()&amp;lt;/code&amp;gt; available in any [{{doxygen-class-url|qMRMLThreeDView}} qMRMLThreeDView] and [{{doxygen-class-url|qMRMLSliceView}} qMRMLSliceView].&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
lm = slicer.app.layoutManager()&lt;br /&gt;
for v in range(lm.threeDViewCount):&lt;br /&gt;
  td = lm.threeDWidget(v)&lt;br /&gt;
  ms = vtk.vtkCollection()&lt;br /&gt;
  td.getDisplayableManagers(ms)&lt;br /&gt;
  for i in range(ms.GetNumberOfItems()):&lt;br /&gt;
   m = ms.GetItemAsObject(i)&lt;br /&gt;
   if m.GetClassName() == &amp;quot;vtkMRMLModelDisplayableManager&amp;quot;:&lt;br /&gt;
     print(m)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== How to center the 3D view on the scene ? ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
layoutManager = slicer.app.layoutManager()&lt;br /&gt;
threeDWidget = layoutManager.threeDWidget(0)&lt;br /&gt;
threeDView = threeDWidget.threeDView()&lt;br /&gt;
threeDView.resetFocalPoint()&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Should I use '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;br /&gt;
&lt;br /&gt;
== How can I use a visual debugger for step-by-step debugging ==&lt;br /&gt;
&lt;br /&gt;
===Debugging using PyCharm or PyDev===&lt;br /&gt;
Visual debugging (setting breakpoints, execute code step-by-step, view variables, stack, etc.) of Python scripted module is possible by using [https://www.jetbrains.com/pycharm/ PyCharm] or [http://pydev.org/ PyDev] by using the ''Python debugger'' module [[Documentation/{{documentation/version}}/Extensions/DebuggingTools|Debugging tools]] extension.&lt;br /&gt;
&lt;br /&gt;
'''See detailed instructions at the [[Documentation/{{documentation/version}}/Extensions/DebuggingTools|Debugging tools extension page]].'''&lt;br /&gt;
[[File:PyDevRemoteDebugSlicer.png|800px|thumb|center|Visual debugging of Python modules in Slicer]]&lt;br /&gt;
&lt;br /&gt;
===Debugging using Visual Studio===&lt;br /&gt;
On Windows, [https://github.com/Microsoft/PTVS Python Tools for Visual Studio] (PTVS) enables debugging Python inside Visual Studio. Its remote debugging capability allows attaching the debugger to Slicer's embedded Python environment.&lt;br /&gt;
&lt;br /&gt;
See [[Documentation/{{documentation/version}}/Developers/Tutorials/Debugging_Python_in_Visual_Studio | Debugging Python in Visual Studio]] for details.&lt;br /&gt;
&lt;br /&gt;
===Debugging using remote-pdb===&lt;br /&gt;
&lt;br /&gt;
A command line debugging session with a [https://docs.python.org/3/library/pdb.html pdb] interface can be achieved with [https://github.com/ionelmc/python-remote-pdb python-remote-pdb].&lt;br /&gt;
&lt;br /&gt;
Install python-remote-pdb into Slicer's Python:&lt;br /&gt;
&lt;br /&gt;
  git clone https://github.com/ionelmc/python-remote-pdb.git&lt;br /&gt;
  cd python-remote-pdb&lt;br /&gt;
  /path/to/Slicer-build/Slicer-build/Slicer ./setup.py install&lt;br /&gt;
&lt;br /&gt;
Then, call ''set_trace()'' where you want to start the debugger.&lt;br /&gt;
&lt;br /&gt;
  from remote_pdb import set_trace; set_trace()&lt;br /&gt;
&lt;br /&gt;
In the console where Slicer was started, a message like the following will be printed:&lt;br /&gt;
&lt;br /&gt;
  RemotePdb session open at 127.0.0.1:1234, waiting for connection&lt;br /&gt;
&lt;br /&gt;
In another terminal, connect with telnet:&lt;br /&gt;
&lt;br /&gt;
  telnet 127.0.0.1 1234&lt;br /&gt;
&lt;br /&gt;
or socat (has history, readline support):&lt;br /&gt;
&lt;br /&gt;
  socat readline tcp:127.0.0.1:1234&lt;br /&gt;
&lt;br /&gt;
== Why can't I access my C++ Qt class from python ==&lt;br /&gt;
* Python wrapping of a Qt class requires a Qt style constructor with QObject as argument (it can be defaulted to null though), which is public. If one of these are missing, python wrapping will fail for that class&lt;br /&gt;
* You cannot access your custom C++ Qt classes from python outside of the scope of your instantiated python class. These will not work:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
BarIDRole = slicer.qFooItemDelegate.LastRole + 1&lt;br /&gt;
&lt;br /&gt;
class BarTableWidget(qt.QTableWidget, VTKObservationMixin):&lt;br /&gt;
&lt;br /&gt;
    def __init__(self, *args, **kwargs):&lt;br /&gt;
        [...]&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
class BarTableWidget(qt.QTableWidget, VTKObservationMixin):&lt;br /&gt;
&lt;br /&gt;
    BarIDRole = slicer.qFooItemDelegate.LastRole + 1&lt;br /&gt;
&lt;br /&gt;
    def __init__(self, *args, **kwargs):&lt;br /&gt;
        [...]&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Instead, do:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
class BarTableWidget(qt.QTableWidget, VTKObservationMixin):&lt;br /&gt;
&lt;br /&gt;
    def __init__(self, *args, **kwargs):&lt;br /&gt;
        self.BarIDRole = slicer.qFooItemDelegate.LastRole + 1&lt;br /&gt;
        [...]&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* [Other reasons go here]&lt;br /&gt;
&lt;br /&gt;
== Can I use factory method like CreateNodeByClass or GetNodesByClass ? ==&lt;br /&gt;
&lt;br /&gt;
See [[Documentation/{{documentation/version}}/Developers/Tutorials/MemoryManagement#Factory_methods]]&lt;br /&gt;
&lt;br /&gt;
== How can I access callData argument in a VTK object observer callback function ==&lt;br /&gt;
&lt;br /&gt;
To get notification about an event emitted by a VTK object you can simply use the AddObserver method, for example:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
def sceneModifiedCallback(caller, eventId):&lt;br /&gt;
  print(&amp;quot;Scene modified&amp;quot;)&lt;br /&gt;
  print(&amp;quot;There are {0} nodes in the scene&amp;quot;. format(slicer.mrmlScene.GetNumberOfNodes()))&lt;br /&gt;
&lt;br /&gt;
sceneModifiedObserverTag = slicer.mrmlScene.AddObserver(vtk.vtkCommand.ModifiedEvent, sceneModifiedCallback)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If an event also contains additional information as CallData then the type of this argument has to be specified as well, for example:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
@vtk.calldata_type(vtk.VTK_OBJECT)&lt;br /&gt;
def nodeAddedCallback(caller, eventId, callData):&lt;br /&gt;
  print(&amp;quot;Node added&amp;quot;)&lt;br /&gt;
  print(&amp;quot;New node: {0}&amp;quot;.format(callData.GetName()))&lt;br /&gt;
&lt;br /&gt;
nodeAddedModifiedObserverTag = slicer.mrmlScene.AddObserver(slicer.vtkMRMLScene.NodeAddedEvent, nodeAddedCallback)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note: @vtk.calldata_type is a Python decorator, which modifies properties of a function that is declared right after the decorator. The decorator is defined in VTK (in Wrapping\Python\vtk\util\misc.py).&lt;br /&gt;
&lt;br /&gt;
Usage from a class requires an extra step of creating the callback in the class __init__ function, as Python2 by default does some extra wrapping (http://stackoverflow.com/questions/9523370/adding-attributes-to-instance-methods-in-python):&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
class MyClass:&lt;br /&gt;
  def __init__(self):&lt;br /&gt;
    from functools import partial&lt;br /&gt;
    def nodeAddedCallback(self, caller, eventId, callData):&lt;br /&gt;
      print(&amp;quot;Node added&amp;quot;)&lt;br /&gt;
      print(&amp;quot;New node: {0}&amp;quot;.format(callData.GetName()))&lt;br /&gt;
    self.nodeAddedCallback = partial(nodeAddedCallback, self)&lt;br /&gt;
    self.nodeAddedCallback.CallDataType = vtk.VTK_OBJECT&lt;br /&gt;
  def registerCallbacks(self):&lt;br /&gt;
    self.nodeAddedModifiedObserverTag = slicer.mrmlScene.AddObserver(slicer.vtkMRMLScene.NodeAddedEvent, self.nodeAddedCallback)&lt;br /&gt;
  def unregisterCallbacks(self):&lt;br /&gt;
    slicer.mrmlScene.RemoveObserver(self.nodeAddedModifiedObserverTag)&lt;br /&gt;
        &lt;br /&gt;
myObject = MyClass()&lt;br /&gt;
myObject.registerCallbacks()&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Allowed CallDataType values:  VTK_STRING, VTK_OBJECT, VTK_INT, VTK_LONG, VTK_DOUBLE, VTK_FLOAT, &amp;quot;string0&amp;quot;. See more information here:&lt;br /&gt;
https://github.com/Kitware/VTK/blob/master/Wrapping/PythonCore/vtkPythonCommand.cxx&lt;br /&gt;
&lt;br /&gt;
A simplified syntax is available by using a mix-in:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
from slicer.util import VTKObservationMixin&lt;br /&gt;
&lt;br /&gt;
class MyClass(VTKObservationMixin):&lt;br /&gt;
  def __init__(self):&lt;br /&gt;
    VTKObservationMixin.__init__(self)&lt;br /&gt;
    self.addObserver(slicer.mrmlScene, slicer.vtkMRMLScene.NodeAddedEvent, self.nodeAddedCallback)&lt;br /&gt;
  &lt;br /&gt;
  @vtk.calldata_type(vtk.VTK_OBJECT)&lt;br /&gt;
  def nodeAddedCallback(self, caller, eventId, callData):&lt;br /&gt;
    print(&amp;quot;Node added&amp;quot;)&lt;br /&gt;
    print(&amp;quot;New node: {0}&amp;quot;.format(callData.GetName()))&lt;br /&gt;
&lt;br /&gt;
myObject = MyClass()&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note: VTKObservationMixin is a Python mix-in that allows adding a set of methods to a class by inheritance. VTKObservationMixin includes addObserver, hasObserver, observer, removeObserver, removeObservers methods, defined in Slicer (in Base\Python\slicer\util.py). For example of usage, see [https://github.com/Slicer/Slicer/blob/master/Base/Python/slicer/tests/test_slicer_util_VTKObservationMixin.py test_slicer_util_VTKObservationMixin.py]&lt;br /&gt;
&lt;br /&gt;
== Slicer crashes if I try to access a non-existing item in an array ==&lt;br /&gt;
&lt;br /&gt;
For example, this code makes Slicer crash:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
s = vtk.vtkStringArray()&lt;br /&gt;
s.GetValue(0)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This behavior is expected, as all VTK objects are implemented in C++ that offers much faster operation but developers have to take care of addressing only valid array elements, for example by checking the number of elements in the array:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
if itemIndex &amp;lt; 0 or itemIndex &amp;gt;= s.GetNumberOfValues()&lt;br /&gt;
  raise IndexError(&amp;quot;index out of bounds&amp;quot;)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== How to run CLI module from Python? ==&lt;br /&gt;
&lt;br /&gt;
See [[Documentation/{{documentation/version}}/Developers/Python_scripting#Running_a_CLI_from_Python|here]].&lt;br /&gt;
&lt;br /&gt;
== How can I run slicer operations from a batch script? ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Slicer --no-main-window --python-script /tmp/test.py&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Contents of /tmp/test.py&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# use a slicer scripted module logic&lt;br /&gt;
from SampleData import SampleDataLogic&lt;br /&gt;
SampleDataLogic().downloadMRHead()&lt;br /&gt;
head = slicer.util.getNode('MRHead')&lt;br /&gt;
&lt;br /&gt;
# use a vtk class&lt;br /&gt;
threshold = vtk.vtkImageThreshold()&lt;br /&gt;
threshold.SetInputData(head.GetImageData())&lt;br /&gt;
threshold.ThresholdBetween(100, 200)&lt;br /&gt;
threshold.SetInValue(255)&lt;br /&gt;
threshold.SetOutValue(0)&lt;br /&gt;
&lt;br /&gt;
#  use a slicer-specific C++ class&lt;br /&gt;
erode = slicer.vtkImageErode()&lt;br /&gt;
erode.SetInputConnection(threshold.GetOutputPort())&lt;br /&gt;
erode.SetNeighborTo4()  &lt;br /&gt;
erode.Update()          &lt;br /&gt;
&lt;br /&gt;
head.SetAndObserveImageData(erode.GetOutputDataObject(0))&lt;br /&gt;
&lt;br /&gt;
slicer.util.saveNode(head, &amp;quot;/tmp/eroded.nrrd&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
exit()&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== How can I run Slicer on a headless compute node? ==&lt;br /&gt;
&lt;br /&gt;
Many cluster nodes are installed with minimal linux systems that don't include X servers.  X servers, particularly those with hardware acceleration traditionally needed to be installed with root privileges, making it impossible to run applications that rendered using X or OpenGL.&lt;br /&gt;
&lt;br /&gt;
But there is a workaround which allows everything in slicer to work normally so you could even do headless rendering.&lt;br /&gt;
&lt;br /&gt;
You can use a modern version of X that supports running a dummy framebuffer.  This can be installed in user mode so you don't even need to have root on the system.&lt;br /&gt;
&lt;br /&gt;
See [https://www.xpra.org/trac/wiki/Xdummy] for details.&lt;br /&gt;
&lt;br /&gt;
There's a thread here with more discussion: [http://massmail.spl.harvard.edu/public-archives/slicer-devel/2015/017317.html]&lt;br /&gt;
&lt;br /&gt;
Here is a working example of the approach running on a headless compute node running CTK tests (which also use Qt and VTK)&lt;br /&gt;
&lt;br /&gt;
[https://github.com/pieper/CTK/blob/master/.travis.yml]&lt;br /&gt;
&lt;br /&gt;
== How to save user's selection of parameters and nodes in the scene? ==&lt;br /&gt;
&lt;br /&gt;
It is preferable to save all the parameter values and nodes selections that the user made on the user interface into the MRML scene. This allows the user to load a scene and continue from where he left off. These information can be saved in a ''slicer.vtkMRMLScriptedModuleNode()'' node.&lt;br /&gt;
&lt;br /&gt;
For example:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
parameterNode=slicer.vtkMRMLScriptedModuleNode()&lt;br /&gt;
&lt;br /&gt;
# Save parameter values and node references to parameter node&lt;br /&gt;
&lt;br /&gt;
alpha = 5.0&lt;br /&gt;
beta = &amp;quot;abc&amp;quot;&lt;br /&gt;
inputNode = slicer.util.getNode(&amp;quot;InputNode&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
parameterNode.SetParameter(&amp;quot;Alpha&amp;quot;,str(alpha))&lt;br /&gt;
parameterNode.SetParameter(&amp;quot;Beta&amp;quot;, beta)&lt;br /&gt;
parameterNode.SetNodeReferenceID(&amp;quot;InputNode&amp;quot;, inputNode.GetID())&lt;br /&gt;
&lt;br /&gt;
# Retrieve parameter values and node references from parameter node&lt;br /&gt;
&lt;br /&gt;
alpha = float(parameterNode.GetParameter(&amp;quot;Alpha&amp;quot;))&lt;br /&gt;
beta = parameterNode.GetParameter(&amp;quot;Beta&amp;quot;)&lt;br /&gt;
inputNode = parameterNode.GetNodeReference(&amp;quot;InputNode&amp;quot;)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Scripted module's logic class have a helper function, ''getParameterNode'', which returns a parameter node that is unique for a specific module. The function creates the parameter node if it has not been created yet. By default, the parameter node is a singleton node, which means that there is only a single instance of the node in the scene. If it is preferable to allow multiple instances of the parameter node, set ''isSingletonParameterNode'' member of the logic object to ''False''.&lt;br /&gt;
&lt;br /&gt;
== How to load a UI file ? ==&lt;br /&gt;
&lt;br /&gt;
See [[Documentation/Nightly/Developers/Tutorials/PythonAndUIFile]]&lt;br /&gt;
&lt;br /&gt;
== How to update progress bar in scripted (Python, or other) CLI modules ==&lt;br /&gt;
&lt;br /&gt;
As detailed in the [https://www.slicer.org/wiki/Documentation/Nightly/Developers/SlicerExecutionModel#Showing_Progress_in_an_Application|Slicer Execution Model documentation], Slicer parses specifically-formatted XML commands printed on stdout, to allow any out-of-process CLI program to report progress back to the main Slicer application (which will causing the progress bar to update). However, it is very important to note that the output must be flushed after each print statement, or else Slicer will not parse the progress sections until the process ends. See the calls to &amp;lt;pre&amp;gt;sys.stdout.flush()&amp;lt;/pre&amp;gt; in the example Python CLI shown below:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#!/usr/bin/env python-real&lt;br /&gt;
&lt;br /&gt;
if __name__ == '__main__':&lt;br /&gt;
  import time&lt;br /&gt;
  import sys&lt;br /&gt;
  &lt;br /&gt;
  print(&amp;quot;&amp;quot;&amp;quot;&amp;lt;filter-start&amp;gt;&amp;lt;filter-name&amp;gt;TestFilter&amp;lt;/filter-name&amp;gt;&amp;lt;filter-comment&amp;gt;ibid&amp;lt;/filter-comment&amp;gt;&amp;lt;/filter-start&amp;gt;&amp;quot;&amp;quot;&amp;quot;)&lt;br /&gt;
  sys.stdout.flush()&lt;br /&gt;
&lt;br /&gt;
  for i in range(0,10):&lt;br /&gt;
      print(i/10.0)&lt;br /&gt;
      print(&amp;quot;&amp;quot;&amp;quot;&amp;lt;filter-progress&amp;gt;{}&amp;lt;/filter-progress&amp;gt;&amp;quot;&amp;quot;&amp;quot;.format(i/10.0))&lt;br /&gt;
      sys.stdout.flush()&lt;br /&gt;
      time.sleep(0.5)&lt;br /&gt;
&lt;br /&gt;
  print(&amp;quot;&amp;quot;&amp;quot;&amp;lt;filter-end&amp;gt;&amp;lt;filter-name&amp;gt;TestFilter&amp;lt;/filter-name&amp;gt;&amp;lt;filter-time&amp;gt;10&amp;lt;/filter-time&amp;gt;&amp;lt;/filter-end&amp;gt;&amp;quot;&amp;quot;&amp;quot;)&lt;br /&gt;
  sys.stdout.flush()&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>Inorton</name></author>
		
	</entry>
	<entry>
		<id>https://www.slicer.org/w/index.php?title=Documentation/Nightly/Developers/Plots&amp;diff=59221</id>
		<title>Documentation/Nightly/Developers/Plots</title>
		<link rel="alternate" type="text/html" href="https://www.slicer.org/w/index.php?title=Documentation/Nightly/Developers/Plots&amp;diff=59221"/>
		<updated>2018-07-24T20:31:08Z</updated>

		<summary type="html">&lt;p&gt;Inorton: /* Constructing a plot */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;noinclude&amp;gt;{{documentation/versioncheck}}&amp;lt;/noinclude&amp;gt;&lt;br /&gt;
{{Clear}}{{TOC right}}&lt;br /&gt;
&lt;br /&gt;
= Slicer plotting overview and acknowledgements =&lt;br /&gt;
&lt;br /&gt;
Slicer provides Plotting facilities that include a plot view that can be displayed in the view layout, similarly to slice 3D views. Plot data is stored in table nodes, and plot series, chart, and view nodes define which table column need to be displayed and how. Plot can be serialized with the MRML scene, including the plot data and display properties. Plot series and charts can be created and edited in Plots module and plots can be also generated directly from Tables module by a single click.&lt;br /&gt;
&lt;br /&gt;
Authors:&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;b&amp;gt;Davide Punzo&amp;lt;/b&amp;gt; (Kapteyn Astronomical Institute, University of Groningen) &amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;b&amp;gt;Andras Lasso&amp;lt;/b&amp;gt; (PerkLab, Queen's University) &amp;lt;br&amp;gt; &lt;br /&gt;
&lt;br /&gt;
Contributors: &amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;b&amp;gt;Jean-Christophe Fillion-Robin&amp;lt;/b&amp;gt; (Kitware) &amp;lt;br&amp;gt; &lt;br /&gt;
&amp;lt;b&amp;gt;Steve Pieper&amp;lt;/b&amp;gt; (Isomics) &amp;lt;br&amp;gt; &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Acknowledgements: &amp;lt;br&amp;gt; &lt;br /&gt;
This work was supported by the European Research Council under the European Union's Seventh Framework Programme (FP/2007-2013)/ERC Grant Agreement nr. 291-531.&amp;lt;br&amp;gt; &amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;!-- ---------------------------- --&amp;gt;&lt;br /&gt;
[[File:ERCIcon.png|300px|European Research Council]]&lt;br /&gt;
[[File:Kapteyn logo1.png|500px|Kapteyn Astronomical Institute]]&lt;br /&gt;
&amp;lt;!-- ---------------------------- --&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Contacts:&lt;br /&gt;
* Davide Punzo, &amp;lt;email&amp;gt;punzodavide@hotmail.it&amp;lt;/email&amp;gt;; &amp;lt;email&amp;gt;D.Punzo@astro.rug.nl&amp;lt;/email&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Plot capabilities =&lt;br /&gt;
* Multiple plots types (Line, Bar, Scatter, Scatter bar), shown in standard view layouts.&lt;br /&gt;
* Configurable chart and axis title, legend, grid lines.&lt;br /&gt;
* Use indexes (0, 1, 2, ...) or a table column for X axis values.&lt;br /&gt;
* Multiple plot series can be added to a single plot chart (even showing data from different tables, with different types - plot, bar), and the same series can be added to multiple charts. The same plot chart can be shown in any plot views (even simultaneously).&lt;br /&gt;
* Label can be assigned to each data point (shown in tooltip when hovering over a data point).&lt;br /&gt;
* Interactive editing of data points by drag-and-drop (data in referenced table nodes is updated).&lt;br /&gt;
* Interactive selection of data points (rectangular or free-hand selection).&lt;br /&gt;
* Plot data and display properties are stored in the MRML scene.&lt;br /&gt;
* Plot view can be embedded into module user interfaces. Plot views can [[#Signals|emit signals]] back to the application as the user interacts with a plot, which allows modules to perform additional processing on the selected data points.&lt;br /&gt;
&lt;br /&gt;
What is the difference between Slicer Plot and Chart?&lt;br /&gt;
[[Documentation/{{documentation/version}}/Developers/FAQ#What_is_the_difference_between_Slicer_Plot_and_Chart_.3F | See FAQ.]]&lt;br /&gt;
&lt;br /&gt;
= Shortcuts and Interactions =&lt;br /&gt;
The Plot infrastructure allow the following interaction:&lt;br /&gt;
&lt;br /&gt;
* Left mouse button: depends on interaction mode of the view&lt;br /&gt;
** Pan view: pan view&lt;br /&gt;
** Select points: select points using rectangular selection&lt;br /&gt;
** Freehand select points: select points using free-form selection&lt;br /&gt;
** Move points: move data points by drag-and-drop; this changes values in the referenced table node&lt;br /&gt;
* Middle mouse button: pan view (except in pan view mode; in that case it zooms to selected rectangular region)&lt;br /&gt;
* Right mouse button: zoom in/out along X and Y axes&lt;br /&gt;
* S: switch interaction mode (pan/select points/.../move points)&lt;br /&gt;
* R: reset view to show all data series&lt;br /&gt;
&lt;br /&gt;
=Architecture=&lt;br /&gt;
&lt;br /&gt;
== MRML Nodes ==&lt;br /&gt;
&lt;br /&gt;
; [{{doxygen-class-url|vtkMRMLTableNode}} vtkMRMLTableNode]&lt;br /&gt;
: Table node stores values that specify data point positions or bar heights in the plots.&lt;br /&gt;
&lt;br /&gt;
; [{{doxygen-class-url|vtkMRMLPlotSeriesNode}} vtkMRMLPlotSeriesNode]&lt;br /&gt;
: Defines a data series by referring to a table node and column name(s) for X and Y axes and labels.&lt;br /&gt;
: It also defines display properties, such as plot type, color, line style.&lt;br /&gt;
: Line and bar plots only require Y axis (points along X axis are equally spaced), scatter plots require two input data columns, for X and Y axes.&lt;br /&gt;
&lt;br /&gt;
; [{{doxygen-class-url|vtkMRMLPlotChartNode}} vtkMRMLPlotChartNode]&lt;br /&gt;
: Specifies which data series need to be shown in the chart.&lt;br /&gt;
: Also contains global display properties for the chart, such as titles and font style.&lt;br /&gt;
&lt;br /&gt;
; [{{doxygen-class-url|vtkMRMLPlotViewNode}} vtkMRMLPlotViewNode]&lt;br /&gt;
: Specifies which chart is to be displayed in the plot view and how the user can interact with it.&lt;br /&gt;
: There has to be exactly one plot view node for each plot view widget. This class can not be created or copied unless is connected with a plot view.&lt;br /&gt;
&lt;br /&gt;
== Widgets == &lt;br /&gt;
&lt;br /&gt;
; [{{doxygen-class-url|qMRMLPlotView}} qMRMLPlotView]&lt;br /&gt;
: Displays a plot. It can be embedded into a module user interface.&lt;br /&gt;
&lt;br /&gt;
; [{{doxygen-class-url|qMRMLPlotWidget}} qMRMLPlotWidget]&lt;br /&gt;
: Displays a plot and in a popup window a plot view controller widget [{{doxygen-class-url|qMRMLPlotViewControllerWidget}} plot view controller widget].&lt;br /&gt;
&lt;br /&gt;
; [{{doxygen-class-url|qMRMLPlotSeriesPropertiesWidget}} qMRMLPlotSeriesPropertiesWidget]&lt;br /&gt;
: Display/edit properties of a plot series node.&lt;br /&gt;
&lt;br /&gt;
; [{{doxygen-class-url|qMRMLPlotChartPropertiesWidget}} qMRMLPlotChartPropertiesWidget]&lt;br /&gt;
: Display/edit properties of a plot series node.&lt;br /&gt;
&lt;br /&gt;
; [{{doxygen-class-url|qMRMLPlotViewControllerWidget}} qMRMLPlotViewControllerWidget]&lt;br /&gt;
: Display/edit properties of a plot view node.&lt;br /&gt;
&lt;br /&gt;
= Constructing a plot = &lt;br /&gt;
Below is an example in python to construct and display a plot communicating completely at the level of MRML. Note: this functionality is not available in Slicer 4.8, please use a recent SlicerPreview nightly build.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
import slicer&lt;br /&gt;
import math&lt;br /&gt;
&lt;br /&gt;
# Create table with x, cos, sin columns&lt;br /&gt;
&lt;br /&gt;
tableNode = slicer.mrmlScene.AddNewNodeByClass(&amp;quot;vtkMRMLTableNode&amp;quot;)&lt;br /&gt;
table = tableNode.GetTable()&lt;br /&gt;
&lt;br /&gt;
arrX = vtk.vtkFloatArray()&lt;br /&gt;
arrX.SetName(&amp;quot;x&amp;quot;)&lt;br /&gt;
table.AddColumn(arrX)&lt;br /&gt;
&lt;br /&gt;
arrY1 = vtk.vtkFloatArray()&lt;br /&gt;
arrY1.SetName(&amp;quot;cos&amp;quot;)&lt;br /&gt;
table.AddColumn(arrY1)&lt;br /&gt;
&lt;br /&gt;
arrY2 = vtk.vtkFloatArray()&lt;br /&gt;
arrY2.SetName(&amp;quot;sin&amp;quot;)&lt;br /&gt;
table.AddColumn(arrY2)&lt;br /&gt;
&lt;br /&gt;
# Fill in the table with some example values&lt;br /&gt;
&lt;br /&gt;
import math&lt;br /&gt;
numPoints = 69&lt;br /&gt;
inc = 7.5 / (numPoints - 1)&lt;br /&gt;
table.SetNumberOfRows(numPoints)&lt;br /&gt;
for i in range(numPoints):&lt;br /&gt;
  table.SetValue(i, 0, i * inc )&lt;br /&gt;
  table.SetValue(i, 1, math.cos(i * inc))&lt;br /&gt;
  table.SetValue(i, 2, math.sin(i * inc))&lt;br /&gt;
&lt;br /&gt;
# Create two plot series nodes&lt;br /&gt;
&lt;br /&gt;
plotSeriesNode1 = slicer.mrmlScene.AddNewNodeByClass(&amp;quot;vtkMRMLPlotSeriesNode&amp;quot;, &amp;quot;My first&amp;quot;)&lt;br /&gt;
plotSeriesNode1.SetAndObserveTableNodeID(tableNode.GetID())&lt;br /&gt;
plotSeriesNode1.SetXColumnName(&amp;quot;x&amp;quot;)&lt;br /&gt;
plotSeriesNode1.SetYColumnName(&amp;quot;cos&amp;quot;)&lt;br /&gt;
plotSeriesNode1.SetPlotType(slicer.vtkMRMLPlotSeriesNode.PlotTypeScatter)&lt;br /&gt;
plotSeriesNode1.SetLineStyle(slicer.vtkMRMLPlotSeriesNode.LineStyleNone)&lt;br /&gt;
plotSeriesNode1.SetMarkerStyle(slicer.vtkMRMLPlotSeriesNode.MarkerStyleSquare)&lt;br /&gt;
plotSeriesNode1.SetUniqueColor()&lt;br /&gt;
&lt;br /&gt;
plotSeriesNode2 = slicer.mrmlScene.AddNewNodeByClass(&amp;quot;vtkMRMLPlotSeriesNode&amp;quot;, &amp;quot;My second&amp;quot;)&lt;br /&gt;
plotSeriesNode2.SetAndObserveTableNodeID(tableNode.GetID())&lt;br /&gt;
plotSeriesNode2.SetXColumnName(&amp;quot;x&amp;quot;)&lt;br /&gt;
plotSeriesNode2.SetYColumnName(&amp;quot;sin&amp;quot;)&lt;br /&gt;
plotSeriesNode2.SetPlotType(slicer.vtkMRMLPlotSeriesNode.PlotTypeScatter)&lt;br /&gt;
plotSeriesNode2.SetUniqueColor()&lt;br /&gt;
&lt;br /&gt;
# Create plot chart node&lt;br /&gt;
&lt;br /&gt;
plotChartNode = slicer.mrmlScene.AddNewNodeByClass(&amp;quot;vtkMRMLPlotChartNode&amp;quot;)&lt;br /&gt;
plotChartNode.AddAndObservePlotSeriesNodeID(plotSeriesNode1.GetID())&lt;br /&gt;
plotChartNode.AddAndObservePlotSeriesNodeID(plotSeriesNode2.GetID())&lt;br /&gt;
plotChartNode.SetTitle('A simple plot with 2 curves')&lt;br /&gt;
plotChartNode.SetXAxisTitle('Something in x')&lt;br /&gt;
plotChartNode.SetYAxisTitle('Something in y')&lt;br /&gt;
&lt;br /&gt;
# Switch to a layout that contains a plot view to create a plot widget&lt;br /&gt;
&lt;br /&gt;
layoutManager = slicer.app.layoutManager()&lt;br /&gt;
layoutWithPlot = slicer.modules.plots.logic().GetLayoutWithPlot(layoutManager.layout)&lt;br /&gt;
layoutManager.setLayout(layoutWithPlot)&lt;br /&gt;
&lt;br /&gt;
# Select chart in plot view&lt;br /&gt;
&lt;br /&gt;
plotWidget = layoutManager.plotWidget(0)&lt;br /&gt;
plotViewNode = plotWidget.mrmlPlotViewNode()&lt;br /&gt;
plotViewNode.SetPlotChartNodeID(plotChartNode.GetID())&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This code produces the plot below.&lt;br /&gt;
&lt;br /&gt;
[[Image:VtkPlot.png|A simple plot.|1200px]]&lt;br /&gt;
&lt;br /&gt;
= Signals =&lt;br /&gt;
PlotViews provide signals that allow Slicer to respond to user interactions with the Plot canvas:&lt;br /&gt;
&lt;br /&gt;
;void dataSelected(vtkStringArray* mrmlPlotDataIDs, vtkCollection* selectionCol)&lt;br /&gt;
:Signal emitted when a data point or more has been selected. Returns the MRMLPlotDataNodes IDs and the correspective arrays with the data points ids (vtkIdTypeArray).&lt;br /&gt;
&lt;br /&gt;
= Future Work =&lt;br /&gt;
* Adding to VTKPlots the possibility to plot errorbars.&lt;br /&gt;
* Add categorical and date labels to the Bar plotting (analogous to the CHART infrastructure)&lt;br /&gt;
* More signals?&lt;br /&gt;
* Add 3D Plots (vtkChartXYZ)&lt;br /&gt;
* Add Click and Drag action for multiple selected points&lt;/div&gt;</summary>
		<author><name>Inorton</name></author>
		
	</entry>
	<entry>
		<id>https://www.slicer.org/w/index.php?title=Documentation/Nightly/SlicerApplication/HardwareConfiguration&amp;diff=59133</id>
		<title>Documentation/Nightly/SlicerApplication/HardwareConfiguration</title>
		<link rel="alternate" type="text/html" href="https://www.slicer.org/w/index.php?title=Documentation/Nightly/SlicerApplication/HardwareConfiguration&amp;diff=59133"/>
		<updated>2018-06-26T13:30:43Z</updated>

		<summary type="html">&lt;p&gt;Inorton: /* Recommended OS versions */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;noinclude&amp;gt;{{documentation/versioncheck}}&amp;lt;/noinclude&amp;gt;&lt;br /&gt;
&amp;lt;!-- ---------------------------- --&amp;gt;&lt;br /&gt;
{{documentation/{{documentation/version}}/slicerapplication-header}}&lt;br /&gt;
&amp;lt;!-- ---------------------------- --&amp;gt;&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
=Recommended Hardware Configuration=&lt;br /&gt;
* Computers running 3D Slicer need enough memory and graphics capabilities to hold both the original data and the processing results in their memory.&lt;br /&gt;
* Memory: more than '''4GB''' (8 or more is recommended).&lt;br /&gt;
* Display: a minimum resolution of '''1024 by 768''' (1280 by 1024 or better is recommended).&lt;br /&gt;
* '''Dedicated''' graphics hardware and memory (1GB is recommended).&lt;br /&gt;
* Many computations in Slicer are multi-threaded and will benefit from multi core, multi CPU configurations.&lt;br /&gt;
* Interface device: a three button mouse with scroll wheel is recommended. For other devices, see [[Documentation/{{documentation/version}}/SlicerApplication/MouseandKeyboardShortcuts#Rotate.2C_Zoom.2C_Pan|this guide]].&lt;br /&gt;
* Internet connection to access online documentation of modules and tutorials&lt;br /&gt;
&lt;br /&gt;
= Recommended OS versions =&lt;br /&gt;
&lt;br /&gt;
* Windows 7 or later, 64bit&lt;br /&gt;
&lt;br /&gt;
* Mac OS X Lion&lt;br /&gt;
** On Mac OS X Maverick - Make sure to install this update: http://support.apple.com/kb/DL1754&lt;br /&gt;
&lt;br /&gt;
* Linux: recent versions of popular distributions should work.  Ubuntu and Fedora are the most widely used distribution among the developers. The SlicerPreview nightly build system runs CentOS 7.&lt;br /&gt;
&lt;br /&gt;
=32 bit versus 64 bit=&lt;br /&gt;
Note that many clinical research tasks, such as processing of large CT or MR volumetric datasets, require more memory than can be accommodated with a 32 bit program. We advise the use of the 64 bit versions of the Slicer wherever feasible.&lt;br /&gt;
&lt;br /&gt;
We do not make 32 bit builds available.&lt;br /&gt;
&lt;br /&gt;
=Examples of Working Configurations=&lt;br /&gt;
==Feb 2012==&lt;br /&gt;
The entries below are hardware/OS combinations which will work with the downloaded executable for the current Slicer 4 release. This are just examples of working configurations.&lt;br /&gt;
*Apple: 15-inch MacBook Pro, 2.3 Ghz Intel Core i7, 8GB Memory, AMD Radeon HD 6750M 1024MB, Mac OS X Lion 10.7.3&lt;br /&gt;
*Windows: Generic Desktop, 3.4 GHz Intel Core i7, 16GB Memory, AMD Radeon HD 5700, Windows 7 Professional 64 bit&lt;br /&gt;
*Linux: Dell Precision m4500, Quad-Core Intel Core i7, 16GB Memory, NVIDIA® Quadro® FX 880M, Ubuntu 10.10&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- ---------------------------- --&amp;gt;&lt;br /&gt;
{{documentation/{{documentation/version}}/slicerapplication-footer}}&lt;br /&gt;
&amp;lt;!-- ---------------------------- --&amp;gt;&lt;/div&gt;</summary>
		<author><name>Inorton</name></author>
		
	</entry>
	<entry>
		<id>https://www.slicer.org/w/index.php?title=Documentation/4.8/SlicerApplication/HardwareConfiguration&amp;diff=59132</id>
		<title>Documentation/4.8/SlicerApplication/HardwareConfiguration</title>
		<link rel="alternate" type="text/html" href="https://www.slicer.org/w/index.php?title=Documentation/4.8/SlicerApplication/HardwareConfiguration&amp;diff=59132"/>
		<updated>2018-06-26T13:30:10Z</updated>

		<summary type="html">&lt;p&gt;Inorton: /* Recommended OS versions */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;noinclude&amp;gt;{{documentation/versioncheck}}&amp;lt;/noinclude&amp;gt;&lt;br /&gt;
&amp;lt;!-- ---------------------------- --&amp;gt;&lt;br /&gt;
{{documentation/{{documentation/version}}/slicerapplication-header}}&lt;br /&gt;
&amp;lt;!-- ---------------------------- --&amp;gt;&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
=Recommended Hardware Configuration=&lt;br /&gt;
* Computers running 3D Slicer need enough memory and graphics capabilities to hold both the original data and the processing results in their memory.&lt;br /&gt;
* Memory: more than '''4GB''' (8 or more is recommended).&lt;br /&gt;
* Display: a minimum resolution of '''1024 by 768''' (1280 by 1024 or better is recommended).&lt;br /&gt;
* '''Dedicated''' graphics hardware and memory (1GB is recommended).&lt;br /&gt;
* Many computations in Slicer are multi-threaded and will benefit from multi core, multi CPU configurations.&lt;br /&gt;
* Interface device: a three button mouse with scroll wheel is recommended. For other devices, see [[Documentation/{{documentation/version}}/SlicerApplication/MouseandKeyboardShortcuts#Rotate.2C_Zoom.2C_Pan|this guide]].&lt;br /&gt;
* Internet connection to access online documentation of modules and tutorials&lt;br /&gt;
&lt;br /&gt;
= Recommended OS versions =&lt;br /&gt;
&lt;br /&gt;
* Windows 7 or later, 64bit&lt;br /&gt;
&lt;br /&gt;
* Mac OS X Lion&lt;br /&gt;
** On Mac OS X Maverick - Make sure to install this update: http://support.apple.com/kb/DL1754&lt;br /&gt;
&lt;br /&gt;
* Linux: recent versions of popular distributions should work.  Ubuntu and Fedora are the most widely used distribution among the developers.&lt;br /&gt;
&lt;br /&gt;
=32 bit versus 64 bit=&lt;br /&gt;
Note that many clinical research tasks, such as processing of large CT or MR volumetric datasets, require more memory than can be accommodated with a 32 bit program. We advise the use of the 64 bit versions of the Slicer wherever feasible.&lt;br /&gt;
&lt;br /&gt;
We do not make 32 bit builds available.&lt;br /&gt;
&lt;br /&gt;
=Examples of Working Configurations=&lt;br /&gt;
==Feb 2012==&lt;br /&gt;
The entries below are hardware/OS combinations which will work with the downloaded executable for the current Slicer 4 release. This are just examples of working configurations.&lt;br /&gt;
*Apple: 15-inch MacBook Pro, 2.3 Ghz Intel Core i7, 8GB Memory, AMD Radeon HD 6750M 1024MB, Mac OS X Lion 10.7.3&lt;br /&gt;
*Windows: Generic Desktop, 3.4 GHz Intel Core i7, 16GB Memory, AMD Radeon HD 5700, Windows 7 Professional 64 bit&lt;br /&gt;
*Linux: Dell Precision m4500, Quad-Core Intel Core i7, 16GB Memory, NVIDIA® Quadro® FX 880M, Ubuntu 10.10&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- ---------------------------- --&amp;gt;&lt;br /&gt;
{{documentation/{{documentation/version}}/slicerapplication-footer}}&lt;br /&gt;
&amp;lt;!-- ---------------------------- --&amp;gt;&lt;/div&gt;</summary>
		<author><name>Inorton</name></author>
		
	</entry>
	<entry>
		<id>https://www.slicer.org/w/index.php?title=Documentation/4.8/SlicerApplication/HardwareConfiguration&amp;diff=59131</id>
		<title>Documentation/4.8/SlicerApplication/HardwareConfiguration</title>
		<link rel="alternate" type="text/html" href="https://www.slicer.org/w/index.php?title=Documentation/4.8/SlicerApplication/HardwareConfiguration&amp;diff=59131"/>
		<updated>2018-06-26T13:29:37Z</updated>

		<summary type="html">&lt;p&gt;Inorton: /* Recommended OS versions */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;noinclude&amp;gt;{{documentation/versioncheck}}&amp;lt;/noinclude&amp;gt;&lt;br /&gt;
&amp;lt;!-- ---------------------------- --&amp;gt;&lt;br /&gt;
{{documentation/{{documentation/version}}/slicerapplication-header}}&lt;br /&gt;
&amp;lt;!-- ---------------------------- --&amp;gt;&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
=Recommended Hardware Configuration=&lt;br /&gt;
* Computers running 3D Slicer need enough memory and graphics capabilities to hold both the original data and the processing results in their memory.&lt;br /&gt;
* Memory: more than '''4GB''' (8 or more is recommended).&lt;br /&gt;
* Display: a minimum resolution of '''1024 by 768''' (1280 by 1024 or better is recommended).&lt;br /&gt;
* '''Dedicated''' graphics hardware and memory (1GB is recommended).&lt;br /&gt;
* Many computations in Slicer are multi-threaded and will benefit from multi core, multi CPU configurations.&lt;br /&gt;
* Interface device: a three button mouse with scroll wheel is recommended. For other devices, see [[Documentation/{{documentation/version}}/SlicerApplication/MouseandKeyboardShortcuts#Rotate.2C_Zoom.2C_Pan|this guide]].&lt;br /&gt;
* Internet connection to access online documentation of modules and tutorials&lt;br /&gt;
&lt;br /&gt;
= Recommended OS versions =&lt;br /&gt;
&lt;br /&gt;
* Windows 7 or later, 64bit&lt;br /&gt;
&lt;br /&gt;
* Mac OS X Lion&lt;br /&gt;
** On Mac OS X Maverick - Make sure to install this update: http://support.apple.com/kb/DL1754&lt;br /&gt;
&lt;br /&gt;
* Linux: recent versions of popular distributions should work.  Ubuntu and Fedora are the most widely used distribution among the developers. The SlicerPreview nightly build system runs CentOS 7.&lt;br /&gt;
&lt;br /&gt;
=32 bit versus 64 bit=&lt;br /&gt;
Note that many clinical research tasks, such as processing of large CT or MR volumetric datasets, require more memory than can be accommodated with a 32 bit program. We advise the use of the 64 bit versions of the Slicer wherever feasible.&lt;br /&gt;
&lt;br /&gt;
We do not make 32 bit builds available.&lt;br /&gt;
&lt;br /&gt;
=Examples of Working Configurations=&lt;br /&gt;
==Feb 2012==&lt;br /&gt;
The entries below are hardware/OS combinations which will work with the downloaded executable for the current Slicer 4 release. This are just examples of working configurations.&lt;br /&gt;
*Apple: 15-inch MacBook Pro, 2.3 Ghz Intel Core i7, 8GB Memory, AMD Radeon HD 6750M 1024MB, Mac OS X Lion 10.7.3&lt;br /&gt;
*Windows: Generic Desktop, 3.4 GHz Intel Core i7, 16GB Memory, AMD Radeon HD 5700, Windows 7 Professional 64 bit&lt;br /&gt;
*Linux: Dell Precision m4500, Quad-Core Intel Core i7, 16GB Memory, NVIDIA® Quadro® FX 880M, Ubuntu 10.10&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- ---------------------------- --&amp;gt;&lt;br /&gt;
{{documentation/{{documentation/version}}/slicerapplication-footer}}&lt;br /&gt;
&amp;lt;!-- ---------------------------- --&amp;gt;&lt;/div&gt;</summary>
		<author><name>Inorton</name></author>
		
	</entry>
	<entry>
		<id>https://www.slicer.org/w/index.php?title=Documentation/Nightly/ModulesMetadata&amp;diff=59124</id>
		<title>Documentation/Nightly/ModulesMetadata</title>
		<link rel="alternate" type="text/html" href="https://www.slicer.org/w/index.php?title=Documentation/Nightly/ModulesMetadata&amp;diff=59124"/>
		<updated>2018-06-22T17:42:28Z</updated>

		<summary type="html">&lt;p&gt;Inorton: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;noinclude&amp;gt;{{documentation/versioncheck}}&amp;lt;/noinclude&amp;gt;&lt;br /&gt;
&amp;lt;includeonly&amp;gt;&lt;br /&gt;
Name, XMLDescriptionURL&lt;br /&gt;
ACPCTransform, http://viewvc.slicer.org/viewvc.cgi/Slicer4/trunk/Modules/CLI/ACPCTransform/ACPCTransform.xml?revision=22697&amp;amp;view=co&lt;br /&gt;
AddScalarVolumes, http://viewvc.slicer.org/viewvc.cgi/Slicer4/trunk/Modules/CLI/AddScalarVolumes/AddScalarVolumes.xml?revision=19194&amp;amp;view=co&lt;br /&gt;
AffineRegistration, http://viewvc.slicer.org/viewvc.cgi/Slicer4/trunk/Modules/CLI/AffineRegistration/AffineRegistration.xml?revision=19194&amp;amp;view=co&lt;br /&gt;
Annotations, http://viewvc.slicer.org/viewvc.cgi/Slicer4/trunk/Modules/Loadable/Annotations/Documentation/Annotations.xml?view=co&amp;amp;pathrev=25061&lt;br /&gt;
BRAINSDemonWarp, https://raw.github.com/BRAINSia/BRAINSTools/master/BRAINSDemonWarp/BRAINSDemonWarp.xml&lt;br /&gt;
BRAINSFit, https://raw.github.com/BRAINSia/BRAINSTools/master/BRAINSFit/BRAINSFit.xml&lt;br /&gt;
BRAINSResample, https://raw.github.com/BRAINSia/BRAINSTools/master/BRAINSResample/BRAINSResample.xml&lt;br /&gt;
BSplineDeformableRegistration, http://viewvc.slicer.org/viewvc.cgi/Slicer4/trunk/Modules/CLI/BSplineDeformableRegistration/BSplineDeformableRegistration.xml?revision=19194&amp;amp;view=co&lt;br /&gt;
BSplineToDeformationField, http://viewvc.slicer.org/viewvc.cgi/Slicer4/trunk/Modules/CLI/BSplineToDeformationField/BSplineToDeformationField.xml?revision=19194&amp;amp;view=co&lt;br /&gt;
Cameras, http://viewvc.slicer.org/viewvc.cgi/Slicer4/trunk/Modules/Core/Cameras/Documentation/Cameras.xml?revision=19238&amp;amp;view=co&lt;br /&gt;
CastScalarVolume, http://viewvc.slicer.org/viewvc.cgi/Slicer4/trunk/Modules/CLI/CastScalarVolume/CastScalarVolume.xml?revision=19608&amp;amp;view=co&lt;br /&gt;
CheckerBoardFilter, http://viewvc.slicer.org/viewvc.cgi/Slicer4/trunk/Modules/CLI/CheckerBoardFilter/CheckerBoardFilter.xml?revision=19170&amp;amp;view=co&lt;br /&gt;
CLIModuleTemplate, http://viewvc.slicer.org/viewvc.cgi/Slicer4/trunk/Extensions/Testing/CLIExtensionTemplate/CLIModuleTemplate/CLIModuleTemplate.xml?revision=22715&amp;amp;view=co&lt;br /&gt;
CreateDICOMSeries, http://viewvc.slicer.org/viewvc.cgi/Slicer4/trunk/Modules/CLI/CreateDICOMSeries/CreateDICOMSeries.xml?revision=19171&amp;amp;view=co&lt;br /&gt;
CurvatureAnisotropicDiffusion, http://viewvc.slicer.org/viewvc.cgi/Slicer4/trunk/Modules/CLI/CurvatureAnisotropicDiffusion/CurvatureAnisotropicDiffusion.xml?revision=18864&amp;amp;view=co&lt;br /&gt;
Data, http://viewvc.slicer.org/viewvc.cgi/Slicer4/trunk/Modules/Loadable/Data/Documentation/Data.xml?view=co&amp;amp;pathrev=25061&lt;br /&gt;
DICOM, http://viewvc.slicer.org/viewvc.cgi/Slicer4/trunk/Modules/Scripted/Scripts/DICOM.xml?revision=19903&amp;amp;view=co&lt;br /&gt;
DicomToNrrdConverter, http://viewvc.slicer.org/viewvc.cgi/Slicer4/trunk/Modules/CLI/DicomToNrrdConverter/DicomToNrrdConverter.xml?revision=19089&amp;amp;view=co&lt;br /&gt;
DiffusionTensorScalarMeasurements, https://raw.githubusercontent.com/SlicerDMRI/SlicerDMRI/master/Modules/CLI/DiffusionTensorScalarMeasurements/DiffusionTensorScalarMeasurements.xml&lt;br /&gt;
DiffusionWeightedVolumeMasking, https://raw.githubusercontent.com/SlicerDMRI/SlicerDMRI/master/Modules/CLI/DiffusionWeightedVolumeMasking/DiffusionWeightedVolumeMasking.xml&lt;br /&gt;
DTIExport, http://viewvc.slicer.org/viewvc.cgi/Slicer4/trunk/Modules/CLI/DTIImportExport/DTIexport.xml?revision=19928&amp;amp;view=co&lt;br /&gt;
DTIImport, http://viewvc.slicer.org/viewvc.cgi/Slicer4/trunk/Modules/CLI/DTIImportExport/DTIimport.xml?revision=19928&amp;amp;view=co&lt;br /&gt;
DWICompare, http://viewvc.slicer.org/viewvc.cgi/Slicer4/trunk/Modules/CLI/DicomToNrrdConverter/ExtendedTesting/DWICompare.xml?revision=18864&amp;amp;view=co&lt;br /&gt;
DWIConverter, https://raw.githubusercontent.com/BRAINSia/BRAINSTools/487208d64667a95ece1a4e4a6aa1f19273108d18/DWIConvert/DWIConvert.xml&lt;br /&gt;
DWModeling, https://raw.githubusercontent.com/SlicerProstate/SlicerProstate/master/DWModeling/DWModeling.xml&lt;br /&gt;
DWIJointRicianLMMSEFilter, http://viewvc.slicer.org/viewvc.cgi/Slicer4/trunk/Modules/CLI/DWIJointRicianLMMSEFilter/DWIJointRicianLMMSEFilter.xml?revision=19197&amp;amp;view=co&lt;br /&gt;
DWIRicianLMMSEFilter, http://viewvc.slicer.org/viewvc.cgi/Slicer4/trunk/Modules/CLI/DWIRicianLMMSEFilter/DWIRicianLMMSEFilter.xml?revision=19197&amp;amp;view=co&lt;br /&gt;
DWIToDTIEstimation, https://raw.githubusercontent.com/SlicerDMRI/SlicerDMRI/master/Modules/CLI/DWIToDTIEstimation/DWIToDTIEstimation.xml&lt;br /&gt;
DWIUnbiasedNonLocalMeansFilter, http://viewvc.slicer.org/viewvc.cgi/Slicer4/trunk/Modules/CLI/DWIUnbiasedNonLocalMeansFilter/DWIUnbiasedNonLocalMeansFilter.xml?revision=19197&amp;amp;view=co&lt;br /&gt;
EncodeSEG, https://raw.githubusercontent.com/QIICR/Reporting/master/SEGSupport/EncodeSEG.xml&lt;br /&gt;
EMSegment_Command-line, http://viewvc.slicer.org/viewvc.cgi/Slicer3/trunk/Modules/EMSegment/CommandLineApplication/EMSegmentCommandLine.xml?revision=16924&amp;amp;view=co&lt;br /&gt;
Endoscopy, http://viewvc.slicer.org/viewvc.cgi/Slicer4/trunk/Modules/Scripted/Scripts/Endoscopy.xml?revision=18864&amp;amp;view=co&lt;br /&gt;
EventBroker, http://viewvc.slicer.org/viewvc.cgi/Slicer4/trunk/Modules/Core/EventBroker/Documentation/EventBroker.xml?revision=19045&amp;amp;view=co&lt;br /&gt;
ExecutionModelTour, http://viewvc.slicer.org/viewvc.cgi/Slicer4/trunk/Modules/CLI/ExecutionModelTour/ExecutionModelTour.xml?revision=19194&amp;amp;view=co&lt;br /&gt;
ExpertAutomatedRegistration, http://viewvc.slicer.org/viewvc.cgi/Slicer4/trunk/Modules/CLI/ExpertAutomatedRegistration/ExpertAutomatedRegistration.xml?revision=19173&amp;amp;view=co&lt;br /&gt;
ExtractSkeleton, http://viewvc.slicer.org/viewvc.cgi/Slicer4/trunk/Modules/CLI/ExtractSkeleton/ExtractSkeleton.xml?revision=18864&amp;amp;view=co&lt;br /&gt;
FiberBundleLabelSelect, https://raw.githubusercontent.com/SlicerDMRI/SlicerDMRI/master/Modules/CLI/FiberBundleLabelSelect/FiberBundleLabelSelect.xml&lt;br /&gt;
FiberTractMeasurements, https://raw.githubusercontent.com/SlicerDMRI/SlicerDMRI/master/Modules/CLI/FiberTractMeasurements/FiberTractMeasurements.xml&lt;br /&gt;
FiducialRegistration, http://viewvc.slicer.org/viewvc.cgi/Slicer4/trunk/Modules/CLI/FiducialRegistration/FiducialRegistration.xml?revision=19173&amp;amp;view=co&lt;br /&gt;
ForegroundMasking, https://raw.github.com/BRAINSia/BRAINSTools/master/BRAINSROIAuto/BRAINSROIAuto.xml&lt;br /&gt;
FreesurferSurfaceSectionExtraction, http://viewvc.slicer.org/viewvc.cgi/Slicer4/trunk/Modules/CLI/FreesurferSurfaceSectionExtraction/FreesurferSurfaceSectionExtraction.xml?revision=18864&amp;amp;view=co&lt;br /&gt;
GaussianBlurImageFilter, http://viewvc.slicer.org/viewvc.cgi/Slicer4/trunk/Modules/CLI/GaussianBlurImageFilter/GaussianBlurImageFilter.xml?revision=19194&amp;amp;view=co&lt;br /&gt;
GradientAnisotropicDiffusion, http://viewvc.slicer.org/viewvc.cgi/Slicer4/trunk/Modules/CLI/GradientAnisotropicDiffusion/GradientAnisotropicDiffusion.xml?revision=18864&amp;amp;view=co&lt;br /&gt;
GrayscaleFillHoleImageFilter, http://viewvc.slicer.org/viewvc.cgi/Slicer4/trunk/Modules/CLI/GrayscaleFillHoleImageFilter/GrayscaleFillHoleImageFilter.xml?revision=19194&amp;amp;view=co&lt;br /&gt;
GrayscaleGrindPeakImageFilter, http://viewvc.slicer.org/viewvc.cgi/Slicer4/trunk/Modules/CLI/GrayscaleGrindPeakImageFilter/GrayscaleGrindPeakImageFilter.xml?revision=19194&amp;amp;view=co&lt;br /&gt;
GrayscaleModelMaker, http://viewvc.slicer.org/viewvc.cgi/Slicer4/trunk/Modules/CLI/GrayscaleModelMaker/GrayscaleModelMaker.xml?revision=18864&amp;amp;view=co&lt;br /&gt;
HistogramMatching, http://viewvc.slicer.org/viewvc.cgi/Slicer4/trunk/Modules/CLI/HistogramMatching/HistogramMatching.xml?revision=18864&amp;amp;view=co&lt;br /&gt;
ImageLabelCombine, http://viewvc.slicer.org/viewvc.cgi/Slicer4/trunk/Modules/CLI/ImageLabelCombine/ImageLabelCombine.xml?revision=18864&amp;amp;view=co&lt;br /&gt;
LabelMapSmoothing, http://viewvc.slicer.org/viewvc.cgi/Slicer4/trunk/Modules/CLI/LabelMapSmoothing/LabelMapSmoothing.xml?revision=18864&amp;amp;view=co&lt;br /&gt;
LinearRegistration, http://viewvc.slicer.org/viewvc.cgi/Slicer4/trunk/Modules/CLI/LinearRegistration/LinearRegistration.xml?revision=19194&amp;amp;view=co&lt;br /&gt;
Markups, http://viewvc.slicer.org/viewvc.cgi/Slicer4/trunk/Modules/Loadable/Markups/Documentation/Markups.xml?view=co&amp;amp;pathrev=25061&lt;br /&gt;
MaskScalarVolume, http://viewvc.slicer.org/viewvc.cgi/Slicer4/trunk/Modules/CLI/MaskScalarVolume/MaskScalarVolume.xml?revision=19608&amp;amp;view=co&lt;br /&gt;
MatlabCommander, https://www.assembla.com/code/slicerrt/subversion/node/blob/trunk/MatlabBridge/src/MatlabCommander/MatlabCommander.xml?raw=1&amp;amp;rev=957&lt;br /&gt;
MedianImageFilter, http://viewvc.slicer.org/viewvc.cgi/Slicer4/trunk/Modules/CLI/MedianImageFilter/MedianImageFilter.xml?revision=19194&amp;amp;view=co&lt;br /&gt;
MergeModels, http://viewvc.slicer.org/viewvc.cgi/Slicer4/trunk/Modules/CLI/MergeModels/MergeModels.xml?revision=22697&amp;amp;view=co&lt;br /&gt;
MeshContourSegmentation, http://viewvc.slicer.org/viewvc.cgi/Slicer4/trunk/Modules/CLI/MeshContourSegmentation/MeshContourSegmentation.xml?revision=19175&amp;amp;view=co&lt;br /&gt;
ModelMaker, http://viewvc.slicer.org/viewvc.cgi/Slicer4/trunk/Modules/CLI/ModelMaker/ModelMaker.xml?revision=22697&amp;amp;view=co&lt;br /&gt;
Models, http://viewvc.slicer.org/viewvc.cgi/Slicer4/trunk/Modules/Loadable/Models/Documentation/Models.xml?revision=25018&amp;amp;view=co&lt;br /&gt;
ModelToLabelMap, http://viewvc.slicer.org/viewvc.cgi/Slicer4/trunk/Modules/CLI/ModelToLabelMap/ModelToLabelMap.xml?revision=22697&amp;amp;view=co&lt;br /&gt;
MRIBiasFieldCorrection, http://viewvc.slicer.org/viewvc.cgi/Slicer4/trunk/Modules/CLI/MRIBiasFieldCorrection/MRIBiasFieldCorrection.xml?revision=18864&amp;amp;view=co&lt;br /&gt;
MultiplyScalarVolumes, http://viewvc.slicer.org/viewvc.cgi/Slicer4/trunk/Modules/CLI/MultiplyScalarVolumes/MultiplyScalarVolumes.xml?revision=19194&amp;amp;view=co&lt;br /&gt;
MultiResolutionAffineRegistration, http://viewvc.slicer.org/viewvc.cgi/Slicer4/trunk/Modules/CLI/MultiResolutionAffineRegistration/MultiResolutionAffineRegistration.xml?revision=19194&amp;amp;view=co&lt;br /&gt;
N4ITKBiasFieldCorrection, http://viewvc.slicer.org/viewvc.cgi/Slicer4/trunk/Modules/CLI/N4ITKBiasFieldCorrection/N4ITKBiasFieldCorrection.xml?revision=22688&amp;amp;view=co&lt;br /&gt;
OrientScalarVolume, http://viewvc.slicer.org/viewvc.cgi/Slicer4/trunk/Modules/CLI/OrientScalarVolume/OrientScalarVolume.xml?revision=19193&amp;amp;view=co&lt;br /&gt;
OtsuThresholdImageFilter, http://viewvc.slicer.org/viewvc.cgi/Slicer4/trunk/Modules/CLI/OtsuThresholdImageFilter/OtsuThresholdImageFilter.xml?revision=19194&amp;amp;view=co&lt;br /&gt;
OtsuThresholdSegmentation, http://viewvc.slicer.org/viewvc.cgi/Slicer4/trunk/Modules/CLI/OtsuThresholdSegmentation/OtsuThresholdSegmentation.xml?revision=18864&amp;amp;view=co&lt;br /&gt;
PETStandardUptakeValueComputation, http://viewvc.slicer.org/viewvc.cgi/Slicer4/trunk/Modules/CLI/PETStandardUptakeValueComputation/PETStandardUptakeValueComputation.xml?revision=19608&amp;amp;view=co&lt;br /&gt;
PkModeling, https://raw.githubusercontent.com/millerjv/PkModeling/master/CLI/PkModeling.xml&lt;br /&gt;
ProbeVolumeWithModel, http://viewvc.slicer.org/viewvc.cgi/Slicer4/trunk/Modules/CLI/ProbeVolumeWithModel/ProbeVolumeWithModel.xml?revision=19194&amp;amp;view=co&lt;br /&gt;
QuadEdgeSurfaceMesher, https://raw.githubusercontent.com/SlicerProstate/SlicerProstate/master/QuadEdgeSurfaceMesher/QuadEdgeSurfaceMesher.xml&lt;br /&gt;
Reformat, http://viewvc.slicer.org/viewvc.cgi/Slicer4/trunk/Modules/Loadable/Reformat/Documentation/Reformat.xml?revision=19165&amp;amp;view=co&lt;br /&gt;
ResampleDTIVolume, http://viewvc.slicer.org/viewvc.cgi/Slicer4/trunk/Modules/CLI/ResampleDTIVolume/ResampleDTIVolume.xml?revision=19197&amp;amp;view=co&lt;br /&gt;
ResampleScalarVectorDWIVolume, http://viewvc.slicer.org/viewvc.cgi/Slicer4/trunk/Modules/CLI/ResampleScalarVectorDWIVolume/ResampleScalarVectorDWIVolume.xml?revision=19186&amp;amp;view=co&lt;br /&gt;
ResampleScalarVolume, http://viewvc.slicer.org/viewvc.cgi/Slicer4/trunk/Modules/CLI/ResampleScalarVolume/ResampleScalarVolume.xml?revision=19185&amp;amp;view=co&lt;br /&gt;
RigidRegistration, http://viewvc.slicer.org/viewvc.cgi/Slicer4/trunk/Modules/CLI/RigidRegistration/RigidRegistration.xml?revision=19194&amp;amp;view=co&lt;br /&gt;
RobustStatisticsSegmenter, http://viewvc.slicer.org/viewvc.cgi/Slicer4/trunk/Modules/CLI/RobustStatisticsSegmenter/RobustStatisticsSegmenter.xml?revision=19198&amp;amp;view=co&lt;br /&gt;
SceneViews, http://viewvc.slicer.org/viewvc.cgi/Slicer4/trunk/Modules/Loadable/SceneViews/Documentation/SceneViews.xml?revision=19608&amp;amp;view=co&lt;br /&gt;
SEG2NRRD, https://raw.githubusercontent.com/QIICR/Reporting/master/SEGSupport/SEG2NRRD.xml&lt;br /&gt;
SegmentationSmoothing, https://raw.githubusercontent.com/SlicerProstate/SlicerProstate/master/SegmentationSmoothing/SegmentationSmoothing.xml&lt;br /&gt;
SimpleRegionGrowingSegmentation, http://viewvc.slicer.org/viewvc.cgi/Slicer4/trunk/Modules/CLI/SimpleRegionGrowingSegmentation/SimpleRegionGrowingSegmentation.xml?revision=22482&amp;amp;view=co&lt;br /&gt;
SubtractScalarVolumes, http://viewvc.slicer.org/viewvc.cgi/Slicer4/trunk/Modules/CLI/SubtractScalarVolumes/SubtractScalarVolumes.xml?revision=19194&amp;amp;view=co&lt;br /&gt;
Tables, http://viewvc.slicer.org/viewvc.cgi/Slicer4/trunk/Modules/Loadable/Tables/Documentation/Tables.xml?revision=24790&amp;amp;view=co&lt;br /&gt;
ThresholdScalarVolume, http://viewvc.slicer.org/viewvc.cgi/Slicer4/trunk/Modules/CLI/ThresholdScalarVolume/ThresholdScalarVolume.xml?revision=22407&amp;amp;view=co&lt;br /&gt;
TractographyDICOMLoad, https://raw.githubusercontent.com/SlicerDMRI/SlicerDMRI/master/Modules/Loadable/TractIO/TractIOCLI/DICOMTract_to_VTK.xml&lt;br /&gt;
TractographyDICOMSave, https://raw.githubusercontent.com/SlicerDMRI/SlicerDMRI/master/Modules/Loadable/TractIO/TractIOCLI/VTK_to_DICOMTract.xml&lt;br /&gt;
TractographyLabelMapSeeding, https://raw.githubusercontent.com/SlicerDMRI/SlicerDMRI/master/Modules/CLI/TractographyLabelMapSeeding/TractographyLabelMapSeeding.xml&lt;br /&gt;
Transforms, http://viewvc.slicer.org/viewvc.cgi/Slicer4/trunk/Modules/Loadable/Transforms/Documentation/Transforms.xml?view=co&amp;amp;pathrev=25061&lt;br /&gt;
UKFTractography, https://raw.githubusercontent.com/pnlbwh/ukftractography/master/UKFTractography/UKFTractography.xml&lt;br /&gt;
ViewControllers, http://viewvc.slicer.org/viewvc.cgi/Slicer4/trunk/Modules/Loadable/ViewControllers/Documentation/ViewControllers.xml?revision=18864&amp;amp;view=co&lt;br /&gt;
VolumeRendering, http://viewvc.slicer.org/viewvc.cgi/Slicer4/trunk/Modules/Loadable/VolumeRendering/Documentation/VolumeRendering.xml?view=co&amp;amp;pathrev=25061&lt;br /&gt;
Volumes, http://viewvc.slicer.org/viewvc.cgi/Slicer4/trunk/Modules/Loadable/Volumes/Documentation/Volumes.xml?view=co&amp;amp;pathrev=25061&lt;br /&gt;
VotingBinaryHoleFillingImageFilter, http://viewvc.slicer.org/viewvc.cgi/Slicer4/trunk/Modules/CLI/VotingBinaryHoleFillingImageFilter/VotingBinaryHoleFillingImageFilter.xml?revision=19194&amp;amp;view=co&lt;br /&gt;
&amp;lt;/includeonly&amp;gt;&amp;lt;noinclude&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{ambox&lt;br /&gt;
| type  = warning&lt;br /&gt;
| text  = To force MediaWiki to clear the cached version of a given page, or to force the page to be redisplayed from its source.&amp;lt;br&amp;gt; Add '''?action=purge''' to the URL of the page you are viewing. For more details, click [http://www.mediawiki.org/wiki/Manual:Purge here].&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{#get_web_data:&lt;br /&gt;
url={{fullurl:Special:GetData/Documentation/{{documentation/version}}/ModulesMetadata}}&lt;br /&gt;
|format=CSV with header|data=name=Name,xmldescriptionurl=XMLDescriptionURL}}&lt;br /&gt;
{| class=&amp;quot;wikitable sortable&amp;quot;&lt;br /&gt;
! Name&lt;br /&gt;
! XMLDescriptionURL {{#for_external_table:&amp;lt;nowiki/&amp;gt;&lt;br /&gt;
{{!}}-&lt;br /&gt;
{{!}} {{{name}}}&lt;br /&gt;
{{!}} {{{xmldescriptionurl}}} }}&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
{{#get_web_data:&lt;br /&gt;
url={{fullurl:Special:GetData/Documentation/{{documentation/version}}/ModulesMetadata}}&lt;br /&gt;
|format=CSV with header&lt;br /&gt;
|data=GaussianBlurImageFilterXMLDescriptionURL=XMLDescriptionURL&lt;br /&gt;
|filters=Name=GaussianBlurImageFilter&lt;br /&gt;
}}&lt;br /&gt;
* {{#external_value:GaussianBlurImageFilterXMLDescriptionURL}}&lt;br /&gt;
&amp;lt;/noinclude&amp;gt;&lt;/div&gt;</summary>
		<author><name>Inorton</name></author>
		
	</entry>
	<entry>
		<id>https://www.slicer.org/w/index.php?title=Documentation/Nightly/Modules/UKFTractography&amp;diff=59123</id>
		<title>Documentation/Nightly/Modules/UKFTractography</title>
		<link rel="alternate" type="text/html" href="https://www.slicer.org/w/index.php?title=Documentation/Nightly/Modules/UKFTractography&amp;diff=59123"/>
		<updated>2018-06-22T17:41:27Z</updated>

		<summary type="html">&lt;p&gt;Inorton: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;noinclude&amp;gt;{{documentation/versioncheck}}&amp;lt;/noinclude&amp;gt;&lt;br /&gt;
&amp;lt;!-- ---------------------------- --&amp;gt;&lt;br /&gt;
{{documentation/{{documentation/version}}/module-header}}&lt;br /&gt;
&amp;lt;!-- ---------------------------- --&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- ---------------------------- --&amp;gt;&lt;br /&gt;
{{documentation/{{documentation/version}}/module-section|Introduction and Acknowledgements}}&lt;br /&gt;
{{documentation/{{documentation/version}}/module-introduction-start|{{documentation/modulename}}}}&lt;br /&gt;
{{documentation/{{documentation/version}}/module-introduction-row}}&lt;br /&gt;
&lt;br /&gt;
{{documentation/{{documentation/version}}/module-acknowledgements}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Contact:  &amp;lt;email&amp;gt;slicer-users@bwh.harvard.edu&amp;lt;/email&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
Website: https://github.com/pnlbwh/ukftractography&amp;lt;br&amp;gt;&lt;br /&gt;
Website: http://slicerdmri.github.io/&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{{documentation/{{documentation/version}}/module-introduction-row}}&lt;br /&gt;
{{documentation/{{documentation/version}}/module-introduction-logo-gallery&lt;br /&gt;
|Image:SlicerDMRIScreenshot.jpg|SlicerDMRI&lt;br /&gt;
|Image:NAC-logo.png|NAC&lt;br /&gt;
|Image:UKF 1.png|Arcuate fasciculus (AF) tract in the setting of edema [Chen et al, 2015]&lt;br /&gt;
|Image:UKF 2.png|Corpus callosum (CC) tract&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{documentation/{{documentation/version}}/module-introduction-end}}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- ---------------------------- --&amp;gt;&lt;br /&gt;
{{documentation/{{documentation/version}}/module-section|Module Description}}&lt;br /&gt;
&lt;br /&gt;
{{documentation/{{documentation/version}}/module-description}}&lt;br /&gt;
&lt;br /&gt;
For additional references, please see below (References section).&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- ---------------------------- --&amp;gt;&lt;br /&gt;
{{documentation/{{documentation/version}}/module-section|Use Cases}}&lt;br /&gt;
By default, this module uses a tensor model (either one or two tensors). The default tensor model is a cylinder: both smaller eigenvalues are equal. The NODDI model can also be used.&lt;br /&gt;
* 1-Tensor tractography&lt;br /&gt;
* 1-Tensor tractography with free water&lt;br /&gt;
* 2-Tensor tractography&lt;br /&gt;
* 2-Tensor tractography with free water&lt;br /&gt;
* Neurite orientation dispersion and density imaging (NODDI)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- ---------------------------- --&amp;gt;&lt;br /&gt;
{{documentation/{{documentation/version}}/module-section|Tutorials}}&lt;br /&gt;
* UKF Tractography tutorial: https://www.slicer.org/slicerWiki/index.php/Documentation/Nightly/Training#UKF&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- ---------------------------- --&amp;gt;&lt;br /&gt;
{{documentation/{{documentation/version}}/module-section|Panels and their use}}&lt;br /&gt;
&lt;br /&gt;
{{documentation/{{documentation/version}}/module-parametersdescription}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- ---------------------------- --&amp;gt;&lt;br /&gt;
{{documentation/{{documentation/version}}/module-section|Similar Modules}}&lt;br /&gt;
* Tractography Seeding&lt;br /&gt;
* Tractography ROI Seeding&lt;br /&gt;
* Diffusion Tensor Estimation&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- ---------------------------- --&amp;gt;&lt;br /&gt;
{{documentation/{{documentation/version}}/module-section|References}}&lt;br /&gt;
* Reference for 2-tensor tractography: &lt;br /&gt;
** Malcolm, J.G., Shenton, M.E. and Rathi, Y., 2010. [http://www.ncbi.nlm.nih.gov/pubmed/20805043 Filtered multitensor tractography. IEEE transactions on medical imaging, 29(9), pp.1664-1675].&lt;br /&gt;
* Reference for 1-tensor and 2-tensor + free-water: &lt;br /&gt;
** Baumgartner C, Michailovich O, Levitt J, Pasternak O, Bouix S, Westin C, Rathi Y. [http://cmic.cs.ucl.ac.uk/cdmri12/pdfs/o1_3.pdf A unified tractography framework for comparing diffusion models on clinical scans. In Computational Diffusion MRI Workshop of MICCAI, Nice 2012 (pp. 27-32).]&lt;br /&gt;
* Reference for using UKF in clinical imaging data from tumor patients with edema: &lt;br /&gt;
** Chen Z, Tie Y, Olubiyi O, Rigolo L, Mehrtash A, Norton I, Pasternak O, Rathi Y, Golby AJ, O'Donnell LJ. [http://www.ncbi.nlm.nih.gov/pubmed/26082890 Reconstruction of the arcuate fasciculus for surgical planning in the setting of peritumoral edema using two-tensor unscented Kalman filter tractography. NeuroImage: Clinical. 2015 Dec 31;7:815-22].&lt;br /&gt;
* Reference for NODDI UKF tractography:&lt;br /&gt;
** Reddy, C.P. and Rathi, Y., 2016. [http://www.ncbi.nlm.nih.gov/pubmed/27147956 Joint Multi-Fiber NODDI Parameter Estimation and Tractography Using the Unscented Information Filter. Frontiers in Neuroscience, 10].&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- ---------------------------- --&amp;gt;&lt;br /&gt;
{{documentation/{{documentation/version}}/module-section|Information for Developers}}&lt;br /&gt;
* https://github.com/pnlbwh/ukftractography&lt;br /&gt;
* https://www.nitrc.org/projects/ukftractography&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- ---------------------------- --&amp;gt;&lt;br /&gt;
&amp;lt;!-- {{documentation/{{documentation/version}}/module-footer}} --&amp;gt;&lt;br /&gt;
&amp;lt;!-- ---------------------------- --&amp;gt;&lt;/div&gt;</summary>
		<author><name>Inorton</name></author>
		
	</entry>
	<entry>
		<id>https://www.slicer.org/w/index.php?title=Documentation/Nightly/Training&amp;diff=59108</id>
		<title>Documentation/Nightly/Training</title>
		<link rel="alternate" type="text/html" href="https://www.slicer.org/w/index.php?title=Documentation/Nightly/Training&amp;diff=59108"/>
		<updated>2018-06-13T18:44:43Z</updated>

		<summary type="html">&lt;p&gt;Inorton: /* Slicer4 Neurosurgical Planning Tutorial */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;noinclude&amp;gt;{{documentation/versioncheck}}&amp;lt;/noinclude&amp;gt;&lt;br /&gt;
=Introduction: Slicer {{documentation/version}} Tutorials=&lt;br /&gt;
&lt;br /&gt;
*This page contains &amp;quot;How to&amp;quot; tutorials with matched sample data sets. They demonstrate how to use the 3D Slicer environment (version {{documentation/version}} release) to accomplish certain tasks. &lt;br /&gt;
*For tutorials for other versions of Slicer, please visit the [[Training| Slicer training portal]].&lt;br /&gt;
*For &amp;quot;reference manual&amp;quot; style documentation, please visit the [[Documentation/{{documentation/version}}|Slicer {{documentation/version}} documentation page]]&lt;br /&gt;
*For questions related to the Slicer4 Training Compendium, please send an e-mail to '''[http://www.na-mic.org/Wiki/index.php/User:SPujol Sonia Pujol, Ph.D., Director of Training of 3D Slicer.]'''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
* Some of these tutorials are based on older releases of 3D Slicer.  The concepts are still useful but bear in mind that some interface elements and features will be different in updated versions.&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
=General Introduction=&lt;br /&gt;
&lt;br /&gt;
==Slicer Welcome Tutorial==&lt;br /&gt;
{|width=&amp;quot;100%&amp;quot;&lt;br /&gt;
|&lt;br /&gt;
*The [[media:SlicerWelcome-tutorial_Slicer4.5.pdf|SlicerWelcome tutorial]] is an introduction to Slicer based on the Welcome module.&lt;br /&gt;
*Author: Sonia Pujol, Ph.D.&lt;br /&gt;
*Audience: First time users who want a general introduction to the software.&lt;br /&gt;
*Modules: Welcome to Slicer, Sample Data&lt;br /&gt;
*Based on: 3D Slicer version 4.6&lt;br /&gt;
|align=&amp;quot;right&amp;quot;|&lt;br /&gt;
[[image:SlicerWelcome-image.png|250px|SlicerWelcome tutorial]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==Slicer4Minute Tutorial==&lt;br /&gt;
{|width=&amp;quot;100%&amp;quot;&lt;br /&gt;
|&lt;br /&gt;
*The [[media:Slicer4.5minute_SoniaPujol.pdf|Slicer4Minute tutorial]]  is a brief introduction to the advanced 3D visualization capabilities of Slicer 4.5.&lt;br /&gt;
*Author: Sonia Pujol, Ph.D.&lt;br /&gt;
*Audience: First time users who want to discover Slicer in 4 minutes.&lt;br /&gt;
*Modules: Welcome to Slicer, Models&lt;br /&gt;
*Based on: 3D Slicer version 4.5&lt;br /&gt;
*The [[media:Slicer4minute.zip|Slicer4Minute dataset]] contains an MR scan of the brain and 3D reconstructions of the anatomy&lt;br /&gt;
|align=&amp;quot;right&amp;quot;|&lt;br /&gt;
[[image:Slicer4minute-image.png|250px|right|Slicer4Minute tutorial]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==Slicer4 Data Loading and 3D Visualization ==&lt;br /&gt;
{|width=&amp;quot;100%&amp;quot;&lt;br /&gt;
|&lt;br /&gt;
&lt;br /&gt;
* Slicer 4.10&lt;br /&gt;
** The [http://slicer.kitware.com/midas3/download/item/356408/20180430_DataLoadingAndVisualizationTutorial.pdf Data loading and visualization] ([http://slicer.kitware.com/midas3/download/item/356409/20180430_DataLoadingAndVisualizationTutorial.pptx pptx]) course guides through the basics of loading and viewing volumes and 3D models in Slicer 4.10. &lt;br /&gt;
** Author: Csaba Pinter&lt;br /&gt;
** Modules: Welcome to Slicer, Data, Volume Rendering, Models.&lt;br /&gt;
** Audience: End-users&lt;br /&gt;
** Based on: 3D Slicer version 4.10&lt;br /&gt;
** The [http://slicer.kitware.com/midas3/download/?items=330421,1 3DVisualization dataset] contain an MR scan and a series of 3D models of the brain.&lt;br /&gt;
&lt;br /&gt;
* Slicer 4.5&lt;br /&gt;
** The [[Media:3DDataLoadingandVisualization_Slicer4.5_SoniaPujol.pdf | Data loading and 3D visualization]] course guides through the basics of loading and viewing volumes and 3D models in Slicer 4.5. &lt;br /&gt;
** Author: Sonia Pujol, Ph.D.&lt;br /&gt;
** Modules: Welcome to Slicer, Sample Data, Models.&lt;br /&gt;
** Audience: End-users&lt;br /&gt;
** Based on: 3D Slicer version 4.5&lt;br /&gt;
** The [http://slicer.kitware.com/midas3/download/?items=330421,1 3DVisualization dataset] contain an MR scan and a series of 3D models of the brain.&lt;br /&gt;
|align=&amp;quot;right&amp;quot;|&lt;br /&gt;
[[Image:20180426_DataLoadingAndVisualizationTutorial.png|right|250px|]]&lt;br /&gt;
[[Image:Slicer4DataLoading_tutorial.png|right|250px|]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=Tutorials for software developers=&lt;br /&gt;
&lt;br /&gt;
== Slicer4 Programming Tutorial ==&lt;br /&gt;
{|width=&amp;quot;100%&amp;quot;&lt;br /&gt;
|&lt;br /&gt;
*The [https://www.dropbox.com/s/wrhrvvmplosiis1/Slicer4_ProgrammingTutorial_SPujol-SPieper_Nightly.pdf?dl=0# Slicer Programming tutorial] guides through the integration of a python module in Slicer4. &lt;br /&gt;
*Author: Sonia Pujol, Ph.D., Steve Pieper, Ph.D.&lt;br /&gt;
*Audience: Developers&lt;br /&gt;
*Based on: 3D Slicer version 4.7&lt;br /&gt;
*The [https://www.dropbox.com/s/6yxu8qepmvywk0n/HelloPython_Nightly.zip?dl=0 HelloPython dataset] contains sample data set (MR scan of the brain) and complete Python module examples.&lt;br /&gt;
|align=&amp;quot;right&amp;quot;|&lt;br /&gt;
[[Image:HelloPythonTutorial.png|right|250px|]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
For additional Python scripts examples, please visit the [[Documentation/{{documentation/version}}/ScriptRepository|Script Repository page]]&lt;br /&gt;
&lt;br /&gt;
==Developing and contributing extensions for 3D Slicer==&lt;br /&gt;
{|width=&amp;quot;100%&amp;quot;&lt;br /&gt;
|&lt;br /&gt;
*The [http://goo.gl/IP4cdg Developing and contributing extensions for 3D Slicer tutorial ] is an introduction to the internals of 3D Slicer and the process of contributing a 3D Slicer extension.&lt;br /&gt;
*Authors: Andrey Fedorov, Jean-Christophe Fillion-Robin, Steve Pieper&lt;br /&gt;
*Audience: Developers&lt;br /&gt;
*Based on: 3D Slicer version 4.4&lt;br /&gt;
|align=&amp;quot;right&amp;quot;|&lt;br /&gt;
[[Image:Contributing3DSlicerExtension.png|right|250px|]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=Specific functions=&lt;br /&gt;
&lt;br /&gt;
==Slicer4 Diffusion Tensor Imaging Tutorial ==&lt;br /&gt;
{|width=&amp;quot;100%&amp;quot;&lt;br /&gt;
|&lt;br /&gt;
*Please visit [http://dmri.slicer.org/docs/ dmri.slicer.org/docs] for the latest documentation of SlicerDMRI.&lt;br /&gt;
*The [https://github.com/SlicerDMRI/slicerdmri.github.io/raw/master/docs/tutorials/DiffusionMRIanalysis.pdf Diffusion Tensor Imaging Tutorial]  course guides through the basics of loading Diffusion Weighted images in Slicer, estimating tensors and generating fiber tracts. &lt;br /&gt;
*Author: Sonia Pujol, Ph.D.&lt;br /&gt;
*Audience: End-users and developers&lt;br /&gt;
*Modules: Data, Volumes, DWI to DTI Estimation, Diffusion Tensor Scalar Measurements, Editor, Markups,Tractography Label Map Seeding, Tractography Interactive Seeding&lt;br /&gt;
*Based on: 3D Slicer version 4.6&lt;br /&gt;
*The [[media:Dti tutorial data.zip|DTI dataset]] contains an MR Diffusion Weighted Imaging scan of the brain.&lt;br /&gt;
|align=&amp;quot;right&amp;quot;|&lt;br /&gt;
[[Image:Slicer4DTI Tutorial.png|right|250px|]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==Slicer4 Neurosurgical Planning Tutorial==&lt;br /&gt;
{|width=&amp;quot;100%&amp;quot;&lt;br /&gt;
|&lt;br /&gt;
*Please visit [http://dmri.slicer.org/docs/ dmri.slicer.org/docs] for the latest documentation of SlicerDMRI.&lt;br /&gt;
*The [http://dmri.slicer.org/tutorials/neurosurgical_planning_dti Neurosurgical Planning tutorial] course guides through the generation of fiber tracts in the vicinity of a tumor.&lt;br /&gt;
*Author: Sonia Pujol, Ph.D., Ron Kikinis, M.D.&lt;br /&gt;
*Audience: End-users and developers&lt;br /&gt;
*Modules: Volumes, Editor, Tractography Label Map Seeding, Tractography Interactive Seeding&lt;br /&gt;
*Based on: 3D Slicer version 4.6&lt;br /&gt;
*The [[Media:WhiteMatterExplorationData.zip| White Matter Exploration datasets]] contains a Diffusion Weighted Imaging scan of  brain tumor patient.&lt;br /&gt;
|align=&amp;quot;right&amp;quot;|&lt;br /&gt;
[[Image:NeurosurgicalPlanningTutorial.png|right|250px|link=http://vimeo.com/67336069]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==Slicer4 3D Visualization of DICOM images for Radiology Applications==&lt;br /&gt;
{|width=&amp;quot;100%&amp;quot;&lt;br /&gt;
|&lt;br /&gt;
*The [[Media:3DSlicer_Dicom_RSNA2015_SoniaPujol.pdf |3D Visualization of DICOM images for Radiology Applications]]  course guides through 3D data loading and visualization of DICOM images for Radiology Applications in Slicer4. &lt;br /&gt;
*Author: Sonia Pujol, Ph.D., Kitt Shaffer, M.D., Ph.D., Ron Kikinis, M.D.&lt;br /&gt;
*Audience: Radiologists and users of Slicer who need a more comprehensive overview over Slicer4 visualization capabilities.&lt;br /&gt;
*Modules: DICOM, Volumes, Volume Rendering, Models.&lt;br /&gt;
*Based on: 3D Slicer version 4.5&lt;br /&gt;
*The [[Media:3DVisualization_DICOM_images_part1.zip‎  | 3DVisualizationDICOM_part1]] and [[Media:3DVisualization_DICOM_images_part2.zip | 3DVisualizationDICOM_part2]] datasets contain a series of MR and CT scans, and 3D models of the brain, lung and liver.&lt;br /&gt;
|align=&amp;quot;right&amp;quot;|&lt;br /&gt;
[[Image:Slicer4RSNA_2.png|right|250px|]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==Slicer4 Quantitative Imaging tutorial==&lt;br /&gt;
{|width=&amp;quot;100%&amp;quot;&lt;br /&gt;
|&lt;br /&gt;
*The [[media:QuantitativeImaging_Slicer4.5.pdf‎ | Slicer4 Quantitative Imaging tutorial]]  guides through the use for Slicer for quantifying small volumetric changes in slow-growing tumors, and for calculating Standardized Uptake Value (SUV) from PET/CT data.&lt;br /&gt;
*Authors: Sonia Pujol, Ph.D., Katarzyna Macura, M.D., Ron Kikinis, M.D.&lt;br /&gt;
*Audience: Radiologists and users of Slicer who need a more comprehensive overview over Slicer4 quantitative imaging capabilities.&lt;br /&gt;
*Modules: Data, Volumes, Models, Change Tracker, PET Standard Uptake Value Computation&lt;br /&gt;
*Based on: 3D Slicer version 4.5&lt;br /&gt;
*The [[media:QuantitativeImaging.zip‎| Quantitative Imaging dataset]]  contains a series of MR and PET/CT data.&lt;br /&gt;
|align=&amp;quot;right&amp;quot;|&lt;br /&gt;
[[Image:Slicer4_QuantitativeImaging.png|right|250px|]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Slicer4 IGT ==&lt;br /&gt;
{|width=&amp;quot;100%&amp;quot;&lt;br /&gt;
|&lt;br /&gt;
*[http://www.slicerigt.org/wp/user-tutorial/ Slicer IGT tutorials]&lt;br /&gt;
*Authors: Tamas Ungi, M.D, Ph.D., Junichi Tokuda, Ph.D.&lt;br /&gt;
*Audience: End-users interested in using Slicer for real-time navigated procedures. E.g. navigated needle insertions or other minimally invasive medical procedures.&lt;br /&gt;
*Modules: SlicerIGT Extension&lt;br /&gt;
*Based on: Slicer4.3.1-2014.09.14&lt;br /&gt;
*Data: [https://onedrive.live.com/redir?resid=7230D4DEC6058018!2937&amp;amp;authkey=!AGQkSCZOwjVYXw8&amp;amp;ithint=folder%2cpptx  Slicer-IGT datasets]&lt;br /&gt;
|align=&amp;quot;right&amp;quot;|&lt;br /&gt;
[[Image:SlicetIGT.png|right|150px|]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Slicer4 Image Segmentation ==&lt;br /&gt;
&lt;br /&gt;
{|width=&amp;quot;100%&amp;quot;&lt;br /&gt;
|&lt;br /&gt;
* Segmentation for 3D printing: shows how to use the Segment Editor module for combining CAD designed parts with patient-specific models.&lt;br /&gt;
** '''[https://discourse.slicer.org/t/new-video-tutorial-for-segment-editor-lumbar-spine-segmentation-for-3d-printing/700 Video tutorial]'''. Author: Hillary Lia.&lt;br /&gt;
** '''[[Documentation/{{documentation/version}}/Training#Segmentation_for_3D_printing|Segmentation for 3D printing Step-by-step tutorial]]'''. Author: Csaba Pinter, MSc&lt;br /&gt;
** Audience: Users and developers interested in segmentation and 3D printing&lt;br /&gt;
** Dataset: [[:File:BasePiece.zip|Phantom base STL model]] Source: [http://perk-software.cs.queensu.ca/plus/doc/nightly/modelcatalog/ PerkLab].&lt;br /&gt;
** Based on: 3D Slicer version 4.7&lt;br /&gt;
|align=&amp;quot;right&amp;quot;|[[Image:20170717_3DPrintingTutorialYoutube.PNG|280px]]&lt;br /&gt;
|---&lt;br /&gt;
|&lt;br /&gt;
* '''[https://youtu.be/BJoIexIvtGo Video tutorial: Whole heart segmentation from cardiac CT]''' shows how to use the Segment Editor module for segmenting heart ventricles, atria, and great vessels from cardiac CT volumes.&lt;br /&gt;
** Author: Andras Lasso, PhD&lt;br /&gt;
** Audience: Users who need to segment heart structures, for example for visualization, quantification, or simulation.&lt;br /&gt;
** Sample data set: http://slicer.kitware.com/midas3/download/bitstream/738905/CTA-cardio2.nrrd&lt;br /&gt;
** Based on: 3D Slicer version 4.8&lt;br /&gt;
|align=&amp;quot;right&amp;quot;|[[Image:WholeHeartSegYoutube.png|280px]]&lt;br /&gt;
|---&lt;br /&gt;
|&lt;br /&gt;
* '''[https://youtu.be/0at15gjk-Ns Video tutorial: Femur and pelvis segmentation from CT]''' shows how to use the Segment Editor module for segmenting pelvis and femur from CT volumes.&lt;br /&gt;
** Author: Andras Lasso, PhD&lt;br /&gt;
** Audience: Users who need to segment bones in CT images for visualization, quantification, or simulation.&lt;br /&gt;
** Sample data set: https://wiki.cancerimagingarchive.net/display/Public/TCGA-PRAD (Subject TCGA-VP-A878)&lt;br /&gt;
** Based on: 3D Slicer version 4.8&lt;br /&gt;
|align=&amp;quot;right&amp;quot;|[[Image:FemurSegmentationYoutube.png|280px]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Slicer4 Image Registration ==&lt;br /&gt;
&lt;br /&gt;
{|width=&amp;quot;100%&amp;quot;&lt;br /&gt;
|&lt;br /&gt;
*The [https://www.slicer.org/slicerWiki/index.php/File:RegistrationTutorial_3DSlicer4.5_spujol.pdf Registration tutorial] shows how to perform intra- and inter-subject registration within Slicer.&lt;br /&gt;
* Authors: Sonia Pujol, Ph.D., Dominik Meier, Ph.D., Ron Kikinis, M.D.&lt;br /&gt;
* Audience: Users and developers interested in image registration&lt;br /&gt;
* Dataset: [[Media:RegistrationData.zip| 3D Slicer Registration Data]]&lt;br /&gt;
|align=&amp;quot;right&amp;quot;|[[File:registration_Slicer4.png|250px]]&lt;br /&gt;
|}&lt;br /&gt;
*Based on: 3D Slicer version 4.5&lt;br /&gt;
See [[Documentation/{{documentation/version}}/Registration/RegistrationLibrary|the Registration Library for worked out registration examples with data]].&lt;br /&gt;
&lt;br /&gt;
==Slicer4 Radiation Therapy Tutorial ==&lt;br /&gt;
&lt;br /&gt;
{|width=&amp;quot;100%&amp;quot;&lt;br /&gt;
|&lt;br /&gt;
* The  [https://github.com/SlicerRt/SlicerRtDoc/raw/master/tutorials/SlicerRT_WorldCongress_TutorialIGRT.pdf SlicerRT tutorial] is an introduction to the Radiation Therapy functionalities of Slicer.&lt;br /&gt;
* Author: Csaba Pinter, Andras Lasso, An Wang, Gregory C. Sharp, David Jaffray, Gabor Fichtinger. &lt;br /&gt;
* Dataset: [http://slicer.kitware.com/midas3/download/item/205404/SlicerRT_WorldCongress_TutorialIGRT_Dataset.zip download] from MIDAS server&lt;br /&gt;
* Based on Slicer 4.7&lt;br /&gt;
|align=&amp;quot;right&amp;quot;|&lt;br /&gt;
&amp;lt;!-- [[Image:TUTORIAL-IMAGE-HERE.png|right|150px|]] --&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Other ==&lt;br /&gt;
&lt;br /&gt;
Additional (non-curated) videos-based demonstrations using 3D Slicer are accessible on  [http://www.youtube.com/results?search_query=3d+slicer&amp;amp;sm=3 You Tube].&lt;br /&gt;
&lt;br /&gt;
= 3D Slicer Tutorial contests=&lt;br /&gt;
&lt;br /&gt;
==Winter 2017 Tutorial contest==&lt;br /&gt;
&lt;br /&gt;
===Segmentation for 3D printing===&lt;br /&gt;
{|width=&amp;quot;100%&amp;quot;&lt;br /&gt;
|&lt;br /&gt;
*The [https://github.com/SlicerRt/SlicerRtDoc/raw/master/tutorials/SegmentationFor3DPrinting_TutorialContestWinter2017.pdf Segmentation for 3D printing Tutorial] ([https://github.com/SlicerRt/SlicerRtDoc/raw/master/tutorials/SegmentationFor3DPrinting_TutorialContestWinter2017.pptx pptx]) is an introduction to the new [[Documentation/{{documentation/version}}/Modules/SegmentEditor|Segment Editor]] module, demonstrated through the popular topic of 3D printing. &lt;br /&gt;
*Author: Csaba Pinter (Queen's University, Canada)&lt;br /&gt;
* [https://www.youtube.com/watch?v=Uht6Fwtr9hE Narrated video version on YouTube].&lt;br /&gt;
*Dataset: [[:File:BasePiece.zip|Phantom base STL model]] Source: [http://perk-software.cs.queensu.ca/plus/doc/nightly/modelcatalog/ PerkLab].&lt;br /&gt;
|align=&amp;quot;right&amp;quot;|&lt;br /&gt;
[[File:SlicerWinterProjectWeek2017-Segmentation-for-3d-printing.png | 200px]]. &lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===Slicer Pathology===&lt;br /&gt;
{|width=&amp;quot;100%&amp;quot;&lt;br /&gt;
|&lt;br /&gt;
*The [[Documentation/{{documentation/version}}/Extensions/SlicerPathology|Slicer Pathology Tutorial]] describes how to use the corresponding tools for automatic and semi-automatic pathology image segmentation.&lt;br /&gt;
*Author: Erich Bremer (Stonybrook), Andriy Fedorov (Brigham and Women’s Hospital)&lt;br /&gt;
*Dataset:  Available directly with the Slicer Pathology Slicer extension.&lt;br /&gt;
|align=&amp;quot;right&amp;quot;|&lt;br /&gt;
[[File:SlicerPathologyScreenShot8.png | 200px]]. &lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===Simple Python Tool for Quality Control of DWI data===&lt;br /&gt;
{|width=&amp;quot;100%&amp;quot;&lt;br /&gt;
|&lt;br /&gt;
*The [http://www.na-mic.org/Wiki/images/3/3a/SimpleDiffusionGradientInformationExtractorTutorial_Chauvin_Jan2017.pptx Simple Multi-shell Diffusion Gradients Information Extractor Tutorial] describes how to use a simple Python script for parsing multi-shell sensitizing gradients information from nifti file format (separated bvecs, bvals files).&lt;br /&gt;
*Author: Laurent Chauvin (ETS Montreal)&lt;br /&gt;
*Dataset:  Not available.&lt;br /&gt;
|align=&amp;quot;right&amp;quot;|&lt;br /&gt;
[[File:SlicerWinterProjectWeek2017-SimpleDiffusionGradientInformationExtractorTutorial.png | 200px]]. &lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===SPHARM-PDM===&lt;br /&gt;
{|width=&amp;quot;100%&amp;quot;&lt;br /&gt;
|&lt;br /&gt;
*The [https://www.nitrc.org/docman/view.php/308/1982/SPHARM-PDM_Tutorial_July2015.pdf SPHARM-PDM Tutorial] describes how to use SPHARM-PDM and ShapePopulationViewer Slicer extensions to respectively compute point-based models using a parametric boundary description for the computing of Shape Analysis and perform the quality control between the different models.&lt;br /&gt;
*Author: Jonathan Perdomo (UNC), Beatriz Paniagua (Kitware Inc.)&lt;br /&gt;
*Dataset:  [https://www.nitrc.org/docman/view.php/308/1981/SPHARM_Tutorial_Data_July2015.zip Tutorial Data]&lt;br /&gt;
|align=&amp;quot;right&amp;quot;|&lt;br /&gt;
[[File:SlicerWinterProjectWeek2017-SPHARM-PDM.png | 200px]]. &lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===Integration of Robot Operating System (ROS) and 3D Slicer using OpenIGTLink===&lt;br /&gt;
{|width=&amp;quot;100%&amp;quot;&lt;br /&gt;
|&lt;br /&gt;
*The [https://www.na-mic.org/Wiki/images/a/ab/ROSIGTLTutorial_Tokuda_Jan2017.pptx Integration of Robot Operating System (ROS) and 3D Slicer using OpenIGTLink Tutorial] describes the software architecture of surgical robot systems and allows to acquire hands-on experience of software-hardware integration for medical robotics.&lt;br /&gt;
*Author: Junichi Tokuda (Brigham and Women’s Hospital)&lt;br /&gt;
*Dataset:  Not available.&lt;br /&gt;
|align=&amp;quot;right&amp;quot;|&lt;br /&gt;
[[File:SlicerWinterProjectWeek2017-Integration-ROS-3DSlicer-OpenIGTLink.png | 200px]]. &lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===Fiber Bundle Volume Measurement===&lt;br /&gt;
{|width=&amp;quot;100%&amp;quot;&lt;br /&gt;
|&lt;br /&gt;
*The [http://www.na-mic.org/Wiki/images/5/57/Fiber_Bundle_Volume_Measurement.pptx Fiber Bundle Volume Measurement Tutorial] aim is to calculate the volume of the fiber bundle that passes through the Corpus Callosum(CC). Following this tutorial, you’ll be able to (1) convert fiber bundles to label map and (2) calculate volume measurements from the fiber bundles.&lt;br /&gt;
*Author: Shun Gong (Shanghai Changzheng Hospital, China)&lt;br /&gt;
*Dataset:  [http://www.na-mic.org/Wiki/images/4/4c/FiberVolume_data.zip Tutorial data]: The following data are provided: Baseline image, Down sampled whole brain tractography (conducted as in the [[Documentation/{{documentation/version}}/Training#Slicer4_Diffusion_Tensor_Imaging_Tutorial|DWI tutorial]] and down-sampled to about 10000 fibers using Tractography Display module), Corpus callosum label map (drawn as in the [[Documentation/{{documentation/version}}/Training#Slicer4_Diffusion_Tensor_Imaging_Tutorial|DWI tutorial]]).&lt;br /&gt;
|align=&amp;quot;right&amp;quot;|&lt;br /&gt;
[[File:SlicerWinterProjectWeek2017-FiberBundleVolumeMeasurements.png | 200px]]. &lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==Winter 2016 Tutorial contest==&lt;br /&gt;
&lt;br /&gt;
===Subject Hierarchy===&lt;br /&gt;
{|width=&amp;quot;100%&amp;quot;&lt;br /&gt;
|&lt;br /&gt;
*The [http://wiki.na-mic.org/Wiki/images/2/27/SubjectHierarchy.TutorialContestWinter2016.pdf Subject Hierarchy] tutorial demonstrates the basic usage and potential of Slicer’s data manager module Subject Hierarchy using a two-timepoint radiotherapy phantom dataset.&lt;br /&gt;
*Author: Csaba Pinter, Queen's University, Canada&lt;br /&gt;
*Dataset:  [http://slicer.kitware.com/midas3/download/item/205404/SlicerRT_WorldCongress_TutorialIGRT_Dataset.zip SlicerRT_WorldCongress_TutorialIGRT_Dataset] The tutorial dataset is a two-timepoint phantom dataset taken from a RANDO head&amp;amp;neck phantom. It contains two studies, the planning one is a DICOM study consisting of a CT grayscale image and radiotherapy data: contours, dose distribution, treatment beams, plan information. The second timepoint consists of a CT NRRD volume and a dose NRRD volume.&lt;br /&gt;
|align=&amp;quot;right&amp;quot;|&lt;br /&gt;
[[File:SubjectHierarchyTutorial.png | 200px]]. &lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===Fiber Bundle Selection and Scalar Measurements===&lt;br /&gt;
{|width=&amp;quot;100%&amp;quot;&lt;br /&gt;
|&lt;br /&gt;
*The [https://github.com/SlicerDMRI/slicerdmri.github.io/raw/master/docs/tutorials/FiberBundleSelectionAndScalarMeasurement.pdf Fiber Bundle Selection and Scalar Measurements] tutorial guides through the use of the Diffusion Bundle Selection module and the Fiber Tract Scalar Measurement module for diffusion MRI tractography data analysis.&lt;br /&gt;
*Author: Fan Zhang, University of Sydney Australia and Brigham and Women's Hospital&lt;br /&gt;
*Dataset:  [[media:FiberBundleSelectionAndScalarMeasurement_TutorialContestWinter2016.zip| Fiber Bundle Selection And Scalar Measurement Tutorial Dataset]]&lt;br /&gt;
|align=&amp;quot;right&amp;quot;|&lt;br /&gt;
[[File:FiberBundleSelectionAndScalarMeasurement_TutorialContestWinter2016_Snapshot.png|200px]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===Plastimatch ===&lt;br /&gt;
{|width=&amp;quot;100%&amp;quot;&lt;br /&gt;
|&lt;br /&gt;
*The [http://www.na-mic.org/Wiki/images/5/5c/Plastimatch_TutorialContestWinter2016.pdf Plastimatch tutorial] guides through registration and wrapping of DICOM and DICOM-RT data using the Plastimatch extension of 3D Slicer.&lt;br /&gt;
*Author: Gregory Sharp, Massachusetts General Hospital&lt;br /&gt;
*Dataset:  [http://www.na-mic.org/Wiki/index.php/File:Plastimatch_TutorialContestWinter2016.zip Plastimatch Tutorial Dataset]&lt;br /&gt;
|align=&amp;quot;right&amp;quot;|&lt;br /&gt;
[[File:PlastimatchTutorial_Winter2016Contest.png|200px]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===UKF ===&lt;br /&gt;
{|width=&amp;quot;100%&amp;quot;&lt;br /&gt;
|&lt;br /&gt;
*The [https://github.com/SlicerDMRI/slicerdmri.github.io/raw/master/docs/tutorials/UKFTractography.pdf UKF tutorial] guides through the use of the Unscented Kalman Filter (UKF) tractography module. &lt;br /&gt;
*Author: Pegah Kahali, Brigham and Women's Hopital&lt;br /&gt;
*Dataset:  [http://www.na-mic.org/Wiki/index.php/File:UKF-Tractography_TutorialContestWinter2016.zip UKF tutorial Dataset]&lt;br /&gt;
|align=&amp;quot;right&amp;quot;|&lt;br /&gt;
[[File:UKF_Winter2016.png|200px]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==Summer 2014 Tutorial contest== &lt;br /&gt;
&lt;br /&gt;
===Cardiac Agatston Tutorial===&lt;br /&gt;
{|width=&amp;quot;100%&amp;quot;&lt;br /&gt;
|&lt;br /&gt;
*[http://wiki.na-mic.org/Wiki/index.php/File:TutorialContest_CardiacAgatstonScoring_2014.pdf  Cardiac Agatston Scoring Tutorial]&lt;br /&gt;
*Authors:   Jessica Forbes, Hans Johnson, University of Iowa&lt;br /&gt;
*Dataset:  [http://wiki.na-mic.org/Wiki/index.php/File:CardiacAgatstonMeasures_TutorialContestSummer2014.zip Cardiac Agatston Scoring Tutorial Dataset]&lt;br /&gt;
|align=&amp;quot;right&amp;quot;|&lt;br /&gt;
[[File:CardiacAgatstonMeasuresModuleScreenshot.jpg| 250px]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===CMR Toolkit LA workflow===&lt;br /&gt;
{|width=&amp;quot;100%&amp;quot;&lt;br /&gt;
|&lt;br /&gt;
*[http://wiki.na-mic.org/Wiki/index.php/File:CMRToolkitLAWorkflow_TutorialContestSummer2014.pdf  CMR Toolkit LA Workflow Tutorial]&lt;br /&gt;
*Authors: Salma Bengali, Josh Cates, University of Utah&lt;br /&gt;
*Dataset:  [http://wiki.na-mic.org/Wiki/index.php/File:CMRToolkitLAWorkflowData_TutorialContestSummer2014.zip CMRToolkitLAWorkflow Dataset]&lt;br /&gt;
|align=&amp;quot;right&amp;quot;|&lt;br /&gt;
[[Image:Utah_SummerContest2014_tutorial.png|300px]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==Summer 2013 Tutorial contest==&lt;br /&gt;
&lt;br /&gt;
===Cardiac MRI Toolkit===&lt;br /&gt;
{|width=&amp;quot;100%&amp;quot;&lt;br /&gt;
|&lt;br /&gt;
*[[Media:Cardiac MRI Toolkit Tutorial Summer2013.pdf|Cardiac MRI Toolkit]]&lt;br /&gt;
*Authors:   Salma Bengali, Josh Cates, SCI, Utah&lt;br /&gt;
*Dataset:  [[Media:Cardiac_MRI_Toolkit_Tutorial_Data.zip|Cardiac MRI Toolkit Tutorial Dataset]]&lt;br /&gt;
|align=&amp;quot;right&amp;quot;|&lt;br /&gt;
[[Image:CMRToolkit_Tutorial_Image.png|250px]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===HelloCLI===&lt;br /&gt;
{|width=&amp;quot;100%&amp;quot;&lt;br /&gt;
|&lt;br /&gt;
*[[Media:Hello_CLI_TutorialContestSummer2013.pdf|HelloCLI]]&lt;br /&gt;
*Authors:   Nadya Shusharina, Greg Sharp, MGH, Boston&lt;br /&gt;
*Dataset:  [[Media:Hello_CLI_TutorialContestSummer2013.zip‎|HelloCLI Dataset]]&lt;br /&gt;
|align=&amp;quot;right&amp;quot;|&lt;br /&gt;
[[Image:Cli_icon.png|300px]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===SlicerRT===&lt;br /&gt;
{|width=&amp;quot;100%&amp;quot;&lt;br /&gt;
|&lt;br /&gt;
*[[Media:SlicerRT_TutorialContestSummer2013.pdf|SlicerRT Tutorial]]&lt;br /&gt;
*Authors:    Csaba Pinter, Andras Lasso (Queen's), Kevin Wang (PMH, Toronto)&lt;br /&gt;
*Dataset:  [[Media:CsabaPinter-SlicerRtTutorial_Namic2013June.zip|SlicerRT Dataset]] &lt;br /&gt;
|align=&amp;quot;right&amp;quot;|&lt;br /&gt;
[[Image:667px-SlicerRT_0.10_IsocenterShiftingEvaluation.png|250px]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===DTIPrep===&lt;br /&gt;
{|width=&amp;quot;100%&amp;quot;&lt;br /&gt;
|&lt;br /&gt;
*[[Media:DTIPrep_TutorialContestSummer2013.pdf|DTIPrep]]&lt;br /&gt;
*Authors:    Dave Welch, SINAPSE, IOWA &lt;br /&gt;
*Dataset:  [[Media:DTIPrepData_TutorialContestSummer2013.zip|DTIPrep Dataset]]&lt;br /&gt;
|align=&amp;quot;right&amp;quot;|&lt;br /&gt;
[[Image:DTIPrep-tutorial.png|250px]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Summer 2012 Tutorial contest == &lt;br /&gt;
&lt;br /&gt;
===Automatic Left Atrial Scar Segmenter ===&lt;br /&gt;
{|width=&amp;quot;100%&amp;quot;&lt;br /&gt;
|&lt;br /&gt;
*[http://wiki.na-mic.org/Wiki/index.php/CARMA-LA-Scar_TutorialContestSummer2012 Automatic Left Atrial Scar Segmenter] &lt;br /&gt;
*Authors:  Greg Gardner, Josh Cates, SCI, Utah&lt;br /&gt;
*Dataset: [http://wiki.na-mic.org/Wiki/index.php/File:CARMA-LA-Scar_TutorialContestSummer2012.zip CARMA-LA-Scar data]&lt;br /&gt;
|align=&amp;quot;right&amp;quot;|&lt;br /&gt;
[[Image:Carma afib auto scar.png|250px]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===Qualitative and quantitative comparison of  two RT dose distributions===&lt;br /&gt;
{|width=&amp;quot;100%&amp;quot;&lt;br /&gt;
|&lt;br /&gt;
*[http://www.na-mic.org/Wiki/index.php/File:PlastimatchDose_TutorialContestSummer2012.pdf Qualitative and quantitative comparison of  two RT dose distributions]&lt;br /&gt;
*Authors:  James Shackleford, Nadya Shusharina, Greg Sharp, MGH&lt;br /&gt;
|align=&amp;quot;right&amp;quot;|&lt;br /&gt;
[[Image:PlastimatchDose.png|250px]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===Dose accumulation for adaptive radiation therapy===&lt;br /&gt;
{|width=&amp;quot;100%&amp;quot;&lt;br /&gt;
|&lt;br /&gt;
*[http://www.na-mic.org/Wiki/index.php/File:DoseAccumulationforAdaptiveRadiationTherapy_TutorialContestSummer2012.pdf Dose accumulation for adaptive radiation therapy]&lt;br /&gt;
*Authors:  Kevin Wang, Csaba Pinter, Andras Lasso, PMH, Queen's&lt;br /&gt;
|align=&amp;quot;right&amp;quot;|&lt;br /&gt;
[[Image:AdaptiveradiationTherapy.png|250px]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===WebGL Export===&lt;br /&gt;
{|width=&amp;quot;100%&amp;quot;&lt;br /&gt;
|&lt;br /&gt;
*[http://www.na-mic.org/Wiki/index.php/File:WebGLExport_TutorialContestSummer2012.pdf  WebdGLExport]&lt;br /&gt;
*Authors:  Nicolas Rannou, Daniel Haehn, Children's Hospital&lt;br /&gt;
|align=&amp;quot;right&amp;quot;|&lt;br /&gt;
[[Image:WebGLExport.png|250px]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===OpenIGTLink===&lt;br /&gt;
{|width=&amp;quot;100%&amp;quot;&lt;br /&gt;
|&lt;br /&gt;
*[http://wiki.slicer.org/slicerWiki/images/f/f1/OpenIGTLinkTutorial_Slicer4.1.0_JunichiTokuda_Apr2012.pdf OpenIGTLink]&lt;br /&gt;
*Authors:  Junichi Tokuda, BWH&lt;br /&gt;
|align=&amp;quot;right&amp;quot;|&lt;br /&gt;
[[Image:OpenIGTLink.png|250px]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=Additional resources =&lt;br /&gt;
{|width=&amp;quot;100%&amp;quot;&lt;br /&gt;
|&lt;br /&gt;
* This ''Slicer 4.1 [http://vimeo.com/41096643 webinar]'' presents the new features and improvements of the release, and a brief overview of work for the next release.&lt;br /&gt;
* Authors: Steve Pieper Ph.D.&lt;br /&gt;
* Audience: First time users and developers interested in Slicer 4.1 new features.&lt;br /&gt;
* Length: 0h20m&lt;br /&gt;
|align=&amp;quot;right&amp;quot;|[[Image:Webinar-Slicer-4.1.png|250px]]&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
----&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
{|width=&amp;quot;100%&amp;quot;&lt;br /&gt;
|&lt;br /&gt;
*This ''Intro to Slicer 4.0 [http://vimeo.com/37671358 webinar]'' provides an introduction to 3DSlicer, and demonstrates core functionalities such as loading, visualizing and saving data. Basic processing tools, including manual registration, manual segmentation and tractography tools are also highlighted. This webinar is a general overview. For in depth information see the modules above and the documentation pages.&lt;br /&gt;
*Authors: Julien Finet, M.S., Steve Pieper, Ph.D., Jean-Christophe Fillion-Robin, M.S. &lt;br /&gt;
*Audience: First time users interested in a broad overview of Slicer’s features and tools.&lt;br /&gt;
*Length: 1h20m&lt;br /&gt;
|align=&amp;quot;right&amp;quot;|[[Image:Webinar.png|250px]]&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
----&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
{|width=&amp;quot;100%&amp;quot;&lt;br /&gt;
|&lt;br /&gt;
*The ''[[Documentation/{{documentation/version}}/Registration/RegistrationLibrary|Slicer Registration Case Library]]'' provides many real-life example cases of using the Slicer registration tools. They include the dataset and step-by-step instructions to follow and try yourself. &lt;br /&gt;
:Author: Dominik Meier, Ph.D.&lt;br /&gt;
:Audience:  users interested learning/applying Slicer image registration technology&lt;br /&gt;
|align=&amp;quot;right&amp;quot;|[[Image:RegLib_table.png|250px|link=http://wiki.slicer.org/slicerWiki/index.php/Documentation/{{documentation/version}}/Registration/RegistrationLibrary]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
= External Resources =&lt;br /&gt;
&lt;br /&gt;
== Resources for Chinese users ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{|width=&amp;quot;100%&amp;quot;&lt;br /&gt;
|&lt;br /&gt;
A 3D Slicer community on WeChat in China offers many tutorials and clinical examples in Chinese.  Note that the images are of interest to non-Chinese speakers and Google Translate does a reasonable job of translating some of the text.&lt;br /&gt;
&lt;br /&gt;
* [https://mp.weixin.qq.com/s?__biz=MzI3MDY4ODA5Mw==&amp;amp;mid=2247486116&amp;amp;idx=1&amp;amp;sn=772e9d431ac32cbb73d08cf0e6bc219a&amp;amp;chksm=eacc0096ddbb89805d93ac4be181d1a35058031bac673d7a91b3b44dccee2bfd1d8461397635#rd Getting started 大脑前动脉远端动脉瘤手术夹闭治疗]&lt;br /&gt;
&lt;br /&gt;
* [https://mp.weixin.qq.com/s?__biz=MzI3MDY4ODA5Mw==&amp;amp;mid=2247484787&amp;amp;idx=1&amp;amp;sn=1f6279bdccab168fc79b7275e9fe91ca&amp;amp;chksm=eacc0f41ddbb8657be92f617661133d87bb55a4ecf12f786e97a8b7d5249a05d11e0cd620c3f#rd distal anterior cerebral artery aneurysm 3D Slicer：漂亮得不像实力派]&lt;br /&gt;
&lt;br /&gt;
* [https://mp.weixin.qq.com/s?__biz=MzI3MDY4ODA5Mw==&amp;amp;mid=2247486360&amp;amp;idx=1&amp;amp;sn=f833b13a26f543aa9175419a03df7f52&amp;amp;chksm=eacc01aaddbb88bcb004773a4db8a9b3c7633d21cda3956f84b96515252eb861c5eb1e75a60b&amp;amp;mpshare=1&amp;amp;scene=24&amp;amp;srcid=0212LIfOkBRm9CvA7ImHCpRt#rd meningioma skull resection 脑膜瘤患者颅骨切除一期修补的3DSlicer方案]&lt;br /&gt;
&lt;br /&gt;
* [https://mp.weixin.qq.com/s?__biz=MzI3MDY4ODA5Mw==&amp;amp;mid=2247486079&amp;amp;idx=1&amp;amp;sn=9b926dc398a408e3441082b9e0ffde61&amp;amp;chksm=eacc004dddbb895bf9b60f5f1bc443513196e4cb90a6caf6f348a4da7b7fc22eb658661aeb49&amp;amp;mpshare=1&amp;amp;scene=24&amp;amp;srcid=0212AFtT2Wq7K7bvkMGTdyih#rd Cerebral hemorrhage by forehead positioning method 脑出血经额手术定位法（五 ]&lt;br /&gt;
&lt;br /&gt;
* [https://mp.weixin.qq.com/s?__biz=MzI3MDY4ODA5Mw==&amp;amp;mid=2247485356&amp;amp;idx=1&amp;amp;sn=044f5899b651b35994db00c32ab688ee&amp;amp;chksm=eacc0d9eddbb8488f16ff82bb1dda8456a4011790fed024781972d578783e67781443cf4a319&amp;amp;mpshare=1&amp;amp;scene=24&amp;amp;srcid=0212G45TadrPnX8tp9eaNXUs#rd Hematoma modeling 血肿建模的第11种方法]&lt;br /&gt;
&lt;br /&gt;
* [https://mp.weixin.qq.com/s?__biz=MzI3MDY4ODA5Mw==&amp;amp;mid=2247486025&amp;amp;idx=1&amp;amp;sn=b281324893be4ab116d20826f1b426c3&amp;amp;chksm=eacc007bddbb896d9deb096f209278f40c0b52c6410a8a9ff3ce8c3697c99304f18eb678f11e&amp;amp;mpshare=1&amp;amp;scene=24&amp;amp;srcid=02125v1kxvIGmfkxx7mUZcCM#rd Mobile phone positioning and AR application 手机定位及AR应用的初步探索]&lt;br /&gt;
&lt;br /&gt;
|align=&amp;quot;right&amp;quot;|&lt;br /&gt;
[[image:Wechat-hemorage-2018-02-12.png|250px|Example WeChat tutorial slides]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Resources in German ==&lt;br /&gt;
&lt;br /&gt;
* [https://www.youtube.com/watch?v=sl-00kGpuPk&amp;amp;list=PLJWCUXz3GeAfmYLiFcKus_c0jcsMnVsgb A series of four YouTube videos on python programming in Slicer] (German narration with English subtitles)&lt;br /&gt;
&lt;br /&gt;
== Murat Maga's blog posts about using 3D Slicer for biology ==&lt;br /&gt;
&lt;br /&gt;
* [https://blogs.uw.edu/maga/2017/04/11/getting-started-with-3d-slicer-as-a-biologist/ Slicer for Biologists]&lt;br /&gt;
* [https://blogs.uw.edu/maga/2017/04/11/a-worked-example-getting-and-visualizing-data-from-digimorph/ Loading data from DigiMorph]&lt;br /&gt;
* [https://blogs.uw.edu/maga/2017/04/11/morphosource-data-and-dealing-with-dicom-series-in-slicer/ Fixing problem DICOM]&lt;br /&gt;
* [https://blogs.uw.edu/maga/2017/04/12/scissors-tool-is-awesome/ Scissors tool is awesom]&lt;br /&gt;
 &lt;br /&gt;
== Using the (legacy) Editor ==&lt;br /&gt;
&lt;br /&gt;
=== Fast GrowCut ===&lt;br /&gt;
&lt;br /&gt;
{|width=&amp;quot;100%&amp;quot;&lt;br /&gt;
|&lt;br /&gt;
* The [[media:FastGrowCutTutorial.pdf |Fast GrowCut tutorial]]  shows how to perform a segmentation using the Fast GrowCut effect in Slicer.&lt;br /&gt;
* Authors: Hillary Lia&lt;br /&gt;
* Audience: Users interested in segmentation&lt;br /&gt;
|align=&amp;quot;right&amp;quot;|[[File:FastGrowCutLogo.png|200px]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Use case: Slicer in paleontology ===&lt;br /&gt;
&lt;br /&gt;
This set of tutorials about the use of slicer in paleontology is very well written and provides step-by-step instructions.  Even though it covers slicer version 3.4, many of the concepts and techniques have applicability to the new version and to any 3D imaging field:&lt;br /&gt;
&lt;br /&gt;
* [http://openpaleo.blogspot.com/2008/12/3d-slicer-tutorial.html Open Source Paleontologist: 3D Slicer: The Tutorial]&lt;br /&gt;
* [http://openpaleo.blogspot.com/2008/12/3d-slicer-tutorial-part-ii.html Open Source Paleontologist: 3D Slicer: The Tutorial Part II]&lt;br /&gt;
* [http://openpaleo.blogspot.com/2008/12/3d-slicer-tutorial-part-iii.html Open Source Paleontologist: 3D Slicer: The Tutorial Part III]&lt;br /&gt;
* [http://openpaleo.blogspot.com/2008/12/3d-slicer-tutorial-part-iv.html Open Source Paleontologist: 3D Slicer: The Tutorial Part IV]&lt;br /&gt;
* [http://openpaleo.blogspot.com/2009/03/3d-slicer-tutorial-part-v.html Open Source Paleontologist: 3D Slicer: The Tutorial Part V]&lt;br /&gt;
* [http://openpaleo.blogspot.com/2009/03/3d-slicer-tutorial-part-vi.html Open Source Paleontologist: 3D Slicer: The Tutorial Part VI]&lt;br /&gt;
&lt;br /&gt;
== Team Contributions ==&lt;br /&gt;
See the collection of videos on the [http://vimeo.com/album/2363361 Kitware vimeo album].&lt;br /&gt;
&lt;br /&gt;
== User Contributions ==&lt;br /&gt;
See the [[Documentation/{{documentation/version}}/Training/UserContributions|User Contributions Page]] for more content.&lt;br /&gt;
&lt;br /&gt;
[http://www.youtube.com/results?search_query=3d+slicer&amp;amp;sm=3 YouTube videos about 3D Slicer]&lt;/div&gt;</summary>
		<author><name>Inorton</name></author>
		
	</entry>
	<entry>
		<id>https://www.slicer.org/w/index.php?title=Documentation/Nightly/ScriptRepository&amp;diff=58992</id>
		<title>Documentation/Nightly/ScriptRepository</title>
		<link rel="alternate" type="text/html" href="https://www.slicer.org/w/index.php?title=Documentation/Nightly/ScriptRepository&amp;diff=58992"/>
		<updated>2018-05-21T18:55:08Z</updated>

		<summary type="html">&lt;p&gt;Inorton: /* Export a fiber tracts to Blender, including color */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;noinclude&amp;gt;{{documentation/versioncheck}}&amp;lt;/noinclude&amp;gt;&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Community-contributed modules=&lt;br /&gt;
&lt;br /&gt;
The examples in this section are [[Documentation/{{documentation/version}}/Developers/Modules#Scripted_Modules| Scripted Modules]] that provide a user interface in the module panel along with specialized implementation logic.&lt;br /&gt;
&lt;br /&gt;
Usage: save the .py file to a directory, add the directory to the additional module paths in the Slicer application settings (choose in the menu: Edit / Application settings, click Modules, click &amp;gt;&amp;gt; next to Additional module paths, click Add, and choose the .py file's location).&lt;br /&gt;
&lt;br /&gt;
==Filters==&lt;br /&gt;
* [https://raw.github.com/pieper/VolumeMasker/master/VolumeMasker.py VolumeMasker.py]: Update a target volume with the results of setting all input volume voxels to 0 except for those that correspond to a selected label value in an input label map (Used for example in the volume rendering in [https://www.youtube.com/watch?v=dfu2gugHLHs this video).&lt;br /&gt;
&lt;br /&gt;
==DICOM==&lt;br /&gt;
* [https://gist.github.com/pieper/6186477 dicom header browser] to easily scroll through dicom files using dcmdump.&lt;br /&gt;
* [https://github.com/SlicerRt/SlicerRT/tree/master/BatchProcessing SlicerRT batch processing] to batch convert RT structure sets to labelmap NRRD files.&lt;br /&gt;
&lt;br /&gt;
==Informatics==&lt;br /&gt;
* [https://gist.github.com/lassoan/bf0954d93cacc8cbe27cd4a3ad503f2f MarkupsInfo.py]: Compute the total length between all the points of a markup list.&lt;br /&gt;
* [https://gist.github.com/lassoan/0e7acfbec36e4577f8b7b0e07ad53a2a LineProfile.py]: Compute intensity profile in a volume along a line.&lt;br /&gt;
&lt;br /&gt;
=Community-contributed examples=&lt;br /&gt;
&lt;br /&gt;
Usage: Copy-paste the shown code lines or linked .py file contents into Python console in Slicer.  Or save them to a file and run them using execfile.&lt;br /&gt;
&lt;br /&gt;
==Capture==&lt;br /&gt;
* Capture the full Slicer screen and save it into a file&lt;br /&gt;
  img = qt.QPixmap.grabWidget(slicer.util.mainWindow()).toImage()&lt;br /&gt;
  img.save('c:/tmp/test.png')&lt;br /&gt;
* Capture all the views save it into a file:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
import ScreenCapture&lt;br /&gt;
cap = ScreenCapture.ScreenCaptureLogic()&lt;br /&gt;
cap.showViewControllers(False)&lt;br /&gt;
cap.captureImageFromView(None,'c:/tmp/test.png')&lt;br /&gt;
cap.showViewControllers(True)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
* Capture a single view:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
viewNodeID = 'vtkMRMLViewNode1'&lt;br /&gt;
import ScreenCapture&lt;br /&gt;
cap = ScreenCapture.ScreenCaptureLogic()&lt;br /&gt;
view = cap.viewFromNode(slicer.mrmlScene.GetNodeByID(viewNodeID))&lt;br /&gt;
cap.captureImageFromView(view,'c:/tmp/test.png')&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Common values for viewNodeID: vtkMRMLSliceNodeRed, vtkMRMLSliceNodeYellow, vtkMRMLSliceNodeGreen, vtkMRMLViewNode1, vtkMRMLViewNode2. &lt;br /&gt;
The ScreenCapture module can also create video animations of rotating views, slice sweeps, etc.&lt;br /&gt;
&lt;br /&gt;
* Capture a slice view sweep into a series of PNG files - for example, Red slice view, 30 images, from position -125.0 to 75.0, into c:/tmp folder, with name image_00001.png, image_00002.png, ...&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
import ScreenCapture&lt;br /&gt;
ScreenCapture.ScreenCaptureLogic().captureSliceSweep(getNode('vtkMRMLSliceNodeRed'), -125.0, 75.0, 30, &amp;quot;c:/tmp&amp;quot;, &amp;quot;image_%05d.png&amp;quot;)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Capture 3D view into PNG file with transparent background&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
renderWindow = slicer.app.layoutManager().threeDWidget(0).threeDView().renderWindow()&lt;br /&gt;
renderWindow.SetAlphaBitPlanes(1)&lt;br /&gt;
wti = vtk.vtkWindowToImageFilter()&lt;br /&gt;
wti.SetInputBufferTypeToRGBA()&lt;br /&gt;
wti.SetInput(renderWindow)&lt;br /&gt;
writer = vtk.vtkPNGWriter()&lt;br /&gt;
writer.SetFileName(&amp;quot;c:/tmp/screenshot.png&amp;quot;)&lt;br /&gt;
writer.SetInputConnection(wti.GetOutputPort())&lt;br /&gt;
writer.Write()&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Launching Slicer==&lt;br /&gt;
* How to open an .mrb file with Slicer at the command line?&lt;br /&gt;
  Slicer.exe --python-code &amp;quot;slicer.util.loadScene( 'f:/2013-08-23-Scene.mrb' )&amp;quot;&lt;br /&gt;
* How to run a script in the Slicer environment in batch mode (without showing any graphical user interface)?&lt;br /&gt;
  Slicer.exe --python-code &amp;quot;doSomething; doSomethingElse; etc.&amp;quot; --testing --no-splash --no-main-window&lt;br /&gt;
&lt;br /&gt;
==Load volume from file==&lt;br /&gt;
When loading a volume from file, it is recommended to set returnNode=True to retrieve the loaded volume node.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
[success, loadedVolumeNode] = slicer.util.loadVolume('c:/Users/abc/Documents/MRHead.nrrd', returnNode=True)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Get a MRML node in the scene based on the node name and call methods of that object. For the MRHead sample data:&lt;br /&gt;
  vol=slicer.util.getNode('MR*')&lt;br /&gt;
  vol.GetImageData().GetDimensions()&lt;br /&gt;
&lt;br /&gt;
==DICOM==&lt;br /&gt;
=== How to access tags of DICOM images imported into Slicer? For example, to print the first patient's first study's first series' &amp;quot;0020,0032&amp;quot; field:===&lt;br /&gt;
  db=slicer.dicomDatabase&lt;br /&gt;
  patientList=db.patients()&lt;br /&gt;
  studyList=db.studiesForPatient(patientList[0])&lt;br /&gt;
  seriesList=db.seriesForStudy(studyList[0])&lt;br /&gt;
  fileList=db.filesForSeries(seriesList[0])&lt;br /&gt;
  print db.fileValue(fileList[0],'0020,0032')&lt;br /&gt;
&lt;br /&gt;
=== How to access tag of a volume loaded from DICOM? For example, get the patient position stored in a volume:===&lt;br /&gt;
  volumeName='2: ENT IMRT'&lt;br /&gt;
  n=slicer.util.getNode(volumeName)&lt;br /&gt;
  instUids=n.GetAttribute('DICOM.instanceUIDs').split()&lt;br /&gt;
  filename=slicer.dicomDatabase.fileForInstance(instUids[0])&lt;br /&gt;
  print slicer.dicomDatabase.fileValue(filename,'0018,5100')&lt;br /&gt;
&lt;br /&gt;
=== How to access tag of an item in the Subject Hierachy tree? For example, get the content time tag of a structure set:===&lt;br /&gt;
  rtStructName = '3: RTSTRUCT: PROS'&lt;br /&gt;
  rtStructNode = slicer.util.getNode(rtStructName)&lt;br /&gt;
  shNode = slicer.vtkMRMLSubjectHierarchyNode.GetSubjectHierarchyNode(slicer.mrmlScene)&lt;br /&gt;
  rtStructShItemID = shNode.GetItemByDataNode(rtStructNode)&lt;br /&gt;
  ctSliceInstanceUids = shNode.GetItemAttribute(rtStructShItemID, 'DICOM.ReferencedInstanceUIDs').split()&lt;br /&gt;
  filename = slicer.dicomDatabase.fileForInstance(ctSliceInstanceUids[0])&lt;br /&gt;
  print slicer.dicomDatabase.fileValue(filename,'0008,0033')&lt;br /&gt;
&lt;br /&gt;
=== How to get path and filename of a loaded DICOM volume?===&lt;br /&gt;
  def pathFromNode(node):&lt;br /&gt;
    storageNode=node.GetStorageNode()&lt;br /&gt;
    if storageNode is not None: # loaded via drag-drop&lt;br /&gt;
        filepath=storageNode.GetFullNameFromFileName()&lt;br /&gt;
    else: # loaded via DICOM browser&lt;br /&gt;
        instanceUIDs=node.GetAttribute('DICOM.instanceUIDs').split()&lt;br /&gt;
        filepath=slicer.dicomDatabase.fileForInstance(instUids[0])&lt;br /&gt;
    return filepath&lt;br /&gt;
  &lt;br /&gt;
  # example:&lt;br /&gt;
  node=slicer.util.getNode('volume1')&lt;br /&gt;
  path=self.pathFromNode(node)&lt;br /&gt;
  print(&amp;quot;DICOM path=%s&amp;quot; % path)&lt;br /&gt;
&lt;br /&gt;
=== How can I convert DICOM to NRRD on the command line?===&lt;br /&gt;
&lt;br /&gt;
 /Applications/Slicer-4.6.2.app/Contents/MacOS/Slicer --no-main-window --python-code &amp;quot;node=slicer.util.loadVolume('/tmp/series/im0.dcm', returnNode=True)[1]; slicer.util.saveNode(node, '/tmp/output.nrrd'); exit()&amp;quot;&lt;br /&gt;
&lt;br /&gt;
The same can be done on windows by using the top level Slicer.exe.  Be sure to use forward slashes in the pathnames within quotes on the command line.&lt;br /&gt;
&lt;br /&gt;
==Toolbar functions==&lt;br /&gt;
* How to turn on slice intersections in the crosshair menu on the toolbar:&lt;br /&gt;
  viewNodes = slicer.mrmlScene.GetNodesByClass('vtkMRMLSliceCompositeNode')&lt;br /&gt;
  viewNodes.UnRegister(slicer.mrmlScene)&lt;br /&gt;
  viewNodes.InitTraversal()&lt;br /&gt;
  viewNode = viewNodes.GetNextItemAsObject()&lt;br /&gt;
  while viewNode:&lt;br /&gt;
    viewNode.SetSliceIntersectionVisibility(1)&lt;br /&gt;
    viewNode = viewNodes.GetNextItemAsObject()&lt;br /&gt;
&lt;br /&gt;
How to find similar functions? For this one I searched for &amp;quot;slice intersections&amp;quot; text in the whole slicer source code, found that the function is implemented in Base\QTGUI\qSlicerViewersToolBar.cxx, then translated the qSlicerViewersToolBarPrivate::setSliceIntersectionVisible(bool visible) method to Python.&lt;br /&gt;
&lt;br /&gt;
==Manipulating objects in the slice viewer==&lt;br /&gt;
* How to define/edit a circular region of interest in a slice viewer?&lt;br /&gt;
&lt;br /&gt;
Drop two markup points on a slice view and copy-paste the code below into the Python console. After this, as you move the markups you’ll see a circle following the markups.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Update the sphere from the fiducial points&lt;br /&gt;
def UpdateSphere(param1, param2):  &lt;br /&gt;
  import math&lt;br /&gt;
  centerPointCoord = [0.0, 0.0, 0.0]&lt;br /&gt;
  markups.GetNthFiducialPosition(0,centerPointCoord)&lt;br /&gt;
  circumferencePointCoord = [0.0, 0.0, 0.0]&lt;br /&gt;
  markups.GetNthFiducialPosition(1,circumferencePointCoord)&lt;br /&gt;
  sphere.SetCenter(centerPointCoord)&lt;br /&gt;
  radius=math.sqrt((centerPointCoord[0]-circumferencePointCoord[0])**2+(centerPointCoord[1]-circumferencePointCoord[1])**2+(centerPointCoord[2]-circumferencePointCoord[2])**2)&lt;br /&gt;
  sphere.SetRadius(radius)&lt;br /&gt;
  sphere.SetPhiResolution(30)&lt;br /&gt;
  sphere.SetThetaResolution(30)&lt;br /&gt;
  sphere.Update()&lt;br /&gt;
&lt;br /&gt;
# Get markup node from scene&lt;br /&gt;
markups=slicer.util.getNode('F')&lt;br /&gt;
sphere = vtk.vtkSphereSource()&lt;br /&gt;
UpdateSphere(0,0)&lt;br /&gt;
 &lt;br /&gt;
# Create model node and add to scene&lt;br /&gt;
modelsLogic = slicer.modules.models.logic()&lt;br /&gt;
model = modelsLogic.AddModel(sphere.GetOutput())&lt;br /&gt;
model.GetDisplayNode().SetSliceIntersectionVisibility(True)&lt;br /&gt;
model.GetDisplayNode().SetSliceIntersectionThickness(3)&lt;br /&gt;
model.GetDisplayNode().SetColor(1,1,0)&lt;br /&gt;
 &lt;br /&gt;
# Call UpdateSphere whenever the fiducials are changed&lt;br /&gt;
markups.AddObserver(&amp;quot;ModifiedEvent&amp;quot;, UpdateSphere, 2)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Switching to markup fiducial placement mode ==&lt;br /&gt;
&lt;br /&gt;
To activate a fiducial placement mode, both interaction mode has to be set and a fiducial node has to be selected:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
interactionNode = slicer.app.applicationLogic().GetInteractionNode()&lt;br /&gt;
selectionNode = slicer.app.applicationLogic().GetSelectionNode()&lt;br /&gt;
selectionNode.SetReferenceActivePlaceNodeClassName(&amp;quot;vtkMRMLMarkupsFiducialNode&amp;quot;)&lt;br /&gt;
fiducialNode = slicer.vtkMRMLMarkupsFiducialNode()&lt;br /&gt;
slicer.mrmlScene.AddNode(fiducialNode)&lt;br /&gt;
fiducialNode.CreateDefaultDisplayNodes() &lt;br /&gt;
selectionNode.SetActivePlaceNodeID(fiducialNode.GetID())&lt;br /&gt;
interactionNode.SetCurrentInteractionMode(interactionNode.Place)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Get a notification if a markup point position is modified ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
def onMarkupsNodeModified(markupsNode, unusedArg2=None, unusedArg3=None):&lt;br /&gt;
  sliceView = markupsNode.GetAttribute('Markups.MovingInSliceView')&lt;br /&gt;
  if not sliceView:&lt;br /&gt;
    print(&amp;quot;Markup list was modified&amp;quot;)&lt;br /&gt;
    return&lt;br /&gt;
  movingMarkupIndex = markupsNode.GetAttribute('Markups.MovingMarkupIndex')&lt;br /&gt;
  pos = [0,0,0]&lt;br /&gt;
  markupsNode.GetNthFiducialPosition(int(movingMarkupIndex), pos)  &lt;br /&gt;
  print(&amp;quot;Markup {0} was moved in slice view {1} to {2}&amp;quot;.format(movingMarkupIndex, sliceView, pos))&lt;br /&gt;
&lt;br /&gt;
markupsNode = slicer.mrmlScene.AddNewNodeByClass(&amp;quot;vtkMRMLMarkupsFiducialNode&amp;quot;)&lt;br /&gt;
markupsNode.CreateDefaultDisplayNodes()&lt;br /&gt;
markupsNode.AddFiducial(0,0,0)&lt;br /&gt;
markupsNode.AddObserver(vtk.vtkCommand.ModifiedEvent, onMarkupsNodeModified)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Show a context menu when a markup point is clicked in a slice or 3D view ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
# Example actions to perform&lt;br /&gt;
&lt;br /&gt;
def action1():&lt;br /&gt;
  print('Action1 on markup '+str(slicer.clickedMarkupIndex))&lt;br /&gt;
&lt;br /&gt;
def action2():&lt;br /&gt;
  print('Action2 on markup '+str(slicer.clickedMarkupIndex))&lt;br /&gt;
&lt;br /&gt;
def action3():&lt;br /&gt;
  print('Action3 on markup '+str(slicer.clickedMarkupIndex))&lt;br /&gt;
&lt;br /&gt;
# Clicked markup index is saved here to let the action&lt;br /&gt;
# know which markup needs to be manipulated.&lt;br /&gt;
slicer.clickedMarkupIndex = -1&lt;br /&gt;
  &lt;br /&gt;
# Create a simple menu&lt;br /&gt;
&lt;br /&gt;
menu = qt.QMenu()&lt;br /&gt;
a1 = qt.QAction(&amp;quot;Test&amp;quot;, slicer.util.mainWindow())&lt;br /&gt;
a1.connect('triggered()', action1)&lt;br /&gt;
menu.addAction(a1)&lt;br /&gt;
a2 = qt.QAction(&amp;quot;Action&amp;quot;, slicer.util.mainWindow())&lt;br /&gt;
a2.connect('triggered()', action1)&lt;br /&gt;
menu.addAction(a2)&lt;br /&gt;
a3 = qt.QAction(&amp;quot;Here&amp;quot;, slicer.util.mainWindow())&lt;br /&gt;
a3.connect('triggered()', action1)&lt;br /&gt;
menu.addAction(a3)&lt;br /&gt;
&lt;br /&gt;
# Add observer to a markup fiducial list&lt;br /&gt;
&lt;br /&gt;
@vtk.calldata_type(vtk.VTK_INT)&lt;br /&gt;
def markupClickedCallback(caller, eventId, callData):&lt;br /&gt;
  slicer.clickedMarkupIndex = callData&lt;br /&gt;
  print('Open menu on markup '+str(slicer.clickedMarkupIndex))&lt;br /&gt;
  menu.move(qt.QCursor.pos())&lt;br /&gt;
  menu.show()&lt;br /&gt;
&lt;br /&gt;
markupsNode = getNode('F')&lt;br /&gt;
observerTag = markupsNode.AddObserver(slicer.vtkMRMLMarkupsNode.PointClickedEvent, markupClickedCallback)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Add a texture mapped plane to the scene as a model ==&lt;br /&gt;
Note that model textures are not exposed in the GUI and are not saved in the scene&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# use dummy image data here&lt;br /&gt;
e = vtk.vtkImageEllipsoidSource()&lt;br /&gt;
&lt;br /&gt;
scene = slicer.mrmlScene&lt;br /&gt;
&lt;br /&gt;
# Create model node&lt;br /&gt;
model = slicer.vtkMRMLModelNode()&lt;br /&gt;
model.SetScene(scene)&lt;br /&gt;
model.SetName(scene.GenerateUniqueName(&amp;quot;2DImageModel&amp;quot;))&lt;br /&gt;
&lt;br /&gt;
planeSource = vtk.vtkPlaneSource()&lt;br /&gt;
model.SetAndObservePolyData(planeSource.GetOutput())&lt;br /&gt;
&lt;br /&gt;
# Create display node&lt;br /&gt;
modelDisplay = slicer.vtkMRMLModelDisplayNode()&lt;br /&gt;
modelDisplay.SetColor(1,1,0) # yellow&lt;br /&gt;
modelDisplay.SetBackfaceCulling(0)&lt;br /&gt;
modelDisplay.SetScene(scene)&lt;br /&gt;
scene.AddNode(modelDisplay)&lt;br /&gt;
model.SetAndObserveDisplayNodeID(modelDisplay.GetID())&lt;br /&gt;
&lt;br /&gt;
# Add to scene&lt;br /&gt;
modelDisplay.SetAndObserveTextureImageData(e.GetOutput())&lt;br /&gt;
scene.AddNode(model) &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
transform = slicer.vtkMRMLLinearTransformNode()&lt;br /&gt;
scene.AddNode(transform) &lt;br /&gt;
model.SetAndObserveTransformNodeID(transform.GetID())&lt;br /&gt;
&lt;br /&gt;
vTransform = vtk.vtkTransform()&lt;br /&gt;
vTransform.Scale(50,50,50)&lt;br /&gt;
vTransform.RotateX(30)&lt;br /&gt;
transform.SetAndObserveMatrixTransformToParent(vTransform.GetMatrix())&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Export entire scene as VRML ==&lt;br /&gt;
&lt;br /&gt;
Save all surface meshes displayed in the scene (models, markups, etc). Solid colors and coloring by scalar is preserved. Textures are not supported.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
exporter = vtk.vtkVRMLExporter()&lt;br /&gt;
exporter.SetRenderWindow(slicer.app.layoutManager().threeDWidget(0).threeDView().renderWindow())&lt;br /&gt;
exporter.SetFileName('C:/tmp/something.wrl')&lt;br /&gt;
exporter.Write()&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Export model to Blender, including color by scalar ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
modelNode = getNode(&amp;quot;Model&amp;quot;)&lt;br /&gt;
plyFilePath = &amp;quot;c:/tmp/model.ply&amp;quot;&lt;br /&gt;
&lt;br /&gt;
modelDisplayNode = modelNode.GetDisplayNode()&lt;br /&gt;
triangles = vtk.vtkTriangleFilter()&lt;br /&gt;
triangles.SetInputConnection(modelDisplayNode.GetOutputPolyDataConnection())&lt;br /&gt;
&lt;br /&gt;
plyWriter = vtk.vtkPLYWriter()&lt;br /&gt;
plyWriter.SetInputConnection(triangles.GetOutputPort())&lt;br /&gt;
lut = vtk.vtkLookupTable()&lt;br /&gt;
lut.DeepCopy(modelDisplayNode.GetColorNode().GetLookupTable())&lt;br /&gt;
lut.SetRange(modelDisplayNode.GetScalarRange())&lt;br /&gt;
plyWriter.SetLookupTable(lut)&lt;br /&gt;
plyWriter.SetArrayName(modelDisplayNode.GetActiveScalarName())&lt;br /&gt;
&lt;br /&gt;
plyWriter.SetFileName(plyFilePath)&lt;br /&gt;
plyWriter.Write()&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Export a fiber tracts to Blender, including color ==&lt;br /&gt;
&lt;br /&gt;
Note: an interactive version of this script is now included in the [http://dmri.slicer.org/ SlicerDMRI extension] ([https://github.com/SlicerDMRI/SlicerDMRI/tree/master/Modules/Scripted/TractographyExportPLY module code]). &lt;br /&gt;
After installing SlicerDMRI, go to ''Modules -&amp;gt; Diffusion -&amp;gt; Import and Export -&amp;gt; Export tractography to PLY (mesh)''.&lt;br /&gt;
&lt;br /&gt;
The example below shows how to export a tractography &amp;quot;FiberBundleNode&amp;quot; to a PLY file:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
lineDisplayNode = getNode(&amp;quot;*LineDisplay*&amp;quot;)&lt;br /&gt;
plyFilePath = &amp;quot;/tmp/fibers.ply&amp;quot;&lt;br /&gt;
&lt;br /&gt;
tuber = vtk.vtkTubeFilter()&lt;br /&gt;
tuber.SetInputData(lineDisplayNode.GetOutputPolyData())&lt;br /&gt;
tuber.Update()&lt;br /&gt;
tubes = tuber.GetOutputDataObject(0)&lt;br /&gt;
scalars = tubes.GetPointData().GetArray(0)&lt;br /&gt;
scalars.SetName(&amp;quot;scalars&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
triangles = vtk.vtkTriangleFilter()&lt;br /&gt;
triangles.SetInputData(tubes)&lt;br /&gt;
triangles.Update()&lt;br /&gt;
&lt;br /&gt;
colorNode = lineDisplayNode.GetColorNode()&lt;br /&gt;
lookupTable = vtk.vtkLookupTable()&lt;br /&gt;
lookupTable.DeepCopy(colorNode.GetLookupTable())&lt;br /&gt;
lookupTable.SetTableRange(0,1)&lt;br /&gt;
&lt;br /&gt;
plyWriter = vtk.vtkPLYWriter()&lt;br /&gt;
plyWriter.SetInputData(triangles.GetOutput())&lt;br /&gt;
plyWriter.SetLookupTable(lookupTable)&lt;br /&gt;
plyWriter.SetArrayName(&amp;quot;scalars&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
plyWriter.SetFileName(plyFilePath)&lt;br /&gt;
plyWriter.Write()&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Clone a volume ==&lt;br /&gt;
This example shows how to clone the MRHead sample volume, including its pixel data and display settings.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sourceVolumeNode = slicer.util.getNode('MRHead')&lt;br /&gt;
volumesLogic = slicer.modules.volumes.logic()&lt;br /&gt;
clonedVolumeNode = volumesLogic.CloneVolume(slicer.mrmlScene, sourceVolumeNode, 'Cloned volume')&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Create a new volume ==&lt;br /&gt;
This example shows how to create a new empty volume.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
nodeName = &amp;quot;MyNewVolume&amp;quot;&lt;br /&gt;
imageSize = [512, 512, 512]&lt;br /&gt;
voxelType=vtk.VTK_UNSIGNED_CHAR&lt;br /&gt;
imageOrigin = [0.0, 0.0, 0.0]&lt;br /&gt;
imageSpacing = [1.0, 1.0, 1.0]&lt;br /&gt;
imageDirections = [[1,0,0], [0,1,0], [0,0,1]]&lt;br /&gt;
fillVoxelValue = 0&lt;br /&gt;
&lt;br /&gt;
# Create an empty image volume, filled with fillVoxelValue&lt;br /&gt;
imageData = vtk.vtkImageData()&lt;br /&gt;
imageData.SetDimensions(imageSize)&lt;br /&gt;
imageData.AllocateScalars(voxelType, 1)&lt;br /&gt;
thresholder = vtk.vtkImageThreshold()&lt;br /&gt;
thresholder.SetInputData(imageData)&lt;br /&gt;
thresholder.SetInValue(fillVoxelValue)&lt;br /&gt;
thresholder.SetOutValue(fillVoxelValue)&lt;br /&gt;
thresholder.Update()&lt;br /&gt;
# Create volume node&lt;br /&gt;
volumeNode = slicer.mrmlScene.AddNewNodeByClass(&amp;quot;vtkMRMLScalarVolumeNode&amp;quot;, nodeName)&lt;br /&gt;
volumeNode.SetOrigin(imageOrigin)&lt;br /&gt;
volumeNode.SetSpacing(imageSpacing)&lt;br /&gt;
volumeNode.SetIJKToRASDirections(imageDirections)&lt;br /&gt;
volumeNode.SetAndObserveImageData(thresholder.GetOutput())&lt;br /&gt;
volumeNode.CreateDefaultDisplayNodes()&lt;br /&gt;
volumeNode.CreateDefaultStorageNode()&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Modify voxels in a volume ==&lt;br /&gt;
&lt;br /&gt;
Typically the fastest and simplest way of modifying voxels is by using numpy operators. Voxels can be retrieved in a numpy array using the `array` method and modified using standard numpy methods. For example, threshold a volume:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
nodeName = 'MRHead'&lt;br /&gt;
thresholdValue = 100&lt;br /&gt;
voxelArray = array(nodeName) # get voxels as numpy array&lt;br /&gt;
voxelArray[voxelArray &amp;lt; thresholdValue] = 0 # modify voxel values&lt;br /&gt;
getNode(nodeName).Modified() # at the end of all processing, notify Slicer that the image modification is completed&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This example shows how to change voxels values of the MRHead sample volume.&lt;br /&gt;
The values will be computed by function f(r,a,s,) = (r-10)*(r-10)+(a+15)*(a+15)+s*s.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
volumeNode=slicer.util.getNode('MRHead')&lt;br /&gt;
ijkToRas = vtk.vtkMatrix4x4()&lt;br /&gt;
volumeNode.GetIJKToRASMatrix(ijkToRas)&lt;br /&gt;
imageData=volumeNode.GetImageData()&lt;br /&gt;
extent = imageData.GetExtent()&lt;br /&gt;
for k in xrange(extent[4], extent[5]+1):&lt;br /&gt;
  for j in xrange(extent[2], extent[3]+1):&lt;br /&gt;
    for i in xrange(extent[0], extent[1]+1):&lt;br /&gt;
      position_Ijk=[i, j, k, 1]&lt;br /&gt;
      position_Ras=ijkToRas.MultiplyPoint(position_Ijk)&lt;br /&gt;
      r=position_Ras[0]&lt;br /&gt;
      a=position_Ras[1]&lt;br /&gt;
      s=position_Ras[2]      &lt;br /&gt;
      functionValue=(r-10)*(r-10)+(a+15)*(a+15)+s*s&lt;br /&gt;
      imageData.SetScalarComponentFromDouble(i,j,k,0,functionValue)&lt;br /&gt;
imageData.SetScalarComponentFromFloat(distortionVectorPosition_Ijk[0], distortionVectorPosition_Ijk[1], distortionVectorPosition_Ijk[2], 0, fillValue)&lt;br /&gt;
imageData.Modified()&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Get the values of all voxels for a label value  ==&lt;br /&gt;
&lt;br /&gt;
If you have a background image called ‘Volume’ and a mask called ‘Volume-label’ created with the Editor you could do something like this:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
import numpy&lt;br /&gt;
volume = array(‘Volume’)&lt;br /&gt;
label = array(‘Volume-label’)&lt;br /&gt;
points  = numpy.where( label == 1 )  # or use another label number depending on what you segmented&lt;br /&gt;
values  = volume[points] # this will be a list of the label values&lt;br /&gt;
values.mean() # should match the mean value of LabelStatistics calculation as a double-check&lt;br /&gt;
numpy.savetxt(‘values.txt’, values)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Access values in a DTI tensor volume ==&lt;br /&gt;
This example shows how to access individual tensors at the voxel level.&lt;br /&gt;
&lt;br /&gt;
First load your DWI volume and estimate tensors to produce a DTI volume called ‘Output DTI Volume’&lt;br /&gt;
&lt;br /&gt;
Then open the python window: View-&amp;gt;Python interactor&lt;br /&gt;
&lt;br /&gt;
Use this command to access tensors through numpy:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
tensors = array('Output DTI Volume')&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Type the following code into the Python window to access all tensor components using vtk commands:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
volumeNode=slicer.util.getNode('Output DTI Volume')&lt;br /&gt;
imageData=volumeNode.GetImageData()&lt;br /&gt;
tensors = imageData.GetPointData().GetTensors()&lt;br /&gt;
extent = imageData.GetExtent()&lt;br /&gt;
idx = 0&lt;br /&gt;
for k in xrange(extent[4], extent[5]+1):&lt;br /&gt;
  for j in xrange(extent[2], extent[3]+1):&lt;br /&gt;
    for i in xrange(extent[0], extent[1]+1):&lt;br /&gt;
      tensors.GetTuple9(idx)&lt;br /&gt;
      idx += 1&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Change window/level (brightness/contrast) or colormap of a volume ==&lt;br /&gt;
This example shows how to change window/level of the MRHead sample volume.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
volumeNode = getNode('MRHead')&lt;br /&gt;
displayNode = volumeNode.GetDisplayNode()&lt;br /&gt;
displayNode.AutoWindowLevelOff()&lt;br /&gt;
displayNode.SetWindow(50)&lt;br /&gt;
displayNode.SetLevel(100)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Change color mapping from grayscale to rainbow:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
displayNode.SetAndObserveColorNodeID('vtkMRMLColorTableNodeRainbow')&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Manipulate a Slice View ==&lt;br /&gt;
&lt;br /&gt;
=== Change the slice offset ===&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
lm = slicer.app.layoutManager()&lt;br /&gt;
red = lm.sliceWidget('Red')&lt;br /&gt;
redLogic = red.sliceLogic()&lt;br /&gt;
# Print current slice offset position&lt;br /&gt;
print redLogic.GetSliceOffset()&lt;br /&gt;
# Change slice position&lt;br /&gt;
redLogic.SetSliceOffset(20)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Iterate over current visible slice views, and modify 3D visibility ===&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
for sliceViewName in layoutManager.sliceViewNames():&lt;br /&gt;
     sliceWidget = layoutManager.sliceWidget(sliceViewName)&lt;br /&gt;
     &lt;br /&gt;
     controller = sliceWidget.sliceController()&lt;br /&gt;
     controller.setSliceVisible(True)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Iterate over current visible slice views, and set foreground and background images ===&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
for sliceViewName in layoutManager.sliceViewNames():&lt;br /&gt;
     sliceWidget = layoutManager.sliceWidget(sliceViewName)&lt;br /&gt;
     &lt;br /&gt;
     # setup background volume&lt;br /&gt;
     compositeNode.SetBackgroundVolumeID(MRVolume.GetID())&lt;br /&gt;
     # setup foreground volume&lt;br /&gt;
     compositeNode.SetForegroundVolumeID(CTVolume.GetID())&lt;br /&gt;
     # change opacity&lt;br /&gt;
     compositeNode.SetForegroundOpacity(0.3)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Fit slice plane to markup fiducials ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sliceNode = slicer.mrmlScene.GetNodeByID(&amp;quot;vtkMRMLSliceNodeRed&amp;quot;)&lt;br /&gt;
markupsNode = slicer.mrmlScene.GetFirstNodeByName(&amp;quot;F&amp;quot;)&lt;br /&gt;
# Get markup point positions as numpy arrays&lt;br /&gt;
import numpy as np&lt;br /&gt;
p1 = np.array([0,0,0])&lt;br /&gt;
p2 = np.array([0,0,0])&lt;br /&gt;
p3 = np.array([0,0,0])&lt;br /&gt;
markupsNode.GetNthFiducialPosition(0, p1)&lt;br /&gt;
markupsNode.GetNthFiducialPosition(1, p2)&lt;br /&gt;
markupsNode.GetNthFiducialPosition(2, p3)&lt;br /&gt;
# Get plane axis directions&lt;br /&gt;
n = np.cross(p2-p1, p2-p3) # plane normal direction&lt;br /&gt;
n = n/np.linalg.norm(n)&lt;br /&gt;
t = np.cross([0, 0, 1], n) # plane transverse direction&lt;br /&gt;
t = t/np.linalg.norm(t)&lt;br /&gt;
# Set slice plane orientation and position&lt;br /&gt;
sliceNode.SetSliceToRASByNTP(n[0], n[1], n[2], t[0], t[1], t[2], p1[0], p1[1], p1[2], 0)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Save a series of images from a Slice View ==&lt;br /&gt;
&lt;br /&gt;
You can use ScreenCapture module to capture series of images. To do it programmatically, save the following into a file such as '/tmp/record.py' and then in the slicer python console type &amp;quot;execfile('/tmp/record.py')&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
layoutName = 'Green'&lt;br /&gt;
imagePathPattern = '/tmp/image-%03d.png'&lt;br /&gt;
steps = 10&lt;br /&gt;
&lt;br /&gt;
widget = slicer.app.layoutManager().sliceWidget(layoutName)&lt;br /&gt;
view = widget.sliceView()&lt;br /&gt;
logic = widget.sliceLogic()&lt;br /&gt;
bounds = [0,]*6&lt;br /&gt;
logic.GetSliceBounds(bounds)&lt;br /&gt;
&lt;br /&gt;
for step in range(steps):&lt;br /&gt;
    offset = bounds[4] + step/(1.*steps) * (bounds[5]-bounds[4])&lt;br /&gt;
    logic.SetSliceOffset(offset)&lt;br /&gt;
    view.forceRender()&lt;br /&gt;
    image = qt.QPixmap.grabWidget(view).toImage()&lt;br /&gt;
    image.save(imagePathPattern % step)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Save the scene into a new directory ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Create a new directory where the scene will be saved into&lt;br /&gt;
import time&lt;br /&gt;
sceneSaveDirectory = slicer.app.temporaryPath + &amp;quot;/saved-scene-&amp;quot; + time.strftime(&amp;quot;%Y%m%d-%H%M%S&amp;quot;)&lt;br /&gt;
if not os.access(sceneSaveDirectory, os.F_OK):&lt;br /&gt;
  os.makedirs(sceneSaveDirectory)&lt;br /&gt;
&lt;br /&gt;
# Save the scene&lt;br /&gt;
if slicer.app.applicationLogic().SaveSceneToSlicerDataBundleDirectory(sceneSaveDirectory, None):&lt;br /&gt;
  logging.info(&amp;quot;Scene saved to: {0}&amp;quot;.format(sceneSaveDirectory))&lt;br /&gt;
else:&lt;br /&gt;
  logging.error(&amp;quot;Scene saving failed&amp;quot;) &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Save the scene into a single MRB file ==&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Generate file name&lt;br /&gt;
import time&lt;br /&gt;
sceneSaveFilename = slicer.app.temporaryPath + &amp;quot;/saved-scene-&amp;quot; + time.strftime(&amp;quot;%Y%m%d-%H%M%S&amp;quot;) + &amp;quot;.mrb&amp;quot;&lt;br /&gt;
&lt;br /&gt;
# Save scene&lt;br /&gt;
if slicer.util.saveScene(sceneSaveFilename):&lt;br /&gt;
  logging.info(&amp;quot;Scene saved to: {0}&amp;quot;.format(sceneSaveFilename))&lt;br /&gt;
else:&lt;br /&gt;
  logging.error(&amp;quot;Scene saving failed&amp;quot;) &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Save a node to file ==&lt;br /&gt;
&lt;br /&gt;
Save a transform node to file (should work with any other node type, if file extension is set to a supported one):&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
myNode = getNode(&amp;quot;LinearTransform_3&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
myStorageNode = myNode.CreateDefaultStorageNode()&lt;br /&gt;
myStorageNode.SetFileName(&amp;quot;c:/tmp/something.tfm&amp;quot;)&lt;br /&gt;
myStorageNode.WriteData(myNode)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Show a volume in the Slice Views ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
volumeNode = slicer.util.getNode('YourVolumeNode')&lt;br /&gt;
applicationLogic = slicer.app.applicationLogic()&lt;br /&gt;
selectionNode = applicationLogic.GetSelectionNode()&lt;br /&gt;
selectionNode.SetSecondaryVolumeID(volumeNode.GetID())&lt;br /&gt;
applicationLogic.PropagateForegroundVolumeSelection(0) &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
or&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
n =  slicer.util.getNode('YourVolumeNode')&lt;br /&gt;
for color in ['Red', 'Yellow', 'Green']:&lt;br /&gt;
    slicer.app.layoutManager().sliceWidget(color).sliceLogic().GetSliceCompositeNode().SetForegroundVolumeID(n.GetID())&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Change opacity of foreground volume in the Slice Views ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
lm = slicer.app.layoutManager()&lt;br /&gt;
sliceLogic = lm.sliceWidget('Red').sliceLogic()&lt;br /&gt;
compositeNode = sliceLogic.GetSliceCompositeNode()&lt;br /&gt;
compositeNode.SetForegroundOpacity(0.4)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Center the 3D View on the Scene ==&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
layoutManager = slicer.app.layoutManager()&lt;br /&gt;
threeDWidget = layoutManager.threeDWidget(0)&lt;br /&gt;
threeDView = threeDWidget.threeDView()&lt;br /&gt;
threeDView.resetFocalPoint()&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Rotate the 3D View==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
layoutManager = slicer.app.layoutManager()&lt;br /&gt;
threeDWidget = layoutManager.threeDWidget(0)&lt;br /&gt;
threeDView = threeDWidget.threeDView()&lt;br /&gt;
threeDView.yaw()&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Display text in a 3D view or slice view ==&lt;br /&gt;
&lt;br /&gt;
The easiest way to show information overlaid on a viewer is to use corner annotations.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
view=slicer.app.layoutManager().threeDWidget(0).threeDView()&lt;br /&gt;
# Set text to &amp;quot;Something&amp;quot;&lt;br /&gt;
view.cornerAnnotation().SetText(vtk.vtkCornerAnnotation.UpperRight,&amp;quot;Something&amp;quot;)&lt;br /&gt;
# Set color to red&lt;br /&gt;
view.cornerAnnotation().GetTextProperty().SetColor(1,0,0)&lt;br /&gt;
# Update the view&lt;br /&gt;
view.forceRender()&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Hide slice view annotations (DataProbe) ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Disable slice annotations immediately&lt;br /&gt;
slicer.modules.DataProbeInstance.infoWidget.sliceAnnotations.sliceViewAnnotationsEnabled=False&lt;br /&gt;
slicer.modules.DataProbeInstance.infoWidget.sliceAnnotations.updateSliceViewFromGUI()&lt;br /&gt;
# Disable slice annotations persistently (after Slicer restarts)&lt;br /&gt;
settings = qt.QSettings()&lt;br /&gt;
settings.setValue('DataProbe/sliceViewAnnotations.enabled', 0)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Turning off interpolation ==&lt;br /&gt;
&lt;br /&gt;
You can turn off interpolation for newly loaded volumes with this script from Steve Pieper.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
def NoInterpolate(caller,event):&lt;br /&gt;
  for node in slicer.util.getNodes('*').values():&lt;br /&gt;
    if node.IsA('vtkMRMLScalarVolumeDisplayNode'):&lt;br /&gt;
      node.SetInterpolate(0)&lt;br /&gt;
	&lt;br /&gt;
slicer.mrmlScene.AddObserver(slicer.mrmlScene.NodeAddedEvent, NoInterpolate)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The below link explains how to put this in your startup script.&lt;br /&gt;
&lt;br /&gt;
http://www.na-mic.org/Wiki/index.php/AHM2012-Slicer-Python#Refining_the_code_and_UI_with_slicerrc&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Customize viewer layout ==&lt;br /&gt;
&lt;br /&gt;
Show a custom layout of a 3D view on top of the red slice view:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
customLayout = (&amp;quot;&amp;lt;layout type=\&amp;quot;vertical\&amp;quot; split=\&amp;quot;true\&amp;quot; &amp;gt;&amp;quot;&lt;br /&gt;
  &amp;quot; &amp;lt;item&amp;gt;&amp;quot;&lt;br /&gt;
  &amp;quot;  &amp;lt;view class=\&amp;quot;vtkMRMLViewNode\&amp;quot; singletontag=\&amp;quot;1\&amp;quot;&amp;gt;&amp;quot;&lt;br /&gt;
  &amp;quot;    &amp;lt;property name=\&amp;quot;viewlabel\&amp;quot; action=\&amp;quot;default\&amp;quot;&amp;gt;1&amp;lt;/property&amp;gt;&amp;quot;&lt;br /&gt;
  &amp;quot;  &amp;lt;/view&amp;gt;&amp;quot;&lt;br /&gt;
  &amp;quot; &amp;lt;/item&amp;gt;&amp;quot;&lt;br /&gt;
  &amp;quot; &amp;lt;item&amp;gt;&amp;quot;&lt;br /&gt;
  &amp;quot;  &amp;lt;view class=\&amp;quot;vtkMRMLSliceNode\&amp;quot; singletontag=\&amp;quot;Red\&amp;quot;&amp;gt;&amp;quot;&lt;br /&gt;
  &amp;quot;   &amp;lt;property name=\&amp;quot;orientation\&amp;quot; action=\&amp;quot;default\&amp;quot;&amp;gt;Axial&amp;lt;/property&amp;gt;&amp;quot;&lt;br /&gt;
  &amp;quot;   &amp;lt;property name=\&amp;quot;viewlabel\&amp;quot; action=\&amp;quot;default\&amp;quot;&amp;gt;R&amp;lt;/property&amp;gt;&amp;quot;&lt;br /&gt;
  &amp;quot;   &amp;lt;property name=\&amp;quot;viewcolor\&amp;quot; action=\&amp;quot;default\&amp;quot;&amp;gt;#F34A33&amp;lt;/property&amp;gt;&amp;quot;&lt;br /&gt;
  &amp;quot;  &amp;lt;/view&amp;gt;&amp;quot;&lt;br /&gt;
  &amp;quot; &amp;lt;/item&amp;gt;&amp;quot;&lt;br /&gt;
  &amp;quot;&amp;lt;/layout&amp;gt;&amp;quot;)&lt;br /&gt;
  &lt;br /&gt;
customLayoutId=501&lt;br /&gt;
&lt;br /&gt;
layoutManager = slicer.app.layoutManager()&lt;br /&gt;
layoutManager.layoutLogic().GetLayoutNode().AddLayoutDescription(customLayoutId, customLayout)                                         &lt;br /&gt;
layoutManager.setLayout(customLayoutId)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
See description of standard layouts (that can be used as examples) here:&lt;br /&gt;
https://github.com/Slicer/Slicer/blob/master/Libs/MRML/Logic/vtkMRMLLayoutLogic.cxx&lt;br /&gt;
&lt;br /&gt;
== Disable certain user interactions in slice views ==&lt;br /&gt;
&lt;br /&gt;
For example, disable slice browsing using mouse wheel and keyboard shortcuts in the red slice viewer:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
interactorStyle = slicer.app.layoutManager().sliceWidget('Red').sliceView().sliceViewInteractorStyle()&lt;br /&gt;
interactorStyle.SetActionEnabled(interactorStyle.BrowseSlice, False)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Hide all slice view controllers:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
lm = slicer.app.layoutManager()&lt;br /&gt;
for sliceViewName in lm.sliceViewNames():&lt;br /&gt;
  lm.sliceWidget(sliceViewName).sliceController().setVisible(False)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Hide all 3D view controllers:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
lm = slicer.app.layoutManager()&lt;br /&gt;
for viewIndex in range(slicer.app.layoutManager().threeDViewCount):&lt;br /&gt;
  lm.threeDWidget(0).threeDController().setVisible(False)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Change default slice view orientation ==&lt;br /&gt;
&lt;br /&gt;
You can left-right &amp;quot;flip&amp;quot; slice view orientation presets (show patient left side on left/right side of the screen) by copy-pasting the script below to your [[Documentation/{{documentation/version}}/Developers/FAQ/Python_Scripting#How_to_systematically_execute_custom_python_code_at_startup_.3F| .slicerrc.py file]].&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Axial slice axes:&lt;br /&gt;
#  1 0 0&lt;br /&gt;
#  0 1 0&lt;br /&gt;
#  0 0 1&lt;br /&gt;
axialSliceToRas=vtk.vtkMatrix3x3()&lt;br /&gt;
&lt;br /&gt;
# Coronal slice axes:&lt;br /&gt;
#  1 0 0 &lt;br /&gt;
#  0 0 -1&lt;br /&gt;
#  0 1 0&lt;br /&gt;
coronalSliceToRas=vtk.vtkMatrix3x3()&lt;br /&gt;
coronalSliceToRas.SetElement(1,1, 0)&lt;br /&gt;
coronalSliceToRas.SetElement(1,2, -1)&lt;br /&gt;
coronalSliceToRas.SetElement(2,1, 1)&lt;br /&gt;
coronalSliceToRas.SetElement(2,2, 0)&lt;br /&gt;
&lt;br /&gt;
# Replace orientation presets in all existing slice nodes and in the default slice node&lt;br /&gt;
sliceNodes = slicer.util.getNodesByClass('vtkMRMLSliceNode')&lt;br /&gt;
sliceNodes.append(slicer.mrmlScene.GetDefaultNodeByClass('vtkMRMLSliceNode'))&lt;br /&gt;
for sliceNode in sliceNodes:&lt;br /&gt;
  orientationPresetName = sliceNode.GetOrientation()&lt;br /&gt;
  sliceNode.RemoveSliceOrientationPreset(&amp;quot;Axial&amp;quot;)&lt;br /&gt;
  sliceNode.AddSliceOrientationPreset(&amp;quot;Axial&amp;quot;, axialSliceToRas)&lt;br /&gt;
  sliceNode.RemoveSliceOrientationPreset(&amp;quot;Coronal&amp;quot;)&lt;br /&gt;
  sliceNode.AddSliceOrientationPreset(&amp;quot;Coronal&amp;quot;, coronalSliceToRas)&lt;br /&gt;
  sliceNode.SetOrientation(orientationPresetName)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Set up custom units in slice view ruler ==&lt;br /&gt;
&lt;br /&gt;
For microscopy or micro-CT images you may want to switch unit to micrometer instead of the default mm. To do that, 1. change the unit in Application settings / Units and 2. update ruler display settings using the script below (it can be copied to your Application startup script):&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
lm = slicer.app.layoutManager()&lt;br /&gt;
for sliceViewName in lm.sliceViewNames():&lt;br /&gt;
  sliceView = lm.sliceWidget(sliceViewName).sliceView()&lt;br /&gt;
  displayableManagerCollection = vtk.vtkCollection()&lt;br /&gt;
  sliceView.getDisplayableManagers(displayableManagerCollection)&lt;br /&gt;
  for dmIndex in xrange(displayableManagerCollection.GetNumberOfItems()):&lt;br /&gt;
    displayableManager = displayableManagerCollection.GetItemAsObject(dmIndex)&lt;br /&gt;
    if not displayableManager.IsA(&amp;quot;vtkMRMLRulerDisplayableManager&amp;quot;):&lt;br /&gt;
      continue&lt;br /&gt;
    displayableManager.RemoveAllRulerScalePresets()&lt;br /&gt;
    displayableManager.AddRulerScalePreset(   0.001, 5, 2, &amp;quot;nm&amp;quot;, 1000.0)&lt;br /&gt;
    displayableManager.AddRulerScalePreset(   0.010, 5, 2, &amp;quot;nm&amp;quot;, 1000.0)&lt;br /&gt;
    displayableManager.AddRulerScalePreset(   0.100, 5, 2, &amp;quot;nm&amp;quot;, 1000.0)&lt;br /&gt;
    displayableManager.AddRulerScalePreset(   0.500, 5, 1, &amp;quot;nm&amp;quot;, 1000.0)&lt;br /&gt;
    displayableManager.AddRulerScalePreset(   1.0,   5, 2, &amp;quot;um&amp;quot;,    1.0)&lt;br /&gt;
    displayableManager.AddRulerScalePreset(   5.0,   5, 1, &amp;quot;um&amp;quot;,    1.0)&lt;br /&gt;
    displayableManager.AddRulerScalePreset(  10.0,   5, 2, &amp;quot;um&amp;quot;,    1.0)&lt;br /&gt;
    displayableManager.AddRulerScalePreset(  50.0,   5, 1, &amp;quot;um&amp;quot;,    1.0)&lt;br /&gt;
    displayableManager.AddRulerScalePreset( 100.0,   5, 2, &amp;quot;um&amp;quot;,    1.0)&lt;br /&gt;
    displayableManager.AddRulerScalePreset( 500.0,   5, 1, &amp;quot;um&amp;quot;,    1.0)&lt;br /&gt;
    displayableManager.AddRulerScalePreset(1000.0,   5, 2, &amp;quot;mm&amp;quot;,    0.001)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Show a slice view outside the view layout ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sliceLayoutName = &amp;quot;TestSlice&amp;quot;&lt;br /&gt;
sliceLayoutLabel = &amp;quot;T&amp;quot;&lt;br /&gt;
# ownerNode manages this view instead of the layout manager (it can be any node in the scene)&lt;br /&gt;
viewOwnerNode = slicer.mrmlScene.AddNewNodeByClass(&amp;quot;vtkMRMLScriptedModuleNode&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
# Create MRML nodes&lt;br /&gt;
sliceNode = slicer.vtkMRMLSliceNode()&lt;br /&gt;
sliceNode.SetName(sliceLayoutName)&lt;br /&gt;
sliceNode.SetLayoutName(sliceLayoutName)&lt;br /&gt;
sliceNode.SetLayoutLabel(sliceLayoutLabel)&lt;br /&gt;
sliceNode.SetLayoutColor(1, 1, 0)&lt;br /&gt;
sliceNode.SetAndObserveParentLayoutNodeID(viewOwnerNode.GetID())&lt;br /&gt;
sliceNode = slicer.mrmlScene.AddNode(sliceNode)&lt;br /&gt;
sliceCompositeNode = slicer.mrmlScene.AddNewNodeByClass(&amp;quot;vtkMRMLSliceCompositeNode&amp;quot;)&lt;br /&gt;
sliceCompositeNode.SetLayoutName(sliceLayoutName)&lt;br /&gt;
&lt;br /&gt;
# Create widget&lt;br /&gt;
sliceWidget = slicer.qMRMLSliceWidget()&lt;br /&gt;
sliceWidget.sliceViewName = sliceLayoutName&lt;br /&gt;
sliceWidget.sliceViewLabel = sliceLayoutLabel&lt;br /&gt;
c = sliceNode.GetLayoutColor()&lt;br /&gt;
sliceWidget.sliceViewColor = qt.QColor.fromRgbF(c[0],c[1],c[2])&lt;br /&gt;
sliceWidget.setMRMLScene(slicer.mrmlScene)&lt;br /&gt;
sliceWidget.setMRMLSliceNode(sliceNode)&lt;br /&gt;
sliceWidget.show()&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Running an ITK filter in Python using SimpleITK ==&lt;br /&gt;
Open the &amp;quot;Sample Data&amp;quot; module and download &amp;quot;MR Head&amp;quot;, then paste the following snippet in Python interactor:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
import SimpleITK as sitk&lt;br /&gt;
import sitkUtils&lt;br /&gt;
inputImage = sitkUtils.PullFromSlicer('MRHead')&lt;br /&gt;
filter = sitk.SignedMaurerDistanceMapImageFilter()&lt;br /&gt;
outputImage = filter.Execute(inputImage)&lt;br /&gt;
sitkUtils.PushToSlicer(outputImage,'outputImage')&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
More information:&lt;br /&gt;
* See the SimpleITK documentation for SimpleITK examples: http://www.itk.org/SimpleITKDoxygen/html/examples.html&lt;br /&gt;
* sitkUtils in Slicer is used for pushing and pulling images from Slicer to SimpleITK: https://github.com/Slicer/Slicer/blob/master/Base/Python/sitkUtils.py&lt;br /&gt;
&lt;br /&gt;
== Get current mouse coordinates in a slice view ==&lt;br /&gt;
&lt;br /&gt;
You can get 3D (RAS) coordinates of the current mouse cursor from the crosshair singleton node as shown in the example below:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
def onMouseMoved(observer,eventid):  &lt;br /&gt;
  ras=[0,0,0]&lt;br /&gt;
  crosshairNode.GetCursorPositionRAS(ras)&lt;br /&gt;
  print(ras)&lt;br /&gt;
&lt;br /&gt;
crosshairNode=slicer.util.getNode('Crosshair') &lt;br /&gt;
crosshairNode.AddObserver(slicer.vtkMRMLCrosshairNode.CursorPositionModifiedEvent, onMouseMoved)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Get DataProbe text ==&lt;br /&gt;
&lt;br /&gt;
You can get the mouse location in pixel coordinates along with the pixel value at the mouse by hitting the '.' (period) key in a slice view after pasting in the following code.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
def printDataProbe():&lt;br /&gt;
  infoWidget = slicer.modules.DataProbeInstance.infoWidget&lt;br /&gt;
  for layer in ('B', 'F', 'L'):&lt;br /&gt;
    print(infoWidget.layerNames[layer].text, infoWidget.layerIJKs[layer].text, infoWidget.layerValues[layer].text)&lt;br /&gt;
&lt;br /&gt;
s = qt.QShortcut(qt.QKeySequence('.'), mainWindow())&lt;br /&gt;
s.connect('activated()', printDataProbe)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Thick slab reconstruction and maximum/minimum intensity volume projections ==&lt;br /&gt;
&lt;br /&gt;
Set up 'red' slice viewer to show thick slab reconstructed from 3 slices:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sliceNode = slicer.mrmlScene.GetNodeByID('vtkMRMLSliceNodeRed')&lt;br /&gt;
appLogic = slicer.app.applicationLogic()&lt;br /&gt;
sliceLogic = appLogic.GetSliceLogic(sliceNode)&lt;br /&gt;
sliceLayerLogic = sliceLogic.GetBackgroundLayer()&lt;br /&gt;
reslice = sliceLayerLogic.GetReslice()&lt;br /&gt;
reslice.SetSlabModeToMean()&lt;br /&gt;
reslice.SetSlabNumberOfSlices(10) # mean of 10 slices will computed&lt;br /&gt;
reslice.SetSlabSliceSpacingFraction(0.3) # spacing between each slice is 0.3 pixel (total 10 * 0.3 = 3 pixel neighborhood)&lt;br /&gt;
sliceNode.Modified()&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Set up 'red' slice viewer to show maximum intensity projection (MIP):&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sliceNode = slicer.mrmlScene.GetNodeByID('vtkMRMLSliceNodeRed')&lt;br /&gt;
appLogic = slicer.app.applicationLogic()&lt;br /&gt;
sliceLogic = appLogic.GetSliceLogic(sliceNode)&lt;br /&gt;
sliceLayerLogic = sliceLogic.GetBackgroundLayer()&lt;br /&gt;
reslice = sliceLayerLogic.GetReslice()&lt;br /&gt;
reslice.SetSlabModeToMax()&lt;br /&gt;
reslice.SetSlabNumberOfSlices(600) # use a large number of slices (600) to cover the entire volume&lt;br /&gt;
reslice.SetSlabSliceSpacingFraction(0.5) # spacing between slices are 0.5 pixel (supersampling is useful to reduce interpolation artifacts)&lt;br /&gt;
sliceNode.Modified()&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The projected image is available in a ''vtkImageData'' object by calling ''reslice.GetOutput()''.&lt;br /&gt;
&lt;br /&gt;
== Change default file type for nodes (that have never been saved yet) ==&lt;br /&gt;
Default node can be specified that will be used as a basis of all new storage nodes. This can be used for setting default file extension. For example, change file format to STL for model nodes:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
defaultModelStorageNode = slicer.vtkMRMLModelStorageNode()&lt;br /&gt;
defaultModelStorageNode.SetDefaultWriteFileExtension('stl')&lt;br /&gt;
slicer.mrmlScene.AddDefaultNode(defaultModelStorageNode)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To permanently change default file extension on your computer, copy-paste the code above into your application startup script (you can find its location in menu: Edit / Application settings / General / Application startup script).&lt;br /&gt;
&lt;br /&gt;
== Change file type for saving for all volumes (with already existing storage nodes) ==&lt;br /&gt;
&lt;br /&gt;
If it is not necessary to preserve file paths then the simplest is to configure default storage node (as shown in the example above), then delete all existing storage nodes. When save dialog is opened, default storage nodes will be recreated.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Delete existing model storage nodes so that they will be recreated with default settings&lt;br /&gt;
existingModelStorageNodes = slicer.util.getNodesByClass('vtkMRMLModelStorageNode')&lt;br /&gt;
for modelStorageNode in existingModelStorageNodes:&lt;br /&gt;
  slicer.mrmlScene.RemoveNode(modelStorageNode)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To update existing storage nodes to use new file extension (but keep all other parameters unchanged) you can use this approach (example is for volume storage):&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
requiredFileExtension = '.nia'&lt;br /&gt;
originalFileExtension = '.nrrd'&lt;br /&gt;
volumeNodes = slicer.util.getNodesByClass('vtkMRMLScalarVolumeNode')&lt;br /&gt;
for volumeNode in volumeNodes:&lt;br /&gt;
  volumeStorageNode = volumeNode.GetStorageNode()&lt;br /&gt;
  if not volumeStorageNode:&lt;br /&gt;
    volumeNode.AddDefaultStorageNode()&lt;br /&gt;
    volumeStorageNode = volumeNode.GetStorageNode()&lt;br /&gt;
    volumeStorageNode.SetFileName(volumeNode.GetName()+requiredFileExtension)&lt;br /&gt;
  else:&lt;br /&gt;
    volumeStorageNode.SetFileName(volumeStorageNode.GetFileName().replace(originalFileExtension, requiredFileExtension))&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Segmentations ==&lt;br /&gt;
&lt;br /&gt;
=== Create a segmentation from a labelmap volume and display in 3D ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
labelmapVolumeNode = getNode('label')&lt;br /&gt;
seg = slicer.mrmlScene.AddNewNodeByClass('vtkMRMLSegmentationNode')&lt;br /&gt;
slicer.modules.segmentations.logic().ImportLabelmapToSegmentationNode(labelmapVolumeNode, seg)&lt;br /&gt;
seg.CreateClosedSurfaceRepresentation()&lt;br /&gt;
slicer.mrmlScene.RemoveNode(labelmapVolumeNode)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The last line is optional. It removes the original labelmap volume so that the same information is not shown twice.&lt;br /&gt;
&lt;br /&gt;
=== Export labelmap node from segmentation node ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
seg = getNode('Segmentation')&lt;br /&gt;
labelmapVolumeNode = slicer.mrmlScene.AddNewNodeByClass('vtkMRMLLabelMapVolumeNode')&lt;br /&gt;
slicer.modules.segmentations.logic().ExportAllSegmentsToLabelmapNode(seg, labelmapVolumeNode)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Show a segmentation in 3D ===&lt;br /&gt;
Segmentation can only be shown in 3D if closed surface representation (or other 3D-displayable representation) is available. To create closed surface representation:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
segmentation.CreateClosedSurfaceRepresentation()&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Get a representation of a segment ===&lt;br /&gt;
Access binary labelmap stored in a segmentation node (without exporting it to a volume node) - if it does not exist, it will return None:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
image = segmentationNode.GetBinaryLabelmapRepresentation(segmentID)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Get closed surface, if it does not exist, it will return None:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
polydata = segmentationNode.GetClosedSurfaceRepresentation(segmentID)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Get binary labelmap representation. If it does not exist then it will be created for that single segment. Applies parent transforms by default (if not desired, another argument needs to be added to the end: false):&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
import vtkSegmentationCorePython as vtkSegmentationCore&lt;br /&gt;
outputOrientedImageData = vtkSegmentationCore.vtkOrientedImageData()&lt;br /&gt;
slicer.vtkSlicerSegmentationsModuleLogic.GetSegmentBinaryLabelmapRepresentation(segmentationNode, segmentID, outputOrientedImageData)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Same as above, for closed surface representation:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
outputPolyData = vtk.vtkPolyData()&lt;br /&gt;
slicer.vtkSlicerSegmentationsModuleLogic.GetSegmentClosedSurfaceRepresentation(segmentationNode, segmentID, outputPolyData)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Convert all segments using default path and conversion parameters ===&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
segmentationNode.CreateBinaryLabelmapRepresentation()&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Convert all segments using custom path or conversion parameters ===&lt;br /&gt;
Change reference image geometry parameter based on an existing referenceImageData image:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
import vtkSegmentationCorePython as vtkSegmentationCore&lt;br /&gt;
referenceGeometry = vtkSegmentationCore.vtkSegmentationConverter.SerializeImageGeometry(referenceImageData)&lt;br /&gt;
segmentation.SetConversionParameter(vtkSegmentationCore.vtkSegmentationConverter.GetReferenceImageGeometryParameterName(), referenceGeometry)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Re-convert using a modified conversion parameter ===&lt;br /&gt;
Changing smoothing factor for closed surface generation:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
import vtkSegmentationCorePython as vtkSegmentationCore&lt;br /&gt;
segmentation = getNode('Segmentation').GetSegmentation()&lt;br /&gt;
&lt;br /&gt;
# Turn of surface smoothing&lt;br /&gt;
segmentation.SetConversionParameter('Smoothing factor','0.0')&lt;br /&gt;
&lt;br /&gt;
# Recreate representation using modified parameters (and default conversion path)&lt;br /&gt;
segmentation.RemoveRepresentation(vtkSegmentationCore.vtkSegmentationConverter.GetSegmentationClosedSurfaceRepresentationName())&lt;br /&gt;
segmentation.CreateRepresentation(vtkSegmentationCore.vtkSegmentationConverter.GetSegmentationClosedSurfaceRepresentationName())&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== How to run segment editor effects from a script ===&lt;br /&gt;
&lt;br /&gt;
Editor effects are complex because they need to handle changing master volumes, undo/redo, masking operations, etc. Therefore, instead of using a segment editor effect, it is simpler to run the underlying filters directly from script.&lt;br /&gt;
&lt;br /&gt;
This example demonstrates how to use Segment editor effects (without GUI, using qMRMLSegmentEditorWidget):&lt;br /&gt;
&lt;br /&gt;
* [https://gist.github.com/lassoan/2d5a5b73645f65a5eb6f8d5f97abf31b brain tumor segmentation using grow from seeds effect]&lt;br /&gt;
* [https://gist.github.com/lassoan/1673b25d8e7913cbc245b4f09ed853f9 skin surface extraction using thresholding and smoothing]&lt;br /&gt;
* [https://gist.github.com/lassoan/2f5071c562108dac8efe277c78f2620f mask a volume with segments and compute histogram for each region]&lt;br /&gt;
&lt;br /&gt;
This example shows how to perform operations on segmentations using VTK filters:&lt;br /&gt;
* [https://gist.github.com/lassoan/7c94c334653010696b2bf96abc0ac8e7 brain tumor segmentation using grow from seeds effect]&lt;br /&gt;
&lt;br /&gt;
== Accessing views, renderers, and cameras ==&lt;br /&gt;
&lt;br /&gt;
Iterate through all 3D views in current layout:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
layoutManager = slicer.app.layoutManager()&lt;br /&gt;
for threeDViewIndex in range(layoutManager.threeDViewCount) :&lt;br /&gt;
  view = layoutManager.threeDWidget(threeDViewIndex).threeDView()&lt;br /&gt;
  threeDViewNode = view.mrmlViewNode()&lt;br /&gt;
  cameraNode = slicer.modules.cameras.logic().GetViewActiveCameraNode(threeDViewNode)&lt;br /&gt;
  print('View node for 3D widget ' + str(threeDViewIndex))&lt;br /&gt;
  print('  Name: ' + threeDViewNode .GetName())&lt;br /&gt;
  print('  ID: ' + threeDViewNode .GetID())&lt;br /&gt;
  print('  Camera ID: ' + cameraNode.GetID())&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Iterate through all slice views in current layout:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
layoutManager = slicer.app.layoutManager()&lt;br /&gt;
for sliceViewName in layoutManager.sliceViewNames():&lt;br /&gt;
  view = layoutManager.sliceWidget(sliceViewName).sliceView()&lt;br /&gt;
  sliceNode = view.mrmlSliceNode()&lt;br /&gt;
  sliceLogic = slicer.app.applicationLogic().GetSliceLogic(sliceNode)&lt;br /&gt;
  compositeNode = sliceLogic.GetSliceCompositeNode()&lt;br /&gt;
  print('Slice view ' + str(sliceViewName))&lt;br /&gt;
  print('  Name: ' + sliceNode.GetName())&lt;br /&gt;
  print('  ID: ' + sliceNode.GetID())&lt;br /&gt;
  print('  Background volume: {0}'.format(compositeNode.GetBackgroundVolumeID()))&lt;br /&gt;
  print('  Foreground volume: {0} (opacity: {1})'.format(compositeNode.GetForegroundVolumeID(), compositeNode.GetForegroundOpacity()))&lt;br /&gt;
  print('  Label volume: {0} (opacity: {1})'.format(compositeNode.GetLabelVolumeID(), compositeNode.GetLabelOpacity()))&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
For low-level manipulation of views, it is possible to access VTK render windows, renderers and cameras of views in the current layout.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
renderWindow = view.renderWindow()&lt;br /&gt;
renderers = renderWindow.GetRenderers()&lt;br /&gt;
renderer = renderers.GetItemAsObject(0)&lt;br /&gt;
camera = cameraNode.GetCamera()&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Change 3D view background color ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
renderWindow = slicer.app.layoutManager().threeDWidget(0).threeDView().renderWindow()&lt;br /&gt;
renderer = renderWindow.GetRenderers().GetFirstRenderer()&lt;br /&gt;
renderer.SetBackground(1,0,0)&lt;br /&gt;
renderer.SetBackground2(1,0,0)&lt;br /&gt;
renderWindow.Render()&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Subject hierarchy == &lt;br /&gt;
==== Get the pseudo-singleton subject hierarchy node ====&lt;br /&gt;
It manages the whole hierarchy and provides functions to access and manipulate&lt;br /&gt;
  shNode = slicer.vtkMRMLSubjectHierarchyNode.GetSubjectHierarchyNode(slicer.mrmlScene)&lt;br /&gt;
&lt;br /&gt;
==== Create subject hierarchy item ====&lt;br /&gt;
  # If it is for a data node, it is automatically created, but the create function can be used to set parent:&lt;br /&gt;
  shNode.CreateItem(parentItemID, dataNode)&lt;br /&gt;
  # If it is a hierarchy item without a data node, then the create function must be used:&lt;br /&gt;
  shNode.CreateSubjectItem(parentItemID, name)&lt;br /&gt;
  shNode.CreateFolderItem(parentItemID, name)&lt;br /&gt;
  shNode.CreateHierarchyItem(parentItemID, name, level) # Advanced method to set level attribute manually (usually subject, study, or folder, but it can be a virtual branch for example)&lt;br /&gt;
&lt;br /&gt;
==== Get subject hierarchy item ====&lt;br /&gt;
Items in subject hierarchy are uniquely identified by integer IDs&lt;br /&gt;
  # Get scene item ID first because it is the root item:&lt;br /&gt;
  sceneItemID = shNode.GetSceneItemID()&lt;br /&gt;
  # Get direct child by name&lt;br /&gt;
  subjectItemID = shNode.GetItemChildWithName(sceneItemID, 'Subject_1')&lt;br /&gt;
  # Get item for data node&lt;br /&gt;
  itemID = shNode.GetItemByDataNode(dataNode)&lt;br /&gt;
  # Get item by UID (such as DICOM)&lt;br /&gt;
  itemID = shNode.GetItemByUID(slicer.vtkMRMLSubjectHierarchyConstants.GetDICOMUIDName(), seriesInstanceUid)&lt;br /&gt;
  itemID = shNode.GetItemByUIDList(slicer.vtkMRMLSubjectHierarchyConstants.GetDICOMInstanceUIDName(), instanceUID)&lt;br /&gt;
  # Invalid item ID for checking validity of a given ID (most functions return the invalid ID when item is not found)&lt;br /&gt;
  invalidItemID = slicer.vtkMRMLSubjectHierarchyNode.GetInvalidItemID()&lt;br /&gt;
&lt;br /&gt;
==== Traverse children of a subject hierarchy item ====&lt;br /&gt;
  children = vtk.vtkIdList()&lt;br /&gt;
  shNode.GetItemChildren(parent, children)&lt;br /&gt;
  for i in xrange(children.GetNumberOfIds()):&lt;br /&gt;
    child = children.GetId(i)&lt;br /&gt;
    ...&lt;br /&gt;
&lt;br /&gt;
==== Manipulate subject hierarchy item ====&lt;br /&gt;
Instead of node operations on the individual subject hierarchy nodes, item operations are performed on the one subject hierarchy node.&lt;br /&gt;
  # Set item name&lt;br /&gt;
  shNode.SetItemName(itemID, 'NewName')&lt;br /&gt;
  # Set item parent (reparent)&lt;br /&gt;
  shNode.SetItemParent(itemID, newParentItemID)&lt;br /&gt;
  # Set visibility of data nodes associated to items in a branch (or a leaf item)&lt;br /&gt;
  shNode.SetDisplayVisibilityForBranch(itemID, 1)&lt;br /&gt;
&lt;br /&gt;
==== Filter items in TreeView or ComboBox ====&lt;br /&gt;
Displayed items can be filtered using ''setAttributeFilter'' method. An example of the usage can be found in the  [https://github.com/Slicer/Slicer/blob/e66e3b08e35384526528e6ae678e9ec9f079f286/Applications/SlicerApp/Testing/Python/SubjectHierarchyGenericSelfTest.py#L352-L360 unit test]. Modified version here:&lt;br /&gt;
    print shTreeView.displayedItemCount() # 5&lt;br /&gt;
    shTreeView.setAttributeFilter('DICOM.Modality') # Nodes must have this attribute&lt;br /&gt;
    print shTreeView.displayedItemCount() # 3&lt;br /&gt;
    shTreeView.setAttributeFilter('DICOM.Modality','CT') # Have attribute and equal 'CT'&lt;br /&gt;
    print shTreeView.displayedItemCount() # 1&lt;br /&gt;
    shTreeView.removeAttributeFilter()&lt;br /&gt;
    print shTreeView.displayedItemCount() # 5&lt;br /&gt;
&lt;br /&gt;
== Plotting ==&lt;br /&gt;
&lt;br /&gt;
=== Create histogram plot of a volume ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Get a volume from SampleData&lt;br /&gt;
import SampleData&lt;br /&gt;
volumeNode = SampleData.SampleDataLogic().downloadMRHead()&lt;br /&gt;
&lt;br /&gt;
# Compute histogram values&lt;br /&gt;
import numpy as np&lt;br /&gt;
histogram = np.histogram(arrayFromVolume(volumeNode), bins=50)&lt;br /&gt;
&lt;br /&gt;
# Save results to a new table node&lt;br /&gt;
tableNode=slicer.mrmlScene.AddNewNodeByClass(&amp;quot;vtkMRMLTableNode&amp;quot;)&lt;br /&gt;
updateTableFromArray(tableNode, histogram)&lt;br /&gt;
tableNode.GetTable().GetColumn(0).SetName(&amp;quot;Count&amp;quot;)&lt;br /&gt;
tableNode.GetTable().GetColumn(1).SetName(&amp;quot;Intensity&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
# Create plot&lt;br /&gt;
plotSeriesNode = slicer.mrmlScene.AddNewNodeByClass(&amp;quot;vtkMRMLPlotSeriesNode&amp;quot;, volumeNode.GetName() + ' histogram')&lt;br /&gt;
plotSeriesNode.SetAndObserveTableNodeID(tableNode.GetID())&lt;br /&gt;
plotSeriesNode.SetXColumnName(&amp;quot;Intensity&amp;quot;)&lt;br /&gt;
plotSeriesNode.SetYColumnName(&amp;quot;Count&amp;quot;)&lt;br /&gt;
plotSeriesNode.SetPlotType(plotSeriesNode.PlotTypeScatterBar)&lt;br /&gt;
plotSeriesNode.SetColor(0, 0.6, 1.0)&lt;br /&gt;
&lt;br /&gt;
# Create chart and add plot&lt;br /&gt;
plotChartNode = slicer.mrmlScene.AddNewNodeByClass(&amp;quot;vtkMRMLPlotChartNode&amp;quot;)&lt;br /&gt;
plotChartNode.AddAndObservePlotSeriesNodeID(plotSeriesNode.GetID())&lt;br /&gt;
plotChartNode.YAxisRangeAutoOff()&lt;br /&gt;
plotChartNode.SetYAxisRange(0, 500000)&lt;br /&gt;
&lt;br /&gt;
# Show plot in layout&lt;br /&gt;
slicer.modules.plots.logic().ShowChartInLayout(plotChartNode)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Execute external applications ==&lt;br /&gt;
&lt;br /&gt;
How to run external applications from Slicer.&lt;br /&gt;
&lt;br /&gt;
=== Run process in default environment ===&lt;br /&gt;
&lt;br /&gt;
When a process is launched from Slicer then by default Slicer's ITK, VTK, Qt, etc. libraries are used. If an external application has its own version of these libraries, then the application is expected to crash. To prevent crashing, the application must be run in the environment where Slicer started up (without all Slicer-specific library paths). This startup environment can be retrieved using ''slicer.util.startupEnvironment()''.&lt;br /&gt;
&lt;br /&gt;
Example: run Python3 script from Slicer:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
command_to_execute = [&amp;quot;/usr/bin/python3&amp;quot;, &amp;quot;-c&amp;quot;, &amp;quot;print('hola')&amp;quot;]&lt;br /&gt;
from subprocess import check_output&lt;br /&gt;
check_output(&lt;br /&gt;
  command_to_execute, &lt;br /&gt;
  env=slicer.util.startupEnvironment()&lt;br /&gt;
  )&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
will output:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
'hola\n'&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
On some systems, ''shell=True'' must be specified as well.&lt;/div&gt;</summary>
		<author><name>Inorton</name></author>
		
	</entry>
	<entry>
		<id>https://www.slicer.org/w/index.php?title=Documentation/Nightly/ScriptRepository&amp;diff=58991</id>
		<title>Documentation/Nightly/ScriptRepository</title>
		<link rel="alternate" type="text/html" href="https://www.slicer.org/w/index.php?title=Documentation/Nightly/ScriptRepository&amp;diff=58991"/>
		<updated>2018-05-21T18:54:23Z</updated>

		<summary type="html">&lt;p&gt;Inorton: /* Export a fiber tracts to Blender, including color */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;noinclude&amp;gt;{{documentation/versioncheck}}&amp;lt;/noinclude&amp;gt;&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Community-contributed modules=&lt;br /&gt;
&lt;br /&gt;
The examples in this section are [[Documentation/{{documentation/version}}/Developers/Modules#Scripted_Modules| Scripted Modules]] that provide a user interface in the module panel along with specialized implementation logic.&lt;br /&gt;
&lt;br /&gt;
Usage: save the .py file to a directory, add the directory to the additional module paths in the Slicer application settings (choose in the menu: Edit / Application settings, click Modules, click &amp;gt;&amp;gt; next to Additional module paths, click Add, and choose the .py file's location).&lt;br /&gt;
&lt;br /&gt;
==Filters==&lt;br /&gt;
* [https://raw.github.com/pieper/VolumeMasker/master/VolumeMasker.py VolumeMasker.py]: Update a target volume with the results of setting all input volume voxels to 0 except for those that correspond to a selected label value in an input label map (Used for example in the volume rendering in [https://www.youtube.com/watch?v=dfu2gugHLHs this video).&lt;br /&gt;
&lt;br /&gt;
==DICOM==&lt;br /&gt;
* [https://gist.github.com/pieper/6186477 dicom header browser] to easily scroll through dicom files using dcmdump.&lt;br /&gt;
* [https://github.com/SlicerRt/SlicerRT/tree/master/BatchProcessing SlicerRT batch processing] to batch convert RT structure sets to labelmap NRRD files.&lt;br /&gt;
&lt;br /&gt;
==Informatics==&lt;br /&gt;
* [https://gist.github.com/lassoan/bf0954d93cacc8cbe27cd4a3ad503f2f MarkupsInfo.py]: Compute the total length between all the points of a markup list.&lt;br /&gt;
* [https://gist.github.com/lassoan/0e7acfbec36e4577f8b7b0e07ad53a2a LineProfile.py]: Compute intensity profile in a volume along a line.&lt;br /&gt;
&lt;br /&gt;
=Community-contributed examples=&lt;br /&gt;
&lt;br /&gt;
Usage: Copy-paste the shown code lines or linked .py file contents into Python console in Slicer.  Or save them to a file and run them using execfile.&lt;br /&gt;
&lt;br /&gt;
==Capture==&lt;br /&gt;
* Capture the full Slicer screen and save it into a file&lt;br /&gt;
  img = qt.QPixmap.grabWidget(slicer.util.mainWindow()).toImage()&lt;br /&gt;
  img.save('c:/tmp/test.png')&lt;br /&gt;
* Capture all the views save it into a file:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
import ScreenCapture&lt;br /&gt;
cap = ScreenCapture.ScreenCaptureLogic()&lt;br /&gt;
cap.showViewControllers(False)&lt;br /&gt;
cap.captureImageFromView(None,'c:/tmp/test.png')&lt;br /&gt;
cap.showViewControllers(True)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
* Capture a single view:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
viewNodeID = 'vtkMRMLViewNode1'&lt;br /&gt;
import ScreenCapture&lt;br /&gt;
cap = ScreenCapture.ScreenCaptureLogic()&lt;br /&gt;
view = cap.viewFromNode(slicer.mrmlScene.GetNodeByID(viewNodeID))&lt;br /&gt;
cap.captureImageFromView(view,'c:/tmp/test.png')&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Common values for viewNodeID: vtkMRMLSliceNodeRed, vtkMRMLSliceNodeYellow, vtkMRMLSliceNodeGreen, vtkMRMLViewNode1, vtkMRMLViewNode2. &lt;br /&gt;
The ScreenCapture module can also create video animations of rotating views, slice sweeps, etc.&lt;br /&gt;
&lt;br /&gt;
* Capture a slice view sweep into a series of PNG files - for example, Red slice view, 30 images, from position -125.0 to 75.0, into c:/tmp folder, with name image_00001.png, image_00002.png, ...&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
import ScreenCapture&lt;br /&gt;
ScreenCapture.ScreenCaptureLogic().captureSliceSweep(getNode('vtkMRMLSliceNodeRed'), -125.0, 75.0, 30, &amp;quot;c:/tmp&amp;quot;, &amp;quot;image_%05d.png&amp;quot;)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Capture 3D view into PNG file with transparent background&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
renderWindow = slicer.app.layoutManager().threeDWidget(0).threeDView().renderWindow()&lt;br /&gt;
renderWindow.SetAlphaBitPlanes(1)&lt;br /&gt;
wti = vtk.vtkWindowToImageFilter()&lt;br /&gt;
wti.SetInputBufferTypeToRGBA()&lt;br /&gt;
wti.SetInput(renderWindow)&lt;br /&gt;
writer = vtk.vtkPNGWriter()&lt;br /&gt;
writer.SetFileName(&amp;quot;c:/tmp/screenshot.png&amp;quot;)&lt;br /&gt;
writer.SetInputConnection(wti.GetOutputPort())&lt;br /&gt;
writer.Write()&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Launching Slicer==&lt;br /&gt;
* How to open an .mrb file with Slicer at the command line?&lt;br /&gt;
  Slicer.exe --python-code &amp;quot;slicer.util.loadScene( 'f:/2013-08-23-Scene.mrb' )&amp;quot;&lt;br /&gt;
* How to run a script in the Slicer environment in batch mode (without showing any graphical user interface)?&lt;br /&gt;
  Slicer.exe --python-code &amp;quot;doSomething; doSomethingElse; etc.&amp;quot; --testing --no-splash --no-main-window&lt;br /&gt;
&lt;br /&gt;
==Load volume from file==&lt;br /&gt;
When loading a volume from file, it is recommended to set returnNode=True to retrieve the loaded volume node.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
[success, loadedVolumeNode] = slicer.util.loadVolume('c:/Users/abc/Documents/MRHead.nrrd', returnNode=True)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Get a MRML node in the scene based on the node name and call methods of that object. For the MRHead sample data:&lt;br /&gt;
  vol=slicer.util.getNode('MR*')&lt;br /&gt;
  vol.GetImageData().GetDimensions()&lt;br /&gt;
&lt;br /&gt;
==DICOM==&lt;br /&gt;
=== How to access tags of DICOM images imported into Slicer? For example, to print the first patient's first study's first series' &amp;quot;0020,0032&amp;quot; field:===&lt;br /&gt;
  db=slicer.dicomDatabase&lt;br /&gt;
  patientList=db.patients()&lt;br /&gt;
  studyList=db.studiesForPatient(patientList[0])&lt;br /&gt;
  seriesList=db.seriesForStudy(studyList[0])&lt;br /&gt;
  fileList=db.filesForSeries(seriesList[0])&lt;br /&gt;
  print db.fileValue(fileList[0],'0020,0032')&lt;br /&gt;
&lt;br /&gt;
=== How to access tag of a volume loaded from DICOM? For example, get the patient position stored in a volume:===&lt;br /&gt;
  volumeName='2: ENT IMRT'&lt;br /&gt;
  n=slicer.util.getNode(volumeName)&lt;br /&gt;
  instUids=n.GetAttribute('DICOM.instanceUIDs').split()&lt;br /&gt;
  filename=slicer.dicomDatabase.fileForInstance(instUids[0])&lt;br /&gt;
  print slicer.dicomDatabase.fileValue(filename,'0018,5100')&lt;br /&gt;
&lt;br /&gt;
=== How to access tag of an item in the Subject Hierachy tree? For example, get the content time tag of a structure set:===&lt;br /&gt;
  rtStructName = '3: RTSTRUCT: PROS'&lt;br /&gt;
  rtStructNode = slicer.util.getNode(rtStructName)&lt;br /&gt;
  shNode = slicer.vtkMRMLSubjectHierarchyNode.GetSubjectHierarchyNode(slicer.mrmlScene)&lt;br /&gt;
  rtStructShItemID = shNode.GetItemByDataNode(rtStructNode)&lt;br /&gt;
  ctSliceInstanceUids = shNode.GetItemAttribute(rtStructShItemID, 'DICOM.ReferencedInstanceUIDs').split()&lt;br /&gt;
  filename = slicer.dicomDatabase.fileForInstance(ctSliceInstanceUids[0])&lt;br /&gt;
  print slicer.dicomDatabase.fileValue(filename,'0008,0033')&lt;br /&gt;
&lt;br /&gt;
=== How to get path and filename of a loaded DICOM volume?===&lt;br /&gt;
  def pathFromNode(node):&lt;br /&gt;
    storageNode=node.GetStorageNode()&lt;br /&gt;
    if storageNode is not None: # loaded via drag-drop&lt;br /&gt;
        filepath=storageNode.GetFullNameFromFileName()&lt;br /&gt;
    else: # loaded via DICOM browser&lt;br /&gt;
        instanceUIDs=node.GetAttribute('DICOM.instanceUIDs').split()&lt;br /&gt;
        filepath=slicer.dicomDatabase.fileForInstance(instUids[0])&lt;br /&gt;
    return filepath&lt;br /&gt;
  &lt;br /&gt;
  # example:&lt;br /&gt;
  node=slicer.util.getNode('volume1')&lt;br /&gt;
  path=self.pathFromNode(node)&lt;br /&gt;
  print(&amp;quot;DICOM path=%s&amp;quot; % path)&lt;br /&gt;
&lt;br /&gt;
=== How can I convert DICOM to NRRD on the command line?===&lt;br /&gt;
&lt;br /&gt;
 /Applications/Slicer-4.6.2.app/Contents/MacOS/Slicer --no-main-window --python-code &amp;quot;node=slicer.util.loadVolume('/tmp/series/im0.dcm', returnNode=True)[1]; slicer.util.saveNode(node, '/tmp/output.nrrd'); exit()&amp;quot;&lt;br /&gt;
&lt;br /&gt;
The same can be done on windows by using the top level Slicer.exe.  Be sure to use forward slashes in the pathnames within quotes on the command line.&lt;br /&gt;
&lt;br /&gt;
==Toolbar functions==&lt;br /&gt;
* How to turn on slice intersections in the crosshair menu on the toolbar:&lt;br /&gt;
  viewNodes = slicer.mrmlScene.GetNodesByClass('vtkMRMLSliceCompositeNode')&lt;br /&gt;
  viewNodes.UnRegister(slicer.mrmlScene)&lt;br /&gt;
  viewNodes.InitTraversal()&lt;br /&gt;
  viewNode = viewNodes.GetNextItemAsObject()&lt;br /&gt;
  while viewNode:&lt;br /&gt;
    viewNode.SetSliceIntersectionVisibility(1)&lt;br /&gt;
    viewNode = viewNodes.GetNextItemAsObject()&lt;br /&gt;
&lt;br /&gt;
How to find similar functions? For this one I searched for &amp;quot;slice intersections&amp;quot; text in the whole slicer source code, found that the function is implemented in Base\QTGUI\qSlicerViewersToolBar.cxx, then translated the qSlicerViewersToolBarPrivate::setSliceIntersectionVisible(bool visible) method to Python.&lt;br /&gt;
&lt;br /&gt;
==Manipulating objects in the slice viewer==&lt;br /&gt;
* How to define/edit a circular region of interest in a slice viewer?&lt;br /&gt;
&lt;br /&gt;
Drop two markup points on a slice view and copy-paste the code below into the Python console. After this, as you move the markups you’ll see a circle following the markups.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Update the sphere from the fiducial points&lt;br /&gt;
def UpdateSphere(param1, param2):  &lt;br /&gt;
  import math&lt;br /&gt;
  centerPointCoord = [0.0, 0.0, 0.0]&lt;br /&gt;
  markups.GetNthFiducialPosition(0,centerPointCoord)&lt;br /&gt;
  circumferencePointCoord = [0.0, 0.0, 0.0]&lt;br /&gt;
  markups.GetNthFiducialPosition(1,circumferencePointCoord)&lt;br /&gt;
  sphere.SetCenter(centerPointCoord)&lt;br /&gt;
  radius=math.sqrt((centerPointCoord[0]-circumferencePointCoord[0])**2+(centerPointCoord[1]-circumferencePointCoord[1])**2+(centerPointCoord[2]-circumferencePointCoord[2])**2)&lt;br /&gt;
  sphere.SetRadius(radius)&lt;br /&gt;
  sphere.SetPhiResolution(30)&lt;br /&gt;
  sphere.SetThetaResolution(30)&lt;br /&gt;
  sphere.Update()&lt;br /&gt;
&lt;br /&gt;
# Get markup node from scene&lt;br /&gt;
markups=slicer.util.getNode('F')&lt;br /&gt;
sphere = vtk.vtkSphereSource()&lt;br /&gt;
UpdateSphere(0,0)&lt;br /&gt;
 &lt;br /&gt;
# Create model node and add to scene&lt;br /&gt;
modelsLogic = slicer.modules.models.logic()&lt;br /&gt;
model = modelsLogic.AddModel(sphere.GetOutput())&lt;br /&gt;
model.GetDisplayNode().SetSliceIntersectionVisibility(True)&lt;br /&gt;
model.GetDisplayNode().SetSliceIntersectionThickness(3)&lt;br /&gt;
model.GetDisplayNode().SetColor(1,1,0)&lt;br /&gt;
 &lt;br /&gt;
# Call UpdateSphere whenever the fiducials are changed&lt;br /&gt;
markups.AddObserver(&amp;quot;ModifiedEvent&amp;quot;, UpdateSphere, 2)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Switching to markup fiducial placement mode ==&lt;br /&gt;
&lt;br /&gt;
To activate a fiducial placement mode, both interaction mode has to be set and a fiducial node has to be selected:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
interactionNode = slicer.app.applicationLogic().GetInteractionNode()&lt;br /&gt;
selectionNode = slicer.app.applicationLogic().GetSelectionNode()&lt;br /&gt;
selectionNode.SetReferenceActivePlaceNodeClassName(&amp;quot;vtkMRMLMarkupsFiducialNode&amp;quot;)&lt;br /&gt;
fiducialNode = slicer.vtkMRMLMarkupsFiducialNode()&lt;br /&gt;
slicer.mrmlScene.AddNode(fiducialNode)&lt;br /&gt;
fiducialNode.CreateDefaultDisplayNodes() &lt;br /&gt;
selectionNode.SetActivePlaceNodeID(fiducialNode.GetID())&lt;br /&gt;
interactionNode.SetCurrentInteractionMode(interactionNode.Place)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Get a notification if a markup point position is modified ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
def onMarkupsNodeModified(markupsNode, unusedArg2=None, unusedArg3=None):&lt;br /&gt;
  sliceView = markupsNode.GetAttribute('Markups.MovingInSliceView')&lt;br /&gt;
  if not sliceView:&lt;br /&gt;
    print(&amp;quot;Markup list was modified&amp;quot;)&lt;br /&gt;
    return&lt;br /&gt;
  movingMarkupIndex = markupsNode.GetAttribute('Markups.MovingMarkupIndex')&lt;br /&gt;
  pos = [0,0,0]&lt;br /&gt;
  markupsNode.GetNthFiducialPosition(int(movingMarkupIndex), pos)  &lt;br /&gt;
  print(&amp;quot;Markup {0} was moved in slice view {1} to {2}&amp;quot;.format(movingMarkupIndex, sliceView, pos))&lt;br /&gt;
&lt;br /&gt;
markupsNode = slicer.mrmlScene.AddNewNodeByClass(&amp;quot;vtkMRMLMarkupsFiducialNode&amp;quot;)&lt;br /&gt;
markupsNode.CreateDefaultDisplayNodes()&lt;br /&gt;
markupsNode.AddFiducial(0,0,0)&lt;br /&gt;
markupsNode.AddObserver(vtk.vtkCommand.ModifiedEvent, onMarkupsNodeModified)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Show a context menu when a markup point is clicked in a slice or 3D view ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
# Example actions to perform&lt;br /&gt;
&lt;br /&gt;
def action1():&lt;br /&gt;
  print('Action1 on markup '+str(slicer.clickedMarkupIndex))&lt;br /&gt;
&lt;br /&gt;
def action2():&lt;br /&gt;
  print('Action2 on markup '+str(slicer.clickedMarkupIndex))&lt;br /&gt;
&lt;br /&gt;
def action3():&lt;br /&gt;
  print('Action3 on markup '+str(slicer.clickedMarkupIndex))&lt;br /&gt;
&lt;br /&gt;
# Clicked markup index is saved here to let the action&lt;br /&gt;
# know which markup needs to be manipulated.&lt;br /&gt;
slicer.clickedMarkupIndex = -1&lt;br /&gt;
  &lt;br /&gt;
# Create a simple menu&lt;br /&gt;
&lt;br /&gt;
menu = qt.QMenu()&lt;br /&gt;
a1 = qt.QAction(&amp;quot;Test&amp;quot;, slicer.util.mainWindow())&lt;br /&gt;
a1.connect('triggered()', action1)&lt;br /&gt;
menu.addAction(a1)&lt;br /&gt;
a2 = qt.QAction(&amp;quot;Action&amp;quot;, slicer.util.mainWindow())&lt;br /&gt;
a2.connect('triggered()', action1)&lt;br /&gt;
menu.addAction(a2)&lt;br /&gt;
a3 = qt.QAction(&amp;quot;Here&amp;quot;, slicer.util.mainWindow())&lt;br /&gt;
a3.connect('triggered()', action1)&lt;br /&gt;
menu.addAction(a3)&lt;br /&gt;
&lt;br /&gt;
# Add observer to a markup fiducial list&lt;br /&gt;
&lt;br /&gt;
@vtk.calldata_type(vtk.VTK_INT)&lt;br /&gt;
def markupClickedCallback(caller, eventId, callData):&lt;br /&gt;
  slicer.clickedMarkupIndex = callData&lt;br /&gt;
  print('Open menu on markup '+str(slicer.clickedMarkupIndex))&lt;br /&gt;
  menu.move(qt.QCursor.pos())&lt;br /&gt;
  menu.show()&lt;br /&gt;
&lt;br /&gt;
markupsNode = getNode('F')&lt;br /&gt;
observerTag = markupsNode.AddObserver(slicer.vtkMRMLMarkupsNode.PointClickedEvent, markupClickedCallback)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Add a texture mapped plane to the scene as a model ==&lt;br /&gt;
Note that model textures are not exposed in the GUI and are not saved in the scene&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# use dummy image data here&lt;br /&gt;
e = vtk.vtkImageEllipsoidSource()&lt;br /&gt;
&lt;br /&gt;
scene = slicer.mrmlScene&lt;br /&gt;
&lt;br /&gt;
# Create model node&lt;br /&gt;
model = slicer.vtkMRMLModelNode()&lt;br /&gt;
model.SetScene(scene)&lt;br /&gt;
model.SetName(scene.GenerateUniqueName(&amp;quot;2DImageModel&amp;quot;))&lt;br /&gt;
&lt;br /&gt;
planeSource = vtk.vtkPlaneSource()&lt;br /&gt;
model.SetAndObservePolyData(planeSource.GetOutput())&lt;br /&gt;
&lt;br /&gt;
# Create display node&lt;br /&gt;
modelDisplay = slicer.vtkMRMLModelDisplayNode()&lt;br /&gt;
modelDisplay.SetColor(1,1,0) # yellow&lt;br /&gt;
modelDisplay.SetBackfaceCulling(0)&lt;br /&gt;
modelDisplay.SetScene(scene)&lt;br /&gt;
scene.AddNode(modelDisplay)&lt;br /&gt;
model.SetAndObserveDisplayNodeID(modelDisplay.GetID())&lt;br /&gt;
&lt;br /&gt;
# Add to scene&lt;br /&gt;
modelDisplay.SetAndObserveTextureImageData(e.GetOutput())&lt;br /&gt;
scene.AddNode(model) &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
transform = slicer.vtkMRMLLinearTransformNode()&lt;br /&gt;
scene.AddNode(transform) &lt;br /&gt;
model.SetAndObserveTransformNodeID(transform.GetID())&lt;br /&gt;
&lt;br /&gt;
vTransform = vtk.vtkTransform()&lt;br /&gt;
vTransform.Scale(50,50,50)&lt;br /&gt;
vTransform.RotateX(30)&lt;br /&gt;
transform.SetAndObserveMatrixTransformToParent(vTransform.GetMatrix())&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Export entire scene as VRML ==&lt;br /&gt;
&lt;br /&gt;
Save all surface meshes displayed in the scene (models, markups, etc). Solid colors and coloring by scalar is preserved. Textures are not supported.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
exporter = vtk.vtkVRMLExporter()&lt;br /&gt;
exporter.SetRenderWindow(slicer.app.layoutManager().threeDWidget(0).threeDView().renderWindow())&lt;br /&gt;
exporter.SetFileName('C:/tmp/something.wrl')&lt;br /&gt;
exporter.Write()&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Export model to Blender, including color by scalar ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
modelNode = getNode(&amp;quot;Model&amp;quot;)&lt;br /&gt;
plyFilePath = &amp;quot;c:/tmp/model.ply&amp;quot;&lt;br /&gt;
&lt;br /&gt;
modelDisplayNode = modelNode.GetDisplayNode()&lt;br /&gt;
triangles = vtk.vtkTriangleFilter()&lt;br /&gt;
triangles.SetInputConnection(modelDisplayNode.GetOutputPolyDataConnection())&lt;br /&gt;
&lt;br /&gt;
plyWriter = vtk.vtkPLYWriter()&lt;br /&gt;
plyWriter.SetInputConnection(triangles.GetOutputPort())&lt;br /&gt;
lut = vtk.vtkLookupTable()&lt;br /&gt;
lut.DeepCopy(modelDisplayNode.GetColorNode().GetLookupTable())&lt;br /&gt;
lut.SetRange(modelDisplayNode.GetScalarRange())&lt;br /&gt;
plyWriter.SetLookupTable(lut)&lt;br /&gt;
plyWriter.SetArrayName(modelDisplayNode.GetActiveScalarName())&lt;br /&gt;
&lt;br /&gt;
plyWriter.SetFileName(plyFilePath)&lt;br /&gt;
plyWriter.Write()&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Export a fiber tracts to Blender, including color ==&lt;br /&gt;
&lt;br /&gt;
Note: an interactive version of this script is now included in the [http://dmri.slicer.org/ SlicerDMRI extension] ([https://github.com/SlicerDMRI/SlicerDMRI/tree/master/Modules/Scripted/TractographyExportPLY module code]). &lt;br /&gt;
After installing SlicerDMRI, go to ''Modules -&amp;gt; Diffusion -&amp;gt; Import and Export -&amp;gt; Export tractography to PLY (mesh)''.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
lineDisplayNode = getNode(&amp;quot;*LineDisplay*&amp;quot;)&lt;br /&gt;
plyFilePath = &amp;quot;/tmp/fibers.ply&amp;quot;&lt;br /&gt;
&lt;br /&gt;
tuber = vtk.vtkTubeFilter()&lt;br /&gt;
tuber.SetInputData(lineDisplayNode.GetOutputPolyData())&lt;br /&gt;
tuber.Update()&lt;br /&gt;
tubes = tuber.GetOutputDataObject(0)&lt;br /&gt;
scalars = tubes.GetPointData().GetArray(0)&lt;br /&gt;
scalars.SetName(&amp;quot;scalars&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
triangles = vtk.vtkTriangleFilter()&lt;br /&gt;
triangles.SetInputData(tubes)&lt;br /&gt;
triangles.Update()&lt;br /&gt;
&lt;br /&gt;
colorNode = lineDisplayNode.GetColorNode()&lt;br /&gt;
lookupTable = vtk.vtkLookupTable()&lt;br /&gt;
lookupTable.DeepCopy(colorNode.GetLookupTable())&lt;br /&gt;
lookupTable.SetTableRange(0,1)&lt;br /&gt;
&lt;br /&gt;
plyWriter = vtk.vtkPLYWriter()&lt;br /&gt;
plyWriter.SetInputData(triangles.GetOutput())&lt;br /&gt;
plyWriter.SetLookupTable(lookupTable)&lt;br /&gt;
plyWriter.SetArrayName(&amp;quot;scalars&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
plyWriter.SetFileName(plyFilePath)&lt;br /&gt;
plyWriter.Write()&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Clone a volume ==&lt;br /&gt;
This example shows how to clone the MRHead sample volume, including its pixel data and display settings.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sourceVolumeNode = slicer.util.getNode('MRHead')&lt;br /&gt;
volumesLogic = slicer.modules.volumes.logic()&lt;br /&gt;
clonedVolumeNode = volumesLogic.CloneVolume(slicer.mrmlScene, sourceVolumeNode, 'Cloned volume')&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Create a new volume ==&lt;br /&gt;
This example shows how to create a new empty volume.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
nodeName = &amp;quot;MyNewVolume&amp;quot;&lt;br /&gt;
imageSize = [512, 512, 512]&lt;br /&gt;
voxelType=vtk.VTK_UNSIGNED_CHAR&lt;br /&gt;
imageOrigin = [0.0, 0.0, 0.0]&lt;br /&gt;
imageSpacing = [1.0, 1.0, 1.0]&lt;br /&gt;
imageDirections = [[1,0,0], [0,1,0], [0,0,1]]&lt;br /&gt;
fillVoxelValue = 0&lt;br /&gt;
&lt;br /&gt;
# Create an empty image volume, filled with fillVoxelValue&lt;br /&gt;
imageData = vtk.vtkImageData()&lt;br /&gt;
imageData.SetDimensions(imageSize)&lt;br /&gt;
imageData.AllocateScalars(voxelType, 1)&lt;br /&gt;
thresholder = vtk.vtkImageThreshold()&lt;br /&gt;
thresholder.SetInputData(imageData)&lt;br /&gt;
thresholder.SetInValue(fillVoxelValue)&lt;br /&gt;
thresholder.SetOutValue(fillVoxelValue)&lt;br /&gt;
thresholder.Update()&lt;br /&gt;
# Create volume node&lt;br /&gt;
volumeNode = slicer.mrmlScene.AddNewNodeByClass(&amp;quot;vtkMRMLScalarVolumeNode&amp;quot;, nodeName)&lt;br /&gt;
volumeNode.SetOrigin(imageOrigin)&lt;br /&gt;
volumeNode.SetSpacing(imageSpacing)&lt;br /&gt;
volumeNode.SetIJKToRASDirections(imageDirections)&lt;br /&gt;
volumeNode.SetAndObserveImageData(thresholder.GetOutput())&lt;br /&gt;
volumeNode.CreateDefaultDisplayNodes()&lt;br /&gt;
volumeNode.CreateDefaultStorageNode()&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Modify voxels in a volume ==&lt;br /&gt;
&lt;br /&gt;
Typically the fastest and simplest way of modifying voxels is by using numpy operators. Voxels can be retrieved in a numpy array using the `array` method and modified using standard numpy methods. For example, threshold a volume:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
nodeName = 'MRHead'&lt;br /&gt;
thresholdValue = 100&lt;br /&gt;
voxelArray = array(nodeName) # get voxels as numpy array&lt;br /&gt;
voxelArray[voxelArray &amp;lt; thresholdValue] = 0 # modify voxel values&lt;br /&gt;
getNode(nodeName).Modified() # at the end of all processing, notify Slicer that the image modification is completed&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This example shows how to change voxels values of the MRHead sample volume.&lt;br /&gt;
The values will be computed by function f(r,a,s,) = (r-10)*(r-10)+(a+15)*(a+15)+s*s.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
volumeNode=slicer.util.getNode('MRHead')&lt;br /&gt;
ijkToRas = vtk.vtkMatrix4x4()&lt;br /&gt;
volumeNode.GetIJKToRASMatrix(ijkToRas)&lt;br /&gt;
imageData=volumeNode.GetImageData()&lt;br /&gt;
extent = imageData.GetExtent()&lt;br /&gt;
for k in xrange(extent[4], extent[5]+1):&lt;br /&gt;
  for j in xrange(extent[2], extent[3]+1):&lt;br /&gt;
    for i in xrange(extent[0], extent[1]+1):&lt;br /&gt;
      position_Ijk=[i, j, k, 1]&lt;br /&gt;
      position_Ras=ijkToRas.MultiplyPoint(position_Ijk)&lt;br /&gt;
      r=position_Ras[0]&lt;br /&gt;
      a=position_Ras[1]&lt;br /&gt;
      s=position_Ras[2]      &lt;br /&gt;
      functionValue=(r-10)*(r-10)+(a+15)*(a+15)+s*s&lt;br /&gt;
      imageData.SetScalarComponentFromDouble(i,j,k,0,functionValue)&lt;br /&gt;
imageData.SetScalarComponentFromFloat(distortionVectorPosition_Ijk[0], distortionVectorPosition_Ijk[1], distortionVectorPosition_Ijk[2], 0, fillValue)&lt;br /&gt;
imageData.Modified()&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Get the values of all voxels for a label value  ==&lt;br /&gt;
&lt;br /&gt;
If you have a background image called ‘Volume’ and a mask called ‘Volume-label’ created with the Editor you could do something like this:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
import numpy&lt;br /&gt;
volume = array(‘Volume’)&lt;br /&gt;
label = array(‘Volume-label’)&lt;br /&gt;
points  = numpy.where( label == 1 )  # or use another label number depending on what you segmented&lt;br /&gt;
values  = volume[points] # this will be a list of the label values&lt;br /&gt;
values.mean() # should match the mean value of LabelStatistics calculation as a double-check&lt;br /&gt;
numpy.savetxt(‘values.txt’, values)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Access values in a DTI tensor volume ==&lt;br /&gt;
This example shows how to access individual tensors at the voxel level.&lt;br /&gt;
&lt;br /&gt;
First load your DWI volume and estimate tensors to produce a DTI volume called ‘Output DTI Volume’&lt;br /&gt;
&lt;br /&gt;
Then open the python window: View-&amp;gt;Python interactor&lt;br /&gt;
&lt;br /&gt;
Use this command to access tensors through numpy:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
tensors = array('Output DTI Volume')&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Type the following code into the Python window to access all tensor components using vtk commands:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
volumeNode=slicer.util.getNode('Output DTI Volume')&lt;br /&gt;
imageData=volumeNode.GetImageData()&lt;br /&gt;
tensors = imageData.GetPointData().GetTensors()&lt;br /&gt;
extent = imageData.GetExtent()&lt;br /&gt;
idx = 0&lt;br /&gt;
for k in xrange(extent[4], extent[5]+1):&lt;br /&gt;
  for j in xrange(extent[2], extent[3]+1):&lt;br /&gt;
    for i in xrange(extent[0], extent[1]+1):&lt;br /&gt;
      tensors.GetTuple9(idx)&lt;br /&gt;
      idx += 1&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Change window/level (brightness/contrast) or colormap of a volume ==&lt;br /&gt;
This example shows how to change window/level of the MRHead sample volume.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
volumeNode = getNode('MRHead')&lt;br /&gt;
displayNode = volumeNode.GetDisplayNode()&lt;br /&gt;
displayNode.AutoWindowLevelOff()&lt;br /&gt;
displayNode.SetWindow(50)&lt;br /&gt;
displayNode.SetLevel(100)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Change color mapping from grayscale to rainbow:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
displayNode.SetAndObserveColorNodeID('vtkMRMLColorTableNodeRainbow')&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Manipulate a Slice View ==&lt;br /&gt;
&lt;br /&gt;
=== Change the slice offset ===&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
lm = slicer.app.layoutManager()&lt;br /&gt;
red = lm.sliceWidget('Red')&lt;br /&gt;
redLogic = red.sliceLogic()&lt;br /&gt;
# Print current slice offset position&lt;br /&gt;
print redLogic.GetSliceOffset()&lt;br /&gt;
# Change slice position&lt;br /&gt;
redLogic.SetSliceOffset(20)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Iterate over current visible slice views, and modify 3D visibility ===&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
for sliceViewName in layoutManager.sliceViewNames():&lt;br /&gt;
     sliceWidget = layoutManager.sliceWidget(sliceViewName)&lt;br /&gt;
     &lt;br /&gt;
     controller = sliceWidget.sliceController()&lt;br /&gt;
     controller.setSliceVisible(True)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Iterate over current visible slice views, and set foreground and background images ===&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
for sliceViewName in layoutManager.sliceViewNames():&lt;br /&gt;
     sliceWidget = layoutManager.sliceWidget(sliceViewName)&lt;br /&gt;
     &lt;br /&gt;
     # setup background volume&lt;br /&gt;
     compositeNode.SetBackgroundVolumeID(MRVolume.GetID())&lt;br /&gt;
     # setup foreground volume&lt;br /&gt;
     compositeNode.SetForegroundVolumeID(CTVolume.GetID())&lt;br /&gt;
     # change opacity&lt;br /&gt;
     compositeNode.SetForegroundOpacity(0.3)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Fit slice plane to markup fiducials ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sliceNode = slicer.mrmlScene.GetNodeByID(&amp;quot;vtkMRMLSliceNodeRed&amp;quot;)&lt;br /&gt;
markupsNode = slicer.mrmlScene.GetFirstNodeByName(&amp;quot;F&amp;quot;)&lt;br /&gt;
# Get markup point positions as numpy arrays&lt;br /&gt;
import numpy as np&lt;br /&gt;
p1 = np.array([0,0,0])&lt;br /&gt;
p2 = np.array([0,0,0])&lt;br /&gt;
p3 = np.array([0,0,0])&lt;br /&gt;
markupsNode.GetNthFiducialPosition(0, p1)&lt;br /&gt;
markupsNode.GetNthFiducialPosition(1, p2)&lt;br /&gt;
markupsNode.GetNthFiducialPosition(2, p3)&lt;br /&gt;
# Get plane axis directions&lt;br /&gt;
n = np.cross(p2-p1, p2-p3) # plane normal direction&lt;br /&gt;
n = n/np.linalg.norm(n)&lt;br /&gt;
t = np.cross([0, 0, 1], n) # plane transverse direction&lt;br /&gt;
t = t/np.linalg.norm(t)&lt;br /&gt;
# Set slice plane orientation and position&lt;br /&gt;
sliceNode.SetSliceToRASByNTP(n[0], n[1], n[2], t[0], t[1], t[2], p1[0], p1[1], p1[2], 0)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Save a series of images from a Slice View ==&lt;br /&gt;
&lt;br /&gt;
You can use ScreenCapture module to capture series of images. To do it programmatically, save the following into a file such as '/tmp/record.py' and then in the slicer python console type &amp;quot;execfile('/tmp/record.py')&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
layoutName = 'Green'&lt;br /&gt;
imagePathPattern = '/tmp/image-%03d.png'&lt;br /&gt;
steps = 10&lt;br /&gt;
&lt;br /&gt;
widget = slicer.app.layoutManager().sliceWidget(layoutName)&lt;br /&gt;
view = widget.sliceView()&lt;br /&gt;
logic = widget.sliceLogic()&lt;br /&gt;
bounds = [0,]*6&lt;br /&gt;
logic.GetSliceBounds(bounds)&lt;br /&gt;
&lt;br /&gt;
for step in range(steps):&lt;br /&gt;
    offset = bounds[4] + step/(1.*steps) * (bounds[5]-bounds[4])&lt;br /&gt;
    logic.SetSliceOffset(offset)&lt;br /&gt;
    view.forceRender()&lt;br /&gt;
    image = qt.QPixmap.grabWidget(view).toImage()&lt;br /&gt;
    image.save(imagePathPattern % step)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Save the scene into a new directory ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Create a new directory where the scene will be saved into&lt;br /&gt;
import time&lt;br /&gt;
sceneSaveDirectory = slicer.app.temporaryPath + &amp;quot;/saved-scene-&amp;quot; + time.strftime(&amp;quot;%Y%m%d-%H%M%S&amp;quot;)&lt;br /&gt;
if not os.access(sceneSaveDirectory, os.F_OK):&lt;br /&gt;
  os.makedirs(sceneSaveDirectory)&lt;br /&gt;
&lt;br /&gt;
# Save the scene&lt;br /&gt;
if slicer.app.applicationLogic().SaveSceneToSlicerDataBundleDirectory(sceneSaveDirectory, None):&lt;br /&gt;
  logging.info(&amp;quot;Scene saved to: {0}&amp;quot;.format(sceneSaveDirectory))&lt;br /&gt;
else:&lt;br /&gt;
  logging.error(&amp;quot;Scene saving failed&amp;quot;) &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Save the scene into a single MRB file ==&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Generate file name&lt;br /&gt;
import time&lt;br /&gt;
sceneSaveFilename = slicer.app.temporaryPath + &amp;quot;/saved-scene-&amp;quot; + time.strftime(&amp;quot;%Y%m%d-%H%M%S&amp;quot;) + &amp;quot;.mrb&amp;quot;&lt;br /&gt;
&lt;br /&gt;
# Save scene&lt;br /&gt;
if slicer.util.saveScene(sceneSaveFilename):&lt;br /&gt;
  logging.info(&amp;quot;Scene saved to: {0}&amp;quot;.format(sceneSaveFilename))&lt;br /&gt;
else:&lt;br /&gt;
  logging.error(&amp;quot;Scene saving failed&amp;quot;) &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Save a node to file ==&lt;br /&gt;
&lt;br /&gt;
Save a transform node to file (should work with any other node type, if file extension is set to a supported one):&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
myNode = getNode(&amp;quot;LinearTransform_3&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
myStorageNode = myNode.CreateDefaultStorageNode()&lt;br /&gt;
myStorageNode.SetFileName(&amp;quot;c:/tmp/something.tfm&amp;quot;)&lt;br /&gt;
myStorageNode.WriteData(myNode)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Show a volume in the Slice Views ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
volumeNode = slicer.util.getNode('YourVolumeNode')&lt;br /&gt;
applicationLogic = slicer.app.applicationLogic()&lt;br /&gt;
selectionNode = applicationLogic.GetSelectionNode()&lt;br /&gt;
selectionNode.SetSecondaryVolumeID(volumeNode.GetID())&lt;br /&gt;
applicationLogic.PropagateForegroundVolumeSelection(0) &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
or&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
n =  slicer.util.getNode('YourVolumeNode')&lt;br /&gt;
for color in ['Red', 'Yellow', 'Green']:&lt;br /&gt;
    slicer.app.layoutManager().sliceWidget(color).sliceLogic().GetSliceCompositeNode().SetForegroundVolumeID(n.GetID())&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Change opacity of foreground volume in the Slice Views ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
lm = slicer.app.layoutManager()&lt;br /&gt;
sliceLogic = lm.sliceWidget('Red').sliceLogic()&lt;br /&gt;
compositeNode = sliceLogic.GetSliceCompositeNode()&lt;br /&gt;
compositeNode.SetForegroundOpacity(0.4)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Center the 3D View on the Scene ==&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
layoutManager = slicer.app.layoutManager()&lt;br /&gt;
threeDWidget = layoutManager.threeDWidget(0)&lt;br /&gt;
threeDView = threeDWidget.threeDView()&lt;br /&gt;
threeDView.resetFocalPoint()&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Rotate the 3D View==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
layoutManager = slicer.app.layoutManager()&lt;br /&gt;
threeDWidget = layoutManager.threeDWidget(0)&lt;br /&gt;
threeDView = threeDWidget.threeDView()&lt;br /&gt;
threeDView.yaw()&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Display text in a 3D view or slice view ==&lt;br /&gt;
&lt;br /&gt;
The easiest way to show information overlaid on a viewer is to use corner annotations.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
view=slicer.app.layoutManager().threeDWidget(0).threeDView()&lt;br /&gt;
# Set text to &amp;quot;Something&amp;quot;&lt;br /&gt;
view.cornerAnnotation().SetText(vtk.vtkCornerAnnotation.UpperRight,&amp;quot;Something&amp;quot;)&lt;br /&gt;
# Set color to red&lt;br /&gt;
view.cornerAnnotation().GetTextProperty().SetColor(1,0,0)&lt;br /&gt;
# Update the view&lt;br /&gt;
view.forceRender()&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Hide slice view annotations (DataProbe) ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Disable slice annotations immediately&lt;br /&gt;
slicer.modules.DataProbeInstance.infoWidget.sliceAnnotations.sliceViewAnnotationsEnabled=False&lt;br /&gt;
slicer.modules.DataProbeInstance.infoWidget.sliceAnnotations.updateSliceViewFromGUI()&lt;br /&gt;
# Disable slice annotations persistently (after Slicer restarts)&lt;br /&gt;
settings = qt.QSettings()&lt;br /&gt;
settings.setValue('DataProbe/sliceViewAnnotations.enabled', 0)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Turning off interpolation ==&lt;br /&gt;
&lt;br /&gt;
You can turn off interpolation for newly loaded volumes with this script from Steve Pieper.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
def NoInterpolate(caller,event):&lt;br /&gt;
  for node in slicer.util.getNodes('*').values():&lt;br /&gt;
    if node.IsA('vtkMRMLScalarVolumeDisplayNode'):&lt;br /&gt;
      node.SetInterpolate(0)&lt;br /&gt;
	&lt;br /&gt;
slicer.mrmlScene.AddObserver(slicer.mrmlScene.NodeAddedEvent, NoInterpolate)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The below link explains how to put this in your startup script.&lt;br /&gt;
&lt;br /&gt;
http://www.na-mic.org/Wiki/index.php/AHM2012-Slicer-Python#Refining_the_code_and_UI_with_slicerrc&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Customize viewer layout ==&lt;br /&gt;
&lt;br /&gt;
Show a custom layout of a 3D view on top of the red slice view:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
customLayout = (&amp;quot;&amp;lt;layout type=\&amp;quot;vertical\&amp;quot; split=\&amp;quot;true\&amp;quot; &amp;gt;&amp;quot;&lt;br /&gt;
  &amp;quot; &amp;lt;item&amp;gt;&amp;quot;&lt;br /&gt;
  &amp;quot;  &amp;lt;view class=\&amp;quot;vtkMRMLViewNode\&amp;quot; singletontag=\&amp;quot;1\&amp;quot;&amp;gt;&amp;quot;&lt;br /&gt;
  &amp;quot;    &amp;lt;property name=\&amp;quot;viewlabel\&amp;quot; action=\&amp;quot;default\&amp;quot;&amp;gt;1&amp;lt;/property&amp;gt;&amp;quot;&lt;br /&gt;
  &amp;quot;  &amp;lt;/view&amp;gt;&amp;quot;&lt;br /&gt;
  &amp;quot; &amp;lt;/item&amp;gt;&amp;quot;&lt;br /&gt;
  &amp;quot; &amp;lt;item&amp;gt;&amp;quot;&lt;br /&gt;
  &amp;quot;  &amp;lt;view class=\&amp;quot;vtkMRMLSliceNode\&amp;quot; singletontag=\&amp;quot;Red\&amp;quot;&amp;gt;&amp;quot;&lt;br /&gt;
  &amp;quot;   &amp;lt;property name=\&amp;quot;orientation\&amp;quot; action=\&amp;quot;default\&amp;quot;&amp;gt;Axial&amp;lt;/property&amp;gt;&amp;quot;&lt;br /&gt;
  &amp;quot;   &amp;lt;property name=\&amp;quot;viewlabel\&amp;quot; action=\&amp;quot;default\&amp;quot;&amp;gt;R&amp;lt;/property&amp;gt;&amp;quot;&lt;br /&gt;
  &amp;quot;   &amp;lt;property name=\&amp;quot;viewcolor\&amp;quot; action=\&amp;quot;default\&amp;quot;&amp;gt;#F34A33&amp;lt;/property&amp;gt;&amp;quot;&lt;br /&gt;
  &amp;quot;  &amp;lt;/view&amp;gt;&amp;quot;&lt;br /&gt;
  &amp;quot; &amp;lt;/item&amp;gt;&amp;quot;&lt;br /&gt;
  &amp;quot;&amp;lt;/layout&amp;gt;&amp;quot;)&lt;br /&gt;
  &lt;br /&gt;
customLayoutId=501&lt;br /&gt;
&lt;br /&gt;
layoutManager = slicer.app.layoutManager()&lt;br /&gt;
layoutManager.layoutLogic().GetLayoutNode().AddLayoutDescription(customLayoutId, customLayout)                                         &lt;br /&gt;
layoutManager.setLayout(customLayoutId)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
See description of standard layouts (that can be used as examples) here:&lt;br /&gt;
https://github.com/Slicer/Slicer/blob/master/Libs/MRML/Logic/vtkMRMLLayoutLogic.cxx&lt;br /&gt;
&lt;br /&gt;
== Disable certain user interactions in slice views ==&lt;br /&gt;
&lt;br /&gt;
For example, disable slice browsing using mouse wheel and keyboard shortcuts in the red slice viewer:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
interactorStyle = slicer.app.layoutManager().sliceWidget('Red').sliceView().sliceViewInteractorStyle()&lt;br /&gt;
interactorStyle.SetActionEnabled(interactorStyle.BrowseSlice, False)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Hide all slice view controllers:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
lm = slicer.app.layoutManager()&lt;br /&gt;
for sliceViewName in lm.sliceViewNames():&lt;br /&gt;
  lm.sliceWidget(sliceViewName).sliceController().setVisible(False)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Hide all 3D view controllers:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
lm = slicer.app.layoutManager()&lt;br /&gt;
for viewIndex in range(slicer.app.layoutManager().threeDViewCount):&lt;br /&gt;
  lm.threeDWidget(0).threeDController().setVisible(False)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Change default slice view orientation ==&lt;br /&gt;
&lt;br /&gt;
You can left-right &amp;quot;flip&amp;quot; slice view orientation presets (show patient left side on left/right side of the screen) by copy-pasting the script below to your [[Documentation/{{documentation/version}}/Developers/FAQ/Python_Scripting#How_to_systematically_execute_custom_python_code_at_startup_.3F| .slicerrc.py file]].&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Axial slice axes:&lt;br /&gt;
#  1 0 0&lt;br /&gt;
#  0 1 0&lt;br /&gt;
#  0 0 1&lt;br /&gt;
axialSliceToRas=vtk.vtkMatrix3x3()&lt;br /&gt;
&lt;br /&gt;
# Coronal slice axes:&lt;br /&gt;
#  1 0 0 &lt;br /&gt;
#  0 0 -1&lt;br /&gt;
#  0 1 0&lt;br /&gt;
coronalSliceToRas=vtk.vtkMatrix3x3()&lt;br /&gt;
coronalSliceToRas.SetElement(1,1, 0)&lt;br /&gt;
coronalSliceToRas.SetElement(1,2, -1)&lt;br /&gt;
coronalSliceToRas.SetElement(2,1, 1)&lt;br /&gt;
coronalSliceToRas.SetElement(2,2, 0)&lt;br /&gt;
&lt;br /&gt;
# Replace orientation presets in all existing slice nodes and in the default slice node&lt;br /&gt;
sliceNodes = slicer.util.getNodesByClass('vtkMRMLSliceNode')&lt;br /&gt;
sliceNodes.append(slicer.mrmlScene.GetDefaultNodeByClass('vtkMRMLSliceNode'))&lt;br /&gt;
for sliceNode in sliceNodes:&lt;br /&gt;
  orientationPresetName = sliceNode.GetOrientation()&lt;br /&gt;
  sliceNode.RemoveSliceOrientationPreset(&amp;quot;Axial&amp;quot;)&lt;br /&gt;
  sliceNode.AddSliceOrientationPreset(&amp;quot;Axial&amp;quot;, axialSliceToRas)&lt;br /&gt;
  sliceNode.RemoveSliceOrientationPreset(&amp;quot;Coronal&amp;quot;)&lt;br /&gt;
  sliceNode.AddSliceOrientationPreset(&amp;quot;Coronal&amp;quot;, coronalSliceToRas)&lt;br /&gt;
  sliceNode.SetOrientation(orientationPresetName)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Set up custom units in slice view ruler ==&lt;br /&gt;
&lt;br /&gt;
For microscopy or micro-CT images you may want to switch unit to micrometer instead of the default mm. To do that, 1. change the unit in Application settings / Units and 2. update ruler display settings using the script below (it can be copied to your Application startup script):&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
lm = slicer.app.layoutManager()&lt;br /&gt;
for sliceViewName in lm.sliceViewNames():&lt;br /&gt;
  sliceView = lm.sliceWidget(sliceViewName).sliceView()&lt;br /&gt;
  displayableManagerCollection = vtk.vtkCollection()&lt;br /&gt;
  sliceView.getDisplayableManagers(displayableManagerCollection)&lt;br /&gt;
  for dmIndex in xrange(displayableManagerCollection.GetNumberOfItems()):&lt;br /&gt;
    displayableManager = displayableManagerCollection.GetItemAsObject(dmIndex)&lt;br /&gt;
    if not displayableManager.IsA(&amp;quot;vtkMRMLRulerDisplayableManager&amp;quot;):&lt;br /&gt;
      continue&lt;br /&gt;
    displayableManager.RemoveAllRulerScalePresets()&lt;br /&gt;
    displayableManager.AddRulerScalePreset(   0.001, 5, 2, &amp;quot;nm&amp;quot;, 1000.0)&lt;br /&gt;
    displayableManager.AddRulerScalePreset(   0.010, 5, 2, &amp;quot;nm&amp;quot;, 1000.0)&lt;br /&gt;
    displayableManager.AddRulerScalePreset(   0.100, 5, 2, &amp;quot;nm&amp;quot;, 1000.0)&lt;br /&gt;
    displayableManager.AddRulerScalePreset(   0.500, 5, 1, &amp;quot;nm&amp;quot;, 1000.0)&lt;br /&gt;
    displayableManager.AddRulerScalePreset(   1.0,   5, 2, &amp;quot;um&amp;quot;,    1.0)&lt;br /&gt;
    displayableManager.AddRulerScalePreset(   5.0,   5, 1, &amp;quot;um&amp;quot;,    1.0)&lt;br /&gt;
    displayableManager.AddRulerScalePreset(  10.0,   5, 2, &amp;quot;um&amp;quot;,    1.0)&lt;br /&gt;
    displayableManager.AddRulerScalePreset(  50.0,   5, 1, &amp;quot;um&amp;quot;,    1.0)&lt;br /&gt;
    displayableManager.AddRulerScalePreset( 100.0,   5, 2, &amp;quot;um&amp;quot;,    1.0)&lt;br /&gt;
    displayableManager.AddRulerScalePreset( 500.0,   5, 1, &amp;quot;um&amp;quot;,    1.0)&lt;br /&gt;
    displayableManager.AddRulerScalePreset(1000.0,   5, 2, &amp;quot;mm&amp;quot;,    0.001)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Show a slice view outside the view layout ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sliceLayoutName = &amp;quot;TestSlice&amp;quot;&lt;br /&gt;
sliceLayoutLabel = &amp;quot;T&amp;quot;&lt;br /&gt;
# ownerNode manages this view instead of the layout manager (it can be any node in the scene)&lt;br /&gt;
viewOwnerNode = slicer.mrmlScene.AddNewNodeByClass(&amp;quot;vtkMRMLScriptedModuleNode&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
# Create MRML nodes&lt;br /&gt;
sliceNode = slicer.vtkMRMLSliceNode()&lt;br /&gt;
sliceNode.SetName(sliceLayoutName)&lt;br /&gt;
sliceNode.SetLayoutName(sliceLayoutName)&lt;br /&gt;
sliceNode.SetLayoutLabel(sliceLayoutLabel)&lt;br /&gt;
sliceNode.SetLayoutColor(1, 1, 0)&lt;br /&gt;
sliceNode.SetAndObserveParentLayoutNodeID(viewOwnerNode.GetID())&lt;br /&gt;
sliceNode = slicer.mrmlScene.AddNode(sliceNode)&lt;br /&gt;
sliceCompositeNode = slicer.mrmlScene.AddNewNodeByClass(&amp;quot;vtkMRMLSliceCompositeNode&amp;quot;)&lt;br /&gt;
sliceCompositeNode.SetLayoutName(sliceLayoutName)&lt;br /&gt;
&lt;br /&gt;
# Create widget&lt;br /&gt;
sliceWidget = slicer.qMRMLSliceWidget()&lt;br /&gt;
sliceWidget.sliceViewName = sliceLayoutName&lt;br /&gt;
sliceWidget.sliceViewLabel = sliceLayoutLabel&lt;br /&gt;
c = sliceNode.GetLayoutColor()&lt;br /&gt;
sliceWidget.sliceViewColor = qt.QColor.fromRgbF(c[0],c[1],c[2])&lt;br /&gt;
sliceWidget.setMRMLScene(slicer.mrmlScene)&lt;br /&gt;
sliceWidget.setMRMLSliceNode(sliceNode)&lt;br /&gt;
sliceWidget.show()&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Running an ITK filter in Python using SimpleITK ==&lt;br /&gt;
Open the &amp;quot;Sample Data&amp;quot; module and download &amp;quot;MR Head&amp;quot;, then paste the following snippet in Python interactor:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
import SimpleITK as sitk&lt;br /&gt;
import sitkUtils&lt;br /&gt;
inputImage = sitkUtils.PullFromSlicer('MRHead')&lt;br /&gt;
filter = sitk.SignedMaurerDistanceMapImageFilter()&lt;br /&gt;
outputImage = filter.Execute(inputImage)&lt;br /&gt;
sitkUtils.PushToSlicer(outputImage,'outputImage')&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
More information:&lt;br /&gt;
* See the SimpleITK documentation for SimpleITK examples: http://www.itk.org/SimpleITKDoxygen/html/examples.html&lt;br /&gt;
* sitkUtils in Slicer is used for pushing and pulling images from Slicer to SimpleITK: https://github.com/Slicer/Slicer/blob/master/Base/Python/sitkUtils.py&lt;br /&gt;
&lt;br /&gt;
== Get current mouse coordinates in a slice view ==&lt;br /&gt;
&lt;br /&gt;
You can get 3D (RAS) coordinates of the current mouse cursor from the crosshair singleton node as shown in the example below:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
def onMouseMoved(observer,eventid):  &lt;br /&gt;
  ras=[0,0,0]&lt;br /&gt;
  crosshairNode.GetCursorPositionRAS(ras)&lt;br /&gt;
  print(ras)&lt;br /&gt;
&lt;br /&gt;
crosshairNode=slicer.util.getNode('Crosshair') &lt;br /&gt;
crosshairNode.AddObserver(slicer.vtkMRMLCrosshairNode.CursorPositionModifiedEvent, onMouseMoved)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Get DataProbe text ==&lt;br /&gt;
&lt;br /&gt;
You can get the mouse location in pixel coordinates along with the pixel value at the mouse by hitting the '.' (period) key in a slice view after pasting in the following code.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
def printDataProbe():&lt;br /&gt;
  infoWidget = slicer.modules.DataProbeInstance.infoWidget&lt;br /&gt;
  for layer in ('B', 'F', 'L'):&lt;br /&gt;
    print(infoWidget.layerNames[layer].text, infoWidget.layerIJKs[layer].text, infoWidget.layerValues[layer].text)&lt;br /&gt;
&lt;br /&gt;
s = qt.QShortcut(qt.QKeySequence('.'), mainWindow())&lt;br /&gt;
s.connect('activated()', printDataProbe)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Thick slab reconstruction and maximum/minimum intensity volume projections ==&lt;br /&gt;
&lt;br /&gt;
Set up 'red' slice viewer to show thick slab reconstructed from 3 slices:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sliceNode = slicer.mrmlScene.GetNodeByID('vtkMRMLSliceNodeRed')&lt;br /&gt;
appLogic = slicer.app.applicationLogic()&lt;br /&gt;
sliceLogic = appLogic.GetSliceLogic(sliceNode)&lt;br /&gt;
sliceLayerLogic = sliceLogic.GetBackgroundLayer()&lt;br /&gt;
reslice = sliceLayerLogic.GetReslice()&lt;br /&gt;
reslice.SetSlabModeToMean()&lt;br /&gt;
reslice.SetSlabNumberOfSlices(10) # mean of 10 slices will computed&lt;br /&gt;
reslice.SetSlabSliceSpacingFraction(0.3) # spacing between each slice is 0.3 pixel (total 10 * 0.3 = 3 pixel neighborhood)&lt;br /&gt;
sliceNode.Modified()&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Set up 'red' slice viewer to show maximum intensity projection (MIP):&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sliceNode = slicer.mrmlScene.GetNodeByID('vtkMRMLSliceNodeRed')&lt;br /&gt;
appLogic = slicer.app.applicationLogic()&lt;br /&gt;
sliceLogic = appLogic.GetSliceLogic(sliceNode)&lt;br /&gt;
sliceLayerLogic = sliceLogic.GetBackgroundLayer()&lt;br /&gt;
reslice = sliceLayerLogic.GetReslice()&lt;br /&gt;
reslice.SetSlabModeToMax()&lt;br /&gt;
reslice.SetSlabNumberOfSlices(600) # use a large number of slices (600) to cover the entire volume&lt;br /&gt;
reslice.SetSlabSliceSpacingFraction(0.5) # spacing between slices are 0.5 pixel (supersampling is useful to reduce interpolation artifacts)&lt;br /&gt;
sliceNode.Modified()&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The projected image is available in a ''vtkImageData'' object by calling ''reslice.GetOutput()''.&lt;br /&gt;
&lt;br /&gt;
== Change default file type for nodes (that have never been saved yet) ==&lt;br /&gt;
Default node can be specified that will be used as a basis of all new storage nodes. This can be used for setting default file extension. For example, change file format to STL for model nodes:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
defaultModelStorageNode = slicer.vtkMRMLModelStorageNode()&lt;br /&gt;
defaultModelStorageNode.SetDefaultWriteFileExtension('stl')&lt;br /&gt;
slicer.mrmlScene.AddDefaultNode(defaultModelStorageNode)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To permanently change default file extension on your computer, copy-paste the code above into your application startup script (you can find its location in menu: Edit / Application settings / General / Application startup script).&lt;br /&gt;
&lt;br /&gt;
== Change file type for saving for all volumes (with already existing storage nodes) ==&lt;br /&gt;
&lt;br /&gt;
If it is not necessary to preserve file paths then the simplest is to configure default storage node (as shown in the example above), then delete all existing storage nodes. When save dialog is opened, default storage nodes will be recreated.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Delete existing model storage nodes so that they will be recreated with default settings&lt;br /&gt;
existingModelStorageNodes = slicer.util.getNodesByClass('vtkMRMLModelStorageNode')&lt;br /&gt;
for modelStorageNode in existingModelStorageNodes:&lt;br /&gt;
  slicer.mrmlScene.RemoveNode(modelStorageNode)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To update existing storage nodes to use new file extension (but keep all other parameters unchanged) you can use this approach (example is for volume storage):&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
requiredFileExtension = '.nia'&lt;br /&gt;
originalFileExtension = '.nrrd'&lt;br /&gt;
volumeNodes = slicer.util.getNodesByClass('vtkMRMLScalarVolumeNode')&lt;br /&gt;
for volumeNode in volumeNodes:&lt;br /&gt;
  volumeStorageNode = volumeNode.GetStorageNode()&lt;br /&gt;
  if not volumeStorageNode:&lt;br /&gt;
    volumeNode.AddDefaultStorageNode()&lt;br /&gt;
    volumeStorageNode = volumeNode.GetStorageNode()&lt;br /&gt;
    volumeStorageNode.SetFileName(volumeNode.GetName()+requiredFileExtension)&lt;br /&gt;
  else:&lt;br /&gt;
    volumeStorageNode.SetFileName(volumeStorageNode.GetFileName().replace(originalFileExtension, requiredFileExtension))&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Segmentations ==&lt;br /&gt;
&lt;br /&gt;
=== Create a segmentation from a labelmap volume and display in 3D ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
labelmapVolumeNode = getNode('label')&lt;br /&gt;
seg = slicer.mrmlScene.AddNewNodeByClass('vtkMRMLSegmentationNode')&lt;br /&gt;
slicer.modules.segmentations.logic().ImportLabelmapToSegmentationNode(labelmapVolumeNode, seg)&lt;br /&gt;
seg.CreateClosedSurfaceRepresentation()&lt;br /&gt;
slicer.mrmlScene.RemoveNode(labelmapVolumeNode)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The last line is optional. It removes the original labelmap volume so that the same information is not shown twice.&lt;br /&gt;
&lt;br /&gt;
=== Export labelmap node from segmentation node ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
seg = getNode('Segmentation')&lt;br /&gt;
labelmapVolumeNode = slicer.mrmlScene.AddNewNodeByClass('vtkMRMLLabelMapVolumeNode')&lt;br /&gt;
slicer.modules.segmentations.logic().ExportAllSegmentsToLabelmapNode(seg, labelmapVolumeNode)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Show a segmentation in 3D ===&lt;br /&gt;
Segmentation can only be shown in 3D if closed surface representation (or other 3D-displayable representation) is available. To create closed surface representation:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
segmentation.CreateClosedSurfaceRepresentation()&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Get a representation of a segment ===&lt;br /&gt;
Access binary labelmap stored in a segmentation node (without exporting it to a volume node) - if it does not exist, it will return None:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
image = segmentationNode.GetBinaryLabelmapRepresentation(segmentID)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Get closed surface, if it does not exist, it will return None:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
polydata = segmentationNode.GetClosedSurfaceRepresentation(segmentID)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Get binary labelmap representation. If it does not exist then it will be created for that single segment. Applies parent transforms by default (if not desired, another argument needs to be added to the end: false):&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
import vtkSegmentationCorePython as vtkSegmentationCore&lt;br /&gt;
outputOrientedImageData = vtkSegmentationCore.vtkOrientedImageData()&lt;br /&gt;
slicer.vtkSlicerSegmentationsModuleLogic.GetSegmentBinaryLabelmapRepresentation(segmentationNode, segmentID, outputOrientedImageData)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Same as above, for closed surface representation:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
outputPolyData = vtk.vtkPolyData()&lt;br /&gt;
slicer.vtkSlicerSegmentationsModuleLogic.GetSegmentClosedSurfaceRepresentation(segmentationNode, segmentID, outputPolyData)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Convert all segments using default path and conversion parameters ===&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
segmentationNode.CreateBinaryLabelmapRepresentation()&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Convert all segments using custom path or conversion parameters ===&lt;br /&gt;
Change reference image geometry parameter based on an existing referenceImageData image:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
import vtkSegmentationCorePython as vtkSegmentationCore&lt;br /&gt;
referenceGeometry = vtkSegmentationCore.vtkSegmentationConverter.SerializeImageGeometry(referenceImageData)&lt;br /&gt;
segmentation.SetConversionParameter(vtkSegmentationCore.vtkSegmentationConverter.GetReferenceImageGeometryParameterName(), referenceGeometry)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Re-convert using a modified conversion parameter ===&lt;br /&gt;
Changing smoothing factor for closed surface generation:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
import vtkSegmentationCorePython as vtkSegmentationCore&lt;br /&gt;
segmentation = getNode('Segmentation').GetSegmentation()&lt;br /&gt;
&lt;br /&gt;
# Turn of surface smoothing&lt;br /&gt;
segmentation.SetConversionParameter('Smoothing factor','0.0')&lt;br /&gt;
&lt;br /&gt;
# Recreate representation using modified parameters (and default conversion path)&lt;br /&gt;
segmentation.RemoveRepresentation(vtkSegmentationCore.vtkSegmentationConverter.GetSegmentationClosedSurfaceRepresentationName())&lt;br /&gt;
segmentation.CreateRepresentation(vtkSegmentationCore.vtkSegmentationConverter.GetSegmentationClosedSurfaceRepresentationName())&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== How to run segment editor effects from a script ===&lt;br /&gt;
&lt;br /&gt;
Editor effects are complex because they need to handle changing master volumes, undo/redo, masking operations, etc. Therefore, instead of using a segment editor effect, it is simpler to run the underlying filters directly from script.&lt;br /&gt;
&lt;br /&gt;
This example demonstrates how to use Segment editor effects (without GUI, using qMRMLSegmentEditorWidget):&lt;br /&gt;
&lt;br /&gt;
* [https://gist.github.com/lassoan/2d5a5b73645f65a5eb6f8d5f97abf31b brain tumor segmentation using grow from seeds effect]&lt;br /&gt;
* [https://gist.github.com/lassoan/1673b25d8e7913cbc245b4f09ed853f9 skin surface extraction using thresholding and smoothing]&lt;br /&gt;
* [https://gist.github.com/lassoan/2f5071c562108dac8efe277c78f2620f mask a volume with segments and compute histogram for each region]&lt;br /&gt;
&lt;br /&gt;
This example shows how to perform operations on segmentations using VTK filters:&lt;br /&gt;
* [https://gist.github.com/lassoan/7c94c334653010696b2bf96abc0ac8e7 brain tumor segmentation using grow from seeds effect]&lt;br /&gt;
&lt;br /&gt;
== Accessing views, renderers, and cameras ==&lt;br /&gt;
&lt;br /&gt;
Iterate through all 3D views in current layout:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
layoutManager = slicer.app.layoutManager()&lt;br /&gt;
for threeDViewIndex in range(layoutManager.threeDViewCount) :&lt;br /&gt;
  view = layoutManager.threeDWidget(threeDViewIndex).threeDView()&lt;br /&gt;
  threeDViewNode = view.mrmlViewNode()&lt;br /&gt;
  cameraNode = slicer.modules.cameras.logic().GetViewActiveCameraNode(threeDViewNode)&lt;br /&gt;
  print('View node for 3D widget ' + str(threeDViewIndex))&lt;br /&gt;
  print('  Name: ' + threeDViewNode .GetName())&lt;br /&gt;
  print('  ID: ' + threeDViewNode .GetID())&lt;br /&gt;
  print('  Camera ID: ' + cameraNode.GetID())&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Iterate through all slice views in current layout:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
layoutManager = slicer.app.layoutManager()&lt;br /&gt;
for sliceViewName in layoutManager.sliceViewNames():&lt;br /&gt;
  view = layoutManager.sliceWidget(sliceViewName).sliceView()&lt;br /&gt;
  sliceNode = view.mrmlSliceNode()&lt;br /&gt;
  sliceLogic = slicer.app.applicationLogic().GetSliceLogic(sliceNode)&lt;br /&gt;
  compositeNode = sliceLogic.GetSliceCompositeNode()&lt;br /&gt;
  print('Slice view ' + str(sliceViewName))&lt;br /&gt;
  print('  Name: ' + sliceNode.GetName())&lt;br /&gt;
  print('  ID: ' + sliceNode.GetID())&lt;br /&gt;
  print('  Background volume: {0}'.format(compositeNode.GetBackgroundVolumeID()))&lt;br /&gt;
  print('  Foreground volume: {0} (opacity: {1})'.format(compositeNode.GetForegroundVolumeID(), compositeNode.GetForegroundOpacity()))&lt;br /&gt;
  print('  Label volume: {0} (opacity: {1})'.format(compositeNode.GetLabelVolumeID(), compositeNode.GetLabelOpacity()))&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
For low-level manipulation of views, it is possible to access VTK render windows, renderers and cameras of views in the current layout.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
renderWindow = view.renderWindow()&lt;br /&gt;
renderers = renderWindow.GetRenderers()&lt;br /&gt;
renderer = renderers.GetItemAsObject(0)&lt;br /&gt;
camera = cameraNode.GetCamera()&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Change 3D view background color ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
renderWindow = slicer.app.layoutManager().threeDWidget(0).threeDView().renderWindow()&lt;br /&gt;
renderer = renderWindow.GetRenderers().GetFirstRenderer()&lt;br /&gt;
renderer.SetBackground(1,0,0)&lt;br /&gt;
renderer.SetBackground2(1,0,0)&lt;br /&gt;
renderWindow.Render()&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Subject hierarchy == &lt;br /&gt;
==== Get the pseudo-singleton subject hierarchy node ====&lt;br /&gt;
It manages the whole hierarchy and provides functions to access and manipulate&lt;br /&gt;
  shNode = slicer.vtkMRMLSubjectHierarchyNode.GetSubjectHierarchyNode(slicer.mrmlScene)&lt;br /&gt;
&lt;br /&gt;
==== Create subject hierarchy item ====&lt;br /&gt;
  # If it is for a data node, it is automatically created, but the create function can be used to set parent:&lt;br /&gt;
  shNode.CreateItem(parentItemID, dataNode)&lt;br /&gt;
  # If it is a hierarchy item without a data node, then the create function must be used:&lt;br /&gt;
  shNode.CreateSubjectItem(parentItemID, name)&lt;br /&gt;
  shNode.CreateFolderItem(parentItemID, name)&lt;br /&gt;
  shNode.CreateHierarchyItem(parentItemID, name, level) # Advanced method to set level attribute manually (usually subject, study, or folder, but it can be a virtual branch for example)&lt;br /&gt;
&lt;br /&gt;
==== Get subject hierarchy item ====&lt;br /&gt;
Items in subject hierarchy are uniquely identified by integer IDs&lt;br /&gt;
  # Get scene item ID first because it is the root item:&lt;br /&gt;
  sceneItemID = shNode.GetSceneItemID()&lt;br /&gt;
  # Get direct child by name&lt;br /&gt;
  subjectItemID = shNode.GetItemChildWithName(sceneItemID, 'Subject_1')&lt;br /&gt;
  # Get item for data node&lt;br /&gt;
  itemID = shNode.GetItemByDataNode(dataNode)&lt;br /&gt;
  # Get item by UID (such as DICOM)&lt;br /&gt;
  itemID = shNode.GetItemByUID(slicer.vtkMRMLSubjectHierarchyConstants.GetDICOMUIDName(), seriesInstanceUid)&lt;br /&gt;
  itemID = shNode.GetItemByUIDList(slicer.vtkMRMLSubjectHierarchyConstants.GetDICOMInstanceUIDName(), instanceUID)&lt;br /&gt;
  # Invalid item ID for checking validity of a given ID (most functions return the invalid ID when item is not found)&lt;br /&gt;
  invalidItemID = slicer.vtkMRMLSubjectHierarchyNode.GetInvalidItemID()&lt;br /&gt;
&lt;br /&gt;
==== Traverse children of a subject hierarchy item ====&lt;br /&gt;
  children = vtk.vtkIdList()&lt;br /&gt;
  shNode.GetItemChildren(parent, children)&lt;br /&gt;
  for i in xrange(children.GetNumberOfIds()):&lt;br /&gt;
    child = children.GetId(i)&lt;br /&gt;
    ...&lt;br /&gt;
&lt;br /&gt;
==== Manipulate subject hierarchy item ====&lt;br /&gt;
Instead of node operations on the individual subject hierarchy nodes, item operations are performed on the one subject hierarchy node.&lt;br /&gt;
  # Set item name&lt;br /&gt;
  shNode.SetItemName(itemID, 'NewName')&lt;br /&gt;
  # Set item parent (reparent)&lt;br /&gt;
  shNode.SetItemParent(itemID, newParentItemID)&lt;br /&gt;
  # Set visibility of data nodes associated to items in a branch (or a leaf item)&lt;br /&gt;
  shNode.SetDisplayVisibilityForBranch(itemID, 1)&lt;br /&gt;
&lt;br /&gt;
==== Filter items in TreeView or ComboBox ====&lt;br /&gt;
Displayed items can be filtered using ''setAttributeFilter'' method. An example of the usage can be found in the  [https://github.com/Slicer/Slicer/blob/e66e3b08e35384526528e6ae678e9ec9f079f286/Applications/SlicerApp/Testing/Python/SubjectHierarchyGenericSelfTest.py#L352-L360 unit test]. Modified version here:&lt;br /&gt;
    print shTreeView.displayedItemCount() # 5&lt;br /&gt;
    shTreeView.setAttributeFilter('DICOM.Modality') # Nodes must have this attribute&lt;br /&gt;
    print shTreeView.displayedItemCount() # 3&lt;br /&gt;
    shTreeView.setAttributeFilter('DICOM.Modality','CT') # Have attribute and equal 'CT'&lt;br /&gt;
    print shTreeView.displayedItemCount() # 1&lt;br /&gt;
    shTreeView.removeAttributeFilter()&lt;br /&gt;
    print shTreeView.displayedItemCount() # 5&lt;br /&gt;
&lt;br /&gt;
== Plotting ==&lt;br /&gt;
&lt;br /&gt;
=== Create histogram plot of a volume ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Get a volume from SampleData&lt;br /&gt;
import SampleData&lt;br /&gt;
volumeNode = SampleData.SampleDataLogic().downloadMRHead()&lt;br /&gt;
&lt;br /&gt;
# Compute histogram values&lt;br /&gt;
import numpy as np&lt;br /&gt;
histogram = np.histogram(arrayFromVolume(volumeNode), bins=50)&lt;br /&gt;
&lt;br /&gt;
# Save results to a new table node&lt;br /&gt;
tableNode=slicer.mrmlScene.AddNewNodeByClass(&amp;quot;vtkMRMLTableNode&amp;quot;)&lt;br /&gt;
updateTableFromArray(tableNode, histogram)&lt;br /&gt;
tableNode.GetTable().GetColumn(0).SetName(&amp;quot;Count&amp;quot;)&lt;br /&gt;
tableNode.GetTable().GetColumn(1).SetName(&amp;quot;Intensity&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
# Create plot&lt;br /&gt;
plotSeriesNode = slicer.mrmlScene.AddNewNodeByClass(&amp;quot;vtkMRMLPlotSeriesNode&amp;quot;, volumeNode.GetName() + ' histogram')&lt;br /&gt;
plotSeriesNode.SetAndObserveTableNodeID(tableNode.GetID())&lt;br /&gt;
plotSeriesNode.SetXColumnName(&amp;quot;Intensity&amp;quot;)&lt;br /&gt;
plotSeriesNode.SetYColumnName(&amp;quot;Count&amp;quot;)&lt;br /&gt;
plotSeriesNode.SetPlotType(plotSeriesNode.PlotTypeScatterBar)&lt;br /&gt;
plotSeriesNode.SetColor(0, 0.6, 1.0)&lt;br /&gt;
&lt;br /&gt;
# Create chart and add plot&lt;br /&gt;
plotChartNode = slicer.mrmlScene.AddNewNodeByClass(&amp;quot;vtkMRMLPlotChartNode&amp;quot;)&lt;br /&gt;
plotChartNode.AddAndObservePlotSeriesNodeID(plotSeriesNode.GetID())&lt;br /&gt;
plotChartNode.YAxisRangeAutoOff()&lt;br /&gt;
plotChartNode.SetYAxisRange(0, 500000)&lt;br /&gt;
&lt;br /&gt;
# Show plot in layout&lt;br /&gt;
slicer.modules.plots.logic().ShowChartInLayout(plotChartNode)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Execute external applications ==&lt;br /&gt;
&lt;br /&gt;
How to run external applications from Slicer.&lt;br /&gt;
&lt;br /&gt;
=== Run process in default environment ===&lt;br /&gt;
&lt;br /&gt;
When a process is launched from Slicer then by default Slicer's ITK, VTK, Qt, etc. libraries are used. If an external application has its own version of these libraries, then the application is expected to crash. To prevent crashing, the application must be run in the environment where Slicer started up (without all Slicer-specific library paths). This startup environment can be retrieved using ''slicer.util.startupEnvironment()''.&lt;br /&gt;
&lt;br /&gt;
Example: run Python3 script from Slicer:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
command_to_execute = [&amp;quot;/usr/bin/python3&amp;quot;, &amp;quot;-c&amp;quot;, &amp;quot;print('hola')&amp;quot;]&lt;br /&gt;
from subprocess import check_output&lt;br /&gt;
check_output(&lt;br /&gt;
  command_to_execute, &lt;br /&gt;
  env=slicer.util.startupEnvironment()&lt;br /&gt;
  )&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
will output:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
'hola\n'&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
On some systems, ''shell=True'' must be specified as well.&lt;/div&gt;</summary>
		<author><name>Inorton</name></author>
		
	</entry>
	<entry>
		<id>https://www.slicer.org/w/index.php?title=Documentation/Nightly/ScriptRepository&amp;diff=58990</id>
		<title>Documentation/Nightly/ScriptRepository</title>
		<link rel="alternate" type="text/html" href="https://www.slicer.org/w/index.php?title=Documentation/Nightly/ScriptRepository&amp;diff=58990"/>
		<updated>2018-05-21T18:51:44Z</updated>

		<summary type="html">&lt;p&gt;Inorton: /* Export a fiber tracts to Blender, including color */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;noinclude&amp;gt;{{documentation/versioncheck}}&amp;lt;/noinclude&amp;gt;&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Community-contributed modules=&lt;br /&gt;
&lt;br /&gt;
The examples in this section are [[Documentation/{{documentation/version}}/Developers/Modules#Scripted_Modules| Scripted Modules]] that provide a user interface in the module panel along with specialized implementation logic.&lt;br /&gt;
&lt;br /&gt;
Usage: save the .py file to a directory, add the directory to the additional module paths in the Slicer application settings (choose in the menu: Edit / Application settings, click Modules, click &amp;gt;&amp;gt; next to Additional module paths, click Add, and choose the .py file's location).&lt;br /&gt;
&lt;br /&gt;
==Filters==&lt;br /&gt;
* [https://raw.github.com/pieper/VolumeMasker/master/VolumeMasker.py VolumeMasker.py]: Update a target volume with the results of setting all input volume voxels to 0 except for those that correspond to a selected label value in an input label map (Used for example in the volume rendering in [https://www.youtube.com/watch?v=dfu2gugHLHs this video).&lt;br /&gt;
&lt;br /&gt;
==DICOM==&lt;br /&gt;
* [https://gist.github.com/pieper/6186477 dicom header browser] to easily scroll through dicom files using dcmdump.&lt;br /&gt;
* [https://github.com/SlicerRt/SlicerRT/tree/master/BatchProcessing SlicerRT batch processing] to batch convert RT structure sets to labelmap NRRD files.&lt;br /&gt;
&lt;br /&gt;
==Informatics==&lt;br /&gt;
* [https://gist.github.com/lassoan/bf0954d93cacc8cbe27cd4a3ad503f2f MarkupsInfo.py]: Compute the total length between all the points of a markup list.&lt;br /&gt;
* [https://gist.github.com/lassoan/0e7acfbec36e4577f8b7b0e07ad53a2a LineProfile.py]: Compute intensity profile in a volume along a line.&lt;br /&gt;
&lt;br /&gt;
=Community-contributed examples=&lt;br /&gt;
&lt;br /&gt;
Usage: Copy-paste the shown code lines or linked .py file contents into Python console in Slicer.  Or save them to a file and run them using execfile.&lt;br /&gt;
&lt;br /&gt;
==Capture==&lt;br /&gt;
* Capture the full Slicer screen and save it into a file&lt;br /&gt;
  img = qt.QPixmap.grabWidget(slicer.util.mainWindow()).toImage()&lt;br /&gt;
  img.save('c:/tmp/test.png')&lt;br /&gt;
* Capture all the views save it into a file:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
import ScreenCapture&lt;br /&gt;
cap = ScreenCapture.ScreenCaptureLogic()&lt;br /&gt;
cap.showViewControllers(False)&lt;br /&gt;
cap.captureImageFromView(None,'c:/tmp/test.png')&lt;br /&gt;
cap.showViewControllers(True)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
* Capture a single view:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
viewNodeID = 'vtkMRMLViewNode1'&lt;br /&gt;
import ScreenCapture&lt;br /&gt;
cap = ScreenCapture.ScreenCaptureLogic()&lt;br /&gt;
view = cap.viewFromNode(slicer.mrmlScene.GetNodeByID(viewNodeID))&lt;br /&gt;
cap.captureImageFromView(view,'c:/tmp/test.png')&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Common values for viewNodeID: vtkMRMLSliceNodeRed, vtkMRMLSliceNodeYellow, vtkMRMLSliceNodeGreen, vtkMRMLViewNode1, vtkMRMLViewNode2. &lt;br /&gt;
The ScreenCapture module can also create video animations of rotating views, slice sweeps, etc.&lt;br /&gt;
&lt;br /&gt;
* Capture a slice view sweep into a series of PNG files - for example, Red slice view, 30 images, from position -125.0 to 75.0, into c:/tmp folder, with name image_00001.png, image_00002.png, ...&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
import ScreenCapture&lt;br /&gt;
ScreenCapture.ScreenCaptureLogic().captureSliceSweep(getNode('vtkMRMLSliceNodeRed'), -125.0, 75.0, 30, &amp;quot;c:/tmp&amp;quot;, &amp;quot;image_%05d.png&amp;quot;)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Capture 3D view into PNG file with transparent background&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
renderWindow = slicer.app.layoutManager().threeDWidget(0).threeDView().renderWindow()&lt;br /&gt;
renderWindow.SetAlphaBitPlanes(1)&lt;br /&gt;
wti = vtk.vtkWindowToImageFilter()&lt;br /&gt;
wti.SetInputBufferTypeToRGBA()&lt;br /&gt;
wti.SetInput(renderWindow)&lt;br /&gt;
writer = vtk.vtkPNGWriter()&lt;br /&gt;
writer.SetFileName(&amp;quot;c:/tmp/screenshot.png&amp;quot;)&lt;br /&gt;
writer.SetInputConnection(wti.GetOutputPort())&lt;br /&gt;
writer.Write()&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Launching Slicer==&lt;br /&gt;
* How to open an .mrb file with Slicer at the command line?&lt;br /&gt;
  Slicer.exe --python-code &amp;quot;slicer.util.loadScene( 'f:/2013-08-23-Scene.mrb' )&amp;quot;&lt;br /&gt;
* How to run a script in the Slicer environment in batch mode (without showing any graphical user interface)?&lt;br /&gt;
  Slicer.exe --python-code &amp;quot;doSomething; doSomethingElse; etc.&amp;quot; --testing --no-splash --no-main-window&lt;br /&gt;
&lt;br /&gt;
==Load volume from file==&lt;br /&gt;
When loading a volume from file, it is recommended to set returnNode=True to retrieve the loaded volume node.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
[success, loadedVolumeNode] = slicer.util.loadVolume('c:/Users/abc/Documents/MRHead.nrrd', returnNode=True)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Get a MRML node in the scene based on the node name and call methods of that object. For the MRHead sample data:&lt;br /&gt;
  vol=slicer.util.getNode('MR*')&lt;br /&gt;
  vol.GetImageData().GetDimensions()&lt;br /&gt;
&lt;br /&gt;
==DICOM==&lt;br /&gt;
=== How to access tags of DICOM images imported into Slicer? For example, to print the first patient's first study's first series' &amp;quot;0020,0032&amp;quot; field:===&lt;br /&gt;
  db=slicer.dicomDatabase&lt;br /&gt;
  patientList=db.patients()&lt;br /&gt;
  studyList=db.studiesForPatient(patientList[0])&lt;br /&gt;
  seriesList=db.seriesForStudy(studyList[0])&lt;br /&gt;
  fileList=db.filesForSeries(seriesList[0])&lt;br /&gt;
  print db.fileValue(fileList[0],'0020,0032')&lt;br /&gt;
&lt;br /&gt;
=== How to access tag of a volume loaded from DICOM? For example, get the patient position stored in a volume:===&lt;br /&gt;
  volumeName='2: ENT IMRT'&lt;br /&gt;
  n=slicer.util.getNode(volumeName)&lt;br /&gt;
  instUids=n.GetAttribute('DICOM.instanceUIDs').split()&lt;br /&gt;
  filename=slicer.dicomDatabase.fileForInstance(instUids[0])&lt;br /&gt;
  print slicer.dicomDatabase.fileValue(filename,'0018,5100')&lt;br /&gt;
&lt;br /&gt;
=== How to access tag of an item in the Subject Hierachy tree? For example, get the content time tag of a structure set:===&lt;br /&gt;
  rtStructName = '3: RTSTRUCT: PROS'&lt;br /&gt;
  rtStructNode = slicer.util.getNode(rtStructName)&lt;br /&gt;
  shNode = slicer.vtkMRMLSubjectHierarchyNode.GetSubjectHierarchyNode(slicer.mrmlScene)&lt;br /&gt;
  rtStructShItemID = shNode.GetItemByDataNode(rtStructNode)&lt;br /&gt;
  ctSliceInstanceUids = shNode.GetItemAttribute(rtStructShItemID, 'DICOM.ReferencedInstanceUIDs').split()&lt;br /&gt;
  filename = slicer.dicomDatabase.fileForInstance(ctSliceInstanceUids[0])&lt;br /&gt;
  print slicer.dicomDatabase.fileValue(filename,'0008,0033')&lt;br /&gt;
&lt;br /&gt;
=== How to get path and filename of a loaded DICOM volume?===&lt;br /&gt;
  def pathFromNode(node):&lt;br /&gt;
    storageNode=node.GetStorageNode()&lt;br /&gt;
    if storageNode is not None: # loaded via drag-drop&lt;br /&gt;
        filepath=storageNode.GetFullNameFromFileName()&lt;br /&gt;
    else: # loaded via DICOM browser&lt;br /&gt;
        instanceUIDs=node.GetAttribute('DICOM.instanceUIDs').split()&lt;br /&gt;
        filepath=slicer.dicomDatabase.fileForInstance(instUids[0])&lt;br /&gt;
    return filepath&lt;br /&gt;
  &lt;br /&gt;
  # example:&lt;br /&gt;
  node=slicer.util.getNode('volume1')&lt;br /&gt;
  path=self.pathFromNode(node)&lt;br /&gt;
  print(&amp;quot;DICOM path=%s&amp;quot; % path)&lt;br /&gt;
&lt;br /&gt;
=== How can I convert DICOM to NRRD on the command line?===&lt;br /&gt;
&lt;br /&gt;
 /Applications/Slicer-4.6.2.app/Contents/MacOS/Slicer --no-main-window --python-code &amp;quot;node=slicer.util.loadVolume('/tmp/series/im0.dcm', returnNode=True)[1]; slicer.util.saveNode(node, '/tmp/output.nrrd'); exit()&amp;quot;&lt;br /&gt;
&lt;br /&gt;
The same can be done on windows by using the top level Slicer.exe.  Be sure to use forward slashes in the pathnames within quotes on the command line.&lt;br /&gt;
&lt;br /&gt;
==Toolbar functions==&lt;br /&gt;
* How to turn on slice intersections in the crosshair menu on the toolbar:&lt;br /&gt;
  viewNodes = slicer.mrmlScene.GetNodesByClass('vtkMRMLSliceCompositeNode')&lt;br /&gt;
  viewNodes.UnRegister(slicer.mrmlScene)&lt;br /&gt;
  viewNodes.InitTraversal()&lt;br /&gt;
  viewNode = viewNodes.GetNextItemAsObject()&lt;br /&gt;
  while viewNode:&lt;br /&gt;
    viewNode.SetSliceIntersectionVisibility(1)&lt;br /&gt;
    viewNode = viewNodes.GetNextItemAsObject()&lt;br /&gt;
&lt;br /&gt;
How to find similar functions? For this one I searched for &amp;quot;slice intersections&amp;quot; text in the whole slicer source code, found that the function is implemented in Base\QTGUI\qSlicerViewersToolBar.cxx, then translated the qSlicerViewersToolBarPrivate::setSliceIntersectionVisible(bool visible) method to Python.&lt;br /&gt;
&lt;br /&gt;
==Manipulating objects in the slice viewer==&lt;br /&gt;
* How to define/edit a circular region of interest in a slice viewer?&lt;br /&gt;
&lt;br /&gt;
Drop two markup points on a slice view and copy-paste the code below into the Python console. After this, as you move the markups you’ll see a circle following the markups.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Update the sphere from the fiducial points&lt;br /&gt;
def UpdateSphere(param1, param2):  &lt;br /&gt;
  import math&lt;br /&gt;
  centerPointCoord = [0.0, 0.0, 0.0]&lt;br /&gt;
  markups.GetNthFiducialPosition(0,centerPointCoord)&lt;br /&gt;
  circumferencePointCoord = [0.0, 0.0, 0.0]&lt;br /&gt;
  markups.GetNthFiducialPosition(1,circumferencePointCoord)&lt;br /&gt;
  sphere.SetCenter(centerPointCoord)&lt;br /&gt;
  radius=math.sqrt((centerPointCoord[0]-circumferencePointCoord[0])**2+(centerPointCoord[1]-circumferencePointCoord[1])**2+(centerPointCoord[2]-circumferencePointCoord[2])**2)&lt;br /&gt;
  sphere.SetRadius(radius)&lt;br /&gt;
  sphere.SetPhiResolution(30)&lt;br /&gt;
  sphere.SetThetaResolution(30)&lt;br /&gt;
  sphere.Update()&lt;br /&gt;
&lt;br /&gt;
# Get markup node from scene&lt;br /&gt;
markups=slicer.util.getNode('F')&lt;br /&gt;
sphere = vtk.vtkSphereSource()&lt;br /&gt;
UpdateSphere(0,0)&lt;br /&gt;
 &lt;br /&gt;
# Create model node and add to scene&lt;br /&gt;
modelsLogic = slicer.modules.models.logic()&lt;br /&gt;
model = modelsLogic.AddModel(sphere.GetOutput())&lt;br /&gt;
model.GetDisplayNode().SetSliceIntersectionVisibility(True)&lt;br /&gt;
model.GetDisplayNode().SetSliceIntersectionThickness(3)&lt;br /&gt;
model.GetDisplayNode().SetColor(1,1,0)&lt;br /&gt;
 &lt;br /&gt;
# Call UpdateSphere whenever the fiducials are changed&lt;br /&gt;
markups.AddObserver(&amp;quot;ModifiedEvent&amp;quot;, UpdateSphere, 2)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Switching to markup fiducial placement mode ==&lt;br /&gt;
&lt;br /&gt;
To activate a fiducial placement mode, both interaction mode has to be set and a fiducial node has to be selected:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
interactionNode = slicer.app.applicationLogic().GetInteractionNode()&lt;br /&gt;
selectionNode = slicer.app.applicationLogic().GetSelectionNode()&lt;br /&gt;
selectionNode.SetReferenceActivePlaceNodeClassName(&amp;quot;vtkMRMLMarkupsFiducialNode&amp;quot;)&lt;br /&gt;
fiducialNode = slicer.vtkMRMLMarkupsFiducialNode()&lt;br /&gt;
slicer.mrmlScene.AddNode(fiducialNode)&lt;br /&gt;
fiducialNode.CreateDefaultDisplayNodes() &lt;br /&gt;
selectionNode.SetActivePlaceNodeID(fiducialNode.GetID())&lt;br /&gt;
interactionNode.SetCurrentInteractionMode(interactionNode.Place)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Get a notification if a markup point position is modified ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
def onMarkupsNodeModified(markupsNode, unusedArg2=None, unusedArg3=None):&lt;br /&gt;
  sliceView = markupsNode.GetAttribute('Markups.MovingInSliceView')&lt;br /&gt;
  if not sliceView:&lt;br /&gt;
    print(&amp;quot;Markup list was modified&amp;quot;)&lt;br /&gt;
    return&lt;br /&gt;
  movingMarkupIndex = markupsNode.GetAttribute('Markups.MovingMarkupIndex')&lt;br /&gt;
  pos = [0,0,0]&lt;br /&gt;
  markupsNode.GetNthFiducialPosition(int(movingMarkupIndex), pos)  &lt;br /&gt;
  print(&amp;quot;Markup {0} was moved in slice view {1} to {2}&amp;quot;.format(movingMarkupIndex, sliceView, pos))&lt;br /&gt;
&lt;br /&gt;
markupsNode = slicer.mrmlScene.AddNewNodeByClass(&amp;quot;vtkMRMLMarkupsFiducialNode&amp;quot;)&lt;br /&gt;
markupsNode.CreateDefaultDisplayNodes()&lt;br /&gt;
markupsNode.AddFiducial(0,0,0)&lt;br /&gt;
markupsNode.AddObserver(vtk.vtkCommand.ModifiedEvent, onMarkupsNodeModified)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Show a context menu when a markup point is clicked in a slice or 3D view ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
# Example actions to perform&lt;br /&gt;
&lt;br /&gt;
def action1():&lt;br /&gt;
  print('Action1 on markup '+str(slicer.clickedMarkupIndex))&lt;br /&gt;
&lt;br /&gt;
def action2():&lt;br /&gt;
  print('Action2 on markup '+str(slicer.clickedMarkupIndex))&lt;br /&gt;
&lt;br /&gt;
def action3():&lt;br /&gt;
  print('Action3 on markup '+str(slicer.clickedMarkupIndex))&lt;br /&gt;
&lt;br /&gt;
# Clicked markup index is saved here to let the action&lt;br /&gt;
# know which markup needs to be manipulated.&lt;br /&gt;
slicer.clickedMarkupIndex = -1&lt;br /&gt;
  &lt;br /&gt;
# Create a simple menu&lt;br /&gt;
&lt;br /&gt;
menu = qt.QMenu()&lt;br /&gt;
a1 = qt.QAction(&amp;quot;Test&amp;quot;, slicer.util.mainWindow())&lt;br /&gt;
a1.connect('triggered()', action1)&lt;br /&gt;
menu.addAction(a1)&lt;br /&gt;
a2 = qt.QAction(&amp;quot;Action&amp;quot;, slicer.util.mainWindow())&lt;br /&gt;
a2.connect('triggered()', action1)&lt;br /&gt;
menu.addAction(a2)&lt;br /&gt;
a3 = qt.QAction(&amp;quot;Here&amp;quot;, slicer.util.mainWindow())&lt;br /&gt;
a3.connect('triggered()', action1)&lt;br /&gt;
menu.addAction(a3)&lt;br /&gt;
&lt;br /&gt;
# Add observer to a markup fiducial list&lt;br /&gt;
&lt;br /&gt;
@vtk.calldata_type(vtk.VTK_INT)&lt;br /&gt;
def markupClickedCallback(caller, eventId, callData):&lt;br /&gt;
  slicer.clickedMarkupIndex = callData&lt;br /&gt;
  print('Open menu on markup '+str(slicer.clickedMarkupIndex))&lt;br /&gt;
  menu.move(qt.QCursor.pos())&lt;br /&gt;
  menu.show()&lt;br /&gt;
&lt;br /&gt;
markupsNode = getNode('F')&lt;br /&gt;
observerTag = markupsNode.AddObserver(slicer.vtkMRMLMarkupsNode.PointClickedEvent, markupClickedCallback)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Add a texture mapped plane to the scene as a model ==&lt;br /&gt;
Note that model textures are not exposed in the GUI and are not saved in the scene&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# use dummy image data here&lt;br /&gt;
e = vtk.vtkImageEllipsoidSource()&lt;br /&gt;
&lt;br /&gt;
scene = slicer.mrmlScene&lt;br /&gt;
&lt;br /&gt;
# Create model node&lt;br /&gt;
model = slicer.vtkMRMLModelNode()&lt;br /&gt;
model.SetScene(scene)&lt;br /&gt;
model.SetName(scene.GenerateUniqueName(&amp;quot;2DImageModel&amp;quot;))&lt;br /&gt;
&lt;br /&gt;
planeSource = vtk.vtkPlaneSource()&lt;br /&gt;
model.SetAndObservePolyData(planeSource.GetOutput())&lt;br /&gt;
&lt;br /&gt;
# Create display node&lt;br /&gt;
modelDisplay = slicer.vtkMRMLModelDisplayNode()&lt;br /&gt;
modelDisplay.SetColor(1,1,0) # yellow&lt;br /&gt;
modelDisplay.SetBackfaceCulling(0)&lt;br /&gt;
modelDisplay.SetScene(scene)&lt;br /&gt;
scene.AddNode(modelDisplay)&lt;br /&gt;
model.SetAndObserveDisplayNodeID(modelDisplay.GetID())&lt;br /&gt;
&lt;br /&gt;
# Add to scene&lt;br /&gt;
modelDisplay.SetAndObserveTextureImageData(e.GetOutput())&lt;br /&gt;
scene.AddNode(model) &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
transform = slicer.vtkMRMLLinearTransformNode()&lt;br /&gt;
scene.AddNode(transform) &lt;br /&gt;
model.SetAndObserveTransformNodeID(transform.GetID())&lt;br /&gt;
&lt;br /&gt;
vTransform = vtk.vtkTransform()&lt;br /&gt;
vTransform.Scale(50,50,50)&lt;br /&gt;
vTransform.RotateX(30)&lt;br /&gt;
transform.SetAndObserveMatrixTransformToParent(vTransform.GetMatrix())&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Export entire scene as VRML ==&lt;br /&gt;
&lt;br /&gt;
Save all surface meshes displayed in the scene (models, markups, etc). Solid colors and coloring by scalar is preserved. Textures are not supported.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
exporter = vtk.vtkVRMLExporter()&lt;br /&gt;
exporter.SetRenderWindow(slicer.app.layoutManager().threeDWidget(0).threeDView().renderWindow())&lt;br /&gt;
exporter.SetFileName('C:/tmp/something.wrl')&lt;br /&gt;
exporter.Write()&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Export model to Blender, including color by scalar ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
modelNode = getNode(&amp;quot;Model&amp;quot;)&lt;br /&gt;
plyFilePath = &amp;quot;c:/tmp/model.ply&amp;quot;&lt;br /&gt;
&lt;br /&gt;
modelDisplayNode = modelNode.GetDisplayNode()&lt;br /&gt;
triangles = vtk.vtkTriangleFilter()&lt;br /&gt;
triangles.SetInputConnection(modelDisplayNode.GetOutputPolyDataConnection())&lt;br /&gt;
&lt;br /&gt;
plyWriter = vtk.vtkPLYWriter()&lt;br /&gt;
plyWriter.SetInputConnection(triangles.GetOutputPort())&lt;br /&gt;
lut = vtk.vtkLookupTable()&lt;br /&gt;
lut.DeepCopy(modelDisplayNode.GetColorNode().GetLookupTable())&lt;br /&gt;
lut.SetRange(modelDisplayNode.GetScalarRange())&lt;br /&gt;
plyWriter.SetLookupTable(lut)&lt;br /&gt;
plyWriter.SetArrayName(modelDisplayNode.GetActiveScalarName())&lt;br /&gt;
&lt;br /&gt;
plyWriter.SetFileName(plyFilePath)&lt;br /&gt;
plyWriter.Write()&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Export a fiber tracts to Blender, including color ==&lt;br /&gt;
&lt;br /&gt;
Note: an interactive version of this script is now included in the [http://dmri.slicer.org/ SlicerDMRI extension] ([https://github.com/SlicerDMRI/SlicerDMRI/tree/master/Modules/Scripted/TractographyExportPLY module code]). &lt;br /&gt;
After installing SlicerDMRI, go to ''Modules -&amp;gt; Diffusion -&amp;gt; Import and Export -&amp;gt; Export tractography to PLY (mesh)''.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
lineDisplayNode = getNode(&amp;quot;*LineDisplay*&amp;quot;)&lt;br /&gt;
plyFilePath = &amp;quot;/tmp/fibers.ply&amp;quot;&lt;br /&gt;
&lt;br /&gt;
tuber = vtk.vtkTubeFilter()&lt;br /&gt;
tuber.SetInputData(lineDisplayNode.GetOutputPolyData())&lt;br /&gt;
tuber.Update()&lt;br /&gt;
tubes = tuber.GetOutputDataObject(0)&lt;br /&gt;
scalars = tubes.GetPointData().GetArray(0)&lt;br /&gt;
scalars.SetName(&amp;quot;scalars&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
triangles = vtk.vtkTriangleFilter()&lt;br /&gt;
triangles.SetInputData(tubes)&lt;br /&gt;
triangles.Update()&lt;br /&gt;
&lt;br /&gt;
colorNode = lineDisplayNode.GetColorNode()&lt;br /&gt;
lookupTable = vtk.vtkLookupTable()&lt;br /&gt;
lookupTable.DeepCopy(colorNode.GetLookupTable())&lt;br /&gt;
lookupTable.SetTableRange(0,1)&lt;br /&gt;
&lt;br /&gt;
plyWriter = vtk.vtkPLYWriter()&lt;br /&gt;
plyWriter.SetInputData(triangles.GetOutput())&lt;br /&gt;
&lt;br /&gt;
if lineDisplayNode.GetColorMode() == lineDisplayNode.colorModeSolid:&lt;br /&gt;
    # for solid colors we need to set uniform mode in the exporter,&lt;br /&gt;
    # to avoid coloring by the last-used scalar array&lt;br /&gt;
    plyWriter.SetColorModeToUniformPointColor()&lt;br /&gt;
    color = np.array(np.multiply(lineDisplayNode.GetColor(), 255),&lt;br /&gt;
                               dtype=np.uint8) # range clamp&lt;br /&gt;
    #plyWriter.SetColor(int(color[0]), int(color[1]), int(color[2]))&lt;br /&gt;
      plyWriter.SetColor(color[0], color[1], color[2])&lt;br /&gt;
else:&lt;br /&gt;
    plyWriter.SetLookupTable(lookupTable)&lt;br /&gt;
    plyWriter.SetArrayName(&amp;quot;scalars&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
plyWriter.SetFileName(plyFilePath)&lt;br /&gt;
plyWriter.Write()&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Clone a volume ==&lt;br /&gt;
This example shows how to clone the MRHead sample volume, including its pixel data and display settings.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sourceVolumeNode = slicer.util.getNode('MRHead')&lt;br /&gt;
volumesLogic = slicer.modules.volumes.logic()&lt;br /&gt;
clonedVolumeNode = volumesLogic.CloneVolume(slicer.mrmlScene, sourceVolumeNode, 'Cloned volume')&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Create a new volume ==&lt;br /&gt;
This example shows how to create a new empty volume.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
nodeName = &amp;quot;MyNewVolume&amp;quot;&lt;br /&gt;
imageSize = [512, 512, 512]&lt;br /&gt;
voxelType=vtk.VTK_UNSIGNED_CHAR&lt;br /&gt;
imageOrigin = [0.0, 0.0, 0.0]&lt;br /&gt;
imageSpacing = [1.0, 1.0, 1.0]&lt;br /&gt;
imageDirections = [[1,0,0], [0,1,0], [0,0,1]]&lt;br /&gt;
fillVoxelValue = 0&lt;br /&gt;
&lt;br /&gt;
# Create an empty image volume, filled with fillVoxelValue&lt;br /&gt;
imageData = vtk.vtkImageData()&lt;br /&gt;
imageData.SetDimensions(imageSize)&lt;br /&gt;
imageData.AllocateScalars(voxelType, 1)&lt;br /&gt;
thresholder = vtk.vtkImageThreshold()&lt;br /&gt;
thresholder.SetInputData(imageData)&lt;br /&gt;
thresholder.SetInValue(fillVoxelValue)&lt;br /&gt;
thresholder.SetOutValue(fillVoxelValue)&lt;br /&gt;
thresholder.Update()&lt;br /&gt;
# Create volume node&lt;br /&gt;
volumeNode = slicer.mrmlScene.AddNewNodeByClass(&amp;quot;vtkMRMLScalarVolumeNode&amp;quot;, nodeName)&lt;br /&gt;
volumeNode.SetOrigin(imageOrigin)&lt;br /&gt;
volumeNode.SetSpacing(imageSpacing)&lt;br /&gt;
volumeNode.SetIJKToRASDirections(imageDirections)&lt;br /&gt;
volumeNode.SetAndObserveImageData(thresholder.GetOutput())&lt;br /&gt;
volumeNode.CreateDefaultDisplayNodes()&lt;br /&gt;
volumeNode.CreateDefaultStorageNode()&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Modify voxels in a volume ==&lt;br /&gt;
&lt;br /&gt;
Typically the fastest and simplest way of modifying voxels is by using numpy operators. Voxels can be retrieved in a numpy array using the `array` method and modified using standard numpy methods. For example, threshold a volume:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
nodeName = 'MRHead'&lt;br /&gt;
thresholdValue = 100&lt;br /&gt;
voxelArray = array(nodeName) # get voxels as numpy array&lt;br /&gt;
voxelArray[voxelArray &amp;lt; thresholdValue] = 0 # modify voxel values&lt;br /&gt;
getNode(nodeName).Modified() # at the end of all processing, notify Slicer that the image modification is completed&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This example shows how to change voxels values of the MRHead sample volume.&lt;br /&gt;
The values will be computed by function f(r,a,s,) = (r-10)*(r-10)+(a+15)*(a+15)+s*s.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
volumeNode=slicer.util.getNode('MRHead')&lt;br /&gt;
ijkToRas = vtk.vtkMatrix4x4()&lt;br /&gt;
volumeNode.GetIJKToRASMatrix(ijkToRas)&lt;br /&gt;
imageData=volumeNode.GetImageData()&lt;br /&gt;
extent = imageData.GetExtent()&lt;br /&gt;
for k in xrange(extent[4], extent[5]+1):&lt;br /&gt;
  for j in xrange(extent[2], extent[3]+1):&lt;br /&gt;
    for i in xrange(extent[0], extent[1]+1):&lt;br /&gt;
      position_Ijk=[i, j, k, 1]&lt;br /&gt;
      position_Ras=ijkToRas.MultiplyPoint(position_Ijk)&lt;br /&gt;
      r=position_Ras[0]&lt;br /&gt;
      a=position_Ras[1]&lt;br /&gt;
      s=position_Ras[2]      &lt;br /&gt;
      functionValue=(r-10)*(r-10)+(a+15)*(a+15)+s*s&lt;br /&gt;
      imageData.SetScalarComponentFromDouble(i,j,k,0,functionValue)&lt;br /&gt;
imageData.SetScalarComponentFromFloat(distortionVectorPosition_Ijk[0], distortionVectorPosition_Ijk[1], distortionVectorPosition_Ijk[2], 0, fillValue)&lt;br /&gt;
imageData.Modified()&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Get the values of all voxels for a label value  ==&lt;br /&gt;
&lt;br /&gt;
If you have a background image called ‘Volume’ and a mask called ‘Volume-label’ created with the Editor you could do something like this:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
import numpy&lt;br /&gt;
volume = array(‘Volume’)&lt;br /&gt;
label = array(‘Volume-label’)&lt;br /&gt;
points  = numpy.where( label == 1 )  # or use another label number depending on what you segmented&lt;br /&gt;
values  = volume[points] # this will be a list of the label values&lt;br /&gt;
values.mean() # should match the mean value of LabelStatistics calculation as a double-check&lt;br /&gt;
numpy.savetxt(‘values.txt’, values)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Access values in a DTI tensor volume ==&lt;br /&gt;
This example shows how to access individual tensors at the voxel level.&lt;br /&gt;
&lt;br /&gt;
First load your DWI volume and estimate tensors to produce a DTI volume called ‘Output DTI Volume’&lt;br /&gt;
&lt;br /&gt;
Then open the python window: View-&amp;gt;Python interactor&lt;br /&gt;
&lt;br /&gt;
Use this command to access tensors through numpy:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
tensors = array('Output DTI Volume')&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Type the following code into the Python window to access all tensor components using vtk commands:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
volumeNode=slicer.util.getNode('Output DTI Volume')&lt;br /&gt;
imageData=volumeNode.GetImageData()&lt;br /&gt;
tensors = imageData.GetPointData().GetTensors()&lt;br /&gt;
extent = imageData.GetExtent()&lt;br /&gt;
idx = 0&lt;br /&gt;
for k in xrange(extent[4], extent[5]+1):&lt;br /&gt;
  for j in xrange(extent[2], extent[3]+1):&lt;br /&gt;
    for i in xrange(extent[0], extent[1]+1):&lt;br /&gt;
      tensors.GetTuple9(idx)&lt;br /&gt;
      idx += 1&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Change window/level (brightness/contrast) or colormap of a volume ==&lt;br /&gt;
This example shows how to change window/level of the MRHead sample volume.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
volumeNode = getNode('MRHead')&lt;br /&gt;
displayNode = volumeNode.GetDisplayNode()&lt;br /&gt;
displayNode.AutoWindowLevelOff()&lt;br /&gt;
displayNode.SetWindow(50)&lt;br /&gt;
displayNode.SetLevel(100)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Change color mapping from grayscale to rainbow:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
displayNode.SetAndObserveColorNodeID('vtkMRMLColorTableNodeRainbow')&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Manipulate a Slice View ==&lt;br /&gt;
&lt;br /&gt;
=== Change the slice offset ===&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
lm = slicer.app.layoutManager()&lt;br /&gt;
red = lm.sliceWidget('Red')&lt;br /&gt;
redLogic = red.sliceLogic()&lt;br /&gt;
# Print current slice offset position&lt;br /&gt;
print redLogic.GetSliceOffset()&lt;br /&gt;
# Change slice position&lt;br /&gt;
redLogic.SetSliceOffset(20)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Iterate over current visible slice views, and modify 3D visibility ===&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
for sliceViewName in layoutManager.sliceViewNames():&lt;br /&gt;
     sliceWidget = layoutManager.sliceWidget(sliceViewName)&lt;br /&gt;
     &lt;br /&gt;
     controller = sliceWidget.sliceController()&lt;br /&gt;
     controller.setSliceVisible(True)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Iterate over current visible slice views, and set foreground and background images ===&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
for sliceViewName in layoutManager.sliceViewNames():&lt;br /&gt;
     sliceWidget = layoutManager.sliceWidget(sliceViewName)&lt;br /&gt;
     &lt;br /&gt;
     # setup background volume&lt;br /&gt;
     compositeNode.SetBackgroundVolumeID(MRVolume.GetID())&lt;br /&gt;
     # setup foreground volume&lt;br /&gt;
     compositeNode.SetForegroundVolumeID(CTVolume.GetID())&lt;br /&gt;
     # change opacity&lt;br /&gt;
     compositeNode.SetForegroundOpacity(0.3)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Fit slice plane to markup fiducials ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sliceNode = slicer.mrmlScene.GetNodeByID(&amp;quot;vtkMRMLSliceNodeRed&amp;quot;)&lt;br /&gt;
markupsNode = slicer.mrmlScene.GetFirstNodeByName(&amp;quot;F&amp;quot;)&lt;br /&gt;
# Get markup point positions as numpy arrays&lt;br /&gt;
import numpy as np&lt;br /&gt;
p1 = np.array([0,0,0])&lt;br /&gt;
p2 = np.array([0,0,0])&lt;br /&gt;
p3 = np.array([0,0,0])&lt;br /&gt;
markupsNode.GetNthFiducialPosition(0, p1)&lt;br /&gt;
markupsNode.GetNthFiducialPosition(1, p2)&lt;br /&gt;
markupsNode.GetNthFiducialPosition(2, p3)&lt;br /&gt;
# Get plane axis directions&lt;br /&gt;
n = np.cross(p2-p1, p2-p3) # plane normal direction&lt;br /&gt;
n = n/np.linalg.norm(n)&lt;br /&gt;
t = np.cross([0, 0, 1], n) # plane transverse direction&lt;br /&gt;
t = t/np.linalg.norm(t)&lt;br /&gt;
# Set slice plane orientation and position&lt;br /&gt;
sliceNode.SetSliceToRASByNTP(n[0], n[1], n[2], t[0], t[1], t[2], p1[0], p1[1], p1[2], 0)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Save a series of images from a Slice View ==&lt;br /&gt;
&lt;br /&gt;
You can use ScreenCapture module to capture series of images. To do it programmatically, save the following into a file such as '/tmp/record.py' and then in the slicer python console type &amp;quot;execfile('/tmp/record.py')&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
layoutName = 'Green'&lt;br /&gt;
imagePathPattern = '/tmp/image-%03d.png'&lt;br /&gt;
steps = 10&lt;br /&gt;
&lt;br /&gt;
widget = slicer.app.layoutManager().sliceWidget(layoutName)&lt;br /&gt;
view = widget.sliceView()&lt;br /&gt;
logic = widget.sliceLogic()&lt;br /&gt;
bounds = [0,]*6&lt;br /&gt;
logic.GetSliceBounds(bounds)&lt;br /&gt;
&lt;br /&gt;
for step in range(steps):&lt;br /&gt;
    offset = bounds[4] + step/(1.*steps) * (bounds[5]-bounds[4])&lt;br /&gt;
    logic.SetSliceOffset(offset)&lt;br /&gt;
    view.forceRender()&lt;br /&gt;
    image = qt.QPixmap.grabWidget(view).toImage()&lt;br /&gt;
    image.save(imagePathPattern % step)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Save the scene into a new directory ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Create a new directory where the scene will be saved into&lt;br /&gt;
import time&lt;br /&gt;
sceneSaveDirectory = slicer.app.temporaryPath + &amp;quot;/saved-scene-&amp;quot; + time.strftime(&amp;quot;%Y%m%d-%H%M%S&amp;quot;)&lt;br /&gt;
if not os.access(sceneSaveDirectory, os.F_OK):&lt;br /&gt;
  os.makedirs(sceneSaveDirectory)&lt;br /&gt;
&lt;br /&gt;
# Save the scene&lt;br /&gt;
if slicer.app.applicationLogic().SaveSceneToSlicerDataBundleDirectory(sceneSaveDirectory, None):&lt;br /&gt;
  logging.info(&amp;quot;Scene saved to: {0}&amp;quot;.format(sceneSaveDirectory))&lt;br /&gt;
else:&lt;br /&gt;
  logging.error(&amp;quot;Scene saving failed&amp;quot;) &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Save the scene into a single MRB file ==&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Generate file name&lt;br /&gt;
import time&lt;br /&gt;
sceneSaveFilename = slicer.app.temporaryPath + &amp;quot;/saved-scene-&amp;quot; + time.strftime(&amp;quot;%Y%m%d-%H%M%S&amp;quot;) + &amp;quot;.mrb&amp;quot;&lt;br /&gt;
&lt;br /&gt;
# Save scene&lt;br /&gt;
if slicer.util.saveScene(sceneSaveFilename):&lt;br /&gt;
  logging.info(&amp;quot;Scene saved to: {0}&amp;quot;.format(sceneSaveFilename))&lt;br /&gt;
else:&lt;br /&gt;
  logging.error(&amp;quot;Scene saving failed&amp;quot;) &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Save a node to file ==&lt;br /&gt;
&lt;br /&gt;
Save a transform node to file (should work with any other node type, if file extension is set to a supported one):&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
myNode = getNode(&amp;quot;LinearTransform_3&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
myStorageNode = myNode.CreateDefaultStorageNode()&lt;br /&gt;
myStorageNode.SetFileName(&amp;quot;c:/tmp/something.tfm&amp;quot;)&lt;br /&gt;
myStorageNode.WriteData(myNode)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Show a volume in the Slice Views ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
volumeNode = slicer.util.getNode('YourVolumeNode')&lt;br /&gt;
applicationLogic = slicer.app.applicationLogic()&lt;br /&gt;
selectionNode = applicationLogic.GetSelectionNode()&lt;br /&gt;
selectionNode.SetSecondaryVolumeID(volumeNode.GetID())&lt;br /&gt;
applicationLogic.PropagateForegroundVolumeSelection(0) &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
or&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
n =  slicer.util.getNode('YourVolumeNode')&lt;br /&gt;
for color in ['Red', 'Yellow', 'Green']:&lt;br /&gt;
    slicer.app.layoutManager().sliceWidget(color).sliceLogic().GetSliceCompositeNode().SetForegroundVolumeID(n.GetID())&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Change opacity of foreground volume in the Slice Views ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
lm = slicer.app.layoutManager()&lt;br /&gt;
sliceLogic = lm.sliceWidget('Red').sliceLogic()&lt;br /&gt;
compositeNode = sliceLogic.GetSliceCompositeNode()&lt;br /&gt;
compositeNode.SetForegroundOpacity(0.4)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Center the 3D View on the Scene ==&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
layoutManager = slicer.app.layoutManager()&lt;br /&gt;
threeDWidget = layoutManager.threeDWidget(0)&lt;br /&gt;
threeDView = threeDWidget.threeDView()&lt;br /&gt;
threeDView.resetFocalPoint()&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Rotate the 3D View==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
layoutManager = slicer.app.layoutManager()&lt;br /&gt;
threeDWidget = layoutManager.threeDWidget(0)&lt;br /&gt;
threeDView = threeDWidget.threeDView()&lt;br /&gt;
threeDView.yaw()&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Display text in a 3D view or slice view ==&lt;br /&gt;
&lt;br /&gt;
The easiest way to show information overlaid on a viewer is to use corner annotations.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
view=slicer.app.layoutManager().threeDWidget(0).threeDView()&lt;br /&gt;
# Set text to &amp;quot;Something&amp;quot;&lt;br /&gt;
view.cornerAnnotation().SetText(vtk.vtkCornerAnnotation.UpperRight,&amp;quot;Something&amp;quot;)&lt;br /&gt;
# Set color to red&lt;br /&gt;
view.cornerAnnotation().GetTextProperty().SetColor(1,0,0)&lt;br /&gt;
# Update the view&lt;br /&gt;
view.forceRender()&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Hide slice view annotations (DataProbe) ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Disable slice annotations immediately&lt;br /&gt;
slicer.modules.DataProbeInstance.infoWidget.sliceAnnotations.sliceViewAnnotationsEnabled=False&lt;br /&gt;
slicer.modules.DataProbeInstance.infoWidget.sliceAnnotations.updateSliceViewFromGUI()&lt;br /&gt;
# Disable slice annotations persistently (after Slicer restarts)&lt;br /&gt;
settings = qt.QSettings()&lt;br /&gt;
settings.setValue('DataProbe/sliceViewAnnotations.enabled', 0)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Turning off interpolation ==&lt;br /&gt;
&lt;br /&gt;
You can turn off interpolation for newly loaded volumes with this script from Steve Pieper.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
def NoInterpolate(caller,event):&lt;br /&gt;
  for node in slicer.util.getNodes('*').values():&lt;br /&gt;
    if node.IsA('vtkMRMLScalarVolumeDisplayNode'):&lt;br /&gt;
      node.SetInterpolate(0)&lt;br /&gt;
	&lt;br /&gt;
slicer.mrmlScene.AddObserver(slicer.mrmlScene.NodeAddedEvent, NoInterpolate)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The below link explains how to put this in your startup script.&lt;br /&gt;
&lt;br /&gt;
http://www.na-mic.org/Wiki/index.php/AHM2012-Slicer-Python#Refining_the_code_and_UI_with_slicerrc&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Customize viewer layout ==&lt;br /&gt;
&lt;br /&gt;
Show a custom layout of a 3D view on top of the red slice view:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
customLayout = (&amp;quot;&amp;lt;layout type=\&amp;quot;vertical\&amp;quot; split=\&amp;quot;true\&amp;quot; &amp;gt;&amp;quot;&lt;br /&gt;
  &amp;quot; &amp;lt;item&amp;gt;&amp;quot;&lt;br /&gt;
  &amp;quot;  &amp;lt;view class=\&amp;quot;vtkMRMLViewNode\&amp;quot; singletontag=\&amp;quot;1\&amp;quot;&amp;gt;&amp;quot;&lt;br /&gt;
  &amp;quot;    &amp;lt;property name=\&amp;quot;viewlabel\&amp;quot; action=\&amp;quot;default\&amp;quot;&amp;gt;1&amp;lt;/property&amp;gt;&amp;quot;&lt;br /&gt;
  &amp;quot;  &amp;lt;/view&amp;gt;&amp;quot;&lt;br /&gt;
  &amp;quot; &amp;lt;/item&amp;gt;&amp;quot;&lt;br /&gt;
  &amp;quot; &amp;lt;item&amp;gt;&amp;quot;&lt;br /&gt;
  &amp;quot;  &amp;lt;view class=\&amp;quot;vtkMRMLSliceNode\&amp;quot; singletontag=\&amp;quot;Red\&amp;quot;&amp;gt;&amp;quot;&lt;br /&gt;
  &amp;quot;   &amp;lt;property name=\&amp;quot;orientation\&amp;quot; action=\&amp;quot;default\&amp;quot;&amp;gt;Axial&amp;lt;/property&amp;gt;&amp;quot;&lt;br /&gt;
  &amp;quot;   &amp;lt;property name=\&amp;quot;viewlabel\&amp;quot; action=\&amp;quot;default\&amp;quot;&amp;gt;R&amp;lt;/property&amp;gt;&amp;quot;&lt;br /&gt;
  &amp;quot;   &amp;lt;property name=\&amp;quot;viewcolor\&amp;quot; action=\&amp;quot;default\&amp;quot;&amp;gt;#F34A33&amp;lt;/property&amp;gt;&amp;quot;&lt;br /&gt;
  &amp;quot;  &amp;lt;/view&amp;gt;&amp;quot;&lt;br /&gt;
  &amp;quot; &amp;lt;/item&amp;gt;&amp;quot;&lt;br /&gt;
  &amp;quot;&amp;lt;/layout&amp;gt;&amp;quot;)&lt;br /&gt;
  &lt;br /&gt;
customLayoutId=501&lt;br /&gt;
&lt;br /&gt;
layoutManager = slicer.app.layoutManager()&lt;br /&gt;
layoutManager.layoutLogic().GetLayoutNode().AddLayoutDescription(customLayoutId, customLayout)                                         &lt;br /&gt;
layoutManager.setLayout(customLayoutId)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
See description of standard layouts (that can be used as examples) here:&lt;br /&gt;
https://github.com/Slicer/Slicer/blob/master/Libs/MRML/Logic/vtkMRMLLayoutLogic.cxx&lt;br /&gt;
&lt;br /&gt;
== Disable certain user interactions in slice views ==&lt;br /&gt;
&lt;br /&gt;
For example, disable slice browsing using mouse wheel and keyboard shortcuts in the red slice viewer:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
interactorStyle = slicer.app.layoutManager().sliceWidget('Red').sliceView().sliceViewInteractorStyle()&lt;br /&gt;
interactorStyle.SetActionEnabled(interactorStyle.BrowseSlice, False)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Hide all slice view controllers:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
lm = slicer.app.layoutManager()&lt;br /&gt;
for sliceViewName in lm.sliceViewNames():&lt;br /&gt;
  lm.sliceWidget(sliceViewName).sliceController().setVisible(False)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Hide all 3D view controllers:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
lm = slicer.app.layoutManager()&lt;br /&gt;
for viewIndex in range(slicer.app.layoutManager().threeDViewCount):&lt;br /&gt;
  lm.threeDWidget(0).threeDController().setVisible(False)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Change default slice view orientation ==&lt;br /&gt;
&lt;br /&gt;
You can left-right &amp;quot;flip&amp;quot; slice view orientation presets (show patient left side on left/right side of the screen) by copy-pasting the script below to your [[Documentation/{{documentation/version}}/Developers/FAQ/Python_Scripting#How_to_systematically_execute_custom_python_code_at_startup_.3F| .slicerrc.py file]].&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Axial slice axes:&lt;br /&gt;
#  1 0 0&lt;br /&gt;
#  0 1 0&lt;br /&gt;
#  0 0 1&lt;br /&gt;
axialSliceToRas=vtk.vtkMatrix3x3()&lt;br /&gt;
&lt;br /&gt;
# Coronal slice axes:&lt;br /&gt;
#  1 0 0 &lt;br /&gt;
#  0 0 -1&lt;br /&gt;
#  0 1 0&lt;br /&gt;
coronalSliceToRas=vtk.vtkMatrix3x3()&lt;br /&gt;
coronalSliceToRas.SetElement(1,1, 0)&lt;br /&gt;
coronalSliceToRas.SetElement(1,2, -1)&lt;br /&gt;
coronalSliceToRas.SetElement(2,1, 1)&lt;br /&gt;
coronalSliceToRas.SetElement(2,2, 0)&lt;br /&gt;
&lt;br /&gt;
# Replace orientation presets in all existing slice nodes and in the default slice node&lt;br /&gt;
sliceNodes = slicer.util.getNodesByClass('vtkMRMLSliceNode')&lt;br /&gt;
sliceNodes.append(slicer.mrmlScene.GetDefaultNodeByClass('vtkMRMLSliceNode'))&lt;br /&gt;
for sliceNode in sliceNodes:&lt;br /&gt;
  orientationPresetName = sliceNode.GetOrientation()&lt;br /&gt;
  sliceNode.RemoveSliceOrientationPreset(&amp;quot;Axial&amp;quot;)&lt;br /&gt;
  sliceNode.AddSliceOrientationPreset(&amp;quot;Axial&amp;quot;, axialSliceToRas)&lt;br /&gt;
  sliceNode.RemoveSliceOrientationPreset(&amp;quot;Coronal&amp;quot;)&lt;br /&gt;
  sliceNode.AddSliceOrientationPreset(&amp;quot;Coronal&amp;quot;, coronalSliceToRas)&lt;br /&gt;
  sliceNode.SetOrientation(orientationPresetName)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Set up custom units in slice view ruler ==&lt;br /&gt;
&lt;br /&gt;
For microscopy or micro-CT images you may want to switch unit to micrometer instead of the default mm. To do that, 1. change the unit in Application settings / Units and 2. update ruler display settings using the script below (it can be copied to your Application startup script):&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
lm = slicer.app.layoutManager()&lt;br /&gt;
for sliceViewName in lm.sliceViewNames():&lt;br /&gt;
  sliceView = lm.sliceWidget(sliceViewName).sliceView()&lt;br /&gt;
  displayableManagerCollection = vtk.vtkCollection()&lt;br /&gt;
  sliceView.getDisplayableManagers(displayableManagerCollection)&lt;br /&gt;
  for dmIndex in xrange(displayableManagerCollection.GetNumberOfItems()):&lt;br /&gt;
    displayableManager = displayableManagerCollection.GetItemAsObject(dmIndex)&lt;br /&gt;
    if not displayableManager.IsA(&amp;quot;vtkMRMLRulerDisplayableManager&amp;quot;):&lt;br /&gt;
      continue&lt;br /&gt;
    displayableManager.RemoveAllRulerScalePresets()&lt;br /&gt;
    displayableManager.AddRulerScalePreset(   0.001, 5, 2, &amp;quot;nm&amp;quot;, 1000.0)&lt;br /&gt;
    displayableManager.AddRulerScalePreset(   0.010, 5, 2, &amp;quot;nm&amp;quot;, 1000.0)&lt;br /&gt;
    displayableManager.AddRulerScalePreset(   0.100, 5, 2, &amp;quot;nm&amp;quot;, 1000.0)&lt;br /&gt;
    displayableManager.AddRulerScalePreset(   0.500, 5, 1, &amp;quot;nm&amp;quot;, 1000.0)&lt;br /&gt;
    displayableManager.AddRulerScalePreset(   1.0,   5, 2, &amp;quot;um&amp;quot;,    1.0)&lt;br /&gt;
    displayableManager.AddRulerScalePreset(   5.0,   5, 1, &amp;quot;um&amp;quot;,    1.0)&lt;br /&gt;
    displayableManager.AddRulerScalePreset(  10.0,   5, 2, &amp;quot;um&amp;quot;,    1.0)&lt;br /&gt;
    displayableManager.AddRulerScalePreset(  50.0,   5, 1, &amp;quot;um&amp;quot;,    1.0)&lt;br /&gt;
    displayableManager.AddRulerScalePreset( 100.0,   5, 2, &amp;quot;um&amp;quot;,    1.0)&lt;br /&gt;
    displayableManager.AddRulerScalePreset( 500.0,   5, 1, &amp;quot;um&amp;quot;,    1.0)&lt;br /&gt;
    displayableManager.AddRulerScalePreset(1000.0,   5, 2, &amp;quot;mm&amp;quot;,    0.001)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Show a slice view outside the view layout ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sliceLayoutName = &amp;quot;TestSlice&amp;quot;&lt;br /&gt;
sliceLayoutLabel = &amp;quot;T&amp;quot;&lt;br /&gt;
# ownerNode manages this view instead of the layout manager (it can be any node in the scene)&lt;br /&gt;
viewOwnerNode = slicer.mrmlScene.AddNewNodeByClass(&amp;quot;vtkMRMLScriptedModuleNode&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
# Create MRML nodes&lt;br /&gt;
sliceNode = slicer.vtkMRMLSliceNode()&lt;br /&gt;
sliceNode.SetName(sliceLayoutName)&lt;br /&gt;
sliceNode.SetLayoutName(sliceLayoutName)&lt;br /&gt;
sliceNode.SetLayoutLabel(sliceLayoutLabel)&lt;br /&gt;
sliceNode.SetLayoutColor(1, 1, 0)&lt;br /&gt;
sliceNode.SetAndObserveParentLayoutNodeID(viewOwnerNode.GetID())&lt;br /&gt;
sliceNode = slicer.mrmlScene.AddNode(sliceNode)&lt;br /&gt;
sliceCompositeNode = slicer.mrmlScene.AddNewNodeByClass(&amp;quot;vtkMRMLSliceCompositeNode&amp;quot;)&lt;br /&gt;
sliceCompositeNode.SetLayoutName(sliceLayoutName)&lt;br /&gt;
&lt;br /&gt;
# Create widget&lt;br /&gt;
sliceWidget = slicer.qMRMLSliceWidget()&lt;br /&gt;
sliceWidget.sliceViewName = sliceLayoutName&lt;br /&gt;
sliceWidget.sliceViewLabel = sliceLayoutLabel&lt;br /&gt;
c = sliceNode.GetLayoutColor()&lt;br /&gt;
sliceWidget.sliceViewColor = qt.QColor.fromRgbF(c[0],c[1],c[2])&lt;br /&gt;
sliceWidget.setMRMLScene(slicer.mrmlScene)&lt;br /&gt;
sliceWidget.setMRMLSliceNode(sliceNode)&lt;br /&gt;
sliceWidget.show()&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Running an ITK filter in Python using SimpleITK ==&lt;br /&gt;
Open the &amp;quot;Sample Data&amp;quot; module and download &amp;quot;MR Head&amp;quot;, then paste the following snippet in Python interactor:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
import SimpleITK as sitk&lt;br /&gt;
import sitkUtils&lt;br /&gt;
inputImage = sitkUtils.PullFromSlicer('MRHead')&lt;br /&gt;
filter = sitk.SignedMaurerDistanceMapImageFilter()&lt;br /&gt;
outputImage = filter.Execute(inputImage)&lt;br /&gt;
sitkUtils.PushToSlicer(outputImage,'outputImage')&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
More information:&lt;br /&gt;
* See the SimpleITK documentation for SimpleITK examples: http://www.itk.org/SimpleITKDoxygen/html/examples.html&lt;br /&gt;
* sitkUtils in Slicer is used for pushing and pulling images from Slicer to SimpleITK: https://github.com/Slicer/Slicer/blob/master/Base/Python/sitkUtils.py&lt;br /&gt;
&lt;br /&gt;
== Get current mouse coordinates in a slice view ==&lt;br /&gt;
&lt;br /&gt;
You can get 3D (RAS) coordinates of the current mouse cursor from the crosshair singleton node as shown in the example below:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
def onMouseMoved(observer,eventid):  &lt;br /&gt;
  ras=[0,0,0]&lt;br /&gt;
  crosshairNode.GetCursorPositionRAS(ras)&lt;br /&gt;
  print(ras)&lt;br /&gt;
&lt;br /&gt;
crosshairNode=slicer.util.getNode('Crosshair') &lt;br /&gt;
crosshairNode.AddObserver(slicer.vtkMRMLCrosshairNode.CursorPositionModifiedEvent, onMouseMoved)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Get DataProbe text ==&lt;br /&gt;
&lt;br /&gt;
You can get the mouse location in pixel coordinates along with the pixel value at the mouse by hitting the '.' (period) key in a slice view after pasting in the following code.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
def printDataProbe():&lt;br /&gt;
  infoWidget = slicer.modules.DataProbeInstance.infoWidget&lt;br /&gt;
  for layer in ('B', 'F', 'L'):&lt;br /&gt;
    print(infoWidget.layerNames[layer].text, infoWidget.layerIJKs[layer].text, infoWidget.layerValues[layer].text)&lt;br /&gt;
&lt;br /&gt;
s = qt.QShortcut(qt.QKeySequence('.'), mainWindow())&lt;br /&gt;
s.connect('activated()', printDataProbe)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Thick slab reconstruction and maximum/minimum intensity volume projections ==&lt;br /&gt;
&lt;br /&gt;
Set up 'red' slice viewer to show thick slab reconstructed from 3 slices:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sliceNode = slicer.mrmlScene.GetNodeByID('vtkMRMLSliceNodeRed')&lt;br /&gt;
appLogic = slicer.app.applicationLogic()&lt;br /&gt;
sliceLogic = appLogic.GetSliceLogic(sliceNode)&lt;br /&gt;
sliceLayerLogic = sliceLogic.GetBackgroundLayer()&lt;br /&gt;
reslice = sliceLayerLogic.GetReslice()&lt;br /&gt;
reslice.SetSlabModeToMean()&lt;br /&gt;
reslice.SetSlabNumberOfSlices(10) # mean of 10 slices will computed&lt;br /&gt;
reslice.SetSlabSliceSpacingFraction(0.3) # spacing between each slice is 0.3 pixel (total 10 * 0.3 = 3 pixel neighborhood)&lt;br /&gt;
sliceNode.Modified()&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Set up 'red' slice viewer to show maximum intensity projection (MIP):&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sliceNode = slicer.mrmlScene.GetNodeByID('vtkMRMLSliceNodeRed')&lt;br /&gt;
appLogic = slicer.app.applicationLogic()&lt;br /&gt;
sliceLogic = appLogic.GetSliceLogic(sliceNode)&lt;br /&gt;
sliceLayerLogic = sliceLogic.GetBackgroundLayer()&lt;br /&gt;
reslice = sliceLayerLogic.GetReslice()&lt;br /&gt;
reslice.SetSlabModeToMax()&lt;br /&gt;
reslice.SetSlabNumberOfSlices(600) # use a large number of slices (600) to cover the entire volume&lt;br /&gt;
reslice.SetSlabSliceSpacingFraction(0.5) # spacing between slices are 0.5 pixel (supersampling is useful to reduce interpolation artifacts)&lt;br /&gt;
sliceNode.Modified()&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The projected image is available in a ''vtkImageData'' object by calling ''reslice.GetOutput()''.&lt;br /&gt;
&lt;br /&gt;
== Change default file type for nodes (that have never been saved yet) ==&lt;br /&gt;
Default node can be specified that will be used as a basis of all new storage nodes. This can be used for setting default file extension. For example, change file format to STL for model nodes:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
defaultModelStorageNode = slicer.vtkMRMLModelStorageNode()&lt;br /&gt;
defaultModelStorageNode.SetDefaultWriteFileExtension('stl')&lt;br /&gt;
slicer.mrmlScene.AddDefaultNode(defaultModelStorageNode)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To permanently change default file extension on your computer, copy-paste the code above into your application startup script (you can find its location in menu: Edit / Application settings / General / Application startup script).&lt;br /&gt;
&lt;br /&gt;
== Change file type for saving for all volumes (with already existing storage nodes) ==&lt;br /&gt;
&lt;br /&gt;
If it is not necessary to preserve file paths then the simplest is to configure default storage node (as shown in the example above), then delete all existing storage nodes. When save dialog is opened, default storage nodes will be recreated.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Delete existing model storage nodes so that they will be recreated with default settings&lt;br /&gt;
existingModelStorageNodes = slicer.util.getNodesByClass('vtkMRMLModelStorageNode')&lt;br /&gt;
for modelStorageNode in existingModelStorageNodes:&lt;br /&gt;
  slicer.mrmlScene.RemoveNode(modelStorageNode)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To update existing storage nodes to use new file extension (but keep all other parameters unchanged) you can use this approach (example is for volume storage):&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
requiredFileExtension = '.nia'&lt;br /&gt;
originalFileExtension = '.nrrd'&lt;br /&gt;
volumeNodes = slicer.util.getNodesByClass('vtkMRMLScalarVolumeNode')&lt;br /&gt;
for volumeNode in volumeNodes:&lt;br /&gt;
  volumeStorageNode = volumeNode.GetStorageNode()&lt;br /&gt;
  if not volumeStorageNode:&lt;br /&gt;
    volumeNode.AddDefaultStorageNode()&lt;br /&gt;
    volumeStorageNode = volumeNode.GetStorageNode()&lt;br /&gt;
    volumeStorageNode.SetFileName(volumeNode.GetName()+requiredFileExtension)&lt;br /&gt;
  else:&lt;br /&gt;
    volumeStorageNode.SetFileName(volumeStorageNode.GetFileName().replace(originalFileExtension, requiredFileExtension))&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Segmentations ==&lt;br /&gt;
&lt;br /&gt;
=== Create a segmentation from a labelmap volume and display in 3D ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
labelmapVolumeNode = getNode('label')&lt;br /&gt;
seg = slicer.mrmlScene.AddNewNodeByClass('vtkMRMLSegmentationNode')&lt;br /&gt;
slicer.modules.segmentations.logic().ImportLabelmapToSegmentationNode(labelmapVolumeNode, seg)&lt;br /&gt;
seg.CreateClosedSurfaceRepresentation()&lt;br /&gt;
slicer.mrmlScene.RemoveNode(labelmapVolumeNode)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The last line is optional. It removes the original labelmap volume so that the same information is not shown twice.&lt;br /&gt;
&lt;br /&gt;
=== Export labelmap node from segmentation node ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
seg = getNode('Segmentation')&lt;br /&gt;
labelmapVolumeNode = slicer.mrmlScene.AddNewNodeByClass('vtkMRMLLabelMapVolumeNode')&lt;br /&gt;
slicer.modules.segmentations.logic().ExportAllSegmentsToLabelmapNode(seg, labelmapVolumeNode)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Show a segmentation in 3D ===&lt;br /&gt;
Segmentation can only be shown in 3D if closed surface representation (or other 3D-displayable representation) is available. To create closed surface representation:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
segmentation.CreateClosedSurfaceRepresentation()&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Get a representation of a segment ===&lt;br /&gt;
Access binary labelmap stored in a segmentation node (without exporting it to a volume node) - if it does not exist, it will return None:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
image = segmentationNode.GetBinaryLabelmapRepresentation(segmentID)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Get closed surface, if it does not exist, it will return None:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
polydata = segmentationNode.GetClosedSurfaceRepresentation(segmentID)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Get binary labelmap representation. If it does not exist then it will be created for that single segment. Applies parent transforms by default (if not desired, another argument needs to be added to the end: false):&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
import vtkSegmentationCorePython as vtkSegmentationCore&lt;br /&gt;
outputOrientedImageData = vtkSegmentationCore.vtkOrientedImageData()&lt;br /&gt;
slicer.vtkSlicerSegmentationsModuleLogic.GetSegmentBinaryLabelmapRepresentation(segmentationNode, segmentID, outputOrientedImageData)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Same as above, for closed surface representation:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
outputPolyData = vtk.vtkPolyData()&lt;br /&gt;
slicer.vtkSlicerSegmentationsModuleLogic.GetSegmentClosedSurfaceRepresentation(segmentationNode, segmentID, outputPolyData)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Convert all segments using default path and conversion parameters ===&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
segmentationNode.CreateBinaryLabelmapRepresentation()&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Convert all segments using custom path or conversion parameters ===&lt;br /&gt;
Change reference image geometry parameter based on an existing referenceImageData image:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
import vtkSegmentationCorePython as vtkSegmentationCore&lt;br /&gt;
referenceGeometry = vtkSegmentationCore.vtkSegmentationConverter.SerializeImageGeometry(referenceImageData)&lt;br /&gt;
segmentation.SetConversionParameter(vtkSegmentationCore.vtkSegmentationConverter.GetReferenceImageGeometryParameterName(), referenceGeometry)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Re-convert using a modified conversion parameter ===&lt;br /&gt;
Changing smoothing factor for closed surface generation:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
import vtkSegmentationCorePython as vtkSegmentationCore&lt;br /&gt;
segmentation = getNode('Segmentation').GetSegmentation()&lt;br /&gt;
&lt;br /&gt;
# Turn of surface smoothing&lt;br /&gt;
segmentation.SetConversionParameter('Smoothing factor','0.0')&lt;br /&gt;
&lt;br /&gt;
# Recreate representation using modified parameters (and default conversion path)&lt;br /&gt;
segmentation.RemoveRepresentation(vtkSegmentationCore.vtkSegmentationConverter.GetSegmentationClosedSurfaceRepresentationName())&lt;br /&gt;
segmentation.CreateRepresentation(vtkSegmentationCore.vtkSegmentationConverter.GetSegmentationClosedSurfaceRepresentationName())&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== How to run segment editor effects from a script ===&lt;br /&gt;
&lt;br /&gt;
Editor effects are complex because they need to handle changing master volumes, undo/redo, masking operations, etc. Therefore, instead of using a segment editor effect, it is simpler to run the underlying filters directly from script.&lt;br /&gt;
&lt;br /&gt;
This example demonstrates how to use Segment editor effects (without GUI, using qMRMLSegmentEditorWidget):&lt;br /&gt;
&lt;br /&gt;
* [https://gist.github.com/lassoan/2d5a5b73645f65a5eb6f8d5f97abf31b brain tumor segmentation using grow from seeds effect]&lt;br /&gt;
* [https://gist.github.com/lassoan/1673b25d8e7913cbc245b4f09ed853f9 skin surface extraction using thresholding and smoothing]&lt;br /&gt;
* [https://gist.github.com/lassoan/2f5071c562108dac8efe277c78f2620f mask a volume with segments and compute histogram for each region]&lt;br /&gt;
&lt;br /&gt;
This example shows how to perform operations on segmentations using VTK filters:&lt;br /&gt;
* [https://gist.github.com/lassoan/7c94c334653010696b2bf96abc0ac8e7 brain tumor segmentation using grow from seeds effect]&lt;br /&gt;
&lt;br /&gt;
== Accessing views, renderers, and cameras ==&lt;br /&gt;
&lt;br /&gt;
Iterate through all 3D views in current layout:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
layoutManager = slicer.app.layoutManager()&lt;br /&gt;
for threeDViewIndex in range(layoutManager.threeDViewCount) :&lt;br /&gt;
  view = layoutManager.threeDWidget(threeDViewIndex).threeDView()&lt;br /&gt;
  threeDViewNode = view.mrmlViewNode()&lt;br /&gt;
  cameraNode = slicer.modules.cameras.logic().GetViewActiveCameraNode(threeDViewNode)&lt;br /&gt;
  print('View node for 3D widget ' + str(threeDViewIndex))&lt;br /&gt;
  print('  Name: ' + threeDViewNode .GetName())&lt;br /&gt;
  print('  ID: ' + threeDViewNode .GetID())&lt;br /&gt;
  print('  Camera ID: ' + cameraNode.GetID())&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Iterate through all slice views in current layout:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
layoutManager = slicer.app.layoutManager()&lt;br /&gt;
for sliceViewName in layoutManager.sliceViewNames():&lt;br /&gt;
  view = layoutManager.sliceWidget(sliceViewName).sliceView()&lt;br /&gt;
  sliceNode = view.mrmlSliceNode()&lt;br /&gt;
  sliceLogic = slicer.app.applicationLogic().GetSliceLogic(sliceNode)&lt;br /&gt;
  compositeNode = sliceLogic.GetSliceCompositeNode()&lt;br /&gt;
  print('Slice view ' + str(sliceViewName))&lt;br /&gt;
  print('  Name: ' + sliceNode.GetName())&lt;br /&gt;
  print('  ID: ' + sliceNode.GetID())&lt;br /&gt;
  print('  Background volume: {0}'.format(compositeNode.GetBackgroundVolumeID()))&lt;br /&gt;
  print('  Foreground volume: {0} (opacity: {1})'.format(compositeNode.GetForegroundVolumeID(), compositeNode.GetForegroundOpacity()))&lt;br /&gt;
  print('  Label volume: {0} (opacity: {1})'.format(compositeNode.GetLabelVolumeID(), compositeNode.GetLabelOpacity()))&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
For low-level manipulation of views, it is possible to access VTK render windows, renderers and cameras of views in the current layout.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
renderWindow = view.renderWindow()&lt;br /&gt;
renderers = renderWindow.GetRenderers()&lt;br /&gt;
renderer = renderers.GetItemAsObject(0)&lt;br /&gt;
camera = cameraNode.GetCamera()&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Change 3D view background color ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
renderWindow = slicer.app.layoutManager().threeDWidget(0).threeDView().renderWindow()&lt;br /&gt;
renderer = renderWindow.GetRenderers().GetFirstRenderer()&lt;br /&gt;
renderer.SetBackground(1,0,0)&lt;br /&gt;
renderer.SetBackground2(1,0,0)&lt;br /&gt;
renderWindow.Render()&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Subject hierarchy == &lt;br /&gt;
==== Get the pseudo-singleton subject hierarchy node ====&lt;br /&gt;
It manages the whole hierarchy and provides functions to access and manipulate&lt;br /&gt;
  shNode = slicer.vtkMRMLSubjectHierarchyNode.GetSubjectHierarchyNode(slicer.mrmlScene)&lt;br /&gt;
&lt;br /&gt;
==== Create subject hierarchy item ====&lt;br /&gt;
  # If it is for a data node, it is automatically created, but the create function can be used to set parent:&lt;br /&gt;
  shNode.CreateItem(parentItemID, dataNode)&lt;br /&gt;
  # If it is a hierarchy item without a data node, then the create function must be used:&lt;br /&gt;
  shNode.CreateSubjectItem(parentItemID, name)&lt;br /&gt;
  shNode.CreateFolderItem(parentItemID, name)&lt;br /&gt;
  shNode.CreateHierarchyItem(parentItemID, name, level) # Advanced method to set level attribute manually (usually subject, study, or folder, but it can be a virtual branch for example)&lt;br /&gt;
&lt;br /&gt;
==== Get subject hierarchy item ====&lt;br /&gt;
Items in subject hierarchy are uniquely identified by integer IDs&lt;br /&gt;
  # Get scene item ID first because it is the root item:&lt;br /&gt;
  sceneItemID = shNode.GetSceneItemID()&lt;br /&gt;
  # Get direct child by name&lt;br /&gt;
  subjectItemID = shNode.GetItemChildWithName(sceneItemID, 'Subject_1')&lt;br /&gt;
  # Get item for data node&lt;br /&gt;
  itemID = shNode.GetItemByDataNode(dataNode)&lt;br /&gt;
  # Get item by UID (such as DICOM)&lt;br /&gt;
  itemID = shNode.GetItemByUID(slicer.vtkMRMLSubjectHierarchyConstants.GetDICOMUIDName(), seriesInstanceUid)&lt;br /&gt;
  itemID = shNode.GetItemByUIDList(slicer.vtkMRMLSubjectHierarchyConstants.GetDICOMInstanceUIDName(), instanceUID)&lt;br /&gt;
  # Invalid item ID for checking validity of a given ID (most functions return the invalid ID when item is not found)&lt;br /&gt;
  invalidItemID = slicer.vtkMRMLSubjectHierarchyNode.GetInvalidItemID()&lt;br /&gt;
&lt;br /&gt;
==== Traverse children of a subject hierarchy item ====&lt;br /&gt;
  children = vtk.vtkIdList()&lt;br /&gt;
  shNode.GetItemChildren(parent, children)&lt;br /&gt;
  for i in xrange(children.GetNumberOfIds()):&lt;br /&gt;
    child = children.GetId(i)&lt;br /&gt;
    ...&lt;br /&gt;
&lt;br /&gt;
==== Manipulate subject hierarchy item ====&lt;br /&gt;
Instead of node operations on the individual subject hierarchy nodes, item operations are performed on the one subject hierarchy node.&lt;br /&gt;
  # Set item name&lt;br /&gt;
  shNode.SetItemName(itemID, 'NewName')&lt;br /&gt;
  # Set item parent (reparent)&lt;br /&gt;
  shNode.SetItemParent(itemID, newParentItemID)&lt;br /&gt;
  # Set visibility of data nodes associated to items in a branch (or a leaf item)&lt;br /&gt;
  shNode.SetDisplayVisibilityForBranch(itemID, 1)&lt;br /&gt;
&lt;br /&gt;
==== Filter items in TreeView or ComboBox ====&lt;br /&gt;
Displayed items can be filtered using ''setAttributeFilter'' method. An example of the usage can be found in the  [https://github.com/Slicer/Slicer/blob/e66e3b08e35384526528e6ae678e9ec9f079f286/Applications/SlicerApp/Testing/Python/SubjectHierarchyGenericSelfTest.py#L352-L360 unit test]. Modified version here:&lt;br /&gt;
    print shTreeView.displayedItemCount() # 5&lt;br /&gt;
    shTreeView.setAttributeFilter('DICOM.Modality') # Nodes must have this attribute&lt;br /&gt;
    print shTreeView.displayedItemCount() # 3&lt;br /&gt;
    shTreeView.setAttributeFilter('DICOM.Modality','CT') # Have attribute and equal 'CT'&lt;br /&gt;
    print shTreeView.displayedItemCount() # 1&lt;br /&gt;
    shTreeView.removeAttributeFilter()&lt;br /&gt;
    print shTreeView.displayedItemCount() # 5&lt;br /&gt;
&lt;br /&gt;
== Plotting ==&lt;br /&gt;
&lt;br /&gt;
=== Create histogram plot of a volume ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Get a volume from SampleData&lt;br /&gt;
import SampleData&lt;br /&gt;
volumeNode = SampleData.SampleDataLogic().downloadMRHead()&lt;br /&gt;
&lt;br /&gt;
# Compute histogram values&lt;br /&gt;
import numpy as np&lt;br /&gt;
histogram = np.histogram(arrayFromVolume(volumeNode), bins=50)&lt;br /&gt;
&lt;br /&gt;
# Save results to a new table node&lt;br /&gt;
tableNode=slicer.mrmlScene.AddNewNodeByClass(&amp;quot;vtkMRMLTableNode&amp;quot;)&lt;br /&gt;
updateTableFromArray(tableNode, histogram)&lt;br /&gt;
tableNode.GetTable().GetColumn(0).SetName(&amp;quot;Count&amp;quot;)&lt;br /&gt;
tableNode.GetTable().GetColumn(1).SetName(&amp;quot;Intensity&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
# Create plot&lt;br /&gt;
plotSeriesNode = slicer.mrmlScene.AddNewNodeByClass(&amp;quot;vtkMRMLPlotSeriesNode&amp;quot;, volumeNode.GetName() + ' histogram')&lt;br /&gt;
plotSeriesNode.SetAndObserveTableNodeID(tableNode.GetID())&lt;br /&gt;
plotSeriesNode.SetXColumnName(&amp;quot;Intensity&amp;quot;)&lt;br /&gt;
plotSeriesNode.SetYColumnName(&amp;quot;Count&amp;quot;)&lt;br /&gt;
plotSeriesNode.SetPlotType(plotSeriesNode.PlotTypeScatterBar)&lt;br /&gt;
plotSeriesNode.SetColor(0, 0.6, 1.0)&lt;br /&gt;
&lt;br /&gt;
# Create chart and add plot&lt;br /&gt;
plotChartNode = slicer.mrmlScene.AddNewNodeByClass(&amp;quot;vtkMRMLPlotChartNode&amp;quot;)&lt;br /&gt;
plotChartNode.AddAndObservePlotSeriesNodeID(plotSeriesNode.GetID())&lt;br /&gt;
plotChartNode.YAxisRangeAutoOff()&lt;br /&gt;
plotChartNode.SetYAxisRange(0, 500000)&lt;br /&gt;
&lt;br /&gt;
# Show plot in layout&lt;br /&gt;
slicer.modules.plots.logic().ShowChartInLayout(plotChartNode)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Execute external applications ==&lt;br /&gt;
&lt;br /&gt;
How to run external applications from Slicer.&lt;br /&gt;
&lt;br /&gt;
=== Run process in default environment ===&lt;br /&gt;
&lt;br /&gt;
When a process is launched from Slicer then by default Slicer's ITK, VTK, Qt, etc. libraries are used. If an external application has its own version of these libraries, then the application is expected to crash. To prevent crashing, the application must be run in the environment where Slicer started up (without all Slicer-specific library paths). This startup environment can be retrieved using ''slicer.util.startupEnvironment()''.&lt;br /&gt;
&lt;br /&gt;
Example: run Python3 script from Slicer:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
command_to_execute = [&amp;quot;/usr/bin/python3&amp;quot;, &amp;quot;-c&amp;quot;, &amp;quot;print('hola')&amp;quot;]&lt;br /&gt;
from subprocess import check_output&lt;br /&gt;
check_output(&lt;br /&gt;
  command_to_execute, &lt;br /&gt;
  env=slicer.util.startupEnvironment()&lt;br /&gt;
  )&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
will output:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
'hola\n'&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
On some systems, ''shell=True'' must be specified as well.&lt;/div&gt;</summary>
		<author><name>Inorton</name></author>
		
	</entry>
	<entry>
		<id>https://www.slicer.org/w/index.php?title=Documentation/Nightly/Modules/FiberBundleLabelSelect&amp;diff=58888</id>
		<title>Documentation/Nightly/Modules/FiberBundleLabelSelect</title>
		<link rel="alternate" type="text/html" href="https://www.slicer.org/w/index.php?title=Documentation/Nightly/Modules/FiberBundleLabelSelect&amp;diff=58888"/>
		<updated>2018-04-10T18:27:34Z</updated>

		<summary type="html">&lt;p&gt;Inorton: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;noinclude&amp;gt;{{documentation/versioncheck}}&amp;lt;/noinclude&amp;gt;&lt;br /&gt;
&amp;lt;!-- ---------------------------- --&amp;gt;&lt;br /&gt;
{{documentation/{{documentation/version}}/module-header}}&lt;br /&gt;
&amp;lt;!-- ---------------------------- --&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- ---------------------------- --&amp;gt;&lt;br /&gt;
{{documentation/{{documentation/version}}/module-section|Introduction and Acknowledgements}}&lt;br /&gt;
{{documentation/{{documentation/version}}/module-introduction-start|{{documentation/modulename}}}}&lt;br /&gt;
{{documentation/{{documentation/version}}/module-introduction-row}}&lt;br /&gt;
&lt;br /&gt;
{{documentation/{{documentation/version}}/module-acknowledgements}}&lt;br /&gt;
Contact:  &amp;lt;email&amp;gt;slicer-users@bwh.harvard.edu&amp;lt;/email&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
Website: http://slicerdmri.github.io/&lt;br /&gt;
&lt;br /&gt;
{{documentation/{{documentation/version}}/module-introduction-row}}&lt;br /&gt;
{{documentation/{{documentation/version}}/module-introduction-logo-gallery&lt;br /&gt;
|Image:SlicerDMRIScreenshot.jpg|SlicerDMRI&lt;br /&gt;
|Image:Logo-splnew.jpg|Surgical Planning Laboratory&lt;br /&gt;
|Image:NAC-logo.png|NAC&lt;br /&gt;
|Image:Wholebraintractography.png|Whole brain tractography&lt;br /&gt;
|Image:CCSelectedTracts.png|Corpus callosum (CC) tract selection&lt;br /&gt;
}}&lt;br /&gt;
{{documentation/{{documentation/version}}/module-introduction-end}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- ---------------------------- --&amp;gt;&lt;br /&gt;
{{documentation/{{documentation/version}}/module-section|Module Description}}&lt;br /&gt;
{{documentation/{{documentation/version}}/module-description}}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- ---------------------------- --&amp;gt;&lt;br /&gt;
{{documentation/{{documentation/version}}/module-section|Use Cases}}&lt;br /&gt;
Most frequently used for these scenarios:&lt;br /&gt;
&lt;br /&gt;
* Use Case 1: Filter out a subset of DTI fiber tracts which are passing through selected region(s) defined in the label map volume.&lt;br /&gt;
* Use Case 2: Filter out a subset of DTI fiber tracts which are NOT passing through selected region(s) defined in the label map volume.&lt;br /&gt;
* Use Case 3: A combination of Case 1 and Case 2.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- ---------------------------- --&amp;gt;&lt;br /&gt;
{{documentation/{{documentation/version}}/module-section|Tutorials}}&lt;br /&gt;
Links to tutorials that use this module&lt;br /&gt;
* Slicer4 Fiber Bundle Selection and Scalar Measurements Tutorial: https://www.slicer.org/slicerWiki/index.php/Documentation/4.5/Training#Fiber_Bundle_Selection_and_Scalar_Measurements&lt;br /&gt;
* Tractography selection and measurements in command line interface (CLI) mode: http://dmri.slicer.org/tutorials/tractography_measurement&lt;br /&gt;
&amp;lt;!-- ---------------------------- --&amp;gt;&lt;br /&gt;
{{documentation/{{documentation/version}}/module-section|Panels and their use}}&lt;br /&gt;
&lt;br /&gt;
{{documentation/{{documentation/version}}/module-parametersdescription}}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- ---------------------------- --&amp;gt;&lt;br /&gt;
{{documentation/{{documentation/version}}/module-section|Similar Modules}}&lt;br /&gt;
* Tractography Label Map Seeding&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- ---------------------------- --&amp;gt;&lt;br /&gt;
{{documentation/{{documentation/version}}/module-section|References}}&lt;br /&gt;
*  http://slicerdmri.github.io/&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- ---------------------------- --&amp;gt;&lt;br /&gt;
{{documentation/{{documentation/version}}/module-section|Information for Developers}}&lt;br /&gt;
* https://github.com/SlicerDMRI&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- ---------------------------- --&amp;gt;&lt;br /&gt;
{{documentation/{{documentation/version}}/module-footer}}&lt;br /&gt;
&amp;lt;!-- ---------------------------- --&amp;gt;&lt;/div&gt;</summary>
		<author><name>Inorton</name></author>
		
	</entry>
	<entry>
		<id>https://www.slicer.org/w/index.php?title=Documentation/Nightly/Modules/Seeding&amp;diff=58887</id>
		<title>Documentation/Nightly/Modules/Seeding</title>
		<link rel="alternate" type="text/html" href="https://www.slicer.org/w/index.php?title=Documentation/Nightly/Modules/Seeding&amp;diff=58887"/>
		<updated>2018-04-10T18:19:16Z</updated>

		<summary type="html">&lt;p&gt;Inorton: Redirected page to Documentation/Nightly/Modules/TractographyLabelMapSeeding&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;#REDIRECT [[Documentation/Nightly/Modules/TractographyLabelMapSeeding]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;noinclude&amp;gt;{{documentation/versioncheck}}&amp;lt;/noinclude&amp;gt;&lt;/div&gt;</summary>
		<author><name>Inorton</name></author>
		
	</entry>
	<entry>
		<id>https://www.slicer.org/w/index.php?title=Documentation/Nightly/Modules/Seeding&amp;diff=58886</id>
		<title>Documentation/Nightly/Modules/Seeding</title>
		<link rel="alternate" type="text/html" href="https://www.slicer.org/w/index.php?title=Documentation/Nightly/Modules/Seeding&amp;diff=58886"/>
		<updated>2018-04-10T18:18:45Z</updated>

		<summary type="html">&lt;p&gt;Inorton: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;noinclude&amp;gt;{{documentation/versioncheck}}&amp;lt;/noinclude&amp;gt;&lt;br /&gt;
&lt;br /&gt;
#REDIRECT [[Documentation/Nightly/Modules/TractographyLabelMapSeeding]]&lt;/div&gt;</summary>
		<author><name>Inorton</name></author>
		
	</entry>
	<entry>
		<id>https://www.slicer.org/w/index.php?title=Documentation/Nightly/Modules/FiberBundleLabelSelect&amp;diff=58885</id>
		<title>Documentation/Nightly/Modules/FiberBundleLabelSelect</title>
		<link rel="alternate" type="text/html" href="https://www.slicer.org/w/index.php?title=Documentation/Nightly/Modules/FiberBundleLabelSelect&amp;diff=58885"/>
		<updated>2018-04-10T17:32:10Z</updated>

		<summary type="html">&lt;p&gt;Inorton: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;noinclude&amp;gt;{{documentation/versioncheck}}&amp;lt;/noinclude&amp;gt;&lt;br /&gt;
&amp;lt;!-- ---------------------------- --&amp;gt;&lt;br /&gt;
{{documentation/{{documentation/version}}/module-header}}&lt;br /&gt;
&amp;lt;!-- ---------------------------- --&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- ---------------------------- --&amp;gt;&lt;br /&gt;
{{documentation/{{documentation/version}}/module-section|Introduction and Acknowledgements}}&lt;br /&gt;
{{documentation/{{documentation/version}}/module-introduction-start|{{documentation/modulename}}}}&lt;br /&gt;
{{documentation/{{documentation/version}}/module-introduction-row}}&lt;br /&gt;
&lt;br /&gt;
{{documentation/{{documentation/version}}/module-acknowledgements}}&lt;br /&gt;
Contact:  &amp;lt;email&amp;gt;slicer-users@bwh.harvard.edu&amp;lt;/email&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
Website: http://slicerdmri.github.io/&lt;br /&gt;
&lt;br /&gt;
{{documentation/{{documentation/version}}/module-introduction-row}}&lt;br /&gt;
{{documentation/{{documentation/version}}/module-introduction-logo-gallery&lt;br /&gt;
|Image:SlicerDMRIScreenshot.jpg|SlicerDMRI&lt;br /&gt;
|Image:Logo-splnew.jpg|Surgical Planning Laboratory&lt;br /&gt;
|Image:NAC-logo.png|NAC&lt;br /&gt;
|Image:Wholebraintractography.png|Whole brain tractography&lt;br /&gt;
|Image:CCSelectedTracts.png|Corpus callosum (CC) tract selection&lt;br /&gt;
}}&lt;br /&gt;
{{documentation/{{documentation/version}}/module-introduction-end}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- ---------------------------- --&amp;gt;&lt;br /&gt;
{{documentation/{{documentation/version}}/module-section|Module Description}}&lt;br /&gt;
{{documentation/{{documentation/version}}/module-description}}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- ---------------------------- --&amp;gt;&lt;br /&gt;
{{documentation/{{documentation/version}}/module-section|Use Cases}}&lt;br /&gt;
Most frequently used for these scenarios:&lt;br /&gt;
&lt;br /&gt;
* Use Case 1: Filter out a subset of DTI fiber tracts which are passing through selected region(s) defined in the label map volume.&lt;br /&gt;
* Use Case 2: Filter out a subset of DTI fiber tracts which are NOT passing through selected region(s) defined in the label map volume.&lt;br /&gt;
* Use Case 3: A combination of Case 1 and Case 2.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- ---------------------------- --&amp;gt;&lt;br /&gt;
{{documentation/{{documentation/version}}/module-section|Tutorials}}&lt;br /&gt;
Links to tutorials that use this module&lt;br /&gt;
* Slicer4 Fiber Bundle Selection and Scalar Measurements Tutorial: https://www.slicer.org/slicerWiki/index.php/Documentation/4.5/Training#Fiber_Bundle_Selection_and_Scalar_Measurements&lt;br /&gt;
* Tractography selection and measurements in command line interface (CLI) mode: http://dmri.slicer.org/tutorials/cli_measurements&lt;br /&gt;
&amp;lt;!-- ---------------------------- --&amp;gt;&lt;br /&gt;
{{documentation/{{documentation/version}}/module-section|Panels and their use}}&lt;br /&gt;
&lt;br /&gt;
{{documentation/{{documentation/version}}/module-parametersdescription}}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- ---------------------------- --&amp;gt;&lt;br /&gt;
{{documentation/{{documentation/version}}/module-section|Similar Modules}}&lt;br /&gt;
* Tractography Label Map Seeding&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- ---------------------------- --&amp;gt;&lt;br /&gt;
{{documentation/{{documentation/version}}/module-section|References}}&lt;br /&gt;
*  http://slicerdmri.github.io/&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- ---------------------------- --&amp;gt;&lt;br /&gt;
{{documentation/{{documentation/version}}/module-section|Information for Developers}}&lt;br /&gt;
* https://github.com/SlicerDMRI&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- ---------------------------- --&amp;gt;&lt;br /&gt;
{{documentation/{{documentation/version}}/module-footer}}&lt;br /&gt;
&amp;lt;!-- ---------------------------- --&amp;gt;&lt;/div&gt;</summary>
		<author><name>Inorton</name></author>
		
	</entry>
	<entry>
		<id>https://www.slicer.org/w/index.php?title=Documentation/Nightly/Developers/Factory&amp;diff=57182</id>
		<title>Documentation/Nightly/Developers/Factory</title>
		<link rel="alternate" type="text/html" href="https://www.slicer.org/w/index.php?title=Documentation/Nightly/Developers/Factory&amp;diff=57182"/>
		<updated>2017-11-01T12:20:30Z</updated>

		<summary type="html">&lt;p&gt;Inorton: /* Overview */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;noinclude&amp;gt;{{documentation/versioncheck}}&amp;lt;/noinclude&amp;gt;&lt;br /&gt;
=Overview=&lt;br /&gt;
&lt;br /&gt;
The Slicer factory machine is maintained by [http://www.kitware.com Kitware] and produces dashboard builds of many software projects, including nightly, continuous, and packaged versions of Slicer and its approved extensions.  See the [http://slicer.cdash.org/index.php?project=Slicer4 Slicer4 dashboard].&lt;br /&gt;
&lt;br /&gt;
These builds are generated every day on three different operating systems: Windows 7, Mac OS X, and Linux.  Because it is not legal to run any version of Mac OS X on a virtual machine (unless its host also runs Mac OS X), the host OS is Mac OS X, and the Windows and Linux builds are run within this machine as virtual machines.&lt;br /&gt;
&lt;br /&gt;
'''Dashboard build scripts are located on GitHub: https://github.com/Slicer/DashboardScripts'''&lt;br /&gt;
&lt;br /&gt;
==Required factory components==&lt;br /&gt;
&lt;br /&gt;
See [[Documentation/{{documentation/version}}/Developers/Tutorials/DashboardSetup|dashboard prerequisites]].&lt;br /&gt;
&lt;br /&gt;
=Host(s)=&lt;br /&gt;
&lt;br /&gt;
== factory.kitware ==&lt;br /&gt;
&lt;br /&gt;
=== Software ===&lt;br /&gt;
The factory machine runs Mac OS X v10.6.8, Snow Leopard.  &lt;br /&gt;
* CMake version: 3.9.0 (before 2017/07/04 was 3.5.0-rc3 with [https://github.com/Kitware/CMake/compare/master...jcfr:osx-framework this patch])&lt;br /&gt;
** Since CMake release &amp;gt;= 3.6 is compiled only for  &amp;gt;= 10.7, a custom build of cmake was done with &amp;lt;code&amp;gt;-DCMAKE_INSTALL_PREFIX:PATH=/Users/kitware/Dashboards/Support/CMake-3.9.0.app/Contents&amp;lt;/code&amp;gt;  &lt;br /&gt;
* Compiler llvm-3.1. Note that the default compiled shipped with XCode 4.2 is not used. See [http://slicer-devel.65872.n3.nabble.com/MacOSX-factory-build-Transitioning-from-hybrid-quot-llvm-g-quot-to-quot-clang-quot-Update-to-Qt-4-8-6-tt4032198.html#a4032199 here] for more details.&lt;br /&gt;
* Tasks scheduled using [http://en.wikipedia.org/wiki/Cron cron]&lt;br /&gt;
&lt;br /&gt;
* Nightly generation of HomebrewCasks: [[Documentation/Nightly/Developers/Factory/HomeBrewInstall|Installation aborted]] (newer system is required for &amp;lt;tt&amp;gt;homebrew/cask-repair&amp;lt;/tt&amp;gt;).&lt;br /&gt;
&lt;br /&gt;
Remote access: Via SSH or VNC from Kitware internal network (192.168.113.230).&lt;br /&gt;
&amp;lt;!--&lt;br /&gt;
The output of &amp;lt;pre&amp;gt;crontab -l&amp;lt;/pre&amp;gt; on the factory machine is as follows:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
55 23 * * * cd /Users/kitware/DashboardScripts &amp;amp;&amp;amp; /usr/bin/cvs -q up -dAP&lt;br /&gt;
0 0 * * * /Users/kitware/DashboardScripts/factory.sh &amp;gt; /Users/kitware/Dashboards/Logs/factory.log 2&amp;gt;&amp;amp;1&lt;br /&gt;
0 9 * * * /Applications/CMake\ 2.8-8.app/Contents/bin/ctest -V -VV -S /Users/kitware/DashboardScripts/factory-64bits_CTKAppLauncher_release_continuous.cmake &amp;gt; /Users/kitware/Dashboards/Logs/factory-64bits_CTKAppLauncher_release_continuous.log 2&amp;gt;&amp;amp;1&lt;br /&gt;
0 9 * * * /Applications/CMake\ 2.8-8.app/Contents/bin/ctest -V -VV -S /Users/kitware/DashboardScripts/factory-64bits_slicer4_release_continuous.cmake &amp;gt; /Users/kitware/Dashboards/Logs/factory-64bits_slicer4_release_continuous.log 2&amp;gt;&amp;amp;1&lt;br /&gt;
0 10 * * * /Applications/CMake\ 2.8-8.app/Contents/bin/ctest -V -VV -S /Users/kitware/DashboardScripts/factory-64bits_slicerextensions_release_continuous.cmake &amp;gt; /Users/kitware/Dashboards/Logs/factory-64bits_slicerextensions_release_continuous.log 2&amp;gt;&amp;amp;1&lt;br /&gt;
0 10 * * * /Applications/CMake\ 2.8-8.app/Contents/bin/ctest -V -VV -S /Users/kitware/DashboardScripts/factory-64bits_slicerextensions_411_release_continuous.cmake &amp;gt; /Users/kitware/Dashboards/Logs/factory-64bits_slicerextensions_411_release_continuous.log 2&amp;gt;&amp;amp;1&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The first tab is a command to update the cvs repository storing all of Kitware's dashboard scripts.  The second is a bash script which runs all of the nightly builds done by the Mac OS X factory.  The rest correspond to all the continuous builds.  An example of an entry in the bash script is as follows:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
open -a x11&lt;br /&gt;
export DISPLAY=:0.0 # just DISPLAY=:0.0 without export is not enough&lt;br /&gt;
export PATH=:/usr/local/git/bin:$PATH&lt;br /&gt;
&lt;br /&gt;
CTEST=/Applications/CMake-3.5.0-rc3.app/Contents/bin/ctest&lt;br /&gt;
LOG_DIR=/Users/kitware/Dashboards/Logs&lt;br /&gt;
DASHBOARD_SCRIPTS_DIR=/Users/kitware/DashboardScripts&lt;br /&gt;
&lt;br /&gt;
# Nightly build of CTKAppLauncher&lt;br /&gt;
&amp;quot;$CTEST&amp;quot; -S $DASHBOARD_SCRIPTS_DIR/factory-64bits_CTKAppLauncher_release_nightly.cmake -VV -O $LOG_DIR/factory-64bits_CTKAppLauncher_release_nightly.log&lt;br /&gt;
&lt;br /&gt;
# Nightly build of slicer&lt;br /&gt;
&amp;quot;$CTEST&amp;quot; -S $DASHBOARD_SCRIPTS_DIR/factory-64bits_slicer4_release_nightly.cmake -VV -O $LOG_DIR/factory-64bits_slicer4_release_nightly.log&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--&lt;br /&gt;
The virtual  machines are run using the Parallels tool.&lt;br /&gt;
--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Hardware ===&lt;br /&gt;
&lt;br /&gt;
* &amp;quot;Mac Pro (Mid 2010)&amp;quot; which has the 64-bit kernel enabled by default. See [http://support.apple.com/kb/HT3770 here] for details.&lt;br /&gt;
&lt;br /&gt;
==== Processor ====&lt;br /&gt;
* 2 x 2.93 GHz 6-Core Intel Xeon&lt;br /&gt;
&lt;br /&gt;
==== Graphics Card ====&lt;br /&gt;
* Chipset Model: ATI Radeon HD 5770&lt;br /&gt;
* Type: GPU&lt;br /&gt;
* Bus PCIe&lt;br /&gt;
* VRAM (total): 1024MB&lt;br /&gt;
* EFI Driver Version: 01.00.436&lt;br /&gt;
&lt;br /&gt;
==== Memory ====&lt;br /&gt;
* 8 x 4GB = 32GB&lt;br /&gt;
* Type: DDR3 ECC&lt;br /&gt;
* Speed: 1333 MHz&lt;br /&gt;
&lt;br /&gt;
== factory-south.kitware ==&lt;br /&gt;
&lt;br /&gt;
=== Software ===&lt;br /&gt;
&lt;br /&gt;
The factory machine runs Mac OS X 10.11.6 (15G31), El Capitan&lt;br /&gt;
* Tasks scheduled using [http://en.wikipedia.org/wiki/Cron cron]&lt;br /&gt;
&lt;br /&gt;
The virtual machines are run using the [http://www.parallels.com/ Parallels Desktop 11].&lt;br /&gt;
* Note that Parallels Desktop supports [http://kb.parallels.com/en/115487 OpenGL 2.1 only] (not higher)&lt;br /&gt;
&lt;br /&gt;
Remote access: Via SSH or VNC from Kitware internal network (10.171.2.166).&lt;br /&gt;
&lt;br /&gt;
=== Hardware ===&lt;br /&gt;
&lt;br /&gt;
==== Processor ====&lt;br /&gt;
* 2 x 2.4 GHz 6-Core Intel Xeon&lt;br /&gt;
&lt;br /&gt;
==== Graphics Card ====&lt;br /&gt;
* Chipset Model: ATI Radeon HD 5770&lt;br /&gt;
* Type: GPU&lt;br /&gt;
* Bus PCIe&lt;br /&gt;
* VRAM (total): 1024MB&lt;br /&gt;
* EFI Driver Version: 01.00.436&lt;br /&gt;
&lt;br /&gt;
==== Memory ====&lt;br /&gt;
* 8 x 8GB = 64 GB&lt;br /&gt;
* Type: DDR3 ECC&lt;br /&gt;
* Speed: 1333 MHz&lt;br /&gt;
&lt;br /&gt;
== overload.kitware and metroplex.kitware ==&lt;br /&gt;
&lt;br /&gt;
[[File:Kitware build servers metroplex-and-overload.jpg|600px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Software ===&lt;br /&gt;
&lt;br /&gt;
* overload: Windows 7 Professional 64-bit&lt;br /&gt;
* metroplex: Red Hat Enterprise Linux WS v7.0&lt;br /&gt;
&lt;br /&gt;
=== Hardware ===&lt;br /&gt;
&lt;br /&gt;
* Dell Precision R7910 Motherboard,BW&lt;br /&gt;
&lt;br /&gt;
==== Processor ====&lt;br /&gt;
&lt;br /&gt;
* Dual Intel® Xeon® Processor E5-2630 v3 (8C, 2.4GHz, Turbo, HT, 20M, 85W)&lt;br /&gt;
&lt;br /&gt;
==== Graphics Card ====&lt;br /&gt;
&lt;br /&gt;
* NVIDIA® Quadro® K620 2GB (DP, DL-DVI-I) (1 DP to SL-DVI adapter)&lt;br /&gt;
&lt;br /&gt;
==== Memory ====&lt;br /&gt;
&lt;br /&gt;
* 32GB (8x4GB) 2133MHz DDR4 RDIMM ECC&lt;br /&gt;
&lt;br /&gt;
==== Storage ====&lt;br /&gt;
&lt;br /&gt;
* 2 X Integrated Intel 4 port AHCI SATA chipset controllers (tot 8 X 6.0Gb/s) SW RAID 0,1,5,10&lt;br /&gt;
* 1 x 1TB Dell 4*Drive PCIe x16 M.2 Solid State Drive Card (boot)&lt;br /&gt;
&lt;br /&gt;
=== overload.kitware ===&lt;br /&gt;
&lt;br /&gt;
* Windows 7 Professional - Service Pack 1 (Build 7601)&lt;br /&gt;
* CMake version: 3.9.0 (before 2017/07/04 was CMake 3.7.1)&lt;br /&gt;
* Compiler: VS2013 Community Edition&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=VM: Linux=&lt;br /&gt;
&amp;lt;!--&lt;br /&gt;
== factory.kitware ==&lt;br /&gt;
* Ubuntu 11.04&lt;br /&gt;
* CMake version: 2.8.8&lt;br /&gt;
* GCC version: Ubuntu 4.4.3-4ubuntu5.1&lt;br /&gt;
* Tasks scheduled using [http://en.wikipedia.org/wiki/Cron cron]&lt;br /&gt;
&lt;br /&gt;
The scripts on this VM are very similar to those on the Host.&lt;br /&gt;
&lt;br /&gt;
=== Remote access ===&lt;br /&gt;
This machine is accessible through SSH and remote VNC.  It has been configured with its own static IP, and should be accessed by VNC through this IP instead of through a VNC connection on the Mac Host.  Do not try to connect through VNC to this machine on the Host.&lt;br /&gt;
&lt;br /&gt;
===Known issues===&lt;br /&gt;
* X crash / GLX&amp;quot; missing on display. See [http://www.na-mic.org/Bug/view.php?id=2468 #2468]: '''FIXED'''&lt;br /&gt;
* Beside the fact Parallel has been updated, the X server still crash and auto-login does NOT succeed. See [http://www.na-mic.org/Bug/view.php?id=2624 #2624]: '''FIXED'''&lt;br /&gt;
--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== factory-south-ubuntu.kitware ==&lt;br /&gt;
* Ubuntu 10.04&lt;br /&gt;
* CMake version: 3.9.0 (before 2017/07/04 was 3.5.0-rc3)&lt;br /&gt;
* GCC version: Ubuntu 4.4.3-4ubuntu5.1&lt;br /&gt;
* Tasks scheduled using [http://en.wikipedia.org/wiki/Cron cron]&lt;br /&gt;
* Processors: 5&lt;br /&gt;
* Memory: 10GB&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ lsb_release -a&lt;br /&gt;
No LSB modules are available.&lt;br /&gt;
Distributor ID:	Ubuntu&lt;br /&gt;
Description:	Ubuntu 10.04.4 LTS&lt;br /&gt;
Release:	10.04&lt;br /&gt;
Codename:	lucid&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
These two compilers are available:&lt;br /&gt;
&lt;br /&gt;
=== gcc/g++ 4.4.3 ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
/usr/bin/cpp-4.4&lt;br /&gt;
/usr/bin/g++-4.4&lt;br /&gt;
/usr/bin/gcc-4.4&lt;br /&gt;
/usr/bin/gcov-4.4&lt;br /&gt;
/usr/bin/x86_64-linux-gnu-cpp-4.4&lt;br /&gt;
/usr/bin/x86_64-linux-gnu-g++-4.4&lt;br /&gt;
/usr/bin/x86_64-linux-gnu-gcc-4.4&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* In the PATH:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ gcc --version&lt;br /&gt;
gcc (Ubuntu 4.4.3-4ubuntu5.1) 4.4.3&lt;br /&gt;
$ g++ --version&lt;br /&gt;
g++ (Ubuntu 4.4.3-4ubuntu5.1) 4.4.3&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== gcc/g++ 4.6.4 ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
/usr/bin/cpp-4.6&lt;br /&gt;
/usr/bin/g++-4.6&lt;br /&gt;
/usr/bin/gcc-4.6&lt;br /&gt;
/usr/bin/gcov-4.6&lt;br /&gt;
/usr/bin/x86_64-linux-gnu-cpp-4.6&lt;br /&gt;
/usr/bin/x86_64-linux-gnu-g++-4.6&lt;br /&gt;
/usr/bin/x86_64-linux-gnu-gcc-4.6&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Installed following these instructions:&lt;br /&gt;
* https://launchpad.net/~ubuntu-toolchain-r/+archive/ubuntu/test?field.series_filter=lucid&lt;br /&gt;
* http://superuser.com/questions/310809/how-can-i-update-gcc-to-the-latest-version-in-ubuntu-10-04/394811#394811&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo add-apt-repository ppa:ubuntu-toolchain-r/test&lt;br /&gt;
sudo apt-get update&lt;br /&gt;
sudo apt-get update&lt;br /&gt;
sudo apt-get install gcc-4.6&lt;br /&gt;
sudo apt-get install g++-4.6&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Remote access ===&lt;br /&gt;
&lt;br /&gt;
Remote access: Via SSH or VNC from Kitware internal network (10.171.2.113).&lt;br /&gt;
&lt;br /&gt;
=VM: Windows 7=&lt;br /&gt;
&lt;br /&gt;
* Tasks are scheduled using the Windows Task Scheduler (Start-&amp;gt;All Programs-&amp;gt;Accessories-&amp;gt;System Tools-&amp;gt;Task Scheduler)&lt;br /&gt;
* On Windows, instead of bash, we use batch scripts comprised of commands to call ctest to run all the nightly scripts.  &lt;br /&gt;
&lt;br /&gt;
== factory-south-win7.kitware ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;This VM is shutdown, build have been moved to overload.kitware&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Windows 7 Ultimate N - Service Pack 1 (Build 7601) on an x86 platform.&lt;br /&gt;
* CMake version: 3.5.0-rc3&lt;br /&gt;
* Compiler: VS2013 Community Edition&lt;br /&gt;
* Processors: 6&lt;br /&gt;
* Memory: 16GB&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Also, keep in mind the [[Documentation/{{documentation/version}}/Developers/Tutorials/DashboardSetup#Remarks remarks]] about building a dashboard on a Windows machine.  These all apply here.&lt;br /&gt;
&lt;br /&gt;
Remote access: Via Remote Desktop from Kitware internal network (10.171.2.245).&lt;br /&gt;
&lt;br /&gt;
=Maintenance=&lt;br /&gt;
&lt;br /&gt;
== Check Virtual Machines (factory-south-ubuntu) ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;factory-south-win7 VM is shutdown, build have been moved to overload.kitware&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== When ===&lt;br /&gt;
&lt;br /&gt;
Every day (or as soon as issues are suspected)&lt;br /&gt;
&lt;br /&gt;
=== What ===&lt;br /&gt;
&lt;br /&gt;
* Try to:&lt;br /&gt;
** SSH into factory-south-ubuntu&lt;br /&gt;
&amp;lt;!--&lt;br /&gt;
** RDP into factory-south-win7&lt;br /&gt;
--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* If failure:&lt;br /&gt;
** Connect to &amp;lt;code&amp;gt;factory.south&amp;lt;/code&amp;gt; and check the state of the virtual machines. &lt;br /&gt;
&lt;br /&gt;
* Are the virtual machine unresponsive ?&lt;br /&gt;
&lt;br /&gt;
* '''No''' -&amp;gt; No further action required&lt;br /&gt;
* '''Yes''' -&amp;gt; Read below&lt;br /&gt;
** Kill both VMs&lt;br /&gt;
** Restart the host (factory-south)&lt;br /&gt;
** Manually start the virtual machines&lt;br /&gt;
** If needed, manually restarts the nightly build (See below)&lt;br /&gt;
&lt;br /&gt;
== Manually restart the night builds ==&lt;br /&gt;
&lt;br /&gt;
If the factory machines were restarted after the regular Nightly startup time, the nightly scripts will have to be explicitly started.&lt;br /&gt;
&lt;br /&gt;
* Linux: Run &amp;lt;code&amp;gt;/home/kitware/Dashboards/DashboardScripts/factory-south-ubuntu.sh&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* MacOSX: Run &amp;lt;code&amp;gt;/Users/kitware/DashboardScripts/factory.sh&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Windows: Open &amp;quot;Task Scheduled&amp;quot; -&amp;gt; slicer -&amp;gt; right click on &amp;quot;Nightly&amp;quot; -&amp;gt; Start&lt;br /&gt;
&lt;br /&gt;
== Nightly Build startup times ==&lt;br /&gt;
&lt;br /&gt;
* Linux: 11:10pm&lt;br /&gt;
&lt;br /&gt;
* MacOSx: 11:10pm&lt;br /&gt;
&lt;br /&gt;
* Windows: Midnight&lt;/div&gt;</summary>
		<author><name>Inorton</name></author>
		
	</entry>
	<entry>
		<id>https://www.slicer.org/w/index.php?title=Help&amp;diff=55036</id>
		<title>Help</title>
		<link rel="alternate" type="text/html" href="https://www.slicer.org/w/index.php?title=Help&amp;diff=55036"/>
		<updated>2017-10-04T11:58:20Z</updated>

		<summary type="html">&lt;p&gt;Inorton: /* Bug Reports and Feature Requests */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Introduction=&lt;br /&gt;
This page is intended to provide links to places where Slicer Users can get help.&lt;br /&gt;
&lt;br /&gt;
=Discourse Forum=&lt;br /&gt;
The most effective way to get help from the community is through the Slicer Discussion Forum:&lt;br /&gt;
* https://discourse.slicer.org&lt;br /&gt;
&lt;br /&gt;
=Training and Documentation=&lt;br /&gt;
*The [[Documentation/{{documentation/currentversion}}/Training|Training page]] provides a series of courses for learning how to use Slicer4. The portfolio contains self-guided presentation and sample data sets.&lt;br /&gt;
*Reference manual style [[Documentation/{{documentation/currentversion}}|documentation]] for Slicer4 can be found on the Slicer Wiki.&lt;br /&gt;
&lt;br /&gt;
=Frequently Asked Questions FAQs=&lt;br /&gt;
We maintain a curated list of questions and answers for both users and developers:&lt;br /&gt;
* [[Documentation/{{documentation/currentversion}}/FAQ | Users FAQ]]&lt;br /&gt;
* [[Documentation/{{documentation/currentversion}}/Developers/FAQ | Developers FAQ]]&lt;br /&gt;
&lt;br /&gt;
=Downloading Slicer=&lt;br /&gt;
*Slicer is free open source software and is distributed under a BSD license. Please read the [[Projects/slicerWeb:LicenseText| Slicer License Agreement]], if you use Slicer. &lt;br /&gt;
*Compiled binaries are accessible through the [http://download.slicer.org Slicer Download] page.&lt;br /&gt;
&lt;br /&gt;
=Bug Reports and Feature Requests=&lt;br /&gt;
In order to file a bug report, please use the Slicer bug tracker:&lt;br /&gt;
* Visit '''http://www.na-mic.org/Bug/signup_page.php'''&lt;br /&gt;
** Log in or create an account.&lt;br /&gt;
** then click on the '''Report Issue''' link in your browser.&lt;br /&gt;
* See [[Documentation/{{documentation/currentversion}}/Report_a_problem|here]] for additional tips on reporting issues.&lt;br /&gt;
For feature requests, please discuss on the Slicer Forum first. An existing or adaptable solution will often be suggested.&lt;br /&gt;
* https://discourse.slicer.org&lt;br /&gt;
&lt;br /&gt;
=Mailing List (discontinued) Archives=&lt;br /&gt;
Prior to Discourse, support and development discussions were conducted on several mailing lists, for which 10+ years of archives are available:&lt;br /&gt;
* [http://massmail.spl.harvard.edu/public-archives/slicer-users slicer-users (usage questions) archive ].&lt;br /&gt;
** ([http://slicer-users.65878.n3.nabble.com/ searchable Nabble mirror])&lt;br /&gt;
* [http://massmail.spl.harvard.edu/public-archives/slicer-devel slicer-devel (programming questions) archive]&lt;br /&gt;
** ([http://slicer-devel.65872.n3.nabble.com/ searchable Nabble mirror])&lt;/div&gt;</summary>
		<author><name>Inorton</name></author>
		
	</entry>
	<entry>
		<id>https://www.slicer.org/w/index.php?title=Help&amp;diff=55035</id>
		<title>Help</title>
		<link rel="alternate" type="text/html" href="https://www.slicer.org/w/index.php?title=Help&amp;diff=55035"/>
		<updated>2017-10-04T11:53:28Z</updated>

		<summary type="html">&lt;p&gt;Inorton: /* Bug Reports and Feature Requests */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Introduction=&lt;br /&gt;
This page is intended to provide links to places where Slicer Users can get help.&lt;br /&gt;
&lt;br /&gt;
=Discourse Forum=&lt;br /&gt;
The most effective way to get help from the community is through the Slicer Discussion Forum:&lt;br /&gt;
* https://discourse.slicer.org&lt;br /&gt;
&lt;br /&gt;
=Training and Documentation=&lt;br /&gt;
*The [[Documentation/{{documentation/currentversion}}/Training|Training page]] provides a series of courses for learning how to use Slicer4. The portfolio contains self-guided presentation and sample data sets.&lt;br /&gt;
*Reference manual style [[Documentation/{{documentation/currentversion}}|documentation]] for Slicer4 can be found on the Slicer Wiki.&lt;br /&gt;
&lt;br /&gt;
=Frequently Asked Questions FAQs=&lt;br /&gt;
We maintain a curated list of questions and answers for both users and developers:&lt;br /&gt;
* [[Documentation/{{documentation/currentversion}}/FAQ | Users FAQ]]&lt;br /&gt;
* [[Documentation/{{documentation/currentversion}}/Developers/FAQ | Developers FAQ]]&lt;br /&gt;
&lt;br /&gt;
=Downloading Slicer=&lt;br /&gt;
*Slicer is free open source software and is distributed under a BSD license. Please read the [[Projects/slicerWeb:LicenseText| Slicer License Agreement]], if you use Slicer. &lt;br /&gt;
*Compiled binaries are accessible through the [http://download.slicer.org Slicer Download] page.&lt;br /&gt;
&lt;br /&gt;
=Bug Reports and Feature Requests=&lt;br /&gt;
We have a data base of bug reports and feature request which is based on a software package called &amp;quot;Mantis&amp;quot;.&lt;br /&gt;
Please file your reports in mantis and send a message about the report to the '''[https://discourse.slicer.org Slicer Discussion Forum]'''.&lt;br /&gt;
* In order to file a feature request or a bug report, please sign up on http://www.na-mic.org/Bug/signup_page.php, then click on the '''Report Issue''' link in your browser.&lt;br /&gt;
* See [[Documentation/{{documentation/currentversion}}/Report_a_problem|here]] for additional tips on reporting issues.&lt;br /&gt;
&lt;br /&gt;
=Mailing List (discontinued) Archives=&lt;br /&gt;
Prior to Discourse, support and development discussions were conducted on several mailing lists, for which 10+ years of archives are available:&lt;br /&gt;
* [http://massmail.spl.harvard.edu/public-archives/slicer-users slicer-users (usage questions) archive ].&lt;br /&gt;
** ([http://slicer-users.65878.n3.nabble.com/ searchable Nabble mirror])&lt;br /&gt;
* [http://massmail.spl.harvard.edu/public-archives/slicer-devel slicer-devel (programming questions) archive]&lt;br /&gt;
** ([http://slicer-devel.65872.n3.nabble.com/ searchable Nabble mirror])&lt;/div&gt;</summary>
		<author><name>Inorton</name></author>
		
	</entry>
	<entry>
		<id>https://www.slicer.org/w/index.php?title=Help&amp;diff=55034</id>
		<title>Help</title>
		<link rel="alternate" type="text/html" href="https://www.slicer.org/w/index.php?title=Help&amp;diff=55034"/>
		<updated>2017-10-04T11:52:46Z</updated>

		<summary type="html">&lt;p&gt;Inorton: /* Bug Reports and Feature Requests */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Introduction=&lt;br /&gt;
This page is intended to provide links to places where Slicer Users can get help.&lt;br /&gt;
&lt;br /&gt;
=Discourse Forum=&lt;br /&gt;
The most effective way to get help from the community is through the Slicer Discussion Forum:&lt;br /&gt;
* https://discourse.slicer.org&lt;br /&gt;
&lt;br /&gt;
=Training and Documentation=&lt;br /&gt;
*The [[Documentation/{{documentation/currentversion}}/Training|Training page]] provides a series of courses for learning how to use Slicer4. The portfolio contains self-guided presentation and sample data sets.&lt;br /&gt;
*Reference manual style [[Documentation/{{documentation/currentversion}}|documentation]] for Slicer4 can be found on the Slicer Wiki.&lt;br /&gt;
&lt;br /&gt;
=Frequently Asked Questions FAQs=&lt;br /&gt;
We maintain a curated list of questions and answers for both users and developers:&lt;br /&gt;
* [[Documentation/{{documentation/currentversion}}/FAQ | Users FAQ]]&lt;br /&gt;
* [[Documentation/{{documentation/currentversion}}/Developers/FAQ | Developers FAQ]]&lt;br /&gt;
&lt;br /&gt;
=Downloading Slicer=&lt;br /&gt;
*Slicer is free open source software and is distributed under a BSD license. Please read the [[Projects/slicerWeb:LicenseText| Slicer License Agreement]], if you use Slicer. &lt;br /&gt;
*Compiled binaries are accessible through the [http://download.slicer.org Slicer Download] page.&lt;br /&gt;
&lt;br /&gt;
=Bug Reports and Feature Requests=&lt;br /&gt;
We have a data base of bug reports and feature request which is based on a software package called &amp;quot;Mantis&amp;quot;.&lt;br /&gt;
Please file your reports in mantis and send a message about the report to the '''[https://discourse.slicer.org Slicer Discourse forum]'''.&lt;br /&gt;
* In order to file a feature request or a bug report, please sign up on http://www.na-mic.org/Bug/signup_page.php, then click on the '''Report Issue''' link in your browser.&lt;br /&gt;
* See [[Documentation/{{documentation/currentversion}}/Report_a_problem|here]] for additional tips on reporting issues.&lt;br /&gt;
&lt;br /&gt;
=Mailing List (discontinued) Archives=&lt;br /&gt;
Prior to Discourse, support and development discussions were conducted on several mailing lists, for which 10+ years of archives are available:&lt;br /&gt;
* [http://massmail.spl.harvard.edu/public-archives/slicer-users slicer-users (usage questions) archive ].&lt;br /&gt;
** ([http://slicer-users.65878.n3.nabble.com/ searchable Nabble mirror])&lt;br /&gt;
* [http://massmail.spl.harvard.edu/public-archives/slicer-devel slicer-devel (programming questions) archive]&lt;br /&gt;
** ([http://slicer-devel.65872.n3.nabble.com/ searchable Nabble mirror])&lt;/div&gt;</summary>
		<author><name>Inorton</name></author>
		
	</entry>
	<entry>
		<id>https://www.slicer.org/w/index.php?title=Documentation/Nightly/Training&amp;diff=53478</id>
		<title>Documentation/Nightly/Training</title>
		<link rel="alternate" type="text/html" href="https://www.slicer.org/w/index.php?title=Documentation/Nightly/Training&amp;diff=53478"/>
		<updated>2017-07-20T20:58:59Z</updated>

		<summary type="html">&lt;p&gt;Inorton: /* Fiber Bundle Selection and Scalar Measurements */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;noinclude&amp;gt;{{documentation/versioncheck}}&amp;lt;/noinclude&amp;gt;&lt;br /&gt;
=Introduction: Slicer {{documentation/version}} Tutorials=&lt;br /&gt;
&lt;br /&gt;
*This page contains &amp;quot;How to&amp;quot; tutorials with matched sample data sets. They demonstrate how to use the 3D Slicer environment (version {{documentation/version}} release) to accomplish certain tasks. &lt;br /&gt;
*For tutorials for other versions of Slicer, please visit the [[Training| Slicer training portal]].&lt;br /&gt;
*For &amp;quot;reference manual&amp;quot; style documentation, please visit the [[Documentation/{{documentation/version}}|Slicer {{documentation/version}} documentation page]]&lt;br /&gt;
*For questions related to the Slicer4 Training Compendium, please send an e-mail to '''[http://www.na-mic.org/Wiki/index.php/User:SPujol Sonia Pujol, Ph.D., Director of Training of 3D Slicer.]'''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
* Some of these tutorials are based on older releases of 3D Slicer.  The concepts are still useful but bear in mind that some interface elements and features will be different in updated versions.&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
=General Introduction=&lt;br /&gt;
&lt;br /&gt;
==Slicer Welcome Tutorial==&lt;br /&gt;
{|width=&amp;quot;100%&amp;quot;&lt;br /&gt;
|&lt;br /&gt;
*The [[media:SlicerWelcome-tutorial_Slicer4.5.pdf|SlicerWelcome tutorial]] is an introduction to Slicer based on the Welcome module.&lt;br /&gt;
*Author: Sonia Pujol, Ph.D.&lt;br /&gt;
*Audience: First time users who want a general introduction to the software.&lt;br /&gt;
*Modules: Welcome to Slicer, Sample Data&lt;br /&gt;
*Based on: 3D Slicer version 4.6&lt;br /&gt;
|align=&amp;quot;right&amp;quot;|&lt;br /&gt;
[[image:SlicerWelcome-image.png|250px|SlicerWelcome tutorial]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==Slicer4Minute Tutorial==&lt;br /&gt;
{|width=&amp;quot;100%&amp;quot;&lt;br /&gt;
|&lt;br /&gt;
*The [[media:Slicer4.5minute_SoniaPujol.pdf|Slicer4Minute tutorial]]  is a brief introduction to the advanced 3D visualization capabilities of Slicer 4.5.&lt;br /&gt;
*Author: Sonia Pujol, Ph.D.&lt;br /&gt;
*Audience: First time users who want to discover Slicer in 4 minutes.&lt;br /&gt;
*Modules: Welcome to Slicer, Models&lt;br /&gt;
*Based on: 3D Slicer version 4.5&lt;br /&gt;
*The [[media:Slicer4minute.zip|Slicer4Minute dataset]] contains an MR scan of the brain and 3D reconstructions of the anatomy&lt;br /&gt;
|align=&amp;quot;right&amp;quot;|&lt;br /&gt;
[[image:Slicer4minute-image.png|250px|right|Slicer4Minute tutorial]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==Slicer4 Data Loading and 3D Visualization ==&lt;br /&gt;
{|width=&amp;quot;100%&amp;quot;&lt;br /&gt;
|&lt;br /&gt;
*The [[Media:3DDataLoadingandVisualization_Slicer4.5_SoniaPujol.pdf | Data loading and 3D visualization]] course guides through the basics of loading and viewing volumes and 3D models in Slicer4 . &lt;br /&gt;
*Author: Sonia Pujol, Ph.D.&lt;br /&gt;
*Modules: Welcome to Slicer, Sample Data, Models.&lt;br /&gt;
*Audience: End-users&lt;br /&gt;
*Based on: 3D Slicer version 4.5&lt;br /&gt;
*The [[Media:3DVisualizationData.zip | 3DVisualization dataset]] contain an MR scan and a series of 3D models of the brain.&lt;br /&gt;
|align=&amp;quot;right&amp;quot;|&lt;br /&gt;
[[Image:Slicer4DataLoading_tutorial.png|right|250px|]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=Tutorials for software developers=&lt;br /&gt;
&lt;br /&gt;
== Slicer4 Programming Tutorial ==&lt;br /&gt;
{|width=&amp;quot;100%&amp;quot;&lt;br /&gt;
|&lt;br /&gt;
*The [https://1drv.ms/b/s!Arm_AFxB9yqHsIUKNqVboYvm4sgd4w Hello Python Programming tutorial] course guides through the integration of a python module in Slicer4. &lt;br /&gt;
*Author: Sonia Pujol, Ph.D., Steve Pieper, Ph.D.&lt;br /&gt;
*Audience: Developers&lt;br /&gt;
*Based on: 3D Slicer version 4.5&lt;br /&gt;
*The [https://1drv.ms/u/s!Arm_AFxB9yqHsIR2N_9krtTHTsTo1Q HelloPython dataset] contains sample data set (MR scan of the brain) and complete Python module examples.&lt;br /&gt;
|align=&amp;quot;right&amp;quot;|&lt;br /&gt;
[[Image:HelloPythonTutorial.png|right|250px|]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
For additional Python scripts examples, please visit the [[Documentation/{{documentation/version}}/ScriptRepository|Script Repository page]]&lt;br /&gt;
&lt;br /&gt;
==Developing and contributing extensions for 3D Slicer==&lt;br /&gt;
{|width=&amp;quot;100%&amp;quot;&lt;br /&gt;
|&lt;br /&gt;
*The [http://goo.gl/IP4cdg Developing and contributing extensions for 3D Slicer tutorial ] is an introduction to the internals of 3D Slicer and the process of contributing a 3D Slicer extension.&lt;br /&gt;
*Authors: Andrey Fedorov, Jean-Christophe Fillion-Robin, Steve Pieper&lt;br /&gt;
*Audience: Developers&lt;br /&gt;
*Based on: 3D Slicer version 4.4&lt;br /&gt;
|align=&amp;quot;right&amp;quot;|&lt;br /&gt;
[[Image:Contributing3DSlicerExtension.png|right|250px|]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=Specific functions=&lt;br /&gt;
&lt;br /&gt;
==Slicer4 Diffusion Tensor Imaging Tutorial ==&lt;br /&gt;
{|width=&amp;quot;100%&amp;quot;&lt;br /&gt;
|&lt;br /&gt;
*The [https://github.com/SlicerDMRI/slicerdmri.github.io/raw/master/docs/tutorials/DiffusionMRIanalysis.pdf Diffusion Tensor Imaging Tutorial]  course guides through the basics of loading Diffusion Weighted images in Slicer, estimating tensors and generating fiber tracts. &lt;br /&gt;
*Author: Sonia Pujol, Ph.D.&lt;br /&gt;
*Audience: End-users and developers&lt;br /&gt;
*Modules: Data, Volumes, DWI to DTI Estimation, Diffusion Tensor Scalar Measurements, Editor, Markups,Tractography Label Map Seeding, Tractography Interactive Seeding&lt;br /&gt;
*Based on: 3D Slicer version 4.5&lt;br /&gt;
*The [[media:Dti tutorial data.zip|DTI dataset]] contains an MR Diffusion Weighted Imaging scan of the brain.&lt;br /&gt;
|align=&amp;quot;right&amp;quot;|&lt;br /&gt;
[[Image:Slicer4DTI Tutorial.png|right|250px|]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==Slicer4 Neurosurgical Planning Tutorial==&lt;br /&gt;
{|width=&amp;quot;100%&amp;quot;&lt;br /&gt;
|&lt;br /&gt;
*The [https://github.com/SlicerDMRI/slicerdmri.github.io/raw/master/docs/tutorials/WhiteMatterExplorationTutorial.pdf Neurosurgical Planning tutorial] course guides through the generation of fiber tracts in the vicinity of a tumor.&lt;br /&gt;
*Author: Sonia Pujol, Ph.D., Ron Kikinis, M.D.&lt;br /&gt;
*Audience: End-users and developers&lt;br /&gt;
*Modules: Volumes, Editor, Tractography Label Map Seeding, Tractography Interactive Seeding&lt;br /&gt;
*Based on: 3D Slicer version 4.5&lt;br /&gt;
*The [[Media:WhiteMatterExplorationData.zip| White Matter Exploration datasets]] contains a Diffusion Weighted Imaging scan of  brain tumor patient.&lt;br /&gt;
|align=&amp;quot;right&amp;quot;|&lt;br /&gt;
[[Image:NeurosurgicalPlanningTutorial.png|right|250px|link=http://vimeo.com/67336069]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==Slicer4 3D Visualization of DICOM images for Radiology Applications==&lt;br /&gt;
{|width=&amp;quot;100%&amp;quot;&lt;br /&gt;
|&lt;br /&gt;
*The [[Media:3DSlicer_Dicom_RSNA2015_SoniaPujol.pdf |3D Visualization of DICOM images for Radiology Applications]]  course guides through 3D data loading and visualization of DICOM images for Radiology Applications in Slicer4. &lt;br /&gt;
*Author: Sonia Pujol, Ph.D., Kitt Shaffer, M.D., Ph.D., Ron Kikinis, M.D.&lt;br /&gt;
*Audience: Radiologists and users of Slicer who need a more comprehensive overview over Slicer4 visualization capabilities.&lt;br /&gt;
*Modules: DICOM, Volumes, Volume Rendering, Models.&lt;br /&gt;
*Based on: 3D Slicer version 4.5&lt;br /&gt;
*The [[Media:3DVisualization_DICOM_images_part1.zip‎  | 3DVisualizationDICOM_part1]] and [[Media:3DVisualization_DICOM_images_part2.zip | 3DVisualizationDICOM_part2]] datasets contain a series of MR and CT scans, and 3D models of the brain, lung and liver.&lt;br /&gt;
|align=&amp;quot;right&amp;quot;|&lt;br /&gt;
[[Image:Slicer4RSNA_2.png|right|250px|]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==Slicer4 Quantitative Imaging tutorial==&lt;br /&gt;
{|width=&amp;quot;100%&amp;quot;&lt;br /&gt;
|&lt;br /&gt;
*The [[media:QuantitativeImaging_Slicer4.5.pdf‎ | Slicer4 Quantitative Imaging tutorial]]  guides through the use for Slicer for quantifying small volumetric changes in slow-growing tumors, and for calculating Standardized Uptake Value (SUV) from PET/CT data.&lt;br /&gt;
*Authors: Sonia Pujol, Ph.D., Katarzyna Macura, M.D., Ron Kikinis, M.D.&lt;br /&gt;
*Audience: Radiologists and users of Slicer who need a more comprehensive overview over Slicer4 quantitative imaging capabilities.&lt;br /&gt;
*Modules: Data, Volumes, Models, Change Tracker, PET Standard Uptake Value Computation&lt;br /&gt;
*Based on: 3D Slicer version 4.5&lt;br /&gt;
*The [[media:QuantitativeImaging.zip‎| Quantitative Imaging dataset]]  contains a series of MR and PET/CT data.&lt;br /&gt;
|align=&amp;quot;right&amp;quot;|&lt;br /&gt;
[[Image:Slicer4_QuantitativeImaging.png|right|250px|]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Slicer4 IGT ==&lt;br /&gt;
{|width=&amp;quot;100%&amp;quot;&lt;br /&gt;
|&lt;br /&gt;
*[http://www.slicerigt.org/wp/user-tutorial/ Slicer IGT tutorials]&lt;br /&gt;
*Authors: Tamas Ungi, M.D, Ph.D., Junichi Tokuda, Ph.D.&lt;br /&gt;
*Audience: End-users interested in using Slicer for real-time navigated procedures. E.g. navigated needle insertions or other minimally invasive medical procedures.&lt;br /&gt;
*Modules: SlicerIGT Extension&lt;br /&gt;
*Based on: Slicer4.3.1-2014.09.14&lt;br /&gt;
*Data: [https://onedrive.live.com/redir?resid=7230D4DEC6058018!2937&amp;amp;authkey=!AGQkSCZOwjVYXw8&amp;amp;ithint=folder%2cpptx  Slicer-IGT datasets]&lt;br /&gt;
|align=&amp;quot;right&amp;quot;|&lt;br /&gt;
[[Image:SlicetIGT.png|right|150px|]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Slicer4 3D Printing ==&lt;br /&gt;
&lt;br /&gt;
{|width=&amp;quot;100%&amp;quot;&lt;br /&gt;
|&lt;br /&gt;
* The video tutorial [https://youtu.be/Uht6Fwtr9hE Segmenting a CT for 3D Printing of a Lumbar Phantom] shows how to use the Segment Editor of 3D Slicer for 3D printing using Slicer 4.7.&lt;br /&gt;
** Author: Hillary Lia&lt;br /&gt;
** Audience: Users and developers interested in 3D printing&lt;br /&gt;
* The [https://www.slicer.org/wiki/Documentation/4.6/Training#Segmentation_for_3D_printing Segmentation for 3D printing] shows how to use the Segment Editor of 3D Slicer for 3D printing using Slicer 4.6.&lt;br /&gt;
** Author: Csaba Pinter, MSc&lt;br /&gt;
** Audience: Users and developers interested in 3D printing&lt;br /&gt;
* This ''Slicer 4.3 [https://www.youtube.com/watch?v=MKLWzD0PiIc 3D printing tutorial]''  shows how to prepare 3D Slicer data for 3D printing using legacy Editor module.&lt;br /&gt;
** Authors: Nabgha Farhat, MSc&lt;br /&gt;
** Audience: Users and developers interested in 3D printing&lt;br /&gt;
|align=&amp;quot;right&amp;quot;|[[Image:20170717_3DPrintingTutorialYoutube.PNG|280px]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Slicer4 Image Registration ==&lt;br /&gt;
&lt;br /&gt;
{|width=&amp;quot;100%&amp;quot;&lt;br /&gt;
|&lt;br /&gt;
*The [https://www.slicer.org/slicerWiki/index.php/File:RegistrationTutorial_3DSlicer4.5_spujol.pdf Registration tutorial] shows how to perform intra- and inter-subject registration within Slicer.&lt;br /&gt;
* Authors: Sonia Pujol, Ph.D., Dominik Meier, Ph.D., Ron Kikinis, M.D.&lt;br /&gt;
* Audience: Users and developers interested in image registration&lt;br /&gt;
* Dataset: [[Media:RegistrationData.zip| 3D Slicer Registration Data]]&lt;br /&gt;
|align=&amp;quot;right&amp;quot;|[[File:registration_Slicer4.png|250px]]&lt;br /&gt;
|}&lt;br /&gt;
*Based on: 3D Slicer version 4.5&lt;br /&gt;
See [[Documentation/{{documentation/version}}/Registration/RegistrationLibrary|the Registration Library for worked out registration examples with data]].&lt;br /&gt;
&lt;br /&gt;
== Fast GrowCut ==&lt;br /&gt;
&lt;br /&gt;
{|width=&amp;quot;100%&amp;quot;&lt;br /&gt;
|&lt;br /&gt;
* The [[media:FastGrowCutTutorial.pdf |Fast GrowCut tutorial]]  shows how to perform a segmentation using the Fast GrowCut effect in Slicer.&lt;br /&gt;
* Authors: Hillary Lia&lt;br /&gt;
* Audience: Users interested in segmentation&lt;br /&gt;
|align=&amp;quot;right&amp;quot;|[[File:FastGrowCutLogo.png|200px]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==Slicer4 Radiation Therapy Tutorial ==&lt;br /&gt;
** The  [https://app.assembla.com/spaces/slicerrt/subversion/source/HEAD/trunk/SlicerRt/doc/tutorials/SlicerRT_TutorialIGRT_4.7.pdf?_format=raw SlicerRT tutorial] is an introduction to the Radiation Therapy functionalities of Slicer.&lt;br /&gt;
** Author: Csaba Pinter, Andras Lasso, An Wang, Gregory C. Sharp, David Jaffray, Gabor Fichtinger. &lt;br /&gt;
** Dataset: [http://slicer.kitware.com/midas3/download/item/205404/SlicerRT_WorldCongress_TutorialIGRT_Dataset.zip download] from MIDAS server&lt;br /&gt;
**Based on Slicer 4.7&lt;br /&gt;
&lt;br /&gt;
== Other ==&lt;br /&gt;
&lt;br /&gt;
Additional (non-curated) videos-based demonstrations using 3D Slicer are accessible on  [http://www.youtube.com/results?search_query=3d+slicer&amp;amp;sm=3 You Tube].&lt;br /&gt;
&lt;br /&gt;
= 3D Slicer Tutorial contests=&lt;br /&gt;
&lt;br /&gt;
==Winter 2017 Tutorial contest==&lt;br /&gt;
&lt;br /&gt;
===Segmentation for 3D printing===&lt;br /&gt;
{|width=&amp;quot;100%&amp;quot;&lt;br /&gt;
|&lt;br /&gt;
*The [https://www.assembla.com/spaces/slicerrt/documents/bmRQGEzzur54v-dmr6CpXy/download/bmRQGEzzur54v-dmr6CpXy Segmentation for 3D printing Tutorial] is an introduction to the new [[Documentation/{{documentation/version}}/Modules/SegmentEditor|Segment Editor]] module, demonstrated through the popular topic of 3D printing. &lt;br /&gt;
*Author: Csaba Pinter (Queen's University, Canada)&lt;br /&gt;
*Dataset: [[:File:BasePiece.zip|Phantom base STL model]] Source: [http://perk-software.cs.queensu.ca/plus/doc/nightly/modelcatalog/ PerkLab].&lt;br /&gt;
|align=&amp;quot;right&amp;quot;|&lt;br /&gt;
[[File:SlicerWinterProjectWeek2017-Segmentation-for-3d-printing.png | 200px]]. &lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===Slicer Pathology===&lt;br /&gt;
{|width=&amp;quot;100%&amp;quot;&lt;br /&gt;
|&lt;br /&gt;
*The [[Documentation/{{documentation/version}}/Extensions/SlicerPathology|Slicer Pathology Tutorial]] describes how to use the corresponding tools for automatic and semi-automatic pathology image segmentation.&lt;br /&gt;
*Author: Erich Bremer (Stonybrook), Andriy Fedorov (Brigham and Women’s Hospital)&lt;br /&gt;
*Dataset:  Available directly with the Slicer Pathology Slicer extension.&lt;br /&gt;
|align=&amp;quot;right&amp;quot;|&lt;br /&gt;
[[File:SlicerPathologyScreenShot8.png | 200px]]. &lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===Simple Python Tool for Quality Control of DWI data===&lt;br /&gt;
{|width=&amp;quot;100%&amp;quot;&lt;br /&gt;
|&lt;br /&gt;
*The [http://www.na-mic.org/Wiki/images/3/3a/SimpleDiffusionGradientInformationExtractorTutorial_Chauvin_Jan2017.pptx Simple Multi-shell Diffusion Gradients Information Extractor Tutorial] describes how to use a simple Python script for parsing multi-shell sensitizing gradients information from nifti file format (separated bvecs, bvals files).&lt;br /&gt;
*Author: Laurent Chauvin (ETS Montreal)&lt;br /&gt;
*Dataset:  Not available.&lt;br /&gt;
|align=&amp;quot;right&amp;quot;|&lt;br /&gt;
[[File:SlicerWinterProjectWeek2017-SimpleDiffusionGradientInformationExtractorTutorial.png | 200px]]. &lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===SPHARM-PDM===&lt;br /&gt;
{|width=&amp;quot;100%&amp;quot;&lt;br /&gt;
|&lt;br /&gt;
*The [https://www.nitrc.org/docman/view.php/308/1982/SPHARM-PDM_Tutorial_July2015.pdf SPHARM-PDM Tutorial] describes how to use SPHARM-PDM and ShapePopulationViewer Slicer extensions to respectively compute point-based models using a parametric boundary description for the computing of Shape Analysis and perform the quality control between the different models.&lt;br /&gt;
*Author: Jonathan Perdomo (UNC), Beatriz Paniagua (Kitware Inc.)&lt;br /&gt;
*Dataset:  [https://www.nitrc.org/docman/view.php/308/1981/SPHARM_Tutorial_Data_July2015.zip Tutorial Data]&lt;br /&gt;
|align=&amp;quot;right&amp;quot;|&lt;br /&gt;
[[File:SlicerWinterProjectWeek2017-SPHARM-PDM.png | 200px]]. &lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===Integration of Robot Operating System (ROS) and 3D Slicer using OpenIGTLink===&lt;br /&gt;
{|width=&amp;quot;100%&amp;quot;&lt;br /&gt;
|&lt;br /&gt;
*The [https://www.na-mic.org/Wiki/images/a/ab/ROSIGTLTutorial_Tokuda_Jan2017.pptx Integration of Robot Operating System (ROS) and 3D Slicer using OpenIGTLink Tutorial] describes the software architecture of surgical robot systems and allows to acquire hands-on experience of software-hardware integration for medical robotics.&lt;br /&gt;
*Author: Junichi Tokuda (Brigham and Women’s Hospital)&lt;br /&gt;
*Dataset:  Not available.&lt;br /&gt;
|align=&amp;quot;right&amp;quot;|&lt;br /&gt;
[[File:SlicerWinterProjectWeek2017-Integration-ROS-3DSlicer-OpenIGTLink.png | 200px]]. &lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===Fiber Bundle Volume Measurement===&lt;br /&gt;
{|width=&amp;quot;100%&amp;quot;&lt;br /&gt;
|&lt;br /&gt;
*The [http://www.na-mic.org/Wiki/images/5/57/Fiber_Bundle_Volume_Measurement.pptx Fiber Bundle Volume Measurement Tutorial] aim is to calculate the volume of the fiber bundle that passes through the Corpus Callosum(CC). Following this tutorial, you’ll be able to (1) convert fiber bundles to label map and (2) calculate volume measurements from the fiber bundles.&lt;br /&gt;
*Author: Shun Gong (Shanghai Changzheng Hospital, China)&lt;br /&gt;
*Dataset:  [http://www.na-mic.org/Wiki/images/4/4c/FiberVolume_data.zip Tutorial data]: The following data are provided: Baseline image, Down sampled whole brain tractography (conducted as in the [[Documentation/{{documentation/version}}/Training#Slicer4_Diffusion_Tensor_Imaging_Tutorial|DWI tutorial]] and down-sampled to about 10000 fibers using Tractography Display module), Corpus callosum label map (drawn as in the [[Documentation/{{documentation/version}}/Training#Slicer4_Diffusion_Tensor_Imaging_Tutorial|DWI tutorial]]).&lt;br /&gt;
|align=&amp;quot;right&amp;quot;|&lt;br /&gt;
[[File:SlicerWinterProjectWeek2017-FiberBundleVolumeMeasurements.png | 200px]]. &lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==Winter 2016 Tutorial contest==&lt;br /&gt;
&lt;br /&gt;
===Subject Hierarchy===&lt;br /&gt;
{|width=&amp;quot;100%&amp;quot;&lt;br /&gt;
|&lt;br /&gt;
*The [http://wiki.na-mic.org/Wiki/images/2/27/SubjectHierarchy.TutorialContestWinter2016.pdf Subject Hierarchy] tutorial demonstrates the basic usage and potential of Slicer’s data manager module Subject Hierarchy using a two-timepoint radiotherapy phantom dataset.&lt;br /&gt;
*Author: Csaba Pinter, Queen's University, Canada&lt;br /&gt;
*Dataset:  [http://slicer.kitware.com/midas3/download/item/205404/SlicerRT_WorldCongress_TutorialIGRT_Dataset.zip SlicerRT_WorldCongress_TutorialIGRT_Dataset] The tutorial dataset is a two-timepoint phantom dataset taken from a RANDO head&amp;amp;neck phantom. It contains two studies, the planning one is a DICOM study consisting of a CT grayscale image and radiotherapy data: contours, dose distribution, treatment beams, plan information. The second timepoint consists of a CT NRRD volume and a dose NRRD volume.&lt;br /&gt;
|align=&amp;quot;right&amp;quot;|&lt;br /&gt;
[[File:SubjectHierarchyTutorial.png | 200px]]. &lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===Fiber Bundle Selection and Scalar Measurements===&lt;br /&gt;
{|width=&amp;quot;100%&amp;quot;&lt;br /&gt;
|&lt;br /&gt;
*The [https://github.com/SlicerDMRI/slicerdmri.github.io/raw/master/docs/tutorials/FiberBundleSelectionAndScalarMeasurement.pdf Fiber Bundle Selection and Scalar Measurements] tutorial guides through the use of the Diffusion Bundle Selection module and the Fiber Tract Scalar Measurement module for diffusion MRI tractography data analysis.&lt;br /&gt;
*Author: Fan Zhang, University of Sydney Australia and Brigham and Women's Hospital&lt;br /&gt;
*Dataset:  [[media:FiberBundleSelectionAndScalarMeasurement_TutorialContestWinter2016.zip| Fiber Bundle Selection And Scalar Measurement Tutorial Dataset]]&lt;br /&gt;
|align=&amp;quot;right&amp;quot;|&lt;br /&gt;
[[File:FiberBundleSelectionAndScalarMeasurement_TutorialContestWinter2016_Snapshot.png|200px]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===Plastimatch ===&lt;br /&gt;
{|width=&amp;quot;100%&amp;quot;&lt;br /&gt;
|&lt;br /&gt;
*The [http://www.na-mic.org/Wiki/images/5/5c/Plastimatch_TutorialContestWinter2016.pdf Plastimatch tutorial] guides through registration and wrapping of DICOM and DICOM-RT data using the Plastimatch extension of 3D Slicer.&lt;br /&gt;
*Author: Gregory Sharp, Massachusetts General Hospital&lt;br /&gt;
*Dataset:  [http://www.na-mic.org/Wiki/index.php/File:Plastimatch_TutorialContestWinter2016.zip Plastimatch Tutorial Dataset]&lt;br /&gt;
|align=&amp;quot;right&amp;quot;|&lt;br /&gt;
[[File:PlastimatchTutorial_Winter2016Contest.png|200px]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===UKF ===&lt;br /&gt;
{|width=&amp;quot;100%&amp;quot;&lt;br /&gt;
|&lt;br /&gt;
*The [https://github.com/SlicerDMRI/slicerdmri.github.io/raw/master/docs/tutorials/UKFTractography.pdf UKF tutorial] guides through the use of the Unscented Kalman Filter (UKF) tractography module. &lt;br /&gt;
*Author: Pegah Kahali, Brigham and Women's Hopital&lt;br /&gt;
*Dataset:  [http://www.na-mic.org/Wiki/index.php/File:UKF-Tractography_TutorialContestWinter2016.zip UKF tutorial Dataset]&lt;br /&gt;
|align=&amp;quot;right&amp;quot;|&lt;br /&gt;
[[File:UKF_Winter2016.png|200px]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==Summer 2014 Tutorial contest== &lt;br /&gt;
&lt;br /&gt;
===Cardiac Agatston Tutorial===&lt;br /&gt;
{|width=&amp;quot;100%&amp;quot;&lt;br /&gt;
|&lt;br /&gt;
*[http://wiki.na-mic.org/Wiki/index.php/File:TutorialContest_CardiacAgatstonScoring_2014.pdf  Cardiac Agatston Scoring Tutorial]&lt;br /&gt;
*Authors:   Jessica Forbes, Hans Johnson, University of Iowa&lt;br /&gt;
*Dataset:  [http://wiki.na-mic.org/Wiki/index.php/File:CardiacAgatstonMeasures_TutorialContestSummer2014.zip Cardiac Agatston Scoring Tutorial Dataset]&lt;br /&gt;
|align=&amp;quot;right&amp;quot;|&lt;br /&gt;
[[File:CardiacAgatstonMeasuresModuleScreenshot.jpg| 250px]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===CMR Toolkit LA workflow===&lt;br /&gt;
{|width=&amp;quot;100%&amp;quot;&lt;br /&gt;
|&lt;br /&gt;
*[http://wiki.na-mic.org/Wiki/index.php/File:CMRToolkitLAWorkflow_TutorialContestSummer2014.pdf  CMR Toolkit LA Workflow Tutorial]&lt;br /&gt;
*Authors: Salma Bengali, Josh Cates, University of Utah&lt;br /&gt;
*Dataset:  [http://wiki.na-mic.org/Wiki/index.php/File:CMRToolkitLAWorkflowData_TutorialContestSummer2014.zip CMRToolkitLAWorkflow Dataset]&lt;br /&gt;
|align=&amp;quot;right&amp;quot;|&lt;br /&gt;
[[Image:Utah_SummerContest2014_tutorial.png|300px]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==Summer 2013 Tutorial contest==&lt;br /&gt;
&lt;br /&gt;
===Cardiac MRI Toolkit===&lt;br /&gt;
{|width=&amp;quot;100%&amp;quot;&lt;br /&gt;
|&lt;br /&gt;
*[[Media:Cardiac MRI Toolkit Tutorial Summer2013.pdf|Cardiac MRI Toolkit]]&lt;br /&gt;
*Authors:   Salma Bengali, Josh Cates, SCI, Utah&lt;br /&gt;
*Dataset:  [[Media:Cardiac_MRI_Toolkit_Tutorial_Data.zip|Cardiac MRI Toolkit Tutorial Dataset]]&lt;br /&gt;
|align=&amp;quot;right&amp;quot;|&lt;br /&gt;
[[Image:CMRToolkit_Tutorial_Image.png|250px]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===HelloCLI===&lt;br /&gt;
{|width=&amp;quot;100%&amp;quot;&lt;br /&gt;
|&lt;br /&gt;
*[[Media:Hello_CLI_TutorialContestSummer2013.pdf|HelloCLI]]&lt;br /&gt;
*Authors:   Nadya Shusharina, Greg Sharp, MGH, Boston&lt;br /&gt;
*Dataset:  [[Media:Hello_CLI_TutorialContestSummer2013.zip‎|HelloCLI Dataset]]&lt;br /&gt;
|align=&amp;quot;right&amp;quot;|&lt;br /&gt;
[[Image:Cli_icon.png|300px]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===SlicerRT===&lt;br /&gt;
{|width=&amp;quot;100%&amp;quot;&lt;br /&gt;
|&lt;br /&gt;
*[[Media:SlicerRT_TutorialContestSummer2013.pdf|SlicerRT Tutorial]]&lt;br /&gt;
*Authors:    Csaba Pinter, Andras Lasso (Queen's), Kevin Wang (PMH, Toronto)&lt;br /&gt;
*Dataset:  [[Media:CsabaPinter-SlicerRtTutorial_Namic2013June.zip|SlicerRT Dataset]] &lt;br /&gt;
|align=&amp;quot;right&amp;quot;|&lt;br /&gt;
[[Image:667px-SlicerRT_0.10_IsocenterShiftingEvaluation.png|250px]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===DTIPrep===&lt;br /&gt;
{|width=&amp;quot;100%&amp;quot;&lt;br /&gt;
|&lt;br /&gt;
*[[Media:DTIPrep_TutorialContestSummer2013.pdf|DTIPrep]]&lt;br /&gt;
*Authors:    Dave Welch, SINAPSE, IOWA &lt;br /&gt;
*Dataset:  [[Media:DTIPrepData_TutorialContestSummer2013.zip|DTIPrep Dataset]]&lt;br /&gt;
|align=&amp;quot;right&amp;quot;|&lt;br /&gt;
[[Image:DTIPrep-tutorial.png|250px]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Summer 2012 Tutorial contest == &lt;br /&gt;
&lt;br /&gt;
===Automatic Left Atrial Scar Segmenter ===&lt;br /&gt;
{|width=&amp;quot;100%&amp;quot;&lt;br /&gt;
|&lt;br /&gt;
*[http://wiki.na-mic.org/Wiki/index.php/CARMA-LA-Scar_TutorialContestSummer2012 Automatic Left Atrial Scar Segmenter] &lt;br /&gt;
*Authors:  Greg Gardner, Josh Cates, SCI, Utah&lt;br /&gt;
*Dataset: [http://wiki.na-mic.org/Wiki/index.php/File:CARMA-LA-Scar_TutorialContestSummer2012.zip CARMA-LA-Scar data]&lt;br /&gt;
|align=&amp;quot;right&amp;quot;|&lt;br /&gt;
[[Image:Carma afib auto scar.png|250px]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===Qualitative and quantitative comparison of  two RT dose distributions===&lt;br /&gt;
{|width=&amp;quot;100%&amp;quot;&lt;br /&gt;
|&lt;br /&gt;
*[http://www.na-mic.org/Wiki/index.php/File:PlastimatchDose_TutorialContestSummer2012.pdf Qualitative and quantitative comparison of  two RT dose distributions]&lt;br /&gt;
*Authors:  James Shackleford, Nadya Shusharina, Greg Sharp, MGH&lt;br /&gt;
|align=&amp;quot;right&amp;quot;|&lt;br /&gt;
[[Image:PlastimatchDose.png|250px]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===Dose accumulation for adaptive radiation therapy===&lt;br /&gt;
{|width=&amp;quot;100%&amp;quot;&lt;br /&gt;
|&lt;br /&gt;
*[http://www.na-mic.org/Wiki/index.php/File:DoseAccumulationforAdaptiveRadiationTherapy_TutorialContestSummer2012.pdf Dose accumulation for adaptive radiation therapy]&lt;br /&gt;
*Authors:  Kevin Wang, Csaba Pinter, Andras Lasso, PMH, Queen's&lt;br /&gt;
|align=&amp;quot;right&amp;quot;|&lt;br /&gt;
[[Image:AdaptiveradiationTherapy.png|250px]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===WebGL Export===&lt;br /&gt;
{|width=&amp;quot;100%&amp;quot;&lt;br /&gt;
|&lt;br /&gt;
*[http://www.na-mic.org/Wiki/index.php/File:WebGLExport_TutorialContestSummer2012.pdf  WebdGLExport]&lt;br /&gt;
*Authors:  Nicolas Rannou, Daniel Haehn, Children's Hospital&lt;br /&gt;
|align=&amp;quot;right&amp;quot;|&lt;br /&gt;
[[Image:WebGLExport.png|250px]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===OpenIGTLink===&lt;br /&gt;
{|width=&amp;quot;100%&amp;quot;&lt;br /&gt;
|&lt;br /&gt;
*[http://wiki.slicer.org/slicerWiki/images/f/f1/OpenIGTLinkTutorial_Slicer4.1.0_JunichiTokuda_Apr2012.pdf OpenIGTLink]&lt;br /&gt;
*Authors:  Junichi Tokuda, BWH&lt;br /&gt;
|align=&amp;quot;right&amp;quot;|&lt;br /&gt;
[[Image:OpenIGTLink.png|250px]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=Additional resources =&lt;br /&gt;
{|width=&amp;quot;100%&amp;quot;&lt;br /&gt;
|&lt;br /&gt;
* This ''Slicer 4.1 [http://vimeo.com/41096643 webinar]'' presents the new features and improvements of the release, and a brief overview of work for the next release.&lt;br /&gt;
* Authors: Steve Pieper Ph.D.&lt;br /&gt;
* Audience: First time users and developers interested in Slicer 4.1 new features.&lt;br /&gt;
* Length: 0h20m&lt;br /&gt;
|align=&amp;quot;right&amp;quot;|[[Image:Webinar-Slicer-4.1.png|250px]]&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
----&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
{|width=&amp;quot;100%&amp;quot;&lt;br /&gt;
|&lt;br /&gt;
*This ''Intro to Slicer 4.0 [http://vimeo.com/37671358 webinar]'' provides an introduction to 3DSlicer, and demonstrates core functionalities such as loading, visualizing and saving data. Basic processing tools, including manual registration, manual segmentation and tractography tools are also highlighted. This webinar is a general overview. For in depth information see the modules above and the documentation pages.&lt;br /&gt;
*Authors: Julien Finet, M.S., Steve Pieper, Ph.D., Jean-Christophe Fillion-Robin, M.S. &lt;br /&gt;
*Audience: First time users interested in a broad overview of Slicer’s features and tools.&lt;br /&gt;
*Length: 1h20m&lt;br /&gt;
|align=&amp;quot;right&amp;quot;|[[Image:Webinar.png|250px]]&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
----&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
{|width=&amp;quot;100%&amp;quot;&lt;br /&gt;
|&lt;br /&gt;
*The ''[[Documentation/{{documentation/version}}/Registration/RegistrationLibrary|Slicer Registration Case Library]]'' provides many real-life example cases of using the Slicer registration tools. They include the dataset and step-by-step instructions to follow and try yourself. &lt;br /&gt;
:Author: Dominik Meier, Ph.D.&lt;br /&gt;
:Audience:  users interested learning/applying Slicer image registration technology&lt;br /&gt;
|align=&amp;quot;right&amp;quot;|[[Image:RegLib_table.png|250px|link=http://wiki.slicer.org/slicerWiki/index.php/Documentation/{{documentation/version}}/Registration/RegistrationLibrary]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
= External Resources =&lt;br /&gt;
&lt;br /&gt;
== Murat Maga's blog posts about using 3D Slicer for biology ==&lt;br /&gt;
&lt;br /&gt;
* [https://blogs.uw.edu/maga/2017/04/11/getting-started-with-3d-slicer-as-a-biologist/ Slicer for Biologists]&lt;br /&gt;
* [https://blogs.uw.edu/maga/2017/04/11/a-worked-example-getting-and-visualizing-data-from-digimorph/ Loading data from DigiMorph]&lt;br /&gt;
* [https://blogs.uw.edu/maga/2017/04/11/morphosource-data-and-dealing-with-dicom-series-in-slicer/ Fixing problem DICOM]&lt;br /&gt;
* [https://blogs.uw.edu/maga/2017/04/12/scissors-tool-is-awesome/ Scissors tool is awesom]&lt;br /&gt;
 &lt;br /&gt;
== Using the (legacy) Editor ==&lt;br /&gt;
&lt;br /&gt;
This set of tutorials about the use of slicer in paleontology is very well written and provides step-by-step instructions.  Even though it covers slicer version 3.4, many of the concepts and techniques have applicability to the new version and to any 3D imaging field:&lt;br /&gt;
&lt;br /&gt;
* [http://openpaleo.blogspot.com/2008/12/3d-slicer-tutorial.html Open Source Paleontologist: 3D Slicer: The Tutorial]&lt;br /&gt;
* [http://openpaleo.blogspot.com/2008/12/3d-slicer-tutorial-part-ii.html Open Source Paleontologist: 3D Slicer: The Tutorial Part II]&lt;br /&gt;
* [http://openpaleo.blogspot.com/2008/12/3d-slicer-tutorial-part-iii.html Open Source Paleontologist: 3D Slicer: The Tutorial Part III]&lt;br /&gt;
* [http://openpaleo.blogspot.com/2008/12/3d-slicer-tutorial-part-iv.html Open Source Paleontologist: 3D Slicer: The Tutorial Part IV]&lt;br /&gt;
* [http://openpaleo.blogspot.com/2009/03/3d-slicer-tutorial-part-v.html Open Source Paleontologist: 3D Slicer: The Tutorial Part V]&lt;br /&gt;
* [http://openpaleo.blogspot.com/2009/03/3d-slicer-tutorial-part-vi.html Open Source Paleontologist: 3D Slicer: The Tutorial Part VI]&lt;br /&gt;
&lt;br /&gt;
== Team Contributions ==&lt;br /&gt;
See the collection of videos on the [http://vimeo.com/album/2363361 Kitware vimeo album].&lt;br /&gt;
&lt;br /&gt;
== User Contributions ==&lt;br /&gt;
See the [[Documentation/{{documentation/version}}/Training/UserContributions|User Contributions Page]] for more content.&lt;br /&gt;
&lt;br /&gt;
[http://www.youtube.com/results?search_query=3d+slicer&amp;amp;sm=3 YouTube videos about 3D Slicer]&lt;/div&gt;</summary>
		<author><name>Inorton</name></author>
		
	</entry>
	<entry>
		<id>https://www.slicer.org/w/index.php?title=Documentation/Nightly/Training&amp;diff=53475</id>
		<title>Documentation/Nightly/Training</title>
		<link rel="alternate" type="text/html" href="https://www.slicer.org/w/index.php?title=Documentation/Nightly/Training&amp;diff=53475"/>
		<updated>2017-07-20T20:58:07Z</updated>

		<summary type="html">&lt;p&gt;Inorton: Link to current UKF tutorial&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;noinclude&amp;gt;{{documentation/versioncheck}}&amp;lt;/noinclude&amp;gt;&lt;br /&gt;
=Introduction: Slicer {{documentation/version}} Tutorials=&lt;br /&gt;
&lt;br /&gt;
*This page contains &amp;quot;How to&amp;quot; tutorials with matched sample data sets. They demonstrate how to use the 3D Slicer environment (version {{documentation/version}} release) to accomplish certain tasks. &lt;br /&gt;
*For tutorials for other versions of Slicer, please visit the [[Training| Slicer training portal]].&lt;br /&gt;
*For &amp;quot;reference manual&amp;quot; style documentation, please visit the [[Documentation/{{documentation/version}}|Slicer {{documentation/version}} documentation page]]&lt;br /&gt;
*For questions related to the Slicer4 Training Compendium, please send an e-mail to '''[http://www.na-mic.org/Wiki/index.php/User:SPujol Sonia Pujol, Ph.D., Director of Training of 3D Slicer.]'''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
* Some of these tutorials are based on older releases of 3D Slicer.  The concepts are still useful but bear in mind that some interface elements and features will be different in updated versions.&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
=General Introduction=&lt;br /&gt;
&lt;br /&gt;
==Slicer Welcome Tutorial==&lt;br /&gt;
{|width=&amp;quot;100%&amp;quot;&lt;br /&gt;
|&lt;br /&gt;
*The [[media:SlicerWelcome-tutorial_Slicer4.5.pdf|SlicerWelcome tutorial]] is an introduction to Slicer based on the Welcome module.&lt;br /&gt;
*Author: Sonia Pujol, Ph.D.&lt;br /&gt;
*Audience: First time users who want a general introduction to the software.&lt;br /&gt;
*Modules: Welcome to Slicer, Sample Data&lt;br /&gt;
*Based on: 3D Slicer version 4.6&lt;br /&gt;
|align=&amp;quot;right&amp;quot;|&lt;br /&gt;
[[image:SlicerWelcome-image.png|250px|SlicerWelcome tutorial]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==Slicer4Minute Tutorial==&lt;br /&gt;
{|width=&amp;quot;100%&amp;quot;&lt;br /&gt;
|&lt;br /&gt;
*The [[media:Slicer4.5minute_SoniaPujol.pdf|Slicer4Minute tutorial]]  is a brief introduction to the advanced 3D visualization capabilities of Slicer 4.5.&lt;br /&gt;
*Author: Sonia Pujol, Ph.D.&lt;br /&gt;
*Audience: First time users who want to discover Slicer in 4 minutes.&lt;br /&gt;
*Modules: Welcome to Slicer, Models&lt;br /&gt;
*Based on: 3D Slicer version 4.5&lt;br /&gt;
*The [[media:Slicer4minute.zip|Slicer4Minute dataset]] contains an MR scan of the brain and 3D reconstructions of the anatomy&lt;br /&gt;
|align=&amp;quot;right&amp;quot;|&lt;br /&gt;
[[image:Slicer4minute-image.png|250px|right|Slicer4Minute tutorial]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==Slicer4 Data Loading and 3D Visualization ==&lt;br /&gt;
{|width=&amp;quot;100%&amp;quot;&lt;br /&gt;
|&lt;br /&gt;
*The [[Media:3DDataLoadingandVisualization_Slicer4.5_SoniaPujol.pdf | Data loading and 3D visualization]] course guides through the basics of loading and viewing volumes and 3D models in Slicer4 . &lt;br /&gt;
*Author: Sonia Pujol, Ph.D.&lt;br /&gt;
*Modules: Welcome to Slicer, Sample Data, Models.&lt;br /&gt;
*Audience: End-users&lt;br /&gt;
*Based on: 3D Slicer version 4.5&lt;br /&gt;
*The [[Media:3DVisualizationData.zip | 3DVisualization dataset]] contain an MR scan and a series of 3D models of the brain.&lt;br /&gt;
|align=&amp;quot;right&amp;quot;|&lt;br /&gt;
[[Image:Slicer4DataLoading_tutorial.png|right|250px|]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=Tutorials for software developers=&lt;br /&gt;
&lt;br /&gt;
== Slicer4 Programming Tutorial ==&lt;br /&gt;
{|width=&amp;quot;100%&amp;quot;&lt;br /&gt;
|&lt;br /&gt;
*The [https://1drv.ms/b/s!Arm_AFxB9yqHsIUKNqVboYvm4sgd4w Hello Python Programming tutorial] course guides through the integration of a python module in Slicer4. &lt;br /&gt;
*Author: Sonia Pujol, Ph.D., Steve Pieper, Ph.D.&lt;br /&gt;
*Audience: Developers&lt;br /&gt;
*Based on: 3D Slicer version 4.5&lt;br /&gt;
*The [https://1drv.ms/u/s!Arm_AFxB9yqHsIR2N_9krtTHTsTo1Q HelloPython dataset] contains sample data set (MR scan of the brain) and complete Python module examples.&lt;br /&gt;
|align=&amp;quot;right&amp;quot;|&lt;br /&gt;
[[Image:HelloPythonTutorial.png|right|250px|]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
For additional Python scripts examples, please visit the [[Documentation/{{documentation/version}}/ScriptRepository|Script Repository page]]&lt;br /&gt;
&lt;br /&gt;
==Developing and contributing extensions for 3D Slicer==&lt;br /&gt;
{|width=&amp;quot;100%&amp;quot;&lt;br /&gt;
|&lt;br /&gt;
*The [http://goo.gl/IP4cdg Developing and contributing extensions for 3D Slicer tutorial ] is an introduction to the internals of 3D Slicer and the process of contributing a 3D Slicer extension.&lt;br /&gt;
*Authors: Andrey Fedorov, Jean-Christophe Fillion-Robin, Steve Pieper&lt;br /&gt;
*Audience: Developers&lt;br /&gt;
*Based on: 3D Slicer version 4.4&lt;br /&gt;
|align=&amp;quot;right&amp;quot;|&lt;br /&gt;
[[Image:Contributing3DSlicerExtension.png|right|250px|]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=Specific functions=&lt;br /&gt;
&lt;br /&gt;
==Slicer4 Diffusion Tensor Imaging Tutorial ==&lt;br /&gt;
{|width=&amp;quot;100%&amp;quot;&lt;br /&gt;
|&lt;br /&gt;
*The [https://github.com/SlicerDMRI/slicerdmri.github.io/raw/master/docs/tutorials/DiffusionMRIanalysis.pdf Diffusion Tensor Imaging Tutorial]  course guides through the basics of loading Diffusion Weighted images in Slicer, estimating tensors and generating fiber tracts. &lt;br /&gt;
*Author: Sonia Pujol, Ph.D.&lt;br /&gt;
*Audience: End-users and developers&lt;br /&gt;
*Modules: Data, Volumes, DWI to DTI Estimation, Diffusion Tensor Scalar Measurements, Editor, Markups,Tractography Label Map Seeding, Tractography Interactive Seeding&lt;br /&gt;
*Based on: 3D Slicer version 4.5&lt;br /&gt;
*The [[media:Dti tutorial data.zip|DTI dataset]] contains an MR Diffusion Weighted Imaging scan of the brain.&lt;br /&gt;
|align=&amp;quot;right&amp;quot;|&lt;br /&gt;
[[Image:Slicer4DTI Tutorial.png|right|250px|]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==Slicer4 Neurosurgical Planning Tutorial==&lt;br /&gt;
{|width=&amp;quot;100%&amp;quot;&lt;br /&gt;
|&lt;br /&gt;
*The [https://github.com/SlicerDMRI/slicerdmri.github.io/raw/master/docs/tutorials/WhiteMatterExplorationTutorial.pdf Neurosurgical Planning tutorial] course guides through the generation of fiber tracts in the vicinity of a tumor.&lt;br /&gt;
*Author: Sonia Pujol, Ph.D., Ron Kikinis, M.D.&lt;br /&gt;
*Audience: End-users and developers&lt;br /&gt;
*Modules: Volumes, Editor, Tractography Label Map Seeding, Tractography Interactive Seeding&lt;br /&gt;
*Based on: 3D Slicer version 4.5&lt;br /&gt;
*The [[Media:WhiteMatterExplorationData.zip| White Matter Exploration datasets]] contains a Diffusion Weighted Imaging scan of  brain tumor patient.&lt;br /&gt;
|align=&amp;quot;right&amp;quot;|&lt;br /&gt;
[[Image:NeurosurgicalPlanningTutorial.png|right|250px|link=http://vimeo.com/67336069]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==Slicer4 3D Visualization of DICOM images for Radiology Applications==&lt;br /&gt;
{|width=&amp;quot;100%&amp;quot;&lt;br /&gt;
|&lt;br /&gt;
*The [[Media:3DSlicer_Dicom_RSNA2015_SoniaPujol.pdf |3D Visualization of DICOM images for Radiology Applications]]  course guides through 3D data loading and visualization of DICOM images for Radiology Applications in Slicer4. &lt;br /&gt;
*Author: Sonia Pujol, Ph.D., Kitt Shaffer, M.D., Ph.D., Ron Kikinis, M.D.&lt;br /&gt;
*Audience: Radiologists and users of Slicer who need a more comprehensive overview over Slicer4 visualization capabilities.&lt;br /&gt;
*Modules: DICOM, Volumes, Volume Rendering, Models.&lt;br /&gt;
*Based on: 3D Slicer version 4.5&lt;br /&gt;
*The [[Media:3DVisualization_DICOM_images_part1.zip‎  | 3DVisualizationDICOM_part1]] and [[Media:3DVisualization_DICOM_images_part2.zip | 3DVisualizationDICOM_part2]] datasets contain a series of MR and CT scans, and 3D models of the brain, lung and liver.&lt;br /&gt;
|align=&amp;quot;right&amp;quot;|&lt;br /&gt;
[[Image:Slicer4RSNA_2.png|right|250px|]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==Slicer4 Quantitative Imaging tutorial==&lt;br /&gt;
{|width=&amp;quot;100%&amp;quot;&lt;br /&gt;
|&lt;br /&gt;
*The [[media:QuantitativeImaging_Slicer4.5.pdf‎ | Slicer4 Quantitative Imaging tutorial]]  guides through the use for Slicer for quantifying small volumetric changes in slow-growing tumors, and for calculating Standardized Uptake Value (SUV) from PET/CT data.&lt;br /&gt;
*Authors: Sonia Pujol, Ph.D., Katarzyna Macura, M.D., Ron Kikinis, M.D.&lt;br /&gt;
*Audience: Radiologists and users of Slicer who need a more comprehensive overview over Slicer4 quantitative imaging capabilities.&lt;br /&gt;
*Modules: Data, Volumes, Models, Change Tracker, PET Standard Uptake Value Computation&lt;br /&gt;
*Based on: 3D Slicer version 4.5&lt;br /&gt;
*The [[media:QuantitativeImaging.zip‎| Quantitative Imaging dataset]]  contains a series of MR and PET/CT data.&lt;br /&gt;
|align=&amp;quot;right&amp;quot;|&lt;br /&gt;
[[Image:Slicer4_QuantitativeImaging.png|right|250px|]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Slicer4 IGT ==&lt;br /&gt;
{|width=&amp;quot;100%&amp;quot;&lt;br /&gt;
|&lt;br /&gt;
*[http://www.slicerigt.org/wp/user-tutorial/ Slicer IGT tutorials]&lt;br /&gt;
*Authors: Tamas Ungi, M.D, Ph.D., Junichi Tokuda, Ph.D.&lt;br /&gt;
*Audience: End-users interested in using Slicer for real-time navigated procedures. E.g. navigated needle insertions or other minimally invasive medical procedures.&lt;br /&gt;
*Modules: SlicerIGT Extension&lt;br /&gt;
*Based on: Slicer4.3.1-2014.09.14&lt;br /&gt;
*Data: [https://onedrive.live.com/redir?resid=7230D4DEC6058018!2937&amp;amp;authkey=!AGQkSCZOwjVYXw8&amp;amp;ithint=folder%2cpptx  Slicer-IGT datasets]&lt;br /&gt;
|align=&amp;quot;right&amp;quot;|&lt;br /&gt;
[[Image:SlicetIGT.png|right|150px|]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Slicer4 3D Printing ==&lt;br /&gt;
&lt;br /&gt;
{|width=&amp;quot;100%&amp;quot;&lt;br /&gt;
|&lt;br /&gt;
* The video tutorial [https://youtu.be/Uht6Fwtr9hE Segmenting a CT for 3D Printing of a Lumbar Phantom] shows how to use the Segment Editor of 3D Slicer for 3D printing using Slicer 4.7.&lt;br /&gt;
** Author: Hillary Lia&lt;br /&gt;
** Audience: Users and developers interested in 3D printing&lt;br /&gt;
* The [https://www.slicer.org/wiki/Documentation/4.6/Training#Segmentation_for_3D_printing Segmentation for 3D printing] shows how to use the Segment Editor of 3D Slicer for 3D printing using Slicer 4.6.&lt;br /&gt;
** Author: Csaba Pinter, MSc&lt;br /&gt;
** Audience: Users and developers interested in 3D printing&lt;br /&gt;
* This ''Slicer 4.3 [https://www.youtube.com/watch?v=MKLWzD0PiIc 3D printing tutorial]''  shows how to prepare 3D Slicer data for 3D printing using legacy Editor module.&lt;br /&gt;
** Authors: Nabgha Farhat, MSc&lt;br /&gt;
** Audience: Users and developers interested in 3D printing&lt;br /&gt;
|align=&amp;quot;right&amp;quot;|[[Image:20170717_3DPrintingTutorialYoutube.PNG|280px]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Slicer4 Image Registration ==&lt;br /&gt;
&lt;br /&gt;
{|width=&amp;quot;100%&amp;quot;&lt;br /&gt;
|&lt;br /&gt;
*The [https://www.slicer.org/slicerWiki/index.php/File:RegistrationTutorial_3DSlicer4.5_spujol.pdf Registration tutorial] shows how to perform intra- and inter-subject registration within Slicer.&lt;br /&gt;
* Authors: Sonia Pujol, Ph.D., Dominik Meier, Ph.D., Ron Kikinis, M.D.&lt;br /&gt;
* Audience: Users and developers interested in image registration&lt;br /&gt;
* Dataset: [[Media:RegistrationData.zip| 3D Slicer Registration Data]]&lt;br /&gt;
|align=&amp;quot;right&amp;quot;|[[File:registration_Slicer4.png|250px]]&lt;br /&gt;
|}&lt;br /&gt;
*Based on: 3D Slicer version 4.5&lt;br /&gt;
See [[Documentation/{{documentation/version}}/Registration/RegistrationLibrary|the Registration Library for worked out registration examples with data]].&lt;br /&gt;
&lt;br /&gt;
== Fast GrowCut ==&lt;br /&gt;
&lt;br /&gt;
{|width=&amp;quot;100%&amp;quot;&lt;br /&gt;
|&lt;br /&gt;
* The [[media:FastGrowCutTutorial.pdf |Fast GrowCut tutorial]]  shows how to perform a segmentation using the Fast GrowCut effect in Slicer.&lt;br /&gt;
* Authors: Hillary Lia&lt;br /&gt;
* Audience: Users interested in segmentation&lt;br /&gt;
|align=&amp;quot;right&amp;quot;|[[File:FastGrowCutLogo.png|200px]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==Slicer4 Radiation Therapy Tutorial ==&lt;br /&gt;
** The  [https://app.assembla.com/spaces/slicerrt/subversion/source/HEAD/trunk/SlicerRt/doc/tutorials/SlicerRT_TutorialIGRT_4.7.pdf?_format=raw SlicerRT tutorial] is an introduction to the Radiation Therapy functionalities of Slicer.&lt;br /&gt;
** Author: Csaba Pinter, Andras Lasso, An Wang, Gregory C. Sharp, David Jaffray, Gabor Fichtinger. &lt;br /&gt;
** Dataset: [http://slicer.kitware.com/midas3/download/item/205404/SlicerRT_WorldCongress_TutorialIGRT_Dataset.zip download] from MIDAS server&lt;br /&gt;
**Based on Slicer 4.7&lt;br /&gt;
&lt;br /&gt;
== Other ==&lt;br /&gt;
&lt;br /&gt;
Additional (non-curated) videos-based demonstrations using 3D Slicer are accessible on  [http://www.youtube.com/results?search_query=3d+slicer&amp;amp;sm=3 You Tube].&lt;br /&gt;
&lt;br /&gt;
= 3D Slicer Tutorial contests=&lt;br /&gt;
&lt;br /&gt;
==Winter 2017 Tutorial contest==&lt;br /&gt;
&lt;br /&gt;
===Segmentation for 3D printing===&lt;br /&gt;
{|width=&amp;quot;100%&amp;quot;&lt;br /&gt;
|&lt;br /&gt;
*The [https://www.assembla.com/spaces/slicerrt/documents/bmRQGEzzur54v-dmr6CpXy/download/bmRQGEzzur54v-dmr6CpXy Segmentation for 3D printing Tutorial] is an introduction to the new [[Documentation/{{documentation/version}}/Modules/SegmentEditor|Segment Editor]] module, demonstrated through the popular topic of 3D printing. &lt;br /&gt;
*Author: Csaba Pinter (Queen's University, Canada)&lt;br /&gt;
*Dataset: [[:File:BasePiece.zip|Phantom base STL model]] Source: [http://perk-software.cs.queensu.ca/plus/doc/nightly/modelcatalog/ PerkLab].&lt;br /&gt;
|align=&amp;quot;right&amp;quot;|&lt;br /&gt;
[[File:SlicerWinterProjectWeek2017-Segmentation-for-3d-printing.png | 200px]]. &lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===Slicer Pathology===&lt;br /&gt;
{|width=&amp;quot;100%&amp;quot;&lt;br /&gt;
|&lt;br /&gt;
*The [[Documentation/{{documentation/version}}/Extensions/SlicerPathology|Slicer Pathology Tutorial]] describes how to use the corresponding tools for automatic and semi-automatic pathology image segmentation.&lt;br /&gt;
*Author: Erich Bremer (Stonybrook), Andriy Fedorov (Brigham and Women’s Hospital)&lt;br /&gt;
*Dataset:  Available directly with the Slicer Pathology Slicer extension.&lt;br /&gt;
|align=&amp;quot;right&amp;quot;|&lt;br /&gt;
[[File:SlicerPathologyScreenShot8.png | 200px]]. &lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===Simple Python Tool for Quality Control of DWI data===&lt;br /&gt;
{|width=&amp;quot;100%&amp;quot;&lt;br /&gt;
|&lt;br /&gt;
*The [http://www.na-mic.org/Wiki/images/3/3a/SimpleDiffusionGradientInformationExtractorTutorial_Chauvin_Jan2017.pptx Simple Multi-shell Diffusion Gradients Information Extractor Tutorial] describes how to use a simple Python script for parsing multi-shell sensitizing gradients information from nifti file format (separated bvecs, bvals files).&lt;br /&gt;
*Author: Laurent Chauvin (ETS Montreal)&lt;br /&gt;
*Dataset:  Not available.&lt;br /&gt;
|align=&amp;quot;right&amp;quot;|&lt;br /&gt;
[[File:SlicerWinterProjectWeek2017-SimpleDiffusionGradientInformationExtractorTutorial.png | 200px]]. &lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===SPHARM-PDM===&lt;br /&gt;
{|width=&amp;quot;100%&amp;quot;&lt;br /&gt;
|&lt;br /&gt;
*The [https://www.nitrc.org/docman/view.php/308/1982/SPHARM-PDM_Tutorial_July2015.pdf SPHARM-PDM Tutorial] describes how to use SPHARM-PDM and ShapePopulationViewer Slicer extensions to respectively compute point-based models using a parametric boundary description for the computing of Shape Analysis and perform the quality control between the different models.&lt;br /&gt;
*Author: Jonathan Perdomo (UNC), Beatriz Paniagua (Kitware Inc.)&lt;br /&gt;
*Dataset:  [https://www.nitrc.org/docman/view.php/308/1981/SPHARM_Tutorial_Data_July2015.zip Tutorial Data]&lt;br /&gt;
|align=&amp;quot;right&amp;quot;|&lt;br /&gt;
[[File:SlicerWinterProjectWeek2017-SPHARM-PDM.png | 200px]]. &lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===Integration of Robot Operating System (ROS) and 3D Slicer using OpenIGTLink===&lt;br /&gt;
{|width=&amp;quot;100%&amp;quot;&lt;br /&gt;
|&lt;br /&gt;
*The [https://www.na-mic.org/Wiki/images/a/ab/ROSIGTLTutorial_Tokuda_Jan2017.pptx Integration of Robot Operating System (ROS) and 3D Slicer using OpenIGTLink Tutorial] describes the software architecture of surgical robot systems and allows to acquire hands-on experience of software-hardware integration for medical robotics.&lt;br /&gt;
*Author: Junichi Tokuda (Brigham and Women’s Hospital)&lt;br /&gt;
*Dataset:  Not available.&lt;br /&gt;
|align=&amp;quot;right&amp;quot;|&lt;br /&gt;
[[File:SlicerWinterProjectWeek2017-Integration-ROS-3DSlicer-OpenIGTLink.png | 200px]]. &lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===Fiber Bundle Volume Measurement===&lt;br /&gt;
{|width=&amp;quot;100%&amp;quot;&lt;br /&gt;
|&lt;br /&gt;
*The [http://www.na-mic.org/Wiki/images/5/57/Fiber_Bundle_Volume_Measurement.pptx Fiber Bundle Volume Measurement Tutorial] aim is to calculate the volume of the fiber bundle that passes through the Corpus Callosum(CC). Following this tutorial, you’ll be able to (1) convert fiber bundles to label map and (2) calculate volume measurements from the fiber bundles.&lt;br /&gt;
*Author: Shun Gong (Shanghai Changzheng Hospital, China)&lt;br /&gt;
*Dataset:  [http://www.na-mic.org/Wiki/images/4/4c/FiberVolume_data.zip Tutorial data]: The following data are provided: Baseline image, Down sampled whole brain tractography (conducted as in the [[Documentation/{{documentation/version}}/Training#Slicer4_Diffusion_Tensor_Imaging_Tutorial|DWI tutorial]] and down-sampled to about 10000 fibers using Tractography Display module), Corpus callosum label map (drawn as in the [[Documentation/{{documentation/version}}/Training#Slicer4_Diffusion_Tensor_Imaging_Tutorial|DWI tutorial]]).&lt;br /&gt;
|align=&amp;quot;right&amp;quot;|&lt;br /&gt;
[[File:SlicerWinterProjectWeek2017-FiberBundleVolumeMeasurements.png | 200px]]. &lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==Winter 2016 Tutorial contest==&lt;br /&gt;
&lt;br /&gt;
===Subject Hierarchy===&lt;br /&gt;
{|width=&amp;quot;100%&amp;quot;&lt;br /&gt;
|&lt;br /&gt;
*The [http://wiki.na-mic.org/Wiki/images/2/27/SubjectHierarchy.TutorialContestWinter2016.pdf Subject Hierarchy] tutorial demonstrates the basic usage and potential of Slicer’s data manager module Subject Hierarchy using a two-timepoint radiotherapy phantom dataset.&lt;br /&gt;
*Author: Csaba Pinter, Queen's University, Canada&lt;br /&gt;
*Dataset:  [http://slicer.kitware.com/midas3/download/item/205404/SlicerRT_WorldCongress_TutorialIGRT_Dataset.zip SlicerRT_WorldCongress_TutorialIGRT_Dataset] The tutorial dataset is a two-timepoint phantom dataset taken from a RANDO head&amp;amp;neck phantom. It contains two studies, the planning one is a DICOM study consisting of a CT grayscale image and radiotherapy data: contours, dose distribution, treatment beams, plan information. The second timepoint consists of a CT NRRD volume and a dose NRRD volume.&lt;br /&gt;
|align=&amp;quot;right&amp;quot;|&lt;br /&gt;
[[File:SubjectHierarchyTutorial.png | 200px]]. &lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===Fiber Bundle Selection and Scalar Measurements===&lt;br /&gt;
{|width=&amp;quot;100%&amp;quot;&lt;br /&gt;
|&lt;br /&gt;
*The [[media:FiberBundleSelectionAndScalarMeasurement_TutorialContestWinter2016.pdf | Fiber Bundle Selection and Scalar Measurements]] tutorial guides through the use of the Diffusion Bundle Selection module and the Fiber Tract Scalar Measurement module for diffusion MRI tractography data analysis.&lt;br /&gt;
*Author: Fan Zhang, University of Sydney Australia, Brigham and Women's Hospital&lt;br /&gt;
*Dataset:  [[media:FiberBundleSelectionAndScalarMeasurement_TutorialContestWinter2016.zip| Fiber Bundle Selection And Scalar Measurement Tutorial Dataset]]&lt;br /&gt;
|align=&amp;quot;right&amp;quot;|&lt;br /&gt;
[[File:FiberBundleSelectionAndScalarMeasurement_TutorialContestWinter2016_Snapshot.png|200px]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===Plastimatch ===&lt;br /&gt;
{|width=&amp;quot;100%&amp;quot;&lt;br /&gt;
|&lt;br /&gt;
*The [http://www.na-mic.org/Wiki/images/5/5c/Plastimatch_TutorialContestWinter2016.pdf Plastimatch tutorial] guides through registration and wrapping of DICOM and DICOM-RT data using the Plastimatch extension of 3D Slicer.&lt;br /&gt;
*Author: Gregory Sharp, Massachusetts General Hospital&lt;br /&gt;
*Dataset:  [http://www.na-mic.org/Wiki/index.php/File:Plastimatch_TutorialContestWinter2016.zip Plastimatch Tutorial Dataset]&lt;br /&gt;
|align=&amp;quot;right&amp;quot;|&lt;br /&gt;
[[File:PlastimatchTutorial_Winter2016Contest.png|200px]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===UKF ===&lt;br /&gt;
{|width=&amp;quot;100%&amp;quot;&lt;br /&gt;
|&lt;br /&gt;
*The [https://github.com/SlicerDMRI/slicerdmri.github.io/raw/master/docs/tutorials/UKFTractography.pdf UKF tutorial] guides through the use of the Unscented Kalman Filter (UKF) tractography module. &lt;br /&gt;
*Author: Pegah Kahali, Brigham and Women's Hopital&lt;br /&gt;
*Dataset:  [http://www.na-mic.org/Wiki/index.php/File:UKF-Tractography_TutorialContestWinter2016.zip UKF tutorial Dataset]&lt;br /&gt;
|align=&amp;quot;right&amp;quot;|&lt;br /&gt;
[[File:UKF_Winter2016.png|200px]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==Summer 2014 Tutorial contest== &lt;br /&gt;
&lt;br /&gt;
===Cardiac Agatston Tutorial===&lt;br /&gt;
{|width=&amp;quot;100%&amp;quot;&lt;br /&gt;
|&lt;br /&gt;
*[http://wiki.na-mic.org/Wiki/index.php/File:TutorialContest_CardiacAgatstonScoring_2014.pdf  Cardiac Agatston Scoring Tutorial]&lt;br /&gt;
*Authors:   Jessica Forbes, Hans Johnson, University of Iowa&lt;br /&gt;
*Dataset:  [http://wiki.na-mic.org/Wiki/index.php/File:CardiacAgatstonMeasures_TutorialContestSummer2014.zip Cardiac Agatston Scoring Tutorial Dataset]&lt;br /&gt;
|align=&amp;quot;right&amp;quot;|&lt;br /&gt;
[[File:CardiacAgatstonMeasuresModuleScreenshot.jpg| 250px]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===CMR Toolkit LA workflow===&lt;br /&gt;
{|width=&amp;quot;100%&amp;quot;&lt;br /&gt;
|&lt;br /&gt;
*[http://wiki.na-mic.org/Wiki/index.php/File:CMRToolkitLAWorkflow_TutorialContestSummer2014.pdf  CMR Toolkit LA Workflow Tutorial]&lt;br /&gt;
*Authors: Salma Bengali, Josh Cates, University of Utah&lt;br /&gt;
*Dataset:  [http://wiki.na-mic.org/Wiki/index.php/File:CMRToolkitLAWorkflowData_TutorialContestSummer2014.zip CMRToolkitLAWorkflow Dataset]&lt;br /&gt;
|align=&amp;quot;right&amp;quot;|&lt;br /&gt;
[[Image:Utah_SummerContest2014_tutorial.png|300px]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==Summer 2013 Tutorial contest==&lt;br /&gt;
&lt;br /&gt;
===Cardiac MRI Toolkit===&lt;br /&gt;
{|width=&amp;quot;100%&amp;quot;&lt;br /&gt;
|&lt;br /&gt;
*[[Media:Cardiac MRI Toolkit Tutorial Summer2013.pdf|Cardiac MRI Toolkit]]&lt;br /&gt;
*Authors:   Salma Bengali, Josh Cates, SCI, Utah&lt;br /&gt;
*Dataset:  [[Media:Cardiac_MRI_Toolkit_Tutorial_Data.zip|Cardiac MRI Toolkit Tutorial Dataset]]&lt;br /&gt;
|align=&amp;quot;right&amp;quot;|&lt;br /&gt;
[[Image:CMRToolkit_Tutorial_Image.png|250px]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===HelloCLI===&lt;br /&gt;
{|width=&amp;quot;100%&amp;quot;&lt;br /&gt;
|&lt;br /&gt;
*[[Media:Hello_CLI_TutorialContestSummer2013.pdf|HelloCLI]]&lt;br /&gt;
*Authors:   Nadya Shusharina, Greg Sharp, MGH, Boston&lt;br /&gt;
*Dataset:  [[Media:Hello_CLI_TutorialContestSummer2013.zip‎|HelloCLI Dataset]]&lt;br /&gt;
|align=&amp;quot;right&amp;quot;|&lt;br /&gt;
[[Image:Cli_icon.png|300px]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===SlicerRT===&lt;br /&gt;
{|width=&amp;quot;100%&amp;quot;&lt;br /&gt;
|&lt;br /&gt;
*[[Media:SlicerRT_TutorialContestSummer2013.pdf|SlicerRT Tutorial]]&lt;br /&gt;
*Authors:    Csaba Pinter, Andras Lasso (Queen's), Kevin Wang (PMH, Toronto)&lt;br /&gt;
*Dataset:  [[Media:CsabaPinter-SlicerRtTutorial_Namic2013June.zip|SlicerRT Dataset]] &lt;br /&gt;
|align=&amp;quot;right&amp;quot;|&lt;br /&gt;
[[Image:667px-SlicerRT_0.10_IsocenterShiftingEvaluation.png|250px]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===DTIPrep===&lt;br /&gt;
{|width=&amp;quot;100%&amp;quot;&lt;br /&gt;
|&lt;br /&gt;
*[[Media:DTIPrep_TutorialContestSummer2013.pdf|DTIPrep]]&lt;br /&gt;
*Authors:    Dave Welch, SINAPSE, IOWA &lt;br /&gt;
*Dataset:  [[Media:DTIPrepData_TutorialContestSummer2013.zip|DTIPrep Dataset]]&lt;br /&gt;
|align=&amp;quot;right&amp;quot;|&lt;br /&gt;
[[Image:DTIPrep-tutorial.png|250px]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Summer 2012 Tutorial contest == &lt;br /&gt;
&lt;br /&gt;
===Automatic Left Atrial Scar Segmenter ===&lt;br /&gt;
{|width=&amp;quot;100%&amp;quot;&lt;br /&gt;
|&lt;br /&gt;
*[http://wiki.na-mic.org/Wiki/index.php/CARMA-LA-Scar_TutorialContestSummer2012 Automatic Left Atrial Scar Segmenter] &lt;br /&gt;
*Authors:  Greg Gardner, Josh Cates, SCI, Utah&lt;br /&gt;
*Dataset: [http://wiki.na-mic.org/Wiki/index.php/File:CARMA-LA-Scar_TutorialContestSummer2012.zip CARMA-LA-Scar data]&lt;br /&gt;
|align=&amp;quot;right&amp;quot;|&lt;br /&gt;
[[Image:Carma afib auto scar.png|250px]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===Qualitative and quantitative comparison of  two RT dose distributions===&lt;br /&gt;
{|width=&amp;quot;100%&amp;quot;&lt;br /&gt;
|&lt;br /&gt;
*[http://www.na-mic.org/Wiki/index.php/File:PlastimatchDose_TutorialContestSummer2012.pdf Qualitative and quantitative comparison of  two RT dose distributions]&lt;br /&gt;
*Authors:  James Shackleford, Nadya Shusharina, Greg Sharp, MGH&lt;br /&gt;
|align=&amp;quot;right&amp;quot;|&lt;br /&gt;
[[Image:PlastimatchDose.png|250px]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===Dose accumulation for adaptive radiation therapy===&lt;br /&gt;
{|width=&amp;quot;100%&amp;quot;&lt;br /&gt;
|&lt;br /&gt;
*[http://www.na-mic.org/Wiki/index.php/File:DoseAccumulationforAdaptiveRadiationTherapy_TutorialContestSummer2012.pdf Dose accumulation for adaptive radiation therapy]&lt;br /&gt;
*Authors:  Kevin Wang, Csaba Pinter, Andras Lasso, PMH, Queen's&lt;br /&gt;
|align=&amp;quot;right&amp;quot;|&lt;br /&gt;
[[Image:AdaptiveradiationTherapy.png|250px]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===WebGL Export===&lt;br /&gt;
{|width=&amp;quot;100%&amp;quot;&lt;br /&gt;
|&lt;br /&gt;
*[http://www.na-mic.org/Wiki/index.php/File:WebGLExport_TutorialContestSummer2012.pdf  WebdGLExport]&lt;br /&gt;
*Authors:  Nicolas Rannou, Daniel Haehn, Children's Hospital&lt;br /&gt;
|align=&amp;quot;right&amp;quot;|&lt;br /&gt;
[[Image:WebGLExport.png|250px]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===OpenIGTLink===&lt;br /&gt;
{|width=&amp;quot;100%&amp;quot;&lt;br /&gt;
|&lt;br /&gt;
*[http://wiki.slicer.org/slicerWiki/images/f/f1/OpenIGTLinkTutorial_Slicer4.1.0_JunichiTokuda_Apr2012.pdf OpenIGTLink]&lt;br /&gt;
*Authors:  Junichi Tokuda, BWH&lt;br /&gt;
|align=&amp;quot;right&amp;quot;|&lt;br /&gt;
[[Image:OpenIGTLink.png|250px]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=Additional resources =&lt;br /&gt;
{|width=&amp;quot;100%&amp;quot;&lt;br /&gt;
|&lt;br /&gt;
* This ''Slicer 4.1 [http://vimeo.com/41096643 webinar]'' presents the new features and improvements of the release, and a brief overview of work for the next release.&lt;br /&gt;
* Authors: Steve Pieper Ph.D.&lt;br /&gt;
* Audience: First time users and developers interested in Slicer 4.1 new features.&lt;br /&gt;
* Length: 0h20m&lt;br /&gt;
|align=&amp;quot;right&amp;quot;|[[Image:Webinar-Slicer-4.1.png|250px]]&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
----&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
{|width=&amp;quot;100%&amp;quot;&lt;br /&gt;
|&lt;br /&gt;
*This ''Intro to Slicer 4.0 [http://vimeo.com/37671358 webinar]'' provides an introduction to 3DSlicer, and demonstrates core functionalities such as loading, visualizing and saving data. Basic processing tools, including manual registration, manual segmentation and tractography tools are also highlighted. This webinar is a general overview. For in depth information see the modules above and the documentation pages.&lt;br /&gt;
*Authors: Julien Finet, M.S., Steve Pieper, Ph.D., Jean-Christophe Fillion-Robin, M.S. &lt;br /&gt;
*Audience: First time users interested in a broad overview of Slicer’s features and tools.&lt;br /&gt;
*Length: 1h20m&lt;br /&gt;
|align=&amp;quot;right&amp;quot;|[[Image:Webinar.png|250px]]&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
----&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
{|width=&amp;quot;100%&amp;quot;&lt;br /&gt;
|&lt;br /&gt;
*The ''[[Documentation/{{documentation/version}}/Registration/RegistrationLibrary|Slicer Registration Case Library]]'' provides many real-life example cases of using the Slicer registration tools. They include the dataset and step-by-step instructions to follow and try yourself. &lt;br /&gt;
:Author: Dominik Meier, Ph.D.&lt;br /&gt;
:Audience:  users interested learning/applying Slicer image registration technology&lt;br /&gt;
|align=&amp;quot;right&amp;quot;|[[Image:RegLib_table.png|250px|link=http://wiki.slicer.org/slicerWiki/index.php/Documentation/{{documentation/version}}/Registration/RegistrationLibrary]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
= External Resources =&lt;br /&gt;
&lt;br /&gt;
== Murat Maga's blog posts about using 3D Slicer for biology ==&lt;br /&gt;
&lt;br /&gt;
* [https://blogs.uw.edu/maga/2017/04/11/getting-started-with-3d-slicer-as-a-biologist/ Slicer for Biologists]&lt;br /&gt;
* [https://blogs.uw.edu/maga/2017/04/11/a-worked-example-getting-and-visualizing-data-from-digimorph/ Loading data from DigiMorph]&lt;br /&gt;
* [https://blogs.uw.edu/maga/2017/04/11/morphosource-data-and-dealing-with-dicom-series-in-slicer/ Fixing problem DICOM]&lt;br /&gt;
* [https://blogs.uw.edu/maga/2017/04/12/scissors-tool-is-awesome/ Scissors tool is awesom]&lt;br /&gt;
 &lt;br /&gt;
== Using the (legacy) Editor ==&lt;br /&gt;
&lt;br /&gt;
This set of tutorials about the use of slicer in paleontology is very well written and provides step-by-step instructions.  Even though it covers slicer version 3.4, many of the concepts and techniques have applicability to the new version and to any 3D imaging field:&lt;br /&gt;
&lt;br /&gt;
* [http://openpaleo.blogspot.com/2008/12/3d-slicer-tutorial.html Open Source Paleontologist: 3D Slicer: The Tutorial]&lt;br /&gt;
* [http://openpaleo.blogspot.com/2008/12/3d-slicer-tutorial-part-ii.html Open Source Paleontologist: 3D Slicer: The Tutorial Part II]&lt;br /&gt;
* [http://openpaleo.blogspot.com/2008/12/3d-slicer-tutorial-part-iii.html Open Source Paleontologist: 3D Slicer: The Tutorial Part III]&lt;br /&gt;
* [http://openpaleo.blogspot.com/2008/12/3d-slicer-tutorial-part-iv.html Open Source Paleontologist: 3D Slicer: The Tutorial Part IV]&lt;br /&gt;
* [http://openpaleo.blogspot.com/2009/03/3d-slicer-tutorial-part-v.html Open Source Paleontologist: 3D Slicer: The Tutorial Part V]&lt;br /&gt;
* [http://openpaleo.blogspot.com/2009/03/3d-slicer-tutorial-part-vi.html Open Source Paleontologist: 3D Slicer: The Tutorial Part VI]&lt;br /&gt;
&lt;br /&gt;
== Team Contributions ==&lt;br /&gt;
See the collection of videos on the [http://vimeo.com/album/2363361 Kitware vimeo album].&lt;br /&gt;
&lt;br /&gt;
== User Contributions ==&lt;br /&gt;
See the [[Documentation/{{documentation/version}}/Training/UserContributions|User Contributions Page]] for more content.&lt;br /&gt;
&lt;br /&gt;
[http://www.youtube.com/results?search_query=3d+slicer&amp;amp;sm=3 YouTube videos about 3D Slicer]&lt;/div&gt;</summary>
		<author><name>Inorton</name></author>
		
	</entry>
	<entry>
		<id>https://www.slicer.org/w/index.php?title=Documentation/Nightly/Training&amp;diff=53472</id>
		<title>Documentation/Nightly/Training</title>
		<link rel="alternate" type="text/html" href="https://www.slicer.org/w/index.php?title=Documentation/Nightly/Training&amp;diff=53472"/>
		<updated>2017-07-20T20:57:15Z</updated>

		<summary type="html">&lt;p&gt;Inorton: Link updated Neurosurgical planning PDF&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;noinclude&amp;gt;{{documentation/versioncheck}}&amp;lt;/noinclude&amp;gt;&lt;br /&gt;
=Introduction: Slicer {{documentation/version}} Tutorials=&lt;br /&gt;
&lt;br /&gt;
*This page contains &amp;quot;How to&amp;quot; tutorials with matched sample data sets. They demonstrate how to use the 3D Slicer environment (version {{documentation/version}} release) to accomplish certain tasks. &lt;br /&gt;
*For tutorials for other versions of Slicer, please visit the [[Training| Slicer training portal]].&lt;br /&gt;
*For &amp;quot;reference manual&amp;quot; style documentation, please visit the [[Documentation/{{documentation/version}}|Slicer {{documentation/version}} documentation page]]&lt;br /&gt;
*For questions related to the Slicer4 Training Compendium, please send an e-mail to '''[http://www.na-mic.org/Wiki/index.php/User:SPujol Sonia Pujol, Ph.D., Director of Training of 3D Slicer.]'''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
* Some of these tutorials are based on older releases of 3D Slicer.  The concepts are still useful but bear in mind that some interface elements and features will be different in updated versions.&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
=General Introduction=&lt;br /&gt;
&lt;br /&gt;
==Slicer Welcome Tutorial==&lt;br /&gt;
{|width=&amp;quot;100%&amp;quot;&lt;br /&gt;
|&lt;br /&gt;
*The [[media:SlicerWelcome-tutorial_Slicer4.5.pdf|SlicerWelcome tutorial]] is an introduction to Slicer based on the Welcome module.&lt;br /&gt;
*Author: Sonia Pujol, Ph.D.&lt;br /&gt;
*Audience: First time users who want a general introduction to the software.&lt;br /&gt;
*Modules: Welcome to Slicer, Sample Data&lt;br /&gt;
*Based on: 3D Slicer version 4.6&lt;br /&gt;
|align=&amp;quot;right&amp;quot;|&lt;br /&gt;
[[image:SlicerWelcome-image.png|250px|SlicerWelcome tutorial]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==Slicer4Minute Tutorial==&lt;br /&gt;
{|width=&amp;quot;100%&amp;quot;&lt;br /&gt;
|&lt;br /&gt;
*The [[media:Slicer4.5minute_SoniaPujol.pdf|Slicer4Minute tutorial]]  is a brief introduction to the advanced 3D visualization capabilities of Slicer 4.5.&lt;br /&gt;
*Author: Sonia Pujol, Ph.D.&lt;br /&gt;
*Audience: First time users who want to discover Slicer in 4 minutes.&lt;br /&gt;
*Modules: Welcome to Slicer, Models&lt;br /&gt;
*Based on: 3D Slicer version 4.5&lt;br /&gt;
*The [[media:Slicer4minute.zip|Slicer4Minute dataset]] contains an MR scan of the brain and 3D reconstructions of the anatomy&lt;br /&gt;
|align=&amp;quot;right&amp;quot;|&lt;br /&gt;
[[image:Slicer4minute-image.png|250px|right|Slicer4Minute tutorial]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==Slicer4 Data Loading and 3D Visualization ==&lt;br /&gt;
{|width=&amp;quot;100%&amp;quot;&lt;br /&gt;
|&lt;br /&gt;
*The [[Media:3DDataLoadingandVisualization_Slicer4.5_SoniaPujol.pdf | Data loading and 3D visualization]] course guides through the basics of loading and viewing volumes and 3D models in Slicer4 . &lt;br /&gt;
*Author: Sonia Pujol, Ph.D.&lt;br /&gt;
*Modules: Welcome to Slicer, Sample Data, Models.&lt;br /&gt;
*Audience: End-users&lt;br /&gt;
*Based on: 3D Slicer version 4.5&lt;br /&gt;
*The [[Media:3DVisualizationData.zip | 3DVisualization dataset]] contain an MR scan and a series of 3D models of the brain.&lt;br /&gt;
|align=&amp;quot;right&amp;quot;|&lt;br /&gt;
[[Image:Slicer4DataLoading_tutorial.png|right|250px|]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=Tutorials for software developers=&lt;br /&gt;
&lt;br /&gt;
== Slicer4 Programming Tutorial ==&lt;br /&gt;
{|width=&amp;quot;100%&amp;quot;&lt;br /&gt;
|&lt;br /&gt;
*The [https://1drv.ms/b/s!Arm_AFxB9yqHsIUKNqVboYvm4sgd4w Hello Python Programming tutorial] course guides through the integration of a python module in Slicer4. &lt;br /&gt;
*Author: Sonia Pujol, Ph.D., Steve Pieper, Ph.D.&lt;br /&gt;
*Audience: Developers&lt;br /&gt;
*Based on: 3D Slicer version 4.5&lt;br /&gt;
*The [https://1drv.ms/u/s!Arm_AFxB9yqHsIR2N_9krtTHTsTo1Q HelloPython dataset] contains sample data set (MR scan of the brain) and complete Python module examples.&lt;br /&gt;
|align=&amp;quot;right&amp;quot;|&lt;br /&gt;
[[Image:HelloPythonTutorial.png|right|250px|]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
For additional Python scripts examples, please visit the [[Documentation/{{documentation/version}}/ScriptRepository|Script Repository page]]&lt;br /&gt;
&lt;br /&gt;
==Developing and contributing extensions for 3D Slicer==&lt;br /&gt;
{|width=&amp;quot;100%&amp;quot;&lt;br /&gt;
|&lt;br /&gt;
*The [http://goo.gl/IP4cdg Developing and contributing extensions for 3D Slicer tutorial ] is an introduction to the internals of 3D Slicer and the process of contributing a 3D Slicer extension.&lt;br /&gt;
*Authors: Andrey Fedorov, Jean-Christophe Fillion-Robin, Steve Pieper&lt;br /&gt;
*Audience: Developers&lt;br /&gt;
*Based on: 3D Slicer version 4.4&lt;br /&gt;
|align=&amp;quot;right&amp;quot;|&lt;br /&gt;
[[Image:Contributing3DSlicerExtension.png|right|250px|]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=Specific functions=&lt;br /&gt;
&lt;br /&gt;
==Slicer4 Diffusion Tensor Imaging Tutorial ==&lt;br /&gt;
{|width=&amp;quot;100%&amp;quot;&lt;br /&gt;
|&lt;br /&gt;
*The [https://github.com/SlicerDMRI/slicerdmri.github.io/raw/master/docs/tutorials/DiffusionMRIanalysis.pdf Diffusion Tensor Imaging Tutorial]  course guides through the basics of loading Diffusion Weighted images in Slicer, estimating tensors and generating fiber tracts. &lt;br /&gt;
*Author: Sonia Pujol, Ph.D.&lt;br /&gt;
*Audience: End-users and developers&lt;br /&gt;
*Modules: Data, Volumes, DWI to DTI Estimation, Diffusion Tensor Scalar Measurements, Editor, Markups,Tractography Label Map Seeding, Tractography Interactive Seeding&lt;br /&gt;
*Based on: 3D Slicer version 4.5&lt;br /&gt;
*The [[media:Dti tutorial data.zip|DTI dataset]] contains an MR Diffusion Weighted Imaging scan of the brain.&lt;br /&gt;
|align=&amp;quot;right&amp;quot;|&lt;br /&gt;
[[Image:Slicer4DTI Tutorial.png|right|250px|]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==Slicer4 Neurosurgical Planning Tutorial==&lt;br /&gt;
{|width=&amp;quot;100%&amp;quot;&lt;br /&gt;
|&lt;br /&gt;
*The [https://github.com/SlicerDMRI/slicerdmri.github.io/raw/master/docs/tutorials/WhiteMatterExplorationTutorial.pdf Neurosurgical Planning tutorial] course guides through the generation of fiber tracts in the vicinity of a tumor.&lt;br /&gt;
*Author: Sonia Pujol, Ph.D., Ron Kikinis, M.D.&lt;br /&gt;
*Audience: End-users and developers&lt;br /&gt;
*Modules: Volumes, Editor, Tractography Label Map Seeding, Tractography Interactive Seeding&lt;br /&gt;
*Based on: 3D Slicer version 4.5&lt;br /&gt;
*The [[Media:WhiteMatterExplorationData.zip| White Matter Exploration datasets]] contains a Diffusion Weighted Imaging scan of  brain tumor patient.&lt;br /&gt;
|align=&amp;quot;right&amp;quot;|&lt;br /&gt;
[[Image:NeurosurgicalPlanningTutorial.png|right|250px|link=http://vimeo.com/67336069]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==Slicer4 3D Visualization of DICOM images for Radiology Applications==&lt;br /&gt;
{|width=&amp;quot;100%&amp;quot;&lt;br /&gt;
|&lt;br /&gt;
*The [[Media:3DSlicer_Dicom_RSNA2015_SoniaPujol.pdf |3D Visualization of DICOM images for Radiology Applications]]  course guides through 3D data loading and visualization of DICOM images for Radiology Applications in Slicer4. &lt;br /&gt;
*Author: Sonia Pujol, Ph.D., Kitt Shaffer, M.D., Ph.D., Ron Kikinis, M.D.&lt;br /&gt;
*Audience: Radiologists and users of Slicer who need a more comprehensive overview over Slicer4 visualization capabilities.&lt;br /&gt;
*Modules: DICOM, Volumes, Volume Rendering, Models.&lt;br /&gt;
*Based on: 3D Slicer version 4.5&lt;br /&gt;
*The [[Media:3DVisualization_DICOM_images_part1.zip‎  | 3DVisualizationDICOM_part1]] and [[Media:3DVisualization_DICOM_images_part2.zip | 3DVisualizationDICOM_part2]] datasets contain a series of MR and CT scans, and 3D models of the brain, lung and liver.&lt;br /&gt;
|align=&amp;quot;right&amp;quot;|&lt;br /&gt;
[[Image:Slicer4RSNA_2.png|right|250px|]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==Slicer4 Quantitative Imaging tutorial==&lt;br /&gt;
{|width=&amp;quot;100%&amp;quot;&lt;br /&gt;
|&lt;br /&gt;
*The [[media:QuantitativeImaging_Slicer4.5.pdf‎ | Slicer4 Quantitative Imaging tutorial]]  guides through the use for Slicer for quantifying small volumetric changes in slow-growing tumors, and for calculating Standardized Uptake Value (SUV) from PET/CT data.&lt;br /&gt;
*Authors: Sonia Pujol, Ph.D., Katarzyna Macura, M.D., Ron Kikinis, M.D.&lt;br /&gt;
*Audience: Radiologists and users of Slicer who need a more comprehensive overview over Slicer4 quantitative imaging capabilities.&lt;br /&gt;
*Modules: Data, Volumes, Models, Change Tracker, PET Standard Uptake Value Computation&lt;br /&gt;
*Based on: 3D Slicer version 4.5&lt;br /&gt;
*The [[media:QuantitativeImaging.zip‎| Quantitative Imaging dataset]]  contains a series of MR and PET/CT data.&lt;br /&gt;
|align=&amp;quot;right&amp;quot;|&lt;br /&gt;
[[Image:Slicer4_QuantitativeImaging.png|right|250px|]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Slicer4 IGT ==&lt;br /&gt;
{|width=&amp;quot;100%&amp;quot;&lt;br /&gt;
|&lt;br /&gt;
*[http://www.slicerigt.org/wp/user-tutorial/ Slicer IGT tutorials]&lt;br /&gt;
*Authors: Tamas Ungi, M.D, Ph.D., Junichi Tokuda, Ph.D.&lt;br /&gt;
*Audience: End-users interested in using Slicer for real-time navigated procedures. E.g. navigated needle insertions or other minimally invasive medical procedures.&lt;br /&gt;
*Modules: SlicerIGT Extension&lt;br /&gt;
*Based on: Slicer4.3.1-2014.09.14&lt;br /&gt;
*Data: [https://onedrive.live.com/redir?resid=7230D4DEC6058018!2937&amp;amp;authkey=!AGQkSCZOwjVYXw8&amp;amp;ithint=folder%2cpptx  Slicer-IGT datasets]&lt;br /&gt;
|align=&amp;quot;right&amp;quot;|&lt;br /&gt;
[[Image:SlicetIGT.png|right|150px|]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Slicer4 3D Printing ==&lt;br /&gt;
&lt;br /&gt;
{|width=&amp;quot;100%&amp;quot;&lt;br /&gt;
|&lt;br /&gt;
* The video tutorial [https://youtu.be/Uht6Fwtr9hE Segmenting a CT for 3D Printing of a Lumbar Phantom] shows how to use the Segment Editor of 3D Slicer for 3D printing using Slicer 4.7.&lt;br /&gt;
** Author: Hillary Lia&lt;br /&gt;
** Audience: Users and developers interested in 3D printing&lt;br /&gt;
* The [https://www.slicer.org/wiki/Documentation/4.6/Training#Segmentation_for_3D_printing Segmentation for 3D printing] shows how to use the Segment Editor of 3D Slicer for 3D printing using Slicer 4.6.&lt;br /&gt;
** Author: Csaba Pinter, MSc&lt;br /&gt;
** Audience: Users and developers interested in 3D printing&lt;br /&gt;
* This ''Slicer 4.3 [https://www.youtube.com/watch?v=MKLWzD0PiIc 3D printing tutorial]''  shows how to prepare 3D Slicer data for 3D printing using legacy Editor module.&lt;br /&gt;
** Authors: Nabgha Farhat, MSc&lt;br /&gt;
** Audience: Users and developers interested in 3D printing&lt;br /&gt;
|align=&amp;quot;right&amp;quot;|[[Image:20170717_3DPrintingTutorialYoutube.PNG|280px]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Slicer4 Image Registration ==&lt;br /&gt;
&lt;br /&gt;
{|width=&amp;quot;100%&amp;quot;&lt;br /&gt;
|&lt;br /&gt;
*The [https://www.slicer.org/slicerWiki/index.php/File:RegistrationTutorial_3DSlicer4.5_spujol.pdf Registration tutorial] shows how to perform intra- and inter-subject registration within Slicer.&lt;br /&gt;
* Authors: Sonia Pujol, Ph.D., Dominik Meier, Ph.D., Ron Kikinis, M.D.&lt;br /&gt;
* Audience: Users and developers interested in image registration&lt;br /&gt;
* Dataset: [[Media:RegistrationData.zip| 3D Slicer Registration Data]]&lt;br /&gt;
|align=&amp;quot;right&amp;quot;|[[File:registration_Slicer4.png|250px]]&lt;br /&gt;
|}&lt;br /&gt;
*Based on: 3D Slicer version 4.5&lt;br /&gt;
See [[Documentation/{{documentation/version}}/Registration/RegistrationLibrary|the Registration Library for worked out registration examples with data]].&lt;br /&gt;
&lt;br /&gt;
== Fast GrowCut ==&lt;br /&gt;
&lt;br /&gt;
{|width=&amp;quot;100%&amp;quot;&lt;br /&gt;
|&lt;br /&gt;
* The [[media:FastGrowCutTutorial.pdf |Fast GrowCut tutorial]]  shows how to perform a segmentation using the Fast GrowCut effect in Slicer.&lt;br /&gt;
* Authors: Hillary Lia&lt;br /&gt;
* Audience: Users interested in segmentation&lt;br /&gt;
|align=&amp;quot;right&amp;quot;|[[File:FastGrowCutLogo.png|200px]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==Slicer4 Radiation Therapy Tutorial ==&lt;br /&gt;
** The  [https://app.assembla.com/spaces/slicerrt/subversion/source/HEAD/trunk/SlicerRt/doc/tutorials/SlicerRT_TutorialIGRT_4.7.pdf?_format=raw SlicerRT tutorial] is an introduction to the Radiation Therapy functionalities of Slicer.&lt;br /&gt;
** Author: Csaba Pinter, Andras Lasso, An Wang, Gregory C. Sharp, David Jaffray, Gabor Fichtinger. &lt;br /&gt;
** Dataset: [http://slicer.kitware.com/midas3/download/item/205404/SlicerRT_WorldCongress_TutorialIGRT_Dataset.zip download] from MIDAS server&lt;br /&gt;
**Based on Slicer 4.7&lt;br /&gt;
&lt;br /&gt;
== Other ==&lt;br /&gt;
&lt;br /&gt;
Additional (non-curated) videos-based demonstrations using 3D Slicer are accessible on  [http://www.youtube.com/results?search_query=3d+slicer&amp;amp;sm=3 You Tube].&lt;br /&gt;
&lt;br /&gt;
= 3D Slicer Tutorial contests=&lt;br /&gt;
&lt;br /&gt;
==Winter 2017 Tutorial contest==&lt;br /&gt;
&lt;br /&gt;
===Segmentation for 3D printing===&lt;br /&gt;
{|width=&amp;quot;100%&amp;quot;&lt;br /&gt;
|&lt;br /&gt;
*The [https://www.assembla.com/spaces/slicerrt/documents/bmRQGEzzur54v-dmr6CpXy/download/bmRQGEzzur54v-dmr6CpXy Segmentation for 3D printing Tutorial] is an introduction to the new [[Documentation/{{documentation/version}}/Modules/SegmentEditor|Segment Editor]] module, demonstrated through the popular topic of 3D printing. &lt;br /&gt;
*Author: Csaba Pinter (Queen's University, Canada)&lt;br /&gt;
*Dataset: [[:File:BasePiece.zip|Phantom base STL model]] Source: [http://perk-software.cs.queensu.ca/plus/doc/nightly/modelcatalog/ PerkLab].&lt;br /&gt;
|align=&amp;quot;right&amp;quot;|&lt;br /&gt;
[[File:SlicerWinterProjectWeek2017-Segmentation-for-3d-printing.png | 200px]]. &lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===Slicer Pathology===&lt;br /&gt;
{|width=&amp;quot;100%&amp;quot;&lt;br /&gt;
|&lt;br /&gt;
*The [[Documentation/{{documentation/version}}/Extensions/SlicerPathology|Slicer Pathology Tutorial]] describes how to use the corresponding tools for automatic and semi-automatic pathology image segmentation.&lt;br /&gt;
*Author: Erich Bremer (Stonybrook), Andriy Fedorov (Brigham and Women’s Hospital)&lt;br /&gt;
*Dataset:  Available directly with the Slicer Pathology Slicer extension.&lt;br /&gt;
|align=&amp;quot;right&amp;quot;|&lt;br /&gt;
[[File:SlicerPathologyScreenShot8.png | 200px]]. &lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===Simple Python Tool for Quality Control of DWI data===&lt;br /&gt;
{|width=&amp;quot;100%&amp;quot;&lt;br /&gt;
|&lt;br /&gt;
*The [http://www.na-mic.org/Wiki/images/3/3a/SimpleDiffusionGradientInformationExtractorTutorial_Chauvin_Jan2017.pptx Simple Multi-shell Diffusion Gradients Information Extractor Tutorial] describes how to use a simple Python script for parsing multi-shell sensitizing gradients information from nifti file format (separated bvecs, bvals files).&lt;br /&gt;
*Author: Laurent Chauvin (ETS Montreal)&lt;br /&gt;
*Dataset:  Not available.&lt;br /&gt;
|align=&amp;quot;right&amp;quot;|&lt;br /&gt;
[[File:SlicerWinterProjectWeek2017-SimpleDiffusionGradientInformationExtractorTutorial.png | 200px]]. &lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===SPHARM-PDM===&lt;br /&gt;
{|width=&amp;quot;100%&amp;quot;&lt;br /&gt;
|&lt;br /&gt;
*The [https://www.nitrc.org/docman/view.php/308/1982/SPHARM-PDM_Tutorial_July2015.pdf SPHARM-PDM Tutorial] describes how to use SPHARM-PDM and ShapePopulationViewer Slicer extensions to respectively compute point-based models using a parametric boundary description for the computing of Shape Analysis and perform the quality control between the different models.&lt;br /&gt;
*Author: Jonathan Perdomo (UNC), Beatriz Paniagua (Kitware Inc.)&lt;br /&gt;
*Dataset:  [https://www.nitrc.org/docman/view.php/308/1981/SPHARM_Tutorial_Data_July2015.zip Tutorial Data]&lt;br /&gt;
|align=&amp;quot;right&amp;quot;|&lt;br /&gt;
[[File:SlicerWinterProjectWeek2017-SPHARM-PDM.png | 200px]]. &lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===Integration of Robot Operating System (ROS) and 3D Slicer using OpenIGTLink===&lt;br /&gt;
{|width=&amp;quot;100%&amp;quot;&lt;br /&gt;
|&lt;br /&gt;
*The [https://www.na-mic.org/Wiki/images/a/ab/ROSIGTLTutorial_Tokuda_Jan2017.pptx Integration of Robot Operating System (ROS) and 3D Slicer using OpenIGTLink Tutorial] describes the software architecture of surgical robot systems and allows to acquire hands-on experience of software-hardware integration for medical robotics.&lt;br /&gt;
*Author: Junichi Tokuda (Brigham and Women’s Hospital)&lt;br /&gt;
*Dataset:  Not available.&lt;br /&gt;
|align=&amp;quot;right&amp;quot;|&lt;br /&gt;
[[File:SlicerWinterProjectWeek2017-Integration-ROS-3DSlicer-OpenIGTLink.png | 200px]]. &lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===Fiber Bundle Volume Measurement===&lt;br /&gt;
{|width=&amp;quot;100%&amp;quot;&lt;br /&gt;
|&lt;br /&gt;
*The [http://www.na-mic.org/Wiki/images/5/57/Fiber_Bundle_Volume_Measurement.pptx Fiber Bundle Volume Measurement Tutorial] aim is to calculate the volume of the fiber bundle that passes through the Corpus Callosum(CC). Following this tutorial, you’ll be able to (1) convert fiber bundles to label map and (2) calculate volume measurements from the fiber bundles.&lt;br /&gt;
*Author: Shun Gong (Shanghai Changzheng Hospital, China)&lt;br /&gt;
*Dataset:  [http://www.na-mic.org/Wiki/images/4/4c/FiberVolume_data.zip Tutorial data]: The following data are provided: Baseline image, Down sampled whole brain tractography (conducted as in the [[Documentation/{{documentation/version}}/Training#Slicer4_Diffusion_Tensor_Imaging_Tutorial|DWI tutorial]] and down-sampled to about 10000 fibers using Tractography Display module), Corpus callosum label map (drawn as in the [[Documentation/{{documentation/version}}/Training#Slicer4_Diffusion_Tensor_Imaging_Tutorial|DWI tutorial]]).&lt;br /&gt;
|align=&amp;quot;right&amp;quot;|&lt;br /&gt;
[[File:SlicerWinterProjectWeek2017-FiberBundleVolumeMeasurements.png | 200px]]. &lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==Winter 2016 Tutorial contest==&lt;br /&gt;
&lt;br /&gt;
===Subject Hierarchy===&lt;br /&gt;
{|width=&amp;quot;100%&amp;quot;&lt;br /&gt;
|&lt;br /&gt;
*The [http://wiki.na-mic.org/Wiki/images/2/27/SubjectHierarchy.TutorialContestWinter2016.pdf Subject Hierarchy] tutorial demonstrates the basic usage and potential of Slicer’s data manager module Subject Hierarchy using a two-timepoint radiotherapy phantom dataset.&lt;br /&gt;
*Author: Csaba Pinter, Queen's University, Canada&lt;br /&gt;
*Dataset:  [http://slicer.kitware.com/midas3/download/item/205404/SlicerRT_WorldCongress_TutorialIGRT_Dataset.zip SlicerRT_WorldCongress_TutorialIGRT_Dataset] The tutorial dataset is a two-timepoint phantom dataset taken from a RANDO head&amp;amp;neck phantom. It contains two studies, the planning one is a DICOM study consisting of a CT grayscale image and radiotherapy data: contours, dose distribution, treatment beams, plan information. The second timepoint consists of a CT NRRD volume and a dose NRRD volume.&lt;br /&gt;
|align=&amp;quot;right&amp;quot;|&lt;br /&gt;
[[File:SubjectHierarchyTutorial.png | 200px]]. &lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===Fiber Bundle Selection and Scalar Measurements===&lt;br /&gt;
{|width=&amp;quot;100%&amp;quot;&lt;br /&gt;
|&lt;br /&gt;
*The [[media:FiberBundleSelectionAndScalarMeasurement_TutorialContestWinter2016.pdf | Fiber Bundle Selection and Scalar Measurements]] tutorial guides through the use of the Diffusion Bundle Selection module and the Fiber Tract Scalar Measurement module for diffusion MRI tractography data analysis.&lt;br /&gt;
*Author: Fan Zhang, University of Sydney Australia, Brigham and Women's Hospital&lt;br /&gt;
*Dataset:  [[media:FiberBundleSelectionAndScalarMeasurement_TutorialContestWinter2016.zip| Fiber Bundle Selection And Scalar Measurement Tutorial Dataset]]&lt;br /&gt;
|align=&amp;quot;right&amp;quot;|&lt;br /&gt;
[[File:FiberBundleSelectionAndScalarMeasurement_TutorialContestWinter2016_Snapshot.png|200px]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===Plastimatch ===&lt;br /&gt;
{|width=&amp;quot;100%&amp;quot;&lt;br /&gt;
|&lt;br /&gt;
*The [http://www.na-mic.org/Wiki/images/5/5c/Plastimatch_TutorialContestWinter2016.pdf Plastimatch tutorial] guides through registration and wrapping of DICOM and DICOM-RT data using the Plastimatch extension of 3D Slicer.&lt;br /&gt;
*Author: Gregory Sharp, Massachusetts General Hospital&lt;br /&gt;
*Dataset:  [http://www.na-mic.org/Wiki/index.php/File:Plastimatch_TutorialContestWinter2016.zip Plastimatch Tutorial Dataset]&lt;br /&gt;
|align=&amp;quot;right&amp;quot;|&lt;br /&gt;
[[File:PlastimatchTutorial_Winter2016Contest.png|200px]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===UKF ===&lt;br /&gt;
{|width=&amp;quot;100%&amp;quot;&lt;br /&gt;
|&lt;br /&gt;
*The [http://www.na-mic.org/Wiki/images/3/3e/UKF-Tractography_TutorialContestWinter2016.pdf UKF tutorial] guides through the use of the Unscented Kalman Filter (UKF) tractography module. &lt;br /&gt;
*Author: Pegah Kahali, Brigham and Women's Hopital&lt;br /&gt;
*Dataset:  [http://www.na-mic.org/Wiki/index.php/File:UKF-Tractography_TutorialContestWinter2016.zip UKF tutorial Dataset]&lt;br /&gt;
|align=&amp;quot;right&amp;quot;|&lt;br /&gt;
[[File:UKF_Winter2016.png|200px]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==Summer 2014 Tutorial contest== &lt;br /&gt;
&lt;br /&gt;
===Cardiac Agatston Tutorial===&lt;br /&gt;
{|width=&amp;quot;100%&amp;quot;&lt;br /&gt;
|&lt;br /&gt;
*[http://wiki.na-mic.org/Wiki/index.php/File:TutorialContest_CardiacAgatstonScoring_2014.pdf  Cardiac Agatston Scoring Tutorial]&lt;br /&gt;
*Authors:   Jessica Forbes, Hans Johnson, University of Iowa&lt;br /&gt;
*Dataset:  [http://wiki.na-mic.org/Wiki/index.php/File:CardiacAgatstonMeasures_TutorialContestSummer2014.zip Cardiac Agatston Scoring Tutorial Dataset]&lt;br /&gt;
|align=&amp;quot;right&amp;quot;|&lt;br /&gt;
[[File:CardiacAgatstonMeasuresModuleScreenshot.jpg| 250px]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===CMR Toolkit LA workflow===&lt;br /&gt;
{|width=&amp;quot;100%&amp;quot;&lt;br /&gt;
|&lt;br /&gt;
*[http://wiki.na-mic.org/Wiki/index.php/File:CMRToolkitLAWorkflow_TutorialContestSummer2014.pdf  CMR Toolkit LA Workflow Tutorial]&lt;br /&gt;
*Authors: Salma Bengali, Josh Cates, University of Utah&lt;br /&gt;
*Dataset:  [http://wiki.na-mic.org/Wiki/index.php/File:CMRToolkitLAWorkflowData_TutorialContestSummer2014.zip CMRToolkitLAWorkflow Dataset]&lt;br /&gt;
|align=&amp;quot;right&amp;quot;|&lt;br /&gt;
[[Image:Utah_SummerContest2014_tutorial.png|300px]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==Summer 2013 Tutorial contest==&lt;br /&gt;
&lt;br /&gt;
===Cardiac MRI Toolkit===&lt;br /&gt;
{|width=&amp;quot;100%&amp;quot;&lt;br /&gt;
|&lt;br /&gt;
*[[Media:Cardiac MRI Toolkit Tutorial Summer2013.pdf|Cardiac MRI Toolkit]]&lt;br /&gt;
*Authors:   Salma Bengali, Josh Cates, SCI, Utah&lt;br /&gt;
*Dataset:  [[Media:Cardiac_MRI_Toolkit_Tutorial_Data.zip|Cardiac MRI Toolkit Tutorial Dataset]]&lt;br /&gt;
|align=&amp;quot;right&amp;quot;|&lt;br /&gt;
[[Image:CMRToolkit_Tutorial_Image.png|250px]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===HelloCLI===&lt;br /&gt;
{|width=&amp;quot;100%&amp;quot;&lt;br /&gt;
|&lt;br /&gt;
*[[Media:Hello_CLI_TutorialContestSummer2013.pdf|HelloCLI]]&lt;br /&gt;
*Authors:   Nadya Shusharina, Greg Sharp, MGH, Boston&lt;br /&gt;
*Dataset:  [[Media:Hello_CLI_TutorialContestSummer2013.zip‎|HelloCLI Dataset]]&lt;br /&gt;
|align=&amp;quot;right&amp;quot;|&lt;br /&gt;
[[Image:Cli_icon.png|300px]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===SlicerRT===&lt;br /&gt;
{|width=&amp;quot;100%&amp;quot;&lt;br /&gt;
|&lt;br /&gt;
*[[Media:SlicerRT_TutorialContestSummer2013.pdf|SlicerRT Tutorial]]&lt;br /&gt;
*Authors:    Csaba Pinter, Andras Lasso (Queen's), Kevin Wang (PMH, Toronto)&lt;br /&gt;
*Dataset:  [[Media:CsabaPinter-SlicerRtTutorial_Namic2013June.zip|SlicerRT Dataset]] &lt;br /&gt;
|align=&amp;quot;right&amp;quot;|&lt;br /&gt;
[[Image:667px-SlicerRT_0.10_IsocenterShiftingEvaluation.png|250px]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===DTIPrep===&lt;br /&gt;
{|width=&amp;quot;100%&amp;quot;&lt;br /&gt;
|&lt;br /&gt;
*[[Media:DTIPrep_TutorialContestSummer2013.pdf|DTIPrep]]&lt;br /&gt;
*Authors:    Dave Welch, SINAPSE, IOWA &lt;br /&gt;
*Dataset:  [[Media:DTIPrepData_TutorialContestSummer2013.zip|DTIPrep Dataset]]&lt;br /&gt;
|align=&amp;quot;right&amp;quot;|&lt;br /&gt;
[[Image:DTIPrep-tutorial.png|250px]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Summer 2012 Tutorial contest == &lt;br /&gt;
&lt;br /&gt;
===Automatic Left Atrial Scar Segmenter ===&lt;br /&gt;
{|width=&amp;quot;100%&amp;quot;&lt;br /&gt;
|&lt;br /&gt;
*[http://wiki.na-mic.org/Wiki/index.php/CARMA-LA-Scar_TutorialContestSummer2012 Automatic Left Atrial Scar Segmenter] &lt;br /&gt;
*Authors:  Greg Gardner, Josh Cates, SCI, Utah&lt;br /&gt;
*Dataset: [http://wiki.na-mic.org/Wiki/index.php/File:CARMA-LA-Scar_TutorialContestSummer2012.zip CARMA-LA-Scar data]&lt;br /&gt;
|align=&amp;quot;right&amp;quot;|&lt;br /&gt;
[[Image:Carma afib auto scar.png|250px]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===Qualitative and quantitative comparison of  two RT dose distributions===&lt;br /&gt;
{|width=&amp;quot;100%&amp;quot;&lt;br /&gt;
|&lt;br /&gt;
*[http://www.na-mic.org/Wiki/index.php/File:PlastimatchDose_TutorialContestSummer2012.pdf Qualitative and quantitative comparison of  two RT dose distributions]&lt;br /&gt;
*Authors:  James Shackleford, Nadya Shusharina, Greg Sharp, MGH&lt;br /&gt;
|align=&amp;quot;right&amp;quot;|&lt;br /&gt;
[[Image:PlastimatchDose.png|250px]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===Dose accumulation for adaptive radiation therapy===&lt;br /&gt;
{|width=&amp;quot;100%&amp;quot;&lt;br /&gt;
|&lt;br /&gt;
*[http://www.na-mic.org/Wiki/index.php/File:DoseAccumulationforAdaptiveRadiationTherapy_TutorialContestSummer2012.pdf Dose accumulation for adaptive radiation therapy]&lt;br /&gt;
*Authors:  Kevin Wang, Csaba Pinter, Andras Lasso, PMH, Queen's&lt;br /&gt;
|align=&amp;quot;right&amp;quot;|&lt;br /&gt;
[[Image:AdaptiveradiationTherapy.png|250px]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===WebGL Export===&lt;br /&gt;
{|width=&amp;quot;100%&amp;quot;&lt;br /&gt;
|&lt;br /&gt;
*[http://www.na-mic.org/Wiki/index.php/File:WebGLExport_TutorialContestSummer2012.pdf  WebdGLExport]&lt;br /&gt;
*Authors:  Nicolas Rannou, Daniel Haehn, Children's Hospital&lt;br /&gt;
|align=&amp;quot;right&amp;quot;|&lt;br /&gt;
[[Image:WebGLExport.png|250px]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===OpenIGTLink===&lt;br /&gt;
{|width=&amp;quot;100%&amp;quot;&lt;br /&gt;
|&lt;br /&gt;
*[http://wiki.slicer.org/slicerWiki/images/f/f1/OpenIGTLinkTutorial_Slicer4.1.0_JunichiTokuda_Apr2012.pdf OpenIGTLink]&lt;br /&gt;
*Authors:  Junichi Tokuda, BWH&lt;br /&gt;
|align=&amp;quot;right&amp;quot;|&lt;br /&gt;
[[Image:OpenIGTLink.png|250px]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=Additional resources =&lt;br /&gt;
{|width=&amp;quot;100%&amp;quot;&lt;br /&gt;
|&lt;br /&gt;
* This ''Slicer 4.1 [http://vimeo.com/41096643 webinar]'' presents the new features and improvements of the release, and a brief overview of work for the next release.&lt;br /&gt;
* Authors: Steve Pieper Ph.D.&lt;br /&gt;
* Audience: First time users and developers interested in Slicer 4.1 new features.&lt;br /&gt;
* Length: 0h20m&lt;br /&gt;
|align=&amp;quot;right&amp;quot;|[[Image:Webinar-Slicer-4.1.png|250px]]&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
----&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
{|width=&amp;quot;100%&amp;quot;&lt;br /&gt;
|&lt;br /&gt;
*This ''Intro to Slicer 4.0 [http://vimeo.com/37671358 webinar]'' provides an introduction to 3DSlicer, and demonstrates core functionalities such as loading, visualizing and saving data. Basic processing tools, including manual registration, manual segmentation and tractography tools are also highlighted. This webinar is a general overview. For in depth information see the modules above and the documentation pages.&lt;br /&gt;
*Authors: Julien Finet, M.S., Steve Pieper, Ph.D., Jean-Christophe Fillion-Robin, M.S. &lt;br /&gt;
*Audience: First time users interested in a broad overview of Slicer’s features and tools.&lt;br /&gt;
*Length: 1h20m&lt;br /&gt;
|align=&amp;quot;right&amp;quot;|[[Image:Webinar.png|250px]]&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
----&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
{|width=&amp;quot;100%&amp;quot;&lt;br /&gt;
|&lt;br /&gt;
*The ''[[Documentation/{{documentation/version}}/Registration/RegistrationLibrary|Slicer Registration Case Library]]'' provides many real-life example cases of using the Slicer registration tools. They include the dataset and step-by-step instructions to follow and try yourself. &lt;br /&gt;
:Author: Dominik Meier, Ph.D.&lt;br /&gt;
:Audience:  users interested learning/applying Slicer image registration technology&lt;br /&gt;
|align=&amp;quot;right&amp;quot;|[[Image:RegLib_table.png|250px|link=http://wiki.slicer.org/slicerWiki/index.php/Documentation/{{documentation/version}}/Registration/RegistrationLibrary]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
= External Resources =&lt;br /&gt;
&lt;br /&gt;
== Murat Maga's blog posts about using 3D Slicer for biology ==&lt;br /&gt;
&lt;br /&gt;
* [https://blogs.uw.edu/maga/2017/04/11/getting-started-with-3d-slicer-as-a-biologist/ Slicer for Biologists]&lt;br /&gt;
* [https://blogs.uw.edu/maga/2017/04/11/a-worked-example-getting-and-visualizing-data-from-digimorph/ Loading data from DigiMorph]&lt;br /&gt;
* [https://blogs.uw.edu/maga/2017/04/11/morphosource-data-and-dealing-with-dicom-series-in-slicer/ Fixing problem DICOM]&lt;br /&gt;
* [https://blogs.uw.edu/maga/2017/04/12/scissors-tool-is-awesome/ Scissors tool is awesom]&lt;br /&gt;
 &lt;br /&gt;
== Using the (legacy) Editor ==&lt;br /&gt;
&lt;br /&gt;
This set of tutorials about the use of slicer in paleontology is very well written and provides step-by-step instructions.  Even though it covers slicer version 3.4, many of the concepts and techniques have applicability to the new version and to any 3D imaging field:&lt;br /&gt;
&lt;br /&gt;
* [http://openpaleo.blogspot.com/2008/12/3d-slicer-tutorial.html Open Source Paleontologist: 3D Slicer: The Tutorial]&lt;br /&gt;
* [http://openpaleo.blogspot.com/2008/12/3d-slicer-tutorial-part-ii.html Open Source Paleontologist: 3D Slicer: The Tutorial Part II]&lt;br /&gt;
* [http://openpaleo.blogspot.com/2008/12/3d-slicer-tutorial-part-iii.html Open Source Paleontologist: 3D Slicer: The Tutorial Part III]&lt;br /&gt;
* [http://openpaleo.blogspot.com/2008/12/3d-slicer-tutorial-part-iv.html Open Source Paleontologist: 3D Slicer: The Tutorial Part IV]&lt;br /&gt;
* [http://openpaleo.blogspot.com/2009/03/3d-slicer-tutorial-part-v.html Open Source Paleontologist: 3D Slicer: The Tutorial Part V]&lt;br /&gt;
* [http://openpaleo.blogspot.com/2009/03/3d-slicer-tutorial-part-vi.html Open Source Paleontologist: 3D Slicer: The Tutorial Part VI]&lt;br /&gt;
&lt;br /&gt;
== Team Contributions ==&lt;br /&gt;
See the collection of videos on the [http://vimeo.com/album/2363361 Kitware vimeo album].&lt;br /&gt;
&lt;br /&gt;
== User Contributions ==&lt;br /&gt;
See the [[Documentation/{{documentation/version}}/Training/UserContributions|User Contributions Page]] for more content.&lt;br /&gt;
&lt;br /&gt;
[http://www.youtube.com/results?search_query=3d+slicer&amp;amp;sm=3 YouTube videos about 3D Slicer]&lt;/div&gt;</summary>
		<author><name>Inorton</name></author>
		
	</entry>
	<entry>
		<id>https://www.slicer.org/w/index.php?title=Documentation/Nightly/Training&amp;diff=53467</id>
		<title>Documentation/Nightly/Training</title>
		<link rel="alternate" type="text/html" href="https://www.slicer.org/w/index.php?title=Documentation/Nightly/Training&amp;diff=53467"/>
		<updated>2017-07-20T20:56:17Z</updated>

		<summary type="html">&lt;p&gt;Inorton: Link updated PDF for DiffusionMRIAnalysis tutorial&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;noinclude&amp;gt;{{documentation/versioncheck}}&amp;lt;/noinclude&amp;gt;&lt;br /&gt;
=Introduction: Slicer {{documentation/version}} Tutorials=&lt;br /&gt;
&lt;br /&gt;
*This page contains &amp;quot;How to&amp;quot; tutorials with matched sample data sets. They demonstrate how to use the 3D Slicer environment (version {{documentation/version}} release) to accomplish certain tasks. &lt;br /&gt;
*For tutorials for other versions of Slicer, please visit the [[Training| Slicer training portal]].&lt;br /&gt;
*For &amp;quot;reference manual&amp;quot; style documentation, please visit the [[Documentation/{{documentation/version}}|Slicer {{documentation/version}} documentation page]]&lt;br /&gt;
*For questions related to the Slicer4 Training Compendium, please send an e-mail to '''[http://www.na-mic.org/Wiki/index.php/User:SPujol Sonia Pujol, Ph.D., Director of Training of 3D Slicer.]'''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
* Some of these tutorials are based on older releases of 3D Slicer.  The concepts are still useful but bear in mind that some interface elements and features will be different in updated versions.&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
=General Introduction=&lt;br /&gt;
&lt;br /&gt;
==Slicer Welcome Tutorial==&lt;br /&gt;
{|width=&amp;quot;100%&amp;quot;&lt;br /&gt;
|&lt;br /&gt;
*The [[media:SlicerWelcome-tutorial_Slicer4.5.pdf|SlicerWelcome tutorial]] is an introduction to Slicer based on the Welcome module.&lt;br /&gt;
*Author: Sonia Pujol, Ph.D.&lt;br /&gt;
*Audience: First time users who want a general introduction to the software.&lt;br /&gt;
*Modules: Welcome to Slicer, Sample Data&lt;br /&gt;
*Based on: 3D Slicer version 4.6&lt;br /&gt;
|align=&amp;quot;right&amp;quot;|&lt;br /&gt;
[[image:SlicerWelcome-image.png|250px|SlicerWelcome tutorial]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==Slicer4Minute Tutorial==&lt;br /&gt;
{|width=&amp;quot;100%&amp;quot;&lt;br /&gt;
|&lt;br /&gt;
*The [[media:Slicer4.5minute_SoniaPujol.pdf|Slicer4Minute tutorial]]  is a brief introduction to the advanced 3D visualization capabilities of Slicer 4.5.&lt;br /&gt;
*Author: Sonia Pujol, Ph.D.&lt;br /&gt;
*Audience: First time users who want to discover Slicer in 4 minutes.&lt;br /&gt;
*Modules: Welcome to Slicer, Models&lt;br /&gt;
*Based on: 3D Slicer version 4.5&lt;br /&gt;
*The [[media:Slicer4minute.zip|Slicer4Minute dataset]] contains an MR scan of the brain and 3D reconstructions of the anatomy&lt;br /&gt;
|align=&amp;quot;right&amp;quot;|&lt;br /&gt;
[[image:Slicer4minute-image.png|250px|right|Slicer4Minute tutorial]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==Slicer4 Data Loading and 3D Visualization ==&lt;br /&gt;
{|width=&amp;quot;100%&amp;quot;&lt;br /&gt;
|&lt;br /&gt;
*The [[Media:3DDataLoadingandVisualization_Slicer4.5_SoniaPujol.pdf | Data loading and 3D visualization]] course guides through the basics of loading and viewing volumes and 3D models in Slicer4 . &lt;br /&gt;
*Author: Sonia Pujol, Ph.D.&lt;br /&gt;
*Modules: Welcome to Slicer, Sample Data, Models.&lt;br /&gt;
*Audience: End-users&lt;br /&gt;
*Based on: 3D Slicer version 4.5&lt;br /&gt;
*The [[Media:3DVisualizationData.zip | 3DVisualization dataset]] contain an MR scan and a series of 3D models of the brain.&lt;br /&gt;
|align=&amp;quot;right&amp;quot;|&lt;br /&gt;
[[Image:Slicer4DataLoading_tutorial.png|right|250px|]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=Tutorials for software developers=&lt;br /&gt;
&lt;br /&gt;
== Slicer4 Programming Tutorial ==&lt;br /&gt;
{|width=&amp;quot;100%&amp;quot;&lt;br /&gt;
|&lt;br /&gt;
*The [https://1drv.ms/b/s!Arm_AFxB9yqHsIUKNqVboYvm4sgd4w Hello Python Programming tutorial] course guides through the integration of a python module in Slicer4. &lt;br /&gt;
*Author: Sonia Pujol, Ph.D., Steve Pieper, Ph.D.&lt;br /&gt;
*Audience: Developers&lt;br /&gt;
*Based on: 3D Slicer version 4.5&lt;br /&gt;
*The [https://1drv.ms/u/s!Arm_AFxB9yqHsIR2N_9krtTHTsTo1Q HelloPython dataset] contains sample data set (MR scan of the brain) and complete Python module examples.&lt;br /&gt;
|align=&amp;quot;right&amp;quot;|&lt;br /&gt;
[[Image:HelloPythonTutorial.png|right|250px|]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
For additional Python scripts examples, please visit the [[Documentation/{{documentation/version}}/ScriptRepository|Script Repository page]]&lt;br /&gt;
&lt;br /&gt;
==Developing and contributing extensions for 3D Slicer==&lt;br /&gt;
{|width=&amp;quot;100%&amp;quot;&lt;br /&gt;
|&lt;br /&gt;
*The [http://goo.gl/IP4cdg Developing and contributing extensions for 3D Slicer tutorial ] is an introduction to the internals of 3D Slicer and the process of contributing a 3D Slicer extension.&lt;br /&gt;
*Authors: Andrey Fedorov, Jean-Christophe Fillion-Robin, Steve Pieper&lt;br /&gt;
*Audience: Developers&lt;br /&gt;
*Based on: 3D Slicer version 4.4&lt;br /&gt;
|align=&amp;quot;right&amp;quot;|&lt;br /&gt;
[[Image:Contributing3DSlicerExtension.png|right|250px|]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=Specific functions=&lt;br /&gt;
&lt;br /&gt;
==Slicer4 Diffusion Tensor Imaging Tutorial ==&lt;br /&gt;
{|width=&amp;quot;100%&amp;quot;&lt;br /&gt;
|&lt;br /&gt;
*The [https://github.com/SlicerDMRI/slicerdmri.github.io/raw/master/docs/tutorials/DiffusionMRIanalysis.pdf Diffusion Tensor Imaging Tutorial]  course guides through the basics of loading Diffusion Weighted images in Slicer, estimating tensors and generating fiber tracts. &lt;br /&gt;
*Author: Sonia Pujol, Ph.D.&lt;br /&gt;
*Audience: End-users and developers&lt;br /&gt;
*Modules: Data, Volumes, DWI to DTI Estimation, Diffusion Tensor Scalar Measurements, Editor, Markups,Tractography Label Map Seeding, Tractography Interactive Seeding&lt;br /&gt;
*Based on: 3D Slicer version 4.5&lt;br /&gt;
*The [[media:Dti tutorial data.zip|DTI dataset]] contains an MR Diffusion Weighted Imaging scan of the brain.&lt;br /&gt;
|align=&amp;quot;right&amp;quot;|&lt;br /&gt;
[[Image:Slicer4DTI Tutorial.png|right|250px|]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==Slicer4 Neurosurgical Planning Tutorial==&lt;br /&gt;
{|width=&amp;quot;100%&amp;quot;&lt;br /&gt;
|&lt;br /&gt;
*The [[media:WhiteMatterExplorationTutorial_SoniaPujol_Slicer4.5.pdf |  Neurosurgical Planning tutorial]]course guides through the generation of fiber tracts in the vicinity of a tumor.&lt;br /&gt;
*Author: Sonia Pujol, Ph.D., Ron Kikinis, M.D.&lt;br /&gt;
*Audience: End-users and developers&lt;br /&gt;
*Modules: Volumes, Editor, Tractography Label Map Seeding, Tractography Interactive Seeding&lt;br /&gt;
*Based on: 3D Slicer version 4.5&lt;br /&gt;
*The [[Media:WhiteMatterExplorationData.zip| White Matter Exploration datasets]] contains a Diffusion Weighted Imaging scan of  brain tumor patient.&lt;br /&gt;
|align=&amp;quot;right&amp;quot;|&lt;br /&gt;
[[Image:NeurosurgicalPlanningTutorial.png|right|250px|link=http://vimeo.com/67336069]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==Slicer4 3D Visualization of DICOM images for Radiology Applications==&lt;br /&gt;
{|width=&amp;quot;100%&amp;quot;&lt;br /&gt;
|&lt;br /&gt;
*The [[Media:3DSlicer_Dicom_RSNA2015_SoniaPujol.pdf |3D Visualization of DICOM images for Radiology Applications]]  course guides through 3D data loading and visualization of DICOM images for Radiology Applications in Slicer4. &lt;br /&gt;
*Author: Sonia Pujol, Ph.D., Kitt Shaffer, M.D., Ph.D., Ron Kikinis, M.D.&lt;br /&gt;
*Audience: Radiologists and users of Slicer who need a more comprehensive overview over Slicer4 visualization capabilities.&lt;br /&gt;
*Modules: DICOM, Volumes, Volume Rendering, Models.&lt;br /&gt;
*Based on: 3D Slicer version 4.5&lt;br /&gt;
*The [[Media:3DVisualization_DICOM_images_part1.zip‎  | 3DVisualizationDICOM_part1]] and [[Media:3DVisualization_DICOM_images_part2.zip | 3DVisualizationDICOM_part2]] datasets contain a series of MR and CT scans, and 3D models of the brain, lung and liver.&lt;br /&gt;
|align=&amp;quot;right&amp;quot;|&lt;br /&gt;
[[Image:Slicer4RSNA_2.png|right|250px|]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==Slicer4 Quantitative Imaging tutorial==&lt;br /&gt;
{|width=&amp;quot;100%&amp;quot;&lt;br /&gt;
|&lt;br /&gt;
*The [[media:QuantitativeImaging_Slicer4.5.pdf‎ | Slicer4 Quantitative Imaging tutorial]]  guides through the use for Slicer for quantifying small volumetric changes in slow-growing tumors, and for calculating Standardized Uptake Value (SUV) from PET/CT data.&lt;br /&gt;
*Authors: Sonia Pujol, Ph.D., Katarzyna Macura, M.D., Ron Kikinis, M.D.&lt;br /&gt;
*Audience: Radiologists and users of Slicer who need a more comprehensive overview over Slicer4 quantitative imaging capabilities.&lt;br /&gt;
*Modules: Data, Volumes, Models, Change Tracker, PET Standard Uptake Value Computation&lt;br /&gt;
*Based on: 3D Slicer version 4.5&lt;br /&gt;
*The [[media:QuantitativeImaging.zip‎| Quantitative Imaging dataset]]  contains a series of MR and PET/CT data.&lt;br /&gt;
|align=&amp;quot;right&amp;quot;|&lt;br /&gt;
[[Image:Slicer4_QuantitativeImaging.png|right|250px|]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Slicer4 IGT ==&lt;br /&gt;
{|width=&amp;quot;100%&amp;quot;&lt;br /&gt;
|&lt;br /&gt;
*[http://www.slicerigt.org/wp/user-tutorial/ Slicer IGT tutorials]&lt;br /&gt;
*Authors: Tamas Ungi, M.D, Ph.D., Junichi Tokuda, Ph.D.&lt;br /&gt;
*Audience: End-users interested in using Slicer for real-time navigated procedures. E.g. navigated needle insertions or other minimally invasive medical procedures.&lt;br /&gt;
*Modules: SlicerIGT Extension&lt;br /&gt;
*Based on: Slicer4.3.1-2014.09.14&lt;br /&gt;
*Data: [https://onedrive.live.com/redir?resid=7230D4DEC6058018!2937&amp;amp;authkey=!AGQkSCZOwjVYXw8&amp;amp;ithint=folder%2cpptx  Slicer-IGT datasets]&lt;br /&gt;
|align=&amp;quot;right&amp;quot;|&lt;br /&gt;
[[Image:SlicetIGT.png|right|150px|]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Slicer4 3D Printing ==&lt;br /&gt;
&lt;br /&gt;
{|width=&amp;quot;100%&amp;quot;&lt;br /&gt;
|&lt;br /&gt;
* The video tutorial [https://youtu.be/Uht6Fwtr9hE Segmenting a CT for 3D Printing of a Lumbar Phantom] shows how to use the Segment Editor of 3D Slicer for 3D printing using Slicer 4.7.&lt;br /&gt;
** Author: Hillary Lia&lt;br /&gt;
** Audience: Users and developers interested in 3D printing&lt;br /&gt;
* The [https://www.slicer.org/wiki/Documentation/4.6/Training#Segmentation_for_3D_printing Segmentation for 3D printing] shows how to use the Segment Editor of 3D Slicer for 3D printing using Slicer 4.6.&lt;br /&gt;
** Author: Csaba Pinter, MSc&lt;br /&gt;
** Audience: Users and developers interested in 3D printing&lt;br /&gt;
* This ''Slicer 4.3 [https://www.youtube.com/watch?v=MKLWzD0PiIc 3D printing tutorial]''  shows how to prepare 3D Slicer data for 3D printing using legacy Editor module.&lt;br /&gt;
** Authors: Nabgha Farhat, MSc&lt;br /&gt;
** Audience: Users and developers interested in 3D printing&lt;br /&gt;
|align=&amp;quot;right&amp;quot;|[[Image:20170717_3DPrintingTutorialYoutube.PNG|280px]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Slicer4 Image Registration ==&lt;br /&gt;
&lt;br /&gt;
{|width=&amp;quot;100%&amp;quot;&lt;br /&gt;
|&lt;br /&gt;
*The [https://www.slicer.org/slicerWiki/index.php/File:RegistrationTutorial_3DSlicer4.5_spujol.pdf Registration tutorial] shows how to perform intra- and inter-subject registration within Slicer.&lt;br /&gt;
* Authors: Sonia Pujol, Ph.D., Dominik Meier, Ph.D., Ron Kikinis, M.D.&lt;br /&gt;
* Audience: Users and developers interested in image registration&lt;br /&gt;
* Dataset: [[Media:RegistrationData.zip| 3D Slicer Registration Data]]&lt;br /&gt;
|align=&amp;quot;right&amp;quot;|[[File:registration_Slicer4.png|250px]]&lt;br /&gt;
|}&lt;br /&gt;
*Based on: 3D Slicer version 4.5&lt;br /&gt;
See [[Documentation/{{documentation/version}}/Registration/RegistrationLibrary|the Registration Library for worked out registration examples with data]].&lt;br /&gt;
&lt;br /&gt;
== Fast GrowCut ==&lt;br /&gt;
&lt;br /&gt;
{|width=&amp;quot;100%&amp;quot;&lt;br /&gt;
|&lt;br /&gt;
* The [[media:FastGrowCutTutorial.pdf |Fast GrowCut tutorial]]  shows how to perform a segmentation using the Fast GrowCut effect in Slicer.&lt;br /&gt;
* Authors: Hillary Lia&lt;br /&gt;
* Audience: Users interested in segmentation&lt;br /&gt;
|align=&amp;quot;right&amp;quot;|[[File:FastGrowCutLogo.png|200px]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==Slicer4 Radiation Therapy Tutorial ==&lt;br /&gt;
** The  [https://app.assembla.com/spaces/slicerrt/subversion/source/HEAD/trunk/SlicerRt/doc/tutorials/SlicerRT_TutorialIGRT_4.7.pdf?_format=raw SlicerRT tutorial] is an introduction to the Radiation Therapy functionalities of Slicer.&lt;br /&gt;
** Author: Csaba Pinter, Andras Lasso, An Wang, Gregory C. Sharp, David Jaffray, Gabor Fichtinger. &lt;br /&gt;
** Dataset: [http://slicer.kitware.com/midas3/download/item/205404/SlicerRT_WorldCongress_TutorialIGRT_Dataset.zip download] from MIDAS server&lt;br /&gt;
**Based on Slicer 4.7&lt;br /&gt;
&lt;br /&gt;
== Other ==&lt;br /&gt;
&lt;br /&gt;
Additional (non-curated) videos-based demonstrations using 3D Slicer are accessible on  [http://www.youtube.com/results?search_query=3d+slicer&amp;amp;sm=3 You Tube].&lt;br /&gt;
&lt;br /&gt;
= 3D Slicer Tutorial contests=&lt;br /&gt;
&lt;br /&gt;
==Winter 2017 Tutorial contest==&lt;br /&gt;
&lt;br /&gt;
===Segmentation for 3D printing===&lt;br /&gt;
{|width=&amp;quot;100%&amp;quot;&lt;br /&gt;
|&lt;br /&gt;
*The [https://www.assembla.com/spaces/slicerrt/documents/bmRQGEzzur54v-dmr6CpXy/download/bmRQGEzzur54v-dmr6CpXy Segmentation for 3D printing Tutorial] is an introduction to the new [[Documentation/{{documentation/version}}/Modules/SegmentEditor|Segment Editor]] module, demonstrated through the popular topic of 3D printing. &lt;br /&gt;
*Author: Csaba Pinter (Queen's University, Canada)&lt;br /&gt;
*Dataset: [[:File:BasePiece.zip|Phantom base STL model]] Source: [http://perk-software.cs.queensu.ca/plus/doc/nightly/modelcatalog/ PerkLab].&lt;br /&gt;
|align=&amp;quot;right&amp;quot;|&lt;br /&gt;
[[File:SlicerWinterProjectWeek2017-Segmentation-for-3d-printing.png | 200px]]. &lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===Slicer Pathology===&lt;br /&gt;
{|width=&amp;quot;100%&amp;quot;&lt;br /&gt;
|&lt;br /&gt;
*The [[Documentation/{{documentation/version}}/Extensions/SlicerPathology|Slicer Pathology Tutorial]] describes how to use the corresponding tools for automatic and semi-automatic pathology image segmentation.&lt;br /&gt;
*Author: Erich Bremer (Stonybrook), Andriy Fedorov (Brigham and Women’s Hospital)&lt;br /&gt;
*Dataset:  Available directly with the Slicer Pathology Slicer extension.&lt;br /&gt;
|align=&amp;quot;right&amp;quot;|&lt;br /&gt;
[[File:SlicerPathologyScreenShot8.png | 200px]]. &lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===Simple Python Tool for Quality Control of DWI data===&lt;br /&gt;
{|width=&amp;quot;100%&amp;quot;&lt;br /&gt;
|&lt;br /&gt;
*The [http://www.na-mic.org/Wiki/images/3/3a/SimpleDiffusionGradientInformationExtractorTutorial_Chauvin_Jan2017.pptx Simple Multi-shell Diffusion Gradients Information Extractor Tutorial] describes how to use a simple Python script for parsing multi-shell sensitizing gradients information from nifti file format (separated bvecs, bvals files).&lt;br /&gt;
*Author: Laurent Chauvin (ETS Montreal)&lt;br /&gt;
*Dataset:  Not available.&lt;br /&gt;
|align=&amp;quot;right&amp;quot;|&lt;br /&gt;
[[File:SlicerWinterProjectWeek2017-SimpleDiffusionGradientInformationExtractorTutorial.png | 200px]]. &lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===SPHARM-PDM===&lt;br /&gt;
{|width=&amp;quot;100%&amp;quot;&lt;br /&gt;
|&lt;br /&gt;
*The [https://www.nitrc.org/docman/view.php/308/1982/SPHARM-PDM_Tutorial_July2015.pdf SPHARM-PDM Tutorial] describes how to use SPHARM-PDM and ShapePopulationViewer Slicer extensions to respectively compute point-based models using a parametric boundary description for the computing of Shape Analysis and perform the quality control between the different models.&lt;br /&gt;
*Author: Jonathan Perdomo (UNC), Beatriz Paniagua (Kitware Inc.)&lt;br /&gt;
*Dataset:  [https://www.nitrc.org/docman/view.php/308/1981/SPHARM_Tutorial_Data_July2015.zip Tutorial Data]&lt;br /&gt;
|align=&amp;quot;right&amp;quot;|&lt;br /&gt;
[[File:SlicerWinterProjectWeek2017-SPHARM-PDM.png | 200px]]. &lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===Integration of Robot Operating System (ROS) and 3D Slicer using OpenIGTLink===&lt;br /&gt;
{|width=&amp;quot;100%&amp;quot;&lt;br /&gt;
|&lt;br /&gt;
*The [https://www.na-mic.org/Wiki/images/a/ab/ROSIGTLTutorial_Tokuda_Jan2017.pptx Integration of Robot Operating System (ROS) and 3D Slicer using OpenIGTLink Tutorial] describes the software architecture of surgical robot systems and allows to acquire hands-on experience of software-hardware integration for medical robotics.&lt;br /&gt;
*Author: Junichi Tokuda (Brigham and Women’s Hospital)&lt;br /&gt;
*Dataset:  Not available.&lt;br /&gt;
|align=&amp;quot;right&amp;quot;|&lt;br /&gt;
[[File:SlicerWinterProjectWeek2017-Integration-ROS-3DSlicer-OpenIGTLink.png | 200px]]. &lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===Fiber Bundle Volume Measurement===&lt;br /&gt;
{|width=&amp;quot;100%&amp;quot;&lt;br /&gt;
|&lt;br /&gt;
*The [http://www.na-mic.org/Wiki/images/5/57/Fiber_Bundle_Volume_Measurement.pptx Fiber Bundle Volume Measurement Tutorial] aim is to calculate the volume of the fiber bundle that passes through the Corpus Callosum(CC). Following this tutorial, you’ll be able to (1) convert fiber bundles to label map and (2) calculate volume measurements from the fiber bundles.&lt;br /&gt;
*Author: Shun Gong (Shanghai Changzheng Hospital, China)&lt;br /&gt;
*Dataset:  [http://www.na-mic.org/Wiki/images/4/4c/FiberVolume_data.zip Tutorial data]: The following data are provided: Baseline image, Down sampled whole brain tractography (conducted as in the [[Documentation/{{documentation/version}}/Training#Slicer4_Diffusion_Tensor_Imaging_Tutorial|DWI tutorial]] and down-sampled to about 10000 fibers using Tractography Display module), Corpus callosum label map (drawn as in the [[Documentation/{{documentation/version}}/Training#Slicer4_Diffusion_Tensor_Imaging_Tutorial|DWI tutorial]]).&lt;br /&gt;
|align=&amp;quot;right&amp;quot;|&lt;br /&gt;
[[File:SlicerWinterProjectWeek2017-FiberBundleVolumeMeasurements.png | 200px]]. &lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==Winter 2016 Tutorial contest==&lt;br /&gt;
&lt;br /&gt;
===Subject Hierarchy===&lt;br /&gt;
{|width=&amp;quot;100%&amp;quot;&lt;br /&gt;
|&lt;br /&gt;
*The [http://wiki.na-mic.org/Wiki/images/2/27/SubjectHierarchy.TutorialContestWinter2016.pdf Subject Hierarchy] tutorial demonstrates the basic usage and potential of Slicer’s data manager module Subject Hierarchy using a two-timepoint radiotherapy phantom dataset.&lt;br /&gt;
*Author: Csaba Pinter, Queen's University, Canada&lt;br /&gt;
*Dataset:  [http://slicer.kitware.com/midas3/download/item/205404/SlicerRT_WorldCongress_TutorialIGRT_Dataset.zip SlicerRT_WorldCongress_TutorialIGRT_Dataset] The tutorial dataset is a two-timepoint phantom dataset taken from a RANDO head&amp;amp;neck phantom. It contains two studies, the planning one is a DICOM study consisting of a CT grayscale image and radiotherapy data: contours, dose distribution, treatment beams, plan information. The second timepoint consists of a CT NRRD volume and a dose NRRD volume.&lt;br /&gt;
|align=&amp;quot;right&amp;quot;|&lt;br /&gt;
[[File:SubjectHierarchyTutorial.png | 200px]]. &lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===Fiber Bundle Selection and Scalar Measurements===&lt;br /&gt;
{|width=&amp;quot;100%&amp;quot;&lt;br /&gt;
|&lt;br /&gt;
*The [[media:FiberBundleSelectionAndScalarMeasurement_TutorialContestWinter2016.pdf | Fiber Bundle Selection and Scalar Measurements]] tutorial guides through the use of the Diffusion Bundle Selection module and the Fiber Tract Scalar Measurement module for diffusion MRI tractography data analysis.&lt;br /&gt;
*Author: Fan Zhang, University of Sydney Australia, Brigham and Women's Hospital&lt;br /&gt;
*Dataset:  [[media:FiberBundleSelectionAndScalarMeasurement_TutorialContestWinter2016.zip| Fiber Bundle Selection And Scalar Measurement Tutorial Dataset]]&lt;br /&gt;
|align=&amp;quot;right&amp;quot;|&lt;br /&gt;
[[File:FiberBundleSelectionAndScalarMeasurement_TutorialContestWinter2016_Snapshot.png|200px]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===Plastimatch ===&lt;br /&gt;
{|width=&amp;quot;100%&amp;quot;&lt;br /&gt;
|&lt;br /&gt;
*The [http://www.na-mic.org/Wiki/images/5/5c/Plastimatch_TutorialContestWinter2016.pdf Plastimatch tutorial] guides through registration and wrapping of DICOM and DICOM-RT data using the Plastimatch extension of 3D Slicer.&lt;br /&gt;
*Author: Gregory Sharp, Massachusetts General Hospital&lt;br /&gt;
*Dataset:  [http://www.na-mic.org/Wiki/index.php/File:Plastimatch_TutorialContestWinter2016.zip Plastimatch Tutorial Dataset]&lt;br /&gt;
|align=&amp;quot;right&amp;quot;|&lt;br /&gt;
[[File:PlastimatchTutorial_Winter2016Contest.png|200px]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===UKF ===&lt;br /&gt;
{|width=&amp;quot;100%&amp;quot;&lt;br /&gt;
|&lt;br /&gt;
*The [http://www.na-mic.org/Wiki/images/3/3e/UKF-Tractography_TutorialContestWinter2016.pdf UKF tutorial] guides through the use of the Unscented Kalman Filter (UKF) tractography module. &lt;br /&gt;
*Author: Pegah Kahali, Brigham and Women's Hopital&lt;br /&gt;
*Dataset:  [http://www.na-mic.org/Wiki/index.php/File:UKF-Tractography_TutorialContestWinter2016.zip UKF tutorial Dataset]&lt;br /&gt;
|align=&amp;quot;right&amp;quot;|&lt;br /&gt;
[[File:UKF_Winter2016.png|200px]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==Summer 2014 Tutorial contest== &lt;br /&gt;
&lt;br /&gt;
===Cardiac Agatston Tutorial===&lt;br /&gt;
{|width=&amp;quot;100%&amp;quot;&lt;br /&gt;
|&lt;br /&gt;
*[http://wiki.na-mic.org/Wiki/index.php/File:TutorialContest_CardiacAgatstonScoring_2014.pdf  Cardiac Agatston Scoring Tutorial]&lt;br /&gt;
*Authors:   Jessica Forbes, Hans Johnson, University of Iowa&lt;br /&gt;
*Dataset:  [http://wiki.na-mic.org/Wiki/index.php/File:CardiacAgatstonMeasures_TutorialContestSummer2014.zip Cardiac Agatston Scoring Tutorial Dataset]&lt;br /&gt;
|align=&amp;quot;right&amp;quot;|&lt;br /&gt;
[[File:CardiacAgatstonMeasuresModuleScreenshot.jpg| 250px]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===CMR Toolkit LA workflow===&lt;br /&gt;
{|width=&amp;quot;100%&amp;quot;&lt;br /&gt;
|&lt;br /&gt;
*[http://wiki.na-mic.org/Wiki/index.php/File:CMRToolkitLAWorkflow_TutorialContestSummer2014.pdf  CMR Toolkit LA Workflow Tutorial]&lt;br /&gt;
*Authors: Salma Bengali, Josh Cates, University of Utah&lt;br /&gt;
*Dataset:  [http://wiki.na-mic.org/Wiki/index.php/File:CMRToolkitLAWorkflowData_TutorialContestSummer2014.zip CMRToolkitLAWorkflow Dataset]&lt;br /&gt;
|align=&amp;quot;right&amp;quot;|&lt;br /&gt;
[[Image:Utah_SummerContest2014_tutorial.png|300px]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==Summer 2013 Tutorial contest==&lt;br /&gt;
&lt;br /&gt;
===Cardiac MRI Toolkit===&lt;br /&gt;
{|width=&amp;quot;100%&amp;quot;&lt;br /&gt;
|&lt;br /&gt;
*[[Media:Cardiac MRI Toolkit Tutorial Summer2013.pdf|Cardiac MRI Toolkit]]&lt;br /&gt;
*Authors:   Salma Bengali, Josh Cates, SCI, Utah&lt;br /&gt;
*Dataset:  [[Media:Cardiac_MRI_Toolkit_Tutorial_Data.zip|Cardiac MRI Toolkit Tutorial Dataset]]&lt;br /&gt;
|align=&amp;quot;right&amp;quot;|&lt;br /&gt;
[[Image:CMRToolkit_Tutorial_Image.png|250px]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===HelloCLI===&lt;br /&gt;
{|width=&amp;quot;100%&amp;quot;&lt;br /&gt;
|&lt;br /&gt;
*[[Media:Hello_CLI_TutorialContestSummer2013.pdf|HelloCLI]]&lt;br /&gt;
*Authors:   Nadya Shusharina, Greg Sharp, MGH, Boston&lt;br /&gt;
*Dataset:  [[Media:Hello_CLI_TutorialContestSummer2013.zip‎|HelloCLI Dataset]]&lt;br /&gt;
|align=&amp;quot;right&amp;quot;|&lt;br /&gt;
[[Image:Cli_icon.png|300px]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===SlicerRT===&lt;br /&gt;
{|width=&amp;quot;100%&amp;quot;&lt;br /&gt;
|&lt;br /&gt;
*[[Media:SlicerRT_TutorialContestSummer2013.pdf|SlicerRT Tutorial]]&lt;br /&gt;
*Authors:    Csaba Pinter, Andras Lasso (Queen's), Kevin Wang (PMH, Toronto)&lt;br /&gt;
*Dataset:  [[Media:CsabaPinter-SlicerRtTutorial_Namic2013June.zip|SlicerRT Dataset]] &lt;br /&gt;
|align=&amp;quot;right&amp;quot;|&lt;br /&gt;
[[Image:667px-SlicerRT_0.10_IsocenterShiftingEvaluation.png|250px]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===DTIPrep===&lt;br /&gt;
{|width=&amp;quot;100%&amp;quot;&lt;br /&gt;
|&lt;br /&gt;
*[[Media:DTIPrep_TutorialContestSummer2013.pdf|DTIPrep]]&lt;br /&gt;
*Authors:    Dave Welch, SINAPSE, IOWA &lt;br /&gt;
*Dataset:  [[Media:DTIPrepData_TutorialContestSummer2013.zip|DTIPrep Dataset]]&lt;br /&gt;
|align=&amp;quot;right&amp;quot;|&lt;br /&gt;
[[Image:DTIPrep-tutorial.png|250px]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Summer 2012 Tutorial contest == &lt;br /&gt;
&lt;br /&gt;
===Automatic Left Atrial Scar Segmenter ===&lt;br /&gt;
{|width=&amp;quot;100%&amp;quot;&lt;br /&gt;
|&lt;br /&gt;
*[http://wiki.na-mic.org/Wiki/index.php/CARMA-LA-Scar_TutorialContestSummer2012 Automatic Left Atrial Scar Segmenter] &lt;br /&gt;
*Authors:  Greg Gardner, Josh Cates, SCI, Utah&lt;br /&gt;
*Dataset: [http://wiki.na-mic.org/Wiki/index.php/File:CARMA-LA-Scar_TutorialContestSummer2012.zip CARMA-LA-Scar data]&lt;br /&gt;
|align=&amp;quot;right&amp;quot;|&lt;br /&gt;
[[Image:Carma afib auto scar.png|250px]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===Qualitative and quantitative comparison of  two RT dose distributions===&lt;br /&gt;
{|width=&amp;quot;100%&amp;quot;&lt;br /&gt;
|&lt;br /&gt;
*[http://www.na-mic.org/Wiki/index.php/File:PlastimatchDose_TutorialContestSummer2012.pdf Qualitative and quantitative comparison of  two RT dose distributions]&lt;br /&gt;
*Authors:  James Shackleford, Nadya Shusharina, Greg Sharp, MGH&lt;br /&gt;
|align=&amp;quot;right&amp;quot;|&lt;br /&gt;
[[Image:PlastimatchDose.png|250px]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===Dose accumulation for adaptive radiation therapy===&lt;br /&gt;
{|width=&amp;quot;100%&amp;quot;&lt;br /&gt;
|&lt;br /&gt;
*[http://www.na-mic.org/Wiki/index.php/File:DoseAccumulationforAdaptiveRadiationTherapy_TutorialContestSummer2012.pdf Dose accumulation for adaptive radiation therapy]&lt;br /&gt;
*Authors:  Kevin Wang, Csaba Pinter, Andras Lasso, PMH, Queen's&lt;br /&gt;
|align=&amp;quot;right&amp;quot;|&lt;br /&gt;
[[Image:AdaptiveradiationTherapy.png|250px]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===WebGL Export===&lt;br /&gt;
{|width=&amp;quot;100%&amp;quot;&lt;br /&gt;
|&lt;br /&gt;
*[http://www.na-mic.org/Wiki/index.php/File:WebGLExport_TutorialContestSummer2012.pdf  WebdGLExport]&lt;br /&gt;
*Authors:  Nicolas Rannou, Daniel Haehn, Children's Hospital&lt;br /&gt;
|align=&amp;quot;right&amp;quot;|&lt;br /&gt;
[[Image:WebGLExport.png|250px]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===OpenIGTLink===&lt;br /&gt;
{|width=&amp;quot;100%&amp;quot;&lt;br /&gt;
|&lt;br /&gt;
*[http://wiki.slicer.org/slicerWiki/images/f/f1/OpenIGTLinkTutorial_Slicer4.1.0_JunichiTokuda_Apr2012.pdf OpenIGTLink]&lt;br /&gt;
*Authors:  Junichi Tokuda, BWH&lt;br /&gt;
|align=&amp;quot;right&amp;quot;|&lt;br /&gt;
[[Image:OpenIGTLink.png|250px]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=Additional resources =&lt;br /&gt;
{|width=&amp;quot;100%&amp;quot;&lt;br /&gt;
|&lt;br /&gt;
* This ''Slicer 4.1 [http://vimeo.com/41096643 webinar]'' presents the new features and improvements of the release, and a brief overview of work for the next release.&lt;br /&gt;
* Authors: Steve Pieper Ph.D.&lt;br /&gt;
* Audience: First time users and developers interested in Slicer 4.1 new features.&lt;br /&gt;
* Length: 0h20m&lt;br /&gt;
|align=&amp;quot;right&amp;quot;|[[Image:Webinar-Slicer-4.1.png|250px]]&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
----&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
{|width=&amp;quot;100%&amp;quot;&lt;br /&gt;
|&lt;br /&gt;
*This ''Intro to Slicer 4.0 [http://vimeo.com/37671358 webinar]'' provides an introduction to 3DSlicer, and demonstrates core functionalities such as loading, visualizing and saving data. Basic processing tools, including manual registration, manual segmentation and tractography tools are also highlighted. This webinar is a general overview. For in depth information see the modules above and the documentation pages.&lt;br /&gt;
*Authors: Julien Finet, M.S., Steve Pieper, Ph.D., Jean-Christophe Fillion-Robin, M.S. &lt;br /&gt;
*Audience: First time users interested in a broad overview of Slicer’s features and tools.&lt;br /&gt;
*Length: 1h20m&lt;br /&gt;
|align=&amp;quot;right&amp;quot;|[[Image:Webinar.png|250px]]&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
----&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
{|width=&amp;quot;100%&amp;quot;&lt;br /&gt;
|&lt;br /&gt;
*The ''[[Documentation/{{documentation/version}}/Registration/RegistrationLibrary|Slicer Registration Case Library]]'' provides many real-life example cases of using the Slicer registration tools. They include the dataset and step-by-step instructions to follow and try yourself. &lt;br /&gt;
:Author: Dominik Meier, Ph.D.&lt;br /&gt;
:Audience:  users interested learning/applying Slicer image registration technology&lt;br /&gt;
|align=&amp;quot;right&amp;quot;|[[Image:RegLib_table.png|250px|link=http://wiki.slicer.org/slicerWiki/index.php/Documentation/{{documentation/version}}/Registration/RegistrationLibrary]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
= External Resources =&lt;br /&gt;
&lt;br /&gt;
== Murat Maga's blog posts about using 3D Slicer for biology ==&lt;br /&gt;
&lt;br /&gt;
* [https://blogs.uw.edu/maga/2017/04/11/getting-started-with-3d-slicer-as-a-biologist/ Slicer for Biologists]&lt;br /&gt;
* [https://blogs.uw.edu/maga/2017/04/11/a-worked-example-getting-and-visualizing-data-from-digimorph/ Loading data from DigiMorph]&lt;br /&gt;
* [https://blogs.uw.edu/maga/2017/04/11/morphosource-data-and-dealing-with-dicom-series-in-slicer/ Fixing problem DICOM]&lt;br /&gt;
* [https://blogs.uw.edu/maga/2017/04/12/scissors-tool-is-awesome/ Scissors tool is awesom]&lt;br /&gt;
 &lt;br /&gt;
== Using the (legacy) Editor ==&lt;br /&gt;
&lt;br /&gt;
This set of tutorials about the use of slicer in paleontology is very well written and provides step-by-step instructions.  Even though it covers slicer version 3.4, many of the concepts and techniques have applicability to the new version and to any 3D imaging field:&lt;br /&gt;
&lt;br /&gt;
* [http://openpaleo.blogspot.com/2008/12/3d-slicer-tutorial.html Open Source Paleontologist: 3D Slicer: The Tutorial]&lt;br /&gt;
* [http://openpaleo.blogspot.com/2008/12/3d-slicer-tutorial-part-ii.html Open Source Paleontologist: 3D Slicer: The Tutorial Part II]&lt;br /&gt;
* [http://openpaleo.blogspot.com/2008/12/3d-slicer-tutorial-part-iii.html Open Source Paleontologist: 3D Slicer: The Tutorial Part III]&lt;br /&gt;
* [http://openpaleo.blogspot.com/2008/12/3d-slicer-tutorial-part-iv.html Open Source Paleontologist: 3D Slicer: The Tutorial Part IV]&lt;br /&gt;
* [http://openpaleo.blogspot.com/2009/03/3d-slicer-tutorial-part-v.html Open Source Paleontologist: 3D Slicer: The Tutorial Part V]&lt;br /&gt;
* [http://openpaleo.blogspot.com/2009/03/3d-slicer-tutorial-part-vi.html Open Source Paleontologist: 3D Slicer: The Tutorial Part VI]&lt;br /&gt;
&lt;br /&gt;
== Team Contributions ==&lt;br /&gt;
See the collection of videos on the [http://vimeo.com/album/2363361 Kitware vimeo album].&lt;br /&gt;
&lt;br /&gt;
== User Contributions ==&lt;br /&gt;
See the [[Documentation/{{documentation/version}}/Training/UserContributions|User Contributions Page]] for more content.&lt;br /&gt;
&lt;br /&gt;
[http://www.youtube.com/results?search_query=3d+slicer&amp;amp;sm=3 YouTube videos about 3D Slicer]&lt;/div&gt;</summary>
		<author><name>Inorton</name></author>
		
	</entry>
	<entry>
		<id>https://www.slicer.org/w/index.php?title=MediaWiki:Sidebar&amp;diff=53084</id>
		<title>MediaWiki:Sidebar</title>
		<link rel="alternate" type="text/html" href="https://www.slicer.org/w/index.php?title=MediaWiki:Sidebar&amp;diff=53084"/>
		<updated>2017-07-14T17:03:43Z</updated>

		<summary type="html">&lt;p&gt;Inorton: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;* About slicer&lt;br /&gt;
**Documentation/Release/Announcements|Introduction&lt;br /&gt;
**Documentation/Release/Acknowledgments|Acknowledgments&lt;br /&gt;
**News|News&lt;br /&gt;
**Contact|Contact Us&lt;br /&gt;
**Licensing | Licensing&lt;br /&gt;
**CommercialUse|Commercial Use&lt;br /&gt;
&lt;br /&gt;
* Publication&lt;br /&gt;
**http://www.spl.harvard.edu/publications/pages/display/?collection=11|Publication DB&lt;br /&gt;
**http://www.spl.harvard.edu/publications/gallery?selectedCollection=11|Image Gallery&lt;br /&gt;
**Main_Page/SlicerCommunity|Slicer Community&lt;br /&gt;
**CitingSlicer|Citing Slicer&lt;br /&gt;
&lt;br /&gt;
* Documentation&lt;br /&gt;
** Documentation/Nightly/Training | Slicer Training&lt;br /&gt;
** Documentation/Nightly | User manual&lt;br /&gt;
** Documentation/Nightly/Developers | Developer manual&lt;br /&gt;
&lt;br /&gt;
* Help&lt;br /&gt;
** Help | Help&lt;br /&gt;
** FAQ | User Q&amp;amp;A&lt;br /&gt;
** Documentation/Nightly/Developers/FAQ | Developer FAQ&lt;br /&gt;
** https://discourse.slicer.org/ | Discussion Forum&lt;br /&gt;
&lt;br /&gt;
* Links&lt;br /&gt;
** http://download.slicer.org | Downloads&lt;br /&gt;
** https://www.slicer.org/wiki/Main_Page | Wiki&lt;br /&gt;
** https://www.slicer.org | Homepage&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--&lt;br /&gt;
Ideally we should add these links to the &amp;quot;toolbox&amp;quot; below. To be able to edit the toolbox, we would have to apply this trick: https://www.mediawiki.org/wiki/User:Seb35/modifyToolbox&lt;br /&gt;
--&amp;gt;&lt;br /&gt;
** Special:Recentchanges | Recent Changes&lt;br /&gt;
&amp;lt;!-- ** https://www.slicer.org/slicerWikiWeb/ | Wiki2web admin page --&amp;gt;&lt;/div&gt;</summary>
		<author><name>Inorton</name></author>
		
	</entry>
	<entry>
		<id>https://www.slicer.org/w/index.php?title=MediaWiki:Sidebar&amp;diff=53081</id>
		<title>MediaWiki:Sidebar</title>
		<link rel="alternate" type="text/html" href="https://www.slicer.org/w/index.php?title=MediaWiki:Sidebar&amp;diff=53081"/>
		<updated>2017-07-14T17:02:17Z</updated>

		<summary type="html">&lt;p&gt;Inorton: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;* About slicer&lt;br /&gt;
**Documentation/Release/Announcements|Introduction&lt;br /&gt;
**Documentation/Release/Acknowledgments|Acknowledgments&lt;br /&gt;
**News|News&lt;br /&gt;
**Contact|Contact Us&lt;br /&gt;
**Licensing | Licensing&lt;br /&gt;
**CommercialUse|Commercial Use&lt;br /&gt;
&lt;br /&gt;
* Publication&lt;br /&gt;
**http://www.spl.harvard.edu/publications/pages/display/?collection=11|Publication DB&lt;br /&gt;
**http://www.spl.harvard.edu/publications/gallery?selectedCollection=11|Image Gallery&lt;br /&gt;
**Main_Page/SlicerCommunity|Slicer Community&lt;br /&gt;
**CitingSlicer|Citing Slicer&lt;br /&gt;
&lt;br /&gt;
* Documentation&lt;br /&gt;
** Documentation/Nightly/Training | Slicer Training&lt;br /&gt;
** Documentation/Nightly | User manual&lt;br /&gt;
** Documentation/Nightly/Developers | Developer manual&lt;br /&gt;
&lt;br /&gt;
* Help&lt;br /&gt;
** Help | Help&lt;br /&gt;
** FAQ | User Q&amp;amp;A&lt;br /&gt;
** Documentation/Nightly/Developers/FAQ | Developer FAQ&lt;br /&gt;
&lt;br /&gt;
* Links&lt;br /&gt;
** http://download.slicer.org | Downloads&lt;br /&gt;
** https://discourse.slicer.org/ | Discussion Forum&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--&lt;br /&gt;
Ideally we should add these links to the &amp;quot;toolbox&amp;quot; below. To be able to edit the toolbox, we would have to apply this trick: https://www.mediawiki.org/wiki/User:Seb35/modifyToolbox&lt;br /&gt;
--&amp;gt;&lt;br /&gt;
** Special:Recentchanges | Recent Changes&lt;br /&gt;
&amp;lt;!-- ** https://www.slicer.org/slicerWikiWeb/ | Wiki2web admin page --&amp;gt;&lt;/div&gt;</summary>
		<author><name>Inorton</name></author>
		
	</entry>
	<entry>
		<id>https://www.slicer.org/w/index.php?title=MediaWiki:Sidebar&amp;diff=53078</id>
		<title>MediaWiki:Sidebar</title>
		<link rel="alternate" type="text/html" href="https://www.slicer.org/w/index.php?title=MediaWiki:Sidebar&amp;diff=53078"/>
		<updated>2017-07-14T17:01:19Z</updated>

		<summary type="html">&lt;p&gt;Inorton: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;* About slicer&lt;br /&gt;
**Documentation/Release/Announcements|Introduction&lt;br /&gt;
**Documentation/Release/Acknowledgments|Acknowledgments&lt;br /&gt;
**News|News&lt;br /&gt;
**Contact|Contact Us&lt;br /&gt;
**Licensing | Licensing&lt;br /&gt;
**CommercialUse|Commercial Use&lt;br /&gt;
&lt;br /&gt;
* Publication&lt;br /&gt;
**http://www.spl.harvard.edu/publications/pages/display/?collection=11|Publication DB&lt;br /&gt;
**http://www.spl.harvard.edu/publications/gallery?selectedCollection=11|Image Gallery&lt;br /&gt;
**Main_Page/SlicerCommunity|Slicer Community&lt;br /&gt;
**CitingSlicer|Citing Slicer&lt;br /&gt;
&lt;br /&gt;
* Documentation&lt;br /&gt;
** Documentation/Nightly/Training | Slicer Training&lt;br /&gt;
** Documentation/Nightly | User manual&lt;br /&gt;
** Documentation/Nightly/Developers | Developer manual&lt;br /&gt;
&lt;br /&gt;
* Help&lt;br /&gt;
** Help | Help&lt;br /&gt;
** FAQ | User FAQ&lt;br /&gt;
** Documentation/Nightly/Developers/FAQ | Developer FAQ&lt;br /&gt;
&lt;br /&gt;
* Links&lt;br /&gt;
** http://download.slicer.org | download.slicer.org&lt;br /&gt;
** https://www.slicer.org/wiki/Main_Page | Slicer Wiki&lt;br /&gt;
** https://discourse.slicer.org/ | Discussion Forum&lt;br /&gt;
** https://www.slicer.org/ | slicer.org&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--&lt;br /&gt;
Ideally we should add these links to the &amp;quot;toolbox&amp;quot; below. To be able to edit the toolbox, we would have to apply this trick: https://www.mediawiki.org/wiki/User:Seb35/modifyToolbox&lt;br /&gt;
--&amp;gt;&lt;br /&gt;
** Special:Recentchanges | Recent Changes&lt;br /&gt;
&amp;lt;!-- ** https://www.slicer.org/slicerWikiWeb/ | Wiki2web admin page --&amp;gt;&lt;/div&gt;</summary>
		<author><name>Inorton</name></author>
		
	</entry>
	<entry>
		<id>https://www.slicer.org/w/index.php?title=Help&amp;diff=53073</id>
		<title>Help</title>
		<link rel="alternate" type="text/html" href="https://www.slicer.org/w/index.php?title=Help&amp;diff=53073"/>
		<updated>2017-07-14T16:58:55Z</updated>

		<summary type="html">&lt;p&gt;Inorton: /* Discourse Forum */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Introduction=&lt;br /&gt;
This page is intended to provide links to places where Slicer Users can get help.&lt;br /&gt;
&lt;br /&gt;
=Discourse Forum=&lt;br /&gt;
The most effective way to get help from the community is through the Slicer Discussion Forum:&lt;br /&gt;
* https://discourse.slicer.org&lt;br /&gt;
&lt;br /&gt;
=Training and Documentation=&lt;br /&gt;
*The [[Documentation/{{documentation/currentversion}}/Training|Training page]] provides a series of courses for learning how to use Slicer4. The portfolio contains self-guided presentation and sample data sets.&lt;br /&gt;
*Reference manual style [[Documentation/{{documentation/currentversion}}|documentation]] for Slicer4 can be found on the Slicer Wiki.&lt;br /&gt;
&lt;br /&gt;
=Frequently Asked Questions FAQs=&lt;br /&gt;
We maintain a curated list of questions and answers for both users and developers:&lt;br /&gt;
* [[Documentation/{{documentation/currentversion}}/FAQ | Users FAQ]]&lt;br /&gt;
* [[Documentation/{{documentation/currentversion}}/Developers/FAQ | Developers FAQ]]&lt;br /&gt;
&lt;br /&gt;
=Downloading Slicer=&lt;br /&gt;
*Slicer is free open source software and is distributed under a BSD license. Please read the [[Projects/slicerWeb:LicenseText| Slicer License Agreement]], if you use Slicer. &lt;br /&gt;
*Compiled binaries are accessible through the [http://download.slicer.org Slicer Download] page.&lt;br /&gt;
&lt;br /&gt;
=Bug Reports and Feature Requests=&lt;br /&gt;
We have a data base of bug reports and feature request which is based on a software package called &amp;quot;Mantis&amp;quot;.&lt;br /&gt;
Please file your reports in mantis and send an email about the report to the slicer-users mailing list.&lt;br /&gt;
* In order to file a feature request or a bug report, please sign up on http://www.na-mic.org/Bug/signup_page.php, then click on the '''Report Issue''' link in your browser.&lt;br /&gt;
* See [[Documentation/{{documentation/currentversion}}/Report_a_problem|here]] for additional tips on reporting issues.&lt;br /&gt;
&lt;br /&gt;
=Mailing List (discontinued) Archives=&lt;br /&gt;
Prior to Discourse, support and development discussions were conducted on several mailing lists, for which 10+ years of archives are available:&lt;br /&gt;
* [http://massmail.spl.harvard.edu/public-archives/slicer-users slicer-users (usage questions) archive ].&lt;br /&gt;
** ([http://slicer-users.65878.n3.nabble.com/ searchable Nabble mirror])&lt;br /&gt;
* [http://massmail.spl.harvard.edu/public-archives/slicer-devel slicer-devel (programming questions) archive]&lt;br /&gt;
** ([http://slicer-devel.65872.n3.nabble.com/ searchable Nabble mirror])&lt;/div&gt;</summary>
		<author><name>Inorton</name></author>
		
	</entry>
	<entry>
		<id>https://www.slicer.org/w/index.php?title=FAQ&amp;diff=53023</id>
		<title>FAQ</title>
		<link rel="alternate" type="text/html" href="https://www.slicer.org/w/index.php?title=FAQ&amp;diff=53023"/>
		<updated>2017-07-13T15:59:37Z</updated>

		<summary type="html">&lt;p&gt;Inorton: Redirected page to Documentation/Nightly/FAQ&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;#REDIRECT [[Documentation/Nightly/FAQ]]&lt;/div&gt;</summary>
		<author><name>Inorton</name></author>
		
	</entry>
	<entry>
		<id>https://www.slicer.org/w/index.php?title=Documentation/Nightly/Developers/Build_Instructions/Prerequisites&amp;diff=52999</id>
		<title>Documentation/Nightly/Developers/Build Instructions/Prerequisites</title>
		<link rel="alternate" type="text/html" href="https://www.slicer.org/w/index.php?title=Documentation/Nightly/Developers/Build_Instructions/Prerequisites&amp;diff=52999"/>
		<updated>2017-07-12T19:50:28Z</updated>

		<summary type="html">&lt;p&gt;Inorton: /* Linux */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;noinclude&amp;gt;{{documentation/versioncheck}}&amp;lt;/noinclude&amp;gt;&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
== PREREQUISITES ==&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;!--&lt;br /&gt;
Please check that the following tools are installed on your machine.&lt;br /&gt;
&lt;br /&gt;
We try to keep current with the most recent releases of these prerequisites, but sometimes it's critical to use the exact versions specified here.  If you run into issues please do whatever you can to find a combination that works or contact the developer mailing list for suggestions.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
{{mbox&lt;br /&gt;
| type = protection&lt;br /&gt;
| text = Qt libraries are '''required'''. Consider reading [[Documentation/{{documentation/version}}/Developers/Build_Instructions/Prerequisites/Qt|Qt requirements]].&lt;br /&gt;
| image= [[{{tool|logo|qt}}|x40px]]&lt;br /&gt;
}}&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{mbox&lt;br /&gt;
| type = protection&lt;br /&gt;
| text = CMake is '''required'''.&lt;br /&gt;
| image= [[{{tool|logo|cmake}}|x40px]]&lt;br /&gt;
}}&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{mbox&lt;br /&gt;
| type = protection&lt;br /&gt;
| text = &amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;Git is '''required'''.&lt;br /&gt;
| image= [[{{tool|logo|git}}|x40px]]&lt;br /&gt;
}}&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{mbox&lt;br /&gt;
| type = protection&lt;br /&gt;
| text = SVN is '''required'''.&lt;br /&gt;
| image= [[{{tool|logo|svn}}|x40px]]&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
--&amp;gt;&lt;br /&gt;
The prerequisites listed below are required to be able to configure/build/package/test Slicer.&lt;br /&gt;
&lt;br /&gt;
=== Linux  ===&lt;br /&gt;
* [{{tool|download|cmake}} CMake] &amp;gt;= 3.7-rc02&lt;br /&gt;
* [{{tool|download|git}} Git] &amp;gt;= 1.7.10&lt;br /&gt;
* [{{tool|download|svn}} Svn] &amp;gt;= 1.7&lt;br /&gt;
* Qt 4.8.6. &amp;lt;small&amp;gt;See details [[Documentation/{{documentation/version}}/Developers/Build_Instructions/Prerequisites/Qt#Linux|here]]. See some history [http://na-mic.org/Mantis/view.php?id=3325#bugnotes here] (Note that any version &amp;gt;= Qt 4.7.4 can be used only for Ubuntu &amp;lt; 12.04)&amp;lt;/small&amp;gt;&lt;br /&gt;
* GCC suite&lt;br /&gt;
&lt;br /&gt;
==== Debian ====&lt;br /&gt;
&lt;br /&gt;
* Debian squeeze/wheezy/testing(jessie) users, start by pasting the following lines in a terminal&lt;br /&gt;
 sudo apt-get install subversion git-core git-svn&lt;br /&gt;
 sudo apt-get install build-essential libx11-dev libxt-dev libgl1-mesa-dev libosmesa6-dev libglu1-mesa-dev libfontconfig-dev libxrender-dev libncurses5-dev&lt;br /&gt;
 sudo apt-get install cmake&lt;br /&gt;
 sudo apt-get install qt-sdk&lt;br /&gt;
&lt;br /&gt;
&amp;lt;hr&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Ubuntu ====&lt;br /&gt;
&lt;br /&gt;
===== Common Prerequisites =====&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
 sudo apt-get install subversion git-core git-svn&lt;br /&gt;
&lt;br /&gt;
 sudo apt-get install make gcc g++ libx11-dev libxt-dev libgl1-mesa-dev libglu1-mesa-dev libfontconfig-dev libxrender-dev libncurses5-dev&lt;br /&gt;
&lt;br /&gt;
 sudo apt-get install libosmesa6-dev  # Only for Ubuntu &amp;lt; 14.04.3&lt;br /&gt;
&lt;br /&gt;
{{remark|red|On Ubuntu 14.04.3 LTS, attempting to install &amp;lt;tt&amp;gt;libosmesa6-dev&amp;lt;/tt&amp;gt; results in an error.&amp;lt;pre&amp;gt;&lt;br /&gt;
The following packages have unmet dependencies:&lt;br /&gt;
 libosmesa6-dev : Depends: libosmesa6 (= 10.1.3-0ubuntu0.4) but it is not going to be installed&lt;br /&gt;
 E: Unable to correct problems, you have held broken packages.&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
For more details, see [https://bugs.launchpad.net/ubuntu/+source/mesa-lts-utopic/+bug/1424059 Bug 1424059].}}&lt;br /&gt;
&lt;br /&gt;
{{remark|green|Slicer compiles successfully without that package, but &amp;lt;tt&amp;gt;VTK_OPENGL_HAS_OSMESA&amp;lt;/tt&amp;gt; is disabled.}}&lt;br /&gt;
&lt;br /&gt;
* For Qt5.5 on Ubuntu 16.04&lt;br /&gt;
 sudo apt-get install libgstreamer-plugins-base0.10-dev&lt;br /&gt;
&lt;br /&gt;
===== CMake =====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;ol&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;Open a terminal and copy the command reported below&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;Download stable version of CMake and extract the archive:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo apt-get install curl&lt;br /&gt;
mkdir ~/Support &amp;amp;&amp;amp; cd ~/Support&lt;br /&gt;
curl -O https://cmake.org/files/v3.8/cmake-3.8.2-Linux-x86_64.tar.gz&lt;br /&gt;
tar -xzvf cmake-3.8.2-Linux-x86_64.tar.gz&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;Create symbolic links into &amp;lt;code&amp;gt;~/bin&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
mkdir -p ~/bin&lt;br /&gt;
for name in cmake ctest cpack ccmake cmake-gui; do&lt;br /&gt;
  ln -s ~/Support/cmake-3.8.2-Linux-x86_64/bin/$name ~/bin/$name&lt;br /&gt;
done&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ol&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{remark|red|You &amp;lt;b&amp;gt;MUST&amp;lt;/b&amp;gt; download the standard CMake binary because the distributed version of CMake cannot be used to build slicer.&amp;lt;br&amp;gt;&lt;br /&gt;
See [[Documentation/{{documentation/version}}/Developers/FAQ/Building#Why_distributed_CMake_can_not_be_used_on_Ubuntu_12.04_and_above_.3F|here]] for more details.}}&lt;br /&gt;
&lt;br /&gt;
===== Qt =====&lt;br /&gt;
&lt;br /&gt;
'''Ubuntu 14.04 and above''': Qt 4 == 4.8.7 MUST be used.&lt;br /&gt;
&lt;br /&gt;
See https://github.com/jcfr/qt-easy-build&lt;br /&gt;
&lt;br /&gt;
or on ubuntu 16.04 and 16.10, you can also install qt4.8.7 with:&lt;br /&gt;
&lt;br /&gt;
 sudo apt-get install qt4-dev-tools libqt4-dev libqt4-core libqt4-gui libqtwebkit-dev&lt;br /&gt;
&lt;br /&gt;
or if that fails (due to libqt4-core and libqt4-gui packages not found):&lt;br /&gt;
&lt;br /&gt;
 sudo apt-get install qt4-dev-tools libqt4-dev libqtcore4 libqtgui4 libqtwebkit-dev&lt;br /&gt;
&lt;br /&gt;
'''Ubuntu 12.04, 12.10, 13.04 and 13.10''': Qt 4 &amp;gt;= 4.8.5 MUST be used.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cd ~/Support   # This is where we will build Qt and dependent libraries&lt;br /&gt;
 &lt;br /&gt;
# Keep track of our working directory&lt;br /&gt;
cwd=$(pwd)&lt;br /&gt;
&lt;br /&gt;
# This will download, then build zlib and openssl in the current folder&lt;br /&gt;
rm -f get-and-build-openssl-for-slicer.sh&lt;br /&gt;
wget https://gist.githubusercontent.com/jcfr/9513568/raw/21f4e4cabca5ad03435ecc17ab546dab5e2c1a2f/get-and-build-openssl-for-slicer.sh&lt;br /&gt;
chmod u+x get-and-build-openssl-for-slicer.sh &lt;br /&gt;
./get-and-build-openssl-for-slicer.sh &lt;br /&gt;
&lt;br /&gt;
# This will download Qt source in the current folder&lt;br /&gt;
wget http://packages.kitware.com/download/item/6175/qt-everywhere-opensource-src-4.8.6.tar.gz&lt;br /&gt;
md5=`md5sum ./qt-everywhere-opensource-src-4.8.6.tar.gz | awk '{ print $1 }'` &amp;amp;&amp;amp;&lt;br /&gt;
[ $md5 == &amp;quot;2edbe4d6c2eff33ef91732602f3518eb&amp;quot; ] || echo &amp;quot;MD5 mismatch. Problem downloading Qt&amp;quot;&lt;br /&gt;
&lt;br /&gt;
# This will configure and build Qt in RELEASE against the zlib and openssl previously built&lt;br /&gt;
tar -xzvf qt-everywhere-opensource-src-4.8.6.tar.gz&lt;br /&gt;
mv qt-everywhere-opensource-src-4.8.6 qt-everywhere-opensource-release-src-4.8.6&lt;br /&gt;
mkdir qt-everywhere-opensource-release-build-4.8.6&lt;br /&gt;
cd qt-everywhere-opensource-release-src-4.8.6&lt;br /&gt;
./configure -prefix $cwd/qt-everywhere-opensource-release-build-4.8.6    \&lt;br /&gt;
                   -release \&lt;br /&gt;
                   -opensource -confirm-license \&lt;br /&gt;
                   -no-qt3support \&lt;br /&gt;
                   -webkit \&lt;br /&gt;
                   -nomake examples -nomake demos \&lt;br /&gt;
                   -openssl -I $cwd/openssl-1.0.1e/include   -L $cwd/openssl-1.0.1e \&lt;br /&gt;
&amp;amp;&amp;amp; make -j7 &amp;amp;&amp;amp; make install&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
For more details, consider reading the FAQ entry: [[Documentation/{{documentation/version}}/Developers/FAQ/Building#Why_Qt_4_.3E.3D_4.8.5_should_be_used_on_Ubuntu_12.04_and_above_.3F|Why Qt 4 &amp;gt;= 4.8.5 should be used on Ubuntu 12.04 and above ?]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;hr&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== CentOS ====&lt;br /&gt;
*CentOS user type:&lt;br /&gt;
 yum install make gcc-c++ libX11-devel libXt-devel libXrender-devel libXext-devel libGLU-devel mesa-libOSMesa-devel mesa-libGL-devel mesa-libGLU-devel ncurses&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--&lt;br /&gt;
Todo: This will have to be added in FAQ: Troubleshoot section&lt;br /&gt;
''glx-utils'' provides ''glxgears'' that can be used to test rendering&lt;br /&gt;
--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== MacOSX ===&lt;br /&gt;
&lt;br /&gt;
* El Capitan is what most developers use.&lt;br /&gt;
* CMake 3.7-rc02 is recommended.&lt;br /&gt;
&lt;br /&gt;
====MacOSX 10.9.4 (Mavericks)====&lt;br /&gt;
&lt;br /&gt;
''' (1) Make sure to install this update: http://support.apple.com/kb/DL1754'''&lt;br /&gt;
&lt;br /&gt;
''' (2) Use CMake 3.0.1 - it is known to be working and is supported''' (if you want to use CMake already installed on your system, 2.8.12.2 is known to work on Mac OS X 10.9.5)&lt;br /&gt;
&lt;br /&gt;
* Mac Os X &amp;gt;= 10.5 (Leopard)&lt;br /&gt;
* [{{tool|download|cmake}} CMake] &amp;gt;= 2.8.9&lt;br /&gt;
** For Mac Os X &amp;gt;= 10.8 ([http://en.wikipedia.org/wiki/OS_X_Mountain_Lion Mountain Lion]) and/or recent XCode &amp;gt;= 4.5.X - [{{tool|download|cmake}} CMake] &amp;gt;= 2.8.11 is required. See http://www.cmake.org/files/v2.8/cmake-2.8.11-Darwin64-universal.tar.gz&lt;br /&gt;
&amp;lt;!-- Waiting for the official release, get the release candidate rc1 [http://www.cmake.org/files/v2.8/cmake-2.8.11-rc1-Darwin64-universal.tar.gz here]. For explanation, see [[Documentation/{{documentation/version}}/Developers/Build_Instructions#ld:_framework_not_found_QtWebKit|here]] and [[Documentation/{{documentation/version}}/Developers/Build_Instructions#On_MacOSX_10.8.2C_CMake_hangs_forever|here]]. These versions are also known to work: exact version 20130121-g92bd8 [http://www.cmake.org/files/dev/cmake-2.8.10.20130121-g92bd8-Darwin-universal.tar.gz here] (or version &amp;gt;= 2.8.10.20130220 [http://www.cmake.org/files/dev/?C=M;O=D here]).&lt;br /&gt;
--&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
 $ curl -O http://www.cmake.org/files/v2.8/cmake-2.8.11-Darwin64-universal.tar.gz&lt;br /&gt;
 $ tar -xzvf cmake-2.8.11-Darwin64-universal.tar.gz --strip-components=1&lt;br /&gt;
&lt;br /&gt;
 $ CMake\ 2.8-11.app/Contents/bin/cmake --version&lt;br /&gt;
 cmake version 2.8.11&lt;br /&gt;
&lt;br /&gt;
* [{{tool|download|git}} Git] &amp;gt;= 1.7.10&lt;br /&gt;
* [{{tool|download|svn}} Svn] &amp;gt;= 1.7&lt;br /&gt;
&amp;lt;!--&lt;br /&gt;
*[[{{tool|logo|cmake}}|x16px]] [{{tool|download|cmake}} CMake] &amp;gt;= 2.8.9&lt;br /&gt;
*[[{{tool|logo|git}}|x16px]] [{{tool|download|git}} Git] &amp;gt;= 1.6.5&lt;br /&gt;
--&amp;gt;&lt;br /&gt;
* XCode (for the SDK libs)&lt;br /&gt;
** After installing XCode, install XCode command line developer tools: &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
xcode-select --install&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
* XQuartz - For Mac Os X &amp;gt;= 10.8 ([http://en.wikipedia.org/wiki/OS_X_Mountain_Lion Mountain Lion]) install XQuartz (http://xquartz.macosforge.org) to get X11 (no longer a default in OS X).&lt;br /&gt;
* Qt 4 &amp;gt;= 4.8.5. We recommend you install the following two packages:&lt;br /&gt;
** Download and install [http://download.qt-project.org/official_releases/qt/4.8/4.8.6/qt-opensource-mac-4.8.6-1.dmg qt-opensource-mac-4.8.6-1.dmg]&lt;br /&gt;
** Download and install [http://download.qt-project.org/official_releases/qt/4.8/4.8.6/qt-opensource-mac-4.8.6-1-debug-libs.dmg qt-opensource-mac-4.8.6-1-debug-libs.dmg]&lt;br /&gt;
** For more details [[Documentation/{{documentation/version}}/Developers/Build_Instructions/Prerequisites/Qt#Mac|here]]&lt;br /&gt;
&amp;lt;!--&lt;br /&gt;
** Newer Xcode versions (e.g. 4.3.2) use clang as the default compiler and '''clang is not compatible with ITK version 3'''.  You should use ITK version 4 with recent versions of Xcode.&lt;br /&gt;
** Xcode with gcc should ork with either version of ITK.&lt;br /&gt;
** OS X Mountain Lion: In Xcode 4.5 you now need to install command line tools (no longer included by default). Install within Xcode under the Xcode-&amp;gt;Preferences-&amp;gt;Downloads tab (otherwise git svn will give errors). Then you will need to install XQuartz (http://xquartz.macosforge.org) to get X11 (no longer a default in OS X).&lt;br /&gt;
--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Mac OSX 10.11 (El Capitan)====&lt;br /&gt;
&lt;br /&gt;
XCode up to version 7 is known to work for Slicer compilation. XCode 8 breaks things on several levels for now. &lt;br /&gt;
Remember to install XCode command line tools (see above) if a reinstall for XCode is needed. &lt;br /&gt;
&lt;br /&gt;
The standard Qt4 installers fail on this version and the 4.8.6 source code won't build.  But [http://slicer-devel.65872.n3.nabble.com/incompatible-qt-4-8-6-with-OS-X-El-Capitan-td4035551.html as described on the slicer-devel mailing list] it is possible to install the [https://github.com/Homebrew/formula-patches/blob/master/qt/el-capitan.patch homebrew version of qt4 which patches it to work on El Capitan] (see below).&lt;br /&gt;
&lt;br /&gt;
* Install the '''OS''', '''Xcode''', and '''XQuartz''' (see MacOSX 10.10 above)&lt;br /&gt;
* Install '''Qt4''' by running the following two commands:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
brew install qt4&lt;br /&gt;
xcode-select --install&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
* TCL does not build correctly on El Capitan as of 2015-12-03, so when building Slicer turn `Slicer_USE_PYTHONQT_WITH_TCL` off.&lt;br /&gt;
&lt;br /&gt;
==== Mac OSX 10.12 (Sierra) ====&lt;br /&gt;
&lt;br /&gt;
Similar to 10.11 (El Capitan), there are new issues with Qt4 (caused by Phonon).&lt;br /&gt;
The GitHub user Cartr [https://github.com/Homebrew/homebrew-core/pull/5216 offered a patch to the brew team], and even though it was not integrated (the homebrew team decided to stop patching their recipe to encourage people to use Qt5), he [https://github.com/cartr/homebrew-qt4 turned his formula into a tap] that can be installed (see below).&lt;br /&gt;
&lt;br /&gt;
Follow instructions for 10.11 ''(Installing Xcode, XQuartz, run without TCL)'' but install '''Qt4''' like shown below instead:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
brew install cartr/qt4/qt&lt;br /&gt;
xcode-select --install&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Confirmed with Xcode: Version 8.1 (8B62) and cmake version 3.4.20151021-g8fbc8e&lt;br /&gt;
&amp;lt;!--&lt;br /&gt;
DCMAKE_OSX_DEPLOYMENT_TARGET:STRING=10.9 -DSlicer_USE_PYTHONQT_WITH_TCL:BOOL=OFF ../Slicer&lt;br /&gt;
make -j `sysctl -n hw.ncpu`&lt;br /&gt;
--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Windows ===&lt;br /&gt;
&lt;br /&gt;
==== Common Prerequisites ====&lt;br /&gt;
* [{{tool|download|cmake}} CMake] &amp;gt;= 3.0 (3.7.1 recommended)&lt;br /&gt;
* [{{tool|download|git}} Git] &amp;gt;= 1.7.10&lt;br /&gt;
&amp;lt;!--&lt;br /&gt;
*[[{{tool|logo|cmake}}|x16px]]  [{{tool|download|cmake}}  CMake] &amp;gt;= 2.8.10&lt;br /&gt;
*[[{{tool|logo|git}}|x16px]]  [{{tool|download|git}}  Git] &amp;gt;= 1.7.10&lt;br /&gt;
* [https://code.google.com/p/msysgit/downloads/list?can=3 ''Git-X.X.X-preview2013XXXX.exe''] recommended.&lt;br /&gt;
--&amp;gt;&lt;br /&gt;
&amp;lt;!--&lt;br /&gt;
** Use of [http://code.google.com/p/tortoisegit/ TortoiseGit] is optional.&lt;br /&gt;
--&amp;gt;&lt;br /&gt;
** {{note}}For convenience, you could update the PATH variable so that ''git'' can be automatically discovered when configuring Slicer. If not, you will have to specify the GIT_EXECUTABLE at configure time.&lt;br /&gt;
&lt;br /&gt;
* [http://www.sliksvn.com/en/download SlikSvn] &amp;lt;!-- or [http://www.cygwin.com cygwin's svn client]--&amp;gt;. If using TortoiseSVN (versions that support command line tools), make sure you install Command line tools (disabled by default)&lt;br /&gt;
&lt;br /&gt;
* NSIS (optional): Needed if packaging Slicer - Click [http://nsis.sourceforge.net/Download here] to download.&lt;br /&gt;
&lt;br /&gt;
* Qt: See details [[Documentation/{{documentation/version}}/Developers/Build_Instructions/Prerequisites/Qt#Windows|here]].&lt;br /&gt;
&lt;br /&gt;
==== Tested and recommended build environment ====&lt;br /&gt;
&lt;br /&gt;
* [https://www.visualstudio.com/en-us/news/vs2013-community-vs.aspx Visual Studio 2013] with Update 5, as of [https://github.com/Slicer/Slicer/commit/71602609ce2ae5e473ece392500825ca96213371 commit 7160260]: Slicer compilation is successful, with some caveats.&lt;br /&gt;
** CMake &amp;gt;= 3.3.1&lt;br /&gt;
** Build Qt 4.8.7 with SSL support using [https://github.com/jcfr/qt-easy-build/tree/4.8.7 qt-easy-build].&lt;br /&gt;
** For Debug mode, disable &amp;lt;code&amp;gt;Slicer_USE_SimpleITK&amp;lt;/code&amp;gt; in CMake.&lt;br /&gt;
&lt;br /&gt;
'''Note: be sure to pick the version of qmake that you built in the earlier steps if applicable (CMake may pick a different qmake, for example if installed with anaconda)'''&lt;br /&gt;
&lt;br /&gt;
==== Experimental/deprecated build environments ====&lt;br /&gt;
&lt;br /&gt;
* VS2008 (deprecated)&lt;br /&gt;
** [https://www.microsoft.com/visualstudio/en-us/products/2008-editions Microsoft Visual Studio 9 2008] (Any edition). [http://go.microsoft.com/?linkid=7729279 VS Express 2008 with SP1 direct link] (functional as of Jan 11, 2014)&lt;br /&gt;
** Make sure to install SP1: Click [http://www.microsoft.com/download/en/details.aspx?id=10986 here] to download SP1 and click [http://massmail.spl.harvard.edu/public-archives/slicer-devel/2012/008206.html here] to understand the motivation.&lt;br /&gt;
*** Make sure to patch VS2008 using the script [https://gist.github.com/jcfr/3c7bef3f8b32f9f6ad4b fix-vc9-redist-manifests.ps1]&lt;br /&gt;
* VS2010 (experimental, may not work)&lt;br /&gt;
** [https://www.microsoft.com/visualstudio/en-us/products/2010-editions Microsoft Visual Studio 2010] (Any edition)&lt;br /&gt;
** Make sure to build or install:&lt;br /&gt;
*** Qt 4.8 &lt;br /&gt;
** Make sure to install:&lt;br /&gt;
*** SP1. Click [http://www.microsoft.com/download/en/details.aspx?id=23691 here] to download SP1 and click [http://developer.qt.nokia.com/faq/answer/why_do_all_qt_4.7_applications_crash_when_using_windows_7_x64_w_vs_2010 here] to understand the motivation.&lt;br /&gt;
*** SP1 Compiler update. Click [https://www.microsoft.com/download/en/details.aspx?id=4422 here] to download and [http://slicer-devel.65872.n3.nabble.com/Windows-7-64Bits-Slicer-4-Build-with-VC-2010-problem-tt3730524.html#a3731661 here] to understand the motivation.&lt;br /&gt;
&amp;lt;!-- JC: This links shouldn't be here: 1) Since this the developer section, it's assumed Visual Studio is installed. 2) The Dll are distributed within Slicer package --&amp;gt;&lt;br /&gt;
&amp;lt;!-- *** Optional: &amp;quot;Microsoft Visual C++ 2010 SP1 Redistributable Package&amp;quot;. Click [http://www.microsoft.com/download/en/details.aspx?id=13523 here for x64] download, or [http://www.microsoft.com/download/en/details.aspx?id=13523 here for x86] download.  [http://www.microsoft.com/download/en/details.aspx?displaylang=en&amp;amp;id=29 x86 (32bit) for VS 2008] --&amp;gt;&lt;br /&gt;
* VS2012 (experimental)&lt;br /&gt;
** Use a desktop version such as [http://www.microsoft.com/visualstudio/eng/downloads#d-express-windows-desktop Visual Studio 2012 Express &amp;lt;b&amp;gt;for Windows Desktop&amp;lt;/b&amp;gt;] and remember [http://www.microsoft.com/en-us/download/details.aspx?id=38188 Visual Studio 2012 Update 2]). Do &amp;lt;b&amp;gt;not&amp;lt;/b&amp;gt; use Visual Studio Express 2012 &amp;lt;em&amp;gt;for Windows 8&amp;lt;/em&amp;gt;. You must install [http://msdn.microsoft.com/en-us/library/ms717422.aspx Windows SDK], otherwise CMake will not even find the C compiler during configure. In CMake, choose &amp;lt;tt&amp;gt;Visual Studio 11 Win64&amp;lt;/tt&amp;gt; as generator.&lt;br /&gt;
* Cygwin (untested)&lt;br /&gt;
** Cygwin suite (building with cygwin gcc not supported, but the cygwin shell environment can be used to run git, svn, etc).&lt;/div&gt;</summary>
		<author><name>Inorton</name></author>
		
	</entry>
	<entry>
		<id>https://www.slicer.org/w/index.php?title=Help&amp;diff=52993</id>
		<title>Help</title>
		<link rel="alternate" type="text/html" href="https://www.slicer.org/w/index.php?title=Help&amp;diff=52993"/>
		<updated>2017-07-12T17:30:03Z</updated>

		<summary type="html">&lt;p&gt;Inorton: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Introduction=&lt;br /&gt;
This page is intended to provide links to places where Slicer Users can get help.&lt;br /&gt;
&lt;br /&gt;
=Discourse Forum=&lt;br /&gt;
The most effective way to get help from the community is through [https://discourse.slicer.org the 3D Slicer community page on Discourse]. Categories:&lt;br /&gt;
* [mailto:slicer+support@discoursemail.com Support]: usage related questions&lt;br /&gt;
* [mailto:slicer+dev@discoursemail.com  Development]: programming related questions&lt;br /&gt;
&lt;br /&gt;
=Training and Documentation=&lt;br /&gt;
*The [[Documentation/{{documentation/currentversion}}/Training|Training page]] provides a series of courses for learning how to use Slicer4. The portfolio contains self-guided presentation and sample data sets.&lt;br /&gt;
*Reference manual style [[Documentation/{{documentation/currentversion}}|documentation]] for Slicer4 can be found on the Slicer Wiki.&lt;br /&gt;
&lt;br /&gt;
=Frequently Asked Questions FAQs=&lt;br /&gt;
We maintain a curated list of questions and answers for both users and developers:&lt;br /&gt;
* [[Documentation/{{documentation/currentversion}}/FAQ | Users FAQ]]&lt;br /&gt;
* [[Documentation/{{documentation/currentversion}}/Developers/FAQ | Developers FAQ]]&lt;br /&gt;
&lt;br /&gt;
=Downloading Slicer=&lt;br /&gt;
*Slicer is free open source software and is distributed under a BSD license. Please read the [[Projects/slicerWeb:LicenseText| Slicer License Agreement]], if you use Slicer. &lt;br /&gt;
*Compiled binaries are accessible through the [http://download.slicer.org Slicer Download] page.&lt;br /&gt;
&lt;br /&gt;
=Bug Reports and Feature Requests=&lt;br /&gt;
We have a data base of bug reports and feature request which is based on a software package called &amp;quot;Mantis&amp;quot;.&lt;br /&gt;
Please file your reports in mantis and send an email about the report to the slicer-users mailing list.&lt;br /&gt;
* In order to file a feature request or a bug report, please sign up on http://www.na-mic.org/Bug/signup_page.php, then click on the '''Report Issue''' link in your browser.&lt;br /&gt;
* See [[Documentation/{{documentation/currentversion}}/Report_a_problem|here]] for additional tips on reporting issues.&lt;br /&gt;
&lt;br /&gt;
=Mailing List (discontinued) Archives=&lt;br /&gt;
Prior to Discourse, support and development discussions were conducted on several mailing lists, for which 10+ years of archives are available:&lt;br /&gt;
* [http://massmail.spl.harvard.edu/public-archives/slicer-users slicer-users (usage questions) archive ].&lt;br /&gt;
** ([http://slicer-users.65878.n3.nabble.com/ searchable Nabble mirror])&lt;br /&gt;
* [http://massmail.spl.harvard.edu/public-archives/slicer-devel slicer-devel (programming questions) archive]&lt;br /&gt;
** ([http://slicer-devel.65872.n3.nabble.com/ searchable Nabble mirror])&lt;/div&gt;</summary>
		<author><name>Inorton</name></author>
		
	</entry>
	<entry>
		<id>https://www.slicer.org/w/index.php?title=Contact&amp;diff=52290</id>
		<title>Contact</title>
		<link rel="alternate" type="text/html" href="https://www.slicer.org/w/index.php?title=Contact&amp;diff=52290"/>
		<updated>2017-06-08T20:41:57Z</updated>

		<summary type="html">&lt;p&gt;Inorton: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;As a first step '''please follow [http://www.slicer.org/slicerWiki/index.php/Documentation/UserFeedback the user feedback guidelines] and use the issue tracker and [http://wiki.slicer.org/slicerWiki/index.php/Help discussion forum]'''.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The people at the emails listed below should only be contacted directly if you have a private issue that cannot be addressed in a public forum.  If you contact one of these people please cc all three rather than sending three independent copies of the same email to all three as this just wastes time (yes, people do that!).&lt;br /&gt;
&lt;br /&gt;
'''How-to questions to the addresses below will be redirected to the discussion forum'''.&lt;br /&gt;
&lt;br /&gt;
* Steve Pieper, Chief Architect&lt;br /&gt;
** pieper [at] isomics.com&lt;br /&gt;
&lt;br /&gt;
* Jean-Christophe Fillion-Robin, Lead Developer &lt;br /&gt;
** jchris.fillionr [at] kitware.com &lt;br /&gt;
&lt;br /&gt;
* Ron Kikinis, Principal Investigator for many Slicer-related projects&lt;br /&gt;
** kikinis [at] bwh.harvard.edu&lt;br /&gt;
&lt;br /&gt;
&amp;lt;big&amp;gt;Again: all technical support questions should go to the [http://wiki.slicer.org/slicerWiki/index.php/Help Slicer discussion forum].&amp;lt;/big&amp;gt;&lt;/div&gt;</summary>
		<author><name>Inorton</name></author>
		
	</entry>
	<entry>
		<id>https://www.slicer.org/w/index.php?title=Contact&amp;diff=52287</id>
		<title>Contact</title>
		<link rel="alternate" type="text/html" href="https://www.slicer.org/w/index.php?title=Contact&amp;diff=52287"/>
		<updated>2017-06-08T20:41:22Z</updated>

		<summary type="html">&lt;p&gt;Inorton: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;As a first step '''please follow [http://www.slicer.org/slicerWiki/index.php/Documentation/UserFeedback the user feedback guidelines] and use the issue tracker and [http://wiki.slicer.org/slicerWiki/index.php/Help discussion forum]'''.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The people at the emails listed below should only be contacted directly if you have a private issue that cannot be addressed in a public forum.  If you contact one of these people please cc all three rather than sending three independent copies of the same email to all three as this just wastes time (yes, people do that!).&lt;br /&gt;
&lt;br /&gt;
'''How-to questions to the addresses below will be redirected to the discussion forum'''.&lt;br /&gt;
&lt;br /&gt;
* Steve Pieper, Chief Architect&lt;br /&gt;
** pieper [at] isomics.com&lt;br /&gt;
&lt;br /&gt;
* Jean-Christophe Fillion-Robin, Lead Developer &lt;br /&gt;
** jchris.fillionr [at] kitware.com &lt;br /&gt;
&lt;br /&gt;
* Ron Kikinis, Principal Investigator for many Slicer-related projects&lt;br /&gt;
** kikinis [at] bwh.harvard.edu&lt;br /&gt;
&lt;br /&gt;
&amp;lt;big&amp;gt;Again: all technical support questions should go to the [http://wiki.slicer.org/slicerWiki/index.php/Help Slicer discussion forum]&amp;lt;/big&amp;gt;&lt;/div&gt;</summary>
		<author><name>Inorton</name></author>
		
	</entry>
	<entry>
		<id>https://www.slicer.org/w/index.php?title=Documentation/4.6/Report_a_problem&amp;diff=52243</id>
		<title>Documentation/4.6/Report a problem</title>
		<link rel="alternate" type="text/html" href="https://www.slicer.org/w/index.php?title=Documentation/4.6/Report_a_problem&amp;diff=52243"/>
		<updated>2017-06-08T13:38:34Z</updated>

		<summary type="html">&lt;p&gt;Inorton: /* User Feedback */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;!--&lt;br /&gt;
&amp;lt;noinclude&amp;gt;{{documentation/versioncheck}}&amp;lt;/noinclude&amp;gt;&lt;br /&gt;
--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=User Feedback=&lt;br /&gt;
&lt;br /&gt;
*I have a question about how to use Slicer for a particular task or I'm not sure things are working right&lt;br /&gt;
** Try your best to sort out the issue by reading documentation and checking error logs&lt;br /&gt;
*** Look at our [[Documentation/UserTraining|portfolio of training materials]] and make a google search to see if the question has been discussed.&lt;br /&gt;
*** Check the [[Documentation/{{documentation/version}}/SlicerApplication/ErrorLog#To_capture_the_entire_error_log_for_a_report|Error Log]] to see if there's something misconfigured, such as a directory that is not readable or writable.&lt;br /&gt;
** I am still unclear about what to do.&lt;br /&gt;
*** &amp;lt;big&amp;gt;[https://discourse.slicer.org Ask a question on the Slicer Forum!]&amp;lt;/big&amp;gt;&lt;br /&gt;
*Something is definitely not working as it should or I would like to request a feature.&lt;br /&gt;
** File a bug report in the issues [http://na-mic.org/Mantis/bug_report_page.php tracker] (you need to register first). It is important to provide enough specific information so that a software developer can duplicate the problem - [[Documentation/{{documentation/version}}/Report_a_problem#Error_report_contents|see details below]].&lt;br /&gt;
** Don't be anonymous: real people trying hard to solve real problems are more likely to get valuable help.  A vague question from a random email is likely to be ignored..&lt;br /&gt;
* I would like to let the Slicer community know, how Slicer helped me in my research.&lt;br /&gt;
**Please send us the citation for your paper.&lt;br /&gt;
**Background: funding for Slicer is provided through competitive mechanisms to a large extent by the US government and to a lesser extend through funding from other governments. The justification of for those resources is that Slicer enables scientific work. Knowing about scientific publications enabled by Slicer is a critical step in this process. Given the international nature of the Slicer community, the nationality of the scientists is not important. Every good paper counts.&lt;br /&gt;
* I would like to give feedback on my experience with Slicer.&lt;br /&gt;
**Share your story using the Feedback link accessible from the Slicer Welcome module&lt;br /&gt;
&lt;br /&gt;
==Error report contents==&lt;br /&gt;
* Describe:&lt;br /&gt;
** What steps were performed before the problem occurred&lt;br /&gt;
** What behavior you expected&lt;br /&gt;
** What happened instead&lt;br /&gt;
* Copy-paste the error log: you can access it from Slicer in the menu: Help / Report a bug. By default log of the current session is displayed but you can retrieve the logs of the last few sessions&lt;br /&gt;
* Optional: capture a screenshot that illustrates the issue&lt;br /&gt;
&lt;br /&gt;
That could be summarized by the SSCCE (Short, Self Contained, Correct (Compilable), Example) approach documented on http://sscce.org&lt;br /&gt;
&lt;br /&gt;
==Workflow for Handling Bugs and Feature Requests in Slicer==&lt;br /&gt;
&lt;br /&gt;
The following instructions describes the recommended workflow to report a problem related to Slicer application. &lt;br /&gt;
&lt;br /&gt;
* 1. [http://na-mic.org/Mantis/signup_page.php Register] on the issue tracker&lt;br /&gt;
&lt;br /&gt;
* 2. [http://massmail.spl.harvard.edu/mailman/listinfo/slicer-devel Sign-up] on the developers mailing list&lt;br /&gt;
&lt;br /&gt;
* 3. Create an issue in the [http://na-mic.org/Mantis/bug_report_page.php tracker].&lt;br /&gt;
&lt;br /&gt;
* 4. Optionally, if you would like to share dataset &amp;gt;= 2MB, you should consider uploading them on our dedicated server. See [[Documentation/{{documentation/version}}/Report_a_problem/UploadData|How to share and associate data with an issue]]&lt;br /&gt;
&lt;br /&gt;
* 5. Send an email on the [http://massmail.spl.harvard.edu/mailman/listinfo/slicer-devel slicer-developers] list pointing to the reported bug. Title of the email should start with &amp;lt;code&amp;gt;[BUG 1234] Title of the bug&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{:Documentation/{{documentation/version}}/Developers/IssueWorkflow}}&lt;/div&gt;</summary>
		<author><name>Inorton</name></author>
		
	</entry>
	<entry>
		<id>https://www.slicer.org/w/index.php?title=Documentation/Nightly/Report_a_problem&amp;diff=52240</id>
		<title>Documentation/Nightly/Report a problem</title>
		<link rel="alternate" type="text/html" href="https://www.slicer.org/w/index.php?title=Documentation/Nightly/Report_a_problem&amp;diff=52240"/>
		<updated>2017-06-08T13:35:47Z</updated>

		<summary type="html">&lt;p&gt;Inorton: /* User Feedback */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;!--&lt;br /&gt;
&amp;lt;noinclude&amp;gt;{{documentation/versioncheck}}&amp;lt;/noinclude&amp;gt;&lt;br /&gt;
--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=User Feedback=&lt;br /&gt;
&lt;br /&gt;
*I have a question about how to use Slicer for a particular task or I'm not sure things are working right&lt;br /&gt;
** Try your best to sort out the issue by reading documentation and checking error logs&lt;br /&gt;
*** Look at our [[Documentation/UserTraining|portfolio of training materials]] and make a google search to see if the question has been discussed.&lt;br /&gt;
*** Check the [[Documentation/{{documentation/version}}/SlicerApplication/ErrorLog#To_capture_the_entire_error_log_for_a_report|Error Log]] to see if there's something misconfigured, such as a directory that is not readable or writable.&lt;br /&gt;
** I am still unclear about what to do.&lt;br /&gt;
*** &amp;lt;big&amp;gt;[https://discourse.slicer.org Ask a question on the Slicer Forum!]&amp;lt;/big&amp;gt;&lt;br /&gt;
*Something is definitely not working as it should or I would like to request a feature.&lt;br /&gt;
** File a bug report in the issues [http://na-mic.org/Mantis/bug_report_page.php tracker] (you need to register first). It is important to provide enough specific information so that a software developer can duplicate the problem - [[Documentation/{{documentation/version}}/Report_a_problem#Error_report_contents|see details below]].&lt;br /&gt;
** Don't be anonymous: real people trying hard to solve real problems are more likely to get valuable help.  A vague question from a random email is likely to be ignored..&lt;br /&gt;
* I would like to let the Slicer community know, how Slicer helped me in my research.&lt;br /&gt;
**Please send us the citation for your paper.&lt;br /&gt;
**Background: funding for Slicer is provided through competitive mechanisms to a large extent by the US government and to a lesser extend through funding from other governments. The justification of for those resources is that Slicer enables scientific work. Knowing about scientific publications enabled by Slicer is a critical step in this process. Given the international nature of the Slicer community, the nationality of the scientists is not important. Every good paper counts.&lt;br /&gt;
* I would like to give feedback on my experience with Slicer.&lt;br /&gt;
**Share your story using the Feedback link accessible from the Slicer Welcome module&lt;br /&gt;
&lt;br /&gt;
==Error report contents==&lt;br /&gt;
* Describe:&lt;br /&gt;
** What steps were performed before the problem occurred&lt;br /&gt;
** What behavior you expected&lt;br /&gt;
** What happened instead&lt;br /&gt;
* Copy-paste the error log: you can access it from Slicer in the menu: Help / Report a bug. By default log of the current session is displayed but you can retrieve the logs of the last few sessions&lt;br /&gt;
* Optional: capture a screenshot that illustrates the issue&lt;br /&gt;
&lt;br /&gt;
That could be summarized by the SSCCE (Short, Self Contained, Correct (Compilable), Example) approach documented on http://sscce.org&lt;br /&gt;
&lt;br /&gt;
==Workflow for Handling Bugs and Feature Requests in Slicer==&lt;br /&gt;
&lt;br /&gt;
The following instructions describes the recommended workflow to report a problem related to Slicer application. &lt;br /&gt;
&lt;br /&gt;
* 1. [http://na-mic.org/Mantis/signup_page.php Register] on the issue tracker&lt;br /&gt;
&lt;br /&gt;
* 2. [http://massmail.spl.harvard.edu/mailman/listinfo/slicer-devel Sign-up] on the developers mailing list&lt;br /&gt;
&lt;br /&gt;
* 3. Create an issue in the [http://na-mic.org/Mantis/bug_report_page.php tracker].&lt;br /&gt;
&lt;br /&gt;
* 4. Optionally, if you would like to share dataset &amp;gt;= 2MB, you should consider uploading them on our dedicated server. See [[Documentation/{{documentation/version}}/Report_a_problem/UploadData|How to share and associate data with an issue]]&lt;br /&gt;
&lt;br /&gt;
* 5. Send an email on the [http://massmail.spl.harvard.edu/mailman/listinfo/slicer-devel slicer-developers] list pointing to the reported bug. Title of the email should start with &amp;lt;code&amp;gt;[BUG 1234] Title of the bug&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{:Documentation/{{documentation/version}}/Developers/IssueWorkflow}}&lt;/div&gt;</summary>
		<author><name>Inorton</name></author>
		
	</entry>
	<entry>
		<id>https://www.slicer.org/w/index.php?title=Documentation/Nightly/Report_a_problem&amp;diff=52235</id>
		<title>Documentation/Nightly/Report a problem</title>
		<link rel="alternate" type="text/html" href="https://www.slicer.org/w/index.php?title=Documentation/Nightly/Report_a_problem&amp;diff=52235"/>
		<updated>2017-06-08T13:28:33Z</updated>

		<summary type="html">&lt;p&gt;Inorton: /* User Feedback */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;!--&lt;br /&gt;
&amp;lt;noinclude&amp;gt;{{documentation/versioncheck}}&amp;lt;/noinclude&amp;gt;&lt;br /&gt;
--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=User Feedback=&lt;br /&gt;
&lt;br /&gt;
*I have a question about how to use Slicer for a particular task or I'm not sure things are working right&lt;br /&gt;
** Try your best to sort out the issue by reading documentation and checking error logs&lt;br /&gt;
*** Look at our [[Documentation/UserTraining|portfolio of training materials]] and make a google search to see if the question has been discussed.&lt;br /&gt;
*** Check the [[Documentation/{{documentation/version}}/SlicerApplication/ErrorLog#To_capture_the_entire_error_log_for_a_report|Error Log]] to see if there's something misconfigured, such as a directory that is not readable or writable.&lt;br /&gt;
** I am still unclear about what to do.&lt;br /&gt;
*** &amp;lt;big&amp;gt;[https://discourse.slicer.org Ask a question on the Slicer Forum!]&amp;lt;/big&amp;gt;&lt;br /&gt;
*Something is definitely not working as it should or I would like to request a feature.&lt;br /&gt;
** File a bug report in the issues [http://na-mic.org/Mantis/bug_report_page.php tracker] (you need to register first) or on the [http://massmail.spl.harvard.edu/mailman/listinfo/slicer-users Slicer users mailing list]. It is important to provide enough specific information so that a software developer can duplicate the problem - [[Documentation/{{documentation/version}}/Report_a_problem#Error_report_contents|see details below]].&lt;br /&gt;
** Don't be anonymous: real people trying hard to solve real problems are more likely to get valuable help.  A vague question from a random email is likely to be ignored..&lt;br /&gt;
* I would like to let the Slicer community know, how Slicer helped me in my research.&lt;br /&gt;
**Please send us the citation for your paper.&lt;br /&gt;
**Background: funding for Slicer is provided through competitive mechanisms to a large extent by the US government and to a lesser extend through funding from other governments. The justification of for those resources is that Slicer enables scientific work. Knowing about scientific publications enabled by Slicer is a critical step in this process. Given the international nature of the Slicer community, the nationality of the scientists is not important. Every good paper counts.&lt;br /&gt;
* I would like to give feedback on my experience with Slicer.&lt;br /&gt;
**Share your story using the Feedback link accessible from the Slicer Welcome module&lt;br /&gt;
&lt;br /&gt;
==Error report contents==&lt;br /&gt;
* Describe:&lt;br /&gt;
** What steps were performed before the problem occurred&lt;br /&gt;
** What behavior you expected&lt;br /&gt;
** What happened instead&lt;br /&gt;
* Copy-paste the error log: you can access it from Slicer in the menu: Help / Report a bug. By default log of the current session is displayed but you can retrieve the logs of the last few sessions&lt;br /&gt;
* Optional: capture a screenshot that illustrates the issue&lt;br /&gt;
&lt;br /&gt;
That could be summarized by the SSCCE (Short, Self Contained, Correct (Compilable), Example) approach documented on http://sscce.org&lt;br /&gt;
&lt;br /&gt;
==Workflow for Handling Bugs and Feature Requests in Slicer==&lt;br /&gt;
&lt;br /&gt;
The following instructions describes the recommended workflow to report a problem related to Slicer application. &lt;br /&gt;
&lt;br /&gt;
* 1. [http://na-mic.org/Mantis/signup_page.php Register] on the issue tracker&lt;br /&gt;
&lt;br /&gt;
* 2. [http://massmail.spl.harvard.edu/mailman/listinfo/slicer-devel Sign-up] on the developers mailing list&lt;br /&gt;
&lt;br /&gt;
* 3. Create an issue in the [http://na-mic.org/Mantis/bug_report_page.php tracker].&lt;br /&gt;
&lt;br /&gt;
* 4. Optionally, if you would like to share dataset &amp;gt;= 2MB, you should consider uploading them on our dedicated server. See [[Documentation/{{documentation/version}}/Report_a_problem/UploadData|How to share and associate data with an issue]]&lt;br /&gt;
&lt;br /&gt;
* 5. Send an email on the [http://massmail.spl.harvard.edu/mailman/listinfo/slicer-devel slicer-developers] list pointing to the reported bug. Title of the email should start with &amp;lt;code&amp;gt;[BUG 1234] Title of the bug&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{:Documentation/{{documentation/version}}/Developers/IssueWorkflow}}&lt;/div&gt;</summary>
		<author><name>Inorton</name></author>
		
	</entry>
	<entry>
		<id>https://www.slicer.org/w/index.php?title=Documentation/4.6/Report_a_problem&amp;diff=52232</id>
		<title>Documentation/4.6/Report a problem</title>
		<link rel="alternate" type="text/html" href="https://www.slicer.org/w/index.php?title=Documentation/4.6/Report_a_problem&amp;diff=52232"/>
		<updated>2017-06-08T13:28:28Z</updated>

		<summary type="html">&lt;p&gt;Inorton: /* User Feedback */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;!--&lt;br /&gt;
&amp;lt;noinclude&amp;gt;{{documentation/versioncheck}}&amp;lt;/noinclude&amp;gt;&lt;br /&gt;
--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=User Feedback=&lt;br /&gt;
&lt;br /&gt;
*I have a question about how to use Slicer for a particular task or I'm not sure things are working right&lt;br /&gt;
** Try your best to sort out the issue by reading documentation and checking error logs&lt;br /&gt;
*** Look at our [[Documentation/UserTraining|portfolio of training materials]] and make a google search to see if the question has been discussed.&lt;br /&gt;
*** Check the [[Documentation/{{documentation/version}}/SlicerApplication/ErrorLog#To_capture_the_entire_error_log_for_a_report|Error Log]] to see if there's something misconfigured, such as a directory that is not readable or writable.&lt;br /&gt;
** I am still unclear about what to do.&lt;br /&gt;
*** &amp;lt;big&amp;gt;[https://discourse.slicer.org Ask a question on the Slicer Forum!]&amp;lt;/big&amp;gt;&lt;br /&gt;
*Something is definitely not working as it should or I would like to request a feature.&lt;br /&gt;
** File a bug report in the issues [http://na-mic.org/Mantis/bug_report_page.php tracker] (you need to register first) or on the [http://massmail.spl.harvard.edu/mailman/listinfo/slicer-users Slicer users mailing list]. It is important to provide enough specific information so that a software developer can duplicate the problem - [[Documentation/{{documentation/version}}/Report_a_problem#Error_report_contents|see details below]].&lt;br /&gt;
** Don't be anonymous: real people trying hard to solve real problems are more likely to get valuable help.  A vague question from a random email is likely to be ignored..&lt;br /&gt;
* I would like to let the Slicer community know, how Slicer helped me in my research.&lt;br /&gt;
**Please send us the citation for your paper.&lt;br /&gt;
**Background: funding for Slicer is provided through competitive mechanisms to a large extent by the US government and to a lesser extend through funding from other governments. The justification of for those resources is that Slicer enables scientific work. Knowing about scientific publications enabled by Slicer is a critical step in this process. Given the international nature of the Slicer community, the nationality of the scientists is not important. Every good paper counts.&lt;br /&gt;
* I would like to give feedback on my experience with Slicer.&lt;br /&gt;
**Share your story using the Feedback link accessible from the Slicer Welcome module&lt;br /&gt;
&lt;br /&gt;
==Error report contents==&lt;br /&gt;
* Describe:&lt;br /&gt;
** What steps were performed before the problem occurred&lt;br /&gt;
** What behavior you expected&lt;br /&gt;
** What happened instead&lt;br /&gt;
* Copy-paste the error log: you can access it from Slicer in the menu: Help / Report a bug. By default log of the current session is displayed but you can retrieve the logs of the last few sessions&lt;br /&gt;
* Optional: capture a screenshot that illustrates the issue&lt;br /&gt;
&lt;br /&gt;
That could be summarized by the SSCCE (Short, Self Contained, Correct (Compilable), Example) approach documented on http://sscce.org&lt;br /&gt;
&lt;br /&gt;
==Workflow for Handling Bugs and Feature Requests in Slicer==&lt;br /&gt;
&lt;br /&gt;
The following instructions describes the recommended workflow to report a problem related to Slicer application. &lt;br /&gt;
&lt;br /&gt;
* 1. [http://na-mic.org/Mantis/signup_page.php Register] on the issue tracker&lt;br /&gt;
&lt;br /&gt;
* 2. [http://massmail.spl.harvard.edu/mailman/listinfo/slicer-devel Sign-up] on the developers mailing list&lt;br /&gt;
&lt;br /&gt;
* 3. Create an issue in the [http://na-mic.org/Mantis/bug_report_page.php tracker].&lt;br /&gt;
&lt;br /&gt;
* 4. Optionally, if you would like to share dataset &amp;gt;= 2MB, you should consider uploading them on our dedicated server. See [[Documentation/{{documentation/version}}/Report_a_problem/UploadData|How to share and associate data with an issue]]&lt;br /&gt;
&lt;br /&gt;
* 5. Send an email on the [http://massmail.spl.harvard.edu/mailman/listinfo/slicer-devel slicer-developers] list pointing to the reported bug. Title of the email should start with &amp;lt;code&amp;gt;[BUG 1234] Title of the bug&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{:Documentation/{{documentation/version}}/Developers/IssueWorkflow}}&lt;/div&gt;</summary>
		<author><name>Inorton</name></author>
		
	</entry>
	<entry>
		<id>https://www.slicer.org/w/index.php?title=Documentation/Nightly/Report_a_problem&amp;diff=52229</id>
		<title>Documentation/Nightly/Report a problem</title>
		<link rel="alternate" type="text/html" href="https://www.slicer.org/w/index.php?title=Documentation/Nightly/Report_a_problem&amp;diff=52229"/>
		<updated>2017-06-08T13:24:00Z</updated>

		<summary type="html">&lt;p&gt;Inorton: /* User Feedback */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;!--&lt;br /&gt;
&amp;lt;noinclude&amp;gt;{{documentation/versioncheck}}&amp;lt;/noinclude&amp;gt;&lt;br /&gt;
--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=User Feedback=&lt;br /&gt;
&lt;br /&gt;
*I have a question about how to use Slicer for a particular task or I'm not sure things are working right&lt;br /&gt;
** Try your best to sort out the issue by reading documentation and checking error logs&lt;br /&gt;
*** Look at our [[Documentation/UserTraining|portfolio of training materials]] and make a google search to see if the question has been discussed.&lt;br /&gt;
*** Check the [[Documentation/{{documentation/version}}/SlicerApplication/ErrorLog#To_capture_the_entire_error_log_for_a_report|Error Log]] to see if there's something misconfigured, such as a directory that is not readable or writable.&lt;br /&gt;
*** I am still unclear about what to do.&lt;br /&gt;
**** &amp;lt;big&amp;gt;[https://discourse.slicer.org Ask a question on the Slicer Forum!]&amp;lt;/big&amp;gt;&lt;br /&gt;
*Something is definitely not working as it should or I would like to request a feature.&lt;br /&gt;
** File a bug report in the issues [http://na-mic.org/Mantis/bug_report_page.php tracker] (you need to register first) or on the [http://massmail.spl.harvard.edu/mailman/listinfo/slicer-users Slicer users mailing list]. It is important to provide enough specific information so that a software developer can duplicate the problem - [[Documentation/{{documentation/version}}/Report_a_problem#Error_report_contents|see details below]].&lt;br /&gt;
** Don't be anonymous: real people trying hard to solve real problems are more likely to get valuable help.  A vague question from a random email is likely to be ignored..&lt;br /&gt;
* I would like to let the Slicer community know, how Slicer helped me in my research.&lt;br /&gt;
**Please send us the citation for your paper.&lt;br /&gt;
**Background: funding for Slicer is provided through competitive mechanisms to a large extent by the US government and to a lesser extend through funding from other governments. The justification of for those resources is that Slicer enables scientific work. Knowing about scientific publications enabled by Slicer is a critical step in this process. Given the international nature of the Slicer community, the nationality of the scientists is not important. Every good paper counts.&lt;br /&gt;
* I would like to give feedback on my experience with Slicer.&lt;br /&gt;
**Share your story using the Feedback link accessible from the Slicer Welcome module&lt;br /&gt;
&lt;br /&gt;
==Error report contents==&lt;br /&gt;
* Describe:&lt;br /&gt;
** What steps were performed before the problem occurred&lt;br /&gt;
** What behavior you expected&lt;br /&gt;
** What happened instead&lt;br /&gt;
* Copy-paste the error log: you can access it from Slicer in the menu: Help / Report a bug. By default log of the current session is displayed but you can retrieve the logs of the last few sessions&lt;br /&gt;
* Optional: capture a screenshot that illustrates the issue&lt;br /&gt;
&lt;br /&gt;
That could be summarized by the SSCCE (Short, Self Contained, Correct (Compilable), Example) approach documented on http://sscce.org&lt;br /&gt;
&lt;br /&gt;
==Workflow for Handling Bugs and Feature Requests in Slicer==&lt;br /&gt;
&lt;br /&gt;
The following instructions describes the recommended workflow to report a problem related to Slicer application. &lt;br /&gt;
&lt;br /&gt;
* 1. [http://na-mic.org/Mantis/signup_page.php Register] on the issue tracker&lt;br /&gt;
&lt;br /&gt;
* 2. [http://massmail.spl.harvard.edu/mailman/listinfo/slicer-devel Sign-up] on the developers mailing list&lt;br /&gt;
&lt;br /&gt;
* 3. Create an issue in the [http://na-mic.org/Mantis/bug_report_page.php tracker].&lt;br /&gt;
&lt;br /&gt;
* 4. Optionally, if you would like to share dataset &amp;gt;= 2MB, you should consider uploading them on our dedicated server. See [[Documentation/{{documentation/version}}/Report_a_problem/UploadData|How to share and associate data with an issue]]&lt;br /&gt;
&lt;br /&gt;
* 5. Send an email on the [http://massmail.spl.harvard.edu/mailman/listinfo/slicer-devel slicer-developers] list pointing to the reported bug. Title of the email should start with &amp;lt;code&amp;gt;[BUG 1234] Title of the bug&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{:Documentation/{{documentation/version}}/Developers/IssueWorkflow}}&lt;/div&gt;</summary>
		<author><name>Inorton</name></author>
		
	</entry>
	<entry>
		<id>https://www.slicer.org/w/index.php?title=Documentation/4.6/FAQ/General&amp;diff=52190</id>
		<title>Documentation/4.6/FAQ/General</title>
		<link rel="alternate" type="text/html" href="https://www.slicer.org/w/index.php?title=Documentation/4.6/FAQ/General&amp;diff=52190"/>
		<updated>2017-06-06T15:53:54Z</updated>

		<summary type="html">&lt;p&gt;Inorton: /* Where can I find someone to help me use Slicer? */&lt;/p&gt;
&lt;hr /&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;
{{#ifeq: {{#titleparts: {{PAGENAME}} | 3 }} | Documentation/{{documentation/version}}/Developers | | ='''User FAQ: {{{1}}}'''=}}&lt;br /&gt;
&amp;lt;/includeonly&amp;gt;&lt;br /&gt;
== What is Slicer ? ==&lt;br /&gt;
{{:Documentation/{{documentation/version}}/Slicer}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Where can I download Slicer? ==&lt;br /&gt;
3DSlicer is available for download by visiting the following link:  http://download.slicer.org&lt;br /&gt;
&lt;br /&gt;
== Where can I download older release of Slicer ? ==&lt;br /&gt;
&lt;br /&gt;
Older releases of 3DSlicer are available here: http://slicer.kitware.com/midas3/folder/274&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== How to install Slicer ? ==&lt;br /&gt;
&lt;br /&gt;
{{:Documentation/{{documentation/version}}/Slicer/Install}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Is Slicer really free?==&lt;br /&gt;
&lt;br /&gt;
Yes, really, truly, free.  Not just a free trial.  No pro version with all the good stuff.  Slicer is free with no strings attached.  You can even re-use the code in any way you want with no royalties and you don't even need to ask us for permission.  (Of course we're always happy to hear from people who've found slicer interesting).&lt;br /&gt;
&lt;br /&gt;
See [http://www.slicer.org/pages/LicenseText the Slicer License page] for the legal version of this.&lt;br /&gt;
&lt;br /&gt;
==Where can I find someone to help me use Slicer?==&lt;br /&gt;
&lt;br /&gt;
We rely on the community of users and developers to share their expertise. Slicer Community support and development discussions are hosted on Discourse, which provides a modern web forum as well as email-only interaction:&lt;br /&gt;
&lt;br /&gt;
    https://discourse.slicer.org&lt;br /&gt;
&lt;br /&gt;
If you post to any public forum, be sure not to include any [http://en.wikipedia.org/wiki/Protected_health_information Protected Health Information (PHI)] or any other data that would get you or anyone else in trouble.  However, posting example data can be very important to people who are interested in helping you solve your problems.  If you can replicate your question using data from the [[Documentation/{{documentation/version}}/Modules/SampleData|Sample Data]] or [[Documentation/{{documentation/version}}/Modules/DataStore|Data Store]] modules that's the first choice.&lt;br /&gt;
&lt;br /&gt;
The [[Documentation/Nightly | Users Manual]] gives descriptions for using each module, and you can check out the [[Documentation/Nightly/Training | Training pages]] for in depth tutorials about workflows.&lt;br /&gt;
&lt;br /&gt;
Mailing list discussions before 2017 April are [https://www.slicer.org/wiki/Help#Mailing_List_.28discontinued.29_Archives archived]&lt;br /&gt;
&lt;br /&gt;
==Can I use slicer for patient care?==&lt;br /&gt;
&lt;br /&gt;
Slicer is intended for research work and ''has no FDA clearances or approvals of any kind''.  It is the responsibility of the user to comply with all laws and regulations (and moral/ethical guidelines) when using slicer.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==How to cite Slicer?==&lt;br /&gt;
{{:CitingSlicer}}&lt;br /&gt;
&lt;br /&gt;
== How do I create an account for the Slicer wiki? ==&lt;br /&gt;
Please note: You only need an account if you want to edit or add pages. &lt;br /&gt;
&lt;br /&gt;
Follow the Log in-&amp;gt;Request Account link from the upper right corner of the slicer wiki page. Once the account request is approved, you will be e-mailed a notification message and the account will be usable at log in.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Can I install Slicer without administrator rights?==&lt;br /&gt;
&lt;br /&gt;
The most convenient way to install Slicer is to run the installer package (Slicer-{{documentation/currentversion}}....exe) as administrator. However, installation is not necessary, you just need to unpack the files in the installer package and copy them to your user directory or a USB drive and start it by running ''Slicer.exe''.&lt;br /&gt;
&lt;br /&gt;
You can unpack the installation package by one of the following methods:&lt;br /&gt;
* Install Slicer on any computer where you have administrator access. All the files that you need to run Slicer are in the C:\Program Files\Slicer... directory.&lt;br /&gt;
* Unpack the installation package by using 7zip or using the InstallExplorer plugin in Total commander or FAR manager (http://nsis.sourceforge.net/Can_I_decompile_an_existing_installer). All the Slicer files will be in the $_OUTDIR directory, except Slicer.exe, so you have to copy Slicer.exe into $_OUTDIR and run it from there. You can rename the $_OUTDIR directory and discard all the other directories ($COMMONFILES, $PLUGINSDIR, etc).&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==What if I have problems with Slicer installation?==&lt;br /&gt;
You can read our guide explaining [[Documentation/{{documentation/version}}/Report_a_problem|how to report a problem]].&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==How to uninstall Slicer?==&lt;br /&gt;
*On Windows, choose &amp;quot;Uninstall&amp;quot; option from the Start menu.&lt;br /&gt;
*On the Mac, remove the Slicer.app file. To clean up settings, remove &amp;quot;~/.config/www.na-mic.org/&amp;quot;&lt;br /&gt;
*On Linux, remove the directory where the application is located. To clean up settings, remove &amp;quot;~/.config/NA-MIC/&amp;quot;&lt;br /&gt;
&lt;br /&gt;
See the information about the location of [[Documentation/{{documentation/version}}/SlicerApplication/Settings|Settings]] for all platforms.  If the uninstaller is not working on windows you may need to remove the settings manually.&lt;br /&gt;
&lt;br /&gt;
== Where can I find Slicer tutorials? ==&lt;br /&gt;
Slicer tutorials associated with the latest {{documentation/currentversion}} stable release are available by visiting the following link:  [[Documentation/Nightly/Training|Click Here]].&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==I read errors in the logs complaining about memory==&lt;br /&gt;
&lt;br /&gt;
Errors such as “Description: Failed to allocate memory for image.” indicate that you don’t have enough memory space.&lt;br /&gt;
This can be a common issue if you run a 32-bit version of Slicer. You cannot expect a 32-bit executable to deal with any moderately complex problem. The [[Documentation/{{documentation/version}}/SlicerApplication/HardwareConfiguration#32_bit_versus_64_bit|recommended solution]] is to download/build/use Slicer in 64-bit mode.&lt;br /&gt;
 &lt;br /&gt;
Possible workarounds:&lt;br /&gt;
* Use a 64-bit version of Slicer &lt;br /&gt;
* You have somewhat more memory if you run the module in a separate process. To do that open [[Documentation/{{documentation/version}}/SlicerApplication/ApplicationSettings#Modules|Edit / Application Settings / Modules]] and check the “Prefer Executable CLIs” option, then restart Slicer.&lt;br /&gt;
* Decrease the size and/or resolution of the input and output images&lt;br /&gt;
** Consider [[Documentation/{{documentation/version}}/Modules/Crop_Volume|Crop Volume]] to focus on just your area of interest.&lt;br /&gt;
** Consider [[Documentation/{{documentation/version}}/Modules/ResampleScalarVectorDWIVolume|ResampleScalarVectorDWIVolume]] or [[Documentation/{{documentation/version}}/Modules/ResampleScalarVolume|ResampleScalarVolume]] increase the sample spacing (decrease the resolution) of your data.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Which Slicer version should I use: 3.X or 4.X ? ==&lt;br /&gt;
&lt;br /&gt;
In general slicer3 and slicer4 have roughly similar functionality with respect to registration basics.  Probably the most important thing to keep in mind is that slicer3 is no longer actively maintained.&lt;br /&gt;
&lt;br /&gt;
Slicer4, on the other hand, has benefited from literally hundreds of bug fixes over the past several years, and typically has better features and much better performance.  Also, the nightly builds of slicer4 are now using ITKv4, which has significantly improved registration code.  I am told by active users/developers of ITK that ITKv4 should provide significantly better results in many cases.  Also, several new registration techniques are being actively developed for slicer4.&lt;br /&gt;
&lt;br /&gt;
Source: http://massmail.spl.harvard.edu/public-archives/slicer-users/2013/006190.html&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== What is my HOME folder ? ==&lt;br /&gt;
&lt;br /&gt;
{|width = &amp;quot;100%&amp;quot;&lt;br /&gt;
! width=&amp;quot;50%&amp;quot; style=&amp;quot;border-bottom: 1px solid darkgrey;font-size: 75%;&amp;quot;| Linux or MacOSX&lt;br /&gt;
! width=&amp;quot;50%&amp;quot; style=&amp;quot;border-bottom: 1px solid darkgrey;font-size: 75%;&amp;quot;| Windows&lt;br /&gt;
|-&lt;br /&gt;
| valign=&amp;quot;top&amp;quot; |&lt;br /&gt;
Start a terminal.&lt;br /&gt;
{{pre2|&amp;lt;nowiki&amp;gt;&lt;br /&gt;
$ echo ~&lt;br /&gt;
/home/jchris&lt;br /&gt;
&amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
| valign=&amp;quot;top&amp;quot; |&lt;br /&gt;
&lt;br /&gt;
Start Command Prompt (Start Menu -&amp;gt; All Programs -&amp;gt; Accessories -&amp;gt; Command Prompt)&lt;br /&gt;
{{pre2|&amp;lt;nowiki&amp;gt;&lt;br /&gt;
&amp;gt; echo %userprofile%&lt;br /&gt;
C:\Users\jcfr&lt;br /&gt;
&amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
|}&lt;/div&gt;</summary>
		<author><name>Inorton</name></author>
		
	</entry>
	<entry>
		<id>https://www.slicer.org/w/index.php?title=Documentation/Nightly/FAQ/General&amp;diff=52187</id>
		<title>Documentation/Nightly/FAQ/General</title>
		<link rel="alternate" type="text/html" href="https://www.slicer.org/w/index.php?title=Documentation/Nightly/FAQ/General&amp;diff=52187"/>
		<updated>2017-06-06T15:52:00Z</updated>

		<summary type="html">&lt;p&gt;Inorton: /* Where can I find someone to help me use Slicer? */&lt;/p&gt;
&lt;hr /&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;
{{#ifeq: {{#titleparts: {{PAGENAME}} | 3 }} | Documentation/{{documentation/version}}/Developers | | ='''User FAQ: {{{1}}}'''=}}&lt;br /&gt;
&amp;lt;/includeonly&amp;gt;&lt;br /&gt;
== What is Slicer ? ==&lt;br /&gt;
{{:Documentation/{{documentation/version}}/Slicer}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Where can I download Slicer? ==&lt;br /&gt;
3DSlicer is available for download by visiting the following link:  '''http://download.slicer.org'''&lt;br /&gt;
&lt;br /&gt;
You can also get older releases by using the offset parameter in the download page. For example, download page from 7 days ago: http://download.slicer.org/?offset=-7&lt;br /&gt;
&lt;br /&gt;
To get a direct download link of previous revision on a selected operating system: http://download.slicer.org/download?os=macosx&amp;amp;stability=any&amp;amp;offset=-1&lt;br /&gt;
&lt;br /&gt;
Always include these parameters:&lt;br /&gt;
*  ''stability'', which can be ''release'', ''nightly'', or ''any''&lt;br /&gt;
*  ''os'', which can be ''win'', ''macosx'', or ''linux''&lt;br /&gt;
&lt;br /&gt;
Additional options:&lt;br /&gt;
* revision built before or on the date: ''date=2015-01-01''&lt;br /&gt;
* same but checkout date: ''checkout-date=2015-02-01''&lt;br /&gt;
* exact revision: ''revision=27000''&lt;br /&gt;
* revision less than of equal: ''closest-revision=26000''&lt;br /&gt;
* latest revision of 4.3 branch, can include patch as well: ''version=4.3''&lt;br /&gt;
&lt;br /&gt;
Any of these queries can be combined with the offset param, which will step forward or backward a given number of revisions. So,&lt;br /&gt;
''stability=release&amp;amp;version=4.5.0&amp;amp;offset=-1'' should give you the revision just before the first 4.5 release.&lt;br /&gt;
&lt;br /&gt;
== Where can I download older release of Slicer ? ==&lt;br /&gt;
&lt;br /&gt;
Older releases of 3DSlicer are available here: http://slicer.kitware.com/midas3/folder/274&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== How to install Slicer ? ==&lt;br /&gt;
&lt;br /&gt;
{{:Documentation/{{documentation/version}}/Slicer/Install}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Is Slicer really free?==&lt;br /&gt;
&lt;br /&gt;
Yes, really, truly, free.  Not just a free trial.  No pro version with all the good stuff.  Slicer is free with no strings attached.  You can even re-use the code in any way you want with no royalties and you don't even need to ask us for permission.  (Of course we're always happy to hear from people who've found slicer interesting).&lt;br /&gt;
&lt;br /&gt;
See [http://www.slicer.org/pages/LicenseText the Slicer License page] for the legal version of this.&lt;br /&gt;
&lt;br /&gt;
==Where can I find someone to help me use Slicer?==&lt;br /&gt;
&lt;br /&gt;
We rely on the community of users and developers to share their expertise. Slicer Community support and development discussions are hosted on Discourse, which provides a modern web forum as well as email-only interaction:&lt;br /&gt;
&lt;br /&gt;
    https://discourse.slicer.org&lt;br /&gt;
&lt;br /&gt;
If you post to any public forum, be sure not to include any [http://en.wikipedia.org/wiki/Protected_health_information Protected Health Information (PHI)] or any other data that would get you or anyone else in trouble.  However, posting example data can be very important to people who are interested in helping you solve your problems.  If you can replicate your question using data from the [[Documentation/{{documentation/version}}/Modules/SampleData|Sample Data]] or [[Documentation/{{documentation/version}}/Modules/DataStore|Data Store]] modules that's the first choice.&lt;br /&gt;
&lt;br /&gt;
The [[Documentation/Nightly | Users Manual]] gives descriptions for using each module, and you can check out the [[Documentation/Nightly/Training | Training pages]] for in depth tutorials about workflows.&lt;br /&gt;
&lt;br /&gt;
Mailing list discussions before 2017 April are [https://www.slicer.org/wiki/Help#Mailing_List_.28discontinued.29_Archives archived]&lt;br /&gt;
&lt;br /&gt;
==Can I use slicer for patient care?==&lt;br /&gt;
&lt;br /&gt;
Slicer is intended for research work and ''has no FDA clearances or approvals of any kind''.  It is the responsibility of the user to comply with all laws and regulations (and moral/ethical guidelines) when using slicer.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==How to cite Slicer?==&lt;br /&gt;
{{:CitingSlicer}}&lt;br /&gt;
&lt;br /&gt;
== How do I create an account for the Slicer wiki? ==&lt;br /&gt;
Please note: You only need an account if you want to edit or add pages. &lt;br /&gt;
&lt;br /&gt;
Follow the Log in-&amp;gt;Request Account link from the upper right corner of the slicer wiki page. Once the account request is approved, you will be e-mailed a notification message and the account will be usable at log in.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Can I install Slicer without administrator rights?==&lt;br /&gt;
&lt;br /&gt;
The most convenient way to install Slicer is to run the installer package (Slicer-{{documentation/currentversion}}....exe) as administrator. However, installation is not necessary, you just need to unpack the files in the installer package and copy them to your user directory or a USB drive and start it by running ''Slicer.exe''.&lt;br /&gt;
&lt;br /&gt;
You can unpack the installation package by one of the following methods:&lt;br /&gt;
* Install Slicer on any computer where you have administrator access. All the files that you need to run Slicer are in the C:\Program Files\Slicer... directory.&lt;br /&gt;
* Unpack the installation package by using 7zip or using the InstallExplorer plugin in Total commander or FAR manager (http://nsis.sourceforge.net/Can_I_decompile_an_existing_installer). All the Slicer files will be in the $_OUTDIR directory, except Slicer.exe, so you have to copy Slicer.exe into $_OUTDIR and run it from there. You can rename the $_OUTDIR directory and discard all the other directories ($COMMONFILES, $PLUGINSDIR, etc).&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==What if I have problems with Slicer installation?==&lt;br /&gt;
You can read our guide explaining [[Documentation/{{documentation/version}}/Report_a_problem|how to report a problem]].&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==How to uninstall Slicer?==&lt;br /&gt;
*On Windows, choose &amp;quot;Uninstall&amp;quot; option from the Start menu.&lt;br /&gt;
*On the Mac, remove the Slicer.app file. To clean up settings, remove &amp;quot;~/.config/www.na-mic.org/&amp;quot;&lt;br /&gt;
*On Linux, remove the directory where the application is located. To clean up settings, remove &amp;quot;~/.config/NA-MIC/&amp;quot;&lt;br /&gt;
&lt;br /&gt;
See the information about the location of [[Documentation/{{documentation/version}}/SlicerApplication/Settings|Settings]] for all platforms.  If the uninstaller is not working on windows you may need to remove the settings manually.&lt;br /&gt;
&lt;br /&gt;
== Where can I find Slicer tutorials? ==&lt;br /&gt;
Slicer tutorials associated with the latest {{documentation/currentversion}} stable release are available by visiting the following link:  [[Documentation/Nightly/Training|Click Here]].&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==I read errors in the logs complaining about memory==&lt;br /&gt;
&lt;br /&gt;
Errors such as “Description: Failed to allocate memory for image.” indicate that you don’t have enough memory space.&lt;br /&gt;
This can be a common issue if you run a 32-bit version of Slicer. You cannot expect a 32-bit executable to deal with any moderately complex problem. The [[Documentation/{{documentation/version}}/SlicerApplication/HardwareConfiguration#32_bit_versus_64_bit|recommended solution]] is to download/build/use Slicer in 64-bit mode.&lt;br /&gt;
 &lt;br /&gt;
Possible workarounds:&lt;br /&gt;
* Use a 64-bit version of Slicer &lt;br /&gt;
* You have somewhat more memory if you run the module in a separate process. To do that open [[Documentation/{{documentation/version}}/SlicerApplication/ApplicationSettings#Modules|Edit / Application Settings / Modules]] and check the “Prefer Executable CLIs” option, then restart Slicer.&lt;br /&gt;
* Decrease the size and/or resolution of the input and output images&lt;br /&gt;
** Consider [[Documentation/{{documentation/version}}/Modules/Crop_Volume|Crop Volume]] to focus on just your area of interest.&lt;br /&gt;
** Consider [[Documentation/{{documentation/version}}/Modules/ResampleScalarVectorDWIVolume|ResampleScalarVectorDWIVolume]] or [[Documentation/{{documentation/version}}/Modules/ResampleScalarVolume|ResampleScalarVolume]] increase the sample spacing (decrease the resolution) of your data.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Which Slicer version should I use: 3.X or 4.X ? ==&lt;br /&gt;
&lt;br /&gt;
In general slicer3 and slicer4 have roughly similar functionality with respect to registration basics.  Probably the most important thing to keep in mind is that slicer3 is no longer actively maintained.&lt;br /&gt;
&lt;br /&gt;
Slicer4, on the other hand, has benefited from literally hundreds of bug fixes over the past several years, and typically has better features and much better performance.  Also, the nightly builds of slicer4 are now using ITKv4, which has significantly improved registration code.  I am told by active users/developers of ITK that ITKv4 should provide significantly better results in many cases.  Also, several new registration techniques are being actively developed for slicer4.&lt;br /&gt;
&lt;br /&gt;
Source: http://massmail.spl.harvard.edu/public-archives/slicer-users/2013/006190.html&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== What is my HOME folder ? ==&lt;br /&gt;
&lt;br /&gt;
{|width = &amp;quot;100%&amp;quot;&lt;br /&gt;
! width=&amp;quot;50%&amp;quot; style=&amp;quot;border-bottom: 1px solid darkgrey;font-size: 75%;&amp;quot;| Linux or MacOSX&lt;br /&gt;
! width=&amp;quot;50%&amp;quot; style=&amp;quot;border-bottom: 1px solid darkgrey;font-size: 75%;&amp;quot;| Windows&lt;br /&gt;
|-&lt;br /&gt;
| valign=&amp;quot;top&amp;quot; |&lt;br /&gt;
Start a terminal.&lt;br /&gt;
{{pre2|&amp;lt;nowiki&amp;gt;&lt;br /&gt;
$ echo ~&lt;br /&gt;
/home/jchris&lt;br /&gt;
&amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
| valign=&amp;quot;top&amp;quot; |&lt;br /&gt;
&lt;br /&gt;
Start Command Prompt (Start Menu -&amp;gt; All Programs -&amp;gt; Accessories -&amp;gt; Command Prompt)&lt;br /&gt;
{{pre2|&amp;lt;nowiki&amp;gt;&lt;br /&gt;
&amp;gt; echo %userprofile%&lt;br /&gt;
C:\Users\jcfr&lt;br /&gt;
&amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
|}&lt;/div&gt;</summary>
		<author><name>Inorton</name></author>
		
	</entry>
	<entry>
		<id>https://www.slicer.org/w/index.php?title=Help&amp;diff=52182</id>
		<title>Help</title>
		<link rel="alternate" type="text/html" href="https://www.slicer.org/w/index.php?title=Help&amp;diff=52182"/>
		<updated>2017-06-06T15:50:54Z</updated>

		<summary type="html">&lt;p&gt;Inorton: /* Mailing List (discontinued) */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Introduction=&lt;br /&gt;
This page is intended to provide links to places where Slicer Users can get help.&lt;br /&gt;
&lt;br /&gt;
=Discourse Forum=&lt;br /&gt;
The most effective way to get help from the community is through [https://discourse.slicer.org the 3D Slicer community page on Discourse]. Categories:&lt;br /&gt;
* [mailto:slicer+support@discoursemail.com Support]: usage related questions&lt;br /&gt;
* [mailto:slicer+dev@discoursemail.com  Development]: programming related questions&lt;br /&gt;
&lt;br /&gt;
=Frequently Asked Questions FAQs=&lt;br /&gt;
We maintain a curated list of questions and answers for both users and developers:&lt;br /&gt;
* [[Documentation/{{documentation/currentversion}}/FAQ | Users FAQ]]&lt;br /&gt;
* [[Documentation/{{documentation/currentversion}}/Developers/FAQ | Developers FAQ]]&lt;br /&gt;
&lt;br /&gt;
=Downloading Slicer=&lt;br /&gt;
*Slicer is free open source software and is distributed under a BSD license. Please read the [[Projects/slicerWeb:LicenseText| Slicer License Agreement]], if you use Slicer. &lt;br /&gt;
*Compiled binaries are accessible through the [http://download.slicer.org Slicer Download] page.&lt;br /&gt;
&lt;br /&gt;
=Bug Reports and Feature Requests=&lt;br /&gt;
We have a data base of bug reports and feature request which is based on a software package called &amp;quot;Mantis&amp;quot;.&lt;br /&gt;
Please file your reports in mantis and send an email about the report to the slicer-users mailing list.&lt;br /&gt;
* In order to file a feature request or a bug report, please sign up on http://www.na-mic.org/Bug/signup_page.php, then click on the '''Report Issue''' link in your browser.&lt;br /&gt;
* See [[Documentation/{{documentation/currentversion}}/Report_a_problem|here]] for additional tips on reporting issues.&lt;br /&gt;
&lt;br /&gt;
=Training and Documentation=&lt;br /&gt;
*The [[Documentation/{{documentation/currentversion}}/Training|Training page]] provides a series of courses for learning how to use Slicer4. The portfolio contains self-guided presentation and sample data sets.&lt;br /&gt;
*Reference manual style [[Documentation/{{documentation/currentversion}}|documentation]] for Slicer4 can be found on the Slicer Wiki.&lt;br /&gt;
&lt;br /&gt;
=Mailing List (discontinued) Archives=&lt;br /&gt;
Prior to Discourse, support and development discussions were conducted on several mailing lists, for which 10+ years of archives are available:&lt;br /&gt;
* [http://massmail.spl.harvard.edu/public-archives/slicer-users slicer-users (usage questions) archive ].&lt;br /&gt;
** ([http://slicer-users.65878.n3.nabble.com/ searchable Nabble mirror])&lt;br /&gt;
* [http://massmail.spl.harvard.edu/public-archives/slicer-devel slicer-devel (programming questions) archive]&lt;br /&gt;
** ([http://slicer-devel.65872.n3.nabble.com/ searchable Nabble mirror])&lt;/div&gt;</summary>
		<author><name>Inorton</name></author>
		
	</entry>
</feed>