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.