Theta neurons and QIF networks
A network of theta neurons coupled all to all.
- Class:
ThetaNeuronsSystem - Import:
from skcomplex.systems.biology.neuroscience import ThetaNeuronsSystem - Field:
biology/neuroscience - Topics:
neuron,phase oscillators,mean field,network - References:
- Ermentrout and Kopell 1986
- Luke, Barreto, and So 2013
- arXiv:1902.05307
Use this system
The block imports the class and simulates the system with its default parameters and its tuned run settings.
from skcomplex.systems.biology.neuroscience import ThetaNeuronsSystem
trajectory = ThetaNeuronsSystem().prepare().simulate()
Parameters
The model parameters take these defaults, and set_params changes them.
| Parameter | Default |
|---|---|
n_neurons |
50 |
eta |
-0.2 |
delta |
0.1 |
kappa |
1.5 |
n |
2 |
random_state |
0 |
solver |
'auto' |
backend |
'auto' |
Tags
The system with its default parameters has these capability tags, which solvers and analyses check.
| Tag | Values |
|---|---|
| Time | continuous |
| Space | none |
| Laws | rate |
| Randomness | deterministic |
| Domains | real |
| Structure | fixed |
Class
The source of the class shows how it builds its components from its model parameters.
class ThetaNeuronsSystem(BaseSystem):
"""A network of theta neurons coupled all to all.
Theta neurons are equivalently quadratic integrate-and-fire neurons.
Neuron `i` follows `theta_i' = (1 - cos theta_i) + (1 + cos theta_i)(eta_i + kappa I)`, where `I` is the mean pulse
`a_n (1 - cos theta_j)^n` of all neurons at the current state. The excitabilities are evenly spaced quantiles of a
Lorentzian distribution of center `eta` and half-width `delta`, the distribution for which Ott and Antonsen's ansatz
reduces the network exactly to one complex equation. Strong excitatory coupling switches the network from a quiet
state to collective firing. The system has the phases `neurons.theta` as its only state.
Args:
n_neurons:
The number of neurons.
eta:
The center of the excitabilities.
delta:
The half-width of the excitabilities.
kappa:
The coupling strength.
n:
The sharpness of the pulses, a positive integer.
random_state:
The seed or generator of the initial phases.
label:
The label of the system, which names it when it is nested in another one.
solver:
The solver of the problem, or `'auto'` for the one the system chooses.
backend:
The backend that evaluates the compiled functions, or `'auto'` for the one the system chooses.
Examples:
>>> from skcomplex.systems.biology.neuroscience import ThetaNeuronsSystem
>>> ThetaNeuronsSystem(20).prepare().system_.elements[0].size
20
"""
field = 'biology/neuroscience'
topics = ('neuron', 'phase oscillators', 'mean field', 'network')
references = ('Ermentrout and Kopell 1986', 'Luke, Barreto, and So 2013', 'arXiv:1902.05307')
until = 20.0
dt = 0.1
def __init__(
self,
n_neurons: int = 50,
*,
eta: float = -0.2,
delta: float = 0.1,
kappa: float = 1.5,
n: int = 2,
random_state: int | np.random.Generator | None = 0,
label: str = 'system',
solver: BaseSolver | str = 'auto',
backend: BaseBackend | str = 'auto',
) -> None:
super().__init__(label, solver=solver, backend=backend)
self.n_neurons = n_neurons
self.eta = eta
self.delta = delta
self.kappa = kappa
self.n = n
self.random_state = random_state
@staticmethod
def _get_lorentzian_quantiles(center: float, width: float, size: int) -> list[float]:
"""Return evenly spaced quantiles of a Lorentzian distribution."""
levels = (np.arange(size) + 0.5) / size
return [float(value) for value in center + width * stats.cauchy.ppf(levels)]
def _prepare(self, context: Sequence[Observable] | None = None) -> None:
"""Set the system of a network of theta neurons.
Args:
context:
The observables to compile with the problem, or `None` for none.
"""
super()._prepare(context)
phases = np.random.default_rng(self.random_state).uniform(0.0, 2 * math.pi, self.n_neurons)
neurons = ThetaNeuronElement(
'neurons',
theta=phases,
eta=np.asarray(self._get_lorentzian_quantiles(self.eta, self.delta, self.n_neurons)),
size=self.n_neurons,
)
self.system_ = System(
self.label,
elements=[neurons],
interactions=[
ThetaNeuronInteraction('phases', target='neurons'),
PulseCouplingInteraction('coupling', neurons='neurons', kappa=self.kappa, n=self.n),
],
)
Components
The system uses these element and interaction classes, each with its nearest class of the core.
Elements:
ThetaNeuronElement, fromElement
Interactions:
ThetaNeuronInteraction, fromInteractionPulseCouplingInteraction, fromInteraction
class ThetaNeuronElement(Element):
"""Theta neurons, each with a phase `theta` that wraps around and an excitability `eta`.
Args:
label:
The label of the neuron or the group.
theta:
The initial phase, one per neuron or shared.
eta:
The excitability, one per neuron or shared.
size:
The number of neurons, or `None` for one.
space:
The space whose sites hold one neuron each, such as a network, or `None` for none.
Examples:
>>> from skcomplex.systems.biology.neuroscience import ThetaNeuronElement
>>> ThetaNeuronElement('neurons', eta=0.5, size=10).size
10
"""
def __init__(
self,
label: str,
*,
theta: Annotated[float | Array, Period(2 * math.pi)] = 0.0,
eta: float | Array = 1.0,
size: int | None = None,
space: BaseSpace | None = None,
) -> None:
super().__init__(label, size=size, space=space)
self.theta = theta
self.eta = eta
class ThetaNeuronInteraction(Interaction):
"""Phase dynamics of theta neurons, `theta' = (1 - cos theta) + (1 + cos theta) eta`.
The neuron fires when its phase passes π. With `eta > 0` it fires periodically with period `π / sqrt(eta)`, and
with `eta < 0` it is excitable. The change of variable `V = tan(theta / 2)` turns it into the quadratic
integrate-and-fire neuron `V' = V² + eta`.
Args:
label:
The label of the interaction.
target:
The path of the neurons, whose values are `theta` and `eta`.
Examples:
>>> from skcomplex.systems.biology.neuroscience import ThetaNeuronInteraction
>>> ThetaNeuronInteraction('phases', target='neurons').target
'neurons'
"""
law_classes = (RateLaw,)
def __init__(self, label: str, *, target: Role) -> None:
super().__init__(label)
self.target = target
def _prepare(self, context: SimpleNamespace) -> None:
"""Set the phase dynamics of the target.
Args:
context:
The namespace of the target, the time `t`, and the parameters.
"""
super()._prepare(context)
theta, eta = context.target.theta, context.target.eta
self.laws_ = [RateLaw(theta, 1 - cos(theta) + (1 + cos(theta)) * eta)]
class PulseCouplingInteraction(Interaction):
"""Global coupling of theta neurons through the mean of their pulses.
Every neuron emits smooth pulses.
Every neuron receives the current `(1 + cos theta) kappa I`, where `I = mean_j a_n (1 - cos theta_j)^n` is the mean
pulse of all neurons at the current state. The pulse peaks when a neuron fires, and `a_n` gives it a unit mean over
the phase. With `kappa > 0` the coupling is excitatory.
Args:
label:
The label of the interaction.
neurons:
The path of the group of theta neurons.
kappa:
The coupling strength.
n:
The sharpness of the pulses, a positive integer.
Examples:
>>> from skcomplex.systems.biology.neuroscience import PulseCouplingInteraction
>>> PulseCouplingInteraction('coupling', neurons='neurons', kappa=2.0).kappa
2.0
"""
law_classes = (RateLaw,)
def __init__(
self,
label: str,
*,
neurons: Role,
kappa: float = 1.0,
n: int = 2,
) -> None:
super().__init__(label)
self.neurons = neurons
self.kappa = kappa
self.n = n
def _prepare(self, context: SimpleNamespace) -> None:
"""Set the current of the mean pulse into every neuron.
Args:
context:
The namespace of the symbols the laws can use.
"""
super()._prepare(context)
s = context
theta = s.neurons.theta
normalization = 2**self.n * math.factorial(self.n) ** 2 / math.factorial(2 * self.n)
pulses = mean(normalization * (1 - cos(theta)) ** self.n)
self.laws_: list[BaseLaw] = [RateLaw(theta, (1 + cos(theta)) * s.kappa * pulses)]
Equations
The equations are those that symbolic returns for the system with its default parameters.
neurons.theta[i]: diff(theta_neurons(t), t) == _reduced_0*kappa_coupling*(cos(theta_neurons(t)) + 1) + eta_neurons*(cos(theta_neurons(t)) + 1) - cos(theta_neurons(t)) + 1