Different questions regarding HOC- and NEURON

The basics of how to develop, test, and use models.
Post Reply
Bonic
Posts: 7
Joined: Mon Nov 19, 2018 2:55 pm

Different questions regarding HOC- and NEURON

Post by Bonic »

Hey,

At the moment i try to learn HOC with a Tutorial provided by the MIT as i will need to make NEURON-Simulation in my thesis. Thereby some questions came up, you may can help me with:

Firstly, it was striking that in HOC you always have to declare "objectvariables" with for example "objectvar stim". What is the benefit of doing this? Why is it not enough to just write "stim = newIClamp(0.5)? Also i recognized that in HOC (or in the HOC tutorial i am doing) an "objectvariable" seems to be something different than in Python, as in the HOC Tutorial the term "objectvariable" revers to something what would be an object/instance in Python. Is that correct? In the same way, does in HOC the term "template" means the same as the term "class" in Python?

Another point that confused me was the following code within the MIT NEURON Tutorial:

Code: Select all

"begintemplate STHcell 
public soma, dend

create some, dend[1]

proc init() {

     ndend = 2 
     
     create soma, dend[ndend]
     
     soma{ ...etc. etc. 
     
     
Why does one has to create "soma, dend" two times? Is the method "proc init()" not able to work with something that was declared outside of the function?


My other question is in regard to the simulations itself:

In the tutorial it is written: "To avoid the transient phase, its a good idea to let the simulation run for a while before performing the experimental manipulations. In the example above, we wait 100 ms before injecting current"

Why does NEURON simulate the transient phase? It is to make the simulation biologically more realistic? Without the transient phase one could start the simulation immediatly...

My questions might seem "very basic" to the most of you, but anyways it would help me a lot if someone would answer.

Kind Regards,

Bonic
Last edited by Bonic on Thu Nov 22, 2018 3:19 pm, edited 2 times in total.
ted
Site Admin
Posts: 6286
Joined: Wed May 18, 2005 4:50 pm
Location: Yale University School of Medicine
Contact:

Re: Different questions regarding HOC- and NEURON

Post by ted »

Bonic wrote: Thu Nov 22, 2018 5:34 amwith a Tutorial provided by the MIT
Never heard of it--the tutorial, that is, not MIT. Where did you find it? How do you know it's any good?
it was striking that in HOC you always have to declare "objectvariables" with for example "objectvar stim".
From one perspective, that might seem just another inexplicable manifestation of a hostile or indifferent universe, but actually it's merely an accident of history. Why don't you use Python instead of hoc? Here's a tutorial that will help you get going: https://neuron.yale.edu/neuron/static/d ... index.html Of course you are free to do whatever you like, but you will bear the consequences of your choice.

We recommend that all new user-written code be in Python. All existing hoc code still works, and can be used from Python, so there's no need to rewrite any old hoc code. And you can use hoc code generated by the CellBuilder and Import3d tool with Python.

Here's some documentation that will help you deal with legacy hoc code that you may encounter
https://www.neuron.yale.edu/ftp/neuron/ ... wledge.pdf
and here's a concise introduction to hoc syntax
https://www.neuron.yale.edu/ftp/neuron/ ... slides.pdf
in the HOC Tutorial the term "objectvariable" revers to something what would be an object/instance in Python.
True.
does in HOC the term "template" means the same as the term "class" in Python?
A template is a definition of a hoc class. It's trivial to reuse hoc classes from Python. For example, suppose cell.hoc contains a template that defines a cell class called Pyr, and that an instance of the Pyr class has sections called soma and dend that are public. Then this Python script

from neuron import h
h.load_file("cell.hoc")
pyramid = h.Pyr()

will create an instance of the Pyr class and its sections will be known to Python as pyramid.soma and pyramid.dend--exactly the same as if you had used Python to define a cell class that has two sections called soma and dend. By the way, this means that you can use the CellBuilder to create new cell class definitions and use those hoc files with your own Python code.
begintemplate STHcell
I see--you stumbled across the tutorial that Gillies and Sterratt wrote years ago. Interesting from a historical perspective, but no need for it now. Stick with Python.
In the tutorial it is written: "To avoid the transient phase, its a good idea to let the simulation run for a while before performing the experimental manipulations. In the example above, we wait 100 ms before injecting current"

Why does NEURON simulate the transient phase? It is to make the simulation biologically more realistic? Without the transient phase one could start the simulation immedeatly...
A mechanistic computational model of a neuron consists of a system of one or more ordinary differential equations (ODEs) that govern the time course of a set of variables called state variables. The ODEs are solved by numerical integration, a process in which the future values of the state variables are calculated from their current values. This poses a question: what values should the state variables have at time t==0? In all but the very simplest cases, it is impossible to know in advance what values to assign to the state variables at t==0, even if you expect that the model will be "at rest." Now you know something new.
Bonic
Posts: 7
Joined: Mon Nov 19, 2018 2:55 pm

Re: Different questions regarding HOC- and NEURON

Post by Bonic »

Hey Ted,

Thank you very much for you answer. By switching to the Python-Tutorial i will follow your advice and not burden myself with confusing HOC syntax anymore.
ted
Site Admin
Posts: 6286
Joined: Wed May 18, 2005 4:50 pm
Location: Yale University School of Medicine
Contact:

Re: Different questions regarding HOC- and NEURON

Post by ted »

Confusion is in the mind of the beholder. To those who are familiar with C/C++, hoc seems reasonably lucid but Python appears to be riddled with obscure syntax. My own opinion is that Python is as easily abused as any other programming language; in particular, obsessively "pythonic" code can be quite opaque to non-pythonistas.
Post Reply