When Python is the interpreter, what is a good
design for the interface to the basic NEURON
- Posts: 35
- Joined: Fri Apr 25, 2014 10:54 am
I have a model with over 10000 sections, specified in Python via the neuron module. When I execute:
I am warned:
Code: Select all
NEURON: Stack too deep. Increase with -NSTACK stacksize option
If I then execute:
and use the ModelViewer to visualize the topology, it's clear that it didn't load more compartments than the limited stacksize.
Is it possible to increase this parameter in Python? Normally it is changed via the command line, or modifying /nrn/share/nrn/lib/nrn.defaults, but it would be nice for model sharing if my script could update the interpreter without requiring the user to climb into the source.
- Site Admin
- Posts: 1575
- Joined: Wed May 18, 2005 3:32 pm
I'm afraid that is not supported.
It's too bad that h.topology() even uses the hoc stack. It just needs to visit each of the child sections of a section in reverse order.
- Posts: 153
- Joined: Fri Nov 28, 2008 3:38 pm
- Location: Yale School of Medicine
If you're using NEURON 7.3 or higher, the reaction-diffusion's morphology submodule will allow you to easily write a version of topology in pure Python.
I haven't tested edge cases (i.e. connecting to positions other than the 1 end), but here's a version that does at least the basics:
Code: Select all
from neuron.rxd import morphology
morph = morphology.MorphologyDB()
def print_morph(sec, indent=0):
print (' ' * indent) + sec.name()
for child in morph.children(sec):
print_morph(child, indent + 2)
for root in morph.roots:
This is recursive, but that's not a huge issue in Python, because there you can set the maximum recursion depth at runtime.