Segmentation Violation

Anything that doesn't fit elsewhere.
Post Reply

Segmentation Violation

Post by mungomatt »

I am trying to model an axon's response to extracellular stimulation from a disk electrode.

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
	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)))
As you can see, if I use the line of code for the point source, then the code runs fine. But as soon as I switch over to the disk electrode, there is an error, and I am not sure why. I am not even sure what a segmentation violation is.

Any help would be appreciated
Site Admin
Posts: 5822
Joined: Wed May 18, 2005 4:50 pm
Location: Yale University School of Medicine

Re: Segmentation Violation

Post by ted »

To start with, if
sin(theta) = x
tan(theta) = x/sqrt(1-x^2)
arcsin(x) = arctan(x/sqrt(1-x^2))

Your code may still have bugs, but you might as well start out with the correct formula.
Post Reply