Channel locations from a .mat file

Hello,

I am very new to python and I want to analyse some EEG data. Right now, I am starting off with the EEG-pre-processing. My supervisor has provided me with some information and the file for the channel location happen to be with an .mat ending. I did some Google research and tried various codes, without any success.

Is it possible to read the channel locations from a file ending with .mat? To then add it with set_montage? It contains the channel locations in a 1X61 structure with 10 fields (theta, radius, X, Y, Z, sph_theta, sph_phi, sph_radius, type). Or is there a way to transform this file into something that is readable in python?

I am working on a MacBook, version 12.6 macOS Monterey,
MNE version: 0.4.0

Hello again and quick update:

I have managed to export the channel locations as an CSV and import it that way to python and added it to my data. Now I am only missing the underlying “head”. Please find pictures of what I am talking about in the reply. The CSV format is also displayed. I get the error “RuntimeWarning: Fiducial point nasion not found, assuming identity unknown to head transformation”

Thank you for any help in advance!
Anna

labels X Y Z
Fp1 30.7 94.9 14
Fpz -0.165 98.3 18.6
Fp2 -31.5 96.4 14.1
F7 74.2 52 3.09
F3 52.9 52 56.7
Fz -0.426 52.4 79.2
F4 -54.9 53.1 55.4
F8 -76 53.6 2.91
FC5 80.9 18.5 33.5
FC1 34.7 15.1 87.3
FC2 -35.8 15.8 85.8
FC6 -84 19.9 33.3
T7 87.4 -11.7 -6.17
C3 67.2 -22.8 64.9
Cz -0.537 -27.5 96.9
C4 -69.1 -21.9 64
T8 -88.2 -10.6 -6.27
CP5 82.8 -53.1 26
CP1 37.1 -66.8 83.7
CP2 -39.9 -66.3 83.6
CP6 -86.2 -52.4 26.7
P7 75.6 -74.9 -12
P3 55.1 -92.6 42.5
Pz -0.444 -101 66.9
P4 -57.3 -92.7 42.6
P8 -76.2 -74.9 -12.2
POz -0.303 -116 30.7
O1 30.8 -119 -11
O2 -31.2 -119 -11.1
AF7 57.4 79.3 8.56
AF3 35.5 82.4 41
AF4 -37.7 83.1 41.4
AF8 -57.9 80.3 8.54
F5 67.4 52 31.3
F1 28.5 52.1 74.1
F2 -31 52.7 73.2
F6 -70 53.4 30.8
FC3 63.1 16.5 64.4
FCz -0.516 14.8 95.5
FC4 -64.7 17.6 63.4
C5 84.9 -17.6 31.6
C1 38 -26.7 90.8
C2 -39.8 -26 89.2
C6 -86.3 -16.6 31.4
CP3 65.7 -61 58.9
CP4 -68 -60.1 58.5
P5 70.5 -84.3 17
P1 29.6 -98.3 60.2
P2 -32.1 -98.6 60.8
P6 -72.2 -84.3 16.9
PO5 50.3 -107 4.87
PO3 39.6 -112 20.4
PO4 -38.3 -112 19.4
PO6 -49.5 -108 4.09
FT7 83.6 20.9 -1.84
FT8 -85 22.4 -1.97
TP7 87.9 -44.5 -10.1
TP8 -87 -43.5 -9.97
PO7 57.2 -101 -12.6
PO8 -58.2 -102 -12.9
Oz -0.161 -123 -7.28

Hello,

The scaling is off. MNE requires meters probably.
Anyway, between FCz and Cz you can see a “dot”. That’s your headshape with the nose and the ears :wink:

Best,
Mathieu

1 Like

This is correct, you need to divide your values by 1000 to convert from mm to m.

Richard


Hi all,

thank you for your fast reply! Yes, I found this post mne.channels.read_custom_montage('128+8locs.xyz'): ValueError: could not convert string to float: - #15 by richard and figured it has to do something with the scaling.

I tried the division by 1000 and it resulted in a still slightly off montage (see attached)

My montage file also contains columns with radius, do you think I should use that in any way?

Thank you
Anna

Ok, so I took a long way around. Imported the channel locations to EEG-Lab in Matlab, exported it and finally have a montage that is somewhat reasonable, but it is still not 100 as in MATLAB. In Matlab the locations are shown in the right position, while python locations are off the head. What is happening?


matlab


and python

You can pass sphere='eeglab' when plotting the montage. This will bring you a little bit closer to what you see in the EEGLAB figure (but still not match it exactly).

Richard