voltage_fluctuation

voltage_fluctuation#

class braintools.metric.voltage_fluctuation(potentials, method='loop')#

Calculate neuronal synchronization via voltage variance analysis.

This method quantifies synchronization by comparing the variance of the population-averaged membrane potential to the average variance of individual neurons’ membrane potentials.

The synchronization measure is computed as:

\[\chi^2(N) = \frac{\sigma_V^2}{\frac{1}{N} \sum_{i=1}^N \sigma_{V_i}^2}\]

where:

  • \(\sigma_V^2\) is the variance of the population average potential

  • \(\sigma_{V_i}^2\) is the variance of individual neuron potentials

  • \(N\) is the number of neurons

The population average potential is:

\[V(t) = \frac{1}{N} \sum_{i=1}^{N} V_i(t)\]

And its variance is:

\[\sigma_V^2 = \left\langle V(t)^2 \right\rangle_t - \left\langle V(t) \right\rangle_t^2\]
Parameters:
  • potentials (brainstate.typing.ArrayLike) – Membrane potential matrix with shape (num_time, num_neurons). Contains the voltage traces for each neuron over time.

  • method (str, default='loop') –

    Computational method:

    • 'loop': Memory-efficient iterative computation

    • 'vmap': Vectorized computation (higher memory usage)

Returns:

Synchronization index. Values > 1 indicate synchronized activity, values ≈ 1 indicate asynchronous activity.

Return type:

float

Examples

>>> import jax.numpy as jnp
>>> import braintools as braintools
>>> # Generate correlated voltage traces
>>> t = jnp.linspace(0, 10, 1000)
>>> # Synchronous case: common oscillation + noise
>>> common_signal = jnp.sin(2 * jnp.pi * t)
>>> potentials_sync = common_signal[:, None] + 0.1 * jnp.random.normal((1000, 10))
>>> sync_idx = braintools.metric.voltage_fluctuation(potentials_sync)
>>> print(f"Synchronized case: {sync_idx:.3f}")
>>>
>>> # Asynchronous case: independent noise
>>> potentials_async = jnp.random.normal((1000, 10))
>>> async_idx = braintools.metric.voltage_fluctuation(potentials_async)
>>> print(f"Asynchronous case: {async_idx:.3f}")

References