()
return x, sfreq
Create a fake example for a dataset
Create a fake example for a dataset
Create a fake example for a dataset
def create_example_dataset():
    """Create a fake example for a dataset"""
    sfreq = 256
    t_recording = 150
    t_trial = 1  # duration of a trial
    intertrial = 2  # time between end of a trial and the next one
    n_chan = 8

    x = np.zeros((n_chan + 1, t_recording * sfreq))  # electrodes + stimulus
    stim = np.zeros(t_recording * sfreq)
    t_offset = 1.0  # offset where the trials start
    n_trials = 40

    rep = np.linspace(0, 4 * t_trial, t_trial * sfreq)
    signal = np.sin(2 * np.pi / t_trial * rep)
    for n in range(n_trials):
        label = n % 2 + 1  # alternate between class 0 and class 1
        tn = int(t_offset * sfreq + n * (t_trial + intertrial) * sfreq)
        stim[tn] = label
        noise = 0.1 * np.random.randn(n_chan, len(signal))
        x[:-1, tn : (tn + t_trial * sfreq)] = label * signal + noise
    x[-1, :] = stim
    return x, sfreq
def create_example_dataset ( ) : sfreq = 256 t_recording = 150 t_trial = 1 # duration of a trial intertrial = 2 # time between end of a trial and the next one n_chan = 8 x = np . zeros ( ( n_chan + 1 , t_recording * sfreq ) ) # electrodes + stimulus stim = np . zeros ( t_recording * sfreq ) t_offset = 1.0 # offset where the trials start n_trials = 40 rep = np . linspace ( 0 , 4 * t_trial , t_trial * sfreq ) signal = np . sin ( 2 * np . pi / t_trial * rep ) for n in range ( n_trials ) : label = n % 2 + 1 # alternate between class 0 and class 1 tn = int ( t_offset * sfreq + n * ( t_trial + intertrial ) * sfreq ) stim [ tn ] = label noise = 0.1 * np . random . randn ( n_chan , len ( signal ) ) x [ : - 1 , tn : ( tn + t_trial * sfreq ) ] = label * signal + noise x [ - 1 , : ] = stim return x , sfreq