Hello, my name is Arnaud Delorme
and I'm the main software architect of the EEGLAB software.
This is part three of EEG processing where we're going to talk about re-referencing and down sampling the data.
So we've already imported data, imported events and channel locations
and now it's time to re-reference and down sample the data.
You can invert some of these steps. I usually re-reference after almost every step.
High-pass filtering, I re-reference. Removing channels, I re-reference.
So the order is not critical.
So, how do you re-reference the data?
[Here] we have the menu "Tools -> Re-reference"
and when you select this menu, you have this interface where you can select the channel you want to reference to.
Here we have "Re-reference data to channel(s)"
so you would check that checkbox, then select specific channels.
For instance, we might want to reference to right mastoid and left mastoid (called "linked mastoids"),
so if that's the case, we would select the two mastoid channels
(here) and press OK.
So when we press OK, we would get an interface that tells us this is a new dataset, what do you want to do with this new dataset?
And we can overwrite the parent dataset (when you don't have much memory, that's a good option).
At this time it's also a good idea to save the dataset.
And when we do that, we have a second data set.
So if we didn't select "Overwrite in memory," we'll have two datasets.
And the datasets can be selected in this menu "Dataset."
So the first dataset is the dataset before referencing, [and] the second dataset is the dataset after referencing.
And we can see here, the reference is unknown. After referencing, the reference is right mastoid and left mastoid.
You can select the dataset here in the "Dataset" menu, so you can switch between datasets.
Another type of reference is called average reference.
So let's go back to this menu "Tools -> Re-reference"
and now we can select "Compute average reference."
When we compute average reference, we might decide to exclude some channels, like EMG muscle or ocular channels,
because ocular channels often have a different reference (they're referenced with respect to each other).
So we can exclude these channels from the average reference computation by entering them in this check box.
So what's the underlying assumption in average reference?
In average reference, the assumption is that the sum of current over all the scalp is 0.
So that means that if we were to sum the channels over the whole scalp, the sum should be 0.
That would mean, for instance, that we should have channels in the neck ideally so we can have a whole enclosed area, and then we're sure that the sum of current is 0.
But even if we don't have the neck, the neck is actually a good insulator
so a lot of the current would flow to this side.
So if we have a good coverage of the head the average reference assumption is a good assumption.
In theory, positive and negative currents across the entire head should balance (no net current source or sink). Average reference enforces this.
In practice, it depends on electrode distribution.
For instance, if you have more density of electrodes on some parts of the scalp, the average reference might not be totally true.
The math behind the average reference is relatively simple.
When you collect your data, in most amplifiers you don't get just the potential at one electrode, you get the differential potential between one electrode and the reference.
For instance, it can be one mastoid here, TP10.
So at FPZ, for instance you get (FPZ - TP10), at FP1 you get (FP1 - TP10), etc.
So that's what comes out of the amplifier.
The average reference assumption is: the sum of all the channel potentials is 0.
So how do we convert this system to your average reference system?
The first step is to recalculate the activity at reference TP10.
And to do that, first we'll consider the sum of all electrode activity (SE).
So if we take the sum of activity of all the electrodes, that will be (FPZ - TP10) + (FP1 - TP10) plus (AF3 - TP10) + (F8 - TP10) ...
So eventually it's all the electrodes minus 64*TP10.
And if we add one more TP10, and we subtract one more TP10, this is the average reference assumption.
So we set this equal to 0 (under the average reference assumption, the sum of all the electrodes is zero).
So now we can easily calculate TP10.
TP10 = -SE/(#channels+1).
Now that we have TP10 for calculating the potential of each channel, we can just simply add TP10 back to the activity of every single channel
and now we have the activity of all the channels in the average reference.
When we go back to this menu, there [are] a couple of other options.
First, there's "Interpolate removed channels."
So if you remove bad channels, for instance, we might want to interpolate them to have better coverage of the scalp, so the average reference assumption is truer.
There's also this option to "Add current reference channel back to the data."
So [as] you saw in the previous screen, we're calculating TP10.
Before calculating average reference, this channel is 0.
It's TP10 referenced to TP10, so TP10 - TP10 = 0.
But after calculating average reference, we can recover the activity of this channel.
It's equal to -SE/65.
So that's what's written here, where you can add the current [reference] channel back to the data.
In general, you should do that when your reference is a scalp channel.
If it's not a scalp channel, you don't want to do that.
For instance, if your reference is the linked ears, or if it's the nose, you don't want to consider this channel when you compute average reference.
And the equations are almost the same.
In one case, we sum all the channels, including the reference, and in the other case we sum all the channels, and we don't include the reference.
The only difference is that in this equation you don't have to add TP10 back.
The next step is to resample the data, if desired.
The main reasons to resample the data [are] to reduce space on disk and time.
For instance, your amplifier might collect data at 2 kHz
and you don't need that type of time resolution when you do your processing, so you might want to decrease the sampling rates.
You would go to "Tools -> Change sampling rate"
and now you can select the new sampling rate, for instance 256 [Hz].
Also, what's important to know (and we'll see that in the next lecture about filtering the data), when you apply and when you change the sampling rate
EEGLAB will automatically filter your data at half the sampling rate.
So if you resample the data at 256 [Hz], it's going to low-pass the data at 128 Hz.
I'm going to illustrate this in EEGLAB.
Again, I'm going to load this dataset in the sample_data folder of EEGLAB.
And I'm going to select this one (eeglab_data.set), which was saved just after importing.
First, I'm going to compute average reference.
So I select the menu "Tools -> Re-reference -> Compute average reference."
The original reference for this dataset was the right mastoid (TP10)
but the left mastoid was not recorded, so we don't want to add it back to the data
otherwise, it would be imbalanced between both sides.
So we're just going to compute average reference, and not add the current reference back to the data.
This is the time where you could save your data as a file.
I'm just going to overwrite it in memory and then I'm going to resample the data
so that's "Tools -> Change sampling rates."
I already have 128 Hz here, which is relatively low.
The reason [for this] is we don't want this dataset to be too large when people download it.
I wouldn't want, in practice, to then down sample to a lower sampling rate
but just for the sake of illustration here, I'm going to resample to 64 Hz.
And again, this is going to apply a low-pass filter below 32 Hz before changing the sampling rate.
And again, [it will ask] what I want to do with the dataset, so I can just overwrite it.
In the next presentation, we will see how to filter data.