Netcon source in NEURON+Python

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

Moderator: hines

Post Reply
vgoudar
Posts: 19
Joined: Fri Dec 03, 2010 3:41 am

Netcon source in NEURON+Python

Post by vgoudar » Fri Mar 25, 2016 5:24 pm

Hello,

I'm trying to do something pretty basic: I'd like the NetCon source to be a variable from a distributed mechanism in the presynaptic cell rather than its voltage, as is usually the case. Python doesnt pass references around, and HOC appears to complain about the variable not being a reference. Here is what I'm seeing.

Code: Select all

>>> pre = h.Section()
>>> pre.L = 10
>>> pre.diam = 10
>>> pre.insert('IAF') #Inserting distributed mechanism here
<nrn.Section object at 0x7faae24375a8>
>>> post = h.Section()
>>> post.L = 10
>>> post.diam = 10
>>> post.insert('IAF')
<nrn.Section object at 0x7faae2437760>
>>> ss = h.Syn(post(0.5)) #Custom synapse (point process)
>>> nc = h.NetCon(pre.spike_IAF,ss)
bad stack access: expecting (double *); really (double)
NEURON: interpreter stack type error
 near line 0
 objref hoc_obj_[2]
                   ^
        NetCon(0, ...)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
RuntimeError: hoc error
Suggestions are highly appreciated.

Thanks.

Best,
Vishwa

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

Re: Netcon source in NEURON+Python

Post by ted » Sat Mar 26, 2016 10:37 am

Do yourself a huge favor and work through "Scripting NEURON with Python"--see the link on the Documentation page http://www.neuron.yale.edu/neuron/docs. Yes, you probably know at least 90% of what's in there already, but maybe you'll find a few pearls. If you just can't wait to get the answer right now, look at the code in

Code: Select all

Ball-and-stick: 3 - Basic cell
  . . .
  * Connect the cells

vgoudar
Posts: 19
Joined: Fri Dec 03, 2010 3:41 am

Re: Netcon source in NEURON+Python

Post by vgoudar » Sun Mar 27, 2016 12:51 am

Hi Ted,

I see my problem. I should have done nc = h.NetCon(pre(0.5)._ref_spike_IAF,ss). But, since IAF is a distributed mechanism, I didn't see the point in saying pre(0.5)._ref_spike_IAF. Although I didn't mention it in my earlier post, I had tried nc = h.NetCon(pre._ref_spike_IAF,ss) and got an error.

Just curious, why is it necessary to specify the location if the source is a member of a distributed mechanism rather than a point process?

Thanks.

Best,
Vishwa

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

Re: Netcon source in NEURON+Python

Post by ted » Mon Mar 28, 2016 10:54 am

vgoudar wrote:why is it necessary to specify the location if the source is a member of a distributed mechanism rather than a point process?
Create an instance of a point process class, and you get a new object whose STATEs and other RANGE variables are unique to that object. The complete name for each of these variables is of the form
classname[instanceindex].varname
or
objrefname.varname
and is completely unambiguous--given a name in either of these forms there is never a question about what variable you mean to access.

Insert a density (or "distributed") mechanism into a section, and each of the section's segments now has new STATE and RANGE variables that are unique to that segment. The complete name for each of these variables is of the form
sectionname.prefix_suffix(range)
where 0<=range<=1 and the value of range specifies the segment whose range variable you intend to access. Given a name in this form, there is never a question about what variable you mean to access. Shortcut notations such as
prefix_suffix(range)
and
prefix_suffix
refer to the value of the range variable in the segment that corresponds to location range in the currently accessed section, and the value of the range variable in the segment that corresponds to the midpoint of the currently accessed section, respectively.

This is all discussed somewhere or other in the Programmer's Reference. A teletype-rendering of a "Hero Badge" is offered to the first person to report the URL(s) in the Programmer's Reference that contain this information.

vgoudar
Posts: 19
Joined: Fri Dec 03, 2010 3:41 am

Re: Netcon source in NEURON+Python

Post by vgoudar » Mon Mar 28, 2016 12:31 pm

Hi Ted,

Yup, certainly a bit "dense" of me to mix up density mechanisms with point processes. Thanks for walking me through that.

Best,
Vishwa

Post Reply