diff --git a/heartpy/heartpy.py b/heartpy/heartpy.py index 7979f3c..053a719 100644 --- a/heartpy/heartpy.py +++ b/heartpy/heartpy.py @@ -276,11 +276,6 @@ def process(hrdata, sample_rate, windowsize=0.75, report_time=False, hrdata = enhance_peaks(hrdata) hrdata = hampel_correcter(hrdata, sample_rate) - # check that the data has positive baseline for the moving average algorithm to work - bl_val = np.percentile(hrdata, 0.1) - if bl_val < 0: - hrdata = hrdata + abs(bl_val) - working_data['hr'] = hrdata working_data['sample_rate'] = sample_rate diff --git a/heartpy/peakdetection.py b/heartpy/peakdetection.py index 518b21d..7e4f05d 100644 --- a/heartpy/peakdetection.py +++ b/heartpy/peakdetection.py @@ -179,7 +179,7 @@ def detect_peaks(hrdata, rol_mean, ma_perc, sample_rate, update_dict=True, worki rmean = np.array(rol_mean) #rol_mean = rmean + ((rmean / 100) * ma_perc) - mn = np.mean(rmean / 100) * ma_perc + mn = np.std(hrdata)*4*ma_perc/100 rol_mean = rmean + mn peaksx = np.where((hrdata > rol_mean))[0] @@ -263,10 +263,10 @@ def fit_peaks(hrdata, rol_mean, sample_rate, bpmmin=40, bpmmax=180, working_data Now the wd dict contains the best fit paramater(s): >>> wd['best'] - 20 + 25 This indicates the best fit can be obtained by raising the moving average - with 20%. + with 25% of the standard deviation of the signal. The results of the peak detection using these parameters are included too. To illustrate, these are the first five detected peaks: @@ -281,7 +281,7 @@ def fit_peaks(hrdata, rol_mean, sample_rate, bpmmin=40, bpmmax=180, working_data ''' # moving average values to test - ma_perc_list = [5, 10, 15, 20, 25, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 150, 200, 300] + ma_perc_list = [-50, -40, -30, -25, -20, -15, -10, -5, 0, 5, 10, 15, 20, 25, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 150, 200, 300] rrsd = [] valid_ma = []