In the past I have modeled the response from a point source with the simple equation, V_ext = I*(rho)/(4*pi*r).
I have solved for the extracellular potentials with respect to radial distance away from the middle of the disk electrode and it is as follows:

My stimul() process is as shown below:
Code: Select all
proc stimul() {
stim.amp = $1
finitialize(v_init)
for i = 0, num_nodes - 1 {
axon[i].e_extracellular = 0
}
while(t<tstop) {
for i = 0, num_nodes-1 {
// Units: Need e_extracellular in mV
// Take stim.i in mA; yes, technically point sources are in nA in NEURON,
// but here, stim.i is only used in this equation,
// so we can take the most convenient units for our purposes.
// ohm*cm*mA/(um)
// So multiply by 10000 um/cm to convert to mV
// This line of code is for a point source and it works.
//axon[i].e_extracellular = 10000*rhoe*stim.i/(2*PI*sqrt((x_axon.x[i] - x_stim)^2 + z_stim^2))
//These lines of code are for the disk electrode and this results in a Segmentation Violation
a = 15875
r = (x_axon.x[i] - x_stim)
x = ( (2*a)/ (((r-a)^2 + z_stim^2)^(1/2) + ((r+a)^2 + z_stim^2)^(1/2)) )
axon[i].e_extracellular = ((10000*stim.i*rhoe*((a^2 - r^2)^(1/2)))/(2*PI*(a^2)*((1-(r/a)^2))^(1/2))) * 2*atan(x/(1+sqrt(1-x^2)))
}
fadvance()
}
}
Any help would be appreciated