mne_rsa.compute_rdm_cv#

mne_rsa.compute_rdm_cv(folds, metric='correlation', **kwargs)[source]#

Compute a dissimilarity matrix (RDM) using cross-validation.

The distance computation is performed from the average of all-but-one “training” folds to the remaining “test” fold. This is repeated with each fold acting as the “test” fold once. The resulting distances are averaged and the result used in the final RDM.

Parameters:
foldsndarray, shape (n_folds, n_items, …)

For each item, all the features. The first dimension are the folds used for cross-validation, items are along the second dimension, and all other dimensions will be flattened and treated as features.

metricstr | function

The distance metric to use to compute the RDM. Can be any metric supported by scipy.spatial.distance.pdist(). When a function is specified, it needs to take in two vectors and output a single number. See also the dist_params parameter to specify and additional parameter for the distance function. Defaults to ‘correlation’.

**kwargsdict, optional

Extra arguments for the distance metric. Refer to scipy.spatial.distance for a list of all other metrics and their arguments.

Returns:
rdmndarray, shape (n_classes * n_classes-1,)

The cross-validated RDM, in condensed form. See scipy.spatial.distance.squareform().

See also

compute_rdm