using find_ch_connectivity for spatio-temporal clustering

External Email - Use Caution

Hello MNE users,

I am attempting to use the function mne.channels.find_ch_connectivity() to
generate a matrix of the channel connectivity. I'd like to use this matrix
as an input to mne.stats.spatio_temporal_cluster_1samp_test() for the
'connectivity' argument.

I am getting an error when I feed the output of find_ch_connectivity into
spatio_temporal_cluster_1samp_test.

Here is my code:

*connect_matrix=mne.channels.find_ch_connectivity(epochs.info
<http://epochs.info>,ch_type='eeg')*

*type(connect_matrix[0]) *
*--> out: scipy.sparse.csr.csr_matrix*

*obs,clusters,cluster_pv,H=mne.stats.spatio_temporal_cluster_1samp_test(
array_of_diffs, connectivity=connect_matrix, n_permuntations=10000)*
*--> ValueError: if a connectivity matrix is given, it must be a scipy
sparse matrix*

It seems that I am expected to input a different type of scipy sparse
matrix for the connectivity argument in the spatio_temporal_cluster_1samp
function, but I am unsure which one and how I might do so.

Or, if anyone has suggestions for how else I might construct a connectivity
matrix to pass into the spatio_temporal_cluster_1samp function, I would
greatly appreciate it!

Thank you, and best wishes,
Dillan Cellier
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.nmr.mgh.harvard.edu/pipermail/mne_analysis/attachments/20190731/f4d6bdea/attachment.html

External Email - Use Caution

Hi Dillan,

if you do not untuple the output of the function like this:

connect_matrix, names = mne.channels.find_ch_connectivity(epochs.info,ch_type='eeg?)

you should pass

connect_matrix[0]

into the clustering permutation function.

Check here for the function signature:
https://www.martinos.org/mne/stable/generated/mne.channels.read_ch_connectivity.html#mne.channels.read_ch_connectivity

Hope that helps,

Denis

External Email - Use Caution

Oh! What a silly oversight. Thank you much for catching that, Denis!

External Email - Use Caution

No problem.
You were close to finding it with your type check.

Best,
Denis