Statistics Functions#
EEGPrep statistics helpers mirror the useful parts of EEGLAB’s
functions/statistics package while using explicit NumPy contracts. Unless
noted otherwise, condition arrays use their final axis for cases, subjects, or
surrogate replications.
Condition Tests#
- eegprep.functions.statistics.statcond(data, *, paired='auto', method='param', mode=None, naccu=200, variance='homogenous', forceanova=False, tail='both', axis=-1, rng=None, alpha=None, surrog=None, stats=None, return_resampling_array=False)
Compare condition arrays using EEGLAB-style t-tests or ANOVAs.
- Parameters:
data (Any) – One- or two-dimensional sequence of condition arrays. The case dimension is the last axis by default.
method (str) –
"param","perm", or"bootstrap".mode (str | None) – Legacy alias for
method.naccu (int) – Number of surrogate samples for nonparametric methods.
variance (str) –
"homogenous"or"inhomogenous"for unpaired t-tests.forceanova (bool) – Use one-way ANOVA instead of a two-condition t-test.
tail (str) – Empirical-tail mode for supplied or computed surrogates.
axis (int) – Axis in each condition array that stores cases.
rng (Generator | int | None) – Optional NumPy generator or seed for deterministic resampling.
alpha (float | None) – Optional threshold for confidence intervals and masks; requires a nonparametric method or supplied surrogate statistics.
surrog (Any) – Precomputed surrogate statistic array.
stats (Any) – Observed statistic to pair with
surrog.return_resampling_array (bool) – Return surrogate condition grids instead of computing statistics.
- Return type:
StatcondResult | SurrogateDistribution
- eegprep.functions.statistics.ttest_cell(a, b=None, *, axis=-1)
Compute paired t-statistics across the case axis.
- eegprep.functions.statistics.ttest2_cell(a, b=None, variance='homogenous', *, axis=-1)
Compute unpaired t-statistics across the case axis.
- eegprep.functions.statistics.anova1_cell(data, *, axis=-1)
Compute one-way unpaired ANOVA F-statistics across condition arrays.
- eegprep.functions.statistics.anova1rm_cell(data, *, axis=-1)
Compute one-way repeated-measures ANOVA F-statistics.
- eegprep.functions.statistics.anova2_cell(data, *, axis=-1)
Compute balanced two-way unpaired ANOVA F-statistics.
Multiple Comparisons And Surrogates#
- eegprep.functions.statistics.fdr(pvals, q=None, fdr_type='parametric')
Compute Benjamini-Hochberg or Benjamini-Yekutieli FDR thresholds.
- Parameters:
pvals (Any) – Numeric p-value array with values in the closed interval [0, 1].
q (float | None) – Desired false discovery rate. If omitted, an EEGLAB-style array of corrected thresholds is returned.
fdr_type (str) –
"parametric"for Benjamini-Hochberg or"nonparametric"/"nonParametric"for Benjamini-Yekutieli.
- Returns:
Threshold and boolean mask with the same shape as
pvals.- Return type:
FDRResult
- eegprep.functions.statistics.stat_surrogate_pvals(distribution, observed, tail='both')
Compute empirical p-values against a surrogate distribution.
- eegprep.functions.statistics.stat_surrogate_ci(distribution, alpha=0.05, tail='both')
Compute surrogate confidence intervals along the last axis.
- eegprep.functions.statistics.surrogdistrib(data, *, method='perm', pairing='on', naccu=1, axis=-1, rng=None)
Build bootstrap or permutation surrogate condition grids.
- Parameters:
data (Any) – One- or two-dimensional sequence of condition arrays.
method (str) –
"perm"/"permutation"or"bootstrap".pairing (str) –
"on"to preserve case identity across conditions or"off"to resample from the pooled case axis.naccu (int) – Number of surrogate grids to generate.
axis (int) – Axis in each condition array that stores cases.
rng (Generator | int | None) – Optional NumPy generator or seed for deterministic resampling.
- Return type:
SurrogateDistribution
Data Helpers#
- eegprep.functions.statistics.concatdata(data, *, axis=-1)
Concatenate condition arrays along their case axis.
- eegprep.functions.statistics.corrcoef_cell(a, b=None, *, axis=-1)
Compute pairwise correlations along a case axis.