Comments (5)
... and then we have to figure out how to disallow changing channel removal/addition when the annotation is off-screen time-wise. I think the simple solution is that a channel can be added/removed from the selected annotation only if some part of the the selected annotation is in the visible time span.
from mne-qt-browser.
And could we also add that the selected annotation can be changed into a channel-wise annotation and/or additional channels can be added to the currently selected channel-wise annotation by clicking on the channel trace?
Thus disabling entirely the bad/not bad interaction when in annotation mode.
from mne-qt-browser.
Updated!
from mne-qt-browser.
Here's some code that could be useful. It works by interacting with the ChannelAxis (the y-axis listing channel names) and doing shift+left-click to toggle the channel being part of the active annotation. It adds to the already existing mouseClickEvent
for it. Basically, if in annotation mode, it gets the name of the channel pressed, gets the annotation index currently active, and then adds/removes that channel to the list of channels associated with that annotation. The added function for this is in the "####" section. I think pieces of it can be used for this next step.
def mouseClickEvent(self, event):
"""Customize mouse click events for ChannelAxis"""
# Clean up channel-texts
if not self.mne.butterfly:
self.ch_texts = {k: v for k, v in self.ch_texts.items()
if k in [tr.ch_name for tr in self.mne.traces]}
# Get channel-name from position of channel-description
ypos = event.scenePos().y()
y_values = np.asarray(list(self.ch_texts.values()))[:, 1, :]
y_diff = np.abs(y_values - ypos)
ch_idx = int(np.argmin(y_diff, axis=0)[0])
ch_name = list(self.ch_texts)[ch_idx]
trace = [tr for tr in self.mne.traces
if tr.ch_name == ch_name][0]
########################################################
# If shift+left-click in annotation mode then add to the annotation
if event.button() == Qt.LeftButton and bool(Qt.ShiftModifier) and self.mne.annotation_mode:
# Find what the currently active annotation is: self.mne.current_description
# Access the instance of the annotation
current_annotation_idx = [annot_ii for annot_ii in range(len(self.mne.inst.annotations))
if self.mne.inst.annotations[annot_ii]['description'] == self.mne.current_description][0]
ch_list_in_annot = list(self.mne.inst.annotations.ch_names[current_annotation_idx])
if ch_name not in ch_list_in_annot:
self.mne.inst.annotations.ch_names[current_annotation_idx] = tuple( ch_list_in_annot + [ch_name] )
else:
# Remove ch_name from annotation
ch_list_in_annot.pop(ch_list_in_annot.index(ch_name))
self.mne.inst.annotations.ch_names[current_annotation_idx] = tuple(ch_list_in_annot)
########################################################
elif event.button() == Qt.LeftButton:
trace.toggle_bad()
elif event.button() == Qt.RightButton:
self.weakmain()._create_ch_context_fig(trace.range_idx)
from mne-qt-browser.
Thx @nmarkowitz !
I probably won't have time this month to get to this so feel free to start a PR if you beat me to it.
current_annotation_idx = [annot_ii for annot_ii in range(len(self.mne.inst.annotations))
if self.mne.inst.annotations[annot_ii]['description'] == self.mne.current_description][0]
FYI I don't think this will work. If there is more than 1 annotation with the same description, this will always return the index of the first annotation that matches the description. I think we'll need a more robust way to find the current annotation. (EDIT) I can probably make a suggestion but I'd need to dig into the code a bit 😄
from mne-qt-browser.
Related Issues (20)
- Benchmark data not available
- Possibility to remove mne-qt-browser splash screen HOT 4
- Plot window is blank and freezes (not responding) when launched in PyCharm's Python console or debugger HOT 6
- BUG: Use of deprecated function HOT 1
- Index bug when annotating segments in data browser HOT 5
- Changing color/thickness of vline appearing on signal plot? HOT 2
- _overview_radio_clicked() takes 1 positional argument but 2 positional arguments were given HOT 3
- channel selection does not work in raw.plot HOT 2
- Scrolling (and general) performance with large number of annotations HOT 12
- mne not recognising mne-qt-browser version for epochs instance HOT 4
- Filter, scrolling, whitening are not playing nicely together HOT 1
- [ENH] Make it possible to toggle visibility of bad channels, especially in butterfly mode HOT 7
- MAINT: Use black
- Update projectors when bad channels are selected/unselected HOT 1
- Q: Release? HOT 4
- Annotation labels should not (or not only) appear in the center of the annotation HOT 4
- MNT: Add issue-forms with YAML instead of Markdown-templates HOT 5
- Crashes on macOS HOT 12
- MNE-Qt-Browser hijacks app icon HOT 9
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from mne-qt-browser.