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

The wilcoxon.statistic returns the W value, which behaves differently from the T statistic used in the original implementation of permutation_cluster_1samp_test. While higher T values indicate stronger effects (i.e., lower p-values), in the case of the Wilcoxon test, it’s the lower W values that correspond to more significant results.

Given this inversion in the interpretation of the statistic, do you have any recommendations for how to appropriately set the other parameters as threshold when using a Wilcoxon-based stat_fun?

1 Like