Artifact rejection in the continuous data system is performed by creating an artifact rejection parameter file, calibrating it with garv, and including it when running avg(1) . This document is on the creation, meaning, and calibration of these arf (artifact rejection function) files and the use of garv.
Using Artifact Rejection with avg
Contents of an arf File Here is an example of a simple arf (artifact rejection function) file, as used by avg(1) and garv, with the columns labelled:
func. desc. chan latlo lathi thresh arcb arg1,arg2,... ppa blink 0 0 950 1500 1 ptswhi block 0 0 950 25 2 50 ptswlo block 0 0 950 25 2 50Above is an example of an arf file. The names above it are primarily for paedagogical purposes and should not be included in the actual file. An arf file is created using an ascii editor; the meanings of the various columns are as follows:
This is the function name and must be one of those detailed below.
This is the descriptive name carried around with the data and usually indicates the type of artifact you are trying to reject. Any character string up to 8 chars can be used. A dname is associated with a particular rejection count bin - see below.
This is the channel on which to perform the function. Channels start at 0. garv (and avg(1) ) will complain if the number is not between 0 and one less than the number of channels of data (inclusive).
latlo and lathi
These are the latencies in msec. referenced to the calculated time of event occurrence. Note that in the continuous data system, this point is presamp msec into the epoch, so to test the entire epoch, the appropriate numbers to enter would be (-presamp) to (epoch_length - presamp). Again, garv (and avg(1) ) will complain if these numbers are out of range. Sometimes a complaint will be issued when seemingly valid latencies are entered. This is due to the time quantization induced by sampling at discrete time points and inherent truncation. For example, if the data are sampled at 100 Hz, the point to point "time grain" is 10 msec. If one has specified 100 msec presampling and enters -100 msec as the starting latency, garv may complain, since the first data point (after truncation) is considered to be at -90 msec. This type of problem may be rectified in future versions of garv, but for now just diddle the latencies by a "time grain" and see if it doesn’t work.
Each function returns a value on each specified data segment. This number represents the threshold above which this function will flag the whole trial (all channels) as a reject. It is currently not possible to reject single channels; this would be of limited usefulness and incurs unbelieveable overhead in accounting.
Although it is possible to use up to 128 rejection functions, counts of rejects are kept in only 8 categories. One of these count bins is preset as a count of the number of raw trials which appeared good in the log file but could not be recovered from the raw file due to data errors. This count bin is number 0, and is named dterrs. It is employed whether or not artifact rejection is requested by the operator. Hence, only seven count bins are available to the arf file. The arcb number is the artifact rejection count bin and should be between 1 and 7. Note also that only 7 dnames are possible. The names are filled in by transferring the dname from the first test encountered which is counted in the arcb. Hence, if two names appear with the same arcb, the first is used for subsequent identification.
Arguments, some or all optional depending on the function, used by the particular function. See below.
Currently the following routines (functions) are implemented which may do something you want:
mavp This routine finds the mean absolute value of the points. No additional args required.
rms Finds rms value. No args required.
max Finds max. No args.
min Finds min. No args.
ppa Finds max-min (peak to peak amplitude). No args.
ppadif Finds max-min (peak to peak amplitude) on the algebraic difference between two channels. Useful for detecting horizontal eye movements. Arg1 specifies the second eeg channel. ptswhi First finds maximum value. Then determines the number of adjacent points which are within + or - arg1 of this maximum value. Useful for blocking. Note that the points are counted only in the neighborhood of the first maximuma in the epoch. See aptshi and aptslo for better blocking detection.
ptswlo Same as ptswhi only surrounding minimum.
lclmxs Finds number of local maxima which, in comparison to adjacent local minima, exceed arg1 in size. Maybe useful for muscle.
aptshi The maximum amplitude point of the epoch is first determined. The total number of points (whether or not they are contiguous) that are within arg1 points in the vertical direction (window of amplitude) of this maximum are counted and returned as the function value.
aptslo Similar to aptshi, except the points are counted around the minimum.
pinv Identical to the polinv test except that rejected artifacts are not considered blinks, and therefore are not passed to the blink correction routines.
polinv Useful for detecting blinks. (The name "polinv" is short for "polarity inversion", which is typically what you see on the lower eye electrode as compared with a frontal electrode when an epoch has a blink.) Note that the routine does not actually look for a polarity inversion between 2 eeg channels. Arg1 specifies a second eeg channel. First polinv calculates the mean difference between the 2 eeg channels. Then it finds the maximum difference between the 2 eeg channels, and returns the absolute difference between the maximum and the mean differences. Note that this function MUST be employed when using the -b option of avg(1) for creating a blink data file. (See documentation for avg(1) and blinkcp programs for more information regarding the blink correction procedure).
mxflat Useful for detecting blocks. Returns the length of the longest "flat" interval in an epoch. Arg1 specifies the maximum vertical distance allowable for an interval to be considered flat. Blocks can normally be detected with a very small value for arg1 (~ 6).
Getting Started garv is invoked thus:
garv presampling [options]optwhere presampling is the total desired prestimulus interval (including the onset delay, or trigger to stimulus delay) Note that by default the raw file is on magtape and the magtape should be loaded and the tape drive should be on line drive prior to invoking garv. garv will work with this minimal set of arguments and display the raw data on the color monitor; most often, however, one will want to calibrate an arf file as well. This is specified as one of the possible options:
-a arf_file Use A.R. tests contained in arf_file. -c chan_prec Select # of points per epoch as 256*chan_prec. -n Don’t rewind the magtape on termination. -r dec_factor Decrease the sampling rate of the data (decimate) by an integral factor dec_factor as they are extracted from the raw file. -d id_filter (This option is not available on DOS systems yet.) digitally filter the data using the integer digital filter id_filter as they are extracted from the raw file.which are appended in any order to the three required arguments. Note - if one employs the -n option, garv will attempt to space to the end of the tape before exiting when an exit is requested. This can take a long time, and the occurrence of a signal during this period will leave the magtape in an unspecified state.
Running garv Once garv has been successfully invoked, it retrieves the first trial in the raw file and prints its record number, event number, and offset within the record, displays the data (all channels) on the display device with a vertical line at the putative time of stimulus occurrence, and if an arf file is in use, prints the contents of the arf file along with the values for each test after application to these data. A message is printed indicating whether or not this trial would have been rejected or accepted given the current thresholds in the arf file. If this trial would have been rejected, the channel of data that cause the rejection is highlighted. If the event was a pause or delete mark, this is noted. At this point, garv will be in command mode, and the following commands will be recognized and performed:
+ Increase the size of the displayed data by a factor of two. The + commands are cumulative and remain in effect until - command(s) are invoked. The current record is redisplayed at the new gain.
- Decrease the size of the displayed data by a factor of two. As with + commands, the - commands are and the current raw data record is redisplayed on the display device.
nnn Advance nnn + 1 trials into the raw file, where nnn is a decimal integer. Note that a blank line (typing only a return) advances the raw file by one trial.
d c0 c1 c2 ... Instead of displaying all the channels of data on the display device, display only channels numbered c0, c1, c2, etc. Note that channels are numbered starting with 0 and cannot exceed the total number of channels minus 1. The c0, c1, c2, etc are decimal integers - any non- numeric arguments or channels out of range will be ignored. The order in which the specified channels are displayed is determined by the order in which they are specified in this command. For example: d 3 6 0 14 will display the fourth, seventh, first, and fifteenth channels on the display device for all subsequent commands. It is possible to specify that no channels be displayed if desired.
a The a command sets the mode of garv to print all A.R. tests and the values obtained from the current data trial. This is the de- fault mode.
V N Advance to the next event number N (a decimal integer). Zero is not a valid event #.
p The p command causes only the A.R. test that causes a rejection to be printed as the trials in the raw file are perused.
P The P (capital ’P’) causes a copy of the current graphics screen to be printed out on the laserjet printer.
h This h or help command causes garv to print a summary of the various command options avail- ble in the current implementation.
q Exit the program. Control d will also work, as will an interrupt (delete key) or an EOF (End of File) on the raw continuous data file.
s The s command causes garv to skip to the next trial in the raw file that would be rejected, given the current arf file. Unlike the +, -, d c0, c1, c2, ..., a, and p commands, the s command does not set a mode, but must be typed in each time to repetitively skip to rejected trial. In this sense, it is in a class with the nnn (or blank line) commands.
e Invokes a text editor with the contents of the current arf file. The default editor is ’vi’ but if the environment variable EDITOR exists, the editor it defines will be used instead. After you edit the file, (optionally) save the changes and quit the editor, garv re-reads the arf file and continues from the epoch where it left off. If some part of the arf file has an error in it, garv will allow you to either re-open the editor to fix the problem, or quit garv altogether.
l c0, c1, ... The l command takes a list of events numbered c0, c1, etc. and creates a "stop list" from them. When moving through data files, garv looks to see if the next event code is on the stop list. If it is, the epoch is skipped, and the next epoch who’s event code is not on the stop list is displayed.
After every command, the data are displayed on the screen, the raw trial and other information printed, and the A.R. tests applied to the data unless the current command or a previous command has indicated otherwise. On invocation the default mode includes ’a’ (print all A.R. tests) and display all channels on the display device. If one wishes to view or calibrate multiple raw files on a single reel of magtape, they are best processed in the order in which they were digitized, using the -n flag on each invocation of garv except the last.
Garv Errors There are, as usual, a number of possible errors that can occur when trying to use garv. These are meant to be self-explanatory, but this does not always ensure an easy solution to the problem. Many of the error messages are the same as for avg(1) , since all the continuous data and A.R. routines are common to both garv and avg(1) .
Table of Contents