mne_features.feature_extraction.FeatureExtractor

class mne_features.feature_extraction.FeatureExtractor(sfreq=256.0, selected_funcs=None, params=None, n_jobs=1, memory=None)

Feature extraction from epoched EEG data.

The method fit_transform implemented in this class can be used to extract univariate or bivariate features from epoched data (see example below). The method fit does not have any effect and is implemented for compatibility with Scikit-learn’s API. As a result, the class FeatureExtractor can be used as a step in a Pipeline (see Pipeline and MNE-features examples). The class also accepts a memory parameter which allows for caching the result of feature extraction. Therefore, if caching is used, calling fit_transform twice on the same data will not trigger a second call to extract_features().

Parameters
sfreqfloat (default: 256.)

Sampling rate of the data.

selected_funcslist of str or tuples

The elements of selected_features are either strings or tuples of the form (str, callable). If an element is of type str, it is the alias of a feature function. The aliases are built from the feature functions’ names by removing compute_. For instance, the alias of the feature function compute_ptp_amp() is ptp_amp. (See the documentation of mne-features). If an element is of type tuple, the first element of the tuple should be a string (name/alias given to a user-defined feature function) and the second element should be a callable (a user-defined feature function which accepts Numpy arrays with shape (n_channels, n_times)). The names/aliases given to user-defined feature functions should not intersect the aliases used by mne-features. If the name given to a user-defined feature function is already used as an alias in mne-features, an error will be raised.

paramsdict or None (default: None)

If not None, dict of optional parameters to be passed to extract_features(). Each key of the funcs_params dict should be of the form: [alias_feature_function]__[optional_param] (for example: higuchi_fd__kmax).

n_jobsint (default: 1)

Number of CPU cores used when parallelizing the feature extraction. If given a value of -1, all cores are used.

memorystr or None (default: None)

If None, no caching is performed. If a string is given, the string should be the path to the caching directory. Caching is particularly advantageous when feature extraction is time consuming.

Examples

>>> import numpy as np
>>> rng = np.random.RandomState(42)
>>> n_epochs, n_channels, n_times = 5, 3, 32
>>> X = rng.randn(n_epochs, n_channels, n_times)
>>> fe = FeatureExtractor(sfreq=100., selected_funcs=['std', 'kurtosis'])
>>> X = fe.fit_transform(X)
>>> print(X.shape)
(5, 6)
__init__(sfreq=256.0, selected_funcs=None, params=None, n_jobs=1, memory=None)

Instantiate a FeatureExtractor object.

Methods

__init__([sfreq, selected_funcs, params, …])

Instantiate a FeatureExtractor object.

fit(X[, y])

Do not have any effect.

fit_transform(X[, y])

Fit to data, then transform it.

get_params([deep])

Get the parameters of the transformer.

set_params(**params)

Set the parameters of the transformer.

transform(X)

Extract features from the array X.

Fork me on GitHub