This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Take a slice out of a volume | |
import SampleData | |
# Input parameters | |
observerTag = None | |
outputSpacing = [2.0, 2.0, 2.0] # Millimeters/pixel | |
outputExtent = [0, 99, 0, 99, 0, 0] # First and last pixel indices along each axis |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from optparse import OptionParser | |
# import os | |
import sys | |
import zipfile | |
import xml.etree.ElementTree as ET | |
parser = OptionParser() | |
parser.add_option( "-i", "--input", dest="InputFilename", help="Input file", metavar="FILE" ) | |
parser.add_option( "-o", "--output", dest="OutputFilename", help="Output file", metavar="FILE" ) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
bottomRadius = 20 | |
topRadius = 12 | |
height = 30 | |
resolution=32 | |
points = vtk.vtkPoints() | |
lines = vtk.vtkCellArray() | |
pts = list() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
import os | |
transform_names = ['LinearTransform_3'] | |
export_fullpath = r"j:\Temp" | |
browserNode = slicer.util.getFirstNodeByName('SequenceBrowser', className='vtkMRMLSequenceBrowserNode') | |
numItems = browserNode.GetNumberOfItems() | |
n = numItems - 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Show the distance between models as colors | |
# Create two models | |
createModelsLogic = slicer.modules.createmodels.logic() | |
cubeNode = createModelsLogic.CreateCube(150, 150, 150) | |
sphereNode = createModelsLogic.CreateSphere(100) | |
# Hide original models, so only the output will be visible |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Create transform node for registration result (optional) | |
alphaToBeta = slicer.vtkMRMLLinearTransformNode() | |
alphaToBeta.SetName('AlphaToBeta') | |
slicer.mrmlScene.AddNode(alphaToBeta) | |
# Experiment parameters (start from here if you have alphaToBeta already) | |
N = 10 # Number of fiducials | |
Scale = 100.0 # Size of space where fiducial are placed |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Create coordinate system models to visualize the transforms | |
createModelsLogic = slicer.modules.createmodels.logic() | |
preModelNode = createModelsLogic.CreateCoordinate(20,2) | |
preModelNode.SetName('PreModel') | |
preModelNode.GetDisplayNode().SetColor(1,1,0) | |
postModelNode = createModelsLogic.CreateCoordinate(20,2) | |
postModelNode.SetName('PostModel') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Example to show difference between PreMultiply and PostMultiply | |
# Create coordinate models using the CreateModels module | |
createModelsLogic = slicer.modules.createmodels.logic() | |
preModelNode = createModelsLogic.CreateCoordinate(20,2) | |
preModelNode.SetName('PreModel') | |
postModelNode = createModelsLogic.CreateCoordinate(20,2) | |
postModelNode.SetName('PostModel') | |
originModelNode = createModelsLogic.CreateCoordinate(20,2) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Copy and paste into Slicer Python interactor | |
# Drag visible fiducials to deform transform | |
# Scale defines how large cube will be created | |
# numPerEdge defines how many fiducials to put on each edge of the cube | |
scale = 30.0 | |
numPerEdge = 3 | |
# Create the FROM fiducial list, and hide it so it doesn't change with mouse interactions |