Simulation control: forcing functions

It is often useful to make some variable 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 Vector class's record and play methods are a better alternative. These are accessible using hoc statements 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

Physical System

A patch of excitable membrane.

Conceptual Model

A spherical cell with Hodgkin-Huxley gNa, gK, and gleak in parallel with membrane capacitance. This is driven by a ramp clamp, i.e. a voltage clamp with a command potential that follows this time course:

vcommand = vhold                    if t <= tstart
           vhold + slope*(t-tstart) if t > tstart

Simulation

Start NEURON with its standard GUI with /course/arbforc as the working directory. Then use Build / single compartment from the Main Menu. This creates a single section with a total surface area of 100 um2 and nseg = 1. It also brings up a Distributed Mechanism Inserter (a small window with checkboxes) that you can use to specify which mechanisms are present.
An aside: the total current in units of [nA] (nanoamperes) through a patch of membrane with area = 100 um2 is numerically equal to the current density in units of [mA/cm2]
The membrane of this single-compartment model has cm = 1 uf/cm2, but it lacks ion channels. Use the inserter to endow it with ion channels (hh), and then set up instrumentation to experiment on it.

The tools you'll bring up with the NEURON Main Menu:

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
(Graph / Current axis, then use the graph's Plot what? to specify SEClamp[0].i)

Run a simulation to test the voltage clamp. If voltage control is visibly poor, divide rs by 10 and try again. Repeat until membrane potential is well controlled.

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 Menu / 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, use Pick Vector to copy the ramp into NEURON's Clipboard.

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 / Vector / Play).

This tool has a "Specify" button that brings up a menu with several items. For this exercise, the most important are "Variable Name" and "Vector from Clipboard". "Vector from Clipboard" will deposit the ramp waveform into the Vector Play tool. Use the tool's View=plot to verify that this has happened. 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 ms will do, and if you plan to play with other waveforms, you might as well make it much larger, say 1000 ms (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).

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 (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.
Use NEURON to execute the init.hoc file in the /course/arbforc subdirectory.
Incidentally, I have included the statement
   dend nseg = 27
in the init.hoc file for improved spatial accuracy.
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 resistance (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. Alternatively, you could create a vector graphically with the MakeCurve tool (NEURON Main Menu / Vector / Draw). This is best suited to waveforms that consist of a sequence of rectangular steps (and linear ramps, if you activate the Vector Play tool's "piecewise continuous" option by clicking on Specify / Piecewise continuous).

3. 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 hands-on course
Copyright © 1998-2012 by N.T. Carnevale and M.L. Hines, all rights reserved.