Non-parametric cluster-level Wilcoxon

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

You can use the stat_fun parameter to specify a custom function for calculation of the statistics.

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

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