neuron attr_praxis fit_praxis nrnglobalmechmenu pval_praxis batch_run fmatrix nrnmechmenu secname batch_save frecord_init nrnpointmenu section_orientation fadvance fstim nrnsecmenu sectionname fclamp fstimi parent_connection stop_praxis fclampi hocmech parent_node this_node fclampv initnrn parent_section this_section fcurrent ismembrane prstim finitialize issection psectionThese are Neuron-specific functions which you can call from the nrnoc interpreter.
functions
batch_run(tstop, tstep, "filename")
batch_run(tstop, tstep, "filename", "comment")
and produces the most efficient run on any given neuron model. This command was created specifically for Cray computers in order eliminate the interpreter overhead as the rate limiting simulation step.while (t < tstop) { for i=0, tstep/dt { fadvance() } // print results to filename }
This command will save selected variables, as they are changed in the run, into a file whose name is given as the third argument. The 4th comment argument is placed at the beginning of the file. The batch_save command specifies which variable are to be saved.
functions
batch_save()
batch_save(&var, &var, ...)
batch_save()
batch_save(&var, &var, ...)
batch_run
.
A pointer to a range variable, eg. "v", must have an explicit
arc length, eg. axon.v(.5).
specifies five quantities to be saved from eachbatch_save() //This clears whatever list existed and starts a new //list of variables to be saved. batch_save(&soma.v(.5), &axon.v(1)) for i=0,2 { batch_save(&dend[i].v(.3)) }
batch_run
.
functions
initnrn()
t, dt, clamp_resist
, and celsius
to the values
they had when the program was first run.
Note that in this
version Ra
is no longer a global variable but a section variable
like L and rallbranch. Thus Ra
can be different for different
sections. In order to set Ra
to a constant value, use:
forall Ra=...
functions
fadvance()
fadvance integrates the equation over the dt step by calling all the BREAKPOINT blocks of models at t+dt/2 twice with v+.001 and v in order to compute the current and conductance to form the matrix conductance*voltage = current. This matrix is then solved for v(t+dt). (if secondorder == 2 the ionic currents are adjusted to be second order correct. If secondorder == 1 the ionic currents are not adjusted but the voltages are second order correct) Lastly the SOLVE statement within the BREAKPOINT block of models is executed with t+dt and the new values of v in order to integrate those states (from new t-.5dt to new t+.5dt).
functions
finitialize()
finitialize(v)
t
is set to 0.
The order of principal actions during an finitialize call is;
t = 0 Clear the event queue. Random.play values assigned to variables. Make sure internal structures needed by integration methods are consistent with the current biophysical spec. Vector.play at t=0 values assigned to variables. All v = arg if the arg is present. Type 0 FInitializeHandler statements executed. All mechanism BEFORE INITIAL blocks are called. All mechanism INITIAL blocks called. Mechanisms that WRITE concentrations are after ion mechanisms and before mechanisms that READ concentrations. LinearMechanism states are initialized INITIAL blocks inside NETRECEIVE blocks are called. All mechanism AFTER INITIAL blocks are called. Type 1 FInitializeHandler statements executed. The INITIAL block net_send(0, flag) events are delivered. Effectively a call to CVode.re_init or fcurrent(), whichever appropriate. Various record functions at t=0. e.g. CVode.record, Vector.record Type 2 FInitializeHandler statements executed.
functions
frecord_init()
functions
fstim()
functions
fstimi()
functions
min = fit_praxis(n, "funname", &x[0])
min = fit_praxis(n, "funname", Vector)
min = fit_praxis(..., ..., ..., "after quad statement")
min = fit_praxis(efun_as_python_callable, hoc_vector)
1 <= n < 20
$1
,
is the number of elements in second arg vector, $&2
. The ith index of the
vector is given by $&2[i]
.
funname()
.
funname may be either an interpreted hoc function or a compiled NMODL function.
If the variable stoprun is set to 1 during a call to fit_praxis, it will return immediately (when the current call to funname returns) with a return value and varx values set to the best minimum found so far. Use stop_praxis to stop after finishing the current principal axis calculation.
The fourth argument, if present, specifies a statement to be executed at the end of each principal axis evaluation.
If the third argument is a Vector, then that style is used to specify the initial starting point and return the final value. However the function is still called with second arg as a pointer into a double array.
The Python callable form uses a Python Callable as the function to minimize and it must take a single hoc Vector argument specifying the values of the parameters for use in evaluation the function. On entry to fit_praxis the Vector specifies the number of parameters and the parameter starting values. On return the vector contains the values of parameters which generated the least minimum found so far.
Hoc example: minimize (x+y - 5)^2 + 5*((x-y) - 15)^2
objref vec vec = new Vector(2) // vec.x[0] is x, vec.x[1] is y func efun() {local x, y x = $&2[0] y = $&2[1] return (x+y - 5)^2 + 5*(x-y - 15)^2 } attr_praxis(1e-5, .5, 0) e = fit_praxis(vec.size(), "efun", vec) printf("e=%g x=%g y=%g\n", e, vec.x[0], vec.x[1]) objref paxis paxis = new Vector() for i=0, 1 { pval = pval_praxis(i, paxis) printf("%d %10g %10g %10g\n", i, pval, paxis.x[0], paxis.x[1]) }
Python example:
from neuron import h v = h.Vector(2) def efun(v): return (v.x[0]+v.x[1] - 5)**2 + 5*(v.x[0]-v.x[1] - 15)**2 h.attr_praxis(1e-5, .5, 0) e = h.fit_praxis(efun, v) print "e=%g x=%g y=%g\n"%(e, v.x[0], v.x[1])
numarg()==n
.
functions
attr_praxis(tolerance, maxstepsize, printmode)
previous_index = attr_praxis(mcell_ran4_index)
norm(x-x0) < tolerance
functions
pval = pval_praxis(i)
pval = pval_praxis(i, &paxis[0])
pval = pval_praxis(i, Vector)
pval_praxis
also fills
the vector with the ith principal axis.
functions
stop_praxis()
stop_praxis(i)
fit_praxis
, then praxis will do a single
(or i) principal axis calculation and then exit.
functions
fclamp()
functions
fclampi()
functions
fclampv()
functions
prstim()
fstim
, fclamp
, and fsyn
functions
fcurrent()
create soma access soma insert hh print "default el_hh = ", el_hh // set el_hh so that the steady state is exactly -70 mV finitialize(-70) // sets v to -70 and m,h,n to corresponding steady state values fcurrent() // set all assigned variables consistent with states // use current balance: 0 = ina + ik + gl_hh*(v - el_hh) el_hh = (ina + ik + gl_hh*v)/gl_hh print "-70 mV steady state el_hh = ", el_hh fcurrent() // recalculate currents (il_hh)
functions
fmatrix()
section {value = fmatrix(x, index)}
With args, return the matrix element associated with the integer index in the row corresponding to the currently accessed section at position x. The index 1...4 is associated with: The coeeficient for the effect of this locations voltage on current balance at the parent location, The coeeficient for the effect of this locations voltage on current balance at this location, The coeeficient for the effect of the parent locations voltage on current balance at this location, The right hand side of the matrix equation for this location. These are the values of NODEA, NODED NODEB, and NODERHS respectively in nrn/src/nrnoc/section.h . The matrix elements are properly setup on return from a call to the fcurrent function. For the fixed step method fadvance modifies NODED and NODERHS but leaves NODEA and NODEB unchanged.
functions
issection("regular expression")
Regular expressions are like those of grep except {} are used in place of [] to avoid conflict with indexed sections. Thus a[{8-15}] matches sections a[8] through a[15]. A match always begins from the beginning of a section name. If you don't want to require a match at the beginning use the dot.
(Note,
that .
matches any character and *
matches 0 or more occurrences
of the previous character). The interpreter always closes each string with
an implicit $
to require a match at the end of the string. If you
don't require a match at the end use ".*
".
will printcreate soma, axon, dendrite[3] forall if (issection("s.*")) { print secname() }
soma
will printforall if (issection("d.*2]")) { print secname() }
dendrite[2]
will print all names which contain the letter "a"forall if (issection(".*a.*")) { print secname() }
soma axon
functions
ismembrane("mechanism")
will print the names of all the sections which contain both Hodgkin-Huxley and Calcium ions.forall if (ismembrane("hh") && ismembrane("ca_ion")) { print secname() }
functions
sectionname(strvar)
This function is superseded by the easier to use, secname .
functions
secname()
orstrdef s s = secname()
orprint secname()
forall for(x) printf("%s(%g)\n", secname(), x)
functions
psection()
globals
secondorder
dt=1e10
. Numerical errors
are proportional to dt.
dt
the numerical errors are proportional
to dt^2
. Cannot be used with voltage clamps. Ionic currents
are first order correct. Channel conductances are second order
correct when plotted at t+dt/2
t-dt/2
globals
t
globals
dt
When using the default implicit integration method ( secondorder = 0) there is no upper limit on dt for numerical stability and in fact for passive models it is often convenient to use dt=1.9 to obtain the steady state in a single time step.
dt can be changed by the user at any time during a simulation. However, some inserted mechanisms may use tables which depend on the value of dt which will be automatically recomputed. In this situation, the tables are not useful and should be bypassed by setting the appropriate usetable_suffix global variables to 0.
globals
clamp_resist
globals
celsius = 6.3
Generally, rate function tables ( eg. used by the hh mechanism) depend on temperature and will automatically be re-computed whenever celsius changes.
globals
stoprun
functions
this_section(x)
functions
this_node(x)
func segnum() { if ($1 <= 0) { return 0 }else if ($1 >= 1) { return nseg+1 }else { return int($1*nseg + .5) } }
functions
parent_section(x)
functions
parent_node(x)
functions
y = parent_connection()
connect child(x), parent(y)
functions
y = section_orientation()
connect child(x), parent(y)
neuronThe following definitions are found in nrnoc/SRC/options.h and add extra functionality which not everyone may need. The extras come at the cost of larger memory requirements for node and section structures. METHOD3 is too large and obscure to benefit most users.
#define VECTORIZE 1 /* hope this speeds up simulations on a Cray */ /* this is no longer optional */ #define EXTRACELLULAR 1 /* extracellular membrane mechanism */ #define DIAMLIST 1 /* section contains diameter info */ /* shape plots make use of this */ #define EXTRAEQN 0 /* ionic concentrations calculated via * jacobian along with v (not implemented) */ #if DIAMLIST #define NTS_SPINE 1 /* A negative diameter in pt3dadd() tags that * diamlist location as having a spine. * diam3d() still returns the positive diameter * spined3d() returns 1 or 0 signifying presence * of spine. setSpineArea() tells how much * area/spine to add to the segment. */ #endif #define METHOD3 1 /* third order spatially correct method */ /* testing only, not completely implemented */ /* not working at this time */ #if METHOD3 spatial_method(i) no arg, returns current method i=0 The standard NEURON method with zero area nodes at the ends of sections. i=1 conventional method with 1/2 area end nodes i=2 modified second order method i=3 third order correct spatial method Note: i=1-3 don't work under all circumstances. They have been insufficiently tested and the correctness must be established for each simulation. #endif #if NEMO neuron2nemo("filename") Beginning of translator between John Millers nemosys program and NEURON. Probably out of date. nemo2neuron("filename") #endif
neuron ghk ion_register nernst ion_charge ion_style
ion
oldstyle = ion_style("name_ion", c_style, e_style, einit, eadvance, cinit)
oldstyle = ion_style("name_ion")
The oldstyle value is previous internal setting of c_style + 4*cinit + 8*e_style + 32*einit + 64*eadvance.
finitialize()
using values of concentrations.
fadvance()
using the values of the concentrations.
nai
set to
nai0_na_ion
and nao
set to nao0_na_ion
.
The automatic style is chosen based on how the set of mechanisms that have been inserted in a section use the ion. Note that the precedence is WRITE > READ > unused in the USEION statement; so if one mechanism READ's cai/cao and another mechanism WRITE's them then WRITE takes precedence in the following table. For compactness, the table assumes the ca ion. Each table entry identifies the equivalent parameters to the ion_style function.
cai/cao -> unused read writeFor example suppose one has inserted a mechanism that READ's eca, a mechanism that READ's cai, cao and a mechanism that WRITE's cai, cao Then, since WRITE takes precedence over READ in the above table,eca unused 0,0,0,0,0 1,0,0,0,0 3,0,0,0,1
eca read 0,1,0,0,0 1,2,1,0,0 3,2,1,1,1
eca write 0,2,0,0,0 1,2,0,0,0 3,2,0,0,1
cai/cao
would appear in the STATE variable panel (first arg is 3),
eca
would appear in the ASSIGNED variable panel (second arg is 2),
eca
would be calculated on a call to finitialize (third arg is 1),
eca
would be calculated on every call to fadvance (fourth arg is 1),
cai/cao
would be initialized (on finitialize) to the global variables
cai0_ca_ion
and cao0_ca_ion
respectively. (note that this takes place just
before the calculation of eca
).
ion
ghk(v, ci, co, charge)
mA/cm2 = (permeability in cm/s)*ghk(mV, mM, mM, valence)
ion
nernst(ci, co, charge)
nernst("ena" or "nai" or "nao", [x])
nernst(ci, co, charge)
nernst("ena" or "nai" or "nao", [x])
nao/nai = exp(z*ena/RTF)
for the ionic variable
named in the string.
ion
type = ion_register("name", charge)
ion
charge = ion_charge("name_ion")