mne_rsa.rdm_array#
- class mne_rsa.rdm_array(X, patches=None, dist_metric='correlation', dist_params={}, y=None, labels=None, n_folds=1, n_jobs=1)[source]#
Generate RDMs 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 RDMs 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
. IfNone
, no searchlight is used. Defaults toNone
.- dist_metricstr | function
The distance metric to use to compute the RDMs. 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 thedist_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 RDMs. 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
Deprecated, use
labels
instead. For each item, a number indicating the class to which the item belongs. Defaults toNone
, in which caselabels
is used.- labelslist | None
For each element in
X
(=the first dimension), a label that identifies the item to which it corresponds. Multiple elements inX
may correspond to the same item, in which case they should have the same label and will either be averaged when computing the data RDM (n_folds=1
) or used for cross-validation (n_folds>1
). Labels may be of any python type that can be compared with==
(int, float, string, tuple, etc). By default (None
), the integers0:len(X)
are used as labels.Added in version 0.10.
- 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. SpecifyNone
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).
- Attributes:
- shapetuple of int
Multidimensional shape of the generated RDMs.
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 RDM.
- For a spatial searchlight:
Two element: the number of time-series and length of a condensed RDM.
- For a temporal searchlight:
Two elements: the number of time-samples and length of a condensed RDM.
- For no searchlight:
One element: the length of a condensed RDM.
- Yields:
- rdmndarray, shape (n_patches, n_items * (n_items - 1))
A RDM (in condensed form) for each searchlight patch.
See also
rdm
rsa
searchlight
- __hash__(/)#
Return hash(self).