# Json markups colors do not work

**URL:** <https://discourse.slicer.org/t/json-markups-colors-do-not-work/35739>\
**Category:** Support\
**Created:** [April 25, 2024, 7:24pm UTC](https://discourse.slicer.org/t/json-markups-colors-do-not-work/35739 "2024-04-25T19:24:14Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![FatihSogukpinar](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/fatihsogukpinar/32/7257_2.png) [@FatihSogukpinar](https://discourse.slicer.org/u/FatihSogukpinar)\
**Post date:** [April 25, 2024, 7:24pm UTC](https://discourse.slicer.org/t/json-markups-colors-do-not-work/35739/1 "2024-04-25T19:24:14Z")

</div>

Hi all,

I am trying to show a bunch of markup points using json file. The points are being loaded, and their positions are correct. However, I am also trying to set their colors and sizes, but somehow, slicer uses the default color and size. It is as if the colors and sizes I set in json do not have an effect at all…

I am using Slicer 5.6.2 and Json scheme here:

> <https://github.com/Slicer/Slicer/blob/main/Modules/Loadable/Markups/Resources/Schema/markups-schema-v1.0.3.json>

Does anyone have any idea about what might be going on ?  
Would a mismatch in versions cause this ? I assume if my json file format was totally wrong, the positions would be wrong too, not just colors and sizes.

Thanks a lot !!  
Fatih.

---

<div class="post-metadata">

**Author:** ![muratmaga](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/muratmaga/32/3622_2.png) [@muratmaga](https://discourse.slicer.org/u/muratmaga)\
**Post date:** [April 25, 2024, 7:29pm UTC](https://discourse.slicer.org/t/json-markups-colors-do-not-work/35739/2 "2024-04-25T19:29:52Z")

</div>

I can’t replicate this in 5.6.2. PointList markup load exactly with the color I specified. I suspect your JSON is incorrect somehow.

Perhaps work of an example you saved directly from Slicer?

---

<div class="post-metadata">

**Author:** ![FatihSogukpinar](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/fatihsogukpinar/32/7257_2.png) [@FatihSogukpinar](https://discourse.slicer.org/u/FatihSogukpinar)\
**Post date:** [April 25, 2024, 8:16pm UTC](https://discourse.slicer.org/t/json-markups-colors-do-not-work/35739/3 "2024-04-25T20:16:24Z")

</div>

Thank you ! I am trying it.

Just to make sure: With the correct json file, I should be able to adjust the colors of markups such that, I am using a continuous colorbar for hundreds of points, right ?  
I mean, I am not forced to use the same color for all markup points when I use json, right ?

Thanks!

---

<div class="post-metadata">

**Author:** ![muratmaga](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/muratmaga/32/3622_2.png) [@muratmaga](https://discourse.slicer.org/u/muratmaga)\
**Post date:** [April 25, 2024, 8:26pm UTC](https://discourse.slicer.org/t/json-markups-colors-do-not-work/35739/4 "2024-04-25T20:26:23Z")

</div>

> [@FatihSogukpinar](#):
>
> I mean, I am not forced to use the same color for all markup points when I use json, right ?

All the control points in a markup node (whether it is a curve or pointlist) will have the same color.

From a different thread, I saw that it is possible to write a JSON file that will have multiple markup nodes. that way you can create one node for every point and have full control over its colors. But you have to do it yourself.

I couldn’t find the thread (I am really no happy with the search on discourse), but it was last week, someone was asking a similar thing.

---

<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:** [April 25, 2024, 10:39pm UTC](https://discourse.slicer.org/t/json-markups-colors-do-not-work/35739/5 "2024-04-25T22:39:09Z")

</div>

Markup control points all displayed with the selected or unselected color. I would not recommend to add a new markup node for each point for performance reasons. If you want to assign an individual color to each point then you can do it with a model node.

It woild not be hard at all to color control points by a data array, but it has not been requested yet.

---

<div class="post-metadata">

**Author:** ![FatihSogukpinar](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/fatihsogukpinar/32/7257_2.png) [@FatihSogukpinar](https://discourse.slicer.org/u/FatihSogukpinar)\
**Post date:** [April 26, 2024, 3:58pm UTC](https://discourse.slicer.org/t/json-markups-colors-do-not-work/35739/6 "2024-04-26T15:58:55Z")

</div>

Thanks a lot for helpful comments !

How about simply creating many different json files, one for each markup point, with its corresponding color, size, etc. properties ? I know it sounds odd. But I don’t know how to do it the way @lassoan described:

> Blockquote  
> If you want to assign an individual color to each point then you can do it with a model node.

Also, I think it could be useful to have this feature in Slicer. I don’t know if I we are the only ones who use Slicer to display brain electrophysiology recordings and activity, but indeed we frequently need to show different subset of points with different display properties, and sometimes we also need to change display properties in a continuous manner, as in this case.

Thanks a lot,  
Fatih.

---

<div class="post-metadata">

**Author:** ![muratmaga](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/muratmaga/32/3622_2.png) [@muratmaga](https://discourse.slicer.org/u/muratmaga)\
**Post date:** [April 26, 2024, 5:00pm UTC](https://discourse.slicer.org/t/json-markups-colors-do-not-work/35739/7 "2024-04-26T17:00:24Z")

</div>

> [@FatihSogukpinar](#):
>
> How about simply creating many different json files, one for each markup point, with its corresponding color, size, etc. properties ? I know it sounds odd. But I don’t know how to do it the way @lassoan described:

Depends on how many you have, if you have hundreds your scene fill get bogged down, and interactions will be too slow.

You can convert the markups to models (3d spheres), see the example here:  
[SlicerMorph/Scripts (github.com)](https://github.com/SlicerMorph/Scripts?tab=readme-ov-file#3-turn-landmarks-into-3d-sphere-models)

You can modify the script to change their color properties…

---

<div class="post-metadata">

**Author:** ![FatihSogukpinar](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/fatihsogukpinar/32/7257_2.png) [@FatihSogukpinar](https://discourse.slicer.org/u/FatihSogukpinar)\
**Post date:** [April 28, 2024, 4:06pm UTC](https://discourse.slicer.org/t/json-markups-colors-do-not-work/35739/8 "2024-04-28T16:06:59Z")

</div>

Thanks!

To be able able to run these python scripts, do I need to run them using Slicer python extension? Or should I save the control points in a way that allows this script to work?

Thanks a lot,  
Fatih

---

<div class="post-metadata">

**Author:** ![muratmaga](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/muratmaga/32/3622_2.png) [@muratmaga](https://discourse.slicer.org/u/muratmaga)\
**Post date:** [April 28, 2024, 5:37pm UTC](https://discourse.slicer.org/t/json-markups-colors-do-not-work/35739/9 "2024-04-28T17:37:39Z")

</div>

Create your points. And copy paste the script into the python console. You may need to change the pointList name to match it to the script one (F)
