Logarithmic Color scale Bar

Slicer version: 4.11.202
Operating system: Windows 10 x64
Software: Jupyter Notebook with Slicer Kernel 4.11

Is it possible to generate a Color Scale Bar with Logarithmic Values.
Since I am working with low distances in the modeltomodeldistance, a logarithmic color scale is needed. With the vtkMRMLProceduralColorNode i can log the LUT colors and the labels are all with the same distances as seen in this picture below.
LogarithmicColors
My question is now to switch the bar and the labels, so the label are logarithmic with low values have a bigger range than higher labels and the color bar with the lut stays in normal range. I tried it with the ProceduralNode and also had a look with at the ColorTableNode but couldn’t figure out how to deal with my problem.
Thanks in advance for dealing with my problem and I am thankful for all the input of the community
Mathias Brucker

@Mik you have been doing a great job in reworking the color bar display. Can you comment on feasibility of logarirthmic scale? Is log scal already supported by the scalar bar widget?

I have not tested it with logarithmic scale it yet. The ScalarBar manual says that if vtkLookupTable has a logarithmic scale then the labels are created using a logarithmic scale.

Anyway it shouldn’t be to difficult to add a check box and flag to the node to switch between log and linear scale.

@MathiasBrucker You can try to set log scale to the LUT instead of linear scale.

Do you have any king of test data so i can check the log scale support?

1 Like

Here what i have got with logarithmic scale
Test LUT

colorTableNode = slicer.mrmlScene.AddNewNodeByClass("vtkMRMLProceduralColorNode", "TestLogColors")
colorTableNode.SetType(slicer.vtkMRMLColorTableNode.User)
colorTransferFunction = vtk.vtkDiscretizableColorTransferFunction()
colorTransferFunction.AddRGBPoint(0.01, 1.0, 0.0, 0.0)
colorTransferFunction.AddRGBPoint(0.1, 0.0, 1.0, 0.0)
colorTransferFunction.AddRGBPoint(1.0, 0.3, 0.0, 1.0)
colorTransferFunction.AddRGBPoint(10.0, 0.6, 0.0, 1.0)
colorTransferFunction.AddRGBPoint(100.0, 0.6, 0.6, 1.0)
colorTransferFunction.AddRGBPoint(1000.0, 1., 1., 1.0)
colorTableNode.SetAndObserveColorTransferFunction(colorTransferFunction) 

LUT screenshot:

ColorBarDisplayNode parameters screenshot:

Unfortunately it still doesn’t work quiet well with Models (the program crashes if the model has already been visible).

Thanks @Mik for your reply, I couldn’t test it yet but i will try it with the logarithmic LUT on the color Node.