[Mne_analysis] Finding nearest neighbors with 'use_tris'?

Eric Larson larson.eric.d at gmail.com
Fri Apr 23 10:31:46 EDT 2021
Search archives:

        External Email - Use Caution        

>
> Also, I'm using MNE 0.20.7. The function 'spatial_tris_connectivity' seems
> to be gone in the latest
>
> stable MNE (0.22.1). Is there an updated way of getting the nearest neighbors matrix?
>
> When versions change functions can be deprecated and renamed. For this
you'd want to look at the release notes, in this case for both 0.21 and
0.22, to see if something changed, in this case this:

https://secure-web.cisco.com/1Edhzwz42XchQKf_0yIyY2MkV6nIV_igPALHq6GIBc0mh138b-w9G2oKnyxQt571p2TEGVTs-DwTxVJ2QwXyI0eyU7aK0UelYolh7GLByaoBOM2X7lR1urySDFkLlBYG2sMr_87qs1yJxzW6YHeFam6Ht98v2LrZ-lZ0Sa5OdNmPW8V2PW7JL7gwgPGwMQWCIVY5W_If8HGgHH5mF8F6R-EfLtMSHE3dm20G5mkkORTibBYvK3Nse5jwSMEIMwhJY3J_TZ6zz6UmI3W-vnQGufQ/https%3A%2F%2Fmne.tools%2Fdev%2Fwhats_new.html%23id6

Suggests you should do something like:

>>> src = mne.setup_source_space('sample', spacing='ico3', subjects_dir='/home/larsoner/mne_data/MNE-sample-data/subjects', add_dist=False)
>>> mne.spatial_src_adjacency(src)
<1284x1284 sparse matrix of type '<class 'numpy.int64'>'
    with 8964 stored elements in COOrdinate format>

Or you could use remap_vertices to use the tris function if you want (but I
find the above code to be cleaner):

>>> mne.spatial_tris_adjacency(src[0]['use_tris'], remap_vertices=True)
<642x642 sparse matrix of type '<class 'numpy.int64'>'
    with 4482 stored elements in COOrdinate format>

Eric
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.nmr.mgh.harvard.edu/pipermail/mne_analysis/attachments/20210423/075827e3/attachment-0001.html 


More information about the Mne_analysis mailing list