mne_rsa.rdm_array#
- class mne_rsa.rdm_array(X, patches=None, dist_metric='correlation', dist_params={}, y=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
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 toNone
.- 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).
- Yields:
- rdmndarray, shape (n_patches, n_items * (n_items - 1))
A RDM (in condensed form) for each searchlight patch.
See also
rdm
rsa
searchlight
- Attributes:
- shapetuple of int
Multidimensional shape of the generted 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.
- __hash__(/)#
Return hash(self).