neuroprob/utils/signal.py
def filter_signal(signal, f_min, f_max, sample_bin):
    """
    Filter in Fourier space by multiplying with a box function for (f_min, f_max).
    """
    track_samples = signal.shape[0]
    Df = 1/sample_bin/track_samples
    low_ind = np.floor(f_min/Df).astype(int)
    high_ind = np.ceil(f_max/Df).astype(int)

    g_fft = np.fft.rfft(signal)
    mask = np.zeros_like(g_fft)
    mask[low_ind:high_ind] = 1.
    g_fft *= mask
    signal_ = np.fft.irfft(g_fft)
    
    if track_samples % 2 == 1: # odd
        signal_ = np.concatenate((signal_, signal_[-1:]))
        
    return signal_

    Filter in Fourier space by multiplying with a box function for (f_min, f_max).
    
Filter in Fourier space by multiplying with a box function for (f_min, f_max).
Filter in Fourier space by multiplying with a box function for ( f_min f_max ) .
def filter_signal(signal, f_min, f_max, sample_bin):
    track_samples = signal.shape[0]
    Df = 1/sample_bin/track_samples
    low_ind = np.floor(f_min/Df).astype(int)
    high_ind = np.ceil(f_max/Df).astype(int)
    g_fft = np.fft.rfft(signal)
    mask = np.zeros_like(g_fft)
    mask[low_ind:high_ind] = 1.
    g_fft *= mask
    signal_ = np.fft.irfft(g_fft)
    if track_samples % 2 == 1: 
        signal_ = np.concatenate((signal_, signal_[-1:]))
    return signal_
def filter_signal ( signal , f_min , f_max , sample_bin ) : track_samples = signal . shape [ 0 ] Df = 1 / sample_bin / track_samples low_ind = np . floor ( f_min / Df ) . astype ( int ) high_ind = np . ceil ( f_max / Df ) . astype ( int ) g_fft = np . fft . rfft ( signal ) mask = np . zeros_like ( g_fft ) mask [ low_ind : high_ind ] = 1. g_fft *= mask signal_ = np . fft . irfft ( g_fft ) if track_samples % 2 == 1 : signal_ = np . concatenate ( ( signal_ , signal_ [ - 1 : ] ) ) return signal_
Filter in Fourier space by multiplying with a box function for (f_min, f_max).
Filter in Fourier space by multiplying with a box function for ( f_min f_max ) .
"""
    Filter in Fourier space by multiplying with a box function for (f_min, f_max).
    """ # odd
signal
f_min
f_max
sample_bin