rsatoolbox.rdm.calc_unbalanced module

Calculation of RDMs from unbalanced datasets, i.e. datasets with different channels or numbers of measurements per dissimilarity

@author: heiko

rsatoolbox.rdm.calc_unbalanced.calc_one_similarity(data_i: DatasetBase, data_j: DatasetBase, cv_desc_i: NDArray, cv_desc_j: NDArray, method='euclidean', noise=None, weighting='number', prior_lambda=1, prior_weight=0.1) Tuple[NDArray, NDArray][source]

finds all pairs of vectors to be compared and calculates one distance

Parameters:
  • data_i (rsatoolbox.data.DatasetBase) – dataset for condition i

  • data_j (rsatoolbox.data.DatasetBase) – dataset for condition j

  • cv_desc_i (numpy.ndarray) – crossvalidation descriptor for condition i

  • cv_desc_j (numpy.ndarray) – crossvalidation descriptor for condition j

  • method (string) – which dissimilarity to compute

  • noise – numpy.ndarray (n_channels x n_channels), optional the covariance or precision matrix over channels necessary for calculation of mahalanobis distances

Returns:

(value, weight)

value is the dissimilarity weight is the weight of the samples

Return type:

(np.ndarray, np.ndarray)

rsatoolbox.rdm.calc_unbalanced.calc_rdm_unbalanced(dataset: SingleOrMultiDataset, method='euclidean', descriptor=None, noise=None, cv_descriptor=None, prior_lambda=1, prior_weight=0.1, weighting='number', enforce_same=False) RDMs[source]

calculate a RDM from an input dataset for unbalanced datasets.

Parameters:
  • dataset (rsatoolbox.data.dataset.DatasetBase) – The dataset the RDM is computed from

  • method (String) – a description of the dissimilarity measure (e.g. ‘Euclidean’)

  • descriptor (String) – obs_descriptor used to define the rows/columns of the RDM

  • noise (numpy.ndarray) – dataset.n_channel x dataset.n_channel precision matrix used to calculate the RDM used only for Mahalanobis and Crossnobis estimators defaults to an identity matrix, i.e. euclidean distance

Returns:

RDMs object with the one RDM

Return type:

rsatoolbox.rdm.rdms.RDMs

rsatoolbox.rdm.calc_unbalanced.ensure_double(a: NDArray) NDArray[np.float64][source]

If required, will convert the array datatype to Float64

This ensures compatibility with the underlying c type “double”. If the array is already compatible, it will pass through. If it is an integer, a converted copy will be made.

Parameters:

a (NDArray) – Numeric numpy array

Returns:

The float64 version of the array

Return type:

NDArray[np.float64]