Code: Select all
nc=new NetCon(nil, syn)
Code: Select all
nc=h.NetCon(None,syn)
Code: Select all
h("nc = new NetCon(nil,syn)")
nc=h.nc
Moderator: hines
Code: Select all
nc=new NetCon(nil, syn)
Code: Select all
nc=h.NetCon(None,syn)
Code: Select all
h("nc = new NetCon(nil,syn)")
nc=h.nc
because you forgoterror "hoc.HocObject' object has no attribute 'nc'"
Code: Select all
from neuron import h, gui
soma=h.Section()
soma.insert('pas')
syn=h.ExpSyn(soma(0.5))
#create netcon
h("objref nil")
nil=h.nil
nc=h.NetCon(nil,syn)
nc.weight[0]=1.0
#prescribe synaptic event to occur
nc.event(30)
h.tstop = 60 #ms
h.run()
#(code for plotting omitted)
Code: Select all
$ nrniv -python -
NEURON -- VERSION 7.5 (1512:e0bd0137f04c) 2017-01-30
Duke, Yale, and the BlueBrain Project -- Copyright 1984-2016
See http://neuron.yale.edu/neuron/credits
>>> from neuron import h
>>> h.allobjects("CVode")
0.0
Code: Select all
$ nrngui -python
. . .
>>> from neuron import h
>>> h.allobjects("CVode")
CVode[0] with 2 refs
Code: Select all
$ nrniv -python
. . .
>>> from neuron import h, gui
>>> h.allobjects("CVode")
CVode[0] with 2 refs
Code: Select all
objref fih
fih = new FInitializeHandler("nc.event(1)")
Code: Select all
fih = h.FInitializeHandler('nrnpython("nc.event(1)")')
Among other things, it makes hoc execute the contents of nrn/share/nrn/lib/hoc/stdrun.hoc . Read the first few statements of that file and you'll see the one that creates a CVode instance. That statement is there because some features of NEURON require an instance of CVode to exist (for reasons too complex and irrelevant to go into here).pascal wrote:why importing gui automatically creates an instance of CVode.
Part of what you "know" is correct and part appears to be misinterpretation of the documentation (which is often rather opaque). Come to think of it, practically everything that any of us "knows" is a mix of truth, falsehood, approximations, and guesses. The problem is how to discern the "true truths" from the "untrue truths" and the "completely wild *ss guesses." Only in some (often nearly) trivial cases is it possible to be absolutely sure which is which. This is one of those cases.I know CVode implements adaptive time step numerical integration, with a separate "stream" for each neuron in the simulation.
Code: Select all
def my_initializer():
# do stuff here...
fih = h.FInitializeHandler(my_initializer)
Code: Select all
fih = h.FInitializeHandler((nc.event, 1))
Code: Select all
from neuron import h, gui
soma=h.Section()
soma.insert('pas')
syn=h.ExpSyn(soma(0.5))
nc=h.NetCon(None,syn)
nc.weight[0]=1.0
def synStim():
nc.event(50)
nc.event(60)
nc.event(100)
fih = h.FInitializeHandler(synStim)
h.tstop = 150
h.run()