Esempio n. 1
0
for band, fmin, fmax in iter_freqs:
    # (re)load the data to save memory
    raw = mne.io.read_raw_fif(raw_fname, preload=True)
    raw.pick_types(meg='grad', eog=True)  # we just look at gradiometers

    # bandpass filter and compute Hilbert
    raw.filter(fmin, fmax, n_jobs=1,  # use more jobs to speed up.
               l_trans_bandwidth=1,  # make sure filter params are the same
               h_trans_bandwidth=1,  # in each band and skip "auto" option.
               fir_design='firwin')
    raw.apply_hilbert(n_jobs=1, envelope=False)

    epochs = mne.Epochs(raw, events, event_id, tmin, tmax, baseline=baseline,
                        reject=dict(grad=4000e-13, eog=350e-6), preload=True)
    # remove evoked response and get analytic signal (envelope)
    epochs.subtract_evoked()  # for this we need to construct new epochs.
    epochs = mne.EpochsArray(
        data=np.abs(epochs.get_data()), info=epochs.info, tmin=epochs.tmin)
    # now average and move on
    frequency_map.append(((band, fmin, fmax), epochs))

beta_data = frequency_map[2][1]
beta_sim = sd.make_sim_data(beta_data, order=17)
alpha_data = frequency_map[1][1]
alpha_sim = sd.make_sim_data(alpha_data, order=17)
theta_data = frequency_map[0][1]
theta_sim = sd.make_sim_data(theta_data, order=17)
gamma_data = frequency_map[3][1]
gamma_sim = sd.make_sim_data(theta_data, order=17)

beta_sim.average().plot_joint()