Hello, my name is Arnaud Delorme
and I'm the main software architect of the EEGLAB software
for processing EEG data.
This is part 4 of the EEG pre-processing series on filtering data.
How do we filter data?
So we've imported the data, imported events and channels
re-referenced the data and down-sampled it
and now we're at this stage, to high-pass filter the data.
When you import data, the first thing you want to do is to look at your data.
So that would be menu "Plot -> Channel data (scroll)"
and sometimes it would look like this.
So you would have all the channel labels here on the left
but then you only have a couple of traces, and sometimes there is even a blank screen.
What happens is that all the channels are offset.
So you need to remove that offset.
You need to remove that DC shift.
So if you're in this interface, you can just go [to] "Display -> Remove DC offset"
and if you click that, then all the channels will now show.
If you're in the main interface, you also want to remove that offset before you apply any filtering
because if you don't, it's going to create artifacts at the beginning and end of the signal.
So, going back to the main interface: "Tools -> Remove baseline."
So it's the same thing that we did in the visualizer.
"Remove baseline -> Remove the mean of each channel?" We can press OK
And as before, we can overwrite the parent if we want to.
Accept the changes.
Now we're ready to filter the data.
The main reason to high-pass filter the data is to remove slow, possibly large amplitude drift.
So to filter the data, you would go to "Tools -> Filter data."
There [are] different filters here, I'm just going to show you the basic one.
There [are] actually lots of EEGLAB extensions which have to do with filtering.
This is just one example of a linear filter.
So when you call this menu, this interface pops up
and this is where you define the high-pass limit
(the lower edge of the frequency pass band).
So here we can say we want to remove everything that's below 0.5 Hz.
And again, the type of limit you would enter here depends on the type of data we're processing.
Since we are going to use independent component analysis (ICA) to remove artifacts
ICA is very sensitive to lower frequency shift.
So we need to set that number relatively high at 0.5 Hz to apply this algorithm.
However, if you want to process event related potential, this might be too high.
You still might want to high-pass [filter] the data, but maybe at 0.1 Hz.
If you want to do both event related potential and apply ICA
in that case, you can apply ICA on a version of data that's filtered
and then apply the ICA solution on a version that's that's not filtered.
We'll talk about that when we talk about ICA.
Let's say, for instance, we just want to high-pass today at 0.5 Hz.
Now there is also this option to select channel types or indices.
If you have channels like respiration, muscle contraction, or heart, you might not want to filter these channels.
So that's an option, you can select which channel you want to filter.
You can also check this box "Plot frequency response."
When you press OK, it asks if you want to overwrite the current dataset.
So if you check that check box "Plot filter response"
this is the filter response for high-pass filter at 0.5 Hz.
Because of the scaling, we don't really see the frequency response at very low frequency at 0.5 Hz
but we see the phase response that's linear.
And then here is another filter.
This is now low-pass at 50 Hz (so filtering everything above 50 Hz).
Then you can see the frequency response, the magnitude, and the phase shift.
The phase shift you don't have to worry about.
Even though it's a linear filter, and it does introduce a phase shift
the filters in EEGLAB are applied in both directions, first forward and then backward.
So this cancels any phase shift, whether the filter is linear or nonlinear.
So there's no phase shift for analysis in EEGLAB
but there would be phase shift if you were processing data in real time and filtering data as it's coming [in].
So that needs to be considered.
There [are] other options [as well].
There's this plugin that's called clean line
so if you go to "Manage plugins -> Manage data processing plugins"
and clean line is a plugin (EEGLAB extension) that uses an approach for line noise removal
advocated by Padha Mitra and Hemant Bokil.
This plugin works by trying to find the sinusoid which corresponds to line noise, and then subtracting that sinusoid.
And there's a lot of data processing behind that.
So if you install that plugin, now you go to your "Tools" menu
and at the bottom of the menu, you have "CleanLine."
It has a lot of questions, like what type of line noise do you want to remove?
If you're in the U.S., you would select 60 Hz and 128 Hz, which is the harmonics.
This is your size of your window.
So CleanLine tries to find a sinusoid that's stable in a four-second window
and then it slides the window a little bit, and applies a method to interpret the sinusoid between the different windows.
So for instance, if your signal is very unstable, you might want to select shorter windows.
And two seconds is the step between windows.
You can check this checkbox if you want to visualize the power spectrum before and after.
So here I'm just going to give you an example.
If you want to see the spectrum of individual channels
you would go to "Plot -> Channel properties."
And we're going to see what the signal looks like before, with a standard filter, and with CleanLine filtering.
So "Plot -> Channel properties"
we would select one channel (ex: channel 31)
and the frequency range has to include the frequency where there is line noise, so we need to be above 60 Hz.
So this is 0.5 Hz high-pass filter, so we just filter at very low frequency, and we can see clearly the 60 Hz.
That's the location of the channel, and that's the way of representing the continuous data.
We talk about this interface in another presentation.
So here, we clearly see line noise is present, it's very sharp.
If we do a 50 Hz (linear) low-pass filter
we see that 60 Hz is attenuated, but it's not completely removed.
Now, if we use CleanLine, you can see that the spectrum is not affected except at 60 Hz, where the line noise is removed.
So it's very efficient to remove line noise.
It doesn't work all the time.
It really depends on the type of noise you have, so you need to try it on your data.
When it works is it's spectacular. but sometimes it doesn't work.
So I'm going to illustrate briefly how to do that in EEGLAB.
So first I start EEGLAB.
And again, we load this dataset in the sample_data folder.
Let's call eeeglab_data.set. That's a data set that has been saved in EEGLAB just after being imported, so it's been processed.
I've imported the dataset, so the first step is to remove the baseline.
Remove mean from each data channel? That's not really necessary in this data set because I think it has been done already
but I'm just doing it here for the sake of illustration.
And then, filter the data.
So the basic filtering, and we can set [the lower stage of the frequency pass band] at 0.5 Hz.
There are no channels here we want to exclude, these are all EEG channels.
We still want to plot the frequency response.
It's plotting the frequency response and asking me what I want to do with the new dataset.
I'm just gonna overwrite it.
I'm just gonna zoom in on the low frequency here so we can see.
This is the response of the filter at low frequency.
In the next video we'll talk about how to examine your data.