The volume updates correctly and shows the correct color levels, but the UI widgets are not updated. Specifically the window/level widgets in the Volume UI.
The GUI updates automatically when the MRML nodes are modified. Volumes module probably showed a different volume than what you modified. Or maybe you modified the volume rendering display node. This code snippet changes scalar volume display nodes of all loaded volumes:
petColor = slicer.mrmlScene.GetFirstNodeByName('PET-Heat')
petNodes = slicer.util.getNodesByClass('vtkMRMLScalarVolumeNode')
for petNode in petNodes:
displayNode = petNode.GetScalarVolumeDisplayNode()
displayNode.SetAndObserveColorNodeID(petColor.GetID())
displayNode.SetWindowLevelMinMax(0, 20)
Thanks, much appreciated. The UI widgets were being updated.
I worked out I needed to explicitly turn off auto window level before setting the window/level values so they weren’t immediately overridden in the UI widget.