I have encountered a conflict between the use of the variable time step method and instances of NetCon objects when using the extracellular mechanism. I found a workaround while writing this post but I decided to share my finding anyway.
The problem, materialised by the MWE below, is that when a NetCon objet is instantiated after the calls
Code: Select all
cvode_active(1)
cvode.maxstep(some_value)
If you execute the code below
Code: Select all
from neuron import h
h.load_file('stdrun.hoc')
# Create section
s = h.Section()
s.insert('hh')
s.insert('extracellular')
# Record time
t = h.Vector()
t.record(h._ref_t)
# Simulation parameters
h.tstop = 10.0
h.cvode_active(1)
h.cvode.maxstep(0.05)
# NetCon to record spike times
nc = h.NetCon(s(0.5)._ref_v, None, sec=s)
spikeTimes = h.Vector()
nc.record(spikeTimes)
# Run simulation
h.finitialize()
h.cvode.solve(h.tstop)
# Print time steps
for ti in t.to_python():
print ti
Notice that the gaps between two consecutive time points is sometimes way larger than 0.05./usr/local/bin/python /Users/ngreiner/Desktop/test.py
NEURON -- VERSION 7.5 master (c693a84) 2017-12-07
Duke, Yale, and the BlueBrain Project -- Copyright 1984-2016
See http://neuron.yale.edu/neuron/credits
0.0
0.0329775041477
0.0659550082954
0.131910016591
0.263820033182
0.527640066363
1.05528013273
1.43128916059
1.80729818845
2.18330721631
2.55931624417
3.31133429989
4.06335235562
4.81537041134
5.56738846706
6.31940652278
7.21133984489
8.103273167
8.9060131569
9.77325478068
10.0
Conversely, the problem does not arise when the NetCon instantiation is done before the calls
Code: Select all
cvode_active(1)
cvode.maxstep(some_value)
Code: Select all
from neuron import h
h.load_file('stdrun.hoc')
# Create section
s = h.Section()
s.insert('hh')
s.insert('extracellular')
# Record time
t = h.Vector()
t.record(h._ref_t)
# NetCon to record spike times
nc = h.NetCon(s(0.5)._ref_v, None, sec=s)
spikeTimes = h.Vector()
nc.record(spikeTimes)
# Simulation parameters
h.tstop = 10.0
h.cvode_active(1)
h.cvode.maxstep(0.05)
# Run simulation
h.finitialize()
h.cvode.solve(h.tstop)
# Print time steps
for ti in t.to_python():
print ti
Importantly, this difference of behavior is not observed when the extracellular mechanism is not included (you can verify it for yourself by replacing insert(‘extracellular’) by insert(‘pas’) in the previous code examples)./usr/local/bin/python /Users/ngreiner/Desktop/test.py
NEURON -- VERSION 7.5 master (c693a84) 2017-12-07
Duke, Yale, and the BlueBrain Project -- Copyright 1984-2016
See http://neuron.yale.edu/neuron/credits
0.0
0.0329775041477
0.0659550082954
0.131910016591
0.263820033182
0.313820033182
0.363820033182
0.413820033182
0.463820033182
0.513820033182
0.563820033182
0.613820033182
0.663820033182
0.713820033182
0.763820033182
0.813820033182
0.863820033182
0.913820033182
0.963820033182
1.01382003318
1.06382003318
1.11382003318
1.16382003318
1.21382003318
1.26382003318
1.31382003318
1.36382003318
1.41382003318
1.46382003318
.
.
.
9.16382003318
9.21382003318
9.26382003318
9.31382003318
9.36382003318
9.41382003318
9.46382003318
9.51382003318
9.56382003318
9.61382003318
9.66382003318
9.71382003318
9.76382003318
9.81382003318
9.86382003318
9.91382003318
9.96382003318
10.0
If anybody knows why this order is important, I’d be grateful to get an explanation.
With regards,
Nathan