When trying out a ball-and-stick model, one written using nrnpython and the other using HOC, I get different results from each of them. I think I have written the equivalent code statements in each example, and I can't see what is going wrong. The codes are below, and I can send the files also if it's easier that way. A remark: when changing the 'connect' statement in the nrnpython version with the one in the comment after it, the result is more similar to the one gotten with HOC (the measurement from the soma still differs).
If someone has the time to look at this and give an opinion, that would be great! (I have been looking at this code for so long, I can't see the mistake(s) anymore.)
Thank you,
Daniel
Code in Python
Code: Select all
from neuron import h
import matplotlib.pyplot as plt
import numpy as np
import seaborn as sns
soma = h.Section()
dend = h.Section()
soma.L = 10
soma.diam = 10
soma.Ra = 1000
soma.insert('pas')
soma.g_pas = 1e-5
soma.cm = 1
dend.L = 200
dend.nseg = 47
dend.diam = 3
dend.Ra = 1000
dend.insert('pas')
dend.g_pas = 1e-3
dend.cm = 1
dend.connect(soma(0), 0) # dend.connect(soma(0), 1)
istim = h.IClamp(1.0, dend)
istim.amp = 0.2
istim.delay = 100
istim.dur = 30
vdlist = []
vdlist.append(h.Vector())
vdlist.append(h.Vector())
vdlist.append(h.Vector())
vs = h.Vector()
t = h.Vector()
vdlist[0].record(dend(1.0)._ref_v)
vdlist[1].record(dend(0.5)._ref_v)
vdlist[2].record(dend(0.0)._ref_v)
vs.record(soma(0.5)._ref_v)
t.record(h._ref_t)
h.load_file("stdrun.hoc")
h.init()
h.tstop = 200
h.run()
# Plotting code from here
rows = 2
fig = plt.figure();
plot_num = 1;
ax2 = fig.add_subplot(rows, 1, plot_num); plot_num += 1;
ax2.set_ylabel('Vd')
ax2.set_xlabel('t')
ax2.xaxis.set_ticks(np.arange(0, h.tstop, 10))
plt.hold(True)
ax2.plot(t, vdlist[0],'b')
ax2.plot(t, vdlist[1],'g')
ax2.plot(t, vdlist[2],'r')
ax2.legend(['dend(1.0)','dend(0.5)','dend(0.0)'])
ax3 = fig.add_subplot(rows, 1, plot_num); plot_num += 1;
ax3.set_ylabel('Vs')
ax3.set_xlabel('t')
ax3.plot(t, vs)
sns.set_context(font_scale = 5.0)
plt.show()
Code: Select all
create soma, dend
access soma
soma.L = 10
soma.diam = 10
soma.Ra = 1000
soma insert pas
soma.g_pas = 1e-5
soma.cm = 1
dend.L = 200
dend.nseg = 47
dend.diam = 3
dend.Ra = 1000
dend insert pas
dend.g_pas = 1e-3
dend.cm = 1
connect dend(0), soma(0)
objectvar istim
dend istim = new IClamp(1.0)
istim.amp = 0.2
istim.del = 100
istim.dur = 30
objref vdlist[3], vs, time
vdlist[0] = new Vector()
vdlist[1] = new Vector()
vdlist[2] = new Vector()
vs = new Vector()
time = new Vector()
vdlist[0].record(&dend.v(1.0))
vdlist[1].record(&dend.v(0.5))
vdlist[2].record(&dend.v(0.0))
vs.record(&soma.v(0.5))
time.record(&t)
load_file("stdrun.hoc")
init()
tstop = 200
run()
//At this point I use the plotting tools from nrngui to see the results.