Page 1 of 1

Displaying FreeSurfer aparc.a2009s+aseg atlas with correct colors

Posted: Tue Oct 23, 2018 6:44 pm
by francois
Hello

I'm trying to display the FreeSurfer Destrieux atlas (aparc.a2009s+aseg.mgz) in Anatomist, with appropriate colors:
https://surfer.nmr.mgh.harvard.edu/fswi ... erColorLUT

The voxel values in this atlas go from 0 to 14175.
To display the atlas correctly in anatomist windows, I read the FreeSurferColorLUT.txt file into a palette with 14176 RGB values (list with 42528 elements with [0,0,0] for all the undefined values), and assigned it to the volume using the following code:

Code: Select all

customPalette = a.createPalette("FreeSurferDestrieux")
customPalette.setColors(colors=colors, color_mode='RGB')
obj.setPalette(customPalette, minVal=0, maxVal=1)
After that, the colors in the volume are incorrectly set. In the anatomist window, I right-click on my FreeSurfer volume object > Color > Palette.
My palette is visible in the list and selected, min=0, max=12175, bounds=[0,12175]
Why 12175 instead of 14176?

What am I doing wrong?
Is there a more straightforward way to color correctly this FreeSurfer aparc.a2009s+aseg atlas?

Thanks
Francois

Re: Displaying FreeSurfer aparc.a2009s+aseg atlas with correct colors

Posted: Wed Oct 24, 2018 9:47 am
by riviere
Hi François,
The min/max you see in the interface are the min/max values of the image voxels (aparc.a2009s+aseg.mgz), not the palette. At the beginning palettes were meant to have an arbitrary number of colors, which are linearly mapped to the interval of the voxel image values. In this situation the number of colors in the palette is not really important. Now to have a one-to-one mapping between colors and voxels values (in a label image like in your situation), you have to use the "absolute mode", and here I'm afraid you have to know the number of colors (but in your situation, you do):

Code: Select all

obj.setPalette(customPalette, minVal=0, maxVal=14175, absoluteMode=True)
The "minVal" / "maxVal" arguments are values in the object voxels which map the bounds of the palette, and they are relative by default ([0-1] is the whole values range of the image) unless "absoluteMode" is used.
Denis

Re: Displaying FreeSurfer aparc.a2009s+aseg atlas with correct colors

Posted: Wed Oct 24, 2018 10:03 am
by francois
Great, it works!
I tried with maxVal=the number of colors, but without this option "absoluteMode".
Thanks!