- mne.stats.spatio_temporal_cluster_1samp_test(X, threshold=None, n_permutations=1024, tail=0, stat_fun=None, adjacency=None, n_jobs=None, seed=None, max_step=1, spatial_exclude=None, step_down_p=0, t_power=1, out_type='indices', check_disjoint=False, buffer_size=1000, verbose=None)#
Non-parametric cluster-level paired t-test for spatio-temporal data.
This function provides a convenient wrapper for
mne.stats.permutation_cluster_1samp_test(), for use with data organized in the form (observations × time × space), (observations × frequencies × space), or optionally (observations × time × frequencies × space). For details, see .
array, shape (n_observations, p[, q], n_vertices)
The data to be clustered. The first dimension should correspond to the difference between paired samples (observations) in two conditions. The second, and optionally third, dimensions correspond to the time or time-frequency data. And, the last dimension should be spatial.
The so-called “cluster forming threshold” in the form of a test statistic (note: this is not an alpha level / “p-value”). If numeric, vertices with data values more extreme than
thresholdwill be used to form clusters. If
None, a t-threshold will be chosen automatically that corresponds to a p-value of 0.05 for the given number of observations (only valid when using a t-statistic). If
'step') then threshold-free cluster enhancement (TFCE) will be used (see the TFCE example and ). See Notes for an example on how to compute a threshold based on a particular p-value for one-tailed or two-tailed tests.
The number of permutations to compute. Can be ‘all’ to perform an exact test.
If tail is 1, the statistic is thresholded above threshold. If tail is -1, the statistic is thresholded below threshold. If tail is 0, the statistic is thresholded on both sides of the distribution.
Function called to calculate the test statistic. Must accept 1D-array as input and return a 1D array. If
None(the default), uses
Defines adjacency between locations in the data, where “locations” can be spatial vertices, frequency bins, time points, etc. For spatial vertices, see:
False, assumes no adjacency (each location is treated as independent and unconnected). If
None, a regular lattice adjacency is assumed, connecting each spatial location to its neighbor(s) along the last dimension of
adjacencyis a matrix, it is assumed to be symmetric (only the upper triangular half is used) and must be square with dimension equal to
X.shape[-1] * X.shape[-2](n_times * n_vertices) or (optionally)
X.shape[-1] * X.shape[-2] * X.shape[-3](n_times * n_freqs * n_vertices). If spatial adjacency is uniform in time, it is recommended to use a square matrix with dimension
X.shape[-1](n_vertices) to save memory and computation, and to use
max_stepto define the extent of temporal adjacency to consider when clustering.
The number of jobs to run in parallel. If
-1, it is set to the number of CPU cores. Requires the
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_backend()context manager that sets another value for
int| instance of
A seed for the NumPy random number generator (RNG). If
None(default), the seed will be obtained from the operating system (see
RandomStatefor details), meaning it will most likely produce different output every time this function or method is run. To achieve reproducible results, pass a value here to explicitly initialize the RNG with a defined state.
Maximum distance between samples along the second axis of
Xto be considered adjacent (typically the second axis is the “time” dimension). Only used when
adjacencyhas shape (n_vertices, n_vertices), that is, when adjacency is only specified for sensors (e.g., via
mne.channels.find_ch_adjacency()), and not via sensors and further dimensions such as time points (e.g., via an additional call of
List of spatial indices to exclude from clustering.
To perform a step-down-in-jumps test, pass a p-value for clusters to exclude from each successive iteration. Default is zero, perform no step-down test (since no clusters will be smaller than this value). Setting this to a reasonable value, e.g. 0.05, can increase sensitivity but costs computation time.
Power to raise the statistical values (usually t-values) by before summing (sign will be retained). Note that
t_power=0will give a count of locations in each cluster,
t_power=1will weight each location by its statistical score.
- out_type‘mask’ | ‘indices’
Output format of clusters within a list. If
'mask', returns a list of boolean arrays, each with the same shape as the input data (or slices if the shape is 1D and adjacency is None), with
Truevalues indicating locations that are part of a cluster. If
'indices', returns a list of tuple of ndarray, where each ndarray contains the indices of locations that together form the given cluster along the given dimension. Note that for large datasets,
'indices'may use far less memory than
'mask'. Default is
Whether to check if the connectivity matrix can be separated into disjoint sets before clustering. This may lead to faster clustering, especially if the second dimension of
X(usually the “time” dimension) is large.
Block size to use when computing test statistics. This can significantly reduce memory usage when
n_jobs > 1and memory sharing between processes is enabled (see
Xwill be shared between processes and each process only needs to allocate space for a small block of locations at a time.
For computing a
thresholdbased on a p-value, use the conversion from
pval = 0.001 # arbitrary df = n_observations - 1 # degrees of freedom for the test thresh = scipy.stats.t.ppf(1 - pval / 2, df) # two-tailed, t distribution
For a one-tailed test (
tail=1), don’t divide the p-value by 2. For testing the lower tail (
tail=-1), don’t subtract