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

Add Custom Event Names and Improve Event Display for Cropped Signals in events_plot() #1029

Open
AntiiRain opened this issue Sep 12, 2024 · 1 comment

Comments

@AntiiRain
Copy link

Hello all!!

Describe the solution you'd like

Currently, the events_plot() function does not allow for the modification of event legends in the plotted graph. It only uses numeric labels (n) to indicate different events. When multiple events are present in a graph, this makes it difficult for others to clearly identify which vertical line corresponds to which event.
image

I propose adding an events_name parameter to the events_plot() function, which would allow for a list of event names to be passed in, corresponding to each event. This would improve clarity in visualizations. For example:

def events_plot(events, signal=None, color="red", linestyle="--", events_name=None):

How could we do it?

  • Introduce a new parameter, events_name, to accept a list of event names.
  • In the plotting loop, add the functionality to display each event name above the corresponding vertical line, which would make it clear what each event represents.
  • This solution has been tested locally, and I am ready to submit a pull request for this enhancement.
    image

Additional Context / Related Issues

  1. Event display inconsistency with signal cropping:
    Another issue I’ve noticed is when a portion of the signal is selected for display, the plot still shows all the events, even if they fall outside the cropped signal. This behavior seems counterintuitive, and manually adjusting the number of events to fit the cropped signal is cumbersome.
    For instance:
plot = nk.events_plot(rpeaks['ECG_R_Peaks'], ecg_signal[:6000])

image

  1. Proposed Solution:
    I am currently working on modifying the events_plot() function so that only events within the selected signal range are displayed. However, I am unsure if this change might impact certain use cases. Do you think this modification makes sense? Should I directly change the event display logic or introduce an additional parameter to allow users to opt in to this automatic event cropping?

Next Steps

I am happy to create a pull request with the first proposed change (i.e., adding events_name). For the second issue, I am open to feedback on the best course of action and whether the change should be made directly or made configurable with a new parameter.

Copy link

welcome bot commented Sep 12, 2024

Hi 👋 Thanks for reaching out and opening your first issue here! We'll try to come back to you as soon as possible. ❤️ kenobi

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

1 participant