Skip to main content
  • Description
  • Computes zero-phase filtering (forward and reverse) on analog continuous channels of an EEG file, 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.


  • Usage
  • eegfiltfilt myeegfilein.eeg myparameterfile.par myeegfileout.eeg [+b32]

    with :

    • myeegfilein.eeg : input EEG file to filter (with extension).
    • myparameterfile.par : filtering parameter file (with extension).
    • myeegfileout.eeg : output (filtered) EEG file (with extension).
    • options:
      +b32 : forces output EEG file to be in 32 bits format. If omitted, output data is in the same format as the input file.


  • Fields of parameter file and example
  • 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
    1. This parameter file (lowpass_butter_10hz.par) computes Butterworth coefficients from the filter definition, and filters all channels of an EEG file containing 10 channels (8 EEG channels and 2 ELAN technical channels) :
    2. #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.par) filters all channels of an EEG file containing 10 channels (8 EEG channels and 2 ELAN technical channels), with a Butterworth filter of same characteristics designed in Matlab (with butter function):
    4. 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.par) computes a band-pass (2-30Hz) Butterworth filter, and filters all channels of an EEG file containing 10 channels (8 EEG channels and 2 ELAN technical channels):
    6. #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
    • WARNING : this tool is not intended to use with concatenated data. For this kind of data use eegepochfiltfilt.


  • Current version
  • 1.05 05-09-2011

  • History
    • 1.00 09-11-2010 (PEA) : 1st version.
    • 1.01 17-11-2010 (PEA) : adds test for filter stability when computing Butterworth coefficients.
    • 1.02 08-12-2010 (PEA) : minor modification.
    • 1.03 03-03-2011 (PEA) : adds +b32 option to force 32 bits output EEG data.
    • 1.04 01-09-2011 (PEA) : fixes error when saving 16 bits data in 32 bits format (+b32 option).
    • 1.05 05-09-2011 (PEA) : changes initial conditions computation (fits to Matlab).


  • Files
  • $ELANPATH/bin/eegfiltfilt

  • See also
  • epfiltfilt, eegepochfiltfilt, eegresample

AttachmentSize
lowpass_butter_10hz.par119 bytes
lowpass_butter_10hz_coefs.par335 bytes
bp_2-30Hz.par123 bytes