inserting synaptic mechanisms from mod file

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

Moderator: hines

Post Reply
Posts: 1
Joined: Wed Mar 25, 2020 4:39 pm

inserting synaptic mechanisms from mod file

Post by Natali83 »


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

# import packages
import neuron
from neuron import h
import numpy
import matplotlib.pyplot as plt
# Load external files & initialize

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

# Configure the passive biophysics
for sec in h.allsec():
sec.Ra = 100 = 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'
Site Admin
Posts: 5988
Joined: Wed May 18, 2005 4:50 pm
Location: Yale University School of Medicine

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, 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
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