New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improving feature names 2 #60
Conversation
…s + enabling to specify channel names when calling extract_features() + adding tests
8b8aa3d
to
612341f
Compare
mne_features/univariate.py
Outdated
@@ -1097,6 +1160,9 @@ def compute_svd_entropy(data, tau=2, emb=10): | |||
return -np.sum(np.multiply(sv_norm, np.log2(sv_norm)), axis=-1) | |||
|
|||
|
|||
compute_svd_entropy.get_feature_names = _compute_generic_feat_names |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd rather do if not hasattra(function, 'get_feature_names')
then use _compute_generic_feat_names. It avoids having to alter any possible function. Otherwise we need an OO design with a base class... which is a lot more work
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed, yet as all univariate functions do not necessarily return a (n_channels,)
-shaped output (for instance compute_spect_slope
), it could be equally dangerous to use a generic function directly in FeatureFunctionTransformer.fit()
. As I see it, there are two approaches given the current implementation:
- either define a function
_compute_[funcname]_feat_names
for every univariate functions and assign it (compute_[funcname].get_feature_names = _compute_[funcname]_feat_names
), but then it would simpler /clearer to make it OO I guess) - assign a generic list of names in
FeatureFunctionTransformer.transform()
if the function is univariate and that the output channel dim is equal to the one of the input (has to be done in thetransform()
in order to get the shape of the output) <= I implemented this one in ed3ae2c, it's a bit messy though
b6158aa
to
ed3ae2c
Compare
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 ! |
6f2755a
to
2759b5f
Compare
thx a lot @paulroujansky ! |
Description
In the light of the changes made in PR #42 related to having more meaningful feature names when
extract_features
is called withreturn_df = True
, I extended the mechanism to every univariate functions, as most of them didn't implement aget_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:
spect_edge_freq
spect_slope
wavelet_coef_energy
teager_kaiser_energy
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:
outputs
I added some tests to check these new functionnalities.