ibllib.dsp.utils

Window generator, front detections, rms

class ibllib.dsp.utils.WindowGenerator(ns, nswin, overlap)

wg = WindowGenerator(ns, nswin, overlap)

Provide sliding windows indices generator for signal processing applications. For straightforward spectrogram / periodogram implementation, prefer scipy methods !

Example of implementations in test_dsp.py.

firstlast

Generator that yields first and last index of windows

Returns:tuple of [first_index, last_index] of the window
print_progress()

Prints progress using a terminal progress bar

slice

Generator that yields slices of windows

Returns:a slice of the window
slice_array(sig, axis=-1)

Provided an array or sliceable object, generator that yields slices corresponding to windows. Especially useful when working on memmpaps

Parameters:
  • sig – array
  • axis – (optional, -1) dimension along which to provide the slice
Returns:

array slice Generator

tscale(fs)

Returns the time scale associated with Window slicing (middle of window) :param fs: sampling frequency (Hz) :return: time axis scale

ibllib.dsp.utils.falls(x, axis=-1, step=-1)

Detects Falling edges of a voltage signal, returns indices

Parameters:
  • x – array on which to compute RMS
  • axis – (optional, -1) negative value
  • step – (optional, -1) value of the step to detect
Returns:

numpy array

ibllib.dsp.utils.fronts(x, axis=-1, step=1)

Detects Rising and Falling edges of a voltage signal, returns indices and

Parameters:
  • x – array on which to compute RMS
  • axis – (optional, -1) negative value
  • step – (optional, -1) value of the step to detect
Returns:

numpy array of indices, numpy array of rises (1) and falls (-1)

ibllib.dsp.utils.rises(x, axis=-1, step=1)

Detect Rising edges of a voltage signal, returns indices

Parameters:
  • x – array on which to compute RMS
  • axis – (optional, -1)
  • step – (optional, 1) amplitude of the step to detect
Returns:

numpy array

ibllib.dsp.utils.rms(x, axis=-1)

Root mean square of array along axis

Parameters:
  • x – array on which to compute RMS
  • axis – (optional, -1)
Returns:

numpy array