WilsonCowanAdaptiveStep#

class brainmass.WilsonCowanAdaptiveStep(in_size, tau_E=Quantity(1., 'ms'), a_E=1.2, theta_E=2.8, tau_I=Quantity(1., 'ms'), a_I=1.0, theta_I=4.0, wEE=12.0, wIE=4.0, wEI=13.0, wII=11.0, r=1.0, tau_aE=Quantity(100., 'ms'), tau_aI=Quantity(80., 'ms'), b_E=0.1, b_I=0.08, noise_E=None, noise_I=None, rE_init=Constant(value=0.0), rI_init=Constant(value=0.0), aE_init=Constant(value=0.0), aI_init=Constant(value=0.0), method='exp_euler')#

Wilson-Cowan neural mass model with spike-frequency adaptation.

This variant adds adaptation currents to both excitatory and inhibitory populations, implementing spike-frequency adaptation. Adaptation currents build up with sustained activity and reduce the effective drive to each population, modeling neural fatigue and habituation effects.

Parameters:
  • in_size (int | Sequence[int] | integer | Sequence[integer]) – Spatial shape of each population (E and I). Can be an int, a tuple of ints, or any size compatible with brainstate.

  • tau_E (Callable | Array | ndarray | bool | number | bool | int | float | complex | Quantity | Param) – Excitatory time constant with unit of time (e.g., 1. * u.ms). Broadcastable to in_size. Default is 1. * u.ms.

  • a_E (Callable | Array | ndarray | bool | number | bool | int | float | complex | Quantity | Param) – Excitatory gain (dimensionless). Broadcastable to in_size. Default is 1.2.

  • theta_E (Callable | Array | ndarray | bool | number | bool | int | float | complex | Quantity | Param) – Excitatory threshold (dimensionless). Broadcastable to in_size. Default is 2.8.

  • tau_I (Callable | Array | ndarray | bool | number | bool | int | float | complex | Quantity | Param) – Inhibitory time constant with unit of time (e.g., 1. * u.ms). Broadcastable to in_size. Default is 1. * u.ms.

  • a_I (Callable | Array | ndarray | bool | number | bool | int | float | complex | Quantity | Param) – Inhibitory gain (dimensionless). Broadcastable to in_size. Default is 1..

  • theta_I (Callable | Array | ndarray | bool | number | bool | int | float | complex | Quantity | Param) – Inhibitory threshold (dimensionless). Broadcastable to in_size. Default is 4.0.

  • wEE (Callable | Array | ndarray | bool | number | bool | int | float | complex | Quantity | Param) – E→E coupling strength (dimensionless). Broadcastable to in_size. Default is 12..

  • wIE (Callable | Array | ndarray | bool | number | bool | int | float | complex | Quantity | Param) – E→I coupling strength (dimensionless). Broadcastable to in_size. Default is 4..

  • wEI (Callable | Array | ndarray | bool | number | bool | int | float | complex | Quantity | Param) – I→E coupling strength (dimensionless). Broadcastable to in_size. Default is 13..

  • wII (Callable | Array | ndarray | bool | number | bool | int | float | complex | Quantity | Param) – I→I coupling strength (dimensionless). Broadcastable to in_size. Default is 11..

  • r (Callable | Array | ndarray | bool | number | bool | int | float | complex | Quantity | Param) – Refractory parameter (dimensionless) that limits maximum activation. Broadcastable to in_size. Default is 1..

  • tau_aE (Callable | Array | ndarray | bool | number | bool | int | float | complex | Quantity | Param) – Excitatory adaptation time constant with unit of time (e.g., 100. * u.ms). Controls how fast adaptation builds up and decays. Broadcastable to in_size. Default is 100. * u.ms.

  • tau_aI (Callable | Array | ndarray | bool | number | bool | int | float | complex | Quantity | Param) – Inhibitory adaptation time constant with unit of time (e.g., 80. * u.ms). Controls how fast adaptation builds up and decays. Broadcastable to in_size. Default is 80. * u.ms.

  • b_E (Callable | Array | ndarray | bool | number | bool | int | float | complex | Quantity | Param) – Excitatory adaptation coupling strength (dimensionless). Controls how strongly activity drives adaptation. Broadcastable to in_size. Default is 0.1.

  • b_I (Callable | Array | ndarray | bool | number | bool | int | float | complex | Quantity | Param) – Inhibitory adaptation coupling strength (dimensionless). Controls how strongly activity drives adaptation. Broadcastable to in_size. Default is 0.08.

  • noise_E (Noise) – Additive noise process for the excitatory population. If provided, its output is added to rE_inp at each update. Default is None.

  • noise_I (Noise) – Additive noise process for the inhibitory population. If provided, its output is added to rI_inp at each update. Default is None.

  • rE_init (Callable) – Initializer for the excitatory state rE. Default is braintools.init.Constant(0.0).

  • rI_init (Callable) – Initializer for the inhibitory state rI. Default is braintools.init.Constant(0.0).

  • aE_init (Callable) – Initializer for the excitatory adaptation current aE. Default is braintools.init.Constant(0.0).

  • aI_init (Callable) – Initializer for the inhibitory adaptation current aI. Default is braintools.init.Constant(0.0).

  • method (str) – The numerical integration method to use. One of 'exp_euler', 'euler', 'rk2', or 'rk4', that is implemented in braintools.quad. Default is 'exp_euler'.

Return type:

Any

rE#

Excitatory population activity (dimensionless). Shape equals (batch?,) + in_size after init_state.

Type:

brainstate.HiddenState

rI#

Inhibitory population activity (dimensionless). Shape equals (batch?,) + in_size after init_state.

Type:

brainstate.HiddenState

aE#

Excitatory adaptation current (dimensionless). Shape equals (batch?,) + in_size after init_state.

Type:

brainstate.HiddenState

aI#

Inhibitory adaptation current (dimensionless). Shape equals (batch?,) + in_size after init_state.

Type:

brainstate.HiddenState

Notes

The continuous-time Wilson-Cowan equations with adaptation are

\[\tau_E \frac{dr_E}{dt} = -r_E(t) + \bigl[1 - r\, r_E(t)\bigr] F_E\bigl(w_{EE} r_E(t) - w_{EI} r_I(t) + I_E(t) - a_E(t)\bigr),\]
\[\tau_I \frac{dr_I}{dt} = -r_I(t) + \bigl[1 - r\, r_I(t)\bigr] F_I\bigl(w_{IE} r_E(t) - w_{II} r_I(t) + I_I(t) - a_I(t)\bigr),\]
\[\tau_a^E \frac{da_E}{dt} = -a_E(t) + b_E\, r_E(t),\]
\[\tau_a^I \frac{da_I}{dt} = -a_I(t) + b_I\, r_I(t),\]

with the sigmoidal transfer function

\[F_j(x) = \frac{1}{1 + e^{-a_j (x - \theta_j)}} - \frac{1}{1 + e^{a_j \theta_j}},\quad j \in \{E, I\}.\]

Adaptation currents increase with population activity and subtract from the effective input, implementing spike-frequency adaptation observed in real neurons.

References

Examples

>>> import brainmass
>>> import brainunit as u
>>> model = brainmass.WilsonCowanAdaptiveStep(
...     in_size=100,
...     tau_aE=100.*u.ms,
...     b_E=0.1
... )
__init__(in_size, tau_E=Quantity(1., 'ms'), a_E=1.2, theta_E=2.8, tau_I=Quantity(1., 'ms'), a_I=1.0, theta_I=4.0, wEE=12.0, wIE=4.0, wEI=13.0, wII=11.0, r=1.0, tau_aE=Quantity(100., 'ms'), tau_aI=Quantity(80., 'ms'), b_E=0.1, b_I=0.08, noise_E=None, noise_I=None, rE_init=Constant(value=0.0), rI_init=Constant(value=0.0), aE_init=Constant(value=0.0), aI_init=Constant(value=0.0), method='exp_euler')[source]#
Parameters:
daE(aE, rE)[source]#

Right-hand side for the excitatory adaptation current.

Parameters:
  • aE (array-like) – Excitatory adaptation current (dimensionless).

  • rE (array-like) – Excitatory activity (dimensionless).

Returns:

Time derivative daE/dt with unit of 1/time.

Return type:

array-like

daI(aI, rI)[source]#

Right-hand side for the inhibitory adaptation current.

Parameters:
  • aI (array-like) – Inhibitory adaptation current (dimensionless).

  • rI (array-like) – Inhibitory activity (dimensionless).

Returns:

Time derivative daI/dt with unit of 1/time.

Return type:

array-like

derivative(state, t, E_ext, I_ext)[source]#

Compute derivatives for all four state variables.

Parameters:
  • state (tuple) – Tuple of (rE, rI, aE, aI) states.

  • t (float) – Current time.

  • E_ext (array-like or scalar) – External input to excitatory population.

  • I_ext (array-like or scalar) – External input to inhibitory population.

Returns:

Tuple of (drE/dt, drI/dt, daE/dt, daI/dt) derivatives.

Return type:

tuple

drE(rE, rI, aE, ext)[source]#

Right-hand side for the excitatory population with adaptation.

Parameters:
  • rE (array-like) – Excitatory activity (dimensionless).

  • rI (array-like) – Inhibitory activity (dimensionless).

  • aE (array-like) – Excitatory adaptation current (dimensionless).

  • ext (array-like or scalar) – External input to E.

Returns:

Time derivative drE/dt with unit of 1/time.

Return type:

array-like

drI(rI, rE, aI, ext)[source]#

Right-hand side for the inhibitory population with adaptation.

Parameters:
  • rI (array-like) – Inhibitory activity (dimensionless).

  • rE (array-like) – Excitatory activity (dimensionless).

  • aI (array-like) – Inhibitory adaptation current (dimensionless).

  • ext (array-like or scalar) – External input to I.

Returns:

Time derivative drI/dt with unit of 1/time.

Return type:

array-like

init_state(batch_size=None, **kwargs)[source]#

Initialize model states rE, rI, aE, and aI.

Parameters:

batch_size (int or None, optional) – Optional leading batch dimension. If None, no batch dimension is used. Default is None.

update(rE_inp=None, rI_inp=None)[source]#

Advance the system by one time step.

Parameters:
  • rE_inp (array-like or scalar or None, optional) – External input to the excitatory population. If None, treated as zero. If noise_E is set, its output is added.

  • rI_inp (array-like or scalar or None, optional) – External input to the inhibitory population. If None, treated as zero. If noise_I is set, its output is added.

Returns:

The updated excitatory activity rE with the same shape as the internal state.

Return type:

array-like

Notes

The method performs numerical integration for all 4 state variables (rE, rI, aE, aI) using the specified method (exp_euler by default).