예제 #1
0
def test_detect_peaks(test_input, expected):
    df = get_data(test_input)
    fs = calc_fs(df)
    rolling_mean = calc_rolling_mean(df, 0.25, fs)
    num_peaks = len(detect_peaks(df, 60, rolling_mean))
    minimum, maximum = expected
    print("fs is {}".format(fs))
    print("num of peaks is {}".format(num_peaks))
    assert (minimum <= num_peaks <= maximum)
예제 #2
0
def test_calc_rolling_mean(test_input, expected):
    df = get_data(test_input)
    hrw = 1
    fs = 2
    rolling_mean = calc_rolling_mean(df, hrw, fs)
    print("rolling_mean is :{}".format(rolling_mean))
    is_close = np.std(np.array(rolling_mean) - np.array(expected))
    print("isClose is :{}".format(is_close))
    assert (is_close <= 0.001)
예제 #3
0
def test_calc_rrsd(test_input, expected):
    df = get_data(test_input)
    fs = calc_fs(df)
    rolling_mean = calc_rolling_mean(df, 0.25, fs)
    peaks = detect_peaks(df, 100, rolling_mean)
    rr_list = calc_rr(df, peaks)
    rrsd = calc_rrsd(rr_list)
    minimum, maximum = expected
    print("rrsd is {}".format(rrsd))
    assert (minimum <= rrsd <= maximum)
예제 #4
0
def test_calc_rr(test_input, expected):
    df = get_data(test_input)
    fs = calc_fs(df)
    rolling_mean = calc_rolling_mean(df, 0.25, fs)
    peaks = detect_peaks(df, 100, rolling_mean)
    rr_list = calc_rr(df, peaks)
    minimum, maximum = expected
    rr_list_invalid = list(
        filter(lambda rr: rr <= minimum or rr >= maximum, rr_list))
    print("num of peaks is {}".format(len(peaks)))
    print("num of rr_invalid is {}".format(len(rr_list_invalid)))
    assert (len(rr_list_invalid) <= 5)
예제 #5
0
def get_mean_hr_bpm(test_input, expected):
    raw_input = input('Enter your input:')
    input_duration = float(raw_input)
    df = get_data(test_input)
    duration = get_duration(df)
    fs = calc_fs(df)
    rolling_mean = calc_rolling_mean(df, 0.25, fs)
    peaks = detect_peaks(df, 100, rolling_mean)
    rr_list = calc_rr(df, peaks)
    bpm = calc_bpm(rr_list)
    mean_hr_bpm = get_mean_hr_bpm(duration, bpm, input_duration)
    minimum, maximum = expected
    print("mean_hr_bpm is {}".format(mean_hr_bpm))
    assert (minimum <= mean_hr_bpm <= maximum)