How to assign default color table to a node

I wonder if this is too trivial for appearing here but I struggle for weeks before realizing that you can easily assign a color table to a node in python

# First access the color table by name, the name is the one that appears in the combobox
PETnodeColor = slicer.util.getFirstNodeByName('PET-Heat')
# Now you get your node display, the node is any vtkMRMLScalarVolumeNode that you have already loaded
displaynode = node.GetScalarVolumeDisplayNode()
# Finally the assignment

This does not even appear in the documentation nor the wiki and is really hard to find


There was an example for setting colormap of a volume in the Slicer script repository. This page has a lot of examples for python scripting.

It was in an example titled “Change window/level (brightness/contrast) or colormap of a volume”.