Skip to content
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

Set frequency bands value while extracting features #56

Open
talhaanwarch opened this issue Jun 16, 2020 · 5 comments
Open

Set frequency bands value while extracting features #56

talhaanwarch opened this issue Jun 16, 2020 · 5 comments

Comments

@talhaanwarch
Copy link

talhaanwarch commented Jun 16, 2020

I am trying to extract frequency band features using following way

feature=['energy_freq_bands','pow_freq_bands','line_length', 'kurtosis', 'ptp_amp', 'skewness']
fe = FeatureExtractor(sfreq=128, selected_funcs=feature)
X_new=fe.fit_transform(X)

It throwing me following error
'The entries of the given freq_bands parameter (%s) must be positive and less than the Nyquist 'frequency.' % str(freq_bands).

So how can I remove the 100Hz frequency value limit from ['energy_freq_bands','pow_freq_bands'] while extracting features.
I mean how can I just set freq_bands=np.array([0.5, 4., 8., 13.,30.]) without changing much things

@talhaanwarch
Copy link
Author

One way is to do it following way using user-defined features

from mne_features.univariate   import compute_pow_freq_bands
def pow_freq(x):
  return compute_pow_freq_bands(128,x,freq_bands=np.array([0.5, 4., 8., 13.,30.]))
def energy_freq(x):
  return compute_energy_freq_bands(128,x,freq_bands=np.array([0.5, 4., 8., 13.,30.]))

selected_funcs = [('powfreq', pow_freq),('energyfreq',energy_freq),'line_length', 'kurtosis', 'ptp_amp', 'skewness']

But energyfreq is giving a strange warning and setting accuracy to NaN. Whereas powfreq is working correctly.

Issue with energyfreq is as follow

Cross-validation accuracy score = nan (+/- nan)
/usr/local/lib/python3.6/dist-packages/sklearn/model_selection/_split.py:296: FutureWarning: Setting a random_state has no effect since shuffle is False. This will raise an error in 0.24. You should leave random_state to its default (None), or set shuffle=True.
  FutureWarning
/usr/local/lib/python3.6/dist-packages/sklearn/model_selection/_validation.py:536: FitFailedWarning: Estimator fit failed. The score on this train-test partition for these parameters will be set to nan. Details: 
ValueError: Data to be filtered must be real floating, got int64

  FitFailedWarning)
/usr/local/lib/python3.6/dist-packages/sklearn/model_selection/_validation.py:536: FitFailedWarning: Estimator fit failed. The score on this train-test partition for these parameters will be set to nan. Details: 
ValueError: Data to be filtered must be real floating, got int64

  FitFailedWarning)

Please check this colab file for reproducing the problem

@agramfort
Copy link
Member

agramfort commented Jun 16, 2020 via email

@talhaanwarch
Copy link
Author

Thanks. In both cases, the data type is int64, but in the case of pow_freq it worked and in another case energy_freq it did not. But changing data type to float it worked

@talhaanwarch
Copy link
Author

i figured out this is the issue with compute_energy_freq_bands that required data in float64 data type. Converting data to float64 will increase the computational time and space.

@agramfort
Copy link
Member

agramfort commented Jun 17, 2020 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants