Adding a new color table to Colors, permanently

I want to add a custom color table to Slicer, and store it permanently, so I can open Volumes (Label Maps) with it.

Right now I am loading it on startup using ~/.slicerrc.py, but I wonder if there is an alternative way?

ctbl_file_path = '/path/mylut.ctbl'
# Create a new color node
color_node = slicer.mrmlScene.AddNewNodeByClass('vtkMRMLColorTableNode')

# Read the color table from the file
color_table = slicer.vtkMRMLColorTableStorageNode()
color_table.SetFileName(ctbl_file_path)
color_table.ReadData(color_node)
color_node.SetName('MyAwesomeColorTable')

In the past we added similar code to certain setup steps of our modules, such as

The advantage of this to your approach is that anyone using the extension will have the custom color tables without extra steps. Of course this only works if you already maintain some modules that your group uses.

1 Like