<commit_before>def calc_inst_hr(time, voltage):
    """ calculate instantaneous HR from ECG data input

    :param time: numpy array, seconds
    :param voltage: numpy array, mV
    :return: numpy array, heart rate between beats in bpm
    """
    import numpy as np
    # import scipy.signal
    # import matplotlib.pyplot as plt
    import peakutils

    # get sampling rate
    fs = 1 / (time[1] - time[0])

    rates = np.array([np.size(voltage)/200])  # search width
    # find peaks
    # peaks = scipy.signal.find_peaks_cwt(voltage, fs / rates)

    # base = peakutils.baseline(voltage, 3, 1000)
    # voltage = voltage - base

    kernel = np.ones(np.size(81)) / 200
    base = np.convolve(voltage, kernel, 'same')
    voltage = voltage - base
    peaks = peakutils.indexes(voltage, .73, int(np.size(voltage)/200))

    # avg_val = np.average(voltage)
    # std_dev = np.std(voltage)
    # keep_peaks = np.array([])
    # for index in peaks:
    #     if voltage[index] >= avg_val + 1.2 * std_dev:
    #         keep_peaks = np.append(keep_peaks, index)

    # print(avg_val)
    # print(std_dev)
    # print(len(peaks), len(keep_peaks))
<commit_msg>COrrecting the Inst HR<commit_after>def calc_inst_hr(time, voltage):
    """ calculate instantaneous HR from ECG data input

    :param time: numpy array, seconds
    :param voltage: numpy array, mV
    :return: numpy array, heart rate between beats in bpm
    """
    import numpy as np
    # import scipy.signal
    # import matplotlib.pyplot as plt
    import peakutils

    # get sampling rate
    fs = 1 / (time[1] - time[0])

    rates = np.array([np.size(voltage)/200])  # search width
    # find peaks
    # peaks = scipy.signal.find_peaks_cwt(voltage, fs / rates)

    # base = peakutils.baseline(voltage, 3, 1000)
    # voltage = voltage - base

    kernel = np.ones(np.size(voltage)) / 200
    base = np.convolve(voltage, kernel, 'same')
    voltage = voltage - base
    peaks = peakutils.indexes(voltage, .73, int(np.size(voltage)/200))

    # avg_val = np.average(voltage)
    # std_dev = np.std(voltage)
    # keep_peaks = np.array([])
    # for index in peaks:
    #     if voltage[index] >= avg_val + 1.2 * std_dev:
    #         keep_peaks = np.append(keep_peaks, index)

    # print(avg_val)
    # print(std_dev)
    # print(len(peaks), len(keep_peaks))

{'fraction_non_alphanumeric': 0.12446351931330472, 'fraction_numerical': 0.01888412017167382, 'mean_word_length': 2.8088235294117645, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5132249', 'n_tokens_mistral': 855, 'n_tokens_neox': 782, 'n_words': 205}