Apply filter with filtfilt to allign filtereted data with input

    The filter is applied once forward and once backward to give it linear
    phase, using Gustafsson's method to give the same length as the original
    signal.

    Args
    ----
    b: ndarray
        Numerator polynomials of the IIR butter filter
    a: ndarray
        Denominator polynomials of the IIR butter filter

    Returns
    -------
    x: ndarray
        Filtered data with linear phase

    Notes
    -----
    This function was adapted from the following StackOverflow answer:
    http://stackoverflow.com/a/25192640/943773

def butter_apply(b, a, data):
    '''Apply filter with filtfilt to allign filtereted data with input

    The filter is applied once forward and once backward to give it linear
    phase, using Gustafsson's method to give the same length as the original
    signal.

    Args
    ----
    b: ndarray
        Numerator polynomials of the IIR butter filter
    a: ndarray
        Denominator polynomials of the IIR butter filter

    Returns
    -------
    x: ndarray
        Filtered data with linear phase

    Notes
    -----
    This function was adapted from the following StackOverflow answer:
    http://stackoverflow.com/a/25192640/943773
    '''
    import scipy.signal

    return scipy.signal.filtfilt(b, a, data, method='gust')