Plotting event-related dynamics for specific frequency bands

Hi!

I’m run some experiments with a Biosemi ActiveTwo with 64 channels. Now I’m following this tutorial for plotting the activity of each specific frequency band of a specific channel (Fpz)

My problem is that when make the plot, the scale in the y-axis seems wrong. The curves of each frequency band seems too little, like if the y scale was too big. One thing that calls my attention is that at beggining and the end of each plot (-500 and 3000ms), I see a rise in the curves. Maybe there’s something wrong with the baseline? Maybe the first and the last time point is not scaled?

I tried changing the x-axis limits but it doesn’t help. I also thought of changing the y axis scale by hand. But I’m sure there must be a more straight forward way of solving it. Or maybe I’m missing something.

Here’s the plot

Here’s the plot zoomed in the beggining of the epoch

And here is the code:

import matplotlib.pyplot as plt
from mne.stats import bootstrap_confidence_interval
from mne.baseline import rescale

# Helper function for plotting spread
def stat_fun(x):
    """Return sum of squares."""
    return np.sum(x**2, axis=0)


# Plot
fig, axes = plt.subplots(5, 1, figsize=(10, 7), sharex=True, sharey=True)
colors = plt.colormaps["winter_r"](np.linspace(0, 1, 5))
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=(-500, 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_confidence_interval(
        average.data, random_state=0, stat_fun=stat_fun
    )
    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(-500, 3000)
    #ax.set_ylim(1e-8*-0.1, 1e-8*0.5)

axes.ravel()[-1].set_xlabel("Time [ms]")

fig

Thanks!

I think it would be good to confirm that the raw EEG signals are correctly scaled and look like valid EEG (e.g. no large artifacts etc.). A PSD would also be helpful to make sure that your t/f analysis is based on decent EEG.