Hello MNE community,
I am in the process of doing some ERD/ERS analysis. After preprocessing steps, I compute time/frequency ERD/ERS maps using tfr_multitaper()
. and can plot the maps with no issues. Following the instructions given here, I plot the corrected maps. However, for all events, the maps look exactly the same. I was wondering if you could help me with this issue. Below is a part of my code for ERDS computation and visualization. Thanks.
events, _ = mne.events_from_annotations(raw)
events = events[np.in1d(events[:, 2], (10002, 10004, 10006)), :]
tmin, tmax = -1, 3
epochs = mne.Epochs(raw, events, dict(down=10002, left=10004, right=10006), tmin, tmax,
picks=("C3", "Cz", "C4"), baseline=None, preload=True)
freqs = np.arange(1, 31)
baseline = -1.5, -0.5
cnorm = TwoSlopeNorm(vmin=-1, vcenter=0, vmax=1.5) # min, center, and max ERDS
vmin, vmax = -0.5, 1.5
kwargs = dict(n_permutations=100, step_down_p=0.05, seed=1,
buffer_size=None, out_type='mask') # for cluster test
cmap = center_cmap(plt.get_cmap("RdBu"), vmin, vmax)
for event in epochs.event_id: # for each condition
tfr = tfr_multitaper(epochs, freqs=freqs, n_cycles=freqs, use_fft=True,
return_itc=False, average=False, decim=2)
tfr.crop(-0.5, 2.5).apply_baseline(baseline, mode="percent")
tfr_ev = tfr
fig, axes = plt.subplots(1, 3, figsize=(15, 5))
for ch, ax in enumerate(axes):
# positive clusters
_, c1, p1, _ = pcluster_test(tfr_ev.data[:, ch], tail=1, **kwargs)
print(p1)
# negative clusters
_, c2, p2, _ = pcluster_test(tfr_ev.data[:, ch], tail=-1, **kwargs)
print(p2)
# note that we keep clusters with p <= 0.05 from the combined clusters
# of two independent tests; in this example, we do not correct for
# these two comparisons
c = np.stack(c1 + c2, axis=2) # combined clusters
p = np.concatenate((p1, p2)) # combined p-values
mask = c[..., p <= 0.05].any(axis=-1)
# plot TFR (ERDS map with masking)
tfr_ev.average().plot([ch], cmap="RdBu", axes=ax,
colorbar=False, show=False, mask=mask,
mask_style="mask")
ax.set_title(epochs.info["ch_names"][ch])
plt.show()