osl_dynamics.analysis.statistics#
Functions to perform statistical significance testing.
Functions#
|
Statistical significance testing for evoked responses. |
|
Statistical significance testing for difference between two groups. |
|
Statistical significance testing for paired difference. |
Module Contents#
- osl_dynamics.analysis.statistics.evoked_response_max_stat_perm(data, n_perm, covariates=None, metric='copes', n_jobs=1)[source]#
Statistical significance testing for evoked responses.
This function fits a General Linear Model (GLM) with ordinary least squares and performs a sign-flip permutation to build a null distribution using maximum statistic across the target dimensions.
- Parameters:
data (np.ndarray) – Data array for baseline corrected evoked responses. Shape is (n_samples, *target_dims).
n_perm (int) – Number of permutations.
covariates (dict, optional) –
Dictionary of continuous covariates to include as confound regressors. Each key is a covariate name and each value is a 1D array of length n_samples. These are z-scored internally. Example:
covariates = { "age": np.array([25, 30, 28, ...]), "head_size": np.array([55.1, 57.3, 54.8, ...]), }
metric (str, optional) – Statistic to compute p-values. Options are
'copes'or'tstats'.n_jobs (int, optional) – Number of jobs to run in parallel.
- Returns:
pvalues – P-values. Shape is (*target_dims,).
- Return type:
np.ndarray
- osl_dynamics.analysis.statistics.group_diff_max_stat_perm(data, assignments, n_perm, covariates=None, metric='tstats', n_jobs=1)[source]#
Statistical significance testing for difference between two groups.
This function fits a General Linear Model (GLM) with ordinary least squares and performs a row-shuffle permutation to build a null distribution using maximum statistic across the target dimensions (target_dims) for the difference between two groups.
- Parameters:
data (np.ndarray) – Data array for baseline corrected evoked responses. Shape is (n_samples, *target_dims).
assignments (np.ndarray) – Group assignments. Shape is (n_samples,). Must have exactly two unique values.
n_perm (int) – Number of permutations.
covariates (dict, optional) –
Dictionary of continuous covariates to include as confound regressors. Each key is a covariate name and each value is a 1D array of length n_samples. These are z-scored internally. Example:
covariates = { "age": np.array([25, 30, 28, ...]), "head_size": np.array([55.1, 57.3, 54.8, ...]), }
metric (str, optional) – Statistic to compute p-values with. Options are
'copes'or'tstats'.n_jobs (int, optional) – Number of jobs to run in parallel.
- Returns:
group_diff (np.ndarray) – Difference between two groups. Shape is (*target_dims,).
pvalues (np.ndarray) – P-values. Shape is (*target_dims,).
- Return type:
Tuple[numpy.ndarray, numpy.ndarray]
- osl_dynamics.analysis.statistics.paired_diff_max_stat_perm(data, n_perm, metric='copes', n_jobs=1)[source]#
Statistical significance testing for paired difference.
This function fits a General Linear Model (GLM) with ordinary least squares and performs sign-flip permutations to build a null distribution with the maximum statistic across the target dimensions for the paired differences.
- Parameters:
data (np.ndarray) – Data array for baseline corrected evoked responses. Shape is (n_samples, *target_dims).
n_perm (int) – Number of permutations.
metric (str, optional) – Statistic to compute p-values with. Options are
'copes'or'tstats'.n_jobs (int, optional) – Number of jobs to run in parallel.
- Returns:
paired_diff (np.ndarray) – Paired differences. Shape is (*target_dims,).
pvalues (np.ndarray) – P-values. Shape is (*target_dims,).
- Return type:
Tuple[numpy.ndarray, numpy.ndarray]