stats#

analysis.stats.cluster_wise_p_val_correction(p_arr, p_sig=0.05, num_permutations=10000)[source]#

Obtain cluster-wise corrected p values.

Based on: neuromodulation/wjn_toolbox https://garstats.wordpress.com/2018/09/06/cluster/

Parameters:
  • (np.array) (p_arr)

  • (float) (p_sig)

  • (int) (num_permutations)

Returns:

  • p (float) (significance level of highest cluster)

  • p_min_index (indices of significant samples)

analysis.stats.cluster_wise_p_val_correction_numba(p_arr, p_sig, n_perm)[source]#

Calculate significant clusters and their corresponding p-values.

Based on: neuromodulation/wjn_toolbox https://garstats.wordpress.com/2018/09/06/cluster/

Parameters:
  • p_arr (array-like) – Array of p-values. WARNING: MUST be one-dimensional

  • p_sig (float) – Significance level

  • n_perm (int) – No. of random permutations for building cluster null-distribution

Returns:

  • p (list of floats) – List of p-values for each cluster

  • p_min_index (list of numpy array) – List of indices of each significant cluster

analysis.stats.permutationTest(x, y, plot_distr=True, x_unit=None, p=5000)[source]#

Calculate permutation test https://towardsdatascience.com/how-to-assess-statistical-significance-in-your-data-with-permutation-tests-8bb925b2113d

x (np array) : first distr. y (np array) : first distr. plot_distr (boolean) : if True: plot permutation histplot and ground truth x_unit (str) : histplot xlabel p (int): number of permutations

returns: gT (float) : estimated ground truth, here absolute difference of distribution means p (float) : p value of permutation test

analysis.stats.permutationTestSpearmansRho(x, y, plot_distr=True, x_unit=None, p=5000)[source]#

Calculate permutation test for multiple repetitions of Spearmans Rho https://towardsdatascience.com/how-to-assess-statistical-significance-in-your-data-with-permutation-tests-8bb925b2113d

x (np array) : first distibution e.g. R^2 y (np array) : second distribution e.g. UPDRS plot_distr (boolean) : if True: permutation histplot and ground truth will be plotted x_unit (str) : histplot xlabel p (int): number of permutations

returns: gT (float) : estimated ground truth, here spearman’s rho p (float) : p value of permutation test

analysis.stats.permutationTest_relative(x, y, plot_distr=True, x_unit=None, p=5000)[source]#

Calculate permutation test https://towardsdatascience.com/how-to-assess-statistical-significance-in-your-data-with-permutation-tests-8bb925b2113d

x (np array) : first distr. y (np array) : first distr. plot_distr (boolean) : if True: plot permutation histplot and ground truth x_unit (str) : histplot xlabel p (int): number of permutations

returns: gT (float) : estimated ground truth, here absolute difference of distribution means p (float) : p value of permutation test

analysis.stats.permutation_numba_onesample(x, y, n_perm, two_tailed=True)[source]#

Perform permutation test with one-sample distribution.

Parameters:
  • x (array_like) – First distribution

  • y (int or float) – Baseline against which to check for statistical significane

  • n_perm (int) – Number of permutations

  • two_tailed (bool, default: True) – Set to False if you would like to perform a one-sampled permutation test, else True

  • two_tailed – Set to False if you would like to perform a one-tailed permutation test, else True

Returns:

  • float – Estimated difference of distribution from baseline

  • float – P-value of permutation test

analysis.stats.permutation_numba_twosample(x, y, n_perm, two_tailed=True)[source]#

Perform permutation test.

Parameters:
  • x (array_like) – First distribution

  • y (array_like) – Second distribution

  • n_perm (int) – Number of permutations

  • two_tailed (bool, default: True) – Set to False if you would like to perform a one-sampled permutation test, else True

  • two_tailed – Set to False if you would like to perform a one-tailed permutation test, else True

Returns:

  • float – Estimated difference of distribution means

  • float – P-value of permutation test