Annotation editing: deletion and undo

Hi everyone,

I just updated mne on my laptop and was surprised by the amazing new function for editing annotations, which will save quite much time for reading a new recording file each time :smiley: Thanks a lot!

During trying this function I found that, if there are two annotations overlapping together, esp. one completely covered by the other, e.g. an artefact within a trial in the example figure below (which I think happens frequently) and I want to delete this artefact annotation, clicking the highlighted area of the artefact will delete both annotations. Is it possible to choose, which one to delete? That would be really great!

The other question would be, whether it is possible to add a option of undo. That would be really an useful function.

  • MNE-Python version: 0.23.dev0
  • operating system: windows 10, 64bit

I suppose codes won’t be necessary for this situation, since a similar case can be reproduced by any recording using raw.plot() and then creating two annotations with one completely covering the other :wink:

in fact it is more serious than this: if you use the new “show/hide” capability in the annotations window to hide the “task” annotations, and then right-click on your “artifact” label, it will still remove the “task” label even though it’s hidden. I’ll work on a bugfix for this.

As for adding an “undo” function… I’m not opposed but it would be a considerable amount of work to implement it.

1 Like

@datalw a fix is in place at FIX: only delete visible annotation spans by drammock · Pull Request #8831 · mne-tools/mne-python · GitHub

Once that PR is merged, if you want to delete only your “artifact” annotation you can just hide the “task” annotations temporarily, and right-click the one to delete, then un-hide the “task” annotations. If you have a chance, please test out the fix before the PR is merged and let us know if it works for you.

Thanks a lot for the fix! I would like to test it. How I should install the fixed version before it is merged? I tried pip install git+git://github.com/drammock/mne-python/tree/fix-annotation-removal.git, it didn’t work. Sorry for the question, git is still quite fresh to me.
The “undo” function was only a suggestion coming to my mind, I am already very happy that we can edit annotations directly in the plots :smiley:

You can do it by pointing pip to the zip archive of that branch, which GitHub automatically provides:

pip install -U https://github.com/drammock/mne-python/archive/fix-annotation-removal.zip
2 Likes

Thanks for reply, I installed in this way successfully!