Not able to run simulation more than once from a NEURON+Python script

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

Moderator: hines

Post Reply
MarkoF
Posts: 7
Joined: Thu Nov 24, 2016 5:13 pm

Not able to run simulation more than once from a NEURON+Python script

Post by MarkoF »

Hello,

I have a problem where trying to run a NEURON simulation from a Python script more than once (e.g. in a loop) would result in a hoc error* after the first successful run. The only way to handle it that I've found is to exit that Python instance, create a new one, and call the script again.

Furthermore, if I take all the code in that script that successfully runs at least the first time, and copy-paste it directly into a new terminal and Python instance, I get the same hoc error. So the same code runs normally (at least once) when called from a script, but when copy-pasted into a terminal (perserving all the indetation) it creates the hoc error.

I've been trying to debug the problem for days to no avail. Ultimately, a colleague ran the same script on two of his machines (Debian and OSX), and on both machines the script finished successfully in its entirety - the loop that calls the simulation iterated multiple times not generating any error. So it has something to do with my machine. Clean installation of NEURON (following this guide, with all the options) didn't help.

My system is Ubuntu 18.04, running Python 2.7.15 from Anaconda. I have probably forgot to give some necessary data, please tell me what I need to supply.



*For reference, this particular hoc error appears after execution of the last of these three lines:

Code: Select all

from neuron import h
...
Import = h.Import3d_SWC_read()
Import.input(morphology)
where morphology is a path to an .SWC file. Prior to this, stdlib.hoc and import3d.hoc were loaded manually.

The error itself is

Code: Select all

NEURON: Arg out of range in user function
 near line 0
 ^
        Import3d_Section[0].Matrix(3, 0)
      Import3d_Section[0].init(0, 0)
    Import3d_SWC_read[0].mksection(0, 0, 0)
  Import3d_SWC_read[0].mksections()
and others
oc_restore_code tobj_count=1 should be 0
ted
Site Admin
Posts: 6289
Joined: Wed May 18, 2005 4:50 pm
Location: Yale University School of Medicine
Contact:

Re: Not able to run simulation more than once from a NEURON+Python script

Post by ted »

a colleague ran the same script on two of his machines (Debian and OSX), and on both machines the script finished successfully in its entirety - the loop that calls the simulation iterated multiple times not generating any error. So it has something to do with my machine.
Might he be using different versions of NEURON and/or Python than you are?
MarkoF
Posts: 7
Joined: Thu Nov 24, 2016 5:13 pm

Re: Not able to run simulation more than once from a NEURON+Python script

Post by MarkoF »

He has the same NEURON version, but his Python is 2.7.13 (compared to my 2.7.15). I will see if it is possible to create a virtual environment with that particular sub-version and compile NEURON with it.
ramcdougal
Posts: 267
Joined: Fri Nov 28, 2008 3:38 pm
Location: Yale School of Public Health

Re: Not able to run simulation more than once from a NEURON+Python script

Post by ramcdougal »

Doesn't solve the mystery, but...

Assuming the morphology is not changing with successive runs, you could load it once before entering the loop, and see this particular issue entirely
MarkoF
Posts: 7
Joined: Thu Nov 24, 2016 5:13 pm

Re: Not able to run simulation more than once from a NEURON+Python script

Post by MarkoF »

Just as an update, testing the script from a virtual environment with Python 2.7.13 and NEURON from conda repository, I get the same error. So it probably is not tied to the Python version.

@ramcdougal I will try to adapt the script to work in that way and see what happens, thanks for the suggestion!
Post Reply