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

**URL:** <https://mne.discourse.group/t/source-localization-converting-ras-vertex-to-ras-x-y-z-coordinates/5419>\
**Category:** Support & Discussions\
**Tags:** ﻿source-localization, eeg\
**Created:** [August 17, 2022, 9:55am UTC](https://mne.discourse.group/t/source-localization-converting-ras-vertex-to-ras-x-y-z-coordinates/5419 "2022-08-17T09:55:03Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![brainfreeze1212](https://yyz2.discourse-cdn.com/free1/user_avatar/mne.discourse.group/brainfreeze1212/32/1815_2.png) [@brainfreeze1212](https://mne.discourse.group/u/brainfreeze1212)\
**Post date:** [August 17, 2022, 9:55am UTC](https://mne.discourse.group/t/source-localization-converting-ras-vertex-to-ras-x-y-z-coordinates/5419/1 "2022-08-17T09:55:04Z")

</div>

Hello,  
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](https://mne.tools/dev/auto_tutorials/inverse/30_mne_dspm_loreta.html)

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,

Brainfreeze1212

MNE version: 0.23.4  
operating System: Ubuntu 20.04

---

<div class="post-metadata">

**Author:** ![agramfort](https://avatars.discourse-cdn.com/v4/letter/a/7c8e57/32.png) [@agramfort](https://mne.discourse.group/u/agramfort)\
**Post date:** [August 19, 2022, 1:03pm UTC](https://mne.discourse.group/t/source-localization-converting-ras-vertex-to-ras-x-y-z-coordinates/5419/2 "2022-08-19T13:03:16Z")

</div>

how did you get vertno\_max ?

A

---

<div class="post-metadata">

**Author:** ![brainfreeze1212](https://yyz2.discourse-cdn.com/free1/user_avatar/mne.discourse.group/brainfreeze1212/32/1815_2.png) [@brainfreeze1212](https://mne.discourse.group/u/brainfreeze1212)\
**Post date:** [August 19, 2022, 1:15pm UTC](https://mne.discourse.group/t/source-localization-converting-ras-vertex-to-ras-x-y-z-coordinates/5419/3 "2022-08-19T13:15:46Z")

</div>

Hello,  
I got vertno\_max like this:

> vertno\_max, time\_max = stc.get\_peak(hemi=‘rh’, vert\_as\_index=None)

---

<div class="post-metadata">

**Author:** ![agramfort](https://avatars.discourse-cdn.com/v4/letter/a/7c8e57/32.png) [@agramfort](https://mne.discourse.group/u/agramfort)\
**Post date:** [August 19, 2022, 1:43pm UTC](https://mne.discourse.group/t/source-localization-converting-ras-vertex-to-ras-x-y-z-coordinates/5419/4 "2022-08-19T13:43:57Z")

</div>

then just do:

ras\_coor = [1][‘rr’][vertno\_max]

I think it should be enough

Alex

---

<div class="post-metadata">

**Author:** ![brainfreeze1212](https://yyz2.discourse-cdn.com/free1/user_avatar/mne.discourse.group/brainfreeze1212/32/1815_2.png) [@brainfreeze1212](https://mne.discourse.group/u/brainfreeze1212)\
**Post date:** [August 22, 2022, 7:23am UTC](https://mne.discourse.group/t/source-localization-converting-ras-vertex-to-ras-x-y-z-coordinates/5419/5 "2022-08-22T07:23:19Z")

</div>

Hello,

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: https://mne.tools/dev/auto\_tutorials/inverse/10\_stc\_class.html). But nonetheless - it did not work since the index is still out of bound…

---

<div class="post-metadata">

**Author:** ![jstout211](https://yyz2.discourse-cdn.com/free1/user_avatar/mne.discourse.group/jstout211/32/180_2.png) [@jstout211](https://mne.discourse.group/u/jstout211)\
**Post date:** [August 22, 2022, 5:44pm UTC](https://mne.discourse.group/t/source-localization-converting-ras-vertex-to-ras-x-y-z-coordinates/5419/6 "2022-08-22T17:44:23Z")

</div>

@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)`
