### Using the Grapher to plot threshold gmax as a function of ion channel distribution

The following assumes you have verified that

    	threshold(&AlphaSynapse[0].gmax)

sets gmax to its threshold value. ie. that you have loaded thresh.hoc, and created a APCount[0] and AlphaSynapse[0] (eg. from PointProcessManagers).

One goal of this exercise is to show that your ability to write short (e.g. 3 line) procedures or functions can greatly increase the power of the GUI.

Most of the Graphs you create from the NEURONMainMenu are implicitly connected to the RunControl, in that

- the RunControl determines the x-axis range and number of points
- the variables that are plotted during a run assume values that are a natural side effect of the computations performed when the Init & Run button calls fadvance()

However, in contrast to plotting a function of time, the graph for the problem in this exercise needs its own independent variable (not t from 0 to tstop, but channel extent along the dendrite (`taper`, which ranges from 0 to 1). The relation between independent variable and x-axis remains the typical one, i.e. you don't want to plot threshold gmax vs. log(`taper`).

NEURON Main Menu / Graph / Grapher starts a general purpose tool for plotting functions of an arbitrary independent variable. We can use either of two strategies to apply it to our problem.

1. We could plot a function that computes the threshold value of gmax based on `taper`. So the first step is to write such a function:

       func g_thresh_taper() {
       	// channel density declines linearly, becoming 0 at the argument
       	hhtaper($1)
       	// calculate the threshold
       	return threshold(&AlphaSynapse[0].gmax)
       }

   With the Grapher it then suffices to set `taper` as the independent variable, specify the Indep Begin and Indep End values as 0 and 1 (the number of Steps should be dend.nseg or an integer factor of dend.nseg), and use the graph scene's PlotWhat menu item to allow you to type `g_thresh_taper(taper)` as the symbol name for plotting.

2. Alternatively, the inconvenience of having to write the `g_thresh_taper` function can be overcome by using the Grapher's generator statement. For each value of the independent variable, the generator statement is executed prior to plotting the variables on the graph. Thus the PlotWhat would be used to plot `AlphaSynapse[0].gmax`, and a generator of

       	hhtaper(taper) threshold(&AlphaSynapse[0].gmax)

   computes gmax as a function of taper.

Caveats

This particular application of the Grapher does have potential drawbacks. For one, it can waste an enormous amount of time: if Steps = 100 but the dendrite has only 25 segments, threshold will be calculated 4 times for each segment! For another, if the independent variable ranges from 0 to 10 instead of 0 to 1, the procedure that distributes the channels could fail when taper > 1. You may note that this won't happen with the `hhtaper()` function provided with this exercise, which has been bulletproofed so that an argument > 1 is clipped to 1; however, this bulletproofing of `hhtaper()` doesn't prevent the Grapher from stupidly plowing ahead to compute gmax for `thresh` = 1 a zillion times.

NEURON hands-on course
Copyright © 1998-2001 by N.T. Carnevale and M.L. Hines, all rights reserved.