From 215f2fa5df3dd8afe9feec9292eff472735df54a Mon Sep 17 00:00:00 2001 From: Matthieu PERREIRA DA SILVA Date: Mon, 2 Oct 2023 16:58:50 +0200 Subject: [PATCH] Update eda_plot.py Fix a bug where you had an exception if there was not the same number of peaks and onsets. This can happen on signal that has been cut (ex: depending on difference conditions). The fix just ignores the first peak (only for display) when there is no onset for the first peak. --- neurokit2/eda/eda_plot.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/neurokit2/eda/eda_plot.py b/neurokit2/eda/eda_plot.py index d61274e435..5ba0cb642b 100644 --- a/neurokit2/eda/eda_plot.py +++ b/neurokit2/eda/eda_plot.py @@ -62,6 +62,10 @@ def eda_plot(eda_signals, info=None, static=True): onsets = np.where(eda_signals["SCR_Onsets"] == 1)[0] half_recovery = np.where(eda_signals["SCR_Recovery"] == 1)[0] + # clean peaks that do not have onsets + if len(peaks) > len(onsets): + peaks = peaks[1:] + # Determine unit of x-axis. x_label = "Time (seconds)" x_axis = np.linspace(0, len(eda_signals) / info["sampling_rate"], len(eda_signals))