How to create adjacency matrix for a specific label?

  • MNE-Python (1.1.0)
  • Spyder version: 5.3.2 (conda)
  • Python version: 3.10.5 64-bit
  • Operating System: Windows 10

I am running a spatio_temporal_cluster_1samp_test (on source data), within a specific label (that I have created by myself). However, I couldn’t find a way to calculate the adjacency matrix for only the specific vertices of the label. And therefore I get a value error:

adjacency = mne.spatial_src_adjacency(src)

ValueError: adjacency (len 20484) must be of the correct size

Is there a way to calculate the adjacency for only specified vertices?

If needed, this is how I created the label:

stc_temp = stc.copy()[np.transpose(good_clusters[0]) == False] = 0.
stc_mask = mne.stc_to_label(stc_temp, src=src, smooth=False, connected=False, subjects_dir=None, verbose=None)


it’s not 100% clear that your custom label is the problem. The rest of that error message should say:

adjacency (len 20484) must be of the correct size, i.e. be equal to or evenly divide the number of tests (???).

If adjacency was computed for a source space, try using the fwd["src"] or inv["src"] as some original source space vertices can be excluded during forward computation.

It would help to know what the ??? was in the error message you got, and if that matches the number of vertices in your custom label. If not, it would also help to know if you’ve already tried the fix suggested by the error message, and if that worked or not.