Correctly calculating total current over section

Managing anatomically complex model cells with the CellBuilder. Importing morphometric data with NEURON's Import3D tool or Robert Cannon's CVAPP. Where to find detailed morphometric data.
Post Reply
Bill Connelly
Posts: 86
Joined: Thu May 22, 2008 11:54 pm
Location: Australian National University

Correctly calculating total current over section

Post by Bill Connelly »

So each segment reports current as mA/cm2 . It is tempting to vector.record them... then sum them all up with vector.add() into a new vector, and then divide that by the total section area. However, that is not correct (not even thinking about units at that point) because each segment could have a different area. So instead what I do, is as I set up the vectors to hold the current density, I set up another set of vectors to hold the area of that segment. Then multiply that density by the area.

So first things first... the density is in mA/cm2 if I multiply that by area in um2 then I get current in 1*10^-11 Amps... i.e. if I times it by 10 I get picoamps. Is that correct?

So the finished code goes something like this:

Code: Select all

    objref tlist, int_tlist, area_vec
    tlist = new List()
    int_tlist = new List()
    area_vec = new Vector()
  
    forsec whole_cell {
      for (seg) { //set up a list full of vectors to store the t current from each segment in the section
        tlist.append(new Vector())
        int_tlist.append(new Vector()) //now int_tlist is necessarily the same length as tlist
        area_vec.append(area(seg)) // area_vec.x(i) is area of tlist.o(i)
        tlist.o(tlist.count()-1).record(&ica(p))
      }
    }
    
    init()
    run()

    for (i=0; i<tlist.count(); i+=1) {
      tlist.o(i).mul(area_vec.x(i) * 10)  //converts current density to current in pA
    }

    //interpolate the current vectors because simulation may be run with variable timestep
    for (i=0; i<int_tlist.count(); i+=1) {
      int_tlist.o(i).interpolate(fixedT, tvec, tlist.o(i))    
    }
    
    sumT = new Vector(int_tlist.o(0).size()) // make sure sumT is the right length
    //sum interpolated current vectors
    for (i=0; i<int_tlist.count(); i+=1) {
      sumT.add(int_tlist.o(i))    
    }

    print sumT.min()
ted
Site Admin
Posts: 6289
Joined: Wed May 18, 2005 4:50 pm
Location: Yale University School of Medicine
Contact:

Re: Correctly calculating total current over section

Post by ted »

You've got the right idea, and your pseudocode is workable (give or take some syntax errors that you'll catch and fix).

A couple of comments:
There's no need to call init() before run() since run() is

Code: Select all

proc run() {
        running_ = 1
        stdinit()
        continuerun(tstop)
}
and stdinit() is

Code: Select all

proc stdinit() {
        cvode_simgraph()
        realtime = 0
        setdt()
        init()
        initPlot()
}
The postprocessing will execute faster, and your program will occupy less RAM, if interpolation is deferred until after the vectors have all been added up. But maybe you need to resample all of the recorded currents.

You know this already, but someone else may not: the way to iterate over all internal nodes (the nodes that are associated with areas, and therefore the only nodes whose membrane current needs to be recorded) of the currently accessed section is
for (x,0) . . .
Bill Connelly
Posts: 86
Joined: Thu May 22, 2008 11:54 pm
Location: Australian National University

Re: Correctly calculating total current over section

Post by Bill Connelly »

Okay, excellent.. just wanted to check that as some of the numbers didn't quite seem right.

I have to interpolate before summation, because I'm using variable time step, and hence one runs time points are not at the same as another... or is there some fancy function I'm unaware of to deal with that?
ted
Site Admin
Posts: 6289
Joined: Wed May 18, 2005 4:50 pm
Location: Yale University School of Medicine
Contact:

Re: Correctly calculating total current over section

Post by ted »

Bill Connelly wrote:just wanted to check that as some of the numbers didn't quite seem right.
I don't like the sound of that. That said, the scale factor is correct. If a compartment has 100 um2 surface area, its membrane current density in mA/cm2 has the same numerical value as its total membrane current in nA. Which means
* multiply current density in mA/cm2 by surface area in um2 and divide by 100, and the result is total current in nA
or
* multiply current density in mA/cm2 by surface area in um2 and multiply by 10, and the result is total current in pA
I have to interpolate before summation, because I'm using variable time step, and hence one runs time points are not at the same as another
Didn't know you were doing multiple runs, but I don't actually see why that matters.
is there some fancy function I'm unaware of to deal with that?
The Vector class's record() method allows this syntax
vdest.record(&var, Dt)
in which the second argument is the time interval at which you want samples to be collected. If you want even greater control, you could use this syntax
vdest.record(&var, tvec)
where the second argument is a Vector whose elements specify the actual times at which samples will be recorded.
Post Reply