Visual annotation question

External Email - Use Caution

Hello,

I'm constructing a script that combines MNE and Tkinter to allow clinicians
to compute various connectivity measures. My files are EDF and not FIF.

I'd like to provide the means for updating raw data when certain intervals
are annotated. By that I mean if I perform raw.plot(), select "a", and
highlight intervals as in the illustration below, I'd like for the raw data
to be updated to exclude the highlighted intervals when the window is
closed. In the picture, the new raw file would be the old one with the
time intervals 100 to 200 and 400 to 500 seconds removed.

Is this possible?

Thanks

Paul F.

[image: image.png]
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.nmr.mgh.harvard.edu/pipermail/mne_analysis/attachments/20200714/ba986ecb/attachment-0001.html
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image.png
Type: image/png
Size: 2645219 bytes
Desc: not available
Url : http://mail.nmr.mgh.harvard.edu/pipermail/mne_analysis/attachments/20200714/ba986ecb/attachment-0001.png

External Email - Use Caution

Hi!

When you close the window, the annotated intervals are stored in raw.annotations. If annotation descriptions start with "bad", they are ignored by most MNE functions (see https://mne.tools/stable/auto_tutorials/raw/plot_30_annotate_raw.html#how-annotations-affect-preprocessing-and-analysis and https://mne.tools/stable/auto_tutorials/preprocessing/plot_20_rejecting_bad_data.html#id1).

Therefore, if you are going to use MNE for further processing, it might not be necessary to remove these intervals from the raw data (but make sure their names start with "bad").

If you really need to remove these intervals from the raw object, I'm not aware of any built-in method to achieve that. There's raw.crop(), but this more or less does the inverse operation and only works with one interval. Epochs do have epochs.drop_bad(), but raw.drop_bad() doesn't exist, but it might be a useful addition.

Feel free to open an issue at https://github.com/mne-tools/mne-python/issues to discuss this feature.

Clemens