Not able to run simulation more than once from a NEURON+Python script
Posted: Tue Aug 21, 2018 11:58 am
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:
where morphology is a path to an .SWC file. Prior to this, stdlib.hoc and import3d.hoc were loaded manually.
The error itself is
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)
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