mne_rsa.dsm_array

class mne_rsa.dsm_array(X, patches=None, dist_metric='correlation', dist_params={}, y=None, n_folds=1)[source]

Generate DSMs from an array of data, possibly in a searchlight pattern.

First use searchlight to compute the searchlight patches. Then you can use this function to compute DSMs for each searchlight patch.

Parameters:
Xndarray, shape (n_items, n_series, n_times)

An array containing the data.

patchesgenerator of tuples | None

Searchlight patches as generated by searchlight. If None, no searchlight is used. Defaults to None.

dist_metricstr | function

The distance metric to use to compute the DSMs. 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’.

dist_paramsdict

Extra arguments for the distance metric used to compute the DSMs. Refer to scipy.spatial.distance for a list of all other metrics and their arguments. Defaults to an empty dictionary.

yndarray of int, shape (n_items,) | None

For each item, a number indicating the class to which the item belongs. When None, each item is assumed to belong to a different class. Defaults to None.

n_foldsint | sklearn.model_selection.BaseCrollValidator | None

Number of cross-validation folds to use when computing the distance metric. Folds are created based on the y parameter. Specify None to use the maximum number of folds possible, given the data. Alternatively, you can pass a Scikit-Learn cross validator object (e.g. sklearn.model_selection.KFold) to assert fine-grained control over how folds are created. Defaults to 1 (no cross-validation).

Yields:
dsmndarray, shape (n_patches, n_items * (n_items - 1))

A DSM (in condensed form) for each searchlight patch.

See also

dsm
rsa
searchlight
Attributes:
shapetuple of int

Multidimensional shape of the generted DSMs.

This is useful for re-shaping the result obtained after consuming the this generator.

For a spatio-temporal searchlight:

Three elements: the number of time-series, number of time samples and length of a consensed DSM.

For a spatial searchlight:

Two element: the number of time-series and length of a condensed DSM.

For a temporal searchlight:

Two elements: the number of time-samples and length of a condensed DSM.

For no searchlight:

One element: the length of a condensed DSM.

__hash__(/)

Return hash(self).

__len__()[source]

Get total number of DSMs that will be generated.