Source Localization: Converting RAS-Vertex to RAS x,y,z coordinates

I am performing different methods of personalized source localization with patients EEG data and respective MRI, with the code just like in the MNE Tutorial: Source localization with MNE, dSPM, sLORETA, and eLORETA — MNE 1.2.dev0 documentation

Unfortunately, the coordinate of the stc.peak is only displayed in MNI-coordinates and the RAS vertex (=vertno_max) is given.

I already tried to convert the RAS vertex on the right hemisphere to RAS coordinates using:

ras_coor = [1]['rr'][stc.rh_vertno[vertno_max]]

but this raises an ‘IndexError: index 123816 is out of bound for axis with size 4098’.

After computation of the forward solution, I checked whether the amount of vertices has declined compared to src. It has not. But the right hemisphere (in both src and fwd) seems to contain n_vertices=127113 of which only n_used=4098 are utilized.

Is there any way, I can get the x,y,z RAS coordinates from the RAS vertex?

Thankyou very much,


MNE version: 0.23.4
operating System: Ubuntu 20.04

how did you get vertno_max ?


I got vertno_max like this:

vertno_max, time_max = stc.get_peak(hemi=‘rh’, vert_as_index=None)

then just do:

ras_coor = [1][‘rr’][vertno_max]

I think it should be enough



unfortunately this also does not work.
I then receive the following ERROR:

TypeError Traceback (most recent call last)
Input In [44], in <cell line: 1>()
----> 1 ras_coor=[1][‘rr’][vertno_max]

TypeError: list indices must be integers or slices, not str

I also tried using:
ras_coor = src[1]['rr'][stc.rh_vertno[vertno_max]]
since the stc object only contains information about the Amplitudes over time whereas the src should contain information about source location (see: But nonetheless - it did not work since the index is still out of bound…

@brainfreeze1212 - I dont’ know if it fixes it, but what if you set vert_as_index to True. I think this gives you the index on source space versus the original freesurfer vertex index.

vertno_max, time_max = stc.get_peak(hemi=‘rh’, vert_as_index=True)