mne.viz.plot_epochs_image(epochs['imag/face'], picks=channel_ind) # plot 95% CI : # - plt.plot() diff_evoked.plot(axes=ax[0,0]) diff_evoked.plot() diff=np.sum(diff_evoked.data ** 2, axis=0) diff = mne.baseline.rescale(diff, times, baseline=(None, 0)) ax[0,0].set_title('%s' %subject) times= diff_evoked.times * 1e3 ci_low, ci_up = _bootstrap_ci(diff_evoked.data, random_state=0, stat_fun=median) ci_low = mne.baseline.rescale(ci_low, diff_evoked.times, baseline=(None, 0)) ci_up = mne.baseline.rescale(ci_up, diff_evoked.times, baseline=(None, 0)) ax[0,0].fill_between(times, diff + ci_up, diff - ci_low, color='red', alpha=0.3) # plot stim face menus stim house #mne.combine_evoked([stim_face,-stim_house], weights= 'equal').plot_joint(title='%s ERP diff Stim Face minus Stim House'%subject ) #plot imag face menus imag house #mne.combine_evoked([imag_face,-imag_house], weights= 'equal').plot_joint(title='%s ERP diff Imag Face minus Imag House'%subject)
info=epochs.info, tmin=epochs.tmin) # now average and move on frequency_map.append(((band, fmin, fmax), epochs.average())) fig, axes = plt.subplots(4, 1, figsize=(10, 7), sharex=True, sharey=True) colors = plt.get_cmap('winter_r')(np.linspace(0, 1, 4)) for ((freq_name, fmin, fmax), average), color, ax in zip(frequency_map, colors, axes.ravel()[::-1]): times = average.times * 1e3 gfp = np.sum(average.data**2, axis=0) gfp = mne.baseline.rescale(gfp, times, baseline=(None, 0)) ax.plot(times, gfp, label=freq_name, color=color, linewidth=2.5) ax.axhline(0, linestyle='--', color='grey', linewidth=2) ci_low, ci_up = _bootstrap_ci(average.data, random_state=0, stat_fun=lambda x: np.sum(x**2, axis=0)) ci_low = rescale(ci_low, average.times, baseline=(None, 0)) ci_up = rescale(ci_up, average.times, baseline=(None, 0)) ax.fill_between(times, gfp + ci_up, gfp - ci_low, color=color, alpha=0.3) ax.grid(True) ax.set_ylabel('GFP') ax.annotate('%s (%d-%dHz)' % (freq_name, fmin, fmax), xy=(0.95, 0.8), horizontalalignment='right', xycoords='axes fraction') ax.set_xlim(-1000, 3000) axes.ravel()[-1].set_xlabel('Time [ms]')
############################################################################### # Now we can compute the Global Field Power # We can track the emergence of spatial patterns compared to baseline # for each frequency band, with a bootstrapped confidence interval. # # We see dominant responses in the Alpha and Beta bands. fig, axes = plt.subplots(4, 1, figsize=(10, 7), sharex=True, sharey=True) colors = plt.get_cmap('winter_r')(np.linspace(0, 1, 4)) for ((freq_name, fmin, fmax), average), color, ax in zip( frequency_map, colors, axes.ravel()[::-1]): times = average.times * 1e3 gfp = np.sum(average.data ** 2, axis=0) gfp = mne.baseline.rescale(gfp, times, baseline=(None, 0)) ax.plot(times, gfp, label=freq_name, color=color, linewidth=2.5) ax.axhline(0, linestyle='--', color='grey', linewidth=2) ci_low, ci_up = _bootstrap_ci(average.data, random_state=0, statfun=lambda x: np.sum(x ** 2, axis=0)) ci_low = rescale(ci_low, average.times, baseline=(None, 0)) ci_up = rescale(ci_up, average.times, baseline=(None, 0)) ax.fill_between(times, gfp + ci_up, gfp - ci_low, color=color, alpha=0.3) ax.grid(True) ax.set_ylabel('GFP') ax.annotate('%s (%d-%dHz)' % (freq_name, fmin, fmax), xy=(0.95, 0.8), horizontalalignment='right', xycoords='axes fraction') ax.set_xlim(-1000, 3000) axes.ravel()[-1].set_xlabel('Time [ms]')