The math behind extracellular mechanisms

The basics of how to develop, test, and use models.
sdanner
Posts: 5
Joined: Sat Aug 29, 2009 7:24 am

Re: The math behind extracellular mechanisms

Post by sdanner »

Thank you for clearing this up for me.
Kind regards
Simon
mzenker

Re: The math behind extracellular mechanisms

Post by mzenker »

Hi,

this is an old thread, but the subject isn't... ;)
ted wrote: Mon Jun 08, 2009 5:09 pm Proceeding from the outside in, the potentials at the ith nodes are vext[1]_i, vext_i, and v_i + vext_i.
(...)

- v_i * cm*D + vext_i * (cm + xc)*D - vext[1]_i * xc*D
= vext_i-1 * (1/xraxial_i) - vext_i * ((1/xraxial_i) + (1/xraxial_i+1)) + vext_i+1 * (1/xraxial_i+1) + g_pas * (v_i - e_pas) - xg * (vext_i - vext[1]_i)

- vext_i * xc*D + vext[1]_i * (xc + xc[1])*D
= vext[1]_i-1 * (1/xraxial[1]_i) - vext[1]_i * ((1/xraxial[1]_i) + (1/xraxial[1]_i+1)) + vext[1]_i+1 * (1/xraxial[1]_i+1) + xg * vext_i - xg[1] * (vext[1]_i - e_extracellular)
(...)
Although I have proofread this several times, it would not surprise me if these equations contain one or more errors (especially in the indices).
Trying to reproduce the equations using the picture in the documentation, I think there is an error in the second and one in the third equation.
The potential difference over cm is just the membrane potential v_i, so that the left hand side of the second equation should read:

- v_i * cm*D + (vext_i * - vext[1]_i) * xc*D

i.e. there is no term vext_i*cm*D.

In the third equation, the resistive current between the [0] and [1] layer is xg * (vext_i - vext[1]_i). The term xg*vext[1]_i is missing, so that the right hand side should read:

vext[1]_i-1 * (1/xraxial[1]_i) - vext[1]_i * ((1/xraxial[1]_i) + (1/xraxial[1]_i+1)) + vext[1]_i+1 * (1/xraxial[1]_i+1) + xg * (vext_i - vext[1]_i) - xg[1] * (vext[1]_i - e_extracellular)

Additionally, I think the equations are easier to read (and derive) if written in terms of potential differences and with a slightly different notation for the time derivative (D == d/dt), since the capacitances are considered to be constant:

cm*D(v_i) = (v_i-1 - v_i)/Ra_i + (v_i+1 - v_i)/Ra_i+1 - g_pas*(v_i - e_pas)

-cm*D(v_i) + xc*D(vext_i - vext[1]_i)
= (vext_i-1 - vext_i)/xraxial_i + (vext_i+1 - vext_i)/xraxial_i+1 + g_pas*(v_i - e_pas) - xg*(vext_i - vext[1]_i)

-xc*D(vext_i - vext[1]_i) + xc[1]*D(vext[1]_i)
= (vext[1]_i-1 - vext[1]_i)/xraxial_i + (vext[1]_i+1 - vext[1]_i)/xraxial_i+1 + xg*(vext_i - vext[1]_i) - xg[1]*(vext[1]_i-e_extracellular_i)

Please correct me if I am wrong...

Matthias
ted
Site Admin
Posts: 6287
Joined: Wed May 18, 2005 4:50 pm
Location: Yale University School of Medicine
Contact:

Re: The math behind extracellular mechanisms

Post by ted »

Yes indeed, there are mistakes in those equations that I wrote. I treated membrane potential as if it were potential relative to ground. Also, notation was bad. It's a good idea to revisit this stuff at least once every decade or so. Too bad I didn't do that long before now. My apologies to the confusion that this caused.

Starting from scratch, treating the potential at each node as "relative to ground", and using these definitions (note: this list was revised by ted on Wed Oct 10, 2018--see Comments at the end of this post)
  • D is the derivative operator
  • each segment has the same physical dimensions and electrical properties
  • cm and gm are total membrane capacitance and conductance of a compartment
  • Ra is total resistance between the centers of adjacent compartments
  • xraxial[0] and xraxial[1] are the net longitudinal extracellular resistances between extracellular positions that correspond to the centers of adjacent compartments, as shown in that diagram
  • xc[0] and xg[0] represent the net radial capacitance and conductance between the two layers of NEURON's extracellular mechanism, as shown in that diagram
  • xc[1] and xg[1] are the net radial capacitance and conductance between the extracellular mechanism's outer layer and the bath, as shown in that diagram
I get the following:

Begin by focussing on the intracellular nodes.

Code: Select all

(cm*D + gm + 2/Ra) * v[i]
  = v[i-1]/Ra + v[i+1]/Ra
    + (cm*D + gm) * vext[0,i]
which rearranges to

Code: Select all

cm*D(v[i]) - cm*D(vext[0,i])
  = - (gm + 2/Ra) * v[i]
    + v[i-1]/Ra + v[i+1]/Ra
    + gm * vext[0,i]
Now shift to the nodes in layer 0.

Code: Select all

((xc[0] + cm)*D + (xg[0] + gm + 2/xraxial[0])) * vext[0,i] 
  = (cm*D + gm) * v[i]
    + (vext[0,i-1] + vext[0,i+1])/xraxial[0]
    + (xc[0]*D + xg[0]) * vext[1,i]
which rearranges to

Code: Select all

-cm*D(v[i]) + (cm + xc[0])*D(vext[0,i]) - xc[0]*D(vext[1,i])
  = gm * v[i]
    - (gm + xg[0] + 2/xraxial[0]) * vext[0,i]
    + (vext[0,i-1] + vext[0,i+1])/xraxial[0]
    + xg[0] * vext[1,i]
Finally deal with the nodes in layer 1.

Code: Select all

((xc[0] + xc[1])*D + (xg[0] + xg[1] + 2/xraxial[1])) * vext[1,i] 
  = (xc[0]*D + xg[0]) * vext[0,i]
    + (vext[1,i-1] + vext[1,i+1])/xraxial[1]
    + xg[1] * e_extracellular[i]
which rearranges to

Code: Select all

-xc[0]*D(vext[0,i]) + (xc[0] + xc[1])*D(vext[1,i])
  = xg[0] * vext[0,i]
    - (xg[0] + xg[1] + 2/xraxial[1]) * vext[1,i]
    + (vext[1,i-1] + vext[1,i+1]) / xraxial[1]
    + xg[1] * e_extracellular[i]
The left hand sides of these equations have two or three derivatives because of the capacitive coupling between adjacent layers.

Comments:
These comments were added by ted on Wed Oct 10, 2018:
1. In NEURON's documentation of extracellular, potentials at extracellular nodes are relative to ground, but potential at the intracellular nodes is transmembrane potential, that is, potential relative to extracellular space immediately adjacent to the section. However, v in the following equations refers to "intracellular potential" (potential at intracellular nodes relative to ground). This definition makes it easier to write the node equations by inspection, and results in a set of equations that is more easily understood.
2. The following statement was removed from the above list on Wed Oct 10, 2018 8:15 am:
v, vext[0], and vext[1] are the potentials indicated in the diagram that is part of NEURON's documentation of the extracellular mechanism
That statement is clearly incorrect and confusing. It led to the exchange starting with the post by mzenker » Tue Oct 09, 2018 3:47 am and ending with the post by ted » Wed Oct 10, 2018 7:57 am. That exchange is preserved below.
End of Comments
mzenker

Re: The math behind extracellular mechanisms

Post by mzenker »

Hi Ted,

I am confused. I don't understand how you derive your equations, and I get different ones if I do it.
I paste here the picture from the documentation:

Code: Select all


          Ra		
o/`--o--'\/\/`--o--'\/\/`--o--'\/\/`--o--'\o vext + v
     |          |          |          |     
    ---        ---        ---        ---
   |   |      |   |      |   |      |   |
    ---        ---        ---        ---
     |          |          |          |     
     |          |          |          |     i_membrane     
     |  xraxial |          |          |
 /`--o--'\/\/`--o--'\/\/`--o--'\/\/`--o--'\ vext
     |          |          |          |     
    ---        ---        ---        ---     xc and xg
   |   |      |   |      |   |      |   |    in  parallel
    ---        ---        ---        ---
     |          |          |          |     
     |          |          |          |     
     |xraxial[1]|          |          |     
 /`--o--'\/\/`--o--'\/\/`--o--'\/\/`--o--'\ vext[1]
     |          |          |          |     
    ---        ---        ---        ---     the series xg[1], e_extracellular
   |   |      |   |      |   |      |   |    combination is in parallel with
   |  ---     |  ---     |  ---     |  ---   the xc[1] capacitance. This is
   |   -      |   -      |   -      |   -    identical to a membrane with
    ---        ---        ---        ---     cm, g_pas, e_pas
     |          |          |          |     
-------------------------------------------- ground
now I write cm, gm, xc[0], xg[0], xc[1], xg[1] and the layer nominations into the schematics. Just to make sure that we are talking about the same things.

Code: Select all


          Ra		
o/`--o--'\/\/`--o--'\/\/`--o--'\/\/`--o--'\o vext + v     intracellular layer   
     |          |          |          |     
    ---        ---        ---        ---
   |   |      |   |      |   |    cm|   |gm
    ---        ---        ---        ---
     |          |          |          |     
     |          |          |          |    
     |xraxial[0]|          |          |
 /`--o--'\/\/`--o--'\/\/`--o--'\/\/`--o--'\ vext[0]             layer 0
     |          |          |          |     
    ---        ---        ---        ---  
   |   |      |   |      |   | xc[0]|   |xg[0] 
    ---        ---        ---        ---
     |          |          |          |     
     |          |          |          |     
     |xraxial[1]|          |          |     
 /`--o--'\/\/`--o--'\/\/`--o--'\/\/`--o--'\ vext[1]           layer 1
     |          |          |          |     
    ---        ---        ---        --- 
   |   |      |   |      |   | xc[1]|   |xg[1]
   |  ---     |  ---     |  ---     |  ---
   |   -      |   -      |   -      |   - e_extracellular
    ---        ---        ---        ---
     |          |          |          |     
-------------------------------------------- ground
now for the voltages (shorthand for potential differences):
  • v is the voltage between the intracellular layer and layer 0.
  • vext[0] is the voltage between layer 0 and ground.
  • vext[1] is the voltage between layer 1 and ground.
  • vext[0]-vext[1] is the voltage between layer 0 and layer 1.
We consider a passive membrane.
ted wrote: Mon Oct 08, 2018 3:11 pm Begin by focussing on the intracellular nodes.

Code: Select all

(cm*D + gm + 2/Ra) * v[i]
  = v[i-1]/Ra + v[i+1]/Ra
    + (cm*D + gm) * vext[0,i]
which rearranges to

Code: Select all

cm*D(v[i]) - cm*D(vext[0,i])
  = - (gm + 2/Ra) * v[i]
    + v[i-1]/Ra + v[i+1]/Ra
    + gm * vext[0,i]
OK. Did you write the first equation directly from inspection of the schematics? Then what is the physical meaning behind this arrangement?
As I see it, we have to write Kirchhoff's law for the node i. So here we go. The currents for that node are (in the direction towards the node)
  • -gm * v[ i]: resistive through membrane
  • -cm * D(v[ i]): capacitive through membrane
  • (v[i+1] - v[ i])/Ra: resistive from node i+1
  • (v[i-1] - v[ i])/Ra: resistive from node i-1
which gives me the following current balance

Code: Select all

(v[i+1] + v[i-1] - 2*v[ i])/Ra - gm*v[i] - cm * D(v[i]) = 0
 
rearranged to separate capacitive and resistive currents and ordering by the voltages / potentials, to compare with your equation:

Code: Select all

cm * D(v[i]) 
= - (gm + 2/Ra)*v[i]) 
  + v[i+1]/Ra + v[i-1]/Ra 
So there is a term (cm*D + gm) * vext[0,i] in your equation which I don't understand. Where does it come from, and what does it mean?
ted wrote: Mon Oct 08, 2018 3:11 pm Now shift to the nodes in layer 0.

Code: Select all

((xc[0] + cm)*D + (xg[0] + gm + 2/xraxial[0])) * vext[0,i] 
  = (cm*D + gm) * v[i]
    + (vext[0,i-1] + vext[0,i+1])/xraxial[0]
    + (xc[0]*D + xg[0]) * vext[1,i]
which rearranges to

Code: Select all

-cm*D(v[i]) + (cm + xc[0])*D(vext[0,i]) - xc[0]*D(vext[1,i])
  = gm * v[i]
    - (gm + xg[0] + 2/xraxial[0]) * vext[0,i]
    + (vext[0,i-1] + vext[0,i+1])/xraxial[0]
    + xg[0] * vext[1,i]
Hmmm... I still don't follow. Remember, I am just a physicist, so I need to stick to Kirchhoff. ;)
Proceeding as above, the currents are
  • gm * v[ i]: resistive through membrane
  • cm * D(v[ i]): capacitive through membrane
  • (vext[0,i+1] - vext[0,i])/xraxial[0]: resistive from node i+1
  • (vext[0,i-1] - vext[0,i])/xraxial[0]: resistive from node i-1
  • -xg[0] * (vext[0,i] - vext[1,i]): resistive between layer 0 and layer 1
  • -xc[0] * D(vext[0,i] - vext[1,i]): capacitive between layer 0 and layer 1
giving the following equation:

Code: Select all

cm * D(v[i]) + gm * v[i] + (vext[0,i+1] + vext[0,i-1] - 2*vext[0,i])/xraxial[0] 
- (xg[0] + xc[0] * D) * (vext[0,i] - vext[1,i]) = 0
or

Code: Select all

-cm*D(v[i]) + xc[0]*D(vext[0,i]) - xc[0]*D(vext[1,i]) 
  = gm * v[i] 
    + (xg[0] - 2/xraxial[0]) * vext[0,i] 
    + (vext[0,i+1] + vext[0,i-1])/xraxial[0] 
    + xg[0] * vext[1,i]
So again there is this term (cm*D + gm)*vext[0,i], as above.
ted wrote: Mon Oct 08, 2018 3:11 pm Finally deal with the nodes in layer 1.

Code: Select all

((xc[0] + xc[1])*D + (xg[0] + xg[1] + 2/xraxial[1])) * vext[1,i] 
  = (xc[0]*D + xg[0]) * vext[0,i]
    + (vext[1,i-1] + vext[1,i+1])/xraxial[1]
    + xg[1] * e_extracellular[i]
which rearranges to

Code: Select all

-xc[0]*D(vext[0,i]) + (xc[0] + xc[1])*D(vext[1,i])
  = xg[0] * vext[0,i]
    - (xg[0] + xg[1] + 2/xraxial[1]) * vext[1,i]
    + (vext[1,i-1] + vext[1,i+1]) / xraxial[1]
    + xg[1] * e_extracellular[i]
Kirchhoff, help!
Here are the currents:
  • xg[0] * (vext[0,i] - vext[1,i]): resistive between layer 0 and layer 1
  • xc[0] * D(vext[0,i] - vext[1,i]): capacitive between layer 0 and layer 1
  • (vext[1,i+1] - vext[1,i])/xraxial[1]: resistive from node i+1
  • (vext[1,i-1] - vext[1,i])/xraxial[1]: resistive from node i-1
  • -xg[1] * (vext[1,i] - e_extracellular[ i]): resistive between layer 1 and ground
  • -xc[1] * D(vext[1,i]): capacitive between layer 1 and ground
so we have

Code: Select all

(xg[0] + xc[0] * D) * (vext[0,i] - vext[1,i]) + (vext[1,i+1] + vext[1,i-1] - 2*vext[1,i])/xraxial[1] 
- xg[1] * (vext[1,i] - e_extracellular) - xc[1] * D(vext[1,i]) = 0
or

Code: Select all

-xc[0] * D(vext[0,i]) + (xc[0] + xc[1]) * D(vext[1,i])
  = xg[0] * vext[0,i]
     - (xg[0] + xg[1] + 2/xraxial[1]) * vext[1,i]
     + (vext[1,i+1] + vext[1,i-1])/xraxial[1] 
     + xg[1] * e_extracellular[i]
This time it's a perfect match! :)

So finally there is just the mysterious (cm*D + gm)*vext[0,i] in the equations for the innercellular node and the node in layer 0.

Matthias
ted
Site Admin
Posts: 6287
Joined: Wed May 18, 2005 4:50 pm
Location: Yale University School of Medicine
Contact:

Re: The math behind extracellular mechanisms

Post by ted »

Perhaps this is the source of confusion:
The schematic diagram in the documentation of extracellular uses v to refer to membrane potential, i.e. the difference between intracellular potential and the potential adjacent to the outer surface of the neurite. However, in yesterday's post I used v to refer to intracellular potential. This is a deliberate choice. Consistency--treating the potential at each node in exactly the same way (i.e. "treating the potential at each node as relative to ground" rather than "treating extracellular potentials as relative to ground while interpreting v as relative to potential adjacent to the external surface of the neurite")--leads to a set of equations that is more easily written and understood than the alternative of treating v as a value measured relative to vext[0].

Of course, there is an alternative way to achieve a different consistency--leave the meaning of v and vext[1] unchanged, but replace vext[0] with a variable equal to vext[0] - vext[1], so that all "potentials" in the equations are "voltage drops between adjacent layers"--but somehow that seems less natural to me.

Yet another approach would be to abandon node equations altogether and resort to loop equations instead, but let's agree not to do that.
mzenker

Re: The math behind extracellular mechanisms

Post by mzenker »

OK, this explains the "mysterious" term. Since in the post it was written
ted wrote: Mon Oct 08, 2018 3:11 pm Starting from scratch, treating the potential at each node as "relative to ground," and using these definitions
  • (...)
  • v, vext[0], and vext[1] are the potentials indicated in the diagram that is part of NEURON's documentation of the extracellular mechanism
  • (...)
and this diagram in the documentation shows the potential at the innercellular layer to be v+vext[0], I didn't get the different meaning of v.

Case closed for now as far as I am concerned... :)

Matthias
ted
Site Admin
Posts: 6287
Joined: Wed May 18, 2005 4:50 pm
Location: Yale University School of Medicine
Contact:

Re: The math behind extracellular mechanisms

Post by ted »

. . . in the post it was written
ted wrote: Mon Oct 08, 2018 3:11 pm Starting from scratch, treating the potential at each node as "relative to ground," and using these definitions
  • (...)
  • v, vext[0], and vext[1] are the potentials indicated in the diagram that is part of NEURON's documentation of the extracellular mechanism
  • (...)
You're right, that was a mistake. I'm sorry it exists, but glad that you caught it. I was so focussed on deriving and proofreading the equations that I didn't think to check the definition of terms. I'll correct that now, and leave a comment for the benefit of others who may read this thread.
OronKotler
Posts: 13
Joined: Wed Oct 31, 2018 2:03 pm

Re: The math behind extracellular mechanisms

Post by OronKotler »

ted wrote: Thu Jun 04, 2009 2:48 pm Considering the simplest case, which omits extracellular--

The equivalent circuit of a section with nseg==1 is a T circuit in which all membrane properties (capacitance and ion channels) are lumped into the vertical stem of the T. Read this
http://www.neuron.yale.edu/neuron/paper ... p2.htm#3.2


Hi Ted,
Thanks for your help.
The link you posted here, is work for me, is there another source for this paper?
http://www.neuron.yale.edu/neuron/paper ... p2.htm#3.2
ted
Site Admin
Posts: 6287
Joined: Wed May 18, 2005 4:50 pm
Location: Yale University School of Medicine
Contact:

Re: The math behind extracellular mechanisms

Post by ted »

Sorry about that. The site's architecture has changed several times over the years, and some old URLs were not updated. The updated link is https://neuron.yale.edu/neuron/static/p ... p2.htm#3.2
Post Reply