distance_matrix here would refer to 3 channels where channel 1 and 2 have a distance of 1.0, channel 1 and 3 have a distance of 2.0 and channel 2 and 3 have a distance of 1.0.
This sort of “low level input” (pre-computed distances between channels) is currently not supported. However, the higher level function, mne.channels.find_ch_adjacency — MNE 1.9.0 documentation, does fall back on computing distances (based on channel locations), to then obtain an adjacency matrix.
Perhaps you can look into the source code of that function and see what lines you can copy and/or adapt to make this useful for your case.
Thanks for the tip. I either had a distance matrix or 3d coordinates. It seems find_ch_adjacency works only with 2d coordinates. I’ll proceed with manually figuring out the adjacencies :/.
You could just project your 3D coordinates to 2D and then find the adjacency for that should at least be a good start, and you could inspect the sanity of it via mne.viz.plot_ch_adjacency — MNE 1.9.0 documentation
import numpy as np
from scipy.spatial import Delaunay
from eeg_positions.utils import _stereographic_projection
from mne.source_estimate import spatial_tris_adjacency
x, y = _stereographic_projection(3d_coordinates)
tri = Delaunay(np.vstack((x, y)).T)
adjacency = spatial_tris_adjacency(tri.simplices)