nipy / PySurfer

Cortical neuroimaging visualization in Python
https://pysurfer.github.io/
BSD 3-Clause "New" or "Revised" License
243 stars 97 forks source link

Set annotation LUT directly #271

Closed mwaskom closed 5 years ago

mwaskom commented 5 years ago

I was having an issue where one label in an annotation would mistakenly be colored bright blue. e.g. this is an incorrect rending of the Yeo2011_7Networks_N1000 annot included with Freesurfer:

image

The issue seems to be this. add_annotation is setting the colors by calling surf.module_manager.scalar_lut_manager.load_lut_from_list. This keeps the lookup table at 255 colors and sets the first n colors where n is the length of the list you pass in. So what's happening is the "wrong" label is the largest ID in the annotation, and it is being colored in with the next color, which is blue (for a relatively small annotation). Why is that happening? It's not exactly clear. I don't see anything obviously wrong with the code we are using to set the scalar values of the annotation mesh. It may be a bug in mayavi.

In either case, it's also possible to set the LUT trait directly. This seems to fix my issue:

image

larsoner commented 5 years ago

Thanks @mwaskom