I recently have had to do some filtering and additional processing of my model output that I didn't need to do before and now need to save my recorded data using a fixed timestep. However, I have a dramatic improvement in execution time using cvode compared to using a fixed timestep and I would like to preserve this efficiency if possible.
Reading the NEURON Vector().record() documentation it seems like my two options are providing a Dt value to determine the regular interval at which our data will be recorded
Code: Select all
vdest = vdest.record(var_reference, Dt)
Code: Select all
vdest = vdest.record(var_reference, tvec)
In a Jupyter Notebook I used the magic command %%timeit to check the execution time of a simple simulation using a fixed timestep and using cvode along with providing the Dt argument.
Code: Select all
%%timeit
sec1 = h.Section(name="sec1")
sec1.insert(h.hh)
stim = h.IClamp(sec1(0))
stim.delay = 5
stim.dur = 1
stim.amp = 0.5
v_fixed = h.Vector().record(sec1(0.5)._ref_v, dt)
t_fixed = t = h.Vector().record(h._ref_t, dt)
h.cvode.active(True)
h.finitialize()
h.continuerun(run_time)
Code: Select all
%%timeit
sec2 = h.Section(name="sec2")
sec2.insert(h.hh)
stim = h.IClamp(sec2(0))
stim.delay = 5
stim.dur = 1
stim.amp = 0.5
h.cvode.active(False)
h.dt = 0.1
v_fixed = h.Vector().record(sec2(0.5)._ref_v)
t_fixed = t = h.Vector().record(h._ref_t)
h.finitialize()
h.continuerun(run_time)
As a sanity check I also checked to see if providing a time Vector provided a benefit versus providing a Dt and it did not which was expected. So it seems my performance boost is slightly lost which, unless I am ignorant of something, makes sense because I'm assuming that my system of equations need to be solved at the provided time values based on Dt which essentially means I am using a fixed time step.
I also looked into h.cvode.record versus Vector().record() in case that would provide a performance boost but with the following code I got the following error and couldn't discern what to fix from the error message (likely syntax I'm guessing).
Code: Select all
%%timeit
sec4 = h.Section(name="sec4")
sec4.insert(h.hh)
stim = h.IClamp(sec4(0))
stim.delay = 5
stim.dur = 1
stim.amp = 0.5
h.cvode.active(True)
dt = 0.1
fixed_time_vec = np.arange(0,500 + dt, dt)
fixed_time_vec = h.Vector(fixed_time_vec)
v_fixed = h.Vector()
h.cvode.record(sec4(0.5)._ref_v, v_fixed, fixed_time_vec)
h.finitialize()
h.continuerun(run_time)
NEURON: Cvode.record pointer not associated with currently accessed section
Use section ... (&var(x)...) intead of ...(§ion.var(x)...)
near line 0
^
CVode[0].record(..., ..., ...)
---------------------------------------------------------------------------
RuntimeError Traceback (most recent call last)
Cell In[112], line 11
9 fixed_time_vec = h.Vector(fixed_time_vec)
10 v_fixed = h.Vector()
---> 11 h.cvode.record(sec4(0.5)._ref_v, v_fixed, fixed_time_vec)
12 h.finitialize()
13 h.continuerun(run_time)
RuntimeError: hocobj_call error
If anyone could let me know if I am going about this in the best way that would be greatly appreciated.