Off-by-a-bit timing problem with NetStim.noise = 0

Anything that doesn't fit elsewhere.
Post Reply
JustasB
Posts: 28
Joined: Tue Dec 08, 2015 8:17 pm
Location: Tempe, AZ, USA
Contact:

Off-by-a-bit timing problem with NetStim.noise = 0

Post by JustasB »

Should NetStim events not be expected to be exact when noise=0? I observe the following dt dependent variations in the event timing with noise = 0.

After running the following:

Code: Select all

from neuron import h,gui

t = []
def collect():
   t.append(h.t)

ns = h.NetStim(0.5)
ns.start = 0
ns.interval = 1
ns.number = 1e9
ns.noise = 0

nc = h.NetCon(ns,None)
nc.record(collect)
h.steps_per_ms = 1.0
h.dt = 1/h.steps_per_ms
h.tstop = 10
h.run()
t
I observe the mostly expected, once-per-ms event times (note the two '0.0's)

Code: Select all

[0.0, 0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0]
However, then after changing the dt:

Code: Select all

t = []
h.steps_per_ms = 16.0
h.dt = 1/h.steps_per_ms
h.run()
t
I see the following:

Code: Select all

[0.0, 0.9999999999999984, 1.999999999999995, 2.9750000000000085, 3.9750000000000227, 4.975000000000037, 5.975000000000051, 6.975000000000065, 7.97500000000008, 8.975000000000025]
Similar results with other dt < 1.0 ms.

I do get the expected exact timing when cvode.active(1), but not with active(0).

Is this by design or a bug?

Neither NetStim docs https://www.neuron.yale.edu/neuron/stat ... ml#NetStim nor a search on this forum speak to this issue.

Update:
With dt = 0.5, it appears that the timings are off by 1 dt for all events with t>0:

Code: Select all

h.steps_per_ms = 2.0
h.dt = 1/h.steps_per_ms

Code: Select all

[0.0, 0.5, 1.5, 2.5, 3.5, 4.5, 5.5, 6.5, 7.5, 8.5, 9.5]
hines
Site Admin
Posts: 1687
Joined: Wed May 18, 2005 3:32 pm

Re: Off-by-a-bit timing problem with NetStim.noise = 0

Post by hines »

That was a bug. t was not being updated to correspond to the event time (ParallelContext.t(0) was updated). This is fixed by
https://github.com/nrnhines/nrn/commit/ ... 7ae3132c20
Now should also work with threads (but if cvode is active, do not change values, just record).
JustasB
Posts: 28
Joined: Tue Dec 08, 2015 8:17 pm
Location: Tempe, AZ, USA
Contact:

Re: Off-by-a-bit timing problem with NetStim.noise = 0

Post by JustasB »

Thank you
Post Reply