Skip to content

Instantly share code, notes, and snippets.

@cpinter
Created June 11, 2020 19:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cpinter/8a1f71c7eb3ef0ebcaa6c1be6e1c9d4a to your computer and use it in GitHub Desktop.
Save cpinter/8a1f71c7eb3ef0ebcaa6c1be6e1c9d4a to your computer and use it in GitHub Desktop.
Set volume rendering preset
def setPresetOffset(self, x, y, dontMoveFirstLast, presetsCombobox):
volRenWidget = slicer.modules.volumerendering.widgetRepresentation()
if volRenWidget is None:
logging.error('Failed to access volume rendering module')
return
# Make sure the proper volume property node is set
volumePropertyNode = presetsCombobox.mrmlVolumePropertyNode()
if volumePropertyNode is None:
logging.error('Failed to access volume properties')
return
volumePropertyNodeWidget = slicer.util.findChild(volRenWidget, 'VolumePropertyNodeWidget')
volumePropertyNodeWidget.setMRMLVolumePropertyNode(volumePropertyNode)
# Adjust the transfer function
volumePropertyNodeWidget.moveAllPoints(x, y, dontMoveFirstLast)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment