In this section, two brief analysis tutorials will be given to
illustrate the EMEGS processing facilities. A 70-sensor
EEG data file, acquired with a simple passive viewing paradigm
including 44 trials in each of three experimental
conditions (3 different neutral faces), presented in random order,
willl be analyzed. The
processed data is included in an EMEGS download so readers can follow
along using the same
data set.
In a first part, standard ERP preprocessing steps, including
segmentation, filtering, correction of eye movements, artifact
detection, event-related averaging and basic data display are
described. In the second part, using the result files from the ERP
analysis (that is, the clean single trial data epochs), the Fieldtrip
plug-in is used to perform a time-frequency analysis.
Please note that the figures referenced can be found in the article:
Peyk, P., De Cesarei, A., & Junghöfer, M. (2011). Electro
Magneto Encephalograhy Software: overview and integration with other
EEG/MEG toolboxes. Computational Intelligence and Neuroscience,
Volume 2011, Article ID 861705.
ERP analysis tutorial
Preprocessing
Download emegs2.5 from the EMEGS website (http://www.emegs.org).
Extract the zip-file and add emegs2.5 and all its subfolders to the
MATLAB path. Extract the 7-zip compressed demo data file in the emegs
testdata folder
(.../emegs2.5/emegs2dTestData/eeg/BinData/Biosemi/EEGTutorialData.7z)
to get the “EEGTutorialData.bdf”-file. Then, type “emegs” in the MATLAB
command window and press “enter” to open the EMEGS start dialog (called
“EMEGS launchpad”, figure 2a). Make sure to activate the “expert”-mode2
on the bottom of the launchpad (figuree 2a-1), then start the
“Preprocessing” tool (figure 2a-2). A yellow interface will open
(figure 2b), push the “open data file” button at the very top (figure
2b-1) and select the demo datafile. The file dialog will reappear
allowing you to select a series of files for batch processing. As in
the present case, we have only 1 data file, push “Cancel” to stop the
file selection. EMEGS reads the data file header and displays number of
channels, data format and recognized predefined sensor configurations
(“Biosemi69” for the present example). As EMEGS has no way of
automatically determining which channels in a BDF file are EEG channels
and which may be irrelevant for ERP analysis (such as ECG- or
EDA-channels), EMEGS will look for a text file listing the relevant
channels. If this file is not found, as is always the case in a freshly
downloaded EMEGS copy, EMEGS displays a corresponding message and lets
you select a predefined channel definition file. Push the “Select
predefined”-button on this dialog and then select the
“DefaultBdfEegChannelsTutorial.txt” file in the folder where the dialog
will start. Next, EMEGS will look for sensor configurations to match
the EEG channels found in the data file. Again, the configurations are
managed by a text file, which in a fresh install is missing too.
Another message comes up to inform you about this. Push the
“Create”-button on this dialog, to have EMEGS create a default version
of this file, which will work for the present data file. Next, enable a
high-pass filter (figure 2b-2) which will bring up the filter transfer
function dialog to configure the filter (note that the stop band of the
filter is displayed in the figure). The default setting is a 0.1Hz
highpass filter, which is fine for this example, so just push “Apply”
on this dialog figure 2b-3) to set this filter and close the dialog
window. The transfer function graph now appears also on the
preprocessing window. You can use the “configure”-button below this
graph to reconfigure the filter later on. Do not set a lowpass filter,
as we will do a wavelet analysis later on and therefore wish to keep
high frequencies. Activate the eye blink and eye movement correction
button (figure 2b-4), activate the checkbox on the bottom of the
preprocessing interface reading “eyecorr with biosig” (not shown) and
enter the size of the data epochs to be extracted: set the number of
points to be extracted before each trigger to 125 (corresponding around
500ms, figure 2b-5, “PreTrig”) and the number of points to be extracted
after each trigger to 150 (corresponding around 600ms, figure
2b-5, “PostTrig”). Push the “Run”-button on the bottom of the
preprocessing window (not shown) to start the analysis. EMEGS will
print a few status messages in the command window, read trigger
information from the data file and display a trial timing graph (time
course of triggers, distance of triggers). After this, channels
need to be rereferenced to Cz3 and again EMEGS does not know, which
channel in the data file really is the Cz channel. Therefore, you are
prompted to enter the name of the Cz sensor during the first analysis
(this information is written to file and remembered in the future). For
now, just confirm the label “Cz” on the input dialog using the
“OK”-button and finally EMEGS will start the preprocessing. It will
write a log file in the folder where the data file resides (called
“PrePro.log”) and display this log file when the analysis is finished.
EMEGS creates a set of files which are described in detail in the EMEGS
help files. Most important is the so-called “session file” which
contains the extracted data epochs (“EEGTutorialData.f.ses” for the
present example).
Artifact detection
Continue with the artifact detection by pushing the “Edit processed
files”-button on the very bottom of the preprocessing window (not
shown). The preprocessing window will close and the artifact detection
window will come up, remembering the processed files. To start the
artifact detection just push the “Abs MaxStd”-button (figure 2c-1),
which has EMEGS perform statistical control of artifacts based on the
maximum absolute amplitude (“Abs”) and the standard deviation excluding
outliers on the maximum side of the trial distribution (“MaxStd”;
exclusion on the minimum side is possible too - for instance to exclude
flat channels - but hardly ever needed in modern amplifier systems).
The program asks you to confirm that you wish to process the files
previously preprocessed (choose “Yes”) and will then display histograms
of the Abs and MaxStd parameters for each channel figure 2c). Narrow
unimodal distributions in nearly all cases indicate good data quality,
whereas multimodal and broad distributions nearly always indicate a
substantial amount of artifacts in the data. EMEGS automatically sets
an individual threshold separating good from bad trials for each
channel (red vertical lines), automatically sorts out globally
contaminated sensors (figure 2c-2, sensor PO4), but prompts you to set
the trial threshold separating good from bad trials manually (figure
2d) by dragging the dotted red line (figure 2d-1) from left to right to
the proper position. Each column of the gray background graph codes the
four possible statistical parameter values (Abs, Std, Gradient and
Flat, arranged as rows) for all channels of one trial and trials are
sorted by data quality with the best trials on the far left and the
worst trials on the far right. The dotted red line you need to adjust
marks the threshold between good and bad trials. For the present data
file, data quality is very good, so a far right position indicating
mostly good trials and very few bad trials is appropriate. To check the
data of a specific trial, right click and select “show trial” from the
context menu (figure 2d-2). The data display program comes up and shows
the current trial, highlighting good channels in green and bad channels
in red. Note that PO4 is correctly highlighted in red (figure 2d-3),
but the data quality of all sensors taken together is quite good,
justifying it’s center position in the quality sorted display. When
you’ve set the threshold properly, push the “accept”-button on the
window named “Number of trials per std of approx.:” (figure 2d-4). A
graphical display of the chronological sequence of good and bad trials
is displayed next (not shown) and global and trial- and
channel-specific thresholds are written to disk.
Event related averaging, sensor
interpolation and simple data display
Push the “Close all and EmegsAvg”-button on the artifact detection main
window (figure 2c-3) to directly start the averaging window for the
edited data. The artifact detection window will close and the averaging
window (not shown) will come up. The data format is set automatically,
and you just need to push the “Run average”-button to start the
averaging and approximation of missing sensors. When finished, EMEGS
again opens the log file to show you a few trial statistics such as the
number of good trials per condition and the average number of good
sensors per trial.
Now, you should be able to find the result files in the data folder.
Namely the files “EEGTutorialData.f.ses.app1”,
“EEGTutorialData.f.ses.app2” and “EEGTutorialData.f.ses.app3” contain
the clean data epochs for the conditions 1, 2 and 3, the files
“EEGTutorialData.f.at1.ar”, “EEGTutorialData.f.at2.ar” and
“EEGTutorialData.f.at2.ar” contain the ERPs.
Push the “Close All and Emegs2d”-button on the bottom right corner of
the averaging window and the data display and analysis window will open
(figure 2e). Push the the “Open data file”-button (figure 2e-1) and
select one of the ERP-files listed above to display it’s data.
Wavelet analysis
Download
EEGLAB 7.2.9.19b from http://sccn.ucsd.edu/eeglab, extract the zip-archive and
add the eeglab folder with all its subfolders to the MATLAB path. Fieltrip is
included in this version of EEGLAB , so no other download is required.
After the averaging step described in the ERP tutorial, approximated
trial by trial data are stored in .app files, which are now used to run
the time-frequency analysis. To display the plug-in interface, either
run the plugin from Emegs2d -> Plugin -> Run Fieldtrip TF
analysis, or run Plugtfwltgui from the Matlab prompt (Figure 3a-1). In
the plugin interface (Figure 3b-2), push the ‘load *.app*’ button and
select any of the three newly created .app* files. The file dialog will
reappear allowing you to select a series of files for batch processing.
As in the present case, we have only 1 data file, push “Cancel” to stop
the file selection. Now enter the wavelet analysis parameters: under
the “frequency settings” label, set min = 8, step = .05 max = 80, step
= 5, to focus on data from 8 to 80 Hz. As frequency resolution is
maximal for low frequencies and minimal for high frequencies (Roach
& Mathalon, 2008), the step between successive frequencies will
vary linearly from 0.5 Hz for the lowest frequencies to 5 Hz for the
highest frequencies. To display a diagnostic plot indicating which and
how many frequencies will be analyzed, push the “show” button(Figure
3b-3). In the displayed plots, the curve relating absolute frequency to
frequency step will be displayed (left), together with a line plot
representing the to-be-analyzed frequency spectrum (y axis), with one
horizontal line for each frequency which will be analyzed (right). In
this sample data, since the pre-trigger and the post-trigger interval
is very short, wavelet parameters will be set to m = 4 and c = 2, to
obtain a short wavelet which can be repeated several times in the data
segment, even at the lowest frequencies. In general, longer baseline
and data segments allow for more accurate time-frequency analyses. To
display the resulting wavelet, push the “display wavelet” button
(Figure 3b-4). Four diagnostic plots will be thus displayed. In the top
row, the resulting wavelet at the lowest (8Hz) and at the highest
(80Hz) frequency are displayed. The bottom-left panel, the curve
relating time and frequency resolution is plotted. Finally, the
bottom-left panel relates the wavelet frequency resolution to the
frequency steps which were selected by the user. Two reference lines
are also displayed, displaying the 1:1 linear relation between
frequency resolution and frequency step (purple) and the 2:1 relation
between frequency line and step (red). This plot can be used to make
sure that the chosen analysis parameters are appropriate, i.e. to check
that frequency step is equal, or half of, frequency resolution. In the
“time settings” section, specify min = 0, max = 1.1, step = 0.01 to
analyze the entire 1100 ms epoch in steps of 10 ms each. Push “Run TF
analysis” to start the analysis (Figure 3b-5). Data will be
automatically converted in the EEGLAB format, then imported in
Fieldtrip and analyzed using the chosen parameters. As a result, a .mat
file containing the time-frequency results, in terms of power and
phase-locking factor (PLF), will be created in the same folder as the
original data.
To display results, choose Emegs2d -> Plugin -> Display TF
results (figure 3a-6) or run Plugtfgui from the MATLAB command window.
Load the newly created .mat files by selecting “Add file” (Figure
3c-7), then activate “single sensor” from the visualization options and
“PO8” as sensor of interest (Figure 3c-8). In the time section, enter
min = 0.16, max = 0.94, with baseline correction from 0.18 to 0.45 (as
described in the ERP tutorial, data epochs include 500ms of baseline,
thus stimulus onset is at 0.5 s). Change the power scale to -6 to +6,
and select tf_plot to display a Fieldtrip plot of the chosen sensor
(Figure 3c-9). In a similar fashion, whole-head topographies and
multiple sensor plots can be easily obtained for both power or PLF
data.