Selecting nearest neighbors of a vertex in source space

External Email - Use Caution

Dear MNE users,

I would like to implement a searchlight-based generalized linear model on
source space data. To do so, I need to select the nearest neighbors of each
vertex but I'm unsure of how to do that in practice.
I have source estimates morphed to the fsaverage brain using ico5 spacing
(10241 vertices per hemisphere) as well as the connectivity matrices and
source spaces. I search in the methods of each of these classes, but did
not find anything that could help me. How can I determine which are the x
nearest neighbors of the nth vertex?

Thank you for your help,
Cheers,
Laetitia
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.nmr.mgh.harvard.edu/pipermail/mne_analysis/attachments/20180920/68681f18/attachment.html

Hi Laetitia,

Please see the code below, neighbours_list contains the list of the
neighbours of each vertex.

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

surf = mne.surface._get_ico_surface(5)
connectivity = spatial_tris_connectivity(surf['tris'])
connectivity = connectivity.todense()
neighbours_list = [np.where(row==1)[1] for row in connectivity]
#neighbours_list contains the list of the neighbours of each vertex

Thanks

Sheraz

External Email - Use Caution

Thank Sheraz, this is exactly what I was searching for!

Le ven. 21 sept. 2018 ? 00:50, Sheraz Khan, PhD <sheraz at nmr.mgh.harvard.edu>
a ?crit :

Hi Laetitia,

Please see the code below, neighbours_list contains the list of the
neighbours of each vertex.

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

surf = mne.surface._get_ico_surface(5)
connectivity = spatial_tris_connectivity(surf['tris'])
connectivity = connectivity.todense()
neighbours_list = [np.where(row==1)[1] for row in connectivity]
#neighbours_list contains the list of the neighbours of each vertex

Thanks

Sheraz

> External Email - Use Caution
>
> Dear MNE users,
>
> I would like to implement a searchlight-based generalized linear model on
> source space data. To do so, I need to select the nearest neighbors of
> each
> vertex but I'm unsure of how to do that in practice.
> I have source estimates morphed to the fsaverage brain using ico5 spacing
> (10241 vertices per hemisphere) as well as the connectivity matrices and
> source spaces. I search in the methods of each of these classes, but did
> not find anything that could help me. How can I determine which are the x
> nearest neighbors of the nth vertex?
>
> Thank you for your help,
> Cheers,
> Laetitia
> _______________________________________________
> Mne_analysis mailing list
> Mne_analysis at nmr.mgh.harvard.edu
> Mne_analysis Info Page

-------------------------
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
_______________________________________________
Mne_analysis mailing list
Mne_analysis at nmr.mgh.harvard.edu
Mne_analysis Info Page

The information in this e-mail is intended only for the person to whom it
is
addressed. If you believe this e-mail was sent to you in error and the
e-mail
contains patient information, please contact the Partners Compliance
HelpLine at
MyComplianceReport.com: Compliance and Ethics Reporting . If the e-mail was sent to you in
error
but does not contain patient information, please contact the sender and
properly
dispose of the e-mail.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.nmr.mgh.harvard.edu/pipermail/mne_analysis/attachments/20180924/86d72f8d/attachment.html