Skip to main content
  • Description
  • Computes zero-phase filtering (forward and reverse) on analog continuous channels of an EEG file containing concatenated epochs, and creates a new EEG file. As input parameters, it can use B and A coefficients computed with Matlab (or SciPy, Octave, Scilab), or it can compute Butterworth filter coefficients from cutoff frequencies. It can compute band-pass, band-stop, low-pass or high-pass filtering.
    When computing Butterworth coefficients, a test for filter stability is processed. If the filter is unstable, no filtering is computed and a message for the new filter order to apply is displayed.
    The output EEG file contains only concatenated epochs. The epochs are made from event codes and pre-stimulus and post-stimulus number of samples.


  • Usage
  • eegepochfiltfilt myeegfilein.eeg myparameterfile.par myevent.pos myeegfileout.eeg

    with :

    • myeegfilein.eeg : input EEG file to filter (with extension).
    • myparameterfile.par : filtering parameter file (with extension).
    • myevent.pos : event file used for epoching (with extension). It contains the events marking zero time of epochs.
    • myeegfileout.eeg : output (filtered) EEG file (with extension).


  • Fields of parameter file and example
  • nb_eventcode 2 Number of event codes to process.
    list_eventcode 2 5 List of the event codes to process.
    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.
    filter_channel 1 1 0 1 0 0 0 List of the channels to filter: 1/0 for selected/unselected channels; the total number of flags is N+2, N being the number of recorded channels in myeegfilein.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 filtered but all channels are stored in the output files.
    filter_type 0 Type of Butterworth filter. Valid values are :
    0 for low-pass filter
    1 for high-pass filter
    2 for band-pass filter
    3 for band-stop filter
    In this example, a low-pass filter is processed.
    filter_order 3 Butterworth filter order.
    In this example, the filter order is 3.
    filter_cutoff_freq1 30 Cutoff frequency 1.
    In case of filter type :
    0 (low-pass) filter : attenuates higher frequencies.
    1 (high-pass) filter : attenuates lower frequencies.
    2 (band-pass) filter : lower frequency of the range of frequencies to pass.
    3 (band-stop) filter : lower frequency of the range of frequencies to attenuate.
    filter_cutoff_freq2 100 Cutoff frequency 2. Needed only for band-pass and band-stop filter (filter_type 2 or 3).
    In case of filter type :
    2 (band-pass) filter : higher frequency of the range of frequencies to pass.
    3 (band-stop) filter : higher frequency of the range of frequencies to attenuate.
    filter_b_coeff_nb 4 Number of B coefficients (in the Matlab way). These coefficients can be of a Butterworth filter, or any other filter.
    filter_b_coeffs
    2.71835675758059e-05 8.15507027274176e-05 8.15507027274176e-05 2.71835675758059e-05
    List of B coefficients.
    As it is text file, be careful of include a maximum of significant digits.
    In this example, coefficients are corresponding to a low-pass Butterworth filter of order 3.
    filter_a_coeff_nb 4 Number of A coefficients (in the Matlab way). These coefficients can be of a Butterworth filter, or any other filter.
    filter_a_coeffs
    1 -2.87730072411486 2.76201379931893 -0.884495606663461
    List of A coefficients.
    As it is text file, be careful of include a maximum of significant digits.
    In this example, coefficients are corresponding to a low-pass Butterworth filter of order 3.

    Use parameters when working with a Butterworth filter and setting filter order, type and cutoff frequency(ies).
    Use parameters when working with a coefficients computed by another way.


  • Examples
  • Both examples below are used to filter concatenated (epoched) data. The epoching is done for event codes 2 and 5.
    The events with code 2 have 400 samples in the pre-stimulus and 1000 samples in the post-stimulus (the epochs contains 400+1+1000 samples).
    The events with code 5 have 800 samples in the pre-stimulus and 1200 samples in the post-stimulus (the epochs contains 800+1+1200 samples).

    1. This parameter file (lowpass_butter_10hz_epoch.par) computes Butterworth coefficients from the filter definition, and filters all channels of an EEG file containing 10 channels:
    2. nb_eventcode 2
      list_eventcode 2 5
      
      prestim_nbsample 400 800
      poststim_nb_sample 1000 1200
      
      
      #low_pass Butterworth filter
      filter_type 0
      
      filter_order 3
      
      filter_cutoff_freq1 10
      
      filter_channel 1 1 1 1 1 1 1 1 0 0
      
    3. This parameter file (lowpass_butter_10hz_coefs_epoch.par) filters all channels of an EEG file containing 10 channels, with a Butterworth filter of same characteristics designed in Matlab (with butter function):
    4. nb_eventcode 2
      list_eventcode 2 5
      
      prestim_nbsample 400 800
      poststim_nb_sample 1000 1200
      
      filter_channel 1 1 1 1 1 1 1 1 0 0
      
      #low_pass Butterworth filter designed with Matlab butter function
      filter_b_coeff_nb 4
      
      filter_b_coeffs
      2.71835675758059e-05    8.15507027274176e-05    8.15507027274176e-05
      2.71835675758059e-05
      
      filter_a_coeff_nb 4
      
      filter_a_coeffs
      1       -2.87730072411486      2.76201379931893 -0.884495606663461
      
    5. This parameter file (bp_2-30Hz_epoch.par) computes a band-pass (2-30Hz) Butterworth filter, and filters all channels of an EEG file containing 10 channels:
    6. nb_eventcode 2
      list_eventcode 2 5
      
      prestim_nbsample 400 800
      poststim_nb_sample 1000 1200
      
      
      #band_pass
      filter_type 2
      
      filter_order 3
      
      filter_cutoff_freq1 2
      filter_cutoff_freq2 30
      
      filter_channel 1 1 1 1 1 1 1 1 0 0
      


  • Comments

  • Current version
  • 1.02 24-01-2017

  • History
    • 1.00 29-11-2010 (PEA) : 1st version.
    • 1.01 05-09-2011 (PEA) : changes initial conditions computation (fits to Matlab).
    • 1.02 24-01-2017 (PEA) : fix an error in data offset computing on large files (>2GB).


  • Files
  • $ELANPATH/bin/eegepochfiltfilt

  • See also
  • epfiltfilt, eegfiltfilt

AttachmentSize
bp_2-30Hz_epoch.par215 bytes
lowpass_butter_10hz_coefs_epoch.par426 bytes
lowpass_butter_10hz_epoch.par426 bytes