Coder Social home page Coder Social logo

Comments (5)

larsoner avatar larsoner commented on July 19, 2024 1

... 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.

mscheltienne avatar mscheltienne commented on July 19, 2024 1

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.

scott-huberty avatar scott-huberty commented on July 19, 2024

Updated!

from mne-qt-browser.

nmarkowitz avatar nmarkowitz commented on July 19, 2024

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.

scott-huberty avatar scott-huberty commented on July 19, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.