Sync “Volumes” color look-up table with “Volume Rendering”

In the Volume Rendering module there is an option to sync the scalar color mapping with the active color mapping in the Volumes module. Can I do the opposite, i.e. create a custom color mapping in the Volume Rendering module and import it for use with Volumes module?

Thanks!

You can do it by copy-pasting this code to the Python console:

volumeNode = getNode('CTChest')
volumeRenderingDisplayNode = slicer.modules.volumerendering.logic().GetFirstVolumeRenderingDisplayNode(volumeNode)
volumeRenderingPropertyNode = volumeRenderingDisplayNode.GetVolumePropertyNode()
colorTransferFunction = volumeRenderingPropertyNode.GetColor()
colorNode = slicer.mrmlScene.AddNewNodeByClass('vtkMRMLProceduralColorNode')
colorNode.SetAndObserveColorTransferFunction(colorTransferFunction)
volumeNode.GetDisplayNode().SetAndObserveColorNodeID(colorNode.GetID())

The code snippet does not synchronize the lookup table range, so you have to adjust it by click-and-drag the mouse in the slice view up/down, left/right.

Also, color LUTs don’t contain opacity value. However, you can do a simple thresholding in Volumes module to remove background.

image

This almoooost works perfectly… The issue is that if the dataset contains entirely, for example, scalars between 0 and 1, it assigns one color to everything, instead of continuous colors.

On the other hand, if I apply a calibration factor to scale the values to, for example, 0 to 1000, the slices look “correct”.

Any ideas why this is?

Thanks!

The code snippet does not synchronize the lookup table range, so you have to adjust it by click-and-drag the mouse in the slice view up/down, left/right.

If the scalar range of the volume is very extreme (e.g., 0.0-1.0) then maybe you have to adjust a lot and it could be easier to adjust it using window/level sliders in Volumes module.