mne-qt-browser
mne-qt-browser copied to clipboard
Annotations Mode: Add Channels to annotations
Hi,
It would be nice if we could add/remove the list of channels that apply to each annotation. I've started playing around with it and it seems a QPushButton
would need to be added and then an instance of QDialog
appears with QTreeWidget
embedded that lists channels. Then the channels would be added/removed by accessing fig.mne.inst.annotations
where fig
is the instance of the browser. I'm new to Qt but I may be able to assist with this. Let me know your thoughts on this.
can you do a mockup of how it would look like? it's a bit abstract for me.
@agramfort , this is what my scratch work done by working around the source code and not changing anything internally. First, call the browser, get the annotations dock and add a button
mne.viz.set_browser_backend("pyqtgraph")
fig = raw.plot(duration=10.0,n_channels=15,use_opengl=True,remove_dc=True,block=False,show=False)
# Get annotation dock
dock = fig.children()[3]
layout = dock.children()[4].children()[0]
# Add button
ch_bt = QPushButton('Channels')
ch_bt.clicked.connect(lambda: print('Surprise!'))
layout.addWidget(ch_bt)
From above snippet, the annotations dock looks like this (button appended to the far right).
Then, instead of printing "Surprise!", clicking the "Channels" button would open a dialogue. I didn't make a mock-up of the dialogue so this is just a picture of fieldtrip's channel dialogue from ft_databrowser
.
Essentially, you would just select which channels apply to the currently selected annotation. Does this make sense?
The field trip UI makes sense
Would you see also a way to do this selection with mouse clicks on the traces ?
That would be ideal. I just don't want to overwrite any existing events. One thought is to add a Shift+Left-Click event when selecting a channel name that is evaluated before the typical Left-click function when in annotation mode. The Shift+Left-Click can toggle a channel being part of the annotation. Channels within the annotation selected can be marked with an asterisk "*" next to their name. There's probably a few ways to do this. I don't want to break/interfere what's already in place
Hello, I was following your discussion, thank you for your new feature suggestion @sportnoah14 .
I just wanted to note that if I am not mistaken there is currently no container in raw.annotations
where information about a sub-selection of channels for each annotation is stored. So I think we would need to add something to mne
too.
When we apply a change like this we could simultaneously also add a container for custom annotation color which was another suggested feature.
@marsipu you're able to store a list of channels in annotations. Check here. For example, you can create an Annotations
object like this:
from mne import Annotations
annot = Annotations(onset=[0, 3, 10], duration=[1, 0.25, 0.5],
description=['Start', 'BAD_flux', 'BAD_noise'],
ch_names=[[], ['MEG0111', 'MEG2563'], ['MEG1443']])
raw.set_annotations(annot)
From what I can tell (though I could be wrong) is that after you set the Annotations
object and the call raw_plot()
using the qt browser, the Annotations
object is stored at fig.mne.inst.annotations
where fig
is the instance of the browser. This is what I assume from digging anyway.
Oh I didn' t see that, thank you. So for channel-specific annotations the visualization would need to be updated too with annotation-segments only spanning behind the selected channels, right?
So for channel-specific annotations the visualization would need to be updated too with annotation-segments only spanning behind the selected channels, right?
yes
Message ID: @.***>
Oh I didn' t see that, thank you. So for channel-specific annotations the visualization would need to be updated too with annotation-segments only spanning behind the selected channels, right?
I was actually thinking just indicating which channels are part of the annotation by having an asterisk next to the channel name when in annotation mode. Whichever is easier though
Nice, I like the asterix-solution. While I think it is doable to show multple AnnotationRegion-instances per annotation based on which channels are selected, this would probably cost quite some scrolling-performance when checking for subsegmented annotations and adding/removing multiple regions accordingly.
Nice, I like the asterix-solution. While I think it is doable to show multple AnnotationRegion-instances per annotation based on which channels are selected, this would probably cost quite some scrolling-performance when checking for subsegmented annotations and adding/removing multiple regions accordingly.
I don't understand all of this but I'm assuming it's something that can occur while loading traces and can slow down the process. I don't think any additional conditionals need to be added. I think everything can be kept as is. Only the channels that apply to the annotation will update by having an asterisk (or some indication) next to their label. My guess is that this shouldn't cost any more computational resources than updating a channel's color if it's bad.
this would probably cost quite some scrolling-performance when checking for subsegmented annotations and adding/removing multiple regions accordingly.
I think what @agramfort suggests is the best solution. So I think we should try it and see how much performance loss we see. If it is really bad, then we can think about how to make it better. (For example, maybe it ends up being a single "image" which spans the channel-epoch x-y space using with nearest-neighbor interpolation, most "pixels" of which are fully transparent, and we fill in the pixels/channel-epoch tiles with colors as necessary. We can do this sort of thing, but let's see if having hundreds of rectangles added/removed on the fly is indeed too painful.)
Closing in favor of https://github.com/mne-tools/mne-qt-browser/issues/123 where I think we're sorting out an interface for this