def tachogram(data, sample_rate, signal=False, in_seconds=False, out_seconds=False):
    """
    Function for generation of ECG Tachogram.

    ----------
    Parameters
    ----------
    data : list
        ECG signal or R peak list. When the input is a raw signal the input flag signal should be
        True.

    sample_rate : int
        Sampling frequency.

    signal : boolean
        If True, then the data argument contains the set of the ECG acquired samples.

    in_seconds : boolean
        If the R peaks list defined as the input argument "data" contains the sample numbers where
        the R peaks occur, then in_seconds needs to be False.

    out_seconds : boolean
        If True then each sample of the returned time axis is expressed in seconds.

    Returns
    -------
    out : list, list
        List of tachogram samples. List of instants where each cardiac cycle ends.

    """

    if signal is False:  # data is a list of R peaks position.
        data_copy = data
        time_axis = numpy.array(data)#.cumsum()
        if out_seconds is True and in_seconds is False:
            time_axis = time_axis / sample_rate
    else:  # data is a ECG signal.
        # Detection of R peaks.
        data_copy = detect_r_peaks(data, sample_rate, time_units=out_seconds, volts=False,
                                   resolution=None, plot_result=False)[0]
        time_axis = data_copy

    # Generation of Tachogram.
    tachogram_data = numpy.diff(time_axis)
    tachogram_time = time_axis[1:]

    return tachogram_data, tachogram_time
def tachogram ( data , sample_rate , signal = False , in_seconds = False , out_seconds = False ) : if signal is False : data_copy = data time_axis = numpy . array ( data ) if out_seconds is True and in_seconds is False : time_axis = time_axis / sample_rate else : data_copy = detect_r_peaks ( data , sample_rate , time_units = out_seconds , volts = False , resolution = None , plot_result = False ) [ 0 ] time_axis = data_copy tachogram_data = numpy . diff ( time_axis ) tachogram_time = time_axis [ 1 : ] return tachogram_data , tachogram_time
Function for generation of ECG Tachogram.

    ----------
    Parameters
    ----------
    data : list
        ECG signal or R peak list. When the input is a raw signal the input flag signal should be
        True.

    sample_rate : int
        Sampling frequency.

    signal : boolean
        If True, then the data argument contains the set of the ECG acquired samples.

    in_seconds : boolean
        If the R peaks list defined as the input argument "data" contains the sample numbers where
        the R peaks occur, then in_seconds needs to be False.

    out_seconds : boolean
        If True then each sample of the returned time axis is expressed in seconds.

    Returns
    -------
    out : list, list
        List of tachogram samples. List of instants where each cardiac cycle ends.