How to combine GUI with hoc programming

The basics of how to develop, test, and use models.
Post Reply
guanbc
Posts: 9
Joined: Mon Feb 18, 2019 6:37 am

How to combine GUI with hoc programming

Post by guanbc »

A very basic question, which may sound silly. Now I can only do simple modeling using Neuron GUI and recreate the model by writing simple init.hoc that contains loading ses file information. I am wondering how to combine GUI with hoc programming to get more flexibility. After opening nrngui and recreating the model, there is a black window entitled 'nrngui', showing the Neuron version and oc> . For combining GUI with hoc programming, where should the hoc lines be written, in the black window or just in a simple text editor, and how to combine them? Or just open the ses file using a text editor and modify it?
ted
Site Admin
Posts: 5797
Joined: Wed May 18, 2005 4:50 pm
Location: Yale University School of Medicine
Contact:

Re: How to combine GUI with hoc programming

Post by ted »

hoc and Python are programming languages. The typical workflow for working with a programming language is

Code: Select all

REPEAT
  write statements in the programming language
  execute the statements
  evaluate the results
UNTIL one has a collection of statements that do what one wants
The first step is done by writing the statements in a plain text editor (not Word) and saving them to a file.
The second step is done by using a program to execute the statements. Usually this involves entering a command in a terminal that makes a program such as NEURON or Python read a text file and execute the statements in that file. Examples:
nrngui foo.hoc # starts NEURON, which executes the contents of foo.hoc
python bar.py # starts Python, which executes the contents of bar.py

NEURON's GUI tools offer a way to avoid having to write code. They work by generating hoc statements that are interpreted by NEURON, so they can substitute for one or more hoc statements. Example: if stim.ses is a session file for a PointProcessManager configured as an IClamp, then the hoc statement
load_file("stim.ses")
will recreate that IClamp. The Python statement
h.load_file('stim.ses') will do the same thing.

A ses file contains hoc statements that recreate not only the IClamp, but also the PointProcessManager (the graphical tool for managing the IClamp). Those hoc statements are generated by the computer, and they are not intended to be edited by users.
guanbc
Posts: 9
Joined: Mon Feb 18, 2019 6:37 am

Re: How to combine GUI with hoc programming

Post by guanbc »

Now that I have saved a workable ses. file for a simple GUI made model, and I want to change the ena from default by changing nao and nai. would you please give a concrete example; eg,I'd like nao and nai to be 44 mM and 50 mM respectively? the Neuron Book is still a bit too abstract. Should I write a hoc file like this?

load_file("nrngui.hoc")
USEION na READ nao nai
nao = 44
nai = 50
load_file("mycell3.ses")
ted
Site Admin
Posts: 5797
Joined: Wed May 18, 2005 4:50 pm
Location: Yale University School of Medicine
Contact:

Re: How to combine GUI with hoc programming

Post by ted »

Should I write a hoc file like this?
That will do nothing useful. It won't get past the second line, which is in NMODL, not hoc. The third and fourth lines will not affect intra- or extracellular sodium concentration because ionic concentrations only exist in the context of sections that contain channels or other mechanisms specified by NMODL code that contain relevant USEION statements. Furthermore, the equilibrium potential of an ionic species is calculated from its intra- and extracellular concentrations only in a section that has a mechanism that WRITEs the intra- and or extracellular concentration of that species, or if an ion_style() statement has been executed that tells NEURON it must calculate the equilibrium potential from concentration.

To sum up: the equilibrium potential and concentrations of an ion x do not exist in a section unless that section has a mechanism that uses that ionic species. And even if the equilibrium potential does exist, it is a simple constant independent of concentration unless there is a mechanism that writes one of the concentrations or you use ion_style() to tell NEURON that it must calculate the equilibrium potential from the ionic concentrations.
Post Reply