Identifying adjacent eeg sensors with find_ch_adjacency()

  • MNE-Python version: 0.23.0
  • operating system: NAME=“Ubuntu”/VERSION=“20.04.2 LTS (Focal Fossa)”

Hello,

I’m wondering how I can acquire an adjacency matrix of my 185-channel eeg cap to perform a searchlight analysis? I use the following function:

raw = mne.io.read_raw_eeglab('185_channel_data.set')
adj, names = mne.channels.find_ch_adjacency(raw.info, 'eeg')
Could not find a adjacency matrix for the data. Computing adjacency based on Delaunay triangulations.
-- number of adjacent vertices : 185

However, I’m confused about the output of this function: it is a list of 5 arrays, each with 185 elements. I was expecting a matrix with each electrode and its four adjacent electrodes?

Any help would be appreciated,

Tom

can you share the file with us?

Alex

Hi Alex,

Here is a box link to the .set file I’m working with: Box

Let me know if there is a separate, preferred way to share files.

Thanks!

Tom

the .fdt file was just uploaded now

here is some code that should help you:

import numpy as np
import mne

raw = mne.io.read_raw_eeglab('awakening-7-cleaned2_nrem.set')
adj, names = mne.channels.find_ch_adjacency(raw.info, 'eeg')

for k in range(len(names)):
    neigh_idx = np.where(adj[k, :].toarray().ravel())[0]
    neigh_names = [names[i] for i in neigh_idx]
    print(f"{names[k]} is next to {neigh_names}")

it gives

1 is next to ['1', '2', '10', '219', '220', '221', '222']
2 is next to ['1', '2', '3', '10', '11', '222', '223']
3 is next to ['2', '3', '4', '11', '223', '224']
4 is next to ['3', '4', '5', '11', '12', '13', '224']
5 is next to ['4', '5', '6', '13', '14', '215', '224']
6 is next to ['5', '6', '7', '14', '15', '207', '215']
7 is next to ['6', '7', '8', '15', '16', '198', '207']
8 is next to ['7', '8', '9', '16', '17', '186', '198']
9 is next to ['8', '9', '17', '44', '45', '132', '186']
10 is next to ['1', '2', '10', '11', '18', '31', '219']
11 is next to ['2', '3', '4', '10', '11', '12', '18']
12 is next to ['4', '11', '12', '13', '18', '19', '20']
...

HTH
Alex

Many thanks @agramfort ! :grin: