Synchrony Statistics of CBGTC spike times

class analyseur.cbgtc.stats.sync.Synchrony[source]

Bases: object

Computes measures of synchrony among the neurons with given spike times

Methods

Argument

compute_basic()

compute_basic_slide()

  • spiketimes_superset: see get_spiketimes_superset

  • OPTIONAL: binsz (0.01 [default]), window ((0, 10) [default]), windowsz (0.5 [default])

compute_fano_factor()

Use Cases

1. Pre-requisites

1.1. Import Modules

from analyseur.cbgtc.loader import LoadSpikeTimes
from analyseur.cbgtc.stats.sync import Synchrony

1.2. Load file and get spike times

loadST = LoadSpikeTimes("spikes_GPi.csv")
spiketimes_superset = loadST.get_spiketimes_superset()

2. Cases

2.1. Compute basic measure of spike times synchrony (for all neurons)

B = Synchrony.compute_basic(spiketimes_superset)

This returns the value for

\[Sync = \sqrt{\frac{var\left(\left[\mu\left(\left[f^{{i}}(t)\right]_{\forall{t}}\right)\right]_{\forall{i}}\right)}{\mu\left(\left[var\left(\left[f^{(i)}(t)\right]_{\forall{i}}\right)\right]_{\forall{t}}\right)}}\]

2.2. Compute the basic measure of synchrony on a smoother frequency estimation

S = Synchrony.compute_basic_slide(spiketimes_superset)

This returns the value for

\[Sync = \sqrt{\frac{var\left(\left[\mu\left(\left[f^{{i}}(t)\right]_{\forall{t}}\right)\right]_{\forall{i}}\right)}{\mu\left(\left[var\left(\left[f^{(i)}(t)\right]_{\forall{i}}\right)\right]_{\forall{t}}\right)}}\]

2.3. Compute Fano factor as a metric for measuring spike times synchrony (for all neurons)

Fs = Synchrony.compute_fano_factor(spiketimes_superset)

This returns the value for

\[F_{Sync} = \frac{var\left(\left[\sum_{\forall{i}}p^{(i)}(t)\right]_{\forall{t}}\right)}{\mu\left(\left[\sum_{\forall{i}}p^{(i)}(t)\right]_{\forall{t}}\right)}\]

classmethod compute_basic(spiketimes_set, binsz=None, window=None, filter_zeros=True)[source]

Returns the basic measure of synchrony of spiking from all neurons.

Parameters:

spiketimes_set – Dictionary returned using get_spiketimes_superset()

or using get_spiketimes_subset()

Parameters:
  • binsz – integer or float; 0.01 [default]

  • window – Tuple in the form (start_time, end_time); (0, 10) [default]

  • filter_zeros – boolean; True [default]

Returns:

  • s_sync : float

  • freq_matrix : numpy array, Population frequencies per time bin

  • time_bins_center : numpy array, Center times of each bin

Formula

Definitions

Interpretation

total neurons, \(n_{Nuc}\)

total number of neurons in the Nucleus

neuron index, \(i\)

i-th neuron in the pool of \(n_{Nuc}\) neurons

frequency, \(f^{(i)}(t)\)

frequency of the i-th neuron at time \(t\)

frequency matrix, \(F = \left[f(a,b) = f^{(a)}(b)\right]_{\forall{a \in [1, n_{Nuc}], b \in [t_0, t_T]}}\)

frequencies of all (\(n_{Nuc}\)) neurons for all times

Let the \(var(\cdot)\), variance function and the \(\mu(\cdot)\), arithmetic mean function be implemented as shown

\[ \begin{align}\begin{aligned}F = \overset{\begin{matrix}t_0 & \quad\quad & t_1 & & & &\ldots & & & t_T\end{matrix}} {\underset{ \begin{matrix} \quad\quad\uparrow & \quad\quad\quad & \uparrow & \quad &\ldots & & & \uparrow \\ \quad\mu_{t_0} & \quad\quad\quad & \mu_{t_1} & \quad &\ldots & & & \mu_{t_T} & \rightarrow var_{\forall{t}} \end{matrix}} {\begin{bmatrix} f^{(1)}(t_0) & f^{(1)}(t_1) & \ldots & f^{(1)}(t_T) \\ f^{(2)}(t_0) & f^{(2)}(t_1) & \ldots & f^{(2)}(t_T) \\ \vdots & \vdots & \ldots & \vdots \\ f^{(i)}(t_0) & f^{(i)}(t_1) & \ldots & f^{(i)}(t_T) \\ \vdots & \vdots & \ldots & \vdots \\ f^{(n_{Nuc})}(t_0) & f^{(n_{Nuc})}(t_1) & \ldots & f^{(n_{Nuc})}(t_T) \end{bmatrix} }}\end{aligned}\end{align} \]

Then, we define

\[A \triangleq var\left(\begin{bmatrix} \mu_{t_0} & \mu_{t_1} & \ldots & \mu_{t_T} \end{bmatrix}\right) = var_{\forall{t}}\]

Implementing the variance function and the arithmetic mean function as shown below

\[ \begin{align}\begin{aligned}F = \overset{\begin{matrix}t_0 & \quad\quad & t_1 & & & &\ldots & & & t_T\end{matrix}} {\underset{ \begin{matrix} \quad\quad\uparrow & \quad\quad\quad & \uparrow & \quad &\ldots & & & \uparrow \\ \quad var_{t_0} & \quad\quad\quad & var_{t_1} & \quad &\ldots & & & var_{t_T} & \rightarrow \mu_{\forall{t}} \end{matrix}} {\begin{bmatrix} f^{(1)}(t_0) & f^{(1)}(t_1) & \ldots & f^{(1)}(t_T) \\ f^{(2)}(t_0) & f^{(2)}(t_1) & \ldots & f^{(2)}(t_T) \\ \vdots & \vdots & \ldots & \vdots \\ f^{(i)}(t_0) & f^{(i)}(t_1) & \ldots & f^{(i)}(t_T) \\ \vdots & \vdots & \ldots & \vdots \\ f^{(n_{Nuc})}(t_0) & f^{(n_{Nuc})}(t_1) & \ldots & f^{(n_{Nuc})}(t_T) \end{bmatrix} }}\end{aligned}\end{align} \]

we make another definition

\[B \triangleq \mu\left(\begin{bmatrix} var_{t_0} & var_{t_1} & \ldots & var_{t_T} \end{bmatrix}\right) = \mu_{\forall{t}}\]

Then, synchrony is measured as

\[Sync = \sqrt{\frac{A}{B}} = \sqrt{\frac{var\left(\left[\mu\left(\left[f^{{i}}(t)\right]_{\forall{i}}\right)\right]_{\forall{t}}\right)}{\mu\left(\left[var\left(\left[f^{(i)}(t)\right]_{\forall{i}}\right)\right]_{\forall{t}}\right)}}\]

NOTE: This method is a simple histogram-based approach that uses fixed bins.

INTERPRETATION

\(S_{sync}\)

Interpretation

\(\approx 0\)

Low synchrony (independent firing)

\(\ge 1\)

High synchrony (neurons fire together)

\(= \infty\)

Perfect synchrony

COMMENTS:

  • Fano factor can indicate population-level synchrony
    • higher values correspond to more synchrony

  • Fano factor depends on time bin size.

Notes on Filtering

The default argument filter_zeros=True means only frequencies during active periods are accounted for making the computation.


classmethod compute_basic_slide(spiketimes_set, binsz=None, window=None, windowsz=None)[source]

Returns the basic measure of synchrony of spiking from all neurons.

Parameters:

spiketimes_set – Dictionary returned using get_spiketimes_superset()

or using get_spiketimes_subset()

Parameters:
  • binsz – integer or float; 0.01 [default]

  • window – Tuple in the form (start_time, end_time); (0, 10) [default]

  • windowsz – integer or float, sliding window size; 0.5 [default]

Returns:

a number

NOTE: The computation is done on a sliding window resulting in a smoother frequency estimation otherwise this is the same as compute_basic(). Therefore, unlike the simple histogram-based approach the use of overlapping windows (sliding windows) results in a smoother frequency estimation.


classmethod compute_fano_factor(spiketimes_set, binsz=None, window=None, filter_zeros=True)[source]

Returns the Fano factor as a measure of synchrony of spiking from all neurons.

Parameters:

spiketimes_set – Dictionary returned using get_spiketimes_superset()

or using get_spiketimes_subset()

Parameters:
  • binsz – integer or float; 0.01 [default]

  • window – Tuple in the form (start_time, end_time); (0, 10) [default]

  • filter_zeros – boolean; True [default]

Returns:

  • fanofactor : float = variance / mean of population spike counts

  • spike_matrix : numpy array, Population spike counts per time bin

  • time_bins_center : numpy array, Center times of each bin

Formula

Definitions

Interpretation

total neurons, \(n_{Nuc}\)

total number of neurons in the Nucleus

neuron index, \(i\)

i-th neuron in the pool of \(n_{Nuc}\) neurons

spike count, \(p^{(i)}(t)\)

spike count of the i-th neuron at time \(t\)

count matrix, \(P = \left[p(a,b) = p^{(a)}(b)\right]_{\forall{a \in [1, n_{Nuc}], b \in [t_0, t_T]}}\)

spike counts of all (\(n_{Nuc}\)) neurons for all times

Let the \(var(\cdot)\), variance function and the \(\mu(\cdot)\), arithmetic mean function be implemented as shown

\[ \begin{align}\begin{aligned}P = \overset{\begin{matrix}t_0 & \quad\quad & t_1 & & & &\ldots & & & t_T\end{matrix}} {\underset{ \begin{matrix} \quad\quad\uparrow & \quad\quad\quad & \uparrow & \quad &\ldots & & & \uparrow \\ \quad\Sigma_{t_0} & \quad\quad\quad & \Sigma_{t_1} & \quad &\ldots & & & \Sigma_{t_T} & \rightarrow var_{\forall{t}} \\ \quad\Sigma_{t_0} & \quad\quad\quad & \Sigma_{t_1} & \quad &\ldots & & & \Sigma_{t_T} & \rightarrow \mu_{\forall{t}} \end{matrix}} {\begin{bmatrix} p^{(1)}(t_0) & p^{(1)}(t_1) & \ldots & p^{(1)}(t_T) \\ p^{(2)}(t_0) & p^{(2)}(t_1) & \ldots & p^{(2)}(t_T) \\ \vdots & \vdots & \ldots & \vdots \\ p^{(i)}(t_0) & p^{(i)}(t_1) & \ldots & p^{(i)}(t_T) \\ \vdots & \vdots & \ldots & \vdots \\ p^{(n_{Nuc})}(t_0) & p^{(n_{Nuc})}(t_1) & \ldots & p^{(n_{Nuc})}(t_T) \end{bmatrix} }}\end{aligned}\end{align} \]

We define

\[ \begin{align}\begin{aligned}A &\triangleq var\left(\begin{bmatrix} \Sigma_{t_0} & \Sigma_{t_1} & \ldots & \Sigma_{t_T} \end{bmatrix}\right) = var_{\forall{t}} \\B &\triangleq \mu\left(\begin{bmatrix} \Sigma_{t_0} & \Sigma_{t_1} & \ldots & \Sigma_{t_T} \end{bmatrix}\right) = \mu_{\forall{t}}\end{aligned}\end{align} \]

Then, synchrony is measured as

\[F_{Sync} = \frac{A}{B} = \frac{var\left(\left[\sum_{\forall{i}}p^{(i)}(t)\right]_{\forall{t}}\right)}{\mu\left(\left[\sum_{\forall{i}}p^{(i)}(t)\right]_{\forall{t}}\right)}\]

INTERPRETATION

Fano Factor

Interpretation

\(= 1\)

Poisson-like variability

\(< 1\)

More regular/periodic than Poisson (Sub-Poisson)

\(> 1\)

More variable/bursty than Poisson (Super-Poisson)

COMMENTS:

  • Fano factor can indicate population-level synchrony
    • higher values correspond to more synchrony

  • Fano factor depends on time bin size.

Notes on Filtering

The default argument filter_zeros=True means only spike counts during active periods are accounted for making the computation. This is the default because,

  • Biological relevance
    • interest in variability of activity during firing periods not during silent periods.

  • Statistical robustness
    • zero bins artificially lower both variance and mean values.

  • Practical interpretation
    • Fano factor is more meaningful when computed over active periods.


classmethod compute_fano_factor_multibins(spiketimes_set, binsz_list=None, window=None)[source]

Returns the Fano factor for multiple bin sizes

Parameters:

spiketimes_set – Dictionary returned using get_spiketimes_superset()

or using get_spiketimes_subset()

Parameters:
  • binsz_list – list of integer or float

  • window – Tuple in the form (start_time, end_time); (0, 10) [default]

Returns:

For each binsz in binsz_list

  • fanofactor : float = variance / mean of population spike counts

  • spike_matrix : numpy array, Population spike counts per time bin

  • time_bins_center : numpy array, Center times of each bin

Formula

see compute_fano_factor()


classmethod compute_pairwise_ci(spiketimes_set, binsz=None, window=None)[source]

Calculate average pairwise correlation index.


classmethod compute_pairwise_corr(spiketimes_set, binsz=None, window=None)[source]

Returns the Pairwise correlation as a measure of synchrony of spiking from all neurons.

Parameters:

spiketimes_set – Dictionary returned using get_spiketimes_superset()

or using get_spiketimes_subset()

Parameters:
  • binsz – integer or float; 0.01 [default]

  • window – Tuple in the form (start_time, end_time); (0, 10) [default]

Returns:

a number

Formula

Definitions

Interpretation

total neurons, \(n_{Nuc}\)

total number of neurons in the Nucleus

neuron index, \(i\)

i-th neuron in the pool of \(n_{Nuc}\) neurons

spike count, \(p^{(i)}(t)\)

spike count of the i-th neuron at time \(t\)

count matrix, \(P = \left[p(a,b) = p^{(a)}(b)\right]_{\forall{a \in [1, n_{Nuc}], b \in [t_0, t_T]}}\)

spike counts of all (\(n_{Nuc}\)) neurons for all times

Let the \(var(\cdot)\), variance function and the \(\mu(\cdot)\), arithmetic mean function be implemented as shown

\[ \begin{align}\begin{aligned}P = \overset{\begin{matrix}t_0 & \quad\quad & t_1 & & & &\ldots & & & t_T\end{matrix}} {\underset{ \begin{matrix} \quad\quad\uparrow & \quad\quad\quad & \uparrow & \quad &\ldots & & & \uparrow \\ \quad\pi_{t_0} & \quad\quad\quad & \pi_{t_1} & \quad &\ldots & & & \pi_{t_T} & \rightarrow var_{\forall{t}} \\ \quad\pi_{t_0} & \quad\quad\quad & \pi_{t_1} & \quad &\ldots & & & \pi_{t_T} & \rightarrow \mu_{\forall{t}} \end{matrix}} {\begin{bmatrix} p^{(1)}(t_0) & p^{(1)}(t_1) & \ldots & p^{(1)}(t_T) \\ p^{(2)}(t_0) & p^{(2)}(t_1) & \ldots & p^{(2)}(t_T) \\ \vdots & \vdots & \ldots & \vdots \\ p^{(i)}(t_0) & p^{(i)}(t_1) & \ldots & p^{(i)}(t_T) \\ \vdots & \vdots & \ldots & \vdots \\ p^{(n_{Nuc})}(t_0) & p^{(n_{Nuc})}(t_1) & \ldots & p^{(n_{Nuc})}(t_T) \end{bmatrix} }}\end{aligned}\end{align} \]

We define

\[ \begin{align}\begin{aligned}A &\triangleq var\left(\begin{bmatrix} \pi_{t_0} & \pi_{t_1} & \ldots & \pi_{t_T} \end{bmatrix}\right) = var_{\forall{t}} \\B &\triangleq \mu\left(\begin{bmatrix} \pi_{t_0} & \pi_{t_1} & \ldots & \pi_{t_T} \end{bmatrix}\right) = \mu_{\forall{t}}\end{aligned}\end{align} \]

Then, synchrony is measured as

\[F_{Sync} = \frac{A}{B} = \frac{var\left(\left[\sum_{\forall{i}}p^{(i)}(t)\right]_{\forall{t}}\right)}{\mu\left(\left[\sum_{\forall{i}}p^{(i)}(t)\right]_{\forall{t}}\right)}\]

classmethod compute_sync_index_from_PSTH(spiketimes_set, binsz=None, window=None)[source]

Synchrony as variance of total population rate