Using Vector Play for continuous output

The basics of how to develop, test, and use models.
Post Reply
Igoy
Posts: 8
Joined: Tue Jun 30, 2015 2:15 pm

Using Vector Play for continuous output

Post by Igoy »

Hi -

I want to use the Vector.play() method to continuously apply a forcing function. The forcing function I want to use is a sine wave modeled as f(t) = A+B*sin(2*PI*f*t). I am able to use the GUI-based approach for graphing this forcing function, copying it to a clipboard, then using the GUI-based Vector play. But I can't seem to figure out the best way to do this in the hoc code.

My current approach looks like:

Code: Select all

  1 // Basics of forcing function
  2 objref forcefunc, forcetime
  3 forcefunc = new Vector()
  4 forcetime = new Vector()
  5 
  6 // Create functions
  7 proc force_waveform() {
  8   forcefunc.resize(6)
  9   forcefunc.fill(0)
 10 
 11   forcefunc.x[0] = -5+5*sin(2*PI*2*t)
 12   forcefunc.x[1] = -5+5*sin(2*PI*2*t)
 13   forcefunc.x[2] = -5+5*sin(2*PI*2*t)
 14   forcefunc.x[3] = -5+5*sin(2*PI*2*t)
 15   forcefunc.x[4] = -5+5*sin(2*PI*2*t)
 16   forcefunc.x[5] = -5+5*sin(2*PI*2*t)
 17 
 18   forcetime.resize(6)
 19   forcetime.fill(0)
 20   forcetime.x[0] = 15
 21   forcetime.x[1] = 16
 22   forcetime.x[2] = 17
 23   forcetime.x[3] = 18
 24   forcetime.x[4] = 19
 25   forcetime.x[5] = 20
 26 }
 27 
 28 proc attach_force() {
 29   forcefunc.play(&node[25].v(0.5), forcetime, 1)
 30 }
 31 
 32 proc set_force() {
 33   force_waveform()
 34   attach_force()
 35 }
 36 set_force()
That seems to be the appropriate implementation, however the two issues are:
1. The values assigned to forcefunc are not varying with time since we don't have access to the variable t (as far as I can tell).
2. I'm not sure how to make this "play" throughout the entire duration of the simulation since I don't have access to the timestep or neuron time as the simulation proceeds. I've temporarily filled in values of 15, 16, 17, 18, 19, 20 to make it play just for testing purposes.

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

Re: Using Vector Play for continuous output

Post by ted »

Suggestions:
1. RTM. The Programmer's Reference documentation of the Vector class's play method, in particular.
2. Use the Forum's search feature to find mentions of Vector play. There will be more than one working example.
3. Use toy programs to test what you think you know, or as an aid to understanding documentation that seems ambiguous.
4. If you think you have filled a pair of vectors with values, use the Vector class's print method to test that assumption.
You might also find it informative to use Graphs, e.g. plot the vector that holds the dependent values vs. the vector that holds the independent values.

By the way, it is useless to try to use Vector.play to drive a state variable such as membrane potential. The value of a state variable is computed by numerical integration of a differential equation, and that is unaffected by trying to play a vector into the state variable. If you really want to force membrane potential in some compartment of a model to follow a particular time course, you need to use an SEClamp with rs = 1e-6 megohms, dur1 = 1e9 ms, and you drive its amp1 parameter. The result won't be very interesting because the voltage clamp completely overrides the effects of local membrane currents.
Post Reply