# How to set volume rendering color same as in slices?

**URL:** <https://discourse.slicer.org/t/how-to-set-volume-rendering-color-same-as-in-slices/22020>\
**Category:** Support\
**Tags:** volume-rendering\
**Created:** [February 17, 2022, 11:05am UTC](https://discourse.slicer.org/t/how-to-set-volume-rendering-color-same-as-in-slices/22020 "2022-02-17T11:05:11Z")\
**Posts on this page:** 18\
**Page:** 1

<div class="post-metadata">

**Author:** ![rasunag27](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/rasunag27/32/3551_2.png) [@rasunag27](https://discourse.slicer.org/u/rasunag27)\
**Post date:** [February 17, 2022, 11:05am UTC](https://discourse.slicer.org/t/how-to-set-volume-rendering-color-same-as-in-slices/22020/1 "2022-02-17T11:05:11Z")

</div>

Hi,

I have loaded RGB compatible ‘.dcm’ slices into the 3D slicer. I am able to get the slices in the RGB format as required. But the 3D volume from volume rendering shows grayscale. If I use preset from Volumes, it will get generated. But, I require the color format as addressed from slices.

How can I change the volume color as same as seen from slices?

Regards,  
Sunag R A.

---

<div class="post-metadata">

**Author:** ![pieper](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/pieper/32/8_2.png) [@pieper](https://discourse.slicer.org/u/pieper)\
**Post date:** [February 17, 2022, 1:47pm UTC](https://discourse.slicer.org/t/how-to-set-volume-rendering-color-same-as-in-slices/22020/2 "2022-02-17T13:47:48Z")

</div>

See if you can replicate what’s shown in the post below. Be sure you are using the latest and report back with details if things aren’t working (i.e. what slicer version you used, how to replicate the issue public data).

> [@Color (RGB) volume rendering](https://discourse.slicer.org/t/color-rgb-volume-rendering/19732):
>
> In recent Slicer Preview Releases, color volume rendering has been made much easier to access. While previously an alpha channel had to be created manually for rendering color RGB volumes, now the alpha channel is created automatically (from the luminance of the image). To render an RGB volume, just load the image stack and drag-and-drop the volume from the Data module to a 3D view (or use Volume Rendering module). When a color volume is loaded then “Scalar Color Mapping” section is not display…

---

<div class="post-metadata">

**Author:** ![rasunag27](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/rasunag27/32/3551_2.png) [@rasunag27](https://discourse.slicer.org/u/rasunag27)\
**Post date:** [February 18, 2022, 3:39am UTC](https://discourse.slicer.org/t/how-to-set-volume-rendering-color-same-as-in-slices/22020/3 "2022-02-18T03:39:22Z")

</div>

@pieper

Thanks for the reply.

Firstly, I am using 3D Slicer with version 4.11.2021226. So, back to 3D volume rendering, I am able to get the color changes based on the ‘preset’ in the Display panel. What I am trying to say is, for example, I have loaded dcm files with temperature RGB values. But in 3D model, apart from Preset color codes, how do I make is similar to color codes of my dcm slices?

I have attached the image for refrence. In the image, we can see that in volume, the color is generated by preset (say, US-Fetal). How to make the color code similar to slice views as can be seen in axial, coronal and sagittal views?  
**Or do we need to add new color codes in presets.xml?**

 ![preset_color_3slicer](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/a/1/a1730a4712e7e1fc0c66e9b76d83e400a9242aab.jpeg)

Regards,  
Sunag R A.

---

<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:** [February 18, 2022, 4:04am UTC](https://discourse.slicer.org/t/how-to-set-volume-rendering-color-same-as-in-slices/22020/4 "2022-02-18T04:04:41Z")

</div>

> [@rasunag27](#):
>
> Firstly, I am using 3D Slicer with version 4.11.2021226.

Please try a recent Slicer Preview Release. RGB volume rendering is set up automatically in these versions, but not in 4.11.2021226.

---

<div class="post-metadata">

**Author:** ![rasunag27](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/rasunag27/32/3551_2.png) [@rasunag27](https://discourse.slicer.org/u/rasunag27)\
**Post date:** [February 18, 2022, 4:07am UTC](https://discourse.slicer.org/t/how-to-set-volume-rendering-color-same-as-in-slices/22020/5 "2022-02-18T04:07:18Z")

</div>

@lassoan

Thanks for the reply. Newer version means 4.13.0 which is in Preview release? In Stable release, I could see 4.11.2021226 as the highest version.

Regards,  
Sunag R A.

---

<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:** [February 18, 2022, 4:10am UTC](https://discourse.slicer.org/t/how-to-set-volume-rendering-color-same-as-in-slices/22020/6 "2022-02-18T04:10:01Z")

</div>

Yes, we mean a recent preview release. It is not the stable release.

 ![image](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/a/e/aeb9cc990357c452c976543382d1d911077688b8.png)

---

<div class="post-metadata">

**Author:** ![rasunag27](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/rasunag27/32/3551_2.png) [@rasunag27](https://discourse.slicer.org/u/rasunag27)\
**Post date:** [February 18, 2022, 4:11am UTC](https://discourse.slicer.org/t/how-to-set-volume-rendering-color-same-as-in-slices/22020/7 "2022-02-18T04:11:06Z")

</div>

Okay thanks. Will work on it.

Regards,  
Sunag R A.

---

<div class="post-metadata">

**Author:** ![rasunag27](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/rasunag27/32/3551_2.png) [@rasunag27](https://discourse.slicer.org/u/rasunag27)\
**Post date:** [February 18, 2022, 5:15am UTC](https://discourse.slicer.org/t/how-to-set-volume-rendering-color-same-as-in-slices/22020/8 "2022-02-18T05:15:05Z")

</div>

@lassoan

I am unable to download the Linux preview version. Tired in Mozilla and Chrome many times. Its getting failed.

Regards,  
Sunag R A.

---

<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:** [February 18, 2022, 2:18pm UTC](https://discourse.slicer.org/t/how-to-set-volume-rendering-color-same-as-in-slices/22020/9 "2022-02-18T14:18:17Z")

</div>

Sorry, there is an issue with the packaging of the latest Slicer Preview Release on Linux. We are working on it, you can track its status here:

> <https://github.com/Slicer/Slicer/issues/6202>
>
> Multiple users reported that latest Slicer Preview Release does not start on Lin…ux. It seems that some ITK shared library file is missing.
> 
> Examples:
> \- https://github.com/Project-MONAI/MONAILabel/discussions/640#discussioncomment-2204689
> \- https://discourse.slicer.org/t/how-to-set-volume-rendering-color-same-as-in-slices/22020/8?u=lassoan
> 
> \## Environment
> \- Slicer version: Slicer-4.13.0-2022-02-17
> \- Operating system: Linux

In the meantime, you can use a Slicer Preview Release from a week ago, downloaded via this link: [https://download.slicer.org/?offset=-7](https://download.slicer.org/?offset=-7) (the `-7` means going back 7 days)

---

<div class="post-metadata">

**Author:** ![rasunag27](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/rasunag27/32/3551_2.png) [@rasunag27](https://discourse.slicer.org/u/rasunag27)\
**Post date:** [February 24, 2022, 3:42am UTC](https://discourse.slicer.org/t/how-to-set-volume-rendering-color-same-as-in-slices/22020/10 "2022-02-24T03:42:28Z")

</div>

@lassoan

Hi, I tried working with 4.13 with previous releases like 7, 20, 50 and 100 days back. In these, I am unable to get any volume rendering view. Nothing happens when I opt for showing volume rendering.

Apart from this, I would like to understand the xml contents in the “presets.xml” mainly on colorTransfer parameter.

Example xml from 3dslicer:

`<VolumeProperty selected="false" hideFromEditors="false" name="MR-T2-Brain" gradientOpacity="4 0 1 160.25 1" userTags="" specularPower="40" scalarOpacity="10 0 0 36.05 0 218.302 0.171429 412.406 1 641 1" id="vtkMRMLVolumePropertyNode26" specular="0.5" shade="1" ambient="0.3" colorTransfer="16 0 0 0 0 98.7223 0.956863 0.839216 0.192157 412.406 0 0.592157 0.807843 641 1 1 1" selectable="true" diffuse="0.6" interpolation="1" effectiveRange="0 412.406"/>`

Or, if any other version which loads color model as slices then that would be good.

Regards,  
Sunag R A.

---

<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:** [February 24, 2022, 5:06am UTC](https://discourse.slicer.org/t/how-to-set-volume-rendering-color-same-as-in-slices/22020/11 "2022-02-24T05:06:42Z")

</div>

I’ve just tested RGB volume rendering on Linux using Slicer-4.13.0-2022-02-14 and it worked well:

[https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/3/e/3e2c48de4486c2d735398c023ae6303e70fdba4d.mp4](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/3/e/3e2c48de4486c2d735398c023ae6303e70fdba4d.mp4)

Please try to follow exactly what is done in the video, using the same [Visible Human head RGB volume](https://github.com/lassoan/PublicTestingData/releases/download/data/HeadHistoCropped.nrrd) and see if that works for you.

If it works then something may be wrong with your data. If you share it (upload somewhere and post the link) then we can have a look.

---

<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:** [February 24, 2022, 5:58am UTC](https://discourse.slicer.org/t/how-to-set-volume-rendering-color-same-as-in-slices/22020/13 "2022-02-24T05:58:34Z")

</div>

Thank you, the video showed what your problem was: you used the experimental “Multi-volume rendering” mode, which [does not support RGB volume rendering](https://slicer.readthedocs.io/en/latest/user_guide/modules/volumerendering.html#limitations).

---

<div class="post-metadata">

**Author:** ![rasunag27](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/rasunag27/32/3551_2.png) [@rasunag27](https://discourse.slicer.org/u/rasunag27)\
**Post date:** [February 24, 2022, 6:04am UTC](https://discourse.slicer.org/t/how-to-set-volume-rendering-color-same-as-in-slices/22020/14 "2022-02-24T06:04:17Z")

</div>

@lassoan

Yes. I changed to CPU ray casting and it worked perfectly for the head image. It is not working for my case study.

If you could provide an email id, I would like to send the case study (zip file of dicom).

Regards,  
Sunag R A.

---

<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:** [February 24, 2022, 6:05am UTC](https://discourse.slicer.org/t/how-to-set-volume-rendering-color-same-as-in-slices/22020/15 "2022-02-24T06:05:25Z")

</div>

You can send me a private message by clicking on my username and then clicking on “Message”.

---

<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:** [February 24, 2022, 6:40am UTC](https://discourse.slicer.org/t/how-to-set-volume-rendering-color-same-as-in-slices/22020/16 "2022-02-24T06:40:57Z")

</div>

I’ve received the data set and it is not legal DICOM.

First of all, the same SOP instance UID is used in all the files, so the DICOM importer imports the first file and ignores the rest.

If I use a workaround and instead of properly using the DICOM module, I just add the data set as non-DICOM data (that uses ITK’s DICOM reader) then the image appears but since the voxel type is short (instead of unsigned char) and the range is off (-1024 to -769), the volume renderer does not show anything.

If you fix the data set to have prober unique identifiers and voxel type and range then Slicer will display it correctly.

RGB volumes are problematic for many reasons, so instead of burning in a colormap I would strongly recommend to save a standard scalar image and apply a color lookup table in the application. You can choose colormap for slice views in Volumes module and apply the same coloring in Volume rendering module by clicking on `Synchronize with Volumes module` button.

 ![image](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/e/9/e97f2a3288aa68f69cd37c2fc4180ddbfb8d9ba2.jpeg)

---

<div class="post-metadata">

**Author:** ![rasunag27](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/rasunag27/32/3551_2.png) [@rasunag27](https://discourse.slicer.org/u/rasunag27)\
**Post date:** [February 24, 2022, 6:43am UTC](https://discourse.slicer.org/t/how-to-set-volume-rendering-color-same-as-in-slices/22020/17 "2022-02-24T06:43:21Z")

</div>

@lassoan

Thank you for the detailed explanation. I will work on it.

Regards,  
Sunag R A.

---

<div class="post-metadata">

**Author:** ![rasunag27](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/rasunag27/32/3551_2.png) [@rasunag27](https://discourse.slicer.org/u/rasunag27)\
**Post date:** [February 24, 2022, 11:53am UTC](https://discourse.slicer.org/t/how-to-set-volume-rendering-color-same-as-in-slices/22020/18 "2022-02-24T11:53:32Z")

</div>

@lassoan

Hi,  
Based on manual color map, I was able to get the 3D model with desired color coding. I saved the scene as “.mrml” file.

Is there way that I could load this mrml color code as default whenever I load new dicom files.?

Attached image as reference.

 ![mrml_save](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/e/6/e679eddd9689f232d914140313718b01611640f8.jpeg)

Regards,  
Sunag R A.

---

<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:** [February 24, 2022, 2:47pm UTC](https://discourse.slicer.org/t/how-to-set-volume-rendering-color-same-as-in-slices/22020/19 "2022-02-24T14:47:47Z")

</div>

Yes, you can customize how specific type of DICOM files are visualized by default.

Probably the simplest solution is to add an observer to the scene and when a new node is added check if that is that special kind. If it is then modify the visualization: change color map, show volume rendering, etc. See an example [here](https://slicer.readthedocs.io/en/latest/developer_guide/script_repository.html#show-volume-rendering-automatically-when-a-volume-is-loaded).

If you want a more clear solution and also specify custom right-click menu actions, etc. then you can define a new Subject Hierarchy plugin that will recognize the special image type and return a high confidence value for it (so your plugin will be the owner of that image). In this case, your plugin will show/hide the volume, so you can customize how exactly it is performed. See these related examples: [simple subject hierarchy plugin](https://slicer.readthedocs.io/en/latest/developer_guide/script_repository.html#subject-hierarchy-plugin-offering-view-context-menu-action), [complete example of a new volume type](https://github.com/SlicerRt/SlicerRT/blob/master/DicomRtImportExport/SubjectHierarchyPlugins/qSlicerSubjectHierarchyRtDoseVolumePlugin.h) (RT dose volume, with custom colormap, custom icon in the subject hierarchy, custom right-click menu actions).
