When Python is the interpreter, what is a good
design for the interface to the basic NEURON
- Posts: 21
- Joined: Wed Jun 17, 2015 5:31 pm
I am having some difficulty finding an answer to the following question in the NEURON-Python documentation so far and was hoping for some guidance or pointing to the right direction.
My question is: How can I load (and thus execute) a hoc file from a python script that is accompanied by command line arguments?
For a simple hoc script I know that the statements load_file("temp.hoc)
in NEURON and h('load_file("temp.hoc")')
in Python are equivalent. However how can I execute more complex NEURON statements from within a python script, like the one below?
Code: Select all
nrniv -c gidOI=0 -c cellindOI=0 -c stimflag=0 -c "strdef runname" -c runname="\"some name\"" -c "strdef origRunName" -c origRunName="\"some name\"" -c "strdef celltype2use" -c celltype2use="\"some cell\"" -c "strdef resultsfolder" -c resultsfolder="\"00055\"" ./folder_results/run_name/00055/run.hoc -c "quit()"
thank you very much
- Site Admin
- Posts: 5784
- Joined: Wed May 18, 2005 4:50 pm
- Location: Yale University School of Medicine
The answer is "don't". That's a lousy user interface--it's inconvenient, tedious, prone to user error, not very readable, and guarantees irreproducibility ("now, what command line did I use to get this interesting result?"). And it's a great way to make sure that nobody else wants to use your code. Suggest instead that you put all of the options into a file called something like options.py or options.hoc that is loaded at runtime.
"Suppose I want to try many different sets of options?"
For each set of options
create an options file with a unique name, e.g. options321.py (or .hoc)
create a script called run321 that copies options321.py to options.py, then launches Python or NEURON
Then when you want to execute a run with that particular set of options, just execute the script called run321