4.4: Exercise- Filtering the Artificial Waveforms
-
- Last updated
- Save as PDF
Now let’s apply a simple filter to the artificial data from the previous exercise. Load waveforms.erp if it isn’t already loaded, and select ERPLAB > Filter & Frequency Tools > Filters for ERP data . Set the parameters as shown in Screenshot 4.3. Most importantly, High-Pass should be unselected and Low-Pass should be selected with a cutoff at 30 Hz. For the big white plotting window, set the X limits to 0 100 . Make sure that the function shown in this window matches what is shown in the screenshot.
The function shown in the plotting window is called the frequency response function of the filter. It tells you the gain that will be applied to each frequency. The gain is just a multiplicative value: A value of 1 means that the amplitude of that frequency will be multiplied by 1 (i.e., unchanged). A value of 0.75 means that the frequency will be multiplied by 0.75, which means that it will be attenuated by 25%. The half-amplitude cutoff of 30 Hz that we specified means that the gain of the filter is 0.5 at 30 Hz; this is the point at which the gain is reduced by half (which is why it’s called the half-amplitude frequency).
The filter we’ve specified has a fairly gentle roll-off of 12 dB/octave. As a result, even though it’s nominally a 30 Hz filter, the gain is still well above zero at 60 Hz, and there is some significant attenuation as low as 10 Hz. Change the roll-off to 48 dB/octave, and you’ll see a frequency response function that appears to be better. The gain is now near 1 for everything below about 20 Hz, and it’s near zero for everything above about 45 Hz. However, as we’ll see later in this chapter, this sharper frequency response function means that the filter produces more distortion in the time domain.
Set the roll-off back to 12 dB/octave, click APPLY , and then name the new ERPset waveforms_30Hz_12dB . Now plot the filtered waveforms. You’ll see that the 60 Hz oscillation is now mostly (but not completely) eliminated from Channel 2. The fact that it’s not completely eliminated makes sense given that the gain at 60 Hz for this filter is around .1 (as shown in the frequency response function), so about 10% of the 60 Hz noise remains after filtering. Channel 3 is now a little smoother, but it still has quite a bit of noise. This makes sense given the amplitude spectrum that we looked at in the previous exercise (Screenshot 4.2.C), in which there was substantial noise at frequencies below 30 Hz.
Now let’s try a more severe filter. Make the original unfiltered ERPset active (by selecting it in the ERPsets menu) and filter it just as before, except set the low-pass cutoff to 10 Hz and set the roll-off to 48 dB/octave. Click APPLY and then name the new ERPset waveforms_10Hz_48dB . If you plot the filtered waveforms, you’ll see that the 60 Hz line noise is almost completely gone from Channel 2 and that the noise in Channel 3 has been significantly reduced (but with some lower-frequency fluctuations in amplitude still visible).
To precisely compare two waveforms, it really helps to overlay them on the same plot. Unfortunately, ERPLAB’s Plot ERP waveforms tool is designed to overlay different bins from a single ERPset and can’t overlay waveforms from different ERPsets. However, there is a trick for solving this problem: We can append multiple ERPsets together into a single ERPset, with different bins for the data from each original ERPset. Let’s append the ERPsets from the original data, the data filtered at 30 Hz, and the data filtered at 10 Hz.
Select EEGLAB > ERPLAB > ERP Operations > Append ERPsets . In the window that pops up, select From ERPsets Menu and put 1 2 3 into the corresponding text box to indicate that you want to append the first three ERPsets. (This assumes that you just have the three relevant ERPsets loaded in the ERPsets menu; change the numbers as needed if you have other ERPsets loaded). Check the Use erpnames box so that it names each bin in the appended file with the names of the ERPsets that are being appended together. See Screenshot 4.4 (you’ll need to select the Include prefixes button before your window will look like the screenshot).
Click RUN and then name the new ERPset appended_waveforms . Now plot the new ERPset, making sure that all three bins are being plotted. You’ll see that the original waveforms are plotted as Bin 1, the waveforms filtered at 30 Hz are plotted as Bin 2, and the waveforms filtered at 10 Hz are plotted as Bin 3. These waveforms are highly overlapping, so you’ll need to zoom in to see how they differ. To do this, single-click on any of the waveforms or the channel label for Channel 2 ( waveform+60Hz ) and a new window will pop up that shows just this channel. Matlab is a little fussy about this feature, so you may need to click a few times to get the click to register (but don’t double-click—you’ll end up with two identical windows). You should see something like Screenshot 4.5.
You’ll see that the three waveforms are pretty similar except that the 60-Hz oscillations are clearly present in the original waveform, mostly but not completely attenuated by the 30-Hz filter, and completely eliminated by the 10-Hz filter. If you look closely, you’ll also see that the first two peaks in the waveform (analogous to the P1 and N1 waves) are reduced in amplitude by the 10-Hz filter. This makes sense, because these peaks contain substantial power near 10 Hz, which is now being attenuated.
It’s easier to see how the filter is impacting the ERP waveform by looking at the original waveform, without any noise. Go back to the plot with all three channels and click on Channel 1 ( waveform ) to zoom in. You should see something like Screenshot 4.6. The first two peaks are slightly attenuated by the 30-Hz filter and more clearly attenuated by the 10-Hz filter. You can also see that the 10-Hz filter produces a little overshoot in the third peak (which is like a P2 wave) and makes the first peak onset earlier.
The 10-Hz filter also produces a small artificial negative peak just after time zero and before the first positive peak. This is not because the filter is at 10 Hz; it’s because we used a very steep roll-off (48 dB/octave). You can verify this for yourself by going back to the original unfiltered data and filtering it with a 10 Hz cutoff but a slope of 12 dB/octave. You’ll see that the artificial negative peak is no longer present.
Now you can see why a steep frequency response function—which seems ideal when you’re focused on frequency information—is not usually a good idea for ERP research. A steep roll-off can really distort the waveform, producing artificial peaks. And this can lead to wildly incorrect conclusions. For example, Darren Tanner, Kara Morgan-Short, and I wrote a paper several years ago (Tanner et al., 2015) showing that inappropriate filtering can make a P600 effect (which is usually a result of a syntactic violation in a language experiment) look like an N400 (which is usually a result of a semantic anomaly). If you learn only one thing from this chapter, I hope it’s that you should use only very mild filters unless you really know what you’re doing (e.g., you fully understand all the equations in Chapter 12 of Luck, 2014). I provide some specific recommendations near the end of the chapter that will allow you to avoid drawing bogus conclusions as a result of inappropriate filtering.