neuromaps.stats.compare_images

neuromaps.stats.compare_images(src, trg, metric='pearsonr', ignore_zero=True, nulls=None, nan_policy='omit', return_nulls=False)[source]

Compare images src and trg.

If src and trg represent data from multiple hemispheres the data are concatenated across hemispheres prior to comparison

Parameters:
  • src (tuple or str or os.PathLike or img_like or array-like) – Images (nib.Nifti1Image or nib.GiftiImage) or parcellated data to be compared.

  • trg (tuple or str or os.PathLike or img_like or array-like) – Images (nib.Nifti1Image or nib.GiftiImage) or parcellated data to be compared.

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

  • ignore_zero (bool, optional) – Whether to perform comparisons ignoring all zero values in src and trg data. Default: True

  • nulls (array_like, optional) – Null data for src to use in generating a non-parametric p-value. If not specified a parametric p-value is generated. Default: None

  • nan_policy ({'propagate', 'raise', 'omit'}, optional) – Defines how to handle when input contains nan. ‘propagate’ propagates the nan values to the callable metric (will return nan if the metric is spearmanr or pearsonr), ‘raise’ throws an error, ‘omit’ performs the calculations ignoring nan values. Default: ‘omit’

  • return_nulls (bool, optional) – Whether to return the null distribution of comparisons. Can only be set to True if nulls is not None. Default: False

Returns:

  • similarity (float) – Comparison metric between src and trg

  • pvalue (float) – The p-value of similarity, if nulls is not None

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