# Setup data for epochs and cross validation X = np.vstack([data_cls, data_pln]) y = np.concatenate([np.zeros(len(data_cls)), np.ones(len(data_pln))]) cv = StratifiedKFold(n_splits=10, shuffle=True) # Create epochs to use for classification n_trial, n_chan, n_time = X.shape events = np.vstack((range(n_trial), np.zeros(n_trial, int), y.astype(int))).T chan_names = ['MEG %i' % chan for chan in range(n_chan)] chan_types = ['mag'] * n_chan sfreq = 250 info = create_info(chan_names, sfreq, chan_types) epochs = EpochsArray(data=X, info=info, events=events, verbose=False) epochs.times = selected_times[:n_time] epochs.crop(-3.8, None) # fit model and score gat = GeneralizationAcrossTime( scorer="accuracy", cv=cv, predict_method="predict") gat.fit(epochs, y=y) gat.score(epochs, y=y) # Save model joblib.dump(gat, data_path + "decode_time_gen/%s_gat_tr.jl" % subject) # make matrix plot and save it fig = gat.plot( cmap="viridis", title="Temporal Gen (Classic vs planning) for transitivity.") fig.savefig(data_path + "decode_time_gen/%s_gat_matrix_tr.png" % subject)