mne-tools / mne-features

MNE-Features software for extracting features from multivariate time series
https://mne-tools.github.io/mne-features/
BSD 3-Clause "New" or "Revised" License
142 stars 32 forks source link

Improving feature names 2 #60

Closed paulroujansky closed 4 years ago

paulroujansky commented 4 years ago

Description

In the light of the changes made in PR https://github.com/mne-tools/mne-features/pull/42 related to having more meaningful feature names when extract_features is called with return_df = True, I extended the mechanism to every univariate functions, as most of them didn't implement a get_feature_names method.

In order to do so, I added a very basic _compute_generic_feat_names function that returns a list [ch0, ch1, ...] (given input channel dim). In addition to that, I added specific feature naming functions to the following metrics:

As a consequence, the columns of the resulting dataframe are a bit more intelligible. In addition to that, I added the possibility to pass the list of channel names when calling extract_features in order to translate these directly in the columns.

Example:

from mne_features.feature_extraction import extract_features
import numpy as np

data = np.random.random((5, 2, 500))

extract_features(data,
                 sfreq=250,
                 selected_funcs=['app_entropy', 'hurst_exp'],
                 ch_names=['PO3', 'PO4'],
                 return_as_df=True)

outputs

I added some tests to check these new functionnalities.

agramfort commented 4 years ago

looks clean to me. Can you please update https://github.com/mne-tools/mne-features/blob/master/doc/whats_new.rst with your name and a note on the contribution?

very glad to see this package useful to some !

agramfort commented 4 years ago

thx a lot @paulroujansky !