mne.stats.permutation_cluster_1samp_test¶

mne.stats.
permutation_cluster_1samp_test
(X, threshold=None, n_permutations=1024, tail=0, stat_fun=None, connectivity=None, verbose=None, n_jobs=1, seed=None, max_step=1, exclude=None, step_down_p=0, t_power=1, out_type='mask', check_disjoint=False, buffer_size=1000)[source]¶ Nonparametric clusterlevel paired ttest.
 Parameters
 X
array
, shape (n_observations, p[, q]) The data to be clustered. The first dimension should correspond to the difference between paired samples (observations) in two conditions. The subarrays
X[k]
can be 1D (e.g., time series) or 2D (e.g., timefrequency image) associated with the kth observation. For spatiotemporal data, see alsomne.stats.spatio_temporal_cluster_1samp_test()
. threshold
float
dict
None
If numeric, vertices with data values more extreme than
threshold
will be used to form clusters. If threshold isNone
, a tthreshold will be chosen automatically that corresponds to a pvalue of 0.05 for the given number of observations (only valid when using a tstatistic). Ifthreshold
is adict
(with keys'start'
and'step'
) then thresholdfree cluster enhancement (TFCE) will be used (see the TFCE example and 1). n_permutations
int
 ‘all’ The number of permutations to compute. Can be ‘all’ to perform an exact test.
 tail
int
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.
 stat_fun
callable()
None
Function called to calculate the test statistic. Must accept 1Darray as input and return a 1D array. If
None
(the default), usesmne.stats.ttest_1samp_no_p()
. connectivity
scipy.sparse.spmatrix
None
False
Defines connectivity between locations in the data, where “locations” can be spatial vertices, frequency bins, etc. If
False
, assumes no connectivity (each location is treated as independent and unconnected). IfNone
, a regular lattice connectivity is assumed, connecting each location to its neighbor(s) along the last dimension ofX
(or the last two dimensions ifX
is 2D). Ifconnectivity
is a matrix, it is assumed to be symmetric (only the upper triangular half is used) and must be square with dimension equal toX.shape[1]
orX.shape[1] * X.shape[2]
. verbosebool,
str
,int
, orNone
If not None, override default verbose level (see
mne.verbose()
and Logging documentation for more). n_jobs
int
The number of jobs to run in parallel (default 1). Requires the joblib package.
 seed
None
int
 instance ofRandomState
If
seed
is anint
, it will be used as a seed forRandomState
. IfNone
, the seed will be obtained from the operating system (seeRandomState
for details). Default isNone
. max_step
int
Maximum distance along the second dimension (typically this is the “time” axis) between samples that are considered “connected”. Only used when
connectivity
has shape (n_vertices, n_vertices). excludebool
array
orNone
Mask to apply to the data to exclude certain points from clustering (e.g., medial wall vertices). Should be the same shape as X. If None, no points are excluded.
 step_down_p
float
To perform a stepdowninjumps test, pass a pvalue for clusters to exclude from each successive iteration. Default is zero, perform no stepdown 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.
 t_power
float
Power to raise the statistical values (usually tvalues) by before summing (sign will be retained). Note that
t_power=0
will give a count of locations in each cluster,t_power=1
will weight each location by its statistical score. out_type‘mask’  ‘indices’
Output format of clusters. If
'mask'
, returns boolean arrays the same shape as the input data, withTrue
values indicating locations that are part of a cluster. If'indices'
, returns a list of lists, where each sublist contains the indices of locations that together form a cluster. Note that for large datasets,'indices'
may use far less memory than'mask'
. Default is'mask'
. check_disjointbool
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. buffer_size
int
None
Block size to use when computing test statistics. This can significantly reduce memory usage when n_jobs > 1 and memory sharing between processes is enabled (see
mne.set_cache_dir()
), becauseX
will be shared between processes and each process only needs to allocate space for a small block of locations at a time. verbosebool,
str
,int
, orNone
If not None, override default verbose level (see
mne.verbose()
and Logging documentation for more).
 X
 Returns
Notes
From an array of paired observations, e.g. a difference in signal amplitudes or power spectra in two conditions, calculate if the data distributions in the two conditions are significantly different. The procedure uses a cluster analysis with permutation test for calculating corrected pvalues. Randomized data are generated with random sign flips. See 2 for more information.
Because a 1sample ttest on the difference in observations is mathematically equivalent to a paired ttest, internally this function computes a 1sample ttest (by default) and uses sign flipping (always) to perform permutations. This might not be suitable for the case where there is truly a single observation under test; see Statistical inference.
If
n_permutations >= 2 ** (n_samples  (tail == 0))
,n_permutations
andseed
will be ignored since an exact test (full permutation test) will be performed.If no initial clusters are found, i.e., all points in the true distribution are below the threshold, then
clusters
,cluster_pv
, andH0
will all be empty arrays.References
 1
Stephen M. Smith and Thomas E. Nichols. Thresholdfree cluster enhancement: addressing problems of smoothing, threshold dependence and localisation in cluster inference. NeuroImage, 44(1):83–98, 2009. doi:10.1016/j.neuroimage.2008.03.061.
 2
Eric Maris and Robert Oostenveld. Nonparametric statistical testing of EEG and MEGdata. Journal of Neuroscience Methods, 164(1):177–190, 2007. doi:10.1016/j.jneumeth.2007.03.024.