Running Neuron without the GUI

The basics of how to develop, test, and use models.
Post Reply
hpay
Posts: 3
Joined: Tue Sep 13, 2016 8:14 pm

Running Neuron without the GUI

Post by hpay » Thu Oct 06, 2016 11:03 pm

I'm running a series of simulations from Matlab by executing the following repeatedly (each time I change an underlying parameter set).

Code: Select all

system(fullfile(cd,'myFile.hoc'))
This runs the simulation successfully, but also pops up the little nrngui menu bar while doing so. I'm running a lot of short simulations and the constant popping up of this window interrupts my workflow! Is there a way have it run in the background without taking control of the mouse away from whatever else I'm doing?

(OS: Windows10)

ted
Site Admin
Posts: 5376
Joined: Wed May 18, 2005 4:50 pm
Location: Yale University School of Medicine
Contact:

Re: Running Neuron without the GUI

Post by ted » Fri Oct 07, 2016 11:49 am

First a comment: in most cases it is easy to construct a program for NEURON in such a way that a family of simulations can be generated without having to exit NEURON after each run and restart it before each parameter change (this can save a lot of time if model setup is a significant fraction of the time required to execute a single run), let alone rely on a shell script or some other program such as Matlab to control which parameter set is used in which run.

This

Code: Select all

system(fullfile(cd,'myFile.hoc'))
seems like a strange way to launch NEURON and get it to execute the contents of myFile.hoc. For one thing, it seems unlikely to be portable across operating systems, but then I don't know much about Matlab, and I have no idea what fullfile(...) is actually doing. Under OS X or Linux, and without the benefit of Matlab, one would ordinarily do
nrngui myFile.hoc
and if that caused the NeuronMainMenu toolbar to appear and one wanted to prevent that,
nrngui -nogui myFile.hoc
would suffice. This would also work under Windows if one were running NEURON from its bash window (see the bash icon in the NEURON program group and in the NEURON folder that is placed on your Desktop when you install NEURON).

If you absolutely have to stick with Matlab and system(fullfile(cd,'myFile.hoc')), then you might try editing myFile.hoc to replace every occurrence of

Code: Select all

load_file("nrngui.hoc")
with

Code: Select all

// load_file("nrngui.hoc")
load_file("stdgui.hoc")
But of course the next time you want the toolbar to appear, you'll have to go back and undo those edits.

hpay
Posts: 3
Joined: Tue Sep 13, 2016 8:14 pm

Re: Running Neuron without the GUI

Post by hpay » Fri Oct 07, 2016 8:35 pm

Thank you! My programming ability is currently 98% matlab and 2 % NEURON, but hopefully that will change :) And just now I'm figuring out how to run someone else's code.

1. Assuming I'm in the correct path, I realize now that "fullfile" is not necessary. fullfile simply creates a full path from component parts.

2. -nogui did the trick, but I need to call neuron, not nrngui for some reason. Guessing due to having added that to the system path (I added C:\nrn\bin\neuron.exe, because I didn't see nrngui.exe there, although I can open nrngui from the start menu)
This works great:

Code: Select all

                    system('neuron -nogui myFile.hoc');
Is there any difference in "neuron.exe" v. "nrngui.exe" /does it matter?
(I'm using version 7.4)

ted
Site Admin
Posts: 5376
Joined: Wed May 18, 2005 4:50 pm
Location: Yale University School of Medicine
Contact:

Re: Running Neuron without the GUI

Post by ted » Sun Oct 09, 2016 3:50 pm

hpay wrote:-nogui did the trick, but I need to call neuron, not nrngui for some reason
Must have something to do with the fact that you're using a Matlab "system call" to launch NEURON. What, I don't know. From the bash shell, nrngui works, as it does under Linux and OS X. As someone who doesn't use proprietary software and has no control over what developers of such software do, I tend to latch onto solutions that work across platforms, and must leave discovery of platform-specific methods to others.
Is there any difference in "neuron.exe" v. "nrngui.exe" /does it matter?
The only concern is whether NEURON will know where to look for the nrnmech.dll file which contains the compiled mechanisms that your code requires. Inability to find that file would make NEURON stop and issue an error message. If that isn't happening, you're OK.

While we're having this discussion, please tell me that your source code and data files are in their own directory, which is not contained in the NEURON installation tree, i.e. not a subdirectory of c:\nrn

hpay
Posts: 3
Joined: Tue Sep 13, 2016 8:14 pm

Re: Running Neuron without the GUI

Post by hpay » Sun Oct 09, 2016 9:43 pm

Thank you. Yes, my neuron source code and data (spike trains generated by matlab and stored in a .txt file) are in a totally separate folder.

(In case it clarifies the neuron v. nrngui question, nrngui doesn't work from the command prompt in Windows either, whereas neuron successfully launches the program)

Code: Select all

C:\Users\hpay4_000>nrngui
'nrngui' is not recognized as an internal or external command,
operable program or batch file.
(My system path includes C:\nrn\bin. Anyway its all fine because I can compile edits to the .mod mechanisms and run simulations successfully.)

Post Reply