# Question about color lookup tables

**URL:** <https://discourse.slicer.org/t/question-about-color-lookup-tables/12316>\
**Category:** Support\
**Created:** [July 1, 2020, 10:16am UTC](https://discourse.slicer.org/t/question-about-color-lookup-tables/12316 "2020-07-01T10:16:15Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![rprueckl](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/rprueckl/32/4240_2.png) [@rprueckl](https://discourse.slicer.org/u/rprueckl)\
**Post date:** [July 1, 2020, 10:16am UTC](https://discourse.slicer.org/t/question-about-color-lookup-tables/12316/1 "2020-07-01T10:16:15Z")

</div>

Hi,

I have a question about using color lookup tables. I wanted to display an atlas nifti file [WHS\_SD\_rat\_atlas\_v3.nii.gz](https://www.nitrc.org/frs/download.php/11403/WHS_SD_rat_atlas_v3.nii.gz) in its original colors according to [WHS\_SD\_rat\_atlas\_v3.label](https://www.nitrc.org/frs/download.php/11404/WHS_SD_rat_atlas_v3.label).

I converted the lookup table to a Slicer lookup table and imported it:

 ![image](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/1/c/1c784e90e65cfb87e6d67a73cb216f13176e5862.png)

I changed the lookup table of the imported atlas volume to the imported lookup table, set its Window/Level settings to Manual Min/Max and the values to 0 and 164 (according to the volume information). This range also fits to the color indices of the lookup table.

Now, the scalars were not colored correctly. I made a dummy nifti using MATLAB to investigate:

```auto
V = zeros(165, 2, 2);
V(:, 1, 1) = linspace(0, 164, 165);
V=uint16(V);
niftiwrite(V,'path\to\testnifti.nii');

```

With the same slicer settings (lookup table, window/level settings), the result is as follows:

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

With this, I soon discovered, that the correct settings for Window/Level Manual Min/Max are 0 and 255 leading to this:

 ![image](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/4/8/48f6a87e4537b61af4628dd0cc80f52f77f41047.png)

When I use the same settings for the atlas, it is displayed in its original colors.

The question is: Why 255?

Thanks for your help!

---

<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:** [July 1, 2020, 1:55pm UTC](https://discourse.slicer.org/t/question-about-color-lookup-tables/12316/2 "2020-07-01T13:55:50Z")

</div>

Can you share the Slicer color file that you generated? If you want 1:1 mapping then you need to set the scalar range to match the number of colors.

By the way, if you load a labelmap volume, then I think the color table is used as is - there is no intensity mapping.

Have you created a script that converted ITK-snap to Slicer color table? Can you share it?

---

<div class="post-metadata">

**Author:** ![rprueckl](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/rprueckl/32/4240_2.png) [@rprueckl](https://discourse.slicer.org/u/rprueckl)\
**Post date:** [July 1, 2020, 2:08pm UTC](https://discourse.slicer.org/t/question-about-color-lookup-tables/12316/3 "2020-07-01T14:08:23Z")

</div>

> [@lassoan](#):
>
> Can you share the Slicer color file that you generated? If you want 1:1 mapping then you need to set the scalar range to match the number of colors.

Sure - it can be downloaded from [here](https://drive.google.com/file/d/1Q42V1SNnCXS76fvy7GapmkJIDaQ9knR8/view?usp=sharing). This version contains entries for the missing color indices in the original file, as I was thinking that missing entries might be an issue here.

I was playing around with the scalar range - I guess that the standard (as depicted in the screenshot) should be fine.

> [@lassoan](#):
>
> By the way, if you load a labelmap volume, then I think the color table is used as is - there is no intensity mapping.

A labelmap volume was one of the first things that came into my mind in connection with atlas-related applications. However, the atlas in question is distributed as a nifti and I couldn’t find a way in my quick research to convert it to a labelmap volume. So I extract the desired regions with the segment editor (thresholding the relevant scalar). Is there a better way to do this?

> [@lassoan](#):
>
> Have you created a script that converted ITK-snap to Slicer color table? Can you share it?

No, I did this by hand.

---

<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:** [July 1, 2020, 3:07pm UTC](https://discourse.slicer.org/t/question-about-color-lookup-tables/12316/4 "2020-07-01T15:07:12Z")

</div>

You can import a labelmap stored in a nifti file as described here:

[https://slicer.readthedocs.io/en/latest/user\_guide/modules/segmentations.html?highlight=labelmap#import-an-existing-segmentation-from-volume-file](https://slicer.readthedocs.io/en/latest/user_guide/modules/segmentations.html?highlight=labelmap#import-an-existing-segmentation-from-volume-file)

You can also convert a scalar volume to labelmap volume after you loaded it, by using “Convert to labelmap” in Volumes module / Volume information section.

---

<div class="post-metadata">

**Author:** ![rprueckl](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/rprueckl/32/4240_2.png) [@rprueckl](https://discourse.slicer.org/u/rprueckl)\
**Post date:** [July 1, 2020, 3:38pm UTC](https://discourse.slicer.org/t/question-about-color-lookup-tables/12316/5 "2020-07-01T15:38:29Z")

</div>

Oh, thanks for this information - especially the first option is very nice. Additionally to having the segments available, it would be very advantageous to be able to also import colors and labels for the segments. This way, the atlas representation would be complete.

Unfortunately, the initial question about the color lookup table settings remains a mystery for me.

---

<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:** [July 2, 2020, 5:37am UTC](https://discourse.slicer.org/t/question-about-color-lookup-tables/12316/6 "2020-07-02T05:37:11Z")

</div>

One more tip: If you work with hundreds of segments then you must use Slicer-4.11, as it has huge performance improvements for managing such large segmentations. It also has search and filter to make it easy to select a subset of segments that you are working on. Right-click on the segment list and choose “Show filter bar” to enable this feature.

 ![image](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/3/6/36d5c71b5042394b27fbd4d49a487d21edf5efdd.png)

---

<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:** [October 1, 2021, 10:20pm UTC](https://discourse.slicer.org/t/question-about-color-lookup-tables/12316/7 "2021-10-01T22:20:44Z")

</div>

A post was split to a new topic: [Rendering at higher than 8 bits per pixel](https://discourse.slicer.org/t/rendering-at-higher-than-8-bits-per-pixel/19961)
