Spatial color coding of EEG/MEG electrodes/sensors

Dear MNE,

For visualization of our 64 channels EEG data in MATLAB, we would like to use the spatial color coding as illustrated/stated on your webpage:

Regarding this we have the following questions:

  1. How can we integrate your python function “spatial_colors” into our MATLAB code?
  2. How can we assign the color codes onto different number of channels, such as 32, 64, 128, or 256 channels? Is there a certain convention for different number of channels? The example on the webpage is for 102 channels/magnetometers.

Kind regards,
Dr. Mehmet Eylem Kirlangic

Hello @Eylem and welcome to the forum!

MNE-Python uses a very simple function to convert the (X, Y, Z) coordinates of channels / sensors into RGB colors:

It should be trivial to re-implement this in Matlab.

Best wishes,


Dear @richard ,

As you pointed out, we were easily able to implement the smart idea of mapping (x, y, z) to RGB in Matlab.

Thank you very much for your prompt support!