Skip to main content
  • Description
  • Computes from an EEG file the mean of the time-frequency powers obtained from each single-trial (mean squared modulus of the wavelet transform). The output is stored in TF file format (one .avg.tf file by event code). The stimulus phase-locking factor is also computed for each event code and stored in TF file format (one .pl.tf file by event code). An averaged EP file (.p) can be substracted to each single trial prior to time-frequency transform.
    These computations requires a parameter file .par and an event position file .pos. Usually, the .pos file is the output of the averaging/rejection program eegavg.

  • Usage
  • tfavg myeegfile.eeg myposfile.pos myparfile.par subsampling [+v] [+ri] [+s] [+z] [+allchannels] [+noreref]

    with :

    • myeegfile.eeg: input .eeg file to process (with extension).
    • myposfile.pos: input event file (with extension).
    • myparfile.par: text file containing computation parameters (with extension).
    • subsampling: time-subsampling factor applied to the tf file created. In all cases, the time sample corresponding to the event onset (0 msec) is kept.
    • 1 : all time samples are saved,
      2 : one over 2 samples are saved,
      3 : one over 3 samples are saved,
      ….

    • options:
      +v : verbose mode on: all events are displayed during the processing progress. If omitted, verbose mode is off.
      +ri : creation of files .avgr.tf and .avgi.tf in TF format, containing the normalized mean real and imaginery parts of the time-frequency transforms; these values are useful for computing the mean of the stimulus-phase-locking factor across several files. If omitted, no file created.
      +s : creation of files .avg2.tf in TF format, containing the mean of the squared values of the time-frequency power (mean of the modulus4 of the wavelet transform). These values are useful for computing the standard deviation of the time-frequency power estimate. If omitted, no file created.
      +z : computes and creates a .Z.avg.tf file with the mean value across trials of the Z-transform of each trial, computed with respect to the baseline defined in the parameter file myparfile.par: (data – mean baseline)/standard deviation of baseline. If omitted, the file is not computed.
      +allchannels : compute on all analog channels of myeegfile.eeg. The "tf_channel_flag" field of parameter file isn't read.
      +noreref : don't change reference of myeegfile.eeg channels. The "tf_channel_ref" field of parameter file isn't read.


  • Fields of parameter file and examples
  • fileprefix myfilename Prefix of the output TF files.
    nb_eventcode 2 Number of event codes to process.
    list_eventcode 2 5 List of the event codes to process.
    prestim_nbsample 400 400 List of the numbers of samples in the prestimulus period; one value for each event code.
    poststim_nbsample 1000 1000 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_msec_start -200 -200 Required only for computing the Z-transform in .Z.avg.tf file (option +z in the command line); list of the baseline start latencies (in ms); one value for each event code.
    baseline_msec_stop -50 -50 Required only for computing the Z-transform in .Z.avg.tf file (option +z in the command line); list of the baseline stop latencies (in ms); one value for each event code.
    tf_channel_flag 1 1 0 1 0 0 0 List of the channels to process: 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 processed and stored in the output .avg.tf files.
    tf_channel_ref 0 3 0 5 0 0 0 List of the new reference for each channel before processing (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 myfile.eeg file; the last 2 flags should be set to 0.
    If omitted, the channels are not modified.
    In this example, N=5, and channel 1 is unchanged, channel 2 is referenced to channel 3, and channel 4 re-referenced to channel 5.
    tf_freq_start 18 18 List of the starting frequencies (in Hz) for the time-frequency analysis (one value for each event code).
    tf_freq_stop 80 80 List of the ending frequencies (in Hz) for the time-frequency analysis (one value for each event code).
    tf_freq_step 2 2 List of the frequency steps (in Hz) for the time-frequency analysis (one value for each event code).
    tf_nb_sample_blackman 100 100 List of the number of samples in the rise or fall time period of the blackman window applied on the single trials before the wavelet transform (one value for each event code).
    tf_wavelet_type 1 1 List of the types of wavelet used for the time-frequency analysis (one value for each event code):
    1: Morlet wavelet.
    2: Gabor wavelet.
    tf_morlet_m 7 7 In case of Morlet wavelet, list of the m ratio used for the time-frequency analysis (one value for each event code): m=f0/sigmaf
    Suggested values for m: m>5, usually m=7.
    This determines the number of cycles of the wavelet.
    tf_gabor_sigmat 100 100 In case of Gabor wavelet, list of the half-window durations of the wavelets (in msec) irrespective of the frequency band (one value for each event code).
    tf_substract_epfile ep.2.p ep.5.p List of the EP file names with extension (.p) used for substracting an averaged response to each single trial prior to time-frequency computation (one string for each event code). These .p files should be compatible to the time-frequency analysis parameters (number of channels, number of samples pre and post-stimulus).
    If omitted, no .p file is substracted to the single trials.


  • Examples
  • In this example, all trials with codes 2 or 5 will be processed with a time window ranging from from 400 samples prior to 1000 samples after event code. The time-frequency analysis will be performed on channels 2 and 5, from 18 to 80 Hz by steps of 2 Hz with a Blackman window having 100 samples for the rise- and for the fall-time, and with Morlet wavelets with a m ratio set to 7.Wavelet transform is performed on channels 1, 2 and 4; channel 1 is unchanged, channel 2 is re-referenced to channel 5, and channel 4 to channel 6.

    Output files:

    Name Comments#
    myfilename.2.avg.tf
    myfilename.5.avg.tf
    Mean of the time-frequency power across single trials (event codes 2 and 5 in this example).
    myfilename.2.pl.tf
    myfilename.5.pl.tf
    Stimulus-phase-locking factor in the time-frequency domain computed across single trials (event codes 2 and 5 in this example).
    myfilename.2.avgr.tf
    myfilename.2.avgi.tf
    myfilename.5.avgr.tf
    myfilename.5.avgi.tf
    If option +ri: Normalized mean real and imaginery parts of the time-frequency transforms obtained over single trials (event codes 2 and 5 in this example).
    myfilename.2.avg2.tf
    myfilename.5.avg2.tf
    If option +s: Mean of the squared values of the time-frequency power across single trials (event codes 2 and 5 in this example).
    myfilename.2.Z.avg.tf
    myfilename.5.Z.avg.tf
    If option +z: Z-transform of the data with respect to the baseline computed on each single trial and averaged across trials (event codes 2 and 5 in this example).


  • 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.38 23-07-2014

  • History
    • 1.00 01-12-2001 (OB/CTB/PEA) : 1st documented version.
    • 1.10 09-12-2001 (PEA) : changes labels of parameter file.
    • 1.11 31-01-2002 (PEA) : checks for subsampling step validity.
    • 1.12 04-02-2002 (PEA) : minor modification.
    • 1.13 23-04-2002 (PEA) : changes file extensions. Adds +z option.
    • 1.14 29-05-2002 (PEA) : changes .z.tf to .Z.avg.tf.
    • 1.15 17-06-2002 (PEA) : supports readpos function (from libpos).
    • 1.16 26-06-2002 (PEA) : changes integer types (long, short to int).
    • 1.17 25-02-2003 (PEA) : minor modification.
    • 1.18 18-09-2003 (PEA) : changes EEG values process. Removes unused variables.
    • 1.19 03-11-2003 (PEA) : adds check for dynamic memory allocation.
    • 1.20 13-11-2003 (PEA) : adds 32 bits EEG support.
    • 1.21 12-10-2004 (PEA) : adds EP file substraction.
    • 1.22 03-11-2004 (PEA) : uses rejection flag of .pos files (libpos).
    • 1.24 18-01-2006 (PEA) : ???.
    • 1.25 02-03-2006 (PEA) : improves memory allocations.
    • 1.26 10-03-2006 (PEA) : improves memory allocations.
    • 1.27 09-01-2007 (PEA) : fixes channel names when no number (elec.dat) is given (adds -1).
    • 1.28 13-08-2007 (PEA) : minor modification.
    • 1.29 25-11-2008 (PEA) : adds MPI usage with OpenMPI. Removes static allocations. Changes array indexation for more readability. Fixes signtest function (libstat) for 64 bits. Adds write_tf_frequency function to libtfmoy.
    • 1.30 19-12-2008 (PEA) : improves memory usage for MPI version (allocation of used frequencies only).
    • 1.31 13-03-2009 (PEA) : improves frequency distribution in MPI version.
    • 1.32 22-02-2010 (PEA) : fixes reading EP file to substract in libpem.
    • 1.33 17-06-2011 (PEA) : uses threads to compute TF transform (TF transform function of libelansignal).
    • 1.34 20-06-2011 (PEA) : minor modification : optimizes memory usage for signal.
    • 1.35 12-06-2012 (PEA) : minor modification : output file name creation.
    • 1.36 22-10-2012 (PEA) : add "+allchannels" and "+noreref" options.
    • 1.37 21-07-2014 (PEA) : fixes an error with +z option introduced with thread usage. Removes baseline_eventcode field (not used).
    • 1.38 23-07-2014 (PEA) : fixes some memory leaks (no deallocation).


  • Files
  • $ELANPATH/bin/tfavg

  • See also
  • tfep, tfsync