Loading NMODL mechanisms....

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

Moderator: hines

Post Reply
gartland

Loading NMODL mechanisms....

Post by gartland » Mon Mar 24, 2008 9:07 pm

Hi,
I have been initializing hoc objects, loading in NMODL mechanisms and inserting the mechanisms semi-successfully using the lines:

Code: Select all

os.system('/usr/local/nrn/i686/bin/nrnivmodl')
h=hoc.HocObject()
h.nrn_load_dll("/home/gartland/rgc/i686/.libs/libnrnmech.so")
h('create soma')
h('access soma')
h('insert spike')
h('ena_spike=40')
I can also use this syntax:

Code: Select all

soma=Section()
soma.push()
soma.insert('pas')
soma(0.5).pas.e=-80
But I can't mix and match (which would be fine and understandable), and I can't do this:

Code: Select all

soma.insert('spike')
soma(0.5).spike.ena=40
This syntax is extremely useful for setting and getting the values of range variables and parameters later, but when I try to soma.insert() I receive the following error:
argument not a density mechanism name
It seems like maybe the mechanisms added with load_dll aren't visible to the insert command accessed with python dot notation? I also get similar errors when I try to do:

Code: Select all

h('insert spike')
soma(0.5).spike.ena=40
Unfortunately I don't have a ton of NEURON experience in hoc so I can't tell if this is a problem with the way I'm trying to use the mechanism or the way that new mechanisms are imported into python. Do you have any idea why I can't insert mechanisms that I've loaded using nrn_load_dll()? Thanks for the help!

-Andrew

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

Post by hines » Sun Apr 06, 2008 4:03 pm

You're right. The python part is not updating its list of mechanisms after
nrn_load_dll. I'll fix that as soon as I can.
Are you happy merely with a subversion repository commit or do you need an installer.

gartland

Post by gartland » Sun Apr 06, 2008 4:12 pm

Cool thanks! I bet turning NEURON into a python module isn't much fun, but it sure does make it easier for me to use and integrate with other analysis routines etc.

I can probably figure out the subversion repository if you give me a couple pointers. I shouldn't have any trouble building the code once i get it on my machine though.

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

Post by hines » Sun Apr 06, 2008 4:32 pm

I should mention that you can avoid the
nrn_load_dll call by launching in the directory where you ran nrnivmodl. Or if you launch using nrniv (instead of ipython) then you can also use the -dll path args
to get things loaded early enough so python will know the mechanism names.

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

Post by hines » Sun Apr 06, 2008 5:49 pm

The changeset
http://www.neuron.yale.edu/cgi-bin/trac ... geset/2046
contains the fix. You can get the repository version using the instructions half way down at
http://www.neuron.yale.edu/neuron/install/getdevel.html

Post Reply