- MNE version: 1.2.1
- operating system: Ubuntu 20.04.5 LTS
Dear MNE community,
Iām trying to replicate the āPermutation t-test on source data with spatio-temporal clusteringā tutorial with my own data:
In my case, instead of making a paired contrast, like in the tutorial:
X = np.abs(X) # only magnitude
X = X[:, :, :, 0] - X[:, :, :, 1] # make paired contrast
Iām comparing two independent groups, so I use āspatio_temporal_cluster_testā instead of āspatio_temporal_cluster_1samp_testā
So I perform a cluster perm test as follows:
# Here we set a cluster forming threshold based on a p-value for
# the cluster based permutation test.
# We use a two-tailed threshold, the "1 - p_threshold" is needed
# because for two-tailed tests we must specify a positive threshold.
p_threshold = 0.05
df = X.shape[0] - 1 # degrees of freedom for the test
t_threshold = stats.distributions.f.ppf(1. - p_threshold / 2.,
X.shape[0] - 1, X2.shape[0] - 1)
n_permutations = 1000 # Should be above 1000.
# Now let's actually do the clustering. This can take a long time...
print('Clustering.')
T_obs, clusters, cluster_p_values, H0 = clu = \
spatio_temporal_cluster_test([X, X2],
n_permutations=n_permutations,
threshold=t_threshold,
max_step=2,
n_jobs=3,
seed=49,
buffer_size=None,
adjacency=adjacency,
out_type='mask',
verbose=True)
However, the error message:
In [27]: runcell(27, '/home/.../3.1._Source_Estimation_ERP_Stat.py')
Traceback (most recent call last):
File "/home/.../3.1._Source_Estimation_ERP_Stat.py", line 388, in <module>
stc_all_cluster_vis = summarize_clusters_stc(clu,
File "/home/.../anaconda3/envs/mne/lib/python3.10/site-packages/mne/stats/cluster_level.py", line 1515, in summarize_clusters_stc
t_inds, v_inds = clusters[cluster_ind]
ValueError: too many values to unpack (expected 2)
is displayed to me when I run:
stc_all_cluster_vis = summarize_clusters_stc(clu,
tstep=tstep,
vertices=fsave_vertices,
subject='fsaverage')
The spatio_temporal_cluster_test found 5 clusters, and two of them are āstatistically significantā.
The variable āclustersā is a list of length 5 and the entries are numpy arrays of boleans. The result of:
In [31]: clusters[0].shape
is:
Out[31]: (221, 20484)
Could anyone help me to understand what Iām doing wrong? I can provide you more information if needed. Any hint would be quite helpful
Thanks in advance,
Bruno