# Displaying a colorbar across viewers for diffusion scalar maps on tractography data

**URL:** <https://discourse.slicer.org/t/displaying-a-colorbar-across-viewers-for-diffusion-scalar-maps-on-tractography-data/30564>\
**Category:** SlicerDMRI\
**Tags:** diffusion, tractography\
**Created:** [July 12, 2023, 7:19pm UTC](https://discourse.slicer.org/t/displaying-a-colorbar-across-viewers-for-diffusion-scalar-maps-on-tractography-data/30564 "2023-07-12T19:19:16Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![jhlegarreta](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/jhlegarreta/32/66542_2.png) [@jhlegarreta](https://discourse.slicer.org/u/jhlegarreta)\
**Post date:** [July 12, 2023, 7:19pm UTC](https://discourse.slicer.org/t/displaying-a-colorbar-across-viewers-for-diffusion-scalar-maps-on-tractography-data/30564/1 "2023-07-12T19:19:16Z")

</div>

Hi,  
is it possible to add a colorbar across the Slicer viewers (just as shown in [the image in this post](https://discourse.slicer.org/t/how-to-find-a-default-colorbar-unit-or-calibrate-in-mm/22501/6) for another type of data) when we load some tractography data and load an associated scalar map, e.g. FA? If yes, how can this be done? At the very least in the 3D viewer?

 ![slicer_tractography_scalarmap_color_highlight](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/4/b/4b60c060c1715fed548bc27e495dc1b132b0f164.png)

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:** [July 12, 2023, 7:23pm UTC](https://discourse.slicer.org/t/displaying-a-colorbar-across-viewers-for-diffusion-scalar-maps-on-tractography-data/30564/2 "2023-07-12T19:23:24Z")

</div>

You can show the color legend in slice or 3D views as described [here](https://slicer.readthedocs.io/en/latest/user_guide/modules/colors.html#show-color-legend).

---

<div class="post-metadata">

**Author:** ![jhlegarreta](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/jhlegarreta/32/66542_2.png) [@jhlegarreta](https://discourse.slicer.org/u/jhlegarreta)\
**Post date:** [July 13, 2023, 8:26pm UTC](https://discourse.slicer.org/t/displaying-a-colorbar-across-viewers-for-diffusion-scalar-maps-on-tractography-data/30564/3 "2023-07-13T20:26:57Z")

</div>

Thanks Andras, but I mean the scalar values of streamlines, not the values corresponding to any underlying volume or structural image. Maybe I did not get it right, but following the linked instructions, I did not find the described context menus, options. Also, being able to click on a point and knowing the value of the scalar value associated to the streamline vertex would be ideal. Hope the two videos in here illustrate it:

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

[https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/6/9/691a5c4cd26742a0cf62b11b080cfd770f7164ba.mp4](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/6/9/691a5c4cd26742a0cf62b11b080cfd770f7164ba.mp4)

---

<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 15, 2023, 3:12pm UTC](https://discourse.slicer.org/t/displaying-a-colorbar-across-viewers-for-diffusion-scalar-maps-on-tractography-data/30564/4 "2023-07-15T15:12:19Z")

</div>

I think tracts are models, so you can use it Mable their color legend in Models module. In addition to that, you can display color legend for any color table in Colors module, but then you need to set the scalar range manually.

---

<div class="post-metadata">

**Author:** ![jhlegarreta](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/jhlegarreta/32/66542_2.png) [@jhlegarreta](https://discourse.slicer.org/u/jhlegarreta)\
**Post date:** [July 17, 2023, 11:43pm UTC](https://discourse.slicer.org/t/displaying-a-colorbar-across-viewers-for-diffusion-scalar-maps-on-tractography-data/30564/5 "2023-07-17T23:43:12Z")

</div>

> in Models module

OK, thanks Andras. That (`Models`; `ColorLegend`) seems to work for the 3D.

However, it only works for lines and not tubes. Thus at times, if we are unaware that lines are being displayed, we will be showing a colorbar that does not correspond to what we think we are looking at. And at times, we prefer to get more insight using the tube visualization.

 ![Slicer_color_by_fa1_models_line_vs_tube_line_cmap](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/c/f/cfc4388b3208b4a2ee62d6ca3ea78b172444faf5.png)

Seeing the wrong correspondence of colorbar values and data along tubes:

 ![Slicer_color_by_fa1_tubes_colorbar_corr_lines](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/a/5/a5ca0ea41712cd2bb7dcfa0cc565552b761e9fa3.jpeg)

Seeing the true correspondence of colorbar values and data along lines:

 ![Slicer_color_by_fa1_lines_colorbar_corr_lines](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/f/a/fa0779de93c4b3cb3db504f215f8e8c0ffbe1c74.png)

And it does not work for the 2D: the context menu shows no option to show the colorbar.

 ![Slicer_color_by_fa1_models_2d_context](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/b/7/b74607caca52c26019022fb3457c5af3da507595.png)

> Colors module,

Where is this module ? I cannot find it.

> [@jhlegarreta](#):
>
> Also, being able to click on a point and knowing the value of the scalar value associated to the streamline vertex would be ideal. Hope the two videos in here illustrate it:

What about this ?

---

<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 19, 2023, 3:51pm UTC](https://discourse.slicer.org/t/displaying-a-colorbar-across-viewers-for-diffusion-scalar-maps-on-tractography-data/30564/6 "2023-07-19T15:51:00Z")

</div>

> [@jhlegarreta](#):
>
> OK, thanks Andras. That (`Models`; `ColorLegend`) seems to work for the 3D.

It should work for all the views where the model is displayed. If it does not seem to work in the latest Slicer Stable Release then try in the latest Slicer Preview Release, too.

> [@jhlegarreta](#):
>
> Thus at times, if we are unaware that lines are being displayed

You can display any number of data nodes and color legends, so it is possible that you can see unrelated data and color legend in the same view. By default, the node name is displayed in the color legend’s title, which should help in avoiding accidental mixups.

> [@jhlegarreta](#):
>
> However, it only works for lines and not tubes.

It seems that tubes does not use the default color mapping, probably because it has some additonal modes. It should be possible to update the code to play nice with the color bar (at least store the color table and color display range in the display node base class). Please create an issue for this in the SlicerDMRI extension’s issue tracker.

---

<div class="post-metadata">

**Author:** ![jhlegarreta](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/jhlegarreta/32/66542_2.png) [@jhlegarreta](https://discourse.slicer.org/u/jhlegarreta)\
**Post date:** [July 24, 2023, 4:38pm UTC](https://discourse.slicer.org/t/displaying-a-colorbar-across-viewers-for-diffusion-scalar-maps-on-tractography-data/30564/7 "2023-07-24T16:38:08Z")

</div>

> [@lassoan](#):
>
> It should work for all the views where the model is displayed. If it does not seem to work in the latest Slicer Stable Release then try in the latest Slicer Preview Release, too.

I cannot afford trying another release, unfortunately, Andras.

> [@lassoan](#):
>
> You can display any number of data nodes and color legends, so it is possible that you can see unrelated data and color legend in the same view. By default, the node name is displayed in the color legend’s title, which should help in avoiding accidental mixups.

I repeatedly tested the feature to check the behavior, and it was not showing the colorbar corresponding to the `Tube` display mode.

> [@lassoan](#):
>
> It seems that tubes does not use the default color mapping, probably because it has some additonal modes. It should be possible to update the code to play nice with the color bar (at least store the color table and color display range in the display node base class). Please create an issue for this in the SlicerDMRI extension’s issue tracker.

Here: [Colorbar does not work for streamline tube display mode · Issue #7123 · Slicer/Slicer · GitHub](https://github.com/Slicer/Slicer/issues/7123)

---

<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 24, 2023, 5:42pm UTC](https://discourse.slicer.org/t/displaying-a-colorbar-across-viewers-for-diffusion-scalar-maps-on-tractography-data/30564/8 "2023-07-24T17:42:36Z")

</div>

> [@jhlegarreta](#):
>
> > [@lassoan](#):
> >
> > You can display any number of data nodes and color legends, so it is possible that you can see unrelated data and color legend in the same view. By default, the node name is displayed in the color legend’s title, which should help in avoiding accidental mixups.
> 
> I repeatedly tested the feature to check the behavior, and it was not showing the colorbar corresponding to the `Tube` display mode.

I meant that it in general. Tube display in SlicerDMRI extension is a special case - it had been implemented before color legend feature was added to Slicer core and unfortunately they are not compatible. Until the issue that you created (thank you!) is fixed, you can display a color legend by creating a dummy model node and selecting lookup table and setting the correct scalar range manually.
