Colormap loading issue after scene save

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:

def CreateCustomColormap():
      more on discrete colormap nodes
    title = "Test Colormap"
    colorNode = slicer.mrmlScene.GetFirstNodeByName("TestColormap")
    if colorNode is None:
        colorNode = slicer.mrmlScene.CreateNodeByClass("vtkMRMLColorTableNode")
        colorNode.UnRegister(None)  # to prevent memory leaks


        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:

After scene save/close/reopen.

Thanks in advance for any pointers!