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

**URL:** https://discourse.slicer.org/t/sync-volumes-color-look-up-table-with-volume-rendering/1770
**Category:** Support
**Created:** [January 6, 2018, 2:10am UTC](https://discourse.slicer.org/t/sync-volumes-color-look-up-table-with-volume-rendering/1770 "2018-01-06T02:10:39Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![Hamburgerfinger](https://avatars.discourse-cdn.com/v4/letter/h/eb9ed0/32.png) [@Hamburgerfinger](https://discourse.slicer.org/u/Hamburgerfinger)
#### Post date: [January 6, 2018, 2:10am UTC](https://discourse.slicer.org/t/sync-volumes-color-look-up-table-with-volume-rendering/1770/1 "2018-01-06T02:10:39Z")

</div>

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!

---

<div class="post-metadata">

### Author: ![lassoan](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/lassoan/32/13_2.png) [@lassoan](https://discourse.slicer.org/u/lassoan)
#### Post date: [January 6, 2018, 2:45pm UTC](https://discourse.slicer.org/t/sync-volumes-color-look-up-table-with-volume-rendering/1770/2 "2018-01-06T14:45:34Z")

</div>

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](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/3/3/339bc6f9e1d255bc00c54d1f8367219ab4e18c01.png)

---

<div class="post-metadata">

### Author: ![Hamburgerfinger](https://avatars.discourse-cdn.com/v4/letter/h/eb9ed0/32.png) [@Hamburgerfinger](https://discourse.slicer.org/u/Hamburgerfinger)
#### Post date: [January 6, 2018, 8:38pm UTC](https://discourse.slicer.org/t/sync-volumes-color-look-up-table-with-volume-rendering/1770/3 "2018-01-06T20:38:15Z")

</div>

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!

---

<div class="post-metadata">

### Author: ![lassoan](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/lassoan/32/13_2.png) [@lassoan](https://discourse.slicer.org/u/lassoan)
#### Post date: [January 8, 2018, 4:06am UTC](https://discourse.slicer.org/t/sync-volumes-color-look-up-table-with-volume-rendering/1770/4 "2018-01-08T04:06:05Z")

</div>

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.
