Skip to content

Instantly share code, notes, and snippets.

@pieper
Created July 31, 2017 20:35
Show Gist options
  • Save pieper/45353db369ffc062e43dcca1fb2fcd86 to your computer and use it in GitHub Desktop.
Save pieper/45353db369ffc062e43dcca1fb2fcd86 to your computer and use it in GitHub Desktop.
import os
import WebServer
tracts = ['AF', 'CST_M1', 'IFOF', 'ILF', 'UF'];
exportDirectory = '/Volumes/encrypted/data/AG/AG1611-SlicerWeb/tracts'
targetTubeCount = 100
for tract in tracts:
tubeNodes = slicer.util.getNodes('vtkMRMLFiberBundleTubeDisplayNode*', useLists=True).values()
for tubeNode in tubeNodes[0]:
tubeNode.SetVisibility(0)
node = slicer.util.getNode(tract+'*')
clusters = vtk.vtkCollection()
node.GetChildrenDisplayableNodes(clusters)
for clusterIndex in range(clusters.GetNumberOfItems()):
cluster = clusters.GetItemAsObject(clusterIndex)
cluster.SetSubsamplingRatio(0.01)
tubeNode = cluster.GetNthDisplayNode(1)
tubeNode.SetVisibility(1)
slicer.util.delayDisplay(tract, 100)
exporter = WebServer.glTFExporter(slicer.mrmlScene)
exporter.targetTubeCount = targetTubeCount
outPath = os.path.join(exportDirectory, tract+".gltf")
fp = open(outPath, 'w');
fp.write(exporter.export())
fp.close()
slicer.util.delayDisplay("done")
toRun = """
execfile('/Users/pieper/slicer4/latest/SlicerWeb/Experiments/AG-export.py')
"""
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment