The Create Template dialog

This is what the Create Template... dialog looks like:

When you click Create, it finds all the indicated marks, averages the points in their vicinities as indicated by the Left and Right Widths, and writes a template file containing those data. (The "Width scale" arrows can be used to change the range of the scales.) This template can be used in a template match filter, allowing the recognition of specific peak shapes.

Normalization

If Normalize is checked (as it is by default), the template is normalized so that the difference between the minimum and the maximum values in the template is 1.0. This is useful if you want the Min and Max parameters of the template match filter to be in your usual units. If Normalize is not checked, the template has the same size as the features averaged to make it. This is useful if you want to see the actual magnitude of the features when you view the template. It is also useful in the template match filter if you want to match only peaks that have the same size as the original: you could, for instance, set Min to 0.95 and Max to 1.05, and then only peaks within 5% of the size of the ones used to create the template would match.

Alignment

In order to average features to create a template, xdatplot has to know how to line them up. For evoked events this is not a problem: the events can be lined up at the time of the evoking signal. But for spontaneous events the problem is difficult. The obvious method is to line peaks up by their maxima, and this is what will happen if you use peak search to mark the peaks used to create the template. The problem is that any ordinary function is flat at the maximum, so the peak is not well-defined. Your peaks will be lined up at the point on each one where a little positive noise spike occurred, and the template will end up with an unsightly little spike on its top, like an old-fashioned Prussian helmet. A common alternative is to line peaks up by the place in the leading edge where the rate of change is fastest. (You can do this in xdatplot by inserting a high-pass filter with a low frequency to differentiate your data, then marking the peaks.) Although the results are cosmetically superior, this method leads to a distortion in the leading edge of the peak that may be as significant as the Pikelhaube effect.

The Least-squares alignment checkbox controls xdatplot's solution to this problem. If it is checked, each feature will be shifted left or right to give the best match with the average of all of them, then the template will be recomputed. The match is evaluated by doing a least-squares fit of the template to the data, so that it is based on the overall shape, not any specific unique point. This is transparent, except that template creation will take longer with Least-squares alignment checked than otherwise.

If Least-squares alignment is not checked, the features are aligned by the marks used to identify them. Thus you have complete control over alignment.

Viewing templates

To look at a template, click the View button of the template dialog box. A File Selection box will pop up, allowing you to select a template. xdatplot relies on an external plotting program to display templates. By default, it uses xmgr, the Motif version of the ACE/gr plotting tool by Paul J Turner. This is what it looks like, displaying an xdatplot template:

If you don't have xmgr, clicking the View button will just result in an error. There are two ways to solve this problem. The first and best solution is to get xmgr. It's free by anonymous FTP from ftp.x.org. If for some reason you can't get xmgr or don't want to, you can change the graphCommand resource to point to another plotting program. The default is "xmgr -source stdin". If you don't have xmgr, but do have gnuplot (free from GNU), you may want to set this to "graph | xplot".

Template Files

Templates are text files in Xresource format. Here's an example of a small one:
    ! tpl-0.1
    *templateType:	INTERPOLATED
    *interTemplate.weight:	3
    *interTemplate.normalization:	242.4765064
    *interTemplate.numPoints:	9
    *interTemplate.points:	-0.002 0.29025162975893209\n\
    -0.0015 -0.13220959755755532\n\
    -0.001 0.06491654409625032\n\
    -0.00050000000000000001 0.28574569155764223\n\
    0 0.43891307222547482\n\
    0.00050000000000000001 0.37557038961749845\n\
    0.001 0.085822686697842321\n\
    0.0015 -0.26742022910369456\n\
    0.002 -0.56108692777452518\n\
The points are simply time-voltage pairs, one per line. This template represents a simple peak. They have been normalized so that the difference between the maximum and minimum voltages is 1.0, and offset so that the voltages add up to 0.0. Real templates are likely to have more than the nine points in this one.

At the moment there is only one template type: interpolated. This means that the continuous function of time represented by this template is derived by interpolating between the given points. In the future there may be other template types, such as Gaussians, sinusoids, or sums of exponentials.

Leon Avery (leon@eatworms.swmed.edu)