Annotations per channels

I have a detection method which is applied for each channel of an EEG data separately. I have a list of annotations for each channel. I couldn’t find any approach that can help me plot these annotation per channel while I can visualize the whole channels.
Is it possible with mne at all?
Should I tweak the source code for this feature?
Please help me I really need this feature.

No, MNE currently does not support annotations for individual channels. As a workaround, you could consider including the channel name in the description.

Thanks, but that would make the figure too cluttered. I have found out that the figures are instances of MNEBrowseFigure, and one way to do it is to modify this function as well as the annotations property of the RAW object to hold and accept list of annotation objects as well. Would it work do you think?

Yes, I’m pretty sure that something like that would work, but it probably requires a decent amount of changes especially in the figure plotting code path. Also, we currently don’t have any plans to integrate such a feature, so your changes would probably be not useful upstream (but that hopefully doesn’t matter). Maybe @drammock can comment as well?

One approach that would work immediately is to do what @cbrnr suggests (include channel name in the annotation description) and make use of the recent enhancement that you can show/hide each annotation type individually (see here) to get around the issue of the figure being too cluttered. This feature was added in v0.22 but there were a couple recent bugfixes to it, so if you’re relying on it for your analysis I would recommend using the current development version of MNE-Python for now, until the next release.

Another approach that would require smaller changes to MNE-Python is to alter the MNEBrowseFigure class so that, when drawing annotations, it checks to see if the annotation description contains a channel name, and if it does, only draws the annotation over that channel. Although easier to implement, this may be somewhat misleading, because (for example) an annotation like bad impedence on Cz would, when plotted, only appear on channel Cz, but during data processing it would count as a “bad” annotation for all channels the purposes of epoch rejection, etc, even if channel Cz had been dropped already.

To fully implement per-channel annotation would require something like adding a channel field to our Annotations objects. This would require a lot of code changes in other parts of MNE-Python, not just the plotting functions; for example, any channel picking/dropping would require checking and possibly modifying the annotations.

Thanks a lot. I think the second solution (modifying the events’ description) would be much easier to approach and for the BAD problem these channel dependent properties could be added at the end of the description comma separated.

See also Event markers per channel · Issue #5507 · mne-tools/mne-python · GitHub where this has been discussed previously and is being discussed again on GitHub

Thanks, Actually I managed to add the channel wise annotations by augmenting the description with the channel name. However, once the number of detected events exceeds a certain value, the figure scrolling may freeze. I hope that your PR will resolve this issue as well.

Dear developers,
I am using the following system:

  • MNE-Python version: 0.22.0
  • operating system: Windows 10

I have checked the new per channel annotation feature that is added to the newer version of the library. However, what I need is to highlight the channel area not the whole eeg data. I have managed to get around that but once the number of annotations becomes too large then the eeg data viewing is a problem.
The problem is in the _draw_annotations function of the viz/ which takes a long time to be executed.
Is there anything I can do to speed it up? Like making it parallel.
Please let me know of the best direction to follow in order to make the EEG plots with the annotation something more practical.

Thanks a lot