mne.stats.permutation_t_test#

mne.stats.permutation_t_test(X, n_permutations=10000, tail=0, n_jobs=None, verbose=None, *, rng=None, seed=None)[source]#

One sample/paired sample permutation test based on a t-statistic.

This function can perform the test on one variable or simultaneously on multiple variables. When applying the test to multiple variables, the “tmax” method is used for adjusting the p-values of each variable for multiple comparisons. Like Bonferroni correction, this method adjusts p-values in a way that controls the family-wise error rate. However, the permutation method will be more powerful than Bonferroni correction when different variables in the test are correlated (see [1]).

Parameters:
Xarray, shape (n_samples, n_tests)

Samples (observations) by number of tests (variables).

n_permutationsint | ‘all’

Number of permutations. If n_permutations is ‘all’ all possible permutations are tested. It’s the exact test, that can be untractable when the number of samples is big (e.g. > 20). If n_permutations >= 2**n_samples then the exact test is performed.

tail-1 | 0 | 1

If tail is 1, the alternative hypothesis is that the mean of the data is greater than 0 (upper tailed test). If tail is 0, the alternative hypothesis is that the mean of the data is different than 0 (two tailed test). If tail is -1, the alternative hypothesis is that the mean of the data is less than 0 (lower tailed test).

n_jobsint | None

The number of jobs to run in parallel. If -1, it is set to the number of CPU cores. Requires the joblib package. None (default) is a marker for ‘unset’ that will be interpreted as n_jobs=1 (sequential execution) unless the call is performed under a joblib.parallel_config context manager that sets another value for n_jobs.

verbosebool | str | int | None

Control verbosity of the logging output. If None, use the default verbosity level. See the logging documentation and mne.verbose() for details. Should only be passed as a keyword argument.

rngNone | int | instance of Generator | RandomState

The random number generator (RNG). If None (default), a new numpy.random.Generator seeded from entropy is used. Pass an int or a numpy.random.Generator for reproducible results, or a legacy RandomState to control the random-number stream or for interoperability with third-party code such as scikit-learn that does not accept generators. An integer seed uses numpy.random.default_rng() and therefore produces a different stream than the same integer passed to a legacy random_state or seed parameter.

New in v1.13.

seedNone | int | instance of RandomState

Supported for compatibility. New code should use rng. If None, NumPy’s global RandomState is used.

Returns:
T_obsarray of shape [n_tests]

T-statistic observed for all variables.

p_valuesarray of shape [n_tests]

P-values for all the tests (a.k.a. variables).

H0array of shape [n_permutations]

T-statistic obtained by permutations and t-max trick for multiple comparison.

Notes

If n_permutations >= 2 ** (n_samples - (tail == 0)), n_permutations, seed, and rng will be ignored since an exact test (full permutation test) will be performed.

References

Examples using mne.stats.permutation_t_test#

Permutation T-test on sensor data

Permutation T-test on sensor data

Statistical inference

Statistical inference