Setpointer when defining a synapse

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

Moderator: hines

Post Reply
Manni
Posts: 2
Joined: Mon Oct 13, 2014 1:09 pm

Setpointer when defining a synapse

Post by Manni » Thu Oct 30, 2014 10:14 am

Hi everyone,

I'm attempting to translate a neuron hoc model to python which uses a detailed kinetic representation of AMPA receptors. The model consists of a hoc synapse model and mod files for hh2, caL, rel and AMPA5. Below is the relevant hoc code;

Code: Select all

create PRE,POST
forall {
  insert pas
}
access PRE
insert hh2
insert caL
insert rel

//----------------------------------------------------------------------------
//  insert postsynaptic mechanisms
//----------------------------------------------------------------------------

objectvar c
c = new AMPA5()             // create synapse
POST c.loc(0.5)             // assign postsynaptic compartment
setpointer c.C, PRE.T_rel(0.5)      // assign presynaptic compartment

My translated python code looks like this;

Code: Select all

from neuron import *
from nrn import *

PRE=Section()
POST=Section()

soma1.insert('hh2')     #hh2 is a custom hh mechanism by the author
soma1.insert('caL')
soma1.insert('pas')
soma1.insert('rel')

soma2.insert('hh2')
soma2.insert('pas')

#synapse
soma2 = cas()
synapse = h.AMPA5()
synapse.loc(0.5)
synapse.C= h.setpointer(soma1(0.5).T_rel, 'ampa', synapse.AMPA5)     #error causing code
I have trouble with the h.setpointer function, whose syntax Neuron-Python describes as; setpointer(_ref_hocvar, 'POINTER_name', point_process or nrn.Mechanism))
Could anyone clarify what the three arguments for h.setpointer should be? I'm aware that assigning synapse.C may also be incorrect, but placing synapse.C anywhere within the h.setpointer arguments leads to a segmentation fault. Any help/insight would be greatly appreciated!

The model I follow is;
http://webcache.googleusercontent.com/s ... en&ct=clnk
(the website does occasionally go offline...)

The mod file for the AMPA5 object is printed below;

Code: Select all

INDEPENDENT {t FROM 0 TO 1 WITH 1 (ms)}

NEURON {
	POINT_PROCESS AMPA5
	POINTER C
	RANGE C0, C1, C2, D1, D2, O
	RANGE g, gmax, rb
	GLOBAL Erev
	GLOBAL Rb, Ru1, Ru2, Rd, Rr, Ro, Rc
	GLOBAL vmin, vmax
	NONSPECIFIC_CURRENT i
}

UNITS {
	(nA) = (nanoamp)
	(mV) = (millivolt)
	(pS) = (picosiemens)
	(umho) = (micromho)
	(mM) = (milli/liter)
	(uM) = (micro/liter)
}

PARAMETER {

	Erev	= 0    (mV)	: reversal potential
	gmax	= 500  (pS)	: maximal conductance
	vmin = -120	(mV)
	vmax = 100	(mV)
	
: Rates

	Rb	= 13   (/mM /ms): binding 
				: diffusion limited (DO NOT ADJUST)
	Ru1	= 0.0059  (/ms)	: unbinding (1st site)
	Ru2	= 86  (/ms)	: unbinding (2nd site)		
	Rd	= 0.9   (/ms)	: desensitization
	Rr	= 0.064 (/ms)	: resensitization 
	Ro	= 2.7    (/ms)	: opening
	Rc	= 0.2    (/ms)	: closing
}

ASSIGNED {
	v		(mV)		: postsynaptic voltage
	i 		(nA)		: current = g*(v - Erev)
	g 		(pS)		: conductance
	C 		(mM)		: pointer to glutamate concentration

	rb		(/ms)    : binding
}

STATE {
	: Channel states (all fractions)
	C0		: unbound
	C1		: single glu bound
	C2		: double glu bound
 	D1		: single glu bound, desensitized
 	D2		: double glu bound, desensitized
	O		: open state 2
}

INITIAL {
	C0=1
	C1=0
	C2=0
	D1=0
	D2=0
	O=0
}

BREAKPOINT {
	SOLVE kstates METHOD sparse

	g = gmax * O
	i = (1e-6) * g * (v - Erev)
}

KINETIC kstates {
	
	rb = Rb * C 

	~ C0  <-> C1	(rb,Ru1)
	~ C1 <-> C2	(rb,Ru2)
	~ C1 <-> D1	(Rd,Rr)
	~ C2 <-> D2	(Rd,Rr)
	~ C2 <-> O	(Ro,Rc)

	CONSERVE C0+C1+C2+D1+D2+O = 1
}

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

Re: Setpointer when defining a synapse

Post by ted » Fri Oct 31, 2014 11:03 pm

Before starting on how to do "setpointer" in Python, I should mention a recent email exchange about NEURON's internals in which Michael Hines reflected on what to import and why. What I learned was that the idea of doing
import neuron
was based on a strategy of "wrapping the early non-pythonic things. As time went by, the 'from neuron import h' became more and more complete and the wrappers, for the most part, were never improved or publicized."

So before going further, I'd suggest replacing
from neuron import *
from nrn import *
with
from neuron import h

Then you can do
PRE = h.Section()
etc.
I have trouble with the h.setpointer function
How can you tell? Have you tried executing the first 5 statements of your Python code?

After you fix that, it's time to review the Programmer's Reference section on Python Accessing Hoc
http://www.neuron.yale.edu/neuron/stati ... essing-hoc
especially the tail end of the subtopic of HocObject
http://www.neuron.yale.edu/neuron/stati ... .HocObject
The hoc setpointer statement is effected in Python as a function call with a syntax for POINT_PROCESS and SUFFIX (density)mechanisms respectively of

Code: Select all

h.setpointer(_ref_hocvar, 'POINTER_name', point_proces_object)
h.setpointer(_ref_hocvar, 'POINTER_name', nrn.Mechanism_object)
See nrn/share/examples/nrniv/nmodl/(tstpnt1.py and tstpnt2.py) for examples of usage. For a density mechanism, the 'POINTER_name' cannot have the SUFFIX appended. For example if a mechanism with suffix foo has a POINTER bar and you want it to point to t use

Code: Select all

h.setpointer(_ref_t, 'bar', sec(x).foo)
The AMPA5 mechanism is a type of point process and its POINTER variable is called C. An instance of AMPA5 must have its C variable linked to some variable that belongs to the presynaptic section. According to the hoc code excerpt that you provide
1. the instance of the AMPA5 point process is called c,
and
2. the presynaptic section is called PRE, the variable of interest in that section is called T and belongs to a density (or "distributed") mechanism called rel. Since rel is a density mechanism, a separate instance of it exists in every segment of the section into which it has been inserted.

So in hoc terms, c.C must be linked to PRE.T_rel(0.5), and that is why the hoc statement is written as
setpointer c.C, PRE.T_rel(0.5)

How to do this in Python?

If the Python names for the presynaptic section and the point process are PRE and syn (to me that seems much more mnemonic, and maybe safer, than c), my guess is that the setpointer statement in Python would be something like
h.setpointer(PRE(0.5)._ref_T_rel, 'C', syn)
This is based on the discussion in the Programmer's Reference plus examination of not only the tstpnt*py examples mentioned there but also tstpnt2.mod which is in the same location as the tstpnt*py files.

Final comment: it would be a very good idea to check the mod file for AMPA5 with modlunit and fix any errors or unit inconsistencies that are discovered.

Manni
Posts: 2
Joined: Mon Oct 13, 2014 1:09 pm

Re: Setpointer when defining a synapse

Post by Manni » Mon Nov 10, 2014 3:52 am

Dear Ted,

Thanks a lot! I made a mistake while copying code to my post, so apologies for the first error of creating wrongly named sections! The syntax you suggested was correct and I have posted my working code for completeness below;

Code: Select all

from neuron import h

PRE=h.Section()
POST=h.Section()

PRE.insert('hh2')     #hh2 is a custom hh mechanism by the author
PRE.insert('caL')
PRE.insert('pas')
PRE.insert('rel')
PRE.nseg = 1
PRE.L = 10
PRE.diam = 10

POST.insert('hh')
POST.insert('pas')
POST.nseg = 10
POST.L = 2.5
POST.diam = 2.5

#synapse
synapse = h.AMPA5()
synapse.loc(POST(0.5))
h.setpointer(PRE(0.5)._ref_T_rel, 'C', synapse)
Measuring voltage at the post-synaptic membrane and monitoring the variable PRE(0.5)._ref_T_rel verified that the synapse works.
Thanks again!

Post Reply