Pre-processing: Filtering

Video Navigator

  1. Goals of Preprocessing Data (40s)
  2. Pre-processing data steps (1m 25s)
  3. DC Offset (1m 48s)
  4. Why Filter (2m 51s)
  5. Frequency Filters (3m 36s)
  6. Low Pass Filters (4m 50s)
  7. High Pass Filters (6m 47s)
  8. Bandpass Filters (8m 28s)
  9. Notch Filters (8m 53s)
  10. Filter Types: Summary (9m 20s)
  11. Process in Matlab (9m 51s)

Goals of Pre-processing Data

Get the raw data into a format that we can look at

Below is the goal of each step, and the corresponding data processing step that helps to achieve the goal.

  1. Reduce noise in the data
    1. Filtering
    2. Artifact Rejection
    3. Bad Channels
  2. Transform the data so it can be compared across trials, conditions, etc.
    1. Baseline correction
    2. Re-referencing
  3. Extract segments of data from the EEG that are time locked to events in the experiment
    1. Epoching
  4. Create and ERP waveform that can be used to compare participants
    1. Averaging

Pre-processing Data Steps

The order of these steps depends on if you have DC or AC data

  1. Filter the data
  2. Look for and deal with any bad channels
  3. Re-reference the data
  4. Epoch the data
  5. Baseline Correct the data
    1. Note steps 4&5 are the same in ERPlab
  6. Artifact Rejection
  7. Average the Data

DC Offset

Before you start filtering...DC Offset

  1. What is the DC offset?
    1. Takes the average of the entire recording and shifts the recording so it averages to 0
      1. Depending on where we are recording, we may start at a different voltage level
      2. Averaging them to 0 brings them to alignment with each other
      3. Without DC offset it will be much more difficult to visually compare the electrode recordings to each other
  2. When do you do a DC Offset
    1. When collecting DC data rather than AC
    2. During the first stage of processing when you filter the data

Why Filter

  1. Improve visual inspection and interpretation
  2. Reduce noise that is not brain activity
    1. Reduce noise from the environment
      1. Reduce 60 Hz equipment noise
    2. Reduce noise from the participant
      1. Reduce EMG frequencies over 100 Hz
      2. Reduce skin potentials and drift
  3. Brain activity is only ~.1 to 30 Hz

Frequency Filters

  1. Frequency filters are like coffee filters
  2. Coffee filters allow coffee to pass through the filter, and block the unwanted grounds
  3. Frequency filters set a threshold that allows certain frequencies to pass (retain), and block the unwanted frequencies (attenuate)
  4. 4 primary filters which we will talk about today
    1. Low pass
    2. High pass
    3. Band pass
    4. Notch
  5. Note: Most filters are a linear operation, so order of operations does not matter
    1. In our process, we do the DC offset within the filtering process, making filtering at the beginning a good option

Low Pass Filters

  1. Only frequencies below the threshold (i.e. they are low enough) can pass through to stay in the data.
    1. Example: If you put up a gate, only something things can get under the gate. A tall giraffe could not get under the gate, but a small mouse could
  2. Low pass filters mostly reduce electrical noise and EMG (muscle) noise
  3. Example of a low pass filter
    1. Example graph (right side of the screen)
      1. Original data (black line) starts with jagged, high-frequency noise
      2. Using the filter smooths out those edges, making the data look more like the red line
        1. Allows us to view the more general peaks, rather than all the noise peaks
    2. Deciding the threshold of the filter (left side of the screen)
      1. Think about how much we are letting pass through (letting different amounts of different frequencies through)
        1. It is not an on or off switch
      2. Below 30 Hz, the amount of the frequencies getting through the filter is more
      3. Above 30 Hz, the amount of frequencies getting through the filter is less
      4. Half amplitude cut off is where about 50% of that frequency is getting through

High Pass Filters

  1. Only let frequencies higher than the threshold frequency can pass through
  2. Limitation: high pass filters can create artificial peaks and reduce parts of the wave
    1. ALWAYS good to look at what your filter is doing to the data!
  3. High pass filters mostly used to reduce slow changes in voltage (e.g. skin potentials which are much lower in frequency)
  4. Example of high pass filter
    1. What happens to the data (right side of the screen)
      1. The higher the high pass filter, the more squat the waveforms get
      2. High pass filters reduce the amplitude of your waveform, which may not be desirable depending on what component you are interested in
    2. Visualization of the filter (left side of the screen)
      1. Upper example
        1. Similar to low pass filter example
      2. Lower example
        1. More similar to what you may see in a program
        2. Such small numbers means the program will often show you a straight line, but in actuality it is not an off vs. on, rather it is more of a curved effect like the other filter

Bandpass Filters

  1. If you put together a low and a high pass filter, you get a bandpass filter
  2. The range of frequencies in-between your thresholds can pass through

Notch Filters

  1. Cuts out a small notch of frequencies -- very narrow band of frequencies removed; most frequencies untouched
  2. Often used for 60 Hz electrical noise from lights

Filter Types: Summary

  1. Low Pass Filters allow the lower frequency data through, attenuating the higher frequency data
  2. High Pass Filters allow the higher frequency data through, attenuating the lower frequencies
  3. Band Pass filter allows only a band of data through
  4. Notch Filters allow all data through, except for data at a specific frequency, which it removes.

Process in Matlab

  1. Open Matlab and set a path
    1. Set Path
      1. Add with subfolders (to ensure your grab all folders within the selected folder)
      2. Navigate to wherever your plugins are
      3. Save the path if you can, and close
  2. Type "eeglab" in the command window to pull up the EEGlab and ERPlab GUI
  3. Import raw data file
    1. File > Import data > Using eeglab function and plugins > From Brain Vis. Rec. .vhdr or .ahdr file
    2. Navigate to data file and select the applicable .vhdr file
    3. Click ok on the question pop up
    4. Name it the subject number
  4. We can confirm the data is loaded by
    1. Datasets tab - whatever dataset has a checkmark next to it is your active dataset
    2. Checking the info in the GUI - there is info in the right column for each of the descriptors of the data
    3. EEGlab > Plot > Channel Data (scroll) - if there is data in the plot, we know the data is loaded
  5. Filter the data
    1. ERPLAB > Filter and frequency tools > Filters for EEG data
    2. In the Basic Filter GUI for continuous data that pops up we can see:
      1. Image of what it thinks the filter will do to the data
      2. Filter type (we use IIR Butterworth filter)
      3. Under Cutoff frequencies, check the Remove mean value (DC bias) before filtering
      4. Thresholds for High-Pass and Low-Pass filters (grey when inactive, yellow when active)
        1. High-Pass at .1
        2. Low-Pass at 30
        3. Play around with these values to see what they do to your data
        4. Click Apply to filter the data with those values
        5. Name it: _filt tag tells you what just happened to the data
        6. Save it as file: Can save the data elsewhere on your computer to save this step
          1. Depending on your version you may be asked to save your old dataset, which is necessary if you want the old dataset in your Datasets tab list
  6. Plot > Channel Data (scroll) to see the filtered data
    1. Can scroll through the entire data time length, as well as change the scale
    2. In comparing different datasets, make sure they are on the same scale, otherwise it is more difficult to
  7. If you want to refilter the data, go back to the raw dataset in the datasets tab
    1. If it asked to save the dataset you are navigating away from, make sure you do so
    2. After re-filtering, make sure to name it something different from your first filtered data to differentiate
    3. You can then plot each filtered dataset to compare the data between filters

Additional Information

PURSUE teaching modules provide instructors with everything they need to add EEG/ERP content in existing courses, teach a full semester course, or train research assistants in the lab. Follow this link to Lab Training Modules that can be used with tutorial videos.

Associated Teaching Modules: Lab Training Modules, Filtering EEG/ERP Data