The code doesn't have any syntax errors, but the behavior is not correct. Here is my code:
Code: Select all
class cell:
def __init__(self):
import neuron as ne
import nrn as n
self.ne = ne
self.n = n
def make_cell(self):
soma = self.soma = self.n.Section()
axon = self.axon = self.n.Section()
dend = self.dend = self.n.Section()
soma.L = 30
soma.nseg = 5
axon.L = 1000
axon.nseg = 30
dend.L = 100
dend.nseg = 10
axon.connect(soma,0.5,1)
dend.connect(soma)
soma.insert('pas')
axon.insert('hh')
dend.insert('pas')
self.vect = self.ne.Vector()
soma.push()
self.vect.record(self.ne.h.ref(soma(0.5).v))
self.ne.h.pop_section()
def run(self,tstop,v_init=-40):
print "Before sim " + str(self.soma(0.5).v)
self.ne.h.finitialize(v_init)
self.ne.h.fcurrent()
while self.ne.h.t < tstop:
self.ne.h.fadvance()
print "After sim " + str(self.soma(0.5).v)
c = cell()
c.make_cell()
c.run(1)
And here is the result of running it:
Code: Select all
NEURON -- VERSION 6.2.1002 (2037) 2008-03-26
Duke, Yale, and the BlueBrain Project -- Copyright 1984-2007
See http://www.neuron.yale.edu/credits.html
Added /Users/davidmorton/dendritetics/code to python's path
>>> from mycell import *
Before sim -65.0
After sim -75.4368941679
>>> c.vect
-65 -65 -65 -65 -65
-65 -65 -65 -65 -65
-65 -65 -65 -65 -65
-65 -65 -65 -65 -65
-65 -65 -65 -65 -65
-65 -65 -65 -65 -65
-65 -65 -65 -65 -65
-65 -65 -65 -65 -65
-65 -65
>>> c.ne.h.dt
0.025000000000000001
>>> c.soma(0.5).v
-75.43689416792887
As you can see, the vector is just recording the initialization value instead of the value throughout the simulation. Perhaps something is wrong with my run() procedure?