Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

interactive annotations on graph #114

Open
noelbk opened this issue Mar 29, 2023 · 9 comments
Open

interactive annotations on graph #114

noelbk opened this issue Mar 29, 2023 · 9 comments

Comments

@noelbk
Copy link

noelbk commented Mar 29, 2023

Hi and thanks for visbrain! We're using it to mark events on our long sleep signals: 6 channels, 70 sps, about 8 hours durarion. We'd like to visually mark regions and validate them from different sources like human experts or algorithms.

I'd like to be able to mark and drag annotations on the signal graph. I'm looking at adding this feature myself, and just wanted to check if anyone else is interested in it, or has already implemented something. Any suggestions?

@TomBugnon
Copy link
Collaborator

Hi Noel, maybe check out our fork?
https://github.com/TomBugnon/visbrain/

It implements a click-and-drag style scoring window. This is hypnogram, not annotations as you requested, but maybe close enough.
Best

@noelbk
Copy link
Author

noelbk commented Mar 29, 2023

Thanks @TomBugnon! I'll check it out right now.

@TomBugnon
Copy link
Collaborator

btw, I don't think it's specified, but I think you need to use python 3.9 and not 3.10

@noelbk
Copy link
Author

noelbk commented Mar 29, 2023

Thanks @TomBugnon. I'm using Python 3.8 with your develop branch at 31b14b6. Have I got the configuration right? What do I click and drag on here? I tried clicking and dragging on all the graph panels. My data's a little weird, not in uV, fs=72... I'll dig into the code to see if I can find the click event
.

Sleep(data=data, sf=72, channels=channels, hypno=None).show()

image

@TomBugnon
Copy link
Collaborator

TomBugnon commented Mar 29, 2023

It works for us on the develop branch at github/TomBugnon/visbrain...

If you debug you can check if you enter this block when clicking and dragging on the signal, and hit this function with the correct value for xlim_scor.

The red vertical bars should be redrawn when you click and drag

@noelbk
Copy link
Author

noelbk commented Mar 29, 2023

Found the problem. Wrong version installed in my venv. 🤦‍♂️ click and drag works. Now I'll work on:

  • [] colour annotation backgrounds
  • [] make annotation regions edges editable (drag to adjust)

Thanks!

@mitometa
Copy link

mitometa commented Apr 5, 2023

bug: Start (seconds) and End (seconds) in Annotations tab show the same value (the end position?).

line 1341 in visuals.py: self._fcn_annotate_add('', (cursor, cursor), title)

@TomBugnon thank you for this drag-click version, very handy to use. how to fix this bug?

@mitometa
Copy link

mitometa commented Apr 9, 2023

solved the annotation problem for mouse release:

edit on_mouse_release(event) in visuals.py:

'
nano +1435 /Path_to/visbrain/gui/sleep/visuals/visuals.py
'

Quit mouse-scoring mode if no window was drawn/we clicked

Add annotation for the dragged window

'

        self._mouse_pressed = False
        mouse_xlim = self._mouse_scorwin_xlim
        min_xdrag = 0.05
        # without drag
        if (
            None in mouse_xlim
            or abs(mouse_xlim[1] - mouse_xlim[0]) <= min_xdrag  # noqa
        ):
            self._mousescoring_active = False
        # with drag
        if (
            self._mousescoring_active == True
        ):
            is_sp_hyp = canvas.title in ['Hypnogram', 'Spectrogram']
            title = canvas.title if is_sp_hyp else canvas.title.split('_')[1]
            self._fcn_annotate_add('', (mouse_xlim[0], mouse_xlim[1]), title)
        self._update_scorwin_indicator()
        self._video.set_video_time(self._xlim_scor[0])

'

@TomBugnon
Copy link
Collaborator

Hi @noelbk can you keep me posted regarding the features you're adding? Not sure I understand what they mean but they could be useful for us as well

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants