brainets / frites

Framework for Information Theoretical analysis of Electrophysiological data and Statistics
https://brainets.github.io/frites/
BSD 3-Clause "New" or "Revised" License
79 stars 20 forks source link

KeyError: 'y' when using wf.fit() #15

Closed zhengliuer closed 3 years ago

zhengliuer commented 3 years ago

Here is the code:

import numpy as np

from mne import EpochsArray, create_info
from frites.dataset import DatasetEphy

import matplotlib.pyplot as plt
n_subjects = 5
n_epochs = 10
n_channels = 5
n_times = 100
sf = 512

x, ch = [], []
for k in range(n_subjects):
    # generate single subject data
    x_suj = np.random.rand(n_epochs, n_channels, n_times)
    # generate some random channel names
    ch_suj = np.array([f"ch_{r}" for r in range(n_channels)])
    # concatenate in a list
    x.append(x_suj)
    ch.append(ch_suj)
# finally lets create a time vector
times = np.arange(n_times) / sf

x_mne = []
for k in range(n_subjects):
    # create some informations
    info = create_info(ch[k].tolist(), sf)
    # create the Epoch of this subject
    epoch = EpochsArray(x[k], info, tmin=times[0], verbose=False)
    # finally, replace it in the original list
    x_mne.append(epoch)

dt = DatasetEphy(x_mne)

mi_type = 'cc'

# define the workflow
wf = WfMi(mi_type=mi_type)
# compute the mutual information
mi, _ = wf.fit(dt, mcp=None, n_jobs=1)

Using the development version of Frites