YakimS
(S. Yakim)
September 24, 2022, 8:41am
1
I want to perform a Non-parametric 1 sample cluster statistic on single trial power to find a significant cluster in a within-subject design.
Is there a way to perform permutation_cluster_1samp_test with Wilcoxon instead of the default t-test?
Thank you,
Sharon
MNE version: 1.1
operating system: Windows 10 Home
richard
(Richard Höchenberger)
September 24, 2022, 8:50am
2
You can use the stat_fun
parameter to specify a custom function for calculation of the statistics.
YakimS
(S. Yakim)
September 24, 2022, 2:16pm
3
Thank you!
I encounter a problem trying to implement it using stat_fun.
I try to execute:
mne.stats.permutation_cluster_1samp_test(subjects_over_time_array, stat_fun=scipy.stats.wilcoxon)
But I get an error:
> File ~\anaconda3\lib\site-packages\scipy\stats\morestats.py:3123, in wilcoxon(x, y, zero_method, correction, alternative, mode)
> 3121 d = asarray(x)
> 3122 if d.ndim > 1:
> -> 3123 raise ValueError('Sample x must be one-dimensional.')
I can’t figure out what’s wrong, as the scipy.stats.wilcoxon
function indeed receives 1D input, as requested in the permutation_cluster_1samp_test
documentation.
Many thanks,
Sharon
richard
(Richard Höchenberger)
September 24, 2022, 3:25pm
4
This works for me:
def stat_fun_wilcox(X):
result = scipy.stats.wilcoxon(X)
return result.statistic
T_obs, clusters, cluster_p_values, H0 = permutation_cluster_1samp_test(
epochs_power,
n_permutations=n_permutations,
threshold=t_thresh,
tail=tail,
adjacency=adjacency,
out_type='mask',
stat_fun=stat_fun_wilcox
)
You need to adjust t_thresh
, though.
1 Like