Skip to content

Instantly share code, notes, and snippets.

@sjh26
Created October 14, 2022 14:50
Show Gist options
  • Save sjh26/42500b8421ac2258c5c4454122c439f8 to your computer and use it in GitHub Desktop.
Save sjh26/42500b8421ac2258c5c4454122c439f8 to your computer and use it in GitHub Desktop.
Example of volume rendering
def toggleVolumeRenderVisibility(self, visible):
volumeNode = <volume node however you get it>
NodeCombo = slicer.util.findChild(self.volumerenderWidget, 'VolumeNodeComboBox')
VisibilityCheckBox = slicer.util.findChild(self.volumerenderWidget, 'VisibilityCheckBox')
volRenLogic = slicer.modules.volumerendering.logic()
if volumeNode is not NodeCombo.currentNode():
displayNode = volRenLogic.CreateDefaultVolumeRenderingNodes(volumeNode)
displayNode.SetVisibility(visible)
displayNode.GetVolumePropertyNode().Copy(volRenLogic.GetPresetByName("CT-AAA"))
AutoReleaseGraphicsResourcesCheckBox = slicer.util.findChild(self.volumerenderWidget, 'AutoReleaseGraphicsResourcesCheckBox')
QualityControlComboBox = slicer.util.findChild(self.volumerenderWidget, 'QualityControlComboBox')
NodeCombo.setCurrentNode(volumeNode)
AutoReleaseGraphicsResourcesCheckBox.checked = True
QualityControlComboBox.currentText = 'Adaptive'
VisibilityCheckBox.checked = visible
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment