braintools.input.ramp#
- braintools.input.ramp(c_start, c_end, duration, t_start=None, t_end=None)#
Generate a linearly ramped input current.
Creates a current that changes linearly from a starting value to an ending value over a specified time window. The ramp can be increasing or decreasing, and can be confined to a portion of the total duration.
- Parameters:
c_start (
Array|ndarray|bool|number|bool|int|float|complex|Quantity) – The starting current amplitude. Supports current units.c_end (
Array|ndarray|bool|number|bool|int|float|complex|Quantity) – The ending current amplitude. Must have same units as c_start.duration (
Array|ndarray|bool|number|bool|int|float|complex|Quantity) – The total duration of the signal.t_start (
Array|ndarray|bool|number|bool|int|float|complex|Quantity|None) – Time point when the ramp begins. Before this, current is 0. Default is 0.t_end (
Array|ndarray|bool|number|bool|int|float|complex|Quantity|None) – Time point when the ramp ends. After this, current remains at c_end. Default is duration.
- Returns:
current – The ramped current array with shape (n_timesteps,).
- Return type:
ndarray or Quantity
- Raises:
UnitMismatchError – If c_start and c_end have different units.
Examples
>>> import brainunit as u >>> import brainstate >>> brainstate.environ.set(dt=0.1 * u.ms)
Simple linear ramp from 0 to 10 pA over 100 ms
>>> current = ramp( ... c_start=0 * u.pA, ... c_end=10 * u.pA, ... duration=100 * u.ms ... )
Decreasing ramp (10 to 0 pA)
>>> current = ramp( ... c_start=10 * u.pA, ... c_end=0 * u.pA, ... duration=100 * u.ms ... )
Ramp with delay and early stop
>>> current = ramp( ... c_start=0 * u.nA, ... c_end=5 * u.nA, ... duration=200 * u.ms, ... t_start=50 * u.ms, # Start ramping at 50 ms ... t_end=150 * u.ms # Stop ramping at 150 ms ... )
Negative to positive ramp
>>> current = ramp( ... c_start=-5 * u.pA, ... c_end=5 * u.pA, ... duration=100 * u.ms ... )
Slow ramp for adaptation studies
>>> current = ramp( ... c_start=0 * u.pA, ... c_end=20 * u.pA, ... duration=1000 * u.ms, ... t_start=100 * u.ms, ... t_end=900 * u.ms ... )
Ramp for I-V curve measurements
>>> current = ramp( ... c_start=-100 * u.pA, ... c_end=100 * u.pA, ... duration=500 * u.ms ... )
Sawtooth wave component
>>> current = ramp( ... c_start=0 * u.pA, ... c_end=10 * u.pA, ... duration=10 * u.ms, ... t_start=1 * u.ms, ... t_end=9 * u.ms ... )
Notes
The ramp is perfectly linear between t_start and t_end
Before t_start, the current is 0 (not c_start)
After t_end, the current remains at the value it reached
Unit consistency is enforced between c_start and c_end