Page 1 of 1

List of all currents that comprise segment membrane current

Posted: Thu Sep 09, 2021 6:02 pm
by zman147
Hello,

I'm attempting to use NEURON to simulate a spiking neuron and then calculate the extracellular potentials that might be measured by a microelectrode array. To do this I'm taking the transmembrane currents from each segment and applying a transformation function to them according to the line-source approximation (as is done in the software LFPy). However, I've been getting some results I don't quite understand so I'm now trying to look at how each independent ion current contributes to the measured extracellular potential.

My problem is that I cannot seem to get the sum of the ionic currents for each segment to equal the segment's i_membrane_ value. I manually collected a list of every ion current I thought would be included in the model by using dir(h) (ina, ik, ica, i_pas, i_cap, il_hh, etc.) and recorded them but for some of the segments the membrane current I calculate (by summing each individual ion current and multiplying by the segment area) differs from the i_membrane value (although for many segments they are identical). This leads me to believe I am somehow missing a current. Is there a way to list all of the ion/other currents that sum to produce a segment's total membrane current? Please let me know if I can clarify anything. Thanks!

Re: List of all currents that comprise segment membrane current

Posted: Fri Sep 10, 2021 10:58 am
by ted
I cannot seem to get the sum of the ionic currents for each segment to equal the segment's i_membrane_
How big is the discrepancy? If you are using fixed time step, does the discrepancy become smaller if you switch to adaptive integration?

Re: List of all currents that comprise segment membrane current

Posted: Mon Oct 24, 2022 4:24 pm
by bbujfalussy
Hi,

We have a similar problem: we want to add all currents flowing into a given segment, including membrane and axial currents. Ideally the sum of all currents equal the capacitive current.

This works fine when we use forward Euler's integration method - but then the whole simulation is inaccurate and/or slow.

However, when we use Crank–Nicolson integration, the total sum of the currents is slightly different than the capacitive current - even in a single compartment with simple Hodgkin Huxley currents. This difference can grow much larger in models with faster voltage sensitive channels.

I believe that this is because the voltage step at time t is calculated based on a first order approximation of the currents at time t+dt/2 and therefore currents and voltages are never completely consistent with each other.

My question is whether there is a simple way to make the model consistent? E.g., by accessing the first order approximation of the currents that is used to calculate the voltage derivative? Alternatively, is there a simple way to learn how exactly Neuron calculates these approximations?

Thanks,

Balazs

Re: List of all currents that comprise segment membrane current

Posted: Tue Oct 25, 2022 12:34 pm
by ted
when we use forward Euler's integration method
Then you must be using some other program than NEURON. NEURON doesn't offer the option of forward Euler. NEURON's fixed time step integration methods are limited to implicit Euler (which is the default method and has first order numerical error) and two variants of Crank-Nicholson (second order error in time).

To maximize computational speed, fixed time step integration advances from t to t+dt in the following way:
1. use v at t to calculate the currents at t
2. use the currents at t to calculate v at t+dt
This is why advancing by a single time step produces currents that are not in agreement with the values that would be calculated from v at t+dt

"Oh, that's horrible!"

Maybe, but it's actually what one should expect from a method that assumes currents are constant during a time step. Numerical error of v and i is proportional to dt. If you want less error, reduce dt.

The second order methods generate solutions for v that have second order numerical error. This means the values calculated at solution times tj = t + j*dt (where j = 0, 1, 2 . . . ) have error that is proportional to t^2. It also means that linear interpolation can be used to compute second order correct values of v at times that lie between t + j*dt and t + (j+1)*dt. The precision of channel conductances and ionic currents depends on the value of the user-specified global variable secondorder. Set secondorder to 1, and channel conductances have second order error at t+dt/2, but ionic currents have only first order error. If you also want ionic currents to have second order error, set secondorder to 2--but remember that ionic currents will be second order correct at t-dt/2. Read about this in the Programmer's Reference.

"So with fixed step methods, NEURON calculates values of v and i that may not agree with each other."

True. If you want to calculate series of v and i values that are consistent with each other, use adaptive integration. NEURON's adaptive integrators report v and i values that are mutually consistent.

"But I want values that are sampled at particular times, e.g. at fixed intervals!"

Then use cvode.record(_ref_rangevar, yvec, tvec, 1) to capture values at the times specified by the values in tvec. Read about this in the Programmer's Reference. Be sure to run some tests to make sure you've got it working properly.