ramanujan.srinath wrote:wish to insert the extracellular mechanism to record the extracellular potential.

Do you mean the

potential at a particular location in a conductive medium? Or do you want to be able to compute the

potential at any arbitrary point, or multiple points?

(For now, I have one cell but eventually I will implement a network.) After inserting extracellular into all sections, all I need is the transmembrane current to be stored into a file. Is this correct?

Partly, and only if you do each of the following:

1. figure out the location in space of the center of each compartment

2. record the time course of transmembrane current generated by each compartment (segment) of the model and save all of these data to one (or more) file(s)

3. perform offline calculations with some other software that combines the time course of each current and its location in space with a model of the conductive medium in which your network is embedded, in order to calculate the

potential at one or more extracellular locations in that volume

Your code excerpt is a pretty good start, but it omits many important details. Also, if you're going to write data to an output file at each time point in the simulation, there's no need to use the Vector class's record() method, is there?

i_membrane is the transmembrane current density. I need the current. So I multiply by the segment area?

Yes, this is one of those details.

A more important one is that the spatial distribution of current sources and sinks must also be taken into consideration. Simply adding up all transmembrane currents at any time in the simulation will produce a net result of 0. To understand why this is so, apply an inductive proof that starts with a single compartment model, then extend to a two compartment model, and finally to an arbitrary number of compartments. For a single compartment model cell, net membrane current is 0 (capacitive current must be equal and opposite to the sum of ionic currents).

For a two compartment model with compartments numbered 0 and 1, there are three currents to consider: net membrane currents im0 and im1 (positive for outward current), and axial current that spreads from compartment 0 to 1 called iax01, the current balance equations are

im0 + iax01 = 0

-iax01 + im1 = 0

from which im0 + im1 = 0, but if the compartment centers are at different locations in space, the model should generate a dipole

field whose intensity depends on the product of im0 and the distance between centers.

For a three compartment model . . . the remainder of the derivation is "left as an exercise to the reader" (a delightful quote from an old calculus textbook by Johnson and Kiokemeister), but you get the point.

(I went through the extracellular_stim_and_rec file and that seems a little extensive for my project.

It calculates the location of the center of each compartment. You might find that part helpful. It also combines that information with a very naive conceptual model of the volume conductor in which the cell is embedded (purely resistive, homogenous, isotropic, effectively infinite in size) to calculate the

potential at a particular location in space.

If all you need are the membrane currents so you can use them as driving functions for a volume conductor model that is simulated with some other software, you might find it helpful to use the following mechanism (simplified from xtra.mod), because it uses compiled code to calculate the product of compartment area with

local i_membrane.

Code: Select all

```
: xtr.mod, based on xtra.mod
COMMENT
This mechanism is intended to be used in conjunction
with the extracellular mechanism. A pointer specified
at the hoc level must be used to connect the
extracellular mechanism's i_membrane to this mechanism's im.
xtr does two useful things:
1. Calculates net membrane current inet from the product
of local i_membrane and segment area.
2. Allows local storage of xyz coordinates interpolated from
the pt3d data. Once stored, these coordinates may be read out
at any time e.g. for writing to a file.
ENDCOMMENT
NEURON {
SUFFIX xtr
RANGE x, y, z
RANGE inet
POINTER im
}
PARAMETER {
x = 0 (1) : spatial coords
y = 0 (1)
z = 0 (1)
}
ASSIGNED {
v (millivolts)
inet (nanoamp)
im (milliamp/cm2)
area (micron2)
}
INITIAL {
inet = (0.01)*im*area
: this demonstrates that area is known
: UNITSOFF
: printf("area = %f\n", area)
: UNITSON
}
: Use BREAKPOINT for NEURON 5.4 and earlier
: BREAKPOINT {
: SOLVE f METHOD cvode_t
: }
:
: PROCEDURE f() {
: : 1 mA * 1 megohm is 1000 volts
: : but ex is in mV
: inet = (0.01)*im*area
: }
: With NEURON 5.5 and later, abandon the BREAKPOINT block and PROCEDURE f(),
: and instead use AFTER SOLVE
AFTER SOLVE { : after each solution step
inet = (0.01)*im*area
}
```

Code: Select all

```
i_net = 0
forall insert extracellular
objref rect, reci
rect = new Vector()
reci = new Vector()
rect.record(&t)
reci.record(&i_net)
finitialize(-65)
objref savdata
savdata = new File()
savdata.wopen("i_membrane.dat")
while (t < tstop) {
i_net = 0
fadvance()
forall {
i_net = i_net + i_membrane(0)
}
print i_net
savdata.printf("%g %g\n", t, i_net)
}
savdata.close()
```