-
Notifications
You must be signed in to change notification settings - Fork 4
Description
Description
In stimuli.py, we usually inject the stimuli with "continuous=1", which is linear interpolation.
stim_vec.play(seg.extracellular._ref_e, time_vec, 1)
But the points of time_vec and stim_vec out of the injection time window doesn't work as what we expect.
Ex:
time_vec=[ 0. 1.5 2. 2.5 3. 3.]
stim_vec =[ 0. 10. 0. 100. 10. 0.]
dt = 0.5, duration = 5
[ 0. 3.33333333 6.66666667 10. 0. 100. 10. 5. 5. 5. 5. ]
According to Neuron docs
When continuous is 1 then linear interpolation is used to define the values between time points. ... When a value is greater than the range of the t vector, linear extrapolation of the last two points is used instead of a constant last value. If a constant outside the range is desired, make sure the last two points have the same y value and have different t values (if the last two values are at the same time, the constant average will be returned).
To Reproduce
from neuron import h
h.load_file("stdrun.hoc")
sec = h.Section(name="sec")
sec.insert("extracellular")
seg = sec(0.5)
t1 = h.Vector([ 0., 1.5, 2., 2.5, 3., 3.])
v1 = h.Vector([ 0., 10., 0., 100., 10., 0])
v1.play(seg.extracellular._ref_e, t1, 1)
rec = h.Vector()
rec.record(seg.extracellular._ref_e)
h.dt = 0.5
h.finitialize()
h.continuerun(5)
print(rec.as_numpy())
[ 0. 3.33333333 6.66666667 10. 0.
100. 10. 5. 5. 5.
5. ]
Expected behavior
We should turn off interpolation, continuous=0, add the last point duration+dt with amp=0 to the vectors
from neuron import h
h.load_file("stdrun.hoc")
sec = h.Section(name="sec")
sec.insert("extracellular")
seg = sec(0.5)
t1 = h.Vector([ 0., 1.5, 2., 2.5, 3., 3.5])
v1 = h.Vector([ 0., 10., 0., 100., 10., 0])
v1.play(seg.extracellular._ref_e, t1, 0)
rec = h.Vector()
rec.record(seg.extracellular._ref_e)
h.dt = 0.5
h.finitialize()
h.continuerun(5)
print(rec.as_numpy())
[ 0. 0. 0. 0. 10. 0. 100. 10. 0. 0. 0.]
Acceptance criteria
- How does pulse stimulus interact with play?