debug merge calc-rdm
@@ -9,7 +9,7 @@ import numpy as np
from pyrsa.rdm.rdms import RDMs
from pyrsa.data.dataset import Dataset
from pyrsa.data import average_dataset_by
-from pyrsa.util.indicator import allpairs
+from pyrsa.util.matrix import pairwise_contrast
def calc_rdm(dataset, method='euclidean', descriptor=None, noise=None):
@@ -59,7 +59,7 @@ def calc_rdm_euclid(dataset, descriptor=None):
RDMs object with the one RDM
"""
measurements, desc, descriptor = _parse_input(dataset, descriptor)
- c_matrix = allpairs(np.arange(measurements.shape[0]))
+ c_matrix = pairwise_contrast(np.arange(measurements.shape[0]))
diff = np.matmul(c_matrix, measurements)
rdm = np.einsum('ij,ij->i', diff, diff) / measurements.shape[1]
rdm = RDMs(dissimilarities=np.array([rdm]),
@@ -113,7 +113,7 @@ def calc_rdm_mahalanobis(dataset, descriptor=None, noise=None):
"""
measurements, desc, descriptor = _parse_input(dataset, descriptor)
noise = _check_noise(noise, dataset.n_channel)
- c_matrix = allpairs(np.arange(measurements.shape[0]))
+ c_matrix = pairwise_contrast(np.arange(measurements.shape[0]))
diff = np.matmul(c_matrix, measurements)
diff2 = np.matmul(noise, diff.T).T
rdm = np.einsum('ij,ij->i', diff, diff2) / measurements.shape[1]
@@ -183,7 +183,7 @@ def calc_rdm_crossnobis(dataset,
def _calc_rdm_crossnobis_single(measurements1, measurements2, noise):
- c_matrix = allpairs(np.arange(measurements1.shape[0]))
+ c_matrix = pairwise_contrast(np.arange(measurements1.shape[0]))
diff_1 = np.matmul(c_matrix, measurements1)
diff_2 = np.matmul(c_matrix, measurements2)
diff_2 = np.matmul(noise, diff_2.transpose())
