How to find the command behind any NEURON GUI button

Often, I will quickly run a simulation test just using the NEURON GUI. However, once I’m ready to script the model and run from Python, it can be quite the hassle to figure the Python command(s) that are behind the actions I performed with the mouse.

Luckily, there is a quick method do to that: Search for the phrase you see in the GUI in the official NEURON repository. No need to download anything or sift through the documentation or the NEURON forums.

Example

Suppose you need to set the “Points plotted/ms” value. Yes, you can do it with the RunControl widget, but how do you do it in code?

Search for the GUI phrase in the NEURON source code

Go to the official NEURON Github repository: https://github.com/neuronsimulator/nrn

And search for the phrase, typing exactly what you see written on the button in quotes:

Most of the code is written in HOC, but the conversion to Python is usually to just prepend the “h.” in front of the HOC command.

The first result shows that the button first sets the h.steps_per_ms value, and then runs the h.setdt() method.

For other GUI actions, you may need to follow the HOC code to figure out how NEURON does it.