<p><span style="padding: 3px 10px; border-radius: 5px; color: #ffffff; font-weight: bold; display: inline-block; background-color: #ff0000;"> External Email - Use Caution </span></p><p></p><div dir="ltr"><div>The distances between sources in a given hemisphere are computed along the cortical surface (Dijkstra distances). Since the two hemispheres are not connected, you have to use a different strategy across hemispheres. For example you could use scipy.spatial.distance.cdist on the src[0]['rr'][src[0]['vertno']] (left) and src[1]['rr'][src[1]['vertno']] (right) to get Euclidean distances. I've used this previously for example to say that any sources within 1 cm Euclidean distance between the hemis would be considered adjacent/neighbors. For my data it didn't make much difference that I remember, but for medial sources (since there is some ambiguity there) it might help.</div><div><br></div><div>Given that you want something like this and I've used it before, feel free to open an MNE-Python issue on GitHub about adding some new function to add this cross-hemisphere connectivity since it seems like it might be useful for others, too. And if you're up for making a PR to add it, that's even better!</div><div><br></div><div>Eric</div><div><br></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Wed, May 12, 2021 at 12:12 AM Gladia Hotan <<a href="mailto:gladiach@gmail.com">gladiach@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><p><span style="padding:3px 10px;border-radius:5px;color:rgb(255,255,255);font-weight:bold;display:inline-block;background-color:rgb(255,0,0)"> External Email - Use Caution </span></p><p></p><div dir="ltr"><div style="font-size:small">Hi Eric,</div><div style="font-size:small"><br></div><div style="font-size:small">Thanks for your help! This function seems to add distances between sources in the same hemisphere. Is there a way to get the distances between sources in different hemispheres?</div><div style="font-size:small"><br></div><div style="font-size:small">Best,</div><div style="font-size:small">Gladia</div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Fri, Apr 23, 2021 at 10:32 PM Eric Larson <<a href="mailto:larson.eric.d@gmail.com" target="_blank">larson.eric.d@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><p><span style="padding:3px 10px;border-radius:5px;color:rgb(255,255,255);font-weight:bold;display:inline-block;background-color:rgb(255,0,0)"> External Email - Use Caution </span></p><p></p><div dir="ltr"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div><span style="color:rgb(0,0,0);font-family:arial,sans-serif">Also, I'm using MNE 0.20.7. The function 'spatial_tris_connectivity' seems to be gone in the latest</span><br></div><div><pre><font face="arial, sans-serif" color="#000000">stable MNE (0.22.1). Is there an updated way of getting the nearest neighbors matrix?</font></pre></div></div></blockquote><div>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:</div><div><br></div><div><a href="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" target="_blank"><font color="red"><b>MailScanner has detected a possible fraud attempt from "secure-web.cisco.com" claiming to be</b></font> https://mne.tools/dev/whats_new.html#id6</a><br></div><div><br></div><div>Suggests you should do something like:</div><div></div><div><pre style="font-family:Consolas,Inconsolata,Courier,monospace;font-size:1em;line-height:1.2em;margin:1.2em 0px"><code style="font-size:0.85em;font-family:Consolas,Inconsolata,Courier,monospace;margin:0px 0.15em;background-color:rgb(248,248,248);white-space:pre-wrap;overflow:auto;border-radius:3px;border:1px solid rgb(204,204,204);padding:0.5em 0.7em;display:block">>>> 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>
</code></pre><div title="MDH:PGRpdj5gYGA8L2Rpdj48ZGl2PiZndDsmZ3Q7Jmd0OyBzcmMgPSBtbmUuc2V0dXBfc291cmNlX3Nw
YWNlKCdzYW1wbGUnLCBzcGFjaW5nPSdpY28zJywgc3ViamVjdHNfZGlyPScvaG9tZS9sYXJzb25l
ci9tbmVfZGF0YS9NTkUtc2FtcGxlLWRhdGEvc3ViamVjdHMnLCBhZGRfZGlzdD1GYWxzZSk8YnI+
Jmd0OyZndDsmZ3Q7IG1uZS5zcGF0aWFsX3NyY19hZGphY2VuY3koc3JjKTxicj4mbHQ7MTI4NHgx
Mjg0IHNwYXJzZSBtYXRyaXggb2YgdHlwZSAnJmx0O2NsYXNzICdudW1weS5pbnQ2NCcmZ3Q7Jzxi
cj4Jd2l0aCA4OTY0IHN0b3JlZCBlbGVtZW50cyBpbiBDT09yZGluYXRlIGZvcm1hdCZndDs8YnI+
PC9kaXY+PGRpdj5gYGA8L2Rpdj48ZGl2PjwvZGl2Pg==" style="height:0px;width:0px;max-height:0px;max-width:0px;overflow:hidden;font-size:0em;padding:0px;margin:0px"></div></div><div>Or you could use remap_vertices to use the tris function if you want (but I find the above code to be cleaner):</div><div></div><div><pre style="font-family:Consolas,Inconsolata,Courier,monospace;font-size:1em;line-height:1.2em;margin:1.2em 0px"><code style="font-size:0.85em;font-family:Consolas,Inconsolata,Courier,monospace;margin:0px 0.15em;background-color:rgb(248,248,248);white-space:pre-wrap;overflow:auto;border-radius:3px;border:1px solid rgb(204,204,204);padding:0.5em 0.7em;display:block">>>> 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>
</code></pre><div title="MDH:PGRpdj5gYGA8L2Rpdj48ZGl2PiZndDsmZ3Q7Jmd0OyBtbmUuc3BhdGlhbF90cmlzX2FkamFjZW5j
eShzcmNbMF1bJ3VzZV90cmlzJ10sIHJlbWFwX3ZlcnRpY2VzPVRydWUpPGJyPiZsdDs2NDJ4NjQy
IHNwYXJzZSBtYXRyaXggb2YgdHlwZSAnJmx0O2NsYXNzICdudW1weS5pbnQ2NCcmZ3Q7Jzxicj4J
d2l0aCA0NDgyIHN0b3JlZCBlbGVtZW50cyBpbiBDT09yZGluYXRlIGZvcm1hdCZndDs8YnI+PC9k
aXY+PGRpdj5gYGA8L2Rpdj48ZGl2PjwvZGl2Pg==" style="height:0px;width:0px;max-height:0px;max-width:0px;overflow:hidden;font-size:0em;padding:0px;margin:0px"></div></div><div>Eric<br></div><div><br></div></div></div>
_______________________________________________<br>
Mne_analysis mailing list<br>
<a href="mailto:Mne_analysis@nmr.mgh.harvard.edu" target="_blank">Mne_analysis@nmr.mgh.harvard.edu</a><br>
<a href="https://secure-web.cisco.com/1Y0U4QOZCNKFE0piEBTADI_l8_CUQZea1jEzuhIjy6JYgPGHcmxR40Co3AmGVlnTzdM7chDBPpZUN0Mk-a_Y38ZrtpG83n11c3wONbSp4yKaMJE_jkVUXklGRpHukxBo5LwY4-oHEpwgYASXMokFR-vcQYTVaGOfsIQb9vSSO7GuVdmr0Xc0ax4Pwl5IXJl_VWRNs7A-W7sJBsQP44UpYxgH0TtHRozkSZpDja67RrGiT1PeD-PuTzrHjeSUQLcJeh-5kGtg3b_85C9q4rRidGw/https%3A%2F%2Fmail.nmr.mgh.harvard.edu%2Fmailman%2Flistinfo%2Fmne_analysis" rel="noreferrer" target="_blank"><font color="red"><b>MailScanner has detected a possible fraud attempt from "secure-web.cisco.com" claiming to be</b></font> https://mail.nmr.mgh.harvard.edu/mailman/listinfo/mne_analysis</a></blockquote></div>
_______________________________________________<br>
Mne_analysis mailing list<br>
<a href="mailto:Mne_analysis@nmr.mgh.harvard.edu" target="_blank">Mne_analysis@nmr.mgh.harvard.edu</a><br>
<a href="https://secure-web.cisco.com/1S_979g4bUzOdpjoDHAJjlDgrEzGvVxZKuHamoJP-sO6F5fczrdL4OX7j-6m2zplYs5IrEhisfXH0n3FMqFUs7uftUUCNvoUGnL5FOuKqJ4SPm1gSnsaXPP28JDC6thPAQ6PmKGM-q47Am-7LS-Y9o2RI6rziER-GjX19IjXBqhjfKxKEH8oE7esc8rGJLz8tD5fI3MGyILD4O6UNQEi4BH_eoR2iEXttA3Hfiqb3RWCovTKbCb6nPpUJWow8MqTLpPA4Dhne3O-oUywve26lIw/https%3A%2F%2Fmail.nmr.mgh.harvard.edu%2Fmailman%2Flistinfo%2Fmne_analysis" rel="noreferrer" target="_blank"><font color="red"><b>MailScanner has detected a possible fraud attempt from "secure-web.cisco.com" claiming to be</b></font> https://mail.nmr.mgh.harvard.edu/mailman/listinfo/mne_analysis</a></blockquote></div></div>