Skip to content
Open
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions neurokit2/ecg/ecg_delineate.py
Original file line number Diff line number Diff line change
Expand Up @@ -763,7 +763,7 @@ def _calc_prominence(peaks, sig, Rpeak=None, minima=False):
_sig = -sig if minima else sig
w[peaks] = scipy.signal.peak_prominences(_sig, peaks)[0]
# optional: set rpeak prominence to zero to emphasize other peaks
if Rpeak is not None:
if Rpeak is not None and Rpeak < len(w):
Comment thread
Viri1990 marked this conversation as resolved.
Outdated
w[Rpeak] = 0
return w

Expand All @@ -772,7 +772,8 @@ def _prominence_find_q_wave(weight_minima, current_wave, max_r_rise_time):
if "ECG_R_Peaks" not in current_wave:
return
q_bound = max(current_wave["ECG_R_Peaks"] - max_r_rise_time, 0)

if len(weight_minima[q_bound : current_wave["ECG_R_Peaks"]]) == 0:
return
current_wave["ECG_Q_Peaks"] = np.argmax(weight_minima[q_bound : current_wave["ECG_R_Peaks"]]) + q_bound


Expand All @@ -781,6 +782,8 @@ def _prominence_find_s_wave(sig, weight_minima, current_wave, max_qrs_interval):
return
s_bound = current_wave["ECG_Q_Peaks"] + max_qrs_interval
s_wave = np.argmax(weight_minima[current_wave["ECG_R_Peaks"] : s_bound] > 0) + current_wave["ECG_R_Peaks"]
if len(weight_minima[current_wave["ECG_R_Peaks"] : s_bound] > 0) == 0:
return
Comment thread
Viri1990 marked this conversation as resolved.
Outdated
current_wave["ECG_S_Peaks"] = (
np.argmin(sig[current_wave["ECG_R_Peaks"] : s_bound]) + current_wave["ECG_R_Peaks"]
if s_wave == current_wave["ECG_R_Peaks"]
Expand Down
Loading