xdatplot filters

Analyze Filters... brings up the filter dialog, which looks like this:

The top (largest) panel of the dialog is a series of filter icons, showing where your data are coming from, and what is being done to them before they are displayed. The first (leftmost) icon is called the datafile filter. It's not really a filter, since it has no input: it just hooks up to a datafile and provides data to subsequent filters, or to the plot window. The second panel is a high-pass filter: this is like a single-pole electronic RC filter. The third filter is a minimax filter. It throws out most of the data points, meaning that the plot will display faster, although it won't reflect the actual data as precisely. (The different filter types are explained in detail below.)

Notice that the high pass filter looks pushed in. This indicates that it is the current filter. The delete button deletes it. The insert button inserts a filter after it. The parameter panel, which is just below the filter panel, shows the parameters of the current filter. The high pass filter has one parameter, its cut-off frequency. In this example the cut-off frequency is 2 Hz (assuming that you have set the units of time to seconds). You can change the frequency by typing a new value in the text field and hitting return.

To make another filter the current filter, just click the mouse on it. The parameter panel below will rearrange to reflect the new current filter.

When you click Insert, the Filter Selection dialog box pops up:

xdatplot version 0.3alpha offers you a choice of 9 types of filters. To choose one, just double-click the mouse on it. It will be inserted after the current filter, becoming the new current filter. If this is the first such filter you've used, the parameters will be default values (which you can set; see customization). You can edit these parameters in the filter dialog.

The datafile filter

The first filter in the filter chain is always a datafile filter, if you have a file open. It has one parameter: the pathname of the datafile. Changing the name is equivalent to opening a new file in the File Open... dialog box.

High-pass filters

The high-pass filter is a simple single-pole filter, like an RC filter:

The high pass filter comes in two flavors, tau specified and frequency specified. These are identical, except that the parameter of the tau specified version is the time constant, while the parameter of the frequency-specified is the -3 decibel frequency. The relationship is tau = 1/(2 Pi f Sqrt[3]).

Low-pass filters

The low-pass filter is a simple single-pole filter, like an RC filter:

The low pass filter comes in two flavors, tau specified and frequency specified. These are identical, except that the parameter of the tau specified version is the time constant, while the parameter of the frequency-specified is the -3 decibel frequency. The relationship is tau = Sqrt[3]/(2 Pi f).

The minimax filter

The minimax filter is for data compression. It replaces groups of points with two points each, the minimum point in the group and the maxmimum point in the group. (The order of the two points in the output is that same as in the input.) This method of compression ensures that the envelope of the plot will be unchanged. If the number of input points is large relative to your display resolution, the appearance of the plot will be unchanged. The minimax filter has one parameter, N, the number of points in each group. Thus, for every N points into the filter, 2 points come out, so the compression is N/2.

The minimax filter is useful if you want a quick overview of a lot of data. It is even more useful for printing or exporting postscript or MIF files of a plot on a large time scale.

The minimax filter is most useful as the last filter in the chain. In other positions, it can cause some strange effects. (High pass filtering of minimaxed data, for instance, can cause brand-new peaks to appear.) You should also realize that, because some points are being discarded, the positions of marks will not be accurate when a minimax filter is in use.

The scale filter

The scale filter simply multiplies the data by a factor. It is somewhat redundant with the V Gain fields of the units dialog,, but the scale factor can be negative; V Gain can't.

The pick filter

The pick filter is xdatplot's kludge for looking at multichannel files. The two parameters are Start, the number of the channel you want to look at (0 for the first, 1 for the second, etc) (yes, I program in C), and the second parameter is the total number of channels.

The assumption behind the pick filter is that a 3-channel recording (for instance) contains the data for channels 0, 1, and 2 at time 0, and 0, 1, 2 at time 1, then 0, 1, 2 at time 2, etc. If you set Start to 0 and N to 3, it simply picks out points 0, 3, 6, ..., which under these assumptions will be channel zero. If you set Start to 1, it picks out 1, 4, 7, ..., which is channel 2.

The template match filter

This is the most complicated of the xdatplot filters. The first parameter is the name of a template file. Template files can be created by Create Template dialog. At each time in the input the filter finds the DC offset and the scale factor that cause the template to best fit the surrounding data points. The better the fit, the larger the output. The second and third parameters are the minimum and maximum scale coefficients allowed in the fit. For instance, if you set Min to 0 and Max to Infinity, a template representing a peak will fit peaks, but not troughs. If you set Min to 5 and Max to Infinity, only peaks whose size is greater than 5 will be fit. (This assumes your template is normalized to a size of 1.) If you set Min and Max both to 20, only peaks of that size will be fit. Finally, if you set Min to -Infinity and Max to +Infinity, the fit will be unbounded.

To be precise, the output of the template match filter is an F statistic. The numerator of the F-statistic is the sample variance of the data points in the region surrounding the point whose extent matches the extent of the template. The denominator is calculated by doing a two-parameter least-squares fit of the template to the data. The two parameters are an offset and a scale factor, the scale factor constrained by Max and Min. The numerator of the F statistic is the sum of the squared residuals from the fit, divided by the number of degrees of freedom (the number of points minus 2, the number of parameters).

The Convolution filter

Convolution can be loosely described as replacing every point in your data with an arbitrary function, and then adding them all up. The function is specified by the Template file parameter of the convolution filter. For instance, if you convolve with a gaussian (one is provided in the source distribution as gauss.tpl), every point gets spread out into a gaussian. This smooths out the plot, reducing high-frequency noise (and high-frequency signal).

The Time scale parameter adjusts the width of the convolution kernel. Templates intended for use in convolution should be designed with some characteristic width equal to 1. For instance, gauss.tpl represents a gaussian of standard deviation 1. For an exponential, the time constant would be the natural dimension; for a sine wave, it might be the period. Then if you set the time scale to 0.01, your data will be convolved with a kernel 10 msec wide (assuming your time units are seconds).

In principle, any linear filter can be implemented as a convolution. Just figure out what the filter's output would be for an impulse input (an infinitely high, narrow peak of area 1, also called a Dirac delta function), create a template representing that output, and convolve your data with it. In practice there are two limitations. First, many filters will produce an impulse on the output, and the template file format isn't yet general enough to describe an impulse. This will probably change someday. Second, the convolution filter is compute-intensive. Any filter implemented as a convolution will be slow. For instance, although you could in principle make a low-pass filter by convolving with an exponential, it would be much less efficient than the built-in low-pass filter.

Leon Avery (leon@eatworms.swmed.edu)