neuromaps.stats.permtest_metric

neuromaps.stats.permtest_metric(a, b, metric='pearsonr', n_perm=1000, seed=0, nulls=None, nan_policy='propagate', return_nulls=False)[source]

Generate non-parameteric p-value of a and b for metric.

Calculates two-tailed p-value for hypothesis of whether samples a and b are related using permutation tests

Parameters:
  • a ((N,) array_like) – Sample observations. These arrays must have the same length

  • b ((N,) array_like) – Sample observations. These arrays must have the same length

  • metric ({'pearsonr', 'spearmanr', callable}, optional) – Type of similarity metric to use to compare a and b. If a callable function is provided it must accept two inputs and return a single value (the similarity metric). Default: ‘pearsonr’

  • n_perm (int, optional) – Number of permutations to assess. Unless a and b are very small this will approximate a randomization test via Monte Carlo simulations. Default: 1000

  • seed ({int, np.random.RandomState instance, None}, optional) – Seed for random number generation. Set to None for pseudo-randomness. Default: 0

  • nulls ((N, P) array_like, optional) – Null array used in place of shuffled a array to compute null distribution of correlations. Array must have the same length as a and b. Providing this will override the value supplied to n_perm. When not specified a standard permutation is used to shuffle a. Default: None

  • nan_policy ({'propagate', 'raise', 'omit'}, optional) – Defines how to handle when inputs contain nan. ‘propagate’ returns nan, ‘raise’ throws an error, ‘omit’ performs the calculations ignoring nan values. Default: ‘propagate’

  • return_nulls (bool, optional) – Whether to return the null distribution of comparisons. Default: False

Returns:

  • similarity (float) – Similarity metric

  • pvalue (float) – Non-parametric p-value

  • nulls ((n_perm, ) array_like) – Null distribution of similarity metrics. Only returned if return_nulls is True.

Notes

The lowest p-value that can be returned by this function is equal to 1 / (n_perm + 1).