Are there anyway to select a label or vertex according to position coordinates?

  • MNE version: 1.8.0
  • operating system: Windows11

Hi everyone, I’m trying to put a simulated signal on a specific position in brian, but I don’t know how to relate the coordinates to Label object. ChatGPT suggests me to use mne.vertex_to_mni and mne.grow_labels , as shown below

import mne
from mne import vertex_to_mni, grow_labels

dipole_pos = [0.05, -0.03, 0.06] 
vertex_idx, _ = mne.source_space.head_to_mni(
    dipole_pos,  
    subject='sample',  
    subjects_dir=subjects_dir 
)

label = mne.grow_labels(
    subject='sample',  
    subjects_dir=subjects_dir, 
    hemi='lh',
    vertices=[vertex_idx],
    n_jobs=1
)

However, I run the script and got an AttributeError: No mne.source_space attribute head_to_mri. I searched head_to_mni in mne’s document and found mne.head_to_mni, but according to the documnet this function just transforms the coordinates and cannot give me the label or vertex.

So, are there anyway to select a label or vertex according to position coordinates? Thanks!

Hi, for a similar task, I applied mne.vertex_to_mni to a label/hemisphere which gave coordinates for each vertex. Then you can find a minimal error for x,y,z coordinates with the coordinate you have (need to be in MNI305 coordinate system too). But check that the result is reasonable, of course.