# Connectivity matrix for cluster permutation test on 3D data

**URL:** <https://mne.discourse.group/t/connectivity-matrix-for-cluster-permutation-test-on-3d-data/2981>\
**Category:** Support & Discussions\
**Created:** [April 13, 2021, 3:53pm UTC](https://mne.discourse.group/t/connectivity-matrix-for-cluster-permutation-test-on-3d-data/2981 "2021-04-13T15:53:34Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Fleur](https://avatars.discourse-cdn.com/v4/letter/f/9d8465/32.png) [@Fleur](https://mne.discourse.group/u/Fleur)\
**Post date:** [April 13, 2021, 3:53pm UTC](https://mne.discourse.group/t/connectivity-matrix-for-cluster-permutation-test-on-3d-data/2981/1 "2021-04-13T15:53:34Z")

</div>

Dear all,

I’m trying to perform cluster permutation tests on 3D spatial data (100 x 100 x 100 voxels).  
Hence, my data matrix is of shape (n subjects, 1, 10e6).  
As far as I understand it, the automatic computation of the adjacency matrix is designed for 2D spatial data. Is there a way to automatically compute the adjacency matrix of a 3D regular grid of points?  
Thanks in advance!

---

<div class="post-metadata">

**Author:** ![drammock](https://yyz2.discourse-cdn.com/free1/user_avatar/mne.discourse.group/drammock/32/4_2.png) [@drammock](https://mne.discourse.group/u/drammock)\
**Post date:** [April 13, 2021, 6:21pm UTC](https://mne.discourse.group/t/connectivity-matrix-for-cluster-permutation-test-on-3d-data/2981/2 "2021-04-13T18:21:15Z")

</div>

`mne.stats.combine_adjacency(*data.shape)` will generate a sparse adjacency matrix where immediate neighbors along any axis will be considered adjacent.
