AttributeError when using extract_features from mne_features: 'FeatureUnion' object has no attribute 'get_feature_names

I am trying to use the extract_features function from the mne_features package to extract some features from EEG data. However, I am getting the following error when I try to run my code:

feature_names = extractor.get_feature_names()

AttributeError: ‘FeatureUnion’ object has no attribute ‘get_feature_names’

The relevant code is also accessible via

Here is the code that I am using:

import mne
import numpy as np
from mne_features.feature_extraction import extract_features

epochs = mne.read_epochs('P_zeroed-epo.fif', preload=True) # the fif file is accessible via the link at the bottom of this post
epochs = epochs.pick_types(eeg=True)
freq_bands = np.array([1.2, 4., 8.0, 13.0, 30.0, 47.0])
ls_feature = ['skewness', 'kurtosis', 'samp_entropy']
funcs_params = dict(pow_freq_bands__psd_method='fft',pow_freq_bands__freq_bands=freq_bands)

feature_s = extract_features(epochs.get_data(), epochs.info['sfreq'],
                             selected_funcs=ls_feature, return_as_df=True,
                             ch_names=epochs.ch_names, n_jobs=1)

I have tried to look up the error message, but I haven’t been able to find a solution that works for me. Can anyone help me figure out what is causing this error and how to fix it?

Thank you in advance for your help.

link to the fif file

Spec:
Windows 11
mne: 1.3.0
mne_features: 0.2.1
sklearn: 1.2.1

The package should work fine fine scikit-learn 1.0.2 albeit with the following deprecation warning

FutureWarning: Function get_feature_names is deprecated; get_feature_names is deprecated in 1.0 and will be removed in 1.2. Please use get_feature_names_out instead.
warnings.warn(msg, category=FutureWarning)

1 Like

see https://github.com/mne-tools/mne-features/pull/88

Alex

1 Like