Skip to main content
. 2018 Dec 18;12:92. doi: 10.3389/fninf.2018.00092

Algorithm 1.

Axial current calculations in LFPy 2.0

 1: children = dict. of child indices n of each parent section sec
 2: connections = dict. of relative location χ ∈ [0, 1] where children connect onto parent section
 3: Ri = list of axial resistances of child segments to corresponding parent nodes
 4: Vm = list of membrane potentials at midpoints of each segment
 5: Initialize length 2(nseg − 1) lists Ia, d and r indexed by m ∈ {0, 1, …, 2(nseg − 1) − 1}
 6: set current and segment indices m = n = 0
 7: set root_sec = True
 8: for sec in neuron morphology do
 9:    if sec has parent section then
10:       set parent segment index f from children and connections
11:       set init_seg = True and root_sec = False
12:    if count(children[sec])>1 then
13:       set branch = True
14:    set χ = connections[sec]
15:    for seg in sec do
16:       if root_sec then
17:           set n = 1 and f = 0
18:           set init_seg = False and root_sec = False
19:           continue
20:       set Rfni=Ri[n]
21:       set Vfm=Vm[f]
22:       set Vnm=Vm[n]
23:       if not init_seg or 0 < χ < 1 then
24:           compute Ia[m]=(Vfm-Vnm)/Rfni (see Figure 3B,C,E)
25:       else
26:           set Rni=Ri[n] (axial resistance from mid to start point of segment n)
27:           set Rfi (axial resistance from end to mid point of parent segment f)
28:           if not branch then
29:               compute Ia[m]=(Vfm-Vnm)/(Rfi+Rni) (see Figure 3D)
30:           else
31:               compute branch point potential
V×m=hVhm/Rhih1/Rhi for h{f,n1,n2,nchildren}
32:               compute Ia[m]=(V×m-Vnm)/Rni (see Figure 3F)
33:       set Ia[m+1] = Ia[m]
34:       compute d[m] by subtracting the midpoint of f from the start point of n
35:       compute d[m+1] by subtracting the start point of n from the midpoint of n
36:       compute r[m] by subtracting 0.5·d[m] from the start point of n
37:       compute r[m+1] by subtracting 0.5·d[m+1] from the midpoint of n
38:       set f = n, n = n+1 and m = m+2
39:       set branch = False and init_seg = False