Time Derivative

Anything that doesn't fit elsewhere.
Post Reply
myreil
Posts: 11
Joined: Mon Mar 14, 2011 2:25 pm

Time Derivative

Post by myreil »

Dear all,

I am using this part in a hoc file in order to calculate the stim_amp(see code). However, the equation used for stim_amp is the derivative calculated by hand which creates inaccuracy in my results. I want to replace this part and make neuron calculate the derivative given the equation. By this I mean that I want to give neuron for example the equation: I(t)=v*c*exp(-w1*t)*sinh(w*t) and it will calculate the dI/dt.
Is this possible? And should it be done in a hoc or a mod file?

Thank you so much in advance for your answer!

Code: Select all

for i=0,int(tstop/dt){
	stim_time.x[i]=i*dt
	if(i>pstart && i<pstop) {
	
		if((RC/(2*LC))^2>1/(LC*CC)){
			//Overdamped
			W1=RC/(2*LC) //1/sec
  			W2=sqrt((W1*W1)-(1/(LC*CC))) //1/sec
  			scale1=amp*CC*W2*((W1/W2)^2-1)/2    // [Ampere]
			exp1=exp(-W1*(stim_time.x[i]-$1)/1000)	// divide by 1000 to keep units in exp in sec
			exp2=exp( W2*(stim_time.x[i]-$1)/1000)
			exp3=exp(-W2*(stim_time.x[i]-$1)/1000)
			stim_amp.x[i]=(scale1*exp1*((W2-W1)*exp2+(W2+W1)*exp3))/1000  // dI/dt  in [A/millisec]		
		}
        }
	testg.line(i*dt,stim_amp.x[i])
  }
ted
Site Admin
Posts: 5810
Joined: Wed May 18, 2005 4:50 pm
Location: Yale University School of Medicine
Contact:

Re: Time Derivative

Post by ted »

Can you describe what you are trying to do without resorting to source code? I have the vague idea that you want a current source whose output is described by a particular function. If yes, then what is the function? If not, then what are you trying to do?
myreil
Posts: 11
Joined: Mon Mar 14, 2011 2:25 pm

Re: Time Derivative

Post by myreil »

I have a function x(t)=a*exp(w*t)*sinh(w*t) and I want neuron to calculate dx/dt either in hoc or mod file.
The reverse thing that DERIVATIVE block in a mod file does.

Is this more clear?
ted
Site Admin
Posts: 5810
Joined: Wed May 18, 2005 4:50 pm
Location: Yale University School of Medicine
Contact:

Re: Time Derivative

Post by ted »

The "correct" (in the sense of being most appropriate for the application) implementation depends on two things: the value that you want to compute, and what you want to do with that value. Now I know the function that describes the value that you want to compute. The derivative of the function can be written in a nice, clean, analytical form. So that solves the problem of how to compute the derivative. The question that remains is what you want to do with the value of the function or its derivative.
myreil
Posts: 11
Joined: Mon Mar 14, 2011 2:25 pm

Re: Time Derivative

Post by myreil »

I want to use dx/dt into a breakpoint of a mod file. (SUFFIX and i_m is a NONSPECIFIC Current)

BREAKPOINT {
i_m=b*(dx/dt)
}

Thank you very much!!
ted
Site Admin
Posts: 5810
Joined: Wed May 18, 2005 4:50 pm
Location: Yale University School of Medicine
Contact:

Re: Time Derivative

Post by ted »

I feel like I'm playing "twenty questions."
myreil wrote:I want to use dx/dt into a breakpoint of a mod file. (SUFFIX and i_m is a NONSPECIFIC Current)

BREAKPOINT {
i_m=b*(dx/dt)
}
And why do you want to do that? You want a density mechanism that generates a current that follows a particular time course? Or do you want to drive membrane potential with a function that follows a particular time course? Try to avoid sending me bits of code. I need to understand what your goal is.
Post Reply