Code: Select all
from neuron import h as nrn
nrn.load_file("nrngui.hoc")
def fi0():
global a
print "fi0() called after v set but before INITIAL blocks"
print " a.v=%g a.m_hh=%g\n" %(a.v, a.m_hh)
a.v = 10
def fi1():
print "fi1() called after INITIAL blocks but before BREAKPOINT blocks"
print " or variable step initialization."
print " Good place to change any states."
print " a.v=%g a.m_hh=%g\n" %(a.v, a.m_hh)
print " b.v=%g b.m_hh=%g\n" %(b.v, b.m_hh)
b.v = 10
def fi2():
print "fi2() called after everything initialized. Just before return"
print " from finitialize."
print " Good place to record or plot initial values"
print " a.v=%g a.m_hh=%g\n" %(a.v, a.m_hh)
print " b.v=%g b.m_hh=%g\n" %(b.v, b.m_hh)
class Test:
def __init__(self):
self.fih = nrn.FInitializeHandler(1, self.p)
def p(self):
print "inside %s.p()\n" %self
fih = []
fih.append(nrn.FInitializeHandler(0, fi0))
fih.append(nrn.FInitializeHandler(1, fi1))
fih.append(nrn.FInitializeHandler(2, fi2))
a = nrn.Section(name='a')
b = nrn.Section(name='b')
for sec in nrn.allsec():
sec.insert('hh')
for sec in nrn.allsec():
nrn.psection(sec)
test = Test()
nrn.stdinit()
fih[0].allprint()