Connecting a NetStim to a Synapses with a NetCon

When Python is the interpreter, what is a good
design for the interface to the basic NEURON

Moderator: hines

Post Reply
Posts: 65
Joined: Tue Jul 15, 2008 11:21 am
Location: EMBL-EBI Cambridge UK

Connecting a NetStim to a Synapses with a NetCon

Post by mattions » Tue Nov 25, 2008 1:07 pm


I'm trying to connect this AMPA synapse (coming from the Wolf 2005 model) with a stim in python.

Here is the code I'm using:

Code: Select all

#!/usr/bin/env python
import neuron
h = neuron.h

dend = h.Section()
stim = h.NetStim()

AMPA = neuron.new_point_process('AMPA')
ampa_syn1 = AMPA(dend, 0.5)

nc = h.NetCon(stim, ampa_syn1)
and this is the AMPA mod:

Code: Select all

TITLE    AMPA synapse for nucleus accumbens model
: see comments below

	RANGE gbar, tau_r, tau_d, scale, spkcnt, countflag, i, t1, ca_ratio, ical, itmp, qfact


	(nA) = (nanoamp)
	(mV) = (millivolt)
	(umho) = (micromho)

	gbar = 8.5e-4   (umho) 	: approx 0.5:1 NMDA:AMPA ratio (Myme 2003)
							:   with mg = 0, vh = -70, one pulse, NMDA = 300 pS
							:   here AMPA = 593 pS (NMDA set to Dalby 2003)
	tau_r = 2.2 	(ms)   	: Gotz 1997, Table 1 - rise tau
	tau_d = 11.5  	(ms)   	: Gotz 1997, Table 1 - decay tau
	Erev = 0    	(mV)   	: reversal potential, Jahn 1998
	saturate = 1.2 			: causes the conductance to saturate - matched to 
							:    Destexhe's reduced model in [1]
	qfact = 2				: convert 22 degC to 35 degC
	ca_ratio = 0.005			: ratio of calcium current to total current
}							: Burnashev/Sakmann J Phys 1995 485:403-418
							: with Carter/Sabatini Neuron 2004 44:483-493

	g (umho)
	v (mV)   		: postsynaptic voltage
	itmp	(nA)	: temp value of current
	i (nA)   		: nonspecific current = g*(v - Erev)
	ical (nA)		: calcium current through AMPA synapse (Carter/Sabatini)
	t1 (ms)
	y1_add (/ms)    : value added to y1 when a presynaptic spike is registered
	y1_loc (/ms)

	countflag		: start/stop counting spikes delivered
	spkcnt			: counts number of events delivered to synapse
	scale			: scale allows the current to be scaled by weight
}					: so NetCon(...,2) gives 2*the current as NetCon(...,1)

	y1 (/ms) 
	y2    			: sum of beta-functions, describing the total conductance

  	y1_add = 0
	scale = 0
	spkcnt = 0
	countflag = 0
	t1 = 0
	y1_loc = 0

  	SOLVE betadyn METHOD cnexp
	g = gbar * y2
  	itmp = scale * g * (v - Erev)
  	i = (1-ca_ratio) * itmp
  	ical = ca_ratio * itmp

DERIVATIVE betadyn {
	: dynamics of the beta-function, from [2]
	y1' = -y1 / (tau_d/qfact)
	y2' = y1 - y2 / (tau_r/qfact)

NET_RECEIVE( weight, y1_loc (/ms) ) {
	: updating the local y1 variable
	y1_loc = y1_loc*exp( -(t - t1) / (tau_d/qfact) )

	: y1_add is dependent on the present value of the local
	: y1 variable, y1_loc
	y1_add = (1 - y1_loc/saturate)

	: update the local y1 variable
	y1_loc = y1_loc + y1_add

	: presynaptic spike is finaly registered
	y1 = y1 + y1_add

	: store the spike time
	t1 = t

	spkcnt = spkcnt + 1

	scale = weight

Author Johan Hake (c) spring 2004
:     Summate input from many presynaptic sources and saturate 
:     each one of them during heavy presynaptic firing

: [1] Destexhe, A., Z. F. Mainen and T. J. Sejnowski (1998)
:     Kinetic models of synaptic transmission
:     In C. Koch and I. Segev (Eds.), Methods in Neuronal Modeling

: [2] Rotter, S. and M. Diesmann (1999) Biol. Cybern. 81, 381-402
:     Exact digital simulation of time-invariant linear systems with application 
:     to neural modeling

Dalby, N. O., and Mody, I. (2003). Activation of NMDA receptors in rat
dentate gyrus granule cells by spontaneous and evoked transmitter
release. J Neurophysiol 90, 786-797.

Gotz, T., Kraushaar, U., Geiger, J., Lubke, J., Berger, T., and Jonas,
P. (1997). Functional properties of AMPA and NMDA receptors expressed in
identified types of basal ganglia neurons. J Neurosci 17, 204-215.

Jahn K, Bufler J, Franke C (1998) Kinetics of AMPA-type glutamate
receptor channels in rat caudate-putamen neurones show a wide range of
desensitization but distinct recovery characteristics. Eur J Neurosci

Myme, C. I., Sugino, K., Turrigiano, G. G., and Nelson, S. B. (2003).
The NMDA-to-AMPA ratio at synapses onto layer 2/3 pyramidal neurons is
conserved across prefrontal and visual cortices. J Neurophysiol 90,

Gutfreund H, Kinetics for the Life Sciences, Cambridge University Press,
1995, pg 234.  (suggested by Ted Carnevale)

The error that I get is:

Code: Select all

NEURON: arg 2 must be a point process or NULLobject
 near line 0
 obfunc new_AMPA() { return new AMPA($1) }
        NetCon(..., ...)
Traceback (most recent call last):
  File "", line 17, in <module>
    nc = h.NetCon(stim, ampa_syn1)
RuntimeError: hoc error
In the hoc world the same process works...

Site Admin
Posts: 5684
Joined: Wed May 18, 2005 4:50 pm
Location: Yale University School of Medicine

Re: Connecting a NetStim to a Synapses with a NetCon

Post by ted » Wed Nov 26, 2008 2:20 pm

Regardless of whether you use Python for this, or revert to hoc, you should also contact the model's author about the proper usage of this mechanism, and test it in a simple model to make sure that it does what it should do.

You should run tests to make sure that this mechanism responds properly to events delivered by one or more NetCons. I suspect that it will respond correctly as long as each instance of the mechanism is driven by one and only one NetCon, but that an instance of the mechanism that is driven by NetCons with different weights will produce incorrect results.

There are two reasons for this.

First, the code as written saves the "time of previous input" in a variable t1 that is a RANGE ASSIGNED variable. "Time of previous input" is generally used in calculations of use-dependent synaptic plasticity. The modeler's intention is almost always to simulate homosynaptic facilitation or depression, for which it is necessary that each input stream keeps track of its own "time of previous input." Otherwise, inputs from different presynaptic cells will potentiate or depress each other--an undesired outcome. t1 should instead have been declared in the NET_RECEIVE statement as a component of the weight vector, e.g.
NET_RECEIVE (weight, t1 (ms), y1_loc)

Second, the synaptic conductance is calculated as the product
scale * gbar * y2
but the value of "scale" is specified in the NET_RECEIVE block as being the weight associated with the input stream that has most recently delivered an event. If an instance of this synaptic mechanism receives events from two or more NetCons that have different weights, synaptic conductance will jump abruptly up or down at each synaptic activation, which seems unlikely to be correct. My suspicion is that the "scale" variable should simply be omitted. The comment in the ASSIGNED block suggests that it may have served a useful purpose in an earlier incarnation of this mechanism, but in the current version it is only a potential source of error and confusion.

There are some minor issues about the NMODL code that could be revised for the sake of clarity and "best practices," but the items mentioned above are the principal sources of concern.

Site Admin
Posts: 1586
Joined: Wed May 18, 2005 3:32 pm

Re: Connecting a NetStim to a Synapses with a NetCon

Post by hines » Wed Nov 26, 2008 5:03 pm

neuron module POINT_PROCESS wrappers are obsolete though they can be used if you reach into the
wrapper to get the POINT_PROCESS object itself. But use
ampa_syn1 = h.AMPA(0.5, sec = dend))
nc = h.NetCon(stim, ampa_syn1)

Posts: 65
Joined: Tue Jul 15, 2008 11:21 am
Location: EMBL-EBI Cambridge UK

Re: Connecting a NetStim to a Synapses with a NetCon

Post by mattions » Thu Nov 27, 2008 1:21 pm

Hi Hines,
thank you for the replies :)

The syntax you proposed work well and I'm able to connect the two right now.

The problem is the AMPA is seems to not receive any input, and I'm thinking to try to build a small test model to have at least a prototype synapse working from scratch.

I would like to know if there is a way to record the input delivered by a NetStim object, so I'm sure the NetStim is delivering the input, the NeCon is connecting with the target and the synapse is getting the input in.

Is there any example somewhere of such system?

Site Admin
Posts: 5684
Joined: Wed May 18, 2005 4:50 pm
Location: Yale University School of Medicine

Re: Connecting a NetStim to a Synapses with a NetCon

Post by ted » Sun Nov 30, 2008 11:30 am

Localization is the key to diagnosis.
Is the problem in the NetCon, the NetStim, the NetCon's target (the synaptic mechanism), or elsewhere?

NetCon: Make sure that the NetCon's weight > 0.
NetStim: Make sure that the NetStim generates an event during the simulation. Set ns.number > 0, ns.start < tstop, ns.noise to 0, and try again.
Synaptic mechanism: Make sure you can set up a working connection between a NetStim and an ExpSyn.

Refer to the Programmer's Reference as needed for details of syntax and examples of usage.

If none of this works, "the problem lies elsewhere."

Post Reply