[Mne_analysis] Vertices

Sheraz Khan, PhD sheraz at nmr.mgh.harvard.edu
Tue Oct 2 11:27:08 EDT 2018
Search archives:

Hi Karin,

Please find below, code snippet for finding neighbors for the individual
subject.

Its much more efficient version of the previous code and does not requires
casting sparse matrix to dense. You can find neighbors for ico5 even on a
conventional laptop.

import mne
from mne.source_estimate import spatial_tris_connectivity
import numpy as np
from mne.datasets import sample

# Only for fsaverage
surf = mne.surface._get_ico_surface(5)
connectivity = spatial_tris_connectivity(surf['tris'])
connectivity = connectivity.asformat('csr')
neighbours_list = np.split(connectivity.indices, connectivity.indptr)[1:-1]
# list of neighbours of each vertex

# for individual subjects having forward operator
data_path = sample.data_path()

fwd = mne.read_forward_solution(
    data_path + '/MEG/sample/sample_audvis-meg-eeg-oct-6-fwd.fif')

lh = fwd['src'][0]  # Visualize the left hemisphere
tris = lh['tris']  # Groups of three vertices that form triangles
connectivity = spatial_tris_connectivity(tris)
connectivity = connectivity.asformat('csr')
neighbours_list = np.split(connectivity.indices, connectivity.indptr)[1:-1]
# list of neighbours of each vertex



Thanks

Sheraz














>         External Email - Use Caution
>
> Well then there's one explanation anyway... I'm using the subject's own
> reconstructed MR.
> Plotting using brain.add_foci(vertex, coords_as_verts=True, hemi='lh',
> color=(1,0,0)) where brain = stc.plot().
>
> Karin
>
> Den sön 30 sep. 2018 kl 18:10 skrev Marijn van Vliet
> <w.m.vanvliet at gmail.com
>>:
>
>> Hi karin,
>>
>> How are you plotting the result exactly? This line:
>>
>> surf = mne.surface._get_ico_surface(5)
>>
>> only works for the fsaverage brain.
>>
>> best,
>> Marijn.
>>
>> > On 30 Sep 2018, at 18:08, Karin Westin <karin.westin85 at gmail.com>
>> wrote:
>> >
>> > surf = mne.surface._get_ico_surface(5)
>>
>>         External Email - Use Caution
>>
>> _______________________________________________
>> Mne_analysis mailing list
>> Mne_analysis at nmr.mgh.harvard.edu
>> https://mail.nmr.mgh.harvard.edu/mailman/listinfo/mne_analysis
> _______________________________________________
> Mne_analysis mailing list
> Mne_analysis at nmr.mgh.harvard.edu
> https://mail.nmr.mgh.harvard.edu/mailman/listinfo/mne_analysis


-------------------------
Sheraz Khan, M.Eng, Ph.D.
Instructor in Radiology

Athinoula A. Martinos Center for Biomedical Imaging
Massachusetts General Hospital
Harvard Medical School

McGovern Institute for Brain Research
Massachusetts Institute of Technology

Tel:   +1 617-643-5634
Fax:   +1 617-948-5966
Email: sheraz at nmr.mgh.harvard.edu
       sheraz at mit.edu
Web:   http://sheraz.mit.edu


More information about the Mne_analysis mailing list