braintools.input.ExponentialDecay#
- class braintools.input.ExponentialDecay(amplitude, tau, duration, t_start=None, t_end=None)#
Generate exponentially decaying input.
Creates an input that decays exponentially from an initial amplitude. This is useful for modeling synaptic currents, adaptation processes, or any phenomenon with exponential relaxation.
- Parameters:
amplitude (
float) – Initial amplitude at the start of decay. Can include units.tau (
Array|ndarray|bool|number|bool|int|float|complex|Quantity) – Decay time constant. The amplitude decreases to ~37% (1/e) after tau.duration (
Array|ndarray|bool|number|bool|int|float|complex|Quantity) – Total duration of the input signal.t_start (
Array|ndarray|bool|number|bool|int|float|complex|Quantity|None) – Start time of the decay. Default is 0.t_end (
Array|ndarray|bool|number|bool|int|float|complex|Quantity|None) – End time of the decay. Default is duration.
See also
DoubleExponentialFor rise and decay dynamics.
GaussianPulseFor symmetric pulse shapes.
Notes
The decay follows: amplitude * exp(-t/tau) for t >= 0. After time tau, the amplitude is reduced to amplitude/e ≈ 0.368*amplitude. After 3*tau, it’s reduced to ~5% of initial value. This class uses the functional exponential_decay API internally.
Examples
Simple exponential decay:
>>> decay = ExponentialDecay( ... amplitude=2.0 * u.nA, ... tau=30 * u.ms, ... duration=200 * u.ms ... ) >>> array = decay()
Delayed decay (starts at t=50ms):
>>> decay = ExponentialDecay( ... amplitude=1.5, ... tau=20 * u.ms, ... duration=150 * u.ms, ... t_start=50 * u.ms ... )
Gated decay with step function:
>>> from braintools.input import Step >>> decay = ExponentialDecay(2.0, 30 * u.ms, 500 * u.ms, t_start=100 * u.ms) >>> step = Step([0, 1], [0, 100] * u.ms, 500 * u.ms) >>> gated_decay = decay * step # Gate the decay
Multiple decay phases:
>>> fast_decay = ExponentialDecay(1.0, 10 * u.ms, 200 * u.ms) >>> slow_decay = ExponentialDecay(0.5, 50 * u.ms, 200 * u.ms) >>> combined = fast_decay + slow_decay # Bi-exponential
Adaptation current simulation:
>>> # Triggered by step input >>> from braintools.input import Step >>> trigger = Step([0, 1, 0], [0, 50, 150] * u.ms, 300 * u.ms) >>> adaptation = ExponentialDecay(0.3, 40 * u.ms, 300 * u.ms, t_start=50 * u.ms) >>> net_current = trigger - adaptation # Adaptation reduces input
Repeated decay pattern:
>>> single_decay = ExponentialDecay(1.0, 15 * u.ms, 50 * u.ms) >>> decay_train = single_decay.repeat(10) # 500ms total
Synaptic depression model:
>>> # Each spike triggers smaller response >>> amplitudes = [1.0, 0.8, 0.6, 0.4] # Decreasing amplitudes >>> times = [0, 50, 100, 150] # Spike times >>> decays = [] >>> for amp, t in zip(amplitudes, times): ... decays.append(ExponentialDecay(amp, 20 * u.ms, 200 * u.ms, t_start=t * u.ms)) >>> depressing_response = sum(decays[1:], decays[0])
- __init__(amplitude, tau, duration, t_start=None, t_end=None)[source]#
Initialize exponential decay.
- Parameters:
amplitude (
float) – Initial amplitude of the decay.tau (
Array|ndarray|bool|number|bool|int|float|complex|Quantity) – Decay time constant.duration (
Array|ndarray|bool|number|bool|int|float|complex|Quantity) – Total duration of the input.t_start (
Array|ndarray|bool|number|bool|int|float|complex|Quantity|None) – Start time of the decay. Default is 0.t_end (
Array|ndarray|bool|number|bool|int|float|complex|Quantity|None) – End time of the decay. Default is duration.
Methods
__init__(amplitude, tau, duration[, ...])Initialize exponential decay.
apply(func)Apply a custom function to the input.
clip([min_val, max_val])Clip the input values to a range.
generate()Generate the exponential decay array using functional API.
repeat(n_times)Repeat the input pattern n times.
scale(factor)Scale the input by a factor.
shift(time_shift)Shift the input in time.
smooth(tau)Apply exponential smoothing to the input.
Attributes
dtGet the time step from global environment.
n_stepsGet the number of time steps.
shapeGet the shape of the input array.