Time-varying maximal conductance

NMODL and the Channel Builder.
lb5999
Posts: 56
Joined: Mon Oct 11, 2010 9:12 am

Re: Time-varying maximal conductance

Post by lb5999 » Tue Feb 07, 2017 12:28 pm

Hi Ted,

You mentioned using vector class play method, and actually that is precisely what I want to do now.

I have an imported vector which has the same time-step dt as that set in my hoc code:

Code: Select all

chdir("C:/models/")
objref f
f = new File("ramp_g_pas.txt")
f.ropen()

objectvar vectv[j]
for i=0,j-1 {access cell[i].soma
vectv[i] = new Vector()
vectv[i].scanf(f)
vectv[i].play(&cell[i].soma.g_pas,dt)
}
However, when I run this, it seems to just be setting vectv[0] as the imported file ramp_g_pas.txt. For all other sections, g_pas = 0. Namely Bcell[1].soma.g_pas all the way to Bcell[j-1].soma.g_pas are set to 0, rather than the ramp function that I am trying to set them all too.

How do I fix this?

I have tried to have a seperate file for each instance vectv, namely:

Code: Select all

objref f[j]
for i=0, j-1 {f[i] = new File("ramp_g_pas.txt")
f[i].ropen()
}
But naturally it takes ages!

Any thoughts on this would be really useful.

Kind regards,
Linford

ted
Site Admin
Posts: 5135
Joined: Wed May 18, 2005 4:50 pm
Location: Yale University School of Medicine
Contact:

Re: Time-varying maximal conductance

Post by ted » Thu Feb 09, 2017 12:17 pm

If g_pas were GLOBAL, it would be sufficient to drive g_pas in just one section; then g_pas in all sections that have the pas mechanism will follow the same time course. But g_pas is not GLOBAL, so you have to drive it in each and every section in which you want it to follow that time course.
I have tried to have a seperate file for each instance
No need to do that. A single pair of vectors that define a waveform can be used to drive as many variables as you like.
I have an imported vector which has the same time-step dt as that set in my hoc code
An ordinary linear ramp can be specified with a much smaller number of points. Consider a ramp that starts at t=0 with value a and remains constant until time t1.
Over the interval t1..t2 it sweeps from a to b.
After t=t2 it remains constant at b.
Just make a vector tvec whose elements have these values
0
t1
t2
t2+1
and another vector yvec whose elements have these values
a
a
b
b
and then use Vector play with interpolation to make yvec drive whatever variable you wish.

The idea is to treat the driving function as a piecewise linear function. You only need to specify the t,y coordinates of the first point in the waveform, then the coordinates of subsequent points at which slope changes. Finally you need to end the tvec and yvec vectors with the coordinates of one last point that, with the penultimate point, defines the slope of the waveform as t->infinity.

In addition to being very compact, this has the advantage of working with adaptive integration or with fixed time step integration regardless of the value of dt. (of course if you're using fixed time step integration, you'll want your function's breakpoints to occur at times that are integer multiples of dt).

Another example: this pair of vectors specifies a rectangular pulse of amplitude 1 that rises from a baseline of 0 at t1 and falls back to the baseline at t2:
tvec
0
t1
t1
t2
t2
t2+1
yvec
0
0
1
1
0
0
Notice that each discontinuity in a function is represented by specifying two points "at the same time" such that the first specified point's y coordinate is the function value just before the discontinuity and the second specified point's y coordinate is the function value immediately after the discontinuity.

ted
Site Admin
Posts: 5135
Joined: Wed May 18, 2005 4:50 pm
Location: Yale University School of Medicine
Contact:

Re: Time-varying maximal conductance

Post by ted » Thu Feb 09, 2017 4:23 pm

A single pair of vectors that define a waveform can be used to drive as many variables as you like.
I should have mentioned the most convenient way to do this: use the
vsrc.play(stmt, tvec, continuous)
form of the command. In your case, the statement stmt would simply be something like
"forall g_pas = $1"
If pas is present in only some of the sections, or if all sections have pas but you only want to change g_pas in some of them, then right after model setup is complete you should append the sections that you want to perturb to a SectionList. For example, you might give that SectionList the name
perturbed
Then your statement would be
"forsec perturbed g_pas = $1"

lb5999
Posts: 56
Joined: Mon Oct 11, 2010 9:12 am

Re: Time-varying maximal conductance

Post by lb5999 » Fri Feb 10, 2017 6:54 am

Thanks Ted, that work's great.

Here's the code I wrote:

Code: Select all

objref tvec, yvec
tvec = new Vector(4)
yvec = new Vector(4)

tvec.x[0]=0
tvec.x[1]=1000
tvec.x[2]=2000
tvec.x[3]=2000+1 

yvec.x[0]=0.5e-3
yvec.x[1]=0.5e-3
yvec.x[2]=0.6e-3
yvec.x[3]=0.6e-3

yvec.play("forall g_pas = $1",tvec,1)

ted
Site Admin
Posts: 5135
Joined: Wed May 18, 2005 4:50 pm
Location: Yale University School of Medicine
Contact:

Re: Time-varying maximal conductance

Post by ted » Fri Feb 10, 2017 4:53 pm

Yep, compact, easy to read and understand, and easy to modify when necessary.

Post Reply