Operating system: Windows 7
Slicer version: 4.9.0
Hi All,
I am trying to use python to do volume rendering and set parameters for it. These are few lines of attempt. However, I run into the problem when trying to get Volume Proper Node to set the preset “CT-Bone”. It says the volumePropertyNode is nonetype object. I wonder why this happens. Thank you for your help.
#Tune volume rendering parameters
volRenLogic = slicer.modules.volumerendering.logic()
preset = volRenLogic.GetPresetByName('CT-Bone')
presetNode = slicer.mrmlScene.AddNode(preset)
volumeNode = slicer.mrmlScene.GetNodeByID('vtkMRMLScalarVolumeNode1')
displayNode = volRenLogic.CreateVolumeRenderingDisplayNode()
volumePropertyNode = displayNode.GetVolumePropertyNode()
volumePropertyNode.Copy(preset)
volRenLogic.UpdateDisplayNodeFromVolumeNode(displayNode, volumeNode, presetNode)
slicer.mrmlScene.AddNode(displayNode)
displayNode.UnRegister(volRenLogic)
volumeNode.AddAndObserveDisplayNodeID(preset.GetID())