Skip to content

Commit

Permalink
Update eda_plot.py
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
mperreir committed Oct 2, 2023
1 parent ce33299 commit 215f2fa
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions neurokit2/eda/eda_plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down

0 comments on commit 215f2fa

Please sign in to comment.