Docs: merps

Introduction

Merps is a program which measures signal parameters of event-related potentials (ERPs) in standard ERPSS data files. It uses an input command file, termed a measurement command file (mcf), to specify which measurements to make and how to make them, and an output file to hold the resulting values. It is also possible to use merps (E1) in an interactive mode, wherein commands are taken from the standard input, and/or the measurements are printed on the standard output. One can optionally specify which data files to measure during the invocation, thus allowing the same mcf to be employed for measuring multiple data sets without having to edit the mcf between each set of measurements.

The user specifies the order in which the measurements are made and placed in the output file, and can optionally specify the number of columns for the output; hence merps is usually sufficient to assemble data for any subsequent statistical analyses. Descriptive information about the measure or the data being measured can be printed to help in verifying the validity of the mcf. In addition, to assist in the interpretation of the measurements, the data being measured can be displayed on a graphics device, if desired. This is especially useful when certain types of measurement errors arise, such as the failure of a peak finding algorithm to locate a negative peak of the proper polarity. One can have merps plot either data that engender these measurement errors, or all data. Finally, it is possible to easily add additional measurement algorithms to merps, avoiding the necessity of having to write special purpose programs in most cases.

Usage

Here's the generic invocation of merps:

The first argument, commandfile, represents the ASCII file containing the measurement commands. If commandfile is any of "-", "stdin", or "none", the standard input is used as the source of commands. In this case, if the standard input is connected to a terminal, merps enters an interactive mode of use, wherein errors are noted but do not cause termination of merps. Hence, one can redirect the standard input from a file containing measurement commands, if desired, and yet not be in interactive mode.

The second argument, outfile, specifies the file in which the measurements will be placed. Note that merps will not write over an existing file, but rather will complain and exit. If the outfile is any of "-", "none", or "stdout", measurements will be printed on the standard output, along with any descriptive information, regardless of the source of the commands. Thus, to use merps in a fully interactive manner, one should invoke merps with "-" as both the commandfile and outfile. Note that the output file (if not the standard output) is removed if a fatal error occurs during execution or if merps (E1) is killed by an interrupt (delete).

Command Line Options

Options for merps are selected with additional arguments on the invocation line that begin with "-". An option may have none, one, or many arguments of its own. Any such arguments for an option immediately follow the option and are associated with that option until another argument beginning with a "-" is encountered. Here are the options that are currently implemented:

Measurement Command Files

The operation of merps is controlled by various commands that are placed in one or more measurement command files, or mcfs. These are standard ASCII files that can be generated using any text editor. The commands for merps, whether in an mcf or supplied interactively, occur one per line, along with any associated arguments. Lines in the command file that begin with "#" are considered comments, and are ignored, as are any blank lines in the file. The first string on any line is interpreted as the command name, whose recognition is based on matching an initial substring. For example, the channels command would be invoked by any word starting with "chan". That is, chan, channels, chans, and chandelier would all be recognized as a valid channels command. The unique substrings that are used to match each command are listed in the description of each command. The case of the command is irrelevant; the command string is converted to lower case before analysis.

Since one must specify the data that will be measured, the order in which to make the measurements, and certain other parameters as well as the type of measurement(s) to make, the command set is divided into measurement parameter commands and measurement commands. The measurement parameter commands set various parameters that control the data that are measured and the order of measurements, while the measurement commands actually cause measurements to be made and the values placed in the output file.

Note that one can specify as many measurements in an mcf as desired, by simply placing them in the mcf. The commands are executed in the order they are encountered in the mcf, and the parameters from measurement parameter commands are retained until the specific command is again encountered in the mcf.

Mandatory Parameter Commands

Some of the measurement parameter commands must be present before any measurement commands appear in the mcf. These mandatory parameter commands and their arguments are:

Optional Parameter Commands

In addition to the mandatory parameter commands, one can utilize certain optional commands to modify the operation of merps:

Measurement Commands

A variety of algorithms that calculate various signal parameters are available in merps, and additional ones are easily added. These mesaurement commands do not have aliases, and the entire name must be typed in full. The case, however, is immaterial. In all cases, merps checks the measurement window, baseline window, etc against the data, possibly encountering a fatal error. Remaining errors generated by the measurement commands and their causes are detailed in the description of each specific algorithm.

Errors that occur during the execution of a measurement command are divided into two categories: hard errors, and soft errors. Hard errors occur when an insurmountable error arises during the execution of a measurement command. If merps is not operating in interactive mode, hard errors are fatal and cause termination of merps, with the attendant removal of the (incomplete) output file. In contrast, soft errors do not cause merps to terminate. In most cases, the measurement algorithm which encounters a soft error attempts to deliver a reasonable datum, although this is not possible in all cases. For both hard and soft errors, a message is printed on the standard error that is intended to help diagnose the problem. For more information on errors, see the section so entitled below.

Currently the following measurement commands are available:

Summary of Operation

Merps reads commands from either the standard input or a measurement command file (mcf) to set various parameters pertaining to performing a measurement or to select a measurement function. Commands that set parameters are termed measurement parameter commands, while commands that actually cause measurements to be made and the values placed in the output file are termed measurement commands. Before measurements can be made, one must define the data file(s) that will be measured using one or more file commands or by using the -f option during the invocation. The particular bin(s) in each data file must also be defined using a bins command, as well as the channel(s) using a channels command, and (optionally) the processing function(s) with a procfuncs command. The window over which the measurement algorithm is applied also must be set using a window command, and, finally, the order to perform the measurements must be specified using an order command. Once these parameters are set, one or more measurement commands can be executed, yielding the output measurements.

The order in which the data files and the bins, channels, and processing functions in those files are measured during the execution of a measurement command is based on an implied, factorial model involving a number of factors and levels of those factors. Beware, however, as these factors are almost certainly not those actually being analyzed experimentally, but rather an algorithmic mechanism for succinctly representing the order in which measurements are to be made. These measurement factors are the data files, bins, processing functions, and channels. Each factor has one or more levels, and each level of a factor is indexed by a non-negative integer. The index is used to select the actual level of the corresponding factor. For example, if four bins were defined by a bins command as 3, 5, 4, and 1, then there are four levels of the bin factor with indices from zero to three, corresponding to bins 3, 5, 4, and 1. Note that the order of the bins that are selected as the bin factor index moves from 0 to 3 is the same as the order that the bins were specified in the bins command. Each of the other factors work similarly; for the files factor, the order of appearance of the file commands determines the order of the files.

This scheme is useful in thinking about the order command, which specifies the order in which the indices of the factors increment and thus the order of the measurements in the output file. For example, the order command


	order  files  channels  bins

will cause all the bins for a specific file and channel to be measured before the next level of the channel is selected. I.e., the indices for the files factor move slowest, those for the channels factor next fastest, and those for the bins factor the fastest. Usually one will perform a repeated measures analysis of variance on the measurements; if one is using ranova (E1) or anovae, files will probably need to "move fastest", and should thus be the last argument on the order command line.

Note that this internal model of factors and levels is not meant to correspond to a particular experimental design, and in most cases more than one experimental factor will be subsumed in the bins that are measured. Nonetheless, this scheme is flexible enough to allow most experimental measurement needs to be met by devising an appropriate mapping of the experimental factors and required order of output onto a sequence of merps commands.

Examples

Perhaps the best way to understand merps is to look at an example or two. Let's consider a hypothetical experiment where the effects of attending to stimuli on the ERPs are to be statistically evaluated. For concreteness, lets say we've presented three subjects with high and low pitched tone pips, and had them attend to one pitch and then the other in separate presentations of the same set of stimuli. Thus, for each subject, we have averaged the raw data and now have four bins as follows:


	Bin       Description
 	1         High Tones, attend High Tones
 	2         Low Tones, attend High Tones
 	3         High Tones, attend Low Tones
 	4         Low Tones, attend Low Tones

These data are in files named s01, s02, s03. We intend to apply a repeated measures analysis of variance to the measurements, and wish to examine the mean amplitude of the ERP at the latency from 100 to 200 msec after stimulus presentation. For various reasons, we also wish to restrict the analysis to the Cz scalp site, which happens to be channel number 3 in the data files. In the analysis, we anticipate three factors:

	Factor  # Levels        Values                  Description

   	A        2     High tone, Low tone     Pitch of eliciting stimulus
   	B        2     Attended, Unattended    Effect of Attention
   	S        3     Ss1, Ss2, Ss3           Subject

Having established this framework for the analysis, an appropriate merps command file (mcf) would be:

	file s01
	file s02
	file s03
	bins 1 3 4 2
	chans 3
	order chans bins files
	window 100 200
	meana

Some comments are perhaps in order. Note that the ordering of the data is such that the same bin and channel is measured for each subject before moving to the next bin; this is appropriate for the ranova (E1) model, since subjects "moves fastest". Also, since only one channel is being measured, the position of the chans and bins in the order command is irrelevant. Since no baseline command was included in the mcf, the entire pre-stimulus period will be used as the zero-voltage reference.

At risk of being too detailed, here is the order in which the measure will appear in the output file after merps is successfully run:


	FILE     BIN     CHAN     DESCRIPTION

 	s01      1       3       Hi Tones, Attend Hi, Subject 1
 	s02      1       3       Hi Tones, Attend Hi, Subject 2
 	s03      1       3       Hi Tones, Attend Hi, Subject 3
 	s01      3       3       Hi Tones, Attend Lo, Subject 1
 	s02      3       3       Hi Tones, Attend Lo, Subject 2
 	s03      3       3       Hi Tones, Attend Lo, Subject 3
 	s01      4       3       Lo Tones, Attend Lo, Subject 1
 	s02      4       3       Lo Tones, Attend Lo, Subject 2
 	s03      4       3       Lo Tones, Attend Lo, Subject 3
 	s01      2       3       Lo Tones, Attend Hi, Subject 1
 	s02      2       3       Lo Tones, Attend Hi, Subject 2
 	s03      2       3       Lo Tones, Attend Hi, Subject 3

One final comment - note that the experimental factors of underlying types of tones and attention are subsumed in the merps bins "measurement factor". The measurement factors, again, are only a mechanistic shorthand for ordering the measurements.

Note that one can specify additional measurements in the mcf by simply continuing the mcf. The commands are executed in the order they are encountered in the mcf, and the parameters from commands are retained until that command is again encountered in the mcf. Hence, if one had a between-subjects factor in addition to the two within-subjects factors in the above example, and the only difference between the measurements was the data files, one might employ an mcf similar to this one:


	file s01
	file s02
	file s03
	bins 1 3 4 2
	chans 3
	order bins chans files
	window 100 200
	meana
	clearfiles
	file s04
	file s05
	file s06
	meana

with the between-subjects factor "moving most slowly". Note that the same bins and channels are measured in the same order for the second meana command, but the files have been switched. This example also demonstrates the optional clearfiles command, which closes all currently open files and resets the number of open files to 0. The ranova model for this analysis might be:

	Factor  # Levels        Values              Description
	
   	A        2     Schizophrenic, Normal   Mental Competence
   	B        2     High tone, Low tone     Pitch of eliciting stimulus
   	C        2     Attended, Unattended    Effect of Attention
   	S        3     Ss1, Ss2, Ss3           Subject within Group

Errors

Errors that occur during the execution of merps are divided into two categories: hard errors, and soft measurement errors. Hard errors occur, for example, when a file cannot be opened, there is a syntactical error in the mcf, or when an insurmountable error arises during the execution of a measurement command. Soft, or measurement errors arise when a measurement command was not successful because of the nature of the data. For example, one might be looking for a negative peak but the data are all positive over the search window. Soft errors arise only during the execution of a measurement command, and are distinguished from hard errors during a measurement command in that some value, possibly useable, is calculated and printed. For example, if one is searching for a positive local peak, but no local peaks are present in the data, the maximum value of the data in the window might be placed in the output file and a soft error noted. This maximum value might be deemed acceptable by the user, in which case one could use the measurement output file "as is". However, if a hard error occurs, the output file of measurements could not be used in subsequent analyses, as non-sensical values (if that) would be present, and the output file is removed before termination of merps if not operating in interactive mode. The description of each measurement command explains the possible errors and their causes. For both hard and soft errors, a message is printed on the standard error that is intended to help diagnose the problem.

Interactive Use of merps

Merps can be used interactively by supplying "-", "none", or "stdin" as the name of the mcf in the invocation, without redirecting the standard input from another source. While not essential, "-", "none", or "stdout" will generally be specified as the output file, so that the measurements and descriptive text will appear on the standard output and can be read. In addition, one will most likely want to employ either the -s, -v, or one of the -g(e) options in the interactive mode, either to generate descriptions and diagnostic information, or to view the data as it is measured.

In the interactive mode, the standard input is used as the source of the commands, and merps behaves differently in a number of ways. Firstly, merps prompts the user for input by printing ": " on the standard output at the end of each command. Secondly, the help command is functional, and prints a summary of the data and parameter commands for merps (E1). Thirdly, interrupts, normally fatal, are caught and return the user to the command level. Finally, the occurrence of certain errors simply aborts the command execution and returns the user to the command level rather than terminating merps (e.g. the inability to open a file).


MERPS
Tutorial Introduction and Reference Manual
Jonathan C. Hansen


© 2005 UCSD ERP Lab
Please send comments and suggestions to the ERPSS Webmaster