# Extract Transfer Function from Color Table

**URL:** <https://discourse.slicer.org/t/extract-transfer-function-from-color-table/5489>\
**Category:** Support\
**Tags:** python, volume-rendering\
**Created:** [January 23, 2019, 7:54pm UTC](https://discourse.slicer.org/t/extract-transfer-function-from-color-table/5489 "2019-01-23T19:54:07Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Valtiel](https://avatars.discourse-cdn.com/v4/letter/v/839c29/32.png) [@Valtiel](https://discourse.slicer.org/u/Valtiel)\
**Post date:** [January 23, 2019, 7:54pm UTC](https://discourse.slicer.org/t/extract-transfer-function-from-color-table/5489/1 "2019-01-23T19:54:07Z")

</div>

Hi!

I’m trying to apply a transfer function to my volume-rendering. I have a custom `vtkMRMLColorTableNode`, but `GetScalarsToColors()` always returns a `vtkLookupTable`. Is there a way to get a `vtkTransferFunction` out of this?

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 23, 2019, 11:44pm UTC](https://discourse.slicer.org/t/extract-transfer-function-from-color-table/5489/2 "2019-01-23T23:44:30Z")

</div>

Transfer functions are stored in volume rendering property nodes.

---

<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 24, 2019, 1:24am UTC](https://discourse.slicer.org/t/extract-transfer-function-from-color-table/5489/3 "2019-01-24T01:24:37Z")

</div>

If you just want the colors in your table to be transferred for volume rendering, you can just click the “Sync with Volumes” checkbox in the properties in the Volume Rendering module. Then uncheck it and you can set the opacities, etc.

---

<div class="post-metadata">

**Author:** ![Valtiel](https://avatars.discourse-cdn.com/v4/letter/v/839c29/32.png) [@Valtiel](https://discourse.slicer.org/u/Valtiel)\
**Post date:** [February 2, 2019, 7:05pm UTC](https://discourse.slicer.org/t/extract-transfer-function-from-color-table/5489/4 "2019-02-02T19:05:09Z")

</div>

Thanks to you two, I managed to find the correct function in the source code!

The way I did it was as follows:

1. First, get the Volume Rendering Logic via `volume_rendering_logic = slicer.modules.volumerendering.logic()`.
2. Then, create the Volume Rendering Node of the Volume Node by using `volume_rendering_node = volume_rendering_logic.CreateDefaultVolumeRenderingNodes(volume_node)`.
3. Finally, “sync” the Display Node of the volume with the Volume Rendering Display Node via `volume_logic.CopyDisplayToVolumeRenderingDisplayNode(volume_rendering_node)`.

Thanks again!
