How to create a color table that doesn't include 0

Hi

I have results from an image analysis that I want to overlay on the intensity values. When I choose the RGB as the color map of the overlay, the green fills everywhere.
I want to exclude values that are very close 0 on either side of the range (say from -.01 to 0.01) from the color table. How can I do it?

Color tables (vtkMRMLColorTableNode) that are editable using the GUI use vtkLookupTable, which uses equally spaced entries. If you want to have an abrupt change in the color map then you need to have many entries.

If you don’t need to edit the entries manually, then you can use procedural color nodes, which use vtkScalarsToColors object internally. Color transfer functions can use arbitrarily spaced control points, so you don’t have to add a lot of entries. I think eventually even procedural color nodes are converted to color tables internally, so if you need abrupt changes then you need to set number of colors in the color table node to a large number (hundreds, maybe even thousands).

You can edit a color node after you duplicate it in the Colors module (Informatics category). If you set the alpha value of a color to 0, then you make it transparent, thus “excluding” it - if I understood you question properly.

Yes, exactly. However, if he needs 0.00 to make transparent but >0.01 and <-0.01 non-transparent, then it means that on a mapped value range of (-1;+1), he would need to have 200 color table entries - not easy to edit manually. If the range of values is (-100;+100) then he would need to have 20000 color table entries, which is impossible to edit manually and might have performance impact (maybe not, I haven’t ever tried use such large color table).

Right. I’d probably have a python function create the color table in .slicerrc.py and define another one setting that color table and a good W/L on the image analysis output volumes.

Thanks for the replies. I have been trying to use the RBG continuous color map, but I can’t seem to find a place to to change the opacity. In the screenshot the middle point is 0 and the ones that are on left and right are -.1, and .1 respectively. But where is the opacity setting?
Capture

There is a new class, https://www.vtk.org/doc/nightly/html/classvtkDiscretizableColorTransferFunction.html, which can do opacity mapping as well. It is not available in Slicer GUI yet, but maybe you can create it in Python and set it in a color node using SetAndObserveColorTransferFunction.

A color editor widget has been added for it a couple of weeks ago to CTK library, so the Colors module could be modified to use discretizable color transfer function class by default and this new color editor widget.