Model Control: Arbitrary forcing functions

It is often useful to make some model parameter follow a predetermined time course during a simulation. For example, you might want to drive a voltage or current clamp with a complex waveform that you have computed or measured experimentally, or have a synaptic conductance or equilibrium potential change in a particular manner. You could do this at the interpreter level by inserting the necessary hoc statements inside the main computational loop, but this is cumbersome and imposes extra interpreter overhead at each time step.

The record and play functions of the Vector class are a better alternative. These are accessible using hoc statments and also through the GUI.

To help you learn how to generate and use arbitrary forcing functions, in this exercise you will use the GUI to make a ramp clamp. You will

But first, you need some membrane with HH channels--

Get something to clamp

Use single to start NEURON from an xterm or DOS window in the course/arbforc directory. This makes NEURON open a hoc file ($NEURONHOME/lib/hoc/single.hoc) that loads and starts the graphical user interface and creates a single section with a total surface area of 100 um2 and nseg = 1.
An aside: the total current through a patch of membrane with area = 100 um2 is numerically equal to the current density in mA/cm2
The membrane of this single-compartment model has cm = 1 uf/cm2, but it lacks ion channels. Endowing it with ion channels and setting up instrumentation to experiment on it are up to you.

The tools you'll need from the NEURON Main Panel:

Set up and test a voltage clamp

Turn the point process into a single electrode clamp (SEClamp) that has these parameters:
dur1 = 1 ms, amp1 = - 65mV
dur2 = 3 ms, amp2 = - 35mV
dur3 = 1 ms, amp3 = - 65mV

You need another graph to show clamp current vs. t
(New Graph / Current axis, then use the graph's Plot what? to specify SEClamp[0].i)

Run a simulation to test the voltage clamp.

Generate the ramp waveform

You want a voltage ramp that starts at v_init mV when t = 0, and rises at a constant rate.

This could be done in hoc by creating a vector with the right number of elements (one for each time step in the simulation), and then assigning the desired value to each element. However, it is more convenient to use the Grapher (NEURON Main Panel / New Graph / Grapher).
Read about it and try this simple example:
Use Plot what?, and enter the expression sin(t) into the "Variable to graph" field.
Then L click on the Grapher's Plot button.

The Grapher can plot any function that you specify in hoc. Once the desired waveform is plotted, you can use Pick Vector to copy it to NEURON's Clipboard.

Let's make a ramp that starts at the holding potential v_init and depolarizes steadily at a rate of 1 mV/ms for 50 ms. To do this, set the following parameters in the Grapher :
PARAMETER VALUE COMMENT
Indep Begin 0 t at start of ramp
Indep End 50 t at end of ramp
Steps 50/dt NEURON's GUI defined dt for us
Independent Var t
X-expr t
Generator leave blank

Next tell the Grapher what to plot (use Plot what?, and enter the expression v_init+t*1 into the "Variable to graph" field).

Plot and examine the resulting waveform (may need to use View=plot).

When you are satisfied with the result, Pick Vector.

Use the waveform as the command for the voltage clamp

The play function of the Vector class can be exercised in hoc, but it is more convenient to use the GUI's Vector Play tool
(NEURON Main Menu / Miscellaneous / Clipboard / Vector Play).

This tool's graph menu includes two special items: Variable Name and Vector from Clipboard. First use Vector from Clipboard to deposit the ramp waveform (verify success with View=plot). Then use Variable Name to specify SEClamp[0].amp1

You are almost ready to test the ramp clamp -- but first you should increase SEClamp[0].dur1 to something BIG. Anything >=50 will do, and if you plan to play with other waveforms, you might as well make it much larger, say 1000 (why is this necessary?).

Finally, L click on Vector Play's "Connected" button, and then run a simulation.

When everything is working, save the configured SEClamp, the graph of clamp current vs. t, the Vector Play tool, and the Grapher to a new session file (call it rampclamp.ses).

CAUTION: be sure to select these objects in the proper order. The rule is "if B depends on A, save A before B." This ensures that when the session file is retrieved, A will be recreated before B. Otherwise B will refer to an object that doesn't exist and you will get an error message.
In this example, the SEClamp must come before the Vector Play tool and the graph of clamp current vs. t. The Grapher is independent of all three, so its position in the sequence doesn't matter.

Exercises

1. Try changing dt.
Turning on Keep Lines in the voltage and current plots will let you compare the new and old results side-by-side.
In the RunControl window, cut dt in half.
What happens to the time course of Vm and clamp current?
What do you think would happen if you increased dt to 0.05 ms?

Why does this occur?

Don't forget to restore dt to 0.025 ms when you're done.

2. Try changing the ramp's dv/dt. In the Grapher's graph window, invoke Change Text and edit the expression, then Plot the new waveform and copy it to the Vector Play tool. Try 2 mV/ms, 3 mV/ms, whatever -- you can't fry this cell!

3. How do you get a plot of clamp current vs. Vm?
Answer: use a Phase Plane graph (NEURON Main Panel / New Graph / Phase Plane).
For the x axis expression enter v (OK for this simple one-compartment model, but SEClamp[0].amp1 would be a more flexible choice for a cell with many sections if you want to move the clamp away from the default section).

4. Try a different driving function, e.g. v_init+sin(2*PI*t/10)*5

An interesting variation: reconfigure the PointProcessManager as an IClamp and drive the amplitude of the current it delivers with a sinusoid or some other waveform.

5. Try the ramp clamp with a different cell, e.g. the ball and stick model used in previous exercises.
Launch initbs.hoc in the arbforc subdirectory.
After playing with the cell under current clamp, close the IClamp PointProcessManager and retrieve the session file rampclamp.ses (a good copy of this file already exists under the name rampclamp.se).

An important aside: when rampclamp.ses was saved, its SEC referred to a section with the name "soma". Therefore it will work with any cell that has a section called "soma". If you try to use it with a cell that does NOT have such a section, it won't work and you'll get an error message.

First try a 1 mV/ms ramp applied to the soma, then try a 2 mV/ms ramp.

Can you improve control of Vm by cutting the SEClamp's access resisitance (rs)?

See what happens when you move the SEClamp out onto the dendrite. It might be instructive to bring up a space plot that monitors Vm along the entire length of the model; in this case, you may also want to speed things up by reducing Points plotted/ms from 40 to 20.

Hints & tips

0. The Grapher can display more than one function at a time--just invoke Plot what? more than once. Avoid visual confusion by making the traces have different colors (Color/Brush).

1. The forcing function can be far more complicated than a one-liner. Create a hoc file that contains your own function, xopen() the file, and then plot it. Simple scaling and baseline shifts can be accomplished in the Grapher itself (Change Text).
Example:

func whatnot() { local abc
  if ($1 < 10) abc = sin(2*PI*$1/10)
  if ($1 >= 10 && $1 < 20) abc = (sin(4*PI*$1/10) > 0)
  if ($1 >= 20) abc = exp(($1-20)/30)*sin(2*PI*(($1-20)/10)^2)
  return abc
}
2. Experimental data (e.g recordings of membrane potential or clamp current) can also be used as forcing functions. File i/o can be done through the GUI with the Clipboard, or under program control with these Vector class methods: fread, fwrite, vread, vwrite, scanf, printf, scantil.


NEURON summer course
Copyright © 1998, 1999 by N.T. Carnevale and M.L. Hines, all rights reserved.