Skip to content

Commit

Permalink
try another fix #555
Browse files Browse the repository at this point in the history
  • Loading branch information
DominiqueMakowski committed Jun 1, 2022
1 parent d1db305 commit 59fce35
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions neurokit2/ecg/ecg_findpeaks.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,13 @@
import scipy.signal
import scipy.stats

from ..signal import (signal_findpeaks, signal_plot, signal_sanitize,
signal_smooth, signal_zerocrossings)
from ..signal import (
signal_findpeaks,
signal_plot,
signal_sanitize,
signal_smooth,
signal_zerocrossings,
)


def ecg_findpeaks(ecg_cleaned, sampling_rate=1000, method="neurokit", show=False, **kwargs):
Expand Down Expand Up @@ -985,7 +990,7 @@ def _ecg_findpeaks_rodrigues(signal, sampling_rate=1000, **kwargs):
a = [1]
processed_ecg = scipy.signal.lfilter(b, a, squar)
tf = len(processed_ecg)
rpeakpos = None
rpeakpos = 0
# R-peak finder FSM
while i < tf: # ignore last sample of recording
# State 1: looking for maximum
Expand All @@ -999,8 +1004,7 @@ def _ecg_findpeaks_rodrigues(signal, sampling_rate=1000, **kwargs):
i += 1

Ramptotal = (19 / 20) * Ramptotal + (1 / 20) * Rpeakamp
if rpeakpos is not None:
rpeaks.append(rpeakpos)
rpeaks.append(rpeakpos)

# State 2: waiting state
d = tf1 - rpeakpos
Expand Down

0 comments on commit 59fce35

Please sign in to comment.