Page 1 of 1

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

Posted: Tue Aug 21, 2018 11:58 am
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

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

Posted: Wed Aug 22, 2018 12:11 am
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?

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

Posted: Wed Aug 22, 2018 4:22 am
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.

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

Posted: Wed Aug 22, 2018 6:13 am
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

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

Posted: Wed Aug 22, 2018 10:47 am
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!