Regression function that with a percent input gives an absolute value of the threshold
    level (used in the muscular activation detection algorithm).
    Converts a relative threshold level to an absolute value.

    ----------
    Parameters
    ----------
    threshold_level : int
        Percentage value that defines the absolute threshold level relatively to the maximum value
        of signal.
    signal : list
        List of EMG smoothed signal samples.
    pre_smooth_signal : list
        Original EMG samples.

    Returns
    -------
    out : float
        Threshold level in absolute format.

def _thres_norm_reg(threshold_level, signal, pre_smooth_signal):
    """
    Regression function that with a percent input gives an absolute value of the threshold
    level (used in the muscular activation detection algorithm).
    Converts a relative threshold level to an absolute value.

    ----------
    Parameters
    ----------
    threshold_level : int
        Percentage value that defines the absolute threshold level relatively to the maximum value
        of signal.
    signal : list
        List of EMG smoothed signal samples.
    pre_smooth_signal : list
        Original EMG samples.

    Returns
    -------
    out : float
        Threshold level in absolute format.

     """
    avg_signal = numpy.average(pre_smooth_signal)
    std_signal = numpy.std(pre_smooth_signal)

    threshold_0_perc_level = (-avg_signal) / float(std_signal)
    threshold_100_perc_level = (numpy.max(signal) - avg_signal) / float(std_signal)

    slope, b_coeff = linregress([0, 100], [threshold_0_perc_level, threshold_100_perc_level])[:2]
    return slope * threshold_level + b_coeff