neuron.Wrapper

# 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: neuron.init, run, psection, 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)

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)

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_arraynumpy.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.

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. **

For running a simulation, consider doing the following instead:

from neuron import h
from neuron.units import ms, mV


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.