Surface SourceSpaces vertex coordinate

  • 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?
:slight_smile:

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
  2. Algorithms and other implementation details — MNE 1.7.1 documentation

Thanks for answering. :smiling_face_with_three_hearts:

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:

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:

[ 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:

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:

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

Did I make something wrong? :crying_cat_face:

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

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.