lina-usc / pylossless

🧠 EEG Processing pipeline that annotates continuous data
https://pylossless.readthedocs.io/en/latest/
MIT License
20 stars 8 forks source link

Feature Request: Improve annotation drawing on timeseries plots. #31

Closed scott-huberty closed 1 year ago

scott-huberty commented 1 year ago

The current method for manually creating annotations on time-series graphs, via shift-clicking, is clunky and non-intuitive.

It appears that there may well be a nicer solution. Check out this notebook I created.

The solution was inspired from this stack overflow answer

and this section of the Dash documentation (EDIT:) which states _Drawing or modifying a shape triggers a relayout event, which can be captured by a callback inside a Dash application._

Other post on the plotly forum, that pointed out the above information, by someone who looks like they have a very similar use-case to us.

scott-huberty commented 1 year ago

UPDATE: I created a Minimally Working example in my Colab notebook of how this would work in a dash app.

FYI Make sure you allow 3rd party cookies in your browser if you want JupyterDash to work in Colab. It took me a while to figure that out....

IMO, a big benefit to using this built-in Plotly functionality to draw shapes, is that deleting shapes is already packaged in the functionality. Simply click on the border of a shape you previously drew to make it active. Then click on the "Erase active shape" in the config mode bar at the top right of the plot.

This (deleting shapes) is something we haven't implemented in our current dash app, and it is something that we definitely need to support..

As we wrap up our current dash app, I am going to continue to probe on a separate dev branch.. I think it's definitely worth exploring...

christian-oreilly commented 1 year ago

I did not look your notebook yet, but the only additional thing that would need to be integrated (if it is not already done) is to connect call back to addition/deletion of these shapes. These callbacks are necessary to update the annotations in the inst accordingly. If there is no problem triggering callbacks on these events, I see no technical issues in deploying that in the QC interface.