Skip to main content
  • Description
  • Computes average evoked potentials from an .eeg file, with artifact rejection. The output is stored in .p file format (one .p file by event code).

  • Usage
  • eegavg myeegfile.eeg myposfilein.pos myparfile.par myposfileout.pos [+v] [+s] [+z] [+z2] [+t] [+allchannels] [+noreref] [+norejection]

    with :

    • myeegfile.eeg: input .eeg file to process (with extension).
    • myposfilein.pos: input event file (with extension).
    • myparfile.par: text file containing average and rejection parameters (with extension).
    • myposfileout.pos: output event file (with extension). It contains the events marked with a rejection code or not.
    • options:
      +v : verbose mode on. If omitted, verbose mode is off.
      +s : creates an .sem.p file with the standard error of the mean (sem) across trials, and an .T.p file with t-test T values for comparison to baseline level (mean/sem). If omitted, files are not created.
      +z : creates a .Z.p file with a Z-transform of the data computed across trials with respect to the baseline : (data – mean baseline)/standard deviation of baseline. If omitted, the file is not created.
      +z2 : creates an .Z2.p file with a Z-transform of the squared data computed across trials with respect to the baseline : (squared data – mean squared baseline)/standard deviation of squared baseline. If omitted, the file is not created.
      +allchannels : computes on all input data file's channels. The "ep_channel_flag" field of parameter file isn't read.
      +noreref : don't change reference of input data channels. The "ep_channel_ref" field of parameter file isn't read.
      +norejection : accept all trials without processing any rejection. The "ep_channel_rejtype" field of parameter file isn't read.


  • Fields of parameter file and examples
  • fileprefix myfilename Prefix of the output .p files.
    nb_eventcode 2 Number of event codes to process.
    list_eventcode 2 5 List of the event codes to process.
    flag_eventcode 1 0 List of flags on the event codes:
    1: event code is processed (rejection and averaging)
    0: event code is written in myposfileout.pos, but not processed.
    This field is optional.
    prestim_nbsample 400 800 List of the numbers of samples in the prestimulus period; one value for each event code.
    poststim_nbsample 1000 1200 List of the numbers of samples in the poststimulus period; one value for each event code; the total number of samples of the analysis is prestim_nbsample + poststim_nbsample + 1, the extra sample corresponds to the event itself.
    baseline_eventcode 2 2 List of the event codes used to compute the baseline.
    0: no baseline correction (default),
    ≠0: event code on which baseline will be computed.
    In this example, the baseline for event code 2 will be computed from event code 2, and the baseline of event code 5 from event code 2.
    This field is optional.
    baseline_msec_start -200 -200 List of the baseline start latencies (in ms); one value for each event code; required only if baseline_eventcode≠0.
    If omitted and baseline_eventcode≠0, the baseline value is computed on the whole epoch.
    baseline_msec_stop -50 -50 List of the baseline stop latencies (in ms); one value for each event code; required only if baseline_eventcode≠0.
    If omitted and baseline_eventcode≠0, the baseline value is computed on the whole epoch.
    ep_channel_flag 1 1 0 1 0 0 0 List of the channels to average: 1/0 for selected/unselected channels; the total number of flags is N+2, N being the number of recorded channels in myeegfile.eeg file; the last 2 flags should be set to 0.
    In this example, N=5, and only channels number 1, 2, 4 will be averaged and stored in the output .p files.
    ep_channel_ref 0 5 0 6 0 0 0 List of the new reference for each channel before averaging (bipolar montage for instance):
    0: no change of the reference,
    ≠0: electrode number (rank) to which the current channel should be re-referenced.
    The total number of values is N+2, N being the number of recorded channels in myeegfile.eeg file; the last 2 flags should be set to 0.
    This field is optional. If omitted, the channels are not modified.
    In this example, N=5, and channel 1 is unchanged, channel 2 is referenced to channel 5, and channel 4 re-referenced to channel 6.
    ep_channel_rejtype 0 0 0 1 0 0 0 List of the rejection types per channel : 0, 1 or 2
    0: no artifact rejection (default)
    1: trial rejection when the amplitude of one of the selected channel exceeds a specified threshold (value given by rej_max_val and rej_min_val; the trial is rejected if any sample is outside the interval [rej_min_val rej_max_val]);
    2: trial artifact rejection when, for one of the selected channel, the amplitude range in a time window exceeds a specified threshold (amplitude specified by rej_range_val and time-window by rej_time_window); event rejected if the signal has an amplitude range larger than rej_range_val in any time-window of rej_time_window duration.
    The total number of flags should be N+2 as in ep_channel_flag (last 2 channels set to 0); artifact rejection will be active only on channels selected in the ep_channel_flag_list. Mixing artifact rejection types 0, 1 and 2 is possible for different channels.
    rej_max_val 0 0 0 15 0 0 0 List of maximum threshold values per channel (physical units (microV, fT, ...)) for amplitude artifact rejection (ep_channel_rejtype = 1). The total number of values should be N+2 (last 2 channels set to 0).
    rej_min_val 0 0 0 -20 0 0 0 List of minimum threshold values per channel (in physical units (microV, fT, ...)) for amplitude artifact rejection (ep_channel_rejtype = 1). The total number of values should be N+2 (last 2 channels set to 0).
    If omitted, the minimum amplitude threshold values are set to - rej_max_val.
    rej_range_val 0 0 0 30 0 0 0 List of threshold values per channel (in physical units (microV, fT, ...)) for amplitude range artifact rejection (ep_channel_rejtype = 2). This threshold is applied either on the whole trial duration (if rej_time_window=0) or on a moving window (if rej_time_window≠0). (The total number of values should be N+2 (last 2 channels set to 0).
    rej_range_val_min 2 2 2 2 2 2 2 List of upper threshold values per channel (in physical units (microV, fT, ...)) for minimum signal variation required in the rejection window (ep_channel_rejtype = 2). This allows to reject trials with “flat” signals (amplitude variation below 2 µV in this example) corresponding to saturating amplifiers. The total number of values should be N+2 (last 2 channels set to 0).
    If omitted, the rejection on this upper threshold is not applied.
    rej_time_window 0 0 0 50 0 0 0 List of time-window length per channel (in ms) for amplitude range artifact rejection (ep_channel_rejtype = 2). The total number of flags is N+2 (last 2 channels set to 0).
    If omitted, rejection on amplitude range will be performed on the whole epoch.
    rej_beg_lat_msec 100 50 List of starting latencies (in ms) to perform rejection for each event.
    If omitted, rejection will be performed from the beginning of the epoch.
    rej_end_lat_msec 500 250 List of ending latencies (in ms) to perform rejection for each event.
    If omitted, rejection will be performed until the end of the epoch.
    erpa_positivity_up 1 Value stored in all output .p file to set the default upward/downward positivity orientation for curve display (by erpa).
    -1 (positivity down) or 1 (positivity up)
    This field is optional. If omitted, erpa will display curve with positivity down.
    erpa_view 4 Value stored in all output .p file. It is used by erpa to set the default mapping view.
    1: right view
    2: left view
    3: top view
    4: back view
    5: large top view
    6: back-top view
    This field is optional. If omitted, it is set to 0, and erpa default will be top view.



    Output:

    • averaged evoked responses (ep files .p) (event codes 002 and 005 in this example):
      myfilename.002.p
      myfilename.005.p
    • text file with all the output displayed on the screen by the program in verbose mode :
      myparfile.par.res
    • if option +s: standard error of the mean across trials (.p files) (event codes 002 and 005 in this example) :
      myfilename.002.sem.p
      myfilename.005.sem.p
    • if option +s: t-test T values for comparison to baseline level (mean/sem) (.p files) (event codes 002 and 005 in this example) :
      myfilename.002.T.p
      myfilename.005.T.p
    • if option +z: Z-transform of the data with respect to the baseline (.p files) (event codes 002 and 005 in this example) :
      myfilename.002.Z.p
      myfilename.005.Z.p
    • if option +z2: Z-transform of the squared data with respect to the squared baseline (.p files) (event codes 002 and 005 in this example) :
      myfilename.002.Z2.p
      myfilename.005.Z2.p


  • Examples
    • baseline correction :
      fileprefix example1
      nb_event_code 3
      list_event_code 80 2 44
      prestim_nbsample 400 100 200
      poststim_nbsample 400 400 400

      baseline_eventcode 80 44 0
      baseline_ms_start -200 -100 0
      baseline_ms_stop -100 0 0

      ep_channel_flag 1 1 1 1 1 1 1 1 0 0
      ep_channel_rejtype 0 0 0 0 0 0 0 0 0 0


      In this example:
      - response to the event code 80 will be baseline corrected using the mean value between -200 and -100 ms prior to event 80,
      - response to the event code 2 will be baseline corrected using the mean value between -100 and 0 ms prior to event 2,
      - response to the event code 44 will not be baseline corrected.

    • artifact rejection :
      fileprefix example2
      nb_event_code 1
      list_event_code 80
      prestim_nbsample 400
      poststim_nbsample 400

      baseline_eventcode 80
      baseline_ms_start -100
      baseline_ms_stop 0

      ep_channel_flag 1 1 1 1 1 1 1 1 0 0
      ep_channel_rejtype 0 0 0 0 0 0 0 1 0 0
      rej_max_val 0 0 0 0 0 0 0 30 0 0


      In this example, all events with the code 80 will be averaged on the 7 acquired channels, except those for which the signal in channel # 7 is more than 30 uV or less than -30 uV, from 400 samples prior to 400 samples after event 80.

    • artifact rejection :
      fileprefix example3
      nb_event_code 1
      list_event_code 80
      prestim_nbsample 200
      poststim_nbsample 400

      baseline_eventcode 80
      baseline_ms_start -100
      baseline_ms_stop 0

      ep_channel_flag 1 1 1 1 1 1 1 1 0 0
      ep_channel_rejtype 2 2 2 2 2 2 2 2 0 0
      rej_range_val 30 30 30 30 30 30 30 30 0 0
      rej_time_window 10 10 10 10 10 10 10 10 0 0


      In this example, all events with the code 80 are averaged, except those for which the signal in any channel has an amplitude range larger than 30 uV on a 10 ms moving time-window. The time-window is shifted by 1 sample step from 200 samples prior to 400 samples after event 80.


  • Comments
    1. Note to CTF 275 MEG users : an example of parameter file with 275 channels is available to download (ctf275_meg.par)
    2. See eegchref to create a re-referenced .eeg data file (several referencing options available).


  • Current version
  • 1.51 19-02-2014

  • History
    • 1.31 13-01-2006 (OB) : bug fix for baseline correction base on another event.
    • 1.32 13-01-2006 (PEA) : bug fix for EEG file size > 2GB.
    • 1.33 29-03-2006 (PEA) : modification for 64 bits compilation.
    • 1.35 31-07-2006 (PEA) : change in rejection. Output event file contains averaged and rejected events (with rejection code).
    • 1.36 17-07-2006 (PEA) : bug fix for rejection code (power of 2). When multiple rejection case for one event, operation between codes is OR.
    • 1.37 14-03-2007 (PEA) : add "+t" command line option. If present, rejection results are written to a text file (fileprefix.rej.out.txt).
    • 1.38 01-08-2007 (PEA) : bug fix : sum in an array of double instead of int (causes overflow).
    • 1.39 13-08-2007 (PEA) : minor modification.
    • 1.40 10-11-2009 (PEA) : bug fix for rejection for dynamic saturation (overflow int values for 32 bits EEG V3).
    • 1.41 05-02-2010 (PEA) : minor modification (use fprintf instead of printf, and make difference between stderr and stdout).
    • 1.42 22-02-2010 (PEA) : correction for reading all events (not just good events) to have all events in output event file.
    • 1.43 23-09-2010 (PEA) : update to use cmake and free release of Elan.
    • 1.44 07-01-2011 (PEA) : fixes buffer overflow and memory problems.
    • 1.45 23-10-2012 (PEA) : remove all static allocations. No maximum nuber of channels.
    • 1.46 24-10-2012 (PEA) : add +allchannels, +noreref and +norejection options to force compute on all channels, no reference change and no rejection without reading corresponding fields of parameter file.
    • 1.47 11-02-2013 (PEA) : fixes a memory error when storing baseline values when no baseline correction is performed.
    • 1.48 19-07-2013 (PEA) : fixes an error when rereferencing a channel with a channel with higher amplitude data may cause data overflow.
    • 1.49 11-09-2013 (PEA) : fixes an error in rejection due to last modification. Fixes a memory deallocation (output data array).
    • 1.50 16-09-2013 (PEA) : fixes an error in baseline correction between events (baseline_eventcode field of parameter file).
    • 1.51 19-02-2014 (PEA) : fixes an error for dynamic rejection (type 2) and specific rejection window (rej_beg_lat_msec and rej_end_lat_msec). Bad rejection window was used.


  • Files
  • $ELANPATH/bin/eegavg

  • See also
  • eegstat, eegchref

AttachmentSize
ctf275_meg.par7.67 KB