Hello,
I'm a graduate student who studied with NEURON.
I conducted extracellular stimulation to anatomically realistic models via the code written by Ted, and investigated electric field thresholds (through apc.n, I checked somatic membrane polarized over 0 or not).
However, there was difference in threshold value according to dt and steps_per_ms.
1) dt=0.1ms and steps_per_ms=10.
2) dt=0.025ms and steps_per_ms=40.
The gap of threshold value between the two cases was 45 mV/mm.
I wondered what causes this difference of thresholds.
If you explain to me the reason, it would be really appreciated.
Thank you in advance.
The effect of changed dt and steps_per_ms

 Posts: 17
 Joined: Fri May 03, 2019 2:41 am

 Site Admin
 Posts: 5935
 Joined: Wed May 18, 2005 4:50 pm
 Location: Yale University School of Medicine
 Contact:
Re: The effect of changed dt and steps_per_ms
Electrical and chemical signaling in cells are described by ordinary and partial differential equations in which time and space are continuous variables. The equations that describe real cells do not have analytical solutions. Instead, it is necessary to solve them by numerical integration, a process that involves two steps
1. Discretization, in which the differential equations are replaced by a set of algebraic formulas that approximate the differential equations. Both space and time are discretized.
2. Use of an algorithm (integration method) in which the algebraic formulas are evaluated repeatedly to calculate an approximate solution, over a sequence of specific times, for each state variable (membrane potential, channel gating state, ionic concentration etc.) at particular locations in space.
The original differential equations are never solved. Instead, only the discretized approximate algebraic formulas are evaluated, so numerical integration can only produce approximate results. The error of of the approximate solution is generally reduced if time and space are chopped into smaller pieces. However, using a finer spatial or temporal discretization increases the computational burden (generates more equations that have to be evaluated, and forces evalutation at more points in time). Also, since numerical calculations in a digital computer have finite precision, each calculation introduces some roundoff error. If the spatial or temporal discretization is too fine, roundoff error can accumulate and corrupt the approximate solution.
For more about this, you might read chapter 4 in The NEURON Book, or see the chapter Numerical Integration Methods by Hines and Carnevale in the Encyclopedia of Computational Neuroscience.
1. Discretization, in which the differential equations are replaced by a set of algebraic formulas that approximate the differential equations. Both space and time are discretized.
2. Use of an algorithm (integration method) in which the algebraic formulas are evaluated repeatedly to calculate an approximate solution, over a sequence of specific times, for each state variable (membrane potential, channel gating state, ionic concentration etc.) at particular locations in space.
The original differential equations are never solved. Instead, only the discretized approximate algebraic formulas are evaluated, so numerical integration can only produce approximate results. The error of of the approximate solution is generally reduced if time and space are chopped into smaller pieces. However, using a finer spatial or temporal discretization increases the computational burden (generates more equations that have to be evaluated, and forces evalutation at more points in time). Also, since numerical calculations in a digital computer have finite precision, each calculation introduces some roundoff error. If the spatial or temporal discretization is too fine, roundoff error can accumulate and corrupt the approximate solution.
For more about this, you might read chapter 4 in The NEURON Book, or see the chapter Numerical Integration Methods by Hines and Carnevale in the Encyclopedia of Computational Neuroscience.

 Posts: 17
 Joined: Fri May 03, 2019 2:41 am
Re: The effect of changed dt and steps_per_ms
Thanks for your kind explanation.
Also, I read the article you recommended. However, I still have a question.
As you mentioned,
The reason I'm asking is that I'm calculating a bunch of neurons almost three thousands of neurons with a few parameters. Thus, small difference of dt is pretty important to my computing time. The original setting of neuron model was 0.025dt so I changed dt as 0.05 but threshold was changed. So I wonder how to determine dt by considering both computing time and more precise approximation.
I would appreciate your explanation.
Thank you,
Also, I read the article you recommended. However, I still have a question.
As you mentioned,
Then, how can I decide the appropriate level of discretization. In other words, How can I determine appropriate dt and steps_per_ms?The error of of the approximate solution is generally reduced if time and space are chopped into smaller pieces. ... f the spatial or temporal discretization is too fine, roundoff error can accumulate and corrupt the approximate solution.
The reason I'm asking is that I'm calculating a bunch of neurons almost three thousands of neurons with a few parameters. Thus, small difference of dt is pretty important to my computing time. The original setting of neuron model was 0.025dt so I changed dt as 0.05 but threshold was changed. So I wonder how to determine dt by considering both computing time and more precise approximation.
I would appreciate your explanation.
Thank you,

 Site Admin
 Posts: 5935
 Joined: Wed May 18, 2005 4:50 pm
 Location: Yale University School of Medicine
 Contact:
Re: The effect of changed dt and steps_per_ms
First, an important fact: NEURON's temporal discretization parameter is dt, not steps_per_ms. steps_per_ms is a parameter that specifies the interval at which graphs are updated. Of course, steps_per_ms and dt must be compatible with each otherfor example, if dt == 0.025 ms, then steps_per_ms can only be 40, 20, 10, 8, 5 . . .  in other words, the relationship between dt and steps_per_ms is
steps_per_ms = 1/(N*dt) where N is a whole number > 0 (that is, N may equal 1, 2, 3 . . . ).
To learn more about dt and steps_per_ms, read the item Why can't I change dt? in the Hot tips area of the NEURON Forum.
In light of all these sources of error, the most reasonable expectation of a model is for it to produce results that are qualitatively similar to experimental results. This same expectation can be used to guide spatial and temporal discretization. Run a series of simulations with different values of dt and compare results. If decreasing dt causes a qualitative change of simulation results (e.g. a qualitative change of firing pattern), then use the smaller value of dt. For spatial discretization, use the d_lambda rule (discussed in this Forum, especially in the Hot tips section).
steps_per_ms = 1/(N*dt) where N is a whole number > 0 (that is, N may equal 1, 2, 3 . . . ).
To learn more about dt and steps_per_ms, read the item Why can't I change dt? in the Hot tips area of the NEURON Forum.
This is always an empirical decision. For most models, 0.025 ms produces sufficiently accurate simulation results. What is "sufficient accuracy"? Remember that a computational model is an approximation to your conceptual model (your hypothesis), and that your hypothesis is a simplified approximation of physical reality. Furthermore, most biological parameters are known to only about 5 to 10% precision. Finally, realize that, for any given cell class, there is a great deal of anatomical and biophysical variability from cell to cell within an individual animal and from one animal to another. Consider the error that is introduced into a model by combining parameters that were obtained from different cells across different animals.How can I determine appropriate dt
In light of all these sources of error, the most reasonable expectation of a model is for it to produce results that are qualitatively similar to experimental results. This same expectation can be used to guide spatial and temporal discretization. Run a series of simulations with different values of dt and compare results. If decreasing dt causes a qualitative change of simulation results (e.g. a qualitative change of firing pattern), then use the smaller value of dt. For spatial discretization, use the d_lambda rule (discussed in this Forum, especially in the Hot tips section).