ibllib.dsp.fourier

Low-level functions to work in frequency domain for n-dim arrays

ibllib.dsp.fourier.bp(ts, si, b, axis=None)

Band-pass filter in frequency domain

Parameters:
  • ts – time serie
  • si – sampling interval in seconds
  • b – cutout frequencies: 4 elements vector or list
  • axis – axis along which to perform reduction (last axis by default)
Returns:

filtered time serie

ibllib.dsp.fourier.dephas(w, phase, axis=-1)

dephas a signal by a given angle in degrees :param w: :param phase: phase in degrees :param axis: :return:

ibllib.dsp.fourier.fexpand(x, ns=1, axis=None)

Reconstructs full spectrum from positive frequencies Works on the last dimension (contiguous in c-stored array)

Parameters:
  • x – numpy.ndarray
  • axis – axis along which to perform reduction (last axis by default)
Returns:

numpy.ndarray

ibllib.dsp.fourier.fit_phase(w, si=1, fmin=0, fmax=None, axis=-1)

Performs a linear regression on the unwrapped phase of a wavelet to obtain a time-delay :param w: wavelet (usually a cross-correlation) :param si: sampling interval :param fmin: sampling interval :param fnax: sampling interval :param axis: :return: dt

ibllib.dsp.fourier.freduce(x, axis=None)

Reduces a spectrum to positive frequencies only Works on the last dimension (contiguous in c-stored array)

Parameters:
  • x – numpy.ndarray
  • axis – axis along which to perform reduction (last axis by default)
Returns:

numpy.ndarray

ibllib.dsp.fourier.fscale(ns, si=1, one_sided=False)

numpy.fft.fftfreq returns Nyquist as a negative frequency so we propose this instead

Parameters:
  • ns – number of samples
  • si – sampling interval in seconds
  • one_sided – if True, returns only positive frequencies
Returns:

fscale: numpy vector containing frequencies in Hertz

ibllib.dsp.fourier.hp(ts, si, b, axis=None)

High-pass filter in frequency domain

Parameters:
  • ts – time serie
  • si – sampling interval in seconds
  • b – cutout frequencies: 2 elements vector or list
  • axis – axis along which to perform reduction (last axis by default)
Returns:

filtered time serie

ibllib.dsp.fourier.lp(ts, si, b, axis=None)

Low-pass filter in frequency domain

Parameters:
  • ts – time serie
  • si – sampling interval in seconds
  • b – cutout frequencies: 2 elements vector or list
  • axis – axis along which to perform reduction (last axis by default)
Returns:

filtered time serie

ibllib.dsp.fourier.shift(w, s, axis=-1)

Shifts a signal in frequency domain, to allow for accurate non-integer shifts :param w: input signal :param s: shift in samples, positive shifts forward :param axis: axis along which to shift :return: w