Question about permutation_cluster_test

Dear MNE,

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.

Thanks in advance,

Dirk

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.nmr.mgh.harvard.edu/pipermail/mne_analysis/attachments/20171128/c6a76b34/attachment.html

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.

Yep. You can get equivalent but slower behavior by using
connectivity=grid_to_graph(19,
141)
<http://scikit-learn.org/stable/modules/generated/sklearn.feature_extraction.image.grid_to_graph.html&gt;\.
See the recently updated stats documentation which has a bit more detail:

https://mne-tools.github.io/dev/auto_tutorials/plot_background_statistics.html#defining-the-connectivity-neighbor-adjacency-matrix

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!

Eric
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.nmr.mgh.harvard.edu/pipermail/mne_analysis/attachments/20171128/62b6764a/attachment.html