Cannot get the syntax correct for creating a gap junction

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

Moderator: hines

Post Reply
maxwellphenderson
Posts: 22
Joined: Mon Mar 07, 2011 12:17 am

Cannot get the syntax correct for creating a gap junction

Post by maxwellphenderson » Fri Feb 22, 2013 3:54 pm

Hello,

I have found several examples for creating gap junctions using hoc; some form of:

Code: Select all

gap_ = new Gap(0.5)
I cannot find the way to do this using Python. I have tried variations and have been looking around for a while in the documentation but not really finding what I needed. Thanks for the help!

maxwellphenderson
Posts: 22
Joined: Mon Mar 07, 2011 12:17 am

Re: Cannot get the syntax correct for creating a gap junctio

Post by maxwellphenderson » Fri Feb 22, 2013 4:47 pm

Also just to add a bit more: I have found that the file gap.mod exists and currently is in the directory:

/neuron/nrn/share/examples/nrniv/nmodl

I also copied it and put it in the same directory as netstim.mod because I found other point process mod files there. Doesn't appear to have helped.

maxwellphenderson
Posts: 22
Joined: Mon Mar 07, 2011 12:17 am

Re: Cannot get the syntax correct for creating a gap junctio

Post by maxwellphenderson » Fri Feb 22, 2013 7:59 pm

One final word - I have been poking around different stuff, and the error that I get when I try

Code: Select all

g = h.gap(0.5, sec = soma)
is

AttributeError: 'hoc.HocObject' object has no attribute 'gap'

So I guess I'm trying to figure out if I am calling this wrong, or if something didn't load / install correctly for me. Thanks!

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

Re: Cannot get the syntax correct for creating a gap junctio

Post by ted » Fri Feb 22, 2013 9:36 pm

maxwellphenderson wrote:Also just to add a bit more: I have found that the file gap.mod exists and currently is in the directory
Put the mod file in the same directory as your model's hoc or python file(s), then compile it by running mknrndll or nrnivmodl on that directory; if you need help with that, look in NEURON's FAQ list (see link at http://www.neuron.yale.edu/neuron/docs) for how to compile mod files. The next time you run NEURON from that directory, NEURON will automatically load the compiled code for the new mechanism and it will be available for your python- or hoc-specified model.

maxwellphenderson
Posts: 22
Joined: Mon Mar 07, 2011 12:17 am

Re: Cannot get the syntax correct for creating a gap junctio

Post by maxwellphenderson » Sat Feb 23, 2013 3:35 pm

Hmm... I think I am having some problems with how I installed NEURON, possibly. I installed NEURON without interviews (which I am guessing is probably ok?).

I installed everything into a folder called 'neuron' (as suggested for obvious reasons in the installation information). When I try to follow the commands for compiling gap.mod:

Code: Select all

modlunit gap.mod
I receive the error:

modlunit: command not found

Also for some reason... when I am in the folder neuron, I have all my python files that import neuron and everything runs smoothly for those. For example, I can run

>> python test.py

which contains:

Code: Select all

from neuron import *
from neuron import h as nrn
from numpy import *
from pylab import *

print h.dt
and get the ouput:

NEURON -- Release 7.1 (359:7f113b76a94b) 2009-10-26
Duke, Yale, and the BlueBrain Project -- Copyright 1984-2008
See http://www.neuron.yale.edu/credits.html

0.025

However, when I try running

>> from neuron import *

in the command line (first line in the python program test.py), my mouse turns into a cross for highlighting something and neuron doesn't appear to load properly, and I am still in the same directory as the python file. Would definitely appreciate help, I tend to be very bad at this kind of thing.. thanks again!

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

Re: Cannot get the syntax correct for creating a gap junctio

Post by ted » Sun Feb 24, 2013 11:52 am

maxwellphenderson wrote:When I try to follow the commands for compiling gap.mod:

Code: Select all

modlunit gap.mod
I receive the error:

modlunit: command not found
1. The command that compiles mod files under UNIX, Linux, and OS X, is nrnivmodl. modlunit checks a mod file for consistency of units.
2. If you installed NEURON from source code but modlunit produces a "command not found" error, your installation is not complete because you haven't added the location of NEURON's executables to your environment's PATH. On my PC I have installed NEURON in /usr/local, and
echo $PATH
reveals that my PATH contains
/usr/local/nrn/i686/bin
You'll probably want to review the installation instructions--see the appropriate link at http://www.neuron.yale.edu/neuron/download

maxwellphenderson
Posts: 22
Joined: Mon Mar 07, 2011 12:17 am

Re: Cannot get the syntax correct for creating a gap junctio

Post by maxwellphenderson » Sun Feb 24, 2013 2:52 pm

Thanks so much for the help with setting the path correctly! After I fixed that, I ran nrnivmodl and everything worked correctly! :)

Now my only remaining issues come back to original syntax issues... when I run the code:

Code: Select all

g = h.gap()
print g
The output I get is:

NEURON -- Release 7.1 (359:7f113b76a94b) 2009-10-26
Duke, Yale, and the BlueBrain Project -- Copyright 1984-2008
See http://www.neuron.yale.edu/credits.html

loading membrane mechanisms from i686/.libs/libnrnmech.so
Additional mechanisms from files
SinClamp.mod gap.mod izap.mod
gap[0]

So that part is OK. However, I still am having difficulties figuring out how to take the hoc code and converting it into python format. I have two section objects a and b, for example. The hoc code I found was:

Code: Select all

a g.loc(0.9999)
setpointer g.vap, b.v(0.0001)
Which seems to set up a a current flow between a flowing into b. Can you tell me the python version of this?

maxwellphenderson
Posts: 22
Joined: Mon Mar 07, 2011 12:17 am

Re: Cannot get the syntax correct for creating a gap junctio

Post by maxwellphenderson » Sun Feb 24, 2013 3:41 pm

To add a bit more (again), the closest I could make was

Code: Select all

#create sections
soma = h.Section()
soma1 = h.Section()
# Insert gap junction  
gap_junction = h.gap(0.9999, sec=soma)
gap_junction.r = 1.0
# Connect gap junction to pre-synaptic cell
h.setpointer(gap_junction._ref_vgap, '_ref_v', soma1(0.0001)._ref_v)
But this receives an error on the last line:

Traceback (most recent call last):
File "testGap.py", line 30, in <module>
h.setpointer(gap_junction._ref_vgap, '_ref_v', soma1(0.0001)._ref_v)
TypeError: setpointer(_ref_hocvar, 'POINTER_name', point_process or nrn.Mechanism))

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

Re: Cannot get the syntax correct for creating a gap junctio

Post by ted » Mon Feb 25, 2013 11:45 pm

I'd expect this part
gap_junction = h.gap(0.9999, sec=soma)
would attach an instance of gap to the last internal node of soma i.e. the node near soma's 1 end.

You appear to want gap_junction's vgap variable to point to the membrane potential at soma1's first internal node.
In hoc this would be done with the statement
setpointer gap_junction.vgap, soma1.v(0.001)
I'd expect the corresponding Python syntax to be
h.setpointer(soma1(0.001)._ref_v, 'vgap', gap_junction)

For more information about this kind of stuff, read about Python accessing hoc
http://www.neuron.yale.edu/neuron/stati ... essing_Hoc
especially the examples involving setpointer.

maxwellphenderson
Posts: 22
Joined: Mon Mar 07, 2011 12:17 am

Re: Cannot get the syntax correct for creating a gap junctio

Post by maxwellphenderson » Wed Feb 27, 2013 11:52 am

Everything is now working correctly and even built my own version of a gap.mod file! Thanks for the help! :)

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

Re: Cannot get the syntax correct for creating a gap junctio

Post by ted » Wed Feb 27, 2013 11:01 pm

Great. Go ye now forth and do publishable work!

Post Reply