# Colormap loading issue after scene save

**URL:** <https://discourse.slicer.org/t/colormap-loading-issue-after-scene-save/36147>\
**Category:** Development\
**Tags:** color, custom-color-table\
**Created:** [May 14, 2024, 3:20pm UTC](https://discourse.slicer.org/t/colormap-loading-issue-after-scene-save/36147 "2024-05-14T15:20:49Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![connorh](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/connorh/32/79802_2.png) [@connorh](https://discourse.slicer.org/u/connorh)\
**Post date:** [May 14, 2024, 3:20pm UTC](https://discourse.slicer.org/t/colormap-loading-issue-after-scene-save/36147/1 "2024-05-14T15:20:49Z")

</div>

I’m creating custom colormaps for a tool I’ve developed. If I create a continuous colormap I can save the scene, close, reload, and the colormap works as expect.

When I create discrete colormaps, it works initially, but when the scene is saved, closed, and reopened the colormap has no data.

I’m creating the discrete colormap by this function:

```auto
def CreateCustomColormap():
    """
      more on discrete colormap nodes https://slicer.readthedocs.io/en/latest/developer_guide/script_repository.html#create-color-table-node
    """
    title = "Test Colormap"
    colorNode = slicer.mrmlScene.GetFirstNodeByName("TestColormap")
    if colorNode is None:
        colorNode = slicer.mrmlScene.CreateNodeByClass("vtkMRMLColorTableNode")
        colorNode.SetTypeToUser()
        colorNode.HideFromEditorsOff()
        slicer.mrmlScene.AddNode(colorNode)
        colorNode.UnRegister(None) # to prevent memory leaks

        colorNode.SetName(slicer.mrmlScene.GenerateUniqueName("TestColormap"))
        

        colorNode.SetNumberOfColors(3)
        colorNode.SetNamesInitialised(True)
        scalars_to_colours = [(0, [210, 210, 210]), (1, [255, 255, 25]), (2, [255, 0, 0])]
        for (label, colour) in scalars_to_colours:
            colorNode.SetColor(label, "", colour[0] / 255, colour[1] / 255, colour[2] / 255)

    return colorNode.GetID()

```

I’ve tried this in the latest preview version of Slicer and in 5.6.1.

When initially created:

 ![DataIsThereColormap](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/b/5/b52ef51560c4a9cd962bae3e6904d087e268a399.png)

After scene save/close/reopen.

 ![LostInfoColormap](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/d/9/d93e2b35793e50beeb8e2507ad8ee56ac02dc4d2.png)

Thanks in advance for any pointers!
