How to convert Epoch to ndarray for usage with mne-features

I have list of epochs and would like to calculate the univariate feature using the compute_energy_freq_bands available from the mne-feature module.

However, the function only accept ndarray type as an input.

def compute_energy_freq_bands(sfreq, data, freq_bands=np.array([0.5, 4., 8.,
13., 30.,
100.]),
deriv_filt=True):
β€œβ€"Band energy (per channel).
Parameters
----------
sfreq : float
Sampling rate of the data.
data : ndarray, shape (n_channels, n_times)

To transform from epoch to ndarray representation, one of the approach I can think is by first transforming the epoch into DF using the to_data_frame and subsequentyly converting it into numpy array. Finally, feed the final ndarray as an input into the compute_energy_freq_bands function.

But, Im curious whether there exist more straightforward or build in approach that I am not aware of to achieve similar objective

You can simply use epochs.get_data() to retrieve the data as a NumPy array directly from your epochs.

1 Like

Thanks for the respond, appreciate it