Setpointer when defining a synaptic connection

151 views
Skip to first unread message

zhao.z...@gmail.com

unread,
Mar 8, 2021, 8:40:28 PM3/8/21
to NetPyNE Q&A forum
Hi,

I have a neuron with a Point Process mechanism 'twocomp' and its Pointer variable is called 'isyn'. I wanted to connect the Netstim to this neuron with the 'Exp2Syn' mod. The 'twocomp' mechanism uses a user-defined variable 'vs' and equations for the calculation of the membrane potential. Therefore, it does not use the synaptic current 'i' in the 'Exp2Syn' mod automatically as the cable equation does in Neuron. 

I want to link Pointer 'isyn' to the synaptic current 'i'. In this way, my mechanism can use the synaptic current for 'vs' calculation. By searching in the Neuron forum, I understand how to use h.setpointer:
        h.setpointer(_ref_hocvar, 'POINTER_name', point_proces_object)
        h.setpointer(_ref_hocvar, 'POINTER_name', nrn.Mechanism_object)

I tried the way to implement Setpointer described in this link: https://www.neuron.yale.edu/phpbb/viewtopic.php?f=45&t=3884 

       sec=sim.net.cells[0].secs['soma'] 
       h.setpointer(sec['synMechs'][0]['hSyn']._ref_i, 'isyn', sec['hSec'](.5))

But I got an Error:
       
       TypeError: 'Dict' object is not callable

Thanks for your help,

Zhihe

Joe Graham

unread,
Mar 9, 2021, 1:12:58 PM3/9/21
to NetPyNE Q&A forum
Hi Zhihe,

I believe the problem is that 'hSec' has been renamed 'hObj' since that forum post was written.  Please swap those and let us know if you have any more problems.

Cheers,
Joe

zhao.z...@gmail.com

unread,
Mar 10, 2021, 2:32:43 PM3/10/21
to NetPyNE Q&A forum
Hi Joe,

I changed 'hSec' to 'hObj' but I got an error: 

  TypeError: 'NoneType' object is not subscriptable. 

I guess there is something incorrect in 'sec['synMechs'][0]['hSyn']._ref_i'.

Thanks,
Zhihe

Joe Graham

unread,
Mar 11, 2021, 9:55:17 AM3/11/21
to NetPyNE Q&A forum
Hi Zhihe,

Yeah, that might be the problem; it's hard to diagnose without seeing the patient...  If you could share your code I would be happy to run it and see what I can figure out.

Cheers,
Joe

Salvador Dura

unread,
Mar 11, 2021, 10:05:06 AM3/11/21
to NetPyNE Q&A forum
you also need to replace 'hSyn' with 'hObj'

in summary, any NEURON object is now contained within the key 'hObj'.

zhao.z...@gmail.com

unread,
Mar 11, 2021, 10:05:20 AM3/11/21
to NetPyNE Q&A forum
Hi Joe,

Here I attached the mechanism 'two_compartment.mod' and the test1.py script. You should be able to run the test1.py (comment out line69-70 for setpointer). 

Thanks,

Zhihe

test1.py
two_compartment.mod

Joe Graham

unread,
Mar 11, 2021, 12:47:27 PM3/11/21
to NetPyNE Q&A forum
Hi Zhihe,

I successfully compiled your mod file, but I can't seem to run anything (even without setpointer) without getting a segmentation fault in NEURON.  NetPyNE is a wrapper around NEURON, so any code you want to use must be functional in NEURON before it can be used in NetPyNE. 

Here is the code I tried just to make sure your mod file worked:

import matplotlib.pyplot as plt
from neuron import h
h.load_file('stdrun.hoc')

soma = h.Section(name='soma')
mod = h.twocomps(soma(0.5))

i_vec = h.Vector()
t_vec = h.Vector()
i_vec.record(mod._ref_isyn)
t_vec.record(h._ref_t)
simdur = 25.0

h.tstop = simdur
h.run()

plt.figure()
plt.plot(t_vec, i_vec)
plt.xlabel('Time (ms)')
plt.ylabel('isyn (nA)')
plt.show() 

Running it results in a segmentation fault for me.

If you can get the above code running, then I can help you get it into NetPyNE.  Let us know if you need any more help.

Best wishes,
Joe

zhao.z...@gmail.com

unread,
Mar 11, 2021, 1:20:58 PM3/11/21
to NetPyNE Q&A forum
Hi Joe,

Thank you! I think this should work with the test1.py script. 

I don't know why I got the message "Kernel died, restarting" after running h.run() in your code. I am trying to figure it out. 

Best,
Zhihe
two_compartment.mod

Joe Graham

unread,
Mar 11, 2021, 1:48:06 PM3/11/21
to NetPyNE Q&A forum
The new mod file won't compile for me.

zhao.z...@gmail.com

unread,
Mar 11, 2021, 2:10:10 PM3/11/21
to NetPyNE Q&A forum
It is weird. I can successfully compile it using 'mknrndll', but I got some Notices.
 compile.png
Best,

Zhihe

Joe Graham

unread,
Mar 11, 2021, 7:28:13 PM3/11/21
to NetPyNE Q&A forum
Hi Zhihe, 

I was able to get your mod file compiled and your test1.py to run (without the setpointer).

This is a complicated case, so please let me know if I'm misunderstanding anything.  Instead of having NEURON calculate the section voltage based on membrane currents, your mod file calculates the section voltage.  You specified this for NetPyNE with:

    PYR_twocomp['secs']['soma']['pointps']['twocomp']['vref'] = 'vs'

This is similar to an example on our website using an Izhikevich mod:

You want to be able to use the current from an Exp2Syn to feed into your cell soma and affect its voltage, but your voltage is calculated in your mod file, and your mod file doesn't accept currents, it accepts events with a weight.  The Izhikevich mod includes its own synaptic mechanisms because (it seems to me) another NEURON mech has no way of affecting the (independent voltage) calculated in the mod file.  I think this is the problem with your case.

I will ask around, but I'm pretty sure you need to talk to a NEURON expert.  I'm not sure what you're trying to do is possible in NEURON with your current mod file (I think you may need to code Exp2Syn into your mod file).  If you can get a working example going in NEURON/Python (like the code I shared above), then I can be of more help getting it going in NetPyNE.

Cheers,
Joe




zhao.z...@gmail.com

unread,
Mar 11, 2021, 9:07:41 PM3/11/21
to NetPyNE Q&A forum
Hi Joe,

Yes, that is exactly what I was trying to do. I will try to make it work in NEURON/Python first. Thank you for your help. I greatly appreciate it!

Best,

Zhihe 

Joe Graham

unread,
Mar 16, 2021, 9:56:41 AM3/16/21
to NetPyNE Q&A forum
Hi Zhihe,

Here is some advice from a NEURON expert: 

"note that since 7.7.2 (I think), you don’t need setpointer, and can just, uh, set the pointers with an = assignment (have to assign a pointer, obv)"

"also: that mod file looks like a thing that should be done with an ARTIFICIAL_CELL not a POINT_PROCESS e.g. as in https://senselab.med.yale.edu/modeldb/showmodel.cshtml?model=37819&file=%2fthal_aug_resp%2fintf.mod#tabs-2 "

Hope that helps.

Best wishes,
Joe
Reply all
Reply to author
Forward
0 new messages