# Surface SourceSpaces vertex coordinate

**URL:** <https://mne.discourse.group/t/surface-sourcespaces-vertex-coordinate/9036>\
**Category:** Support & Discussions\
**Created:** [July 5, 2024, 4:18pm UTC](https://mne.discourse.group/t/surface-sourcespaces-vertex-coordinate/9036 "2024-07-05T16:18:48Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Alaylm1016](https://yyz2.discourse-cdn.com/free1/user_avatar/mne.discourse.group/alaylm1016/32/3197_2.png) [@Alaylm1016](https://mne.discourse.group/u/Alaylm1016)\
**Post date:** [July 5, 2024, 4:18pm UTC](https://mne.discourse.group/t/surface-sourcespaces-vertex-coordinate/9036/1 "2024-07-05T16:18:48Z")

</div>

- MNE version: 1.6.1
- operating system: Windows 10

Hi, I want to get the vertex locations from a Surface SourceSpaces object. I’m not sure whether _src[0][‘rr’]_ is what I need. Since MNE-Python uses Freeurfer surface RAS, is the result of _src[0][‘rr’]_ in such coordinate frame? And is it possible to get the vertex positions in MRI scan RAS?  
🙂

---

<div class="post-metadata">

**Author:** ![wmvanvliet](https://yyz2.discourse-cdn.com/free1/user_avatar/mne.discourse.group/wmvanvliet/32/100_2.png) [@wmvanvliet](https://mne.discourse.group/u/wmvanvliet)\
**Post date:** [July 5, 2024, 8:21pm UTC](https://mne.discourse.group/t/surface-sourcespaces-vertex-coordinate/9036/2 "2024-07-05T20:21:54Z")

</div>

`src[0]['rr']` is indeed in FreeSurfer surface RAS. To to convert to MRI scan RAS, you need to apply the _inverse_ of the vox2ras transform to convert `src[0]['rr']` to voxel indices, which you can then transform with the affine transform into MRI scan RAS.

See:

1. [How MNE uses FreeSurfer’s outputs — MNE 1.7.1 documentation](https://mne.tools/stable/auto_tutorials/forward/50_background_freesurfer_mne.html)
2. [Algorithms and other implementation details — MNE 1.7.1 documentation](https://mne.tools/stable/documentation/implementation.html#coordinate-systems)

---

<div class="post-metadata">

**Author:** ![Alaylm1016](https://yyz2.discourse-cdn.com/free1/user_avatar/mne.discourse.group/alaylm1016/32/3197_2.png) [@Alaylm1016](https://mne.discourse.group/u/Alaylm1016)\
**Post date:** [July 6, 2024, 4:05pm UTC](https://mne.discourse.group/t/surface-sourcespaces-vertex-coordinate/9036/3 "2024-07-06T16:05:31Z")

</div>

Thanks for answering. 🥰

I still get two questions. The first one is that I find MNE-Python offers a method to convert vertices to MNI coordinates by `mne.vertex_to_mni`. Like:

```python
src = mne.read_source_spaces(src) 
mni = mne.vertex_to_mni(
vertices=src[1]['vertno'], 
    hemis=1,
    subject='bst_resting', 
    subjects_dir='mne_data/MNE-brainstorm-data/bst_resting/subjects'
)
print(mni[2000])
print(mni[3000])

```

The results of above codes are:

```python
[40.57146301 -22.86971309 39.23717664]
[8.4092257 4.65913789 36.30525687]

```

I also find that MNE-Python offers another method to read the transform from subject’s RAS to MNI by `mne.transforms.read_ras_mni_t`. However, when I tried to apply this transform on subject’s RAS like:

```python
ras2mni = mne.transforms.read_ras_mni_t(
    subject='bst_resting', 
    subjects_dir='mne_data/MNE-brainstorm-data/bst_resting/subjects'
)
trans = ras2mni.get('trans')
print(trans.dot(np.append(src[1]['rr'][2000] * 1e3, 1)))
print(trans.dot(np.append(src[1]['rr'][3000] * 1e3, 1)))

```

I got different results:

```python
[9.64153958 -103.30903771 -17.48005282 1.]
[10.02140865 -100.87837363 -12.71987926 1.]

```

Did I make something wrong? 😿

The second question is about the transform from RAS to voxel. I looked up some information and followed their guidance. Here are my codes:

```python
import nibabel as nib
import numpy as np
img = nib.load('mne_data/MNE-brainstorm-data/bst_resting/subjects/bst_resting/mri/orig.mgz')
vox2ras_tkr = img.header.get_vox2ras_tkr()
vox2ras_tkr_inv = np.linalg.inv(vox2ras_tkr)
vox = vox2ras_tkr_inv.dot(np.append(src[1]['rr'][2000] * 1e3, 1))

```

I’m not sure if these steps are correct.
