# Below/aboverange color show for model scalars

**URL:** <https://discourse.slicer.org/t/below-aboverange-color-show-for-model-scalars/19205>\
**Category:** Development\
**Created:** [August 16, 2021, 3:20am UTC](https://discourse.slicer.org/t/below-aboverange-color-show-for-model-scalars/19205 "2021-08-16T03:20:44Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![wabwan25](https://avatars.discourse-cdn.com/v4/letter/w/b19c9b/32.png) [@wabwan25](https://discourse.slicer.org/u/wabwan25)\
**Post date:** [August 16, 2021, 3:20am UTC](https://discourse.slicer.org/t/below-aboverange-color-show-for-model-scalars/19205/1 "2021-08-16T03:20:44Z")

</div>

Using python code, I copied a colornode and set below/above-range-colors as I need specific colors for scalar values out of the range. The below/above-range-color show correctly on scalar volume node. However, when applied the colornode to model scalars, it can set the range on scalars but didn’t show the below/above-range-colors.

cmap = slicer.util.getNode(“vtkMRMLColorTableNodeRainbow”)  
cmap.GetScalarsToColors().SetRange(20, 80)  
cmap.GetScalarsToColors().UseAboveRangeColorOn()  
cmap.GetScalarsToColors().SetAboveRangeColor(0.8, 0, 1, 1)  
cmap.GetScalarsToColors().UseBelowRangeColorOn()  
cmap.GetScalarsToColors().SetBelowRangeColor(0.82, 0.82, 0.82, 1)

this below/aboveRangeColor works for volume, but didn’t work for model scalars. I need the ranged scalars show for a model in Slicer. Any suggestions are greatly appreciated.

---

<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:** [August 16, 2021, 5:42am UTC](https://discourse.slicer.org/t/below-aboverange-color-show-for-model-scalars/19205/2 "2021-08-16T05:42:43Z")

</div>

Above/below range is not supported and it accidentally works for volumes because we did not explicitly disabled it. Adding proper support for out-of-range values would be probably significant effort (saving into colormap files, propagating to every display pipeline where colors can be used, etc.), but if you implement it then most likely we can integrate it into Slicer core. However, you are probably much better off if you just add one color above and one color below your “valid” color range. Values above/below the colormap’s range use the last/first value of the colormap.

---

<div class="post-metadata">

**Author:** ![wabwan25](https://avatars.discourse-cdn.com/v4/letter/w/b19c9b/32.png) [@wabwan25](https://discourse.slicer.org/u/wabwan25)\
**Post date:** [August 17, 2021, 1:01am UTC](https://discourse.slicer.org/t/below-aboverange-color-show-for-model-scalars/19205/3 "2021-08-17T01:01:57Z")

</div>

I worry that adding one color below the range will change the mapping slope from scalars to colors which I want to keep. Thank you very much for the answering.

---

<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:** [August 17, 2021, 3:11am UTC](https://discourse.slicer.org/t/below-aboverange-color-show-for-model-scalars/19205/4 "2021-08-17T03:11:26Z")

</div>

If you use the same color table and do not specify above/below range values then the color mapping will match.

By default, voxel values are volumes are mapped by via window/level to 0-255 range of the color table. If you use a procedural color map (such as RedGreenBlue or PET-DICOM) then it can simplify things if you bypass this window/level mapping by enable direct color mapping using `volumeNode.GetDisplayNode().SetScalarRangeFlag(slicer.vtkMRMLDisplayNode.UseDirectMapping)`.
