NEURON¶
Configuration options¶
Adaptive time step integration¶
The default integration method used by the pyNN.neuron
backend uses a
fixed time step, specified by the timestep argument to the setup()
function.
NEURON also supports use of variable time step methods, which can improve simulation speed:
setup(use_cvode=True)
If using cvode, there are two more optional parameters:
setup(cvode=True,
rtol=0.001, # specify relative error tolerance
atol=1e-4) # specify absolute error tolerance
If not specified, the default values are rtol = 0 and atol = 0.001. For full details, see the CVode documentation
Todo
native_rng_baseseed is added to MPI.rank to form seed for SpikeSourcePoisson, etc., but I think it would be better to add a seed parameter to SpikeSourcePoisson
Todo
Population.get_data() does not yet handle cvode properly.
Using native cell models¶
A native NEURON cell model is described using a Python class (which may wrap a Hoc template). For this class to work with PyNN, there are a small number of requirements:
the
__init__()
method should take just**parameters
as its argument.instances should have attributes:
source
: a reference to the membrane potential which will bemonitored for spike emission, e.g.
self.soma(0.5)._ref_v
source_section
: the HocSection
in whichsource
is located.
parameter_names
: a tuple of the names of attributes/properties ofthe class that correspond to parameters of the model.
traces
: an empty dict, used for recording.
recording_time
: should beFalse
initially.there must be a
memb_init()
method, taking no arguments.
Here is an example, which uses the nrnutils package for conciseness:
from nrnutils import Mechanism, Section
class SimpleNeuron(object):
def __init__(self, **parameters):
hh = Mechanism('hh', gl=parameters['g_leak'], el=-65,
gnabar=parameters['gnabar'], gkbar=parameters['gkbar'])
self.soma = Section(L=30, diam=30, mechanisms=[hh])
self.soma.add_synapse('ampa', 'Exp2Syn', e=0.0, tau1=0.1, tau2=5.0)
# needed for PyNN
self.source_section = self.soma
self.source = self.soma(0.5)._ref_v
self.parameter_names = ('g_leak', 'gnabar', 'gkbar')
self.traces = {}
self.recording_time = False
def _set_gnabar(self, value):
for seg in self.soma:
seg.hh.gnabar = value
def _get_gnabar(self):
return self.soma(0.5).hh.gnabar
gnabar = property(fget=_get_gnabar, fset=_set_gnabar)
# ... gkbar and g_leak properties defined similarly
def memb_init(self):
for seg in self.soma:
seg.v = self.v_init
For each cell model, you must also define a cell type:
from pyNN.neuron import NativeCellType
class SimpleNeuronType(NativeCellType):
default_parameters = {'g_leak': 0.0002, 'gkbar': 0.036, 'gnabar': 0.12}
default_initial_values = {'v': -65.0}
recordable = ['soma(0.5).v', 'soma(0.5).ina']
units = {'soma(0.5).v' : 'mV', 'soma(0.5).ina': 'nA'}
receptor_types = ['soma.ampa']
model = SimpleNeuron
The requirement to explicitly list all variables you might wish to record in the
recordable
attribute is a temporary inconvenience, which will be removed in
a future version.
It is now straightforward to use this cell type in PyNN:
from pyNN.neuron import setup, run, Population, Projection, AllToAllConnector, StaticSynapse
setup()
p1 = Population(10, SimpleNeuronType(g_leak=0.0003))
p1.record('soma(0.5).ina')
syn = StaticSynapse(weight=0.01, delay=0.5)
prj = Projection(p1, p1, AllToAllConnector(), syn, receptor_type='soma.ampa')
run(100.0)
output = p1.get_data()
If your model relies on other NMODL mechanisms, call the
load_mechanisms()
function with the path to the directory
containing the .mod
files.