Thus far I have been using Matlab scripts for my permutation tests, but I would like to use mne functionality for this as well. Today I have been playing around with some tutorials using mne.stats.permutation_cluster_test and used it on my own data as well. This seemed to work fine, however, there is one aspect that is not entirely clear to me.
In my understanding if the argument connectivity is set to None, to be considered part of a cluster a node needs to be connected to another node in horizontal or vertical direction. But what I would like to do is to specify the connectivity matrix such that diagonals are also set to be part of the cluster. As a first attempt I tried to set connectivity with the following argument sparse.csr_matrix(np.ones((3,3))), but this gave me the error that connectivity must be of the correct size (I am comparing 3d arrays with the following dimensions: 16 x 19 x 141, where the first dimension are the number of observations)
Could you please tell me how to set the connectivity matrix to accomplish this or could you point me to a tutorial where this is explained.
In my understanding if the argument connectivity is set to None, to be
considered part of a cluster a node needs to be connected to another node
in horizontal or vertical direction.
But what I would like to do is to specify the connectivity matrix such that
diagonals are also set to be part of the cluster. As a first attempt I
tried to set connectivity with the following argument sparse.csr_matrix
(np.ones((3,3))), but this gave me the error that connectivity must be of
the correct size (I am comparing 3d arrays with the following dimensions:
16 x 19 x 141, where the first dimension are the number of observations)
Your matrix needs to specify the connectivity from each point to every
other point. Since you have 19 along one dimension and 141 along the other,
it will need to be shape (2679, 2679). grid_to_graph will give you an array
of this size, and then you'll need to add additional entries for the
elements in the array that correspond to the diagonal positions. To get a
handle on the problem, you might want to start with a smaller toy dataset
(maybe 3x3 like in the docs) so that it's easier to visualize what's
happening (e.g., plot the connectivity with
matplotlib.pyplot.imshow(connectivity)
along the way). If you get it working, it could make for a nice example to
add to MNE!