open-discussion > How to Reverse a Colormap?
Showing 1-5 of 5 posts
Display:
Results per page:
Dec 7, 2021  02:12 AM | bcecconi - Center for sleep and consciousness
How to Reverse a Colormap?
Hello!
In MRIcron, I'm using the classic_overlay as colormap (red are positive values and blue negative ones). I would like to reverse it: i.e., red negative values and blue positive ones. Anyone knows an easy way to do this in MRIcron?
Thanks in adv
Dec 7, 2021  12:12 PM | Chris Rorden
RE: How to Reverse a Colormap?
MRIcron stores color lookup tables in its /Resources/LUT folder. These files must have the filename extension .lut. These can be either ImageJ binary format (these files are precisely 768 bytes) or Osirix text format (these are larger than 768 bytes and can be modified with a text editor or Excel). The 'overlay_classic.lut' is the latter. This format stores 256 colors each defined by an brightness index (0..255), plus red, green and blue components (each 0..255). So to invert the color scheme just change the index column so that all values 1..255 are flipped (255..1). I would leave index 0 untouched (this makes the darkest voxels black). You can place the edited file' overlay_inv.lut' in your LUT folder and restart MRIcron.

https://github.com/CPernet/brain_colours...
https://gist.github.com/stowler/5493255
https://people.cas.sc.edu/rorden/mricro/...

While I am happy that my MRIcron software has proved popular and robust, my current development efforts have shifted to MRIcroGL. MRIcroGL leverages OpenGL 2.1 (released in 2006) and Python scripting. It also includes many color schemes (viridis, mako, plasma, inferno) that are designed for common forms of color blindness.
  https://cran.r-project.org/web/packages/viridis/vignettes/intro-to-viridis.html
  https://github.com/CPernet/brain_colours
Attachment: overlay_inv.lut
Dec 7, 2021  03:12 PM | bcecconi - Center for sleep and consciousness
RE: How to Reverse a Colormap?
Dear Chris Rorden,
thank you so much for your very helpful answer. I did what you suggested, flipping the index values and leaving untouched the other columns and the 0 in the index col. Unfortunately, however, despite MRIcron recognizes my new colormap, it shows me the brain all black..I tried changing scale, but nothing seems to work. I attached here the overlay_classic_inverted file in case you have time to have a look at it and tell what I did wrong..

Thanks again for your help and time :)
Dec 7, 2021  04:12 PM | Chris Rorden
RE: How to Reverse a Colormap?
Did you try the .lut file I added in my attachment. Note that my file is a raw text file. The file you uploaded is in "RichTextFormat" which is not raw text.

The raw text data looks like this:

* s=byte index red green blue
S 0 0 0 0
S 1 255 0 16
S 2 255 0 13
S 3 255 0 10
S 4 255 0 8
...

While your RTF has a lot of formatting:

{\rtf1\ansi\ansicpg1252\cocoartf2580
\cocoatextscaling0\cocoaplatform0{\fonttbl\f0\fswiss\fcharset0 Helvetica;\f1\froman\fcharset0 TimesNewRomanPSMT;}
{\colortbl;\red255\green255\blue255;\red191\green191\blue191;}
{\*\expandedcolortbl;;\csgray\c79525;}
\margl1440\margr1440\vieww11520\viewh8400\viewkind0
\deftab720

\itap1\trowd \taflags1 \trgaph108\trleft-108 \trwWidth6500\trftsWidth3 \trbrdrt\brdrnil \trbrdrl\brdrnil \trbrdrr\brdrnil
\clvertalb \clshdrawnil \clwWidth1299\clftsWidth3 \clbrdrt\brdrs\brdrw20\brdrcf2 \clbrdrl\brdrs\brdrw20\brdrcf2 \clbrdrb\brdrs\brdrw20\brdrcf2 \clbrdrr\brdrs\brdrw20\brdrcf2 \clpadl100 \clpadr100 \gaph\cellx1728
\clvertalb \clshdrawnil \clwWidth1020\clftsWidth3 \clbrdrt\brdrs\brdrw20\brdrcf2 \clbrdrl\brdrs\brdrw20\brdrcf2 \clbrdrb\brdrs\brdrw20\brdrcf2 \clbrdrr\brdrs\brdrw20\brdrcf2 \clpadl100 \clpadr100 \gaph\cellx3456
\clvertalb \clshdrawnil \clwWidth1020\clftsWidth3 \clbrdrt\brdrs\brdrw20\brdrcf2 \clbrdrl\brdrs\brdrw20\brdrcf2 \clbrdrb\brdrs\brdrw20\brdrcf2 \clbrdrr\brdrs\brdrw20\brdrcf2 \clpadl100 \clpadr100 \gaph\cellx5184
\clvertalb \clshdrawnil \clwWidth1020\clftsWidth3 \clbrdrt\brdrs\brdrw20\brdrcf2 \clbrdrl\brdrs\brdrw20\brdrcf2 \clbrdrb\brdrs\brdrw20\brdrcf2 \clbrdrr\brdrs\brdrw20\brdrcf2 \clpadl100 \clpadr100 \gaph\cellx6912
\clvertalb \clshdrawnil \clwWidth1040\clftsWidth3 \clbrdrt\brdrs\brdrw20\brdrcf2 \clbrdrl\brdrs\brdrw20\brdrcf2 \clbrdrb\brdrs\brdrw20\brdrcf2 \clbrdrr\brdrs\brdrw20\brdrcf2 \clpadl100 \clpadr100 \gaph\cellx8640
\pard\intbl\itap1\pardeftab720\ri0\partightenfactor0
\f0\fs24 \cf0 * s=byte \cell
\pard\intbl\itap1\pardeftab720\ri0\partightenfactor0
\cf0 Index
\f1\fs20 \cell
\pard\intbl\itap1\pardeftab720\ri0\partightenfactor0
...
Dec 7, 2021  05:12 PM | bcecconi - Center for sleep and consciousness
RE: How to Reverse a Colormap?
Thanks so much for your answer.
Indeed, there was a lot of formatting that I didn't see. Now that is in plain text works :)
I cannot see any attachment so I didn't manage to try yours but now it works. The only thing is that my "negative values" are now displayed in pink with blue borders rather than all blue..To change this should I flip the red or blue column too?

In any case, thank you so much for your help and time.
Attachment: ForForum.png