Table of Contents

Name

raw2asci - create an ascii version of an ERP raw file

Synopsis

raw2asci rawfile [-header] [-events] [-eeg] [-records start stop] [-summary]

Description

raw2asci reads the ERP raw data file rawfile (created by the dig(2) program) and dumps the information contained in it to standard output in human-readable, or ASCII, format. rawfile may be in either raw (.raw) or compressed raw (.crw) format.

The format of a raw file is as follows. The first 512 bytes contain header information, which is described in /usr/local/erp/include/header.h. This header remains with the data as they are processed and much of it is filled in by the various analyses programs, so in the raw file header only these fields are present: evtno, nchans, odelay, ctickt, chndes, subdes, expdes, and cprecis (it is unclear why cprecis is set here since it pertains to data analysis rather than data collection, but for some reason the dig(2) program initializes it to "1").

After the header, the rest of the raw file contains a variable number of records until end-of-file. Each record represents 256 sample periods and contains two blocks, one block for event codes and one block for EEG data. A record begins with a 512 byte block for event codes that is capable of storing one event code per sample period (a potential event code occupies two bytes). If more than one event code happens to be received during a single sample period only one is stored and the rest are discarded. The first slot (i.e. the first and second bytes) of this block is reserved for the record number (record numbers start at 0), so if an event code arrives during the first sample period of a record it is held and stored in the second slot (i.e. the third and fourth bytes), which is a minor fault of this data format.

After the event code block, the rest of the record is the data block which contains 256 samples of digitized EEG. The size of this block varies according to the number of channels; each data sample occupies two bytes, so the size of this block is (2 * 256 * nchans) bytes. The data are multiplexed as follows:

         sample0/chan0
         sample0/chan1
         sample0/chan2
             :
         sample0/(nchans-3)
         sample0/(nchans-2)
         sample0/(nchans-1)
         sample1/chan0
         sample1/chan1
         sample1/chan2
             :
         sample1/(nchans-3)
         sample1/(nchans-2)
         sample1/(nchans-1)
             :
         sample255/chan0
         sample255/chan1
         sample255/chan2
             :
         sample255/(nchans-3)
         sample255/(nchans-2)
         sample255/(nchans-1)
Rarely, there is an index at the end of the file. In 1994 an indexed version of the raw file was introduced, with an index at the end for faster record retrieval (see /usr/local/erp/include/rawio.h for details). This version never came into general use even though the rawio routines currently still support it, so only certain old raw files have this index. One had to create the index using the crwidx program, now retired. The presence of an index is indicated by HASCRWIDX (0x0005) in the "flags" header variable, in which case the "nrawrecs" header variable contains the number of actual data records contained in the raw file, and the handful of extra records beyond "nrawrecs" comprise the index.

A full dump of rawfile can result in a massive amount of output, roughly 6 times the size of the uncompressed raw file. The options (see below) can be used to limit the amount of information that is dumped, resulting in a more manageable amount of output.

Options

-header
This option specifies to dump the header. It may be combined with either the -events or -eeg option to to dump only the data of interest. If none of the -header, -events, or -eeg options are specified, all data are dumped.

-events
This option specifies to dump the event codes. It may be combined with either the -header or -eeg option to to dump only the data of interest. If none of the -header, -events, or -eeg options are specified, all data are dumped.

-eeg
This option specifies to dump the EEG. It may be combined with either the -header or -events option to to dump only the data of interest. If none of the -header, -events, or -eeg options are specified, all data are dumped.

-records start stop
This option allows the user to specify a range of records from rawfile to dump, rather than all records. The range is from record number start to record number stop-1 (i.e. the stop record is excluded from the range). Record numbers start at 0. A simple way to determine the total number of records in rawfile is to use the -summary option and inspect the output; the headings for the summary totals should indicate the range of records in rawfile.

-summary
This option specifies to dump only a summary in the form of total counts from the records being considered. For the event codes the summary displays the total number of times each event code occurs; for the EEG data the summary displays the total number of times that each EEG data values occurs.

Files

/usr/local/erp/include/header.h, /usr/local/erp/include/rawio.h

See Also

dig(2) , avg2asci(1) , log2asci(1)

Author

Paul Krewski


Table of Contents