| Various EEG File Formats and ConventionsDocumented by Paul Bourke
 NeuroScan EEG File FormatsApril 1997, updated September 1997The following documents the file structure for continuous EEG files as created by SCAN version 4 (the files are still reported as version 3 as the format hasn't changed). Experience has shown that many (most) of the fields are not filled out correctly by the software. In particular, the best way to work out the number of samples is 
 
 
 Average EEG To calculate the expected number of samples from the file size 
 
   Sample code to convert average files to ascii, avg2ascii.c sethead.h The following is my version of the "sethead.h" file, designed to make implementations on other machines easier, namely "other-endian" machines. Note that character fields are single byte, longs are 4 bytes, floats are 4 bytes IEEE format, short ints are 2 bytes.  
typedef struct {               /* Electrode structure  ------------------- */
   char  lab[10];              /* Electrode label - last bye contains NULL */
   char  reference;            /* Reference electrode number               */
   char  skip;                 /* Skip electrode flag ON=1 OFF=0           */
   char  reject;               /* Artifact reject flag                     */
   char  display;              /* Display flag for 'STACK' display         */
   char  bad;                  /* Bad electrode flag                       */
   unsigned short int n;       /* Number of observations                   */
   char  avg_reference;        /* Average reference status                 */
   char  ClipAdd;              /* Automatically add to clipboard           */
   float x_coord;              /* X screen coord. for 'TOP' display        */
   float y_coord;              /* Y screen coord. for 'TOP' display        */
   float veog_wt;              /* VEOG correction weight                   */
   float veog_std;             /* VEOG std dev. for weight                 */
   float snr;                  /* signal-to-noise statistic                */
   float heog_wt;              /* HEOG Correction weight                   */
   float heog_std;             /* HEOG Std dev. for weight                 */
   short int baseline;         /* Baseline correction value in raw ad units*/
   char  Filtered;             /* Toggel indicating file has be filtered   */
   char  Fsp;                  /* Extra data                               */
   float aux1_wt;              /* AUX1 Correction weight                   */
   float aux1_std;             /* AUX1 Std dev. for weight                 */
   float sensitivity;          /* electrode sensitivity                    */
   char  Gain;                 /* Amplifier gain                           */
   char  HiPass;               /* Hi Pass value                            */
   char  LoPass;               /* Lo Pass value                            */
   unsigned char Page;         /* Display page                             */
   unsigned char Size;         /* Electrode window display size            */
   unsigned char Impedance;    /* Impedance test                           */
   unsigned char PhysicalChnl; /* Physical channel used                    */
   char  Rectify;              /* Free space                               */
   float calib;                /* Calibration factor                       */
} ELECTLOC;
typedef struct{
   char   rev[20];              /* Revision string                         */
   char   type;                 /* File type AVG=1, EEG=0                  */
   char   id[20];               /* Patient ID                              */
   char   oper[20];             /* Operator ID                             */
   char   doctor[20];           /* Doctor ID                               */
   char   referral[20];         /* Referral ID                             */
   char   hospital[20];         /* Hospital ID                             */
   char   patient[20];          /* Patient name                            */
   short  int age;              /* Patient Age                             */
   char   sex;                  /* Patient Sex Male='M', Female='F'        */
   char   hand;                 /* Handedness Mixed='M',Rt='R', lft='L'    */
   char   med[20];              /* Medications                             */
   char   classif[20];          /* Classification                          */
   char   state[20];            /* Patient wakefulness                     */
   char   label[20];            /* Session label                           */
   char   date[10];             /* Session date string                     */
   char   time[12];             /* Session time strin                      */
   float  mean_age;             /* Mean age (Group files only)             */
   float  stdev;                /* Std dev of age (Group files only)       */
   short int n;                 /* Number in group file                    */
   char   compfile[38];         /* Path and name of comparison file        */
   float  SpectWinComp;         /* Spectral window compensation factor     */
   float  MeanAccuracy;         /* Average respose accuracy                */
   float  MeanLatency;          /* Average response latency                */
   char   sortfile[46];         /* Path and name of sort file              */
   long   NumEvents;            /* Number of events in eventable           */
   char   compoper;             /* Operation used in comparison            */
   char   avgmode;              /* Set during online averaging             */
   char   review;               /* Set during review of EEG data           */
   short unsigned nsweeps;      /* Number of expected sweeps               */
   short unsigned compsweeps;   /* Number of actual sweeps                 */
   short unsigned acceptcnt;    /* Number of accepted sweeps               */
   short unsigned rejectcnt;    /* Number of rejected sweeps               */
   short unsigned pnts;         /* Number of points per waveform           */
   short unsigned nchannels;    /* Number of active channels               */
   short unsigned avgupdate;    /* Frequency of average update             */
   char  domain;                /* Acquisition domain TIME=0, FREQ=1       */
   char  variance;              /* Variance data included flag             */
   unsigned short rate;         /* D-to-A rate                             */
   double scale;                /* scale factor for calibration            */
   char  veogcorrect;           /* VEOG corrected flag                     */
   char  heogcorrect;           /* HEOG corrected flag                     */
   char  aux1correct;           /* AUX1 corrected flag                     */
   char  aux2correct;           /* AUX2 corrected flag                     */
   float veogtrig;              /* VEOG trigger percentage                 */
   float heogtrig;              /* HEOG trigger percentage                 */
   float aux1trig;              /* AUX1 trigger percentage                 */
   float aux2trig;              /* AUX2 trigger percentage                 */
   short int heogchnl;          /* HEOG channel number                     */
   short int veogchnl;          /* VEOG channel number                     */
   short int aux1chnl;          /* AUX1 channel number                     */
   short int aux2chnl;          /* AUX2 channel number                     */
   char  veogdir;               /* VEOG trigger direction flag             */
   char  heogdir;               /* HEOG trigger direction flag             */
   char  aux1dir;               /* AUX1 trigger direction flag             */
   char  aux2dir;               /* AUX2 trigger direction flag             */
   short int veog_n;            /* Number of points per VEOG waveform      */
   short int heog_n;            /* Number of points per HEOG waveform      */
   short int aux1_n;            /* Number of points per AUX1 waveform      */
   short int aux2_n;            /* Number of points per AUX2 waveform      */
   short int veogmaxcnt;        /* Number of observations per point - VEOG */
   short int heogmaxcnt;        /* Number of observations per point - HEOG */
   short int aux1maxcnt;        /* Number of observations per point - AUX1 */
   short int aux2maxcnt;        /* Number of observations per point - AUX2 */
   char   veogmethod;           /* Method used to correct VEOG             */
   char   heogmethod;           /* Method used to correct HEOG             */
   char   aux1method;           /* Method used to correct AUX1             */
   char   aux2method;           /* Method used to correct AUX2             */
   float  AmpSensitivity;       /* External Amplifier gain                 */
   char   LowPass;              /* Toggle for Amp Low pass filter          */
   char   HighPass;             /* Toggle for Amp High pass filter         */
   char   Notch;                /* Toggle for Amp Notch state              */
   char   AutoClipAdd;          /* AutoAdd on clip                         */
   char   baseline;             /* Baseline correct flag                   */
   float  offstart;             /* Start point for baseline correction     */
   float  offstop;              /* Stop point for baseline correction      */
   char   reject;               /* Auto reject flag                        */
   float  rejstart;             /* Auto reject start point                 */
   float  rejstop;              /* Auto reject stop point                  */
   float  rejmin;               /* Auto reject minimum value               */
   float  rejmax;               /* Auto reject maximum value               */
   char   trigtype;             /* Trigger type                            */
   float  trigval;              /* Trigger value                           */
   char   trigchnl;             /* Trigger channel                         */
   short int trigmask;          /* Wait value for LPT port                 */
   float trigisi;               /* Interstimulus interval (INT trigger)    */
   float trigmin;               /* Min trigger out voltage (start of pulse)*/
   float trigmax;               /* Max trigger out voltage (during pulse)  */
   char  trigdir;               /* Duration of trigger out pulse           */
   char  Autoscale;             /* Autoscale on average                    */
   short int n2;                /* Number in group 2 (MANOVA)              */
   char  dir;                   /* Negative display up or down             */
   float dispmin;               /* Display minimum (Yaxis)                 */
   float dispmax;               /* Display maximum (Yaxis)                 */
   float xmin;                  /* X axis minimum (epoch start in sec)     */
   float xmax;                  /* X axis maximum (epoch stop in sec)      */
   float AutoMin;               /* Autoscale minimum                       */
   float AutoMax;               /* Autoscale maximum                       */
   float zmin;                  /* Z axis minimum - Not currently used     */
   float zmax;                  /* Z axis maximum - Not currently used     */
   float lowcut;                /* Archival value - low cut on external amp*/
   float highcut;               /* Archival value - Hi cut on external amp */
   char  common;                /* Common mode rejection flag              */
   char  savemode;              /* Save mode EEG AVG or BOTH               */
   char  manmode;               /* Manual rejection of incomming data      */
   char  ref[10];               /* Label for reference electode            */
   char  Rectify;               /* Rectification on external channel       */
   float DisplayXmin;           /* Minimun for X-axis display              */
   float DisplayXmax;           /* Maximum for X-axis display              */
   char  phase;                 /* flag for phase computation              */
   char  screen[16];            /* Screen overlay path name                */
   short int CalMode;           /* Calibration mode                        */
   short int CalMethod;         /* Calibration method                      */
   short int CalUpdate;         /* Calibration update rate                 */
   short int CalBaseline;       /* Baseline correction during cal          */
   short int CalSweeps;         /* Number of calibration sweeps            */
   float CalAttenuator;         /* Attenuator value for calibration        */
   float CalPulseVolt;          /* Voltage for calibration pulse           */
   float CalPulseStart;         /* Start time for pulse                    */
   float CalPulseStop;          /* Stop time for pulse                     */
   float CalFreq;               /* Sweep frequency                         */
   char  taskfile[34];          /* Task file name                          */
   char  seqfile[34];           /* Sequence file path name                 */
   char  SpectMethod;           /* Spectral method                         */
   char  SpectScaling;          /* Scaling employed                        */
   char  SpectWindow;           /* Window employed                         */
   float SpectWinLength;        /* Length of window %                      */
   char  SpectOrder;            /* Order of Filter for Max Entropy method  */
   char  NotchFilter;           /* Notch Filter in or out                  */
   char  unused[11];            /* Free space                              */
   short  FspStopMethod;        /* FSP - Stoping mode                      */
   short  FspStopMode;          /* FSP - Stoping mode                      */
   float FspFValue;             /* FSP - F value to stop terminate         */
   short int FspPoint;          /* FSP - Single point location             */
   short int FspBlockSize;      /* FSP - block size for averaging          */
   unsigned short FspP1;        /* FSP - Start of window                   */
   unsigned short FspP2;        /* FSP - Stop  of window                   */
   float FspAlpha;              /* FSP - Alpha value                       */
   float FspNoise;              /* FSP - Signal to ratio value             */
   short int FspV1;             /* FSP - degrees of freedom                */
   char  montage[40];           /* Montage file path name                  */
   char  EventFile[40];         /* Event file path name                    */
   float fratio;                /* Correction factor for spectral array    */
   char  minor_rev;             /* Current minor revision                  */
   short int eegupdate;         /* How often incomming eeg is refreshed    */
   char   compressed;           /* Data compression flag                   */
   float  xscale;               /* X position for scale box - Not used     */
   float  yscale;               /* Y position for scale box - Not used     */
   float  xsize;                /* Waveform size X direction               */
   float  ysize;                /* Waveform size Y direction               */
   char   ACmode;               /* Set SYNAP into AC mode                  */
   unsigned char CommonChnl;    /* Channel for common waveform             */
   char   Xtics;                /* Scale tool- 'tic' flag in X direction   */
   char   Xrange;               /* Scale tool- range (ms,sec,Hz) flag X dir*/
   char   Ytics;                /* Scale tool- 'tic' flag in Y direction   */
   char   Yrange;               /* Scale tool- range (uV, V) flag Y dir    */
   float  XScaleValue;          /* Scale tool- value for X dir             */
   float  XScaleInterval;       /* Scale tool- interval between tics X dir */
   float  YScaleValue;          /* Scale tool- value for Y dir             */
   float  YScaleInterval;       /* Scale tool- interval between tics Y dir */
   float  ScaleToolX1;          /* Scale tool- upper left hand screen pos  */
   float  ScaleToolY1;          /* Scale tool- upper left hand screen pos  */
   float  ScaleToolX2;          /* Scale tool- lower right hand screen pos */
   float  ScaleToolY2;          /* Scale tool- lower right hand screen pos */
   short int port;              /* Port address for external triggering    */
   long  NumSamples;            /* Number of samples in continous file     */
   char  FilterFlag;            /* Indicates that file has been filtered   */
   float LowCutoff;             /* Low frequency cutoff                    */
   short int LowPoles;          /* Number of poles                         */
   float HighCutoff;            /* High frequency cutoff                   */
   short int HighPoles;         /* High cutoff number of poles             */
   char  FilterType;            /* Bandpass=0 Notch=1 Highpass=2 Lowpass=3 */
   char  FilterDomain;          /* Frequency=0 Time=1                      */
   char  SnrFlag;               /* SNR computation flag                    */
   char  CoherenceFlag;         /* Coherence has been  computed            */
   char  ContinousType;         /* Method used to capture events in *.cnt  */
   long  EventTablePos;         /* Position of event table                 */
   float ContinousSeconds;      /* Number of seconds to displayed per page */
   long  ChannelOffset;         /* Block size of one channel in SYNAMPS    */
   char  AutoCorrectFlag;       /* Autocorrect of DC values                */
   unsigned char DCThreshold;   /* Auto correct of DC level                */
} SETUP;
typedef struct {
   char Teeg;                   /* Either 1 or 2                           */
   long Size;                   /* Total length of all the events          */
   long Offset;                 /* Hopefully always 0                      */
} TEEG;
typedef struct {
   unsigned short StimType;     /* range 0-65535                           */
   unsigned char  KeyBoard;     /* range 0-11 corresponding to fcn keys +1 */
   char KeyPad_Accept;          /* 0->3 range 0-15 bit coded response pad  */
                                /* 4->7 values 0xd=Accept 0xc=Reject       */
   long Offset;                 /* file offset of event                    */
} EVENT1;
typedef struct{
   unsigned short StimType;     /* range 0-65535                           */
   unsigned char  KeyBoard;     /* range 0-11 corresponding to fcn keys +1 */
   char KeyPad_Accept;          /* 0->3 range 0-15 bit coded response pad  */
                                /* 4->7 values 0xd=Accept 0xc=Reject       */
   long Offset;                 /* file offset of event                    */
   short Type;
   short Code;
   float Latency;
   char EpochEvent;
   char Accept2;
   char Accuracy;
} EVENT2; Electrode position as used by Brain Dynamics Laboratory, 1996/1997 
  
 
 Westmead EEG file formatAugust 1997The following describes the important aspects of the EEG data files from the Department of Medical Physics and Cognitive Neuroscience Unit, Westmead Hospital, Westmead, NSW 2145, Australia. The files consist a ID line followed by a header followed by the actual data section. The ID and header is ascii/readable text while the EEG data is binary, simply a series of 2 byte signed ints (usually referred to in C as "short int"). Note that while the files have an ASCII header they must be FTPed or otherwise transferred in binary mode to preserve the EEG data part. While the mixed ASCII/BINARY nature makes dealing with these files a bit awkward at times, it is often convenient to browse the header using a text editor or just using "more". 
 Basic C source code that takes a Westmead EEG file and converts it into an ascii file is given here: westmead2ascii.c. It can be readily modified and used as the basis of a converter to meet you specific needs.Electrode positions as used by Westmead Hospital, 1995 -> 1999.  
 ASCII format for EEG signalsSeptember 1997The file consists of two header lines followed by the data. The first header line has 4 constants, the number of channels, the sampling frequency (Hz), the number of events, and the number of samples. The second header line consists of the column names for the data that follows. If the data is raw EEG signals then the columns should be the electrode names. The first two columns of the data section are predefined, they are the sample number and the event code. The remaining columns contain the samples from each channel (electrode). 
Note: 
 The first few representative lines of such a file might look like this: 
 62 500 0 1000 sample event FP1 FPZ FP2 F3A F4A F7 F5 F3 F1 FZ F2 F4 F6 F8 C5A C3A . . . 0 0 -1746 -1717 -1716 -1710 -1676 -1528 -1738 -1493 -1736 -1324 -1432 . . . 1 0 -1962 -1891 -1988 -1864 -1717 -1663 -1853 -1583 -1746 -1378 -1505 . . . 2 0 -2112 -1952 -2128 -1936 -1688 -1748 -1867 -1612 -1786 -1394 -1548 . . . 3 0 -2063 -1857 -2032 -1853 -1600 -1694 -1774 -1547 -1802 -1373 -1535 . . . 4 0 -1767 -1595 -1697 -1551 -1438 -1433 -1552 -1406 -1688 -1296 -1437 . . . 5 0 -1315 -1222 -1229 -1128 -1219 -1032 -1196 -1176 -1430 -1172 -1281 . . . 6 0 -898 -887 -822 -802 -1062 -683 -838 -976 -1144 -1067 -1148 -1139 . . . 7 0 -757 -799 -692 -772 -1042 -571 -676 -940 -1051 -1079 -1143 -1147 . . . : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : 
 Electrocap CoordinatesCompiled by Per LineJanuary 1997 
 
 
  International 10-20 electrode position standard. 
 | |||||||||||||