LinearStep#
- class brainmass.LinearStep(in_size, gamma=-10.0, init_x=Constant(value=0.01), noise_x=None, method='exp_euler')#
Linear neural-mass node with damping (TVB
Linearmodel).A single-state linear model with a damping coefficient, used in The Virtual Brain as a canonical baseline for validating simulation pipelines and network coupling without nonlinear complications [1]. Despite its simplicity it is a genuine network node: the long-range and local coupling enter additively.
\[\frac{dx}{dt} = \gamma\,x + c,\]where \(x\) is the (dimensionless) node activity, \(\gamma\) the damping coefficient, and \(c\) the summed coupling/external input. For a stable node \(\gamma\) must be negative and its magnitude should exceed the node’s in-degree; with \(c = 0\) the activity relaxes exponentially, \(x(t) = x_0 e^{\gamma t}\).
This is distinct from
ThresholdLinearStep, which is a two-population (E/I) threshold-linear rate model.- Parameters:
in_size (
int|Sequence[int] |integer|Sequence[integer]) – Spatial shape of the node. Anintor tuple ofint;gammabroadcasts to this shape.gamma (
Callable|Array|ndarray|bool|number|bool|int|float|complex|Quantity|Param) – Damping coefficient (dimensionless). Must be negative for stability. Default is-10.0.init_x (
Callable) – Initializer for the activity statex. Default isbraintools.init.Constant(0.01).noise_x (
Noise) – Additive noise process. If provided, its output is added to the inputx_inpat each update. Default isNone.method (
str) – Integration method,'exp_euler'(default) or anybraintools.quadmethod (e.g.'rk4'). The exponential-Euler step is exact for this linear system.
- Return type:
Any
- x#
Node activity (dimensionless). Shape
(batch?,) + in_size.- Type:
brainstate.HiddenState
Notes
The state is dimensionless and
dx()carries unit1/ms, so an exponential-Euler step withdtin milliseconds is consistent (the convention shared by the other*Stepmodels in this package).References
Examples
>>> import brainmass >>> import brainstate >>> import brainunit as u >>> model = brainmass.LinearStep(in_size=1, gamma=-5.0) >>> _ = brainstate.nn.init_all_states(model) >>> with brainstate.environ.context(dt=0.1 * u.ms): ... x = model.update() >>> x.shape (1,)
- __init__(in_size, gamma=-10.0, init_x=Constant(value=0.01), noise_x=None, method='exp_euler')[source]#
- dx(x, x_inp)[source]#
Right-hand side for the activity
x.- Parameters:
x (array-like) – Current activity (dimensionless).
x_inp (array-like or scalar) – Summed coupling/external input (includes noise if enabled).
- Returns:
Time derivative
dx/dtwith unit1/ms.- Return type:
array-like
- init_state(batch_size=None, **kwargs)[source]#
Allocate the activity state
x.- Parameters:
batch_size (int or None, optional) – Optional leading batch dimension. If
None, no batch dimension is used. Default isNone.
- update(x_inp=None)[source]#
Advance the node by one time step.
- Parameters:
x_inp (array-like or scalar or None, optional) – Summed coupling/external input. If
None, treated as zero. Ifnoise_xis set, its output is added. Default isNone.- Returns:
The updated activity
x, same shape as the internal state.- Return type:
array-like