rsatoolbox.rdm.compare module

Comparison methods for comparing two RDMs objects

rsatoolbox.rdm.compare.compare(rdm1, rdm2, method='cosine', sigma_k=None)[source]

calculates the similarity between two RDMs objects using a chosen method

Parameters:
  • rdm1 (rsatoolbox.rdm.RDMs) – first set of RDMs

  • rdm2 (rsatoolbox.rdm.RDMs) – second set of RDMs

  • method (string) –

    which method to use, options are:

    ’cosine’ = cosine similarity

    ’spearman’ = spearman rank correlation

    ’corr’ = pearson correlation

    ’kendall’ = kendall-tau b

    ’tau-a’ = kendall-tau a

    ’rho-a’ = spearman correlation without tie correction

    ’corr_cov’ = pearson correlation after whitening

    ’cosine_cov’ = unbiased distance correlation which is equivalent to the cosine dinstance after whitening

    ’neg_riem_dist’ = negative riemannian distance

  • sigma_k (numpy.ndarray) – covariance matrix of the pattern estimates. Used only for methods ‘corr_cov’ and ‘cosine_cov’.

Returns:

dist:

pariwise similarities between the RDMs from the RDMs objects

Return type:

numpy.ndarray

rsatoolbox.rdm.compare.compare_correlation(rdm1, rdm2)[source]

calculates the correlations between two RDMs objects

Parameters:
  • rdm1 (rsatoolbox.rdm.RDMs) – first set of RDMs

  • rdm2 (rsatoolbox.rdm.RDMs) – second set of RDMs

Returns:

dist:

correlations between the two RDMs

Return type:

numpy.ndarray

rsatoolbox.rdm.compare.compare_correlation_cov_weighted(rdm1, rdm2, sigma_k=None)[source]

calculates the correlations between two RDMs objects after whitening with the covariance of the entries

Parameters:
  • rdm1 (rsatoolbox.rdm.RDMs) – first set of RDMs

  • rdm2 (rsatoolbox.rdm.RDMs) – second set of RDMs

Returns:

dist:

correlations between the two RDMs

Return type:

numpy.ndarray

rsatoolbox.rdm.compare.compare_cosine(rdm1, rdm2)[source]

calculates the cosine similarities between two RDMs objects

Parameters:
  • rdm1 (rsatoolbox.rdm.RDMs) – first set of RDMs

  • rdm2 (rsatoolbox.rdm.RDMs) – second set of RDMs

Returns:

dist

cosine similarity between the two RDMs

Return type:

numpy.ndarray

rsatoolbox.rdm.compare.compare_cosine_cov_weighted(rdm1, rdm2, sigma_k=None)[source]

calculates the cosine similarities between two RDMs objects

Parameters:
  • rdm1 (rsatoolbox.rdm.RDMs) – first set of RDMs

  • rdm2 (rsatoolbox.rdm.RDMs) – second set of RDMs

Returns:

dist:

cosine similarities between the two RDMs

Return type:

numpy.ndarray

rsatoolbox.rdm.compare.compare_kendall_tau(rdm1, rdm2)[source]

calculates the Kendall-tau bs between two RDMs objects. Kendall-tau b is the version, which corrects for ties. We here use the implementation from scipy.

Parameters:
  • rdm1 (rsatoolbox.rdm.RDMs) – first set of RDMs

  • rdm2 (rsatoolbox.rdm.RDMs) – second set of RDMs

Returns:

dist:

kendall-tau correlation between the two RDMs

Return type:

numpy.ndarray

rsatoolbox.rdm.compare.compare_kendall_tau_a(rdm1, rdm2)[source]

calculates the Kendall-tau a based distance between two RDMs objects. adequate when some models predict ties

Parameters:
  • rdm1 (rsatoolbox.rdm.RDMs) – first set of RDMs

  • rdm2 (rsatoolbox.rdm.RDMs) – second set of RDMs

Returns:

dist:

kendall-tau a between the two RDMs

Return type:

numpy.ndarray

rsatoolbox.rdm.compare.compare_neg_riemannian_distance(rdm1, rdm2, sigma_k=None)[source]

calculates the negative Riemannian distance between two RDMs objects.

Parameters:
  • rdm1 (rsatoolbox.rdm.RDMs) – first set of RDMs

  • rdm2 (rsatoolbox.rdm.RDMs) – second set of RDMs

Returns:

dist:

negative Riemannian distance between the two RDMs

Return type:

numpy.ndarray

rsatoolbox.rdm.compare.compare_rho_a(rdm1, rdm2)[source]

calculates the spearman rank correlations between two RDMs objects without tie correction

Parameters:
  • rdm1 (rsatoolbox.rdm.RDMs) – first set of RDMs

  • rdm2 (rsatoolbox.rdm.RDMs) – second set of RDMs

Returns:

dist:

rank correlations between the two RDMs

Return type:

numpy.ndarray

rsatoolbox.rdm.compare.compare_spearman(rdm1, rdm2)[source]

calculates the spearman rank correlations between two RDMs objects

Parameters:
  • rdm1 (rsatoolbox.rdm.RDMs) – first set of RDMs

  • rdm2 (rsatoolbox.rdm.RDMs) – second set of RDMs

Returns:

dist:

rank correlations between the two RDMs

Return type:

numpy.ndarray