neuron.init · neuron.load_mechanisms · neuron.new_hoc_class · neuron.new_point_process · neuron.nrn_dll · neuron.nrn_dll_sym · neuron.nrn_dll_sym_nt · neuron.numpy_element_ref · neuron.quit · neuron.run · neuron.test · neuron.test_rxd · neuron.xopen
neuron¶
For empirically-based simulations of neurons and networks of neurons in Python.
This is the top-level module of the official python interface to the NEURON simulation environment (http://neuron.yale.edu/neuron/).
Documentation is available in the docstrings.
For a list of available names, try dir(neuron).
Example:
$ ipython In [1]: import neuron NEURON – VERSION 6.2 2008-08-22 Duke, Yale, and the BlueBrain Project – Copyright 1984-2007 See http://neuron.yale.edu/credits.html
In [2]: neuron.h ?
Important names and sub-packages¶
For help on these useful functions, see their docstrings:
load_mechanisms
neuron.h
The top-level Hoc interpreter.
Execute Hoc commands by calling h with a string argument:
>>> h('objref myobj') >>> h('myobj = new Vector(10)')All Hoc defined variables are accessible by attribute access to h.
Example:
>>> print h.myobj.x[9]Hoc Classes are also defined, for example:
>>> v = h.Vector([1,2,3]) >>> soma = h.Section()More help is available for the respective class by looking in the object docstring:
>>> help(h.Vector)
neuron.gui
Import this package if you are using NEURON as an extension to Python, and you would like to use the NEURON GUI.
If you are using NEURON with embedded python, “nrniv -python”, use rather “nrngui -python” if you would like to use the NEURON GUI.
$Id: __init__.py,v 1.1 2008/05/26 11:39:44 hines Exp hines $
-
exception
neuron.
HocError
¶
-
class
neuron.
Wrapper
¶ Base class to provide attribute access for HocObjects.
-
neuron.
init
()¶ function init():
Initialize the simulation kernel. This should be called before a run(tstop) call.
** This function exists for historical purposes. Use in new code is not recommended. **
Use h.finitialize() instead, which allows you to specify the membrane potential to initialize to; via e.g. h.finitialize(-65)
This function is deprecated and will be removed in a future release.
By default, the units used by h.finitialize are in mV, but you can be explicit using NEURON’s unit’s library, e.g.
from neuron.units import mV h.finitialize(-65 * mV)
https://www.neuron.yale.edu/neuron/static/py_doc/simctrl/programmatic.html?#finitialize
-
neuron.
load_mechanisms
(path)¶ Search for and load NMODL mechanisms from the path given.
This function will not load a mechanism path twice.
The path should specify the directory in which nrnivmodl or mknrndll was run, and in which the directory ‘i686’ (or ‘x86_64’ or ‘powerpc’ depending on your platform) was created
-
neuron.
new_hoc_class
(name, doc=None)¶ Returns a Python-wrapped hoc class where the object does not need to be associated with a section.
doc - specify a docstring for the new hoc class
-
neuron.
new_point_process
(name, doc=None)¶ Returns a Python-wrapped hoc class where the object needs to be associated with a section.
doc - specify a docstring for the new pointprocess class
-
neuron.
nrn_dll
(printpath=False)¶ Return a ctypes object corresponding to the NEURON library.
Warning
This provides access to the C-language internals of NEURON and should be used with care.
-
neuron.
nrn_dll_sym
(name, type=None)¶ return the specified object from the NEURON dlls.
- namestring
- the name of the object (function, integer, etc…)
- typeNone or ctypes type (e.g. ctypes.c_int)
- the type of the object (if None, assumes function pointer)
-
neuron.
nrn_dll_sym_nt
(name, type)¶ return the specified object from the NEURON dlls. helper for nrn_dll_sym(name, type). Try to find the name in either nrniv.dll or libnrnpython1013.dll
-
neuron.
numpy_element_ref
(numpy_array, index)¶ Return a HOC reference into a numpy array.
- numpy_array
numpy.ndarray
- the numpy array
- indexint
- the index into the numpy array
Warning
No bounds checking.
Warning
Assumes a contiguous array of doubles. In particular, be careful when using slices. If the array is multi-dimensional, the user must figure out the integer index to the desired element.
- numpy_array
-
neuron.
quit
(*args, **kwargs)¶ Exits the program. Can be used as the action of a button. If edit buffers are open you will be asked if you wish to save them before the final exit.
This function is deprecated and will be removed in a future release. Use
h.quit()
orsys.exit()
instead. (Note: sys.exit will not prompt for saving edit buffers.)
-
neuron.
run
(tstop)¶ function run(tstop)
Run the simulation (advance the solver) until tstop [ms]
h.run() and h.continuerun(tstop) are more powerful solutions defined in the stdrun.hoc library.
** This function exists for historical purposes. Use in new code is not recommended. **
This function is deprecated and will be removed in a future release.
For running a simulation, consider doing the following instead:
Begin your code with
from neuron import h from neuron.units import ms, mV h.load_file('stdrun.hoc')
Then when it is time to initialize and run the simulation:
h.finitialize(-65 * mV) h.continuerun(100 * ms)
where the initial membrane potential and the simulation run time are adjusted as appropriate for your model.
-
neuron.
test
(exitOnError=True)¶ Runs a global battery of unit tests on the neuron module.
-
neuron.
test_rxd
(exitOnError=True)¶ Runs a tests on the rxd and crxd modules.
-
neuron.
xopen
(*args, **kwargs)¶ - Syntax:
neuron.xopen("hocfile")
neuron.xopen("hocfile", "RCSrevision")
- Description:
h.xopen()
executes the commands inhocfile
. This is a convenient way to define user functions and procedures. An optional second argument is the RCS revision number in the form of a string. The RCS file with that revision number is checked out into a temporary file and executed. The temporary file is then removed. A file of the same primary name is unaffected.
This function is deprecated and will be removed in a future release. Use
h.xopen
instead.
See also