The Neurophysiological Biomarker Toolbox (NBT)

## How to remove artifacts in EEG signals

The process of data cleaning consists of the following steps:

1. Remove bad channels ( i.e. channels with poor contact to the scalp)
2. Remove noisy intervals
3. Save Cleaned Signal
4. Compare the outcomes of your cleaning process with the demoset Cleaned files.

The noisy intervals and channels are stored in the corresponding Info file. In subsequent analysis, you can omit these artifacts. Once the artifacts are determined, they will be removed in subsequent analysis before the calculation of already implemented biomarkers.

1. From NBT gui
2. open EEGlab: EEGlab|Start EEGlab
2. First you need to filter your signal. Go to Tools|Filter the data|Short IIR filter in the EEGlab window. Write 1 in the highpass field and 45 in the lowpass field, and click Ok. When asked check the checkbox “Overwrite signal in memory”, and click Ok.

It is possible that your filter settings cannot be used to create an adequate filter (i.e., Matlab will return warnings and your signal will be lost in the process). To avoid this, you can use an improved, albeit slower, version of the basic FIR filter. To do so go to Tools|Filter the data| Basic FIR filter (new) in the EEGlab window and supply the desired filter settings (see figure below).

1. In the command window NBT will ask you “Do you want to use Joint probability, Kurtosis, Faster toolbox, Correlation method, PCA method, or abnormal Spectra? (Write J, K, F, C, P or S)”.
2. Write F, and press Enter (NBT will then classify bad channels using methods we will not discuss here, see )
3. NBT then plots the bad channels. You should check that you agree with the algorithm! Bad channels will often stand out very clearly with huge jumps and much 50 Hz noise.
4. If you agree; type N, and press enter to the question “Do you want to change this list?”, which appears in the command window. If you do not agree, type Y and you will get the opportunity to change the list of bad channels and press enter.
5. Close the two windows. The list of bad channels will be saved automatically.

The following figure shows the bad channels detection on the loaded signal. The bad channels are presented in the EEG topography as red spots and in the plot of the signals as red tracks. Scrolling through the plot using the arrows can help to visualize if the detected channels are indeed bad or if they can provide acceptable signals. The automatic detection identified as bad channels 68, 70 and 126. Visualizing the whole signal by scrolling, it seems that these channels are not excessively corrupted. In this case:

• you can type Y to the question “Do you want to change this list?”
• a successively edit [], standing for empty vector, no channel is selected as bad

When you high pass filter before having cleaned your data, you smear out your artifacts in time (elongating them). It's recommended then to apply substantial high-pass filter (low cut off freq >0.05-0.1 Hz) for visualization purposes only. Typical settings for displaying: the high-pass filter and a low-pass filter are 0.5-1 Hz and 35–70 Hz, respectively. The high-pass filter typically filters out slow artifacts, such as electrogalvanic signals and movement artifacts, whereas the low-pass filter filters out high-frequency artifacts, such as electromyographic signals.

Good practice to detect bad channels and noisy intervals: Together with the automatic selection of the bad channels we invite you to scroll with attention through all the signals using the plotting tools previously introduced. Although this procedure is tedious and requires time, it is crucial for the analysis of your data.

### 2. Remove Noisy Intervals

Noisy intervals mostly appear as huge jumps in the EEG signals, most often they are produced by electrodes moving. These transient artifact usually affect more than one channel. A transient artifact is characterized by a very sharp change in voltage. You should be careful not to remove eye artifacts which are more slow in their voltage change (see figure below). Also do not remove transient artifacts which do only appear in the bad channels.

If you are already in EEGlab and you have already opened the figure with the plot of the Signals and the bad channels in red you can skip the steps 1 and 2.1 presented hereafter:

1. From NBT gui
2. open EEGlab: EEGlab|Start EEGlab
2. Plot the signal:
1. Plot|Channel data(scroll)
2. Transient artifacts are best identified by scrolling through the data while viewing all of the channels (e.g., 129).
1. Click in the beginning of the artifact, and drag the mouse until the end.
2. Scroll to the next transient artifact, and repeat point 2.2.1.
3. When you are done, click Reject (see video below)
4. When asked “What do you want to do with the new dataset”, click “Overwrite in memory”, click Ok.

You can avoid to include in the transient artifacts eye-blinking artifacts. As you can see in this figure, eye-blink appears in the form of slower perturbation of the signal. Eye-blink artifacts can be removed applying Independent Component Analysis.

### 3. Save Cleaned Signal

In order to save the results of the cleaning procedure, from the EEGlab window go to NBT|File|Save as NBT Signal

1. answer Y to the question “Do you want to save this signal?” appearing in the command window
2. type CleanSignal to the question “Name of NBT Signal? (should contain the word Signal)”
3. select a folder where to save your data. You can select the same folder where the original dataset is stored. In the latter case the original data and clean signals will be kept in the same file name and when you will try to load again the file NBT.S0006.081215.ECR1.mat, a window will appear asking if you want to load the original signal or the cleaned signal.

It is also possible to remove bad channels and transient artifacts directly in the NBT gui. The major difference compared to cleaning with EEGlab is that NBT allows you to store the time intervals that contain the artifacts, whereas EEGlab removes the intervals and consequently obliges you to lose the original data or to save the cleaned data as a new dataset that doubles the memory space you need.

1. From NBT gui
2. go to Pre-processing|Remove artifacts current NBT Signal, a window will appear to set plotting parameters.
1. To select bad channels you can click on the single channel and add it as bad channel;
2. To select bad intervals click on the button “click here to select noisy interval”, with double click on the plot you can select bad intervals. Scroll the plot to analyze the whole track, setting plot parameters can help to better visualize the data.
3. Once you're finished click on “click here to finish” and it will ask you to save your data as in 3. Save Cleaned Signal. But be sure you do not rename the Signal you were working on: the artifact information is stored in the Info file, you do not need to create a new “cleaned” Signal.

If you want to repeat the operation, automatically loading other signals, go to Pre-processing|Remove artifacts multiple NBT Signals.

### 4. Compare the outcomes of your cleaning process with the demoset Cleaned files

Artifacts rejection and bad channels rejection is not a trivial task. It often requires experience with neurophysiological signals and also among experts there can be variability in the cleaning process. If this is your first experience with EEG signals you might want to check that you did a good job with your data cleaning.

For this reason we provided a cleaned version of the data set, downloadable from here (1 GB), that you can use as reference.

Follow these instructions for comparing the outcome of your cleaning with the provided cleaned data:


%1. load the provide clean data info file
CleanDatadirectory = '/Users/Giusi/Documents/NBT/database/SORT_DEMOSET'; % path of the directory where the clean data are
filename = 'NBT.S0006.081215.EOR1_info.mat';% name of the infofile you want to inspect
% note that the struct variable CLEANSignalInfo will appear in your workspace
%2. Inspect bad channels and removed intervals (epochs)
CLEANSignalInfo.notes

ans =

orig_ref: 129
fid: 'NBT_S0006_081215_EOR1_'
remepochs: [55 97]
intchans: [ 14  17 21 25 128 ]


The field remepochs indicates which intervals have been removed. Consider that the cleaned demoset has been epoched with 2 seconds epochs, which means that, for example, the epoch 55 corresponds to the interval [108,110] seconds ( = [55*2-2, 55*2]) in the original raw signal track. You can compare the indicated intervals with the ones that you removed.

The field intchans contains the removed channels. Also in this case you can check if the channels you removed are the same.

The correspondence of your cleaned data with the ones provided doesn't have to be strict. But it is fundamental to check whether the cleaning procedure affects the biomarkers computation and the final statistics on the data; you will learn more about this in the section Compute Statistics

To learn more about semi-automatic methods for neurophysiological data cleaning visit the page Automatic and Semi-Automatic methods for EEG pre-processing

Next step: Compute Independent Component Analysis

Go back to the Tutorials