-
Notifications
You must be signed in to change notification settings - Fork 4
Bb_downs_filter_chaninfo_exclchan
This script starts by loading the previously created .set file, so you need to set the home_path to where you saved the data and the new data will also be saved there. The first thing the script does is down-sample to 256 Hz. We collect data at 512Hz, and there is no real reason to keep it at this high resolution, but it does take up more space and slows down the process when analyzing.
The second step is a 1Hz high-pass filter. To change this you need to also decide on the filter order. See this for more info
Same counts for the third step, which is a 45Hz high-pass filter. For more detailed info on filters see the "More info on filtering" chapter.
To optimize the ICA solutions, these are the suggested filters. However, if you want to look at components that show up later in the data, 1Hz might be too high. See this paper for more info on filters.
The fourth step is adding information to the channels. This is why you
need to define the path to EEGlab or to the 'biosemi160' file. It will
look for a file to import the channel information. The difference
between the two paths has to do with that for 64channels we use a 10-20
layout for the BIOsemi caps, however for the 160channel caps we have a
spherical layout. The first file is part of EEGlab, but this is not the
case for the 160channel cap. 64channels is defined as 64 to 95, because
a full extra ribbon would be 96 channels. In or lab we normally go up to
8 channels, but we have data that has more. This takes that in
consideration. small update 2/14/2022 We were always using the
standard-10-5-cap385.elp
file. However we work with caps that have the
10-20 system. Because of this we are now using the standard_1020.ELC
file. This is only the case for 64 channel data. When using 160channel
data, we need to rely on the biosemi file, because 160 channel data has
a spherical configuration and does not follow the 10-20 system.
5/31/2021 update Lastly, in step 5, it will reject channels based
on a kurtosis threshold. It is set to 5, which is the standard. Channels
with a kurtosis > 5 will be deleted. We are using the
pop_clean_rawdata
function instead of the previously used
pop_rejchan
. This new functions allows for more cleaning. Currently we
are only use the parts of the function that focus on channel deletion.
We delete a channel if
- It's more than 5 seconds flat
- there is high frequency noise than is bigger 4 standard deviantionsof the rest of the signal
- if there is a minimal acceptable correlation with the nearby channels of 0.8
-
If you set
clean_data ={'y'}
data gets segmented in 0.5 second blocks and if the noise exceeds a set threshold these blocks are deleted.- This threshold is currently set to 5 standard deviations, but this will need to be adjusted depending on how clean the data is.
- It's worth it to note that when we epoch the data, we reject noisy epochs, so this also takes care of noisy moments.
- The threshold for when to delete data is found in the line that
calls
pop_clean_rawdata
. More specifically after 'burstCriterion'.
All of these settings are the standard settings and result in clean data, without losing excessive amount of channels.
important for now Even though for now we cannot exclude externals from the cleaning process, and thus we need to delete them beforehand. The EEGLAB people have said that they are working on a fix base on my request. Currently (when manually updating the function) there are still errors when excluding externals from this cleaning, but hopefully quick this will be solved. So if you need to use externals, use the old cleaning functions, this one is still in the code.
These are the variables you NEED to change:
subject_list = {'some sort of ID' 'a different id for a different particpant'};
eeglab_location = 'C:\Users\wherever\eeglab2021.1\'; %needed if using a 10-5-cap
scripts_location = 'C:\\Scripts\'; %needed if using 160channel data
home_path = 'the main folder where you store your data';
These you can change if you want to change settings
downsample_to=256; % what is the sample rate you want to downsample to
lowpass_filter_hz=45; %45hz filter
highpass_filter_hz=1; %1hz filter
10/14/2022 update ### plotting_bridged_channels We added this function,
which uses eBridge
. This is a function that uses the EEG structure and
checks if there are channels that are bridged. The full explanation can
be found
here.
Or in this
paper
that was written and resulted in the function. bridge=eBridge(EEG)
gives us a structure in which bridge.Bridged.Labels
gives us the
labels of all the bridged channels. Later we use this to plot a figure
of the location of bridged channels. note that bridged channels are
not deleted. In the plotting_bridged_channels
function we use
eBridge
and plot the locations of the bridged channels.
You do not need to follow the filtering in this script. EEGlab makes it relatively easy to created/use new filters.
3/1/2022 update, we won't need to add filter order anymore. It is very important to know the filter order (which is the width of the sliding window in data points or see this EEGLAB information about this)
Before this EEGLAB update to their filter function, you would have to set the filter order yourself. While still suggested in when opening the GUI, you do not need to do this. If you do not set it yourself EEGLAB will calculate it for you and you can find it in the output text in the command window. as seen in figure3.
figure 1.
figure 2. hit "ok"
figure 3.
This shows up in Matlab. Replace the filter number with the number 1.
followed by the number "preforming
EEG = pop_eegfiltnew(EEG, 'locutoff',1);
EEG = pop_eegfiltnew(EEG, 'hicutoff',45);
However, but this in the script itselve, you can simply replace the number for
lowpass_filter_hz=45; %45hz filter
highpass_filter_hz=1; %1hz filter
Choosing what filters to use will have a big impact on your data. There are a couple things to consider because filters will have impact in several different ways on your data.
ICA The EEGlab people suggest using a 1Hz and 45Hz filter to get the best ICA solutions. But if one only uses the ICA for removing eye blinks and eye movement it might be worth it to think this through.
We usually use a low-pass filter to get rid of high frequency noise that
cannot be caused by the brain. By using a 45Hz filter this can be
solved.Unless you are interested in specific frequencies that go above
40Hz it's normally safe to use it. This is what the filter will do to
[data:\\{.uri}](%5Bdata:%5D(data:)%7B.uri%7D){.uri}
The black line is down-sampled like the Red line + a 45Hz filter is ran
on it. If you look at the zoomed in parts it is clear the this smooths
out the ERP.
A high-pass filter is used to stop Baseline drift. This drift is
stronger for kids and some patient populations (0.1Hz) then for Adult
subjects
(0.01Hz).
One other thing it helps with is solving artifacts created by sweat.
When looking at early components, one can usually use a 1Hz filter. This
filter might however cause issues if you look at later components
(starting at P2 and onward). This is what a 1 Hz filter does
It's interesting to point out that the impact of the filter is more
strongly seen the later you look at the ERP. Since we are interested in
the P1 (90-130ms) which is early, we can use this filter. The impact is
not big enough to say that it distorts the data.
In the first figure, we were interested in the first component, whereas
in the second figure we were interested in the error-related positivity
(Pe), that is around 200-400ms. Here the filter causes a pretty big
difference. For us to use these data, we need to use a lower high-pass
filter.
It is very important that you know what the impact of your filter can
be. One of the things to think of is what frequency you expect in the
ERP. If it's in the higher Range you could go for a 0.5Hz or maybe a 1Hz
filter (1Hz might be too much according to some).
As you can see here, the filters seem to have more or less the same
impact, since we are looking at the early components.
However here we want to look at later components and we are looking at a
ERP based on a False alarm which should be a lower frequency response.
Here the 1Hz filter has way too much effect and distorts the data.
In the following 2 plots we ran the same 1Hz filter on the data, but we changed the filter order. The standard filter order suggested by EEGlab for a 1Hz filter is 1690 (this order is different for different filters; a 0.1Hz filter has a suggested order of 16895). We chose 846 as filter order because this is the smallest filter order that can be chosen for this filter. If you would choose a different filter the minimum is different. There is no max filter order, but when we tested 100000000 as an order, after 2 days EEGlab hadn't completed 5%.
This is the combination of a 1Hz and a 45Hz filter
Back to the home page
Back to the Ba_cleaning_optional page
To the C_manual_check page