inserting synaptic mechanisms from mod file

NMODL and the Channel Builder.
Post Reply
Natali83
Posts: 1
Joined: Wed Mar 25, 2020 4:39 pm

inserting synaptic mechanisms from mod file

Post by Natali83 »

Hello,

I'm using python that import neuron as a package.

I want to insert a synaptic mechanism from a .mod file.
The code was working three years ago, but now is giving me an error
when I tried to import the mechanism.

here is the code that I'm using:

#Compile the mod file
!nrnivmodl

# import packages
import neuron
from neuron import h
import numpy
import matplotlib.pyplot as plt
# Load external files & initialize
neuron.h.load_file("stdrun.hoc");
neuron.h.stdinit();

# Create a simple neuron to host the synapse
soma = neuron.h.Section()
soma.L = 40
soma.diam = 40
soma.insert('pas')

# Configure the passive biophysics
for sec in h.allsec():
sec.Ra = 100
sec.cm = 1

# Insert the synaptic mechanism
synapse = h.SimpleAMPA_NMDA(soma(0.5))
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
<ipython-input-6-50fc4935bda3> in <module>
----> 1 synapse = h.SimpleAMPA_NMDA(soma(0.5))

AttributeError: 'hoc.HocObject' object has no attribute 'SimpleAMPA_NMDA'
ted
Site Admin
Posts: 6287
Joined: Wed May 18, 2005 4:50 pm
Location: Yale University School of Medicine
Contact:

Re: inserting synaptic mechanisms from mod file

Post by ted »

First, a comment about the example code in your post: many of the statements in it are deprecated or useless or serve no useful purpose at the point at which they are executed. A strong suggestion: if you want a quick, up-to-date, and reasonably complete introduction to using Python to build NEURON models and run simulations, go to NEURON's Documentation page https://neuron.yale.edu/neuron/docs, find the link labeled Scripting NEURON with Python, and work through that tutorial. It'll save you a lot of time and effort, and you'll be able to write usable, readable Python that properly takes advantage of NEURON.

The error message
AttributeError Traceback (most recent call last)
<ipython-input-6-50fc4935bda3> in <module>
----> 1 synapse = h.SimpleAMPA_NMDA(soma(0.5))
suggests that NEURON doesn't know anything about SimpleAMPA_NMDA. Presumably that's a point process implementation of a synaptic mechanism that is written in NMODL. My guess is that either you haven't put the mod file for that mechanism in the same directory as where your Python file is located, or that the embedded command
!nrnivmodl
is not forcing compilation of the mod file(s) that are in that directory. IMO it's a bad idea to stick too much stuff into a program, and it's never a good idea to bundle compilation of mod files into the Python file that specifies a NEURON model. Suggest eliminating that command from your Python file, and instead running nrnivmodl from the command line instead. Then you will see whether compilation succeeds, or fails with error messages.
Post Reply