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)
Here is the code:
Using the development version of Frites