mne_features.feature_extraction
.FeatureExtractor¶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()
.
Sampling rate of the data.
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.
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
).
Number of CPU cores used when parallelizing the feature extraction. If given a value of -1, all cores are used.
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.
See also
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)
Instantiate a FeatureExtractor object.
Methods
|
Instantiate a FeatureExtractor object. |
|
Do not have any effect. |
|
Fit to data, then transform it. |
|
Get the parameters of the transformer. |
|
Set the parameters of the transformer. |
|
Extract features from the array X. |