FitzHugh-Nagumo ODE
The FitzHugh-Nagumo neuron.
- Class:
FitzhughNagumoODESystem - Import:
from skcomplex.systems.biology.neuroscience import FitzhughNagumoODESystem - Field:
biology/neuroscience - Topics:
neuron,excitability,relaxation oscillations - References:
- FitzHugh 1961
- Nagumo, Arimoto, and Yoshizawa 1962
- Trzaska 2023
- Datseris and Parlitz 2022
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 FitzhughNagumoODESystem
trajectory = FitzhughNagumoODESystem().prepare().simulate()
Parameters
The model parameters take these defaults, and set_params changes them.
| Parameter | Default |
|---|---|
v |
-1.2 |
w |
-0.6 |
a |
0.7 |
b |
0.8 |
epsilon |
0.08 |
I |
0.5 |
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 FitzhughNagumoODESystem(BaseSystem):
"""The FitzHugh-Nagumo neuron.
It is the two-variable reduction of Hodgkin and Huxley's excitable membrane.
Without current the neuron rests on a stable fixed point and answers a large enough kick with one spike. A current
`I` between about 0.33 and 1.42 destabilizes the rest and the neuron fires periodically. The system has the
potential `neuron.v` and the recovery `neuron.w`.
Args:
v:
The initial potential.
w:
The initial recovery.
a:
The offset of the recovery.
b:
The damping of the recovery.
epsilon:
The time scale of the recovery.
I:
The applied current.
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 FitzhughNagumoODESystem
>>> FitzhughNagumoODESystem(I=0.0).prepare().system_.interactions[0].I
0.0
"""
field = 'biology/neuroscience'
topics = ('neuron', 'excitability', 'relaxation oscillations')
references = ('FitzHugh 1961', 'Nagumo, Arimoto, and Yoshizawa 1962', 'Trzaska 2023', 'Datseris and Parlitz 2022')
until = 100.0
dt = 0.2
def __init__(
self,
v: float = -1.2,
w: float = -0.6,
*,
a: float = 0.7,
b: float = 0.8,
epsilon: float = 0.08,
I: float = 0.5,
label: str = 'system',
solver: BaseSolver | str = 'auto',
backend: BaseBackend | str = 'auto',
) -> None:
super().__init__(label, solver=solver, backend=backend)
self.v = v
self.w = w
self.a = a
self.b = b
self.epsilon = epsilon
self.I = I
def _prepare(self, context: Sequence[Observable] | None = None) -> None:
"""Set the system of the FitzHugh-Nagumo neuron.
Args:
context:
The observables to compile with the problem, or `None` for none.
"""
super()._prepare(context)
kinetics = FitzHughNagumoInteraction(
'kinetics',
target='neuron',
a=self.a,
b=self.b,
epsilon=self.epsilon,
I=self.I,
)
self.system_ = System(
self.label,
elements=[FitzHughNagumoNeuronElement('neuron', v=self.v, w=self.w)],
interactions=[kinetics],
)
Components
The system uses these element and interaction classes, each with its nearest class of the core.
Elements:
FitzHughNagumoNeuronElement, fromElement
Interactions:
FitzHughNagumoInteraction, fromInteraction
class FitzHughNagumoNeuronElement(Element):
"""FitzHugh-Nagumo neuron, with a fast potential `v` and a slow recovery `w`.
The neuron has no laws of its own. FitzHugh-Nagumo kinetics change it.
Args:
label:
The label of the neuron.
v:
The initial potential.
w:
The initial recovery.
Examples:
>>> from skcomplex.systems.biology.neuroscience import FitzHughNagumoNeuronElement
>>> FitzHughNagumoNeuronElement('neuron').w
-0.6
"""
def __init__(
self,
label: str,
*,
v: float = -1.2,
w: float = -0.6,
) -> None:
super().__init__(label)
self.v = v
self.w = w
class FitzHughNagumoInteraction(Interaction):
"""FitzHugh-Nagumo kinetics of a fast variable `v` and a slow recovery `w`.
The fast variable and the recovery are states of a target.
The fast variable follows `v' = v - v³/3 - w + I` and the recovery `w' = epsilon (v + a - b w)`. On a field the
kinetics act on every cell, and a diffusion of the fast variable makes the medium excitable.
Args:
label:
The label of the interaction.
target:
The path of the element or field whose states follow the kinetics.
fast:
The name of the fast state, such as a membrane potential.
slow:
The name of the slow recovery state.
a:
The offset of the recovery.
b:
The damping of the recovery.
epsilon:
The time scale of the recovery.
I:
The applied current.
Raises:
ValidationError:
A state name is not a name, or the fast and the slow state are the same.
Examples:
>>> from skcomplex.core.components.elements import Element
>>> from skcomplex.core.systems import System
>>> from skcomplex.systems.biology.common.excitable import FitzHughNagumoInteraction
>>> kinetics = FitzHughNagumoInteraction('kinetics', target='cell', I=0.5)
>>> cell = Element('cell', values={'v': -1.2, 'w': -0.6})
>>> system = System(elements=[cell], interactions=[kinetics]).prepare()
>>> trajectory = system.simulate(100.0, dt=0.1)
>>> bool(trajectory.get_values('cell.v').max() > 1.5)
True
"""
law_classes = (RateLaw,)
def __init__(
self,
label: str,
*,
target: Role,
fast: str = 'v',
slow: str = 'w',
a: float = 0.7,
b: Annotated[float, RealSet.closed_open(0, oo)] = 0.8,
epsilon: Annotated[float, RealSet.open(0, oo)] = 0.08,
I: float = 0.0,
) -> None:
super().__init__(label)
self.target = target
self.fast = fast
self.slow = slow
self.a = a
self.b = b
self.epsilon = epsilon
self.I = I
def _check_arguments(self) -> None:
"""Raise an error for an argument the interaction cannot take.
Raises:
ValidationError:
A state name is not a name, or the fast and the slow state are the same.
"""
super()._check_arguments()
names = (self.fast, self.slow)
if not all(isinstance(name, str) and name.isidentifier() for name in names) or self.fast == self.slow:
error_msg = f'{self.label!r} reads the states {names!r}. Give two different names of states.'
raise ValidationError(error_msg)
def _prepare(self, context: SimpleNamespace) -> None:
"""Set the cubic fast kinetics and the slow linear recovery.
Args:
context:
The namespace of the target.
"""
super()._prepare(context)
v, w, t = getattr(context.target, self.fast), getattr(context.target, self.slow), context.t
self.laws_: list[BaseLaw] = [
RateLaw(v.diff(t), v - v**3 / 3 - w + context.I),
RateLaw(w.diff(t), context.epsilon * (v + context.a - context.b * w)),
]
Equations
The equations are those that symbolic returns for the system with its default parameters.
neuron.v: diff(v_neuron(t), t) == -1/3*v_neuron(t)^3 + I_kinetics + v_neuron(t) - w_neuron(t)
neuron.w: diff(w_neuron(t), t) == -(b_kinetics*w_neuron(t) - a_kinetics - v_neuron(t))*epsilon_kinetics