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.test · neuron.test_rxd



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 (

Documentation is available in the docstrings.

For a list of available names, try dir(neuron).


$ ipython In [1]: import neuron NEURON – VERSION 6.2 2008-08-22 Duke, Yale, and the BlueBrain Project – Copyright 1984-2007 See

In [2]: neuron.h ?

Important names and sub-packages

For help on these useful functions, see their docstrings:

neuron.init, run, psection, load_mechanisms


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.


>>> 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)


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:,v 1.1 2008/05/26 11:39:44 hines Exp hines $

class neuron.Wrapper

Base class to provide attribute access for HocObjects.


function init():

Initialize the simulation kernel. This should be called before a run(tstop) call.

Use h.finitialize() instead, which allows you to specify the membrane potential to initialize to; via e.g. h.finitialize(-65)


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


Return a ctypes object corresponding to the NEURON library.


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.


name : string

the name of the object (function, integer, etc…)

type : None 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

index : int

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.

function run(tstop)

Run the simulation (advance the solver) until tstop [ms]


Runs a global battery of unit tests on the neuron module.


Runs a tests on the rxd and crxd modules.