How to plot EpochsTFR images?

  • MNE-Python version: 0.22.0
  • operating system: win10
    I want to plot the time-frequency diagram of each trail of EpochsTFR, but I don’t want to use the plt.contourf method, because the image obtained is a bit redundant, as shown below:
    AverageTFR provides the plot method, and the time-frequency graph obtained is as follows, which is very beautiful, so I was thinking, can EpochTFR also provide the plot function?

There is no plot method for EpochsTFR, but if you want something similar to what we do in AverageTFR.plot, you could try matplotlib.pyplot.imshow (there’s also matplotlib.axes.Axes.imshow if you prefer this API).

Another way is to select the epoch you want to visualise, then average (which does not change the data, but the object is now AverageTFR and has the .plot() method) and use the .plot() method:


This seems to indicate that we should have a respective plotting function for EpochsTFR…

1 Like

I would make EpochsTFR.plot() raise an error and tell the user to select the epochs via indexing, average and plot :smile:
I must say I like the index, average and plot way - it is explicit. Especially if one is selecting multiple trials - a condition for example. But I agree that for plotting single trials, the .average() step is counter-intuitive.
One rather simple way to avoid the .average() for single epochs would be to return AverageTFR when indexing selects a single epoch. It would not be very elegant though. :slight_smile:

But we don’t do that for Epochs either so IMHO that’s inconsistent

@richard Yes, I wasn’t fully serious. :slight_smile: However, I’m not sure what should be the default - plotting a tfr for every epoch would not make sense if one does tfr_epochs.plot(). Maybe something reasonably good would be to show the first epoch by default and allow navigating through the tfr epochs interactively (so something similar to what epochs.plot() does).

1 Like