Mne.vis.plot_epochs() shifts bad epochs selection

  • MNE-Python version: 0.22.0
  • operating system: Ubuntu 20.04.1

Dear all,

I face the problem when using mne.vis.plot_epochs() function.

For our analysis, I manually view all the epochs of each subject to select bad epochs (the mne.vis.plot_epochs() function allows to do this by clicking on these epochs; they are highlighted with the red and are excluded from further analysis).

I have used this method previously and never had a problem until updating MNE to 0.22.0 version. Two other things that I have changed as compared with the previous script which works good:

  1. I now use matplotlib.use(ā€˜Qt5Aggā€™), as with ā€˜TkAggā€™ [shift + ->] keys donā€™t work for some reason (while [->] key still works)
  2. Additionally, we included in our analysis annotate_muscle_zscore() function for raw data

Actually, I donā€™t fully understand why this happens, but - after scrolling all the epochs of one subject (with [shift + ->]), when I return to bad red epochs to make sure that I selected them right, in some subjects (not in all!) I observe that ā€œbadā€ epochs selection (red) is shifted by one to the right. Notably, not all the red epochs are usually shifted, this typically this happens only with the several last epochs.
In the final ā€˜cleanā€™ epochs data I indeed observe that in some subjects there are bad epochs in the last part of recording, like if I did not dropped themā€¦

Unfortunately, by now I cannot replicate this error and donā€™t understand why this happens. In one subject I returned to the same place (epoch) three times, reselected bad epoch, but when I returned to this place again - red selection was shiftedā€¦ I have repeated this action (reselection - change place - return to epoch - reselection) three times, during which selection constantly shifted by 1 epoch in the same manner. But next, selection did not shift in that place anymore. So I really canā€™t understand what is the reasonā€¦

If someone has an idea what is the cause of this error I would be very grateful to hear any suggestions.

hey @okapi Thanks for this (potential) bug report. Sorry for replying so late. If you solved the problem in the meantime, please post the solution as a reply and mark it as the ā€œsolutionā€ to this thread.

Now to your question: You say yourself:

Unfortunately, by now I cannot replicate this error and donā€™t understand why this happens.

To be able to properly help with solving a bug itā€™s crucial to get a MWE in the form of code that replicates the error. Please provide one! Or if this thread is now obsolete, please provide one next time!

This may have been fixed by Fix scrolling behavior in epochs.plot() by drammock Ā· Pull Request #9459 Ā· mne-tools/mne-python Ā· GitHub. @okapi are you able to test using the current development version of MNE-Python, to see if it works now with your data?