Displaying FreeSurfer aparc.a2009s+aseg atlas with correct colors

Questions about Anatomist manipulation

Moderators: denghien, riviere

Post Reply
francois
Posts: 63
Joined: Tue Jul 25, 2017 9:37 am

Displaying FreeSurfer aparc.a2009s+aseg atlas with correct colors

Post 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
User avatar
riviere
Site Admin
Posts: 1361
Joined: Tue Jan 06, 2004 12:21 pm
Location: CEA NeuroSpin, Saint Aubin, France
Contact:

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

Post 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
francois
Posts: 63
Joined: Tue Jul 25, 2017 9:37 am

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

Post by francois »

Great, it works!
I tried with maxVal=the number of colors, but without this option "absoluteMode".
Thanks!
Post Reply