Curate class for processing rBCBG results (in respective files)

Functions

filter_rates()

preprocess()

Use Cases

1. Pre-requisites

1.1. Import Modules

from analyseur.rbcbg.loader import LoadRates
from analyseur.rbcbg.curate import filter_rates, preprocess

1.2. Load file and get the firing rates

loadFR = LoadRates("GPiSNr_model_9_percent_0.csv")
t_sec, rates_Hz = loadFR.get_rates()

2. Cases

2.1. Filter rates for a desired window

filtered_t, filter_rates = filter_rates(times_sec=t_sec, rates_Hz=rates_Hz, window=(0.2, 0.5))

filters for time window 0.2 seconds to 0.5 seconds.

2.2. Preprocess the rates

prep_rates = preprocess(rates_Hz=rates_Hz, highpass_freq=0.5)

prepocessed for high-pass frequency cutoff 0.5 Hz.


analyseur.rbcbg.curate.apply_highpass_filter(detrended_rates, fs, hp_freq)[source]

High-pass filter to remove slow drifts, i.e. remove noise (low frequencies).

Parameters:
  • detrended_rates – array returned using detrend_rates()

  • fs – scalar value for frequency

  • hp_freq – scalar value for high-pass cutoff

Returns:

array

This applies a zero-phase high-pass Butterworth filter to remove low-frequency components.

This function attenuates slow drifts and low-frequency noise from the input signal using a 4th-order Butterworth high-pass filter. The filtering is performed with forward-backward filtering (filtfilt), ensuring zero phase distortion.


analyseur.rbcbg.curate.detrend_rates(rates_Hz)[source]

Detrend the rates by removing the linear trend (but the time points stay exactly the same).

Parameters:

rates_Hz – array returned using get_rates()

Returns:

array

For example:

time (s)

rate (Hz)

detrend rate

0.000

5

-1

0.001

6

0

0.002

7

1


analyseur.rbcbg.curate.filter_rates(times_sec=None, rates_Hz=None, window=None)[source]

Returns the times (s) and rates (Hz) filtered within the desired window.

Parameters:
  • times_sec – array returned using get_rates()

  • rates_Hz – array returned using get_rates()

  • window – 2-tuple; (0, 10) [default]

Returns:

2-tuple; filtered_times, filtered_rates


analyseur.rbcbg.curate.preprocess(rates_Hz=None, highpass_freq=None)[source]

Preprocesses the given rates.

Parameters:
  • rates_Hz – array returned using get_rates()

  • highpass_freq – float; 0.5 [default]

Returns:

array of preprocessed rates

The preprocessing is done in the following order:


analyseur.rbcbg.curate.zscore_normalize(filtered_rates)[source]

Normalize firing rates using z-score standardization, z = (x - mean) / std.

Parameters:

filtered_rates – array returned using apply_highpass_filter()

Returns:

array