The Neurophysiological Biomarker Toolbox (NBT)

# Granger causality analysis of EEG data

In this tutorial we will learn how effective connectivity between EEG sources can be assessed using linear measures of information flow based on the concept of Granger Causality (GC).

Below you can download the slides of a lecture that deals with the topic of this tutorial. The file is very large (83 MBytes) because it contains several animations. Also, be sure of using a relatively recent version of Adobe Acrobat Reader to display the presentation. Other pdf viewers may not display some of the videos correctly.

Please download the tutorial and uncompress the .zip file. Then simply add directory tutorial_sync and all its subdirectories to your MATLAB's path. To add a directory and all its subdirectories to MATLAB's path you can use MATLAB's command:

addpath(genpath('M:/mypath/tutorial_sync'))

where M:/mypath/tutorial_sync is the location where you uncompressed the .zip file.

Note: The tutorial .zip file contains the tutorial code, the required data files and this documentation in HTML format. You can browse the documentation offline by opening with your web browser file index.htm, which is found under folder tutorial_sync.

# Dependencies

The tutorial should work under MATLAB R2010a or newer. It is likely to work also under not too much older MATLAB versions. The tutorial makes use of the following freely available MATLAB toolboxes:

For convenience, all the dependencies have been included in the tutorial .zip package so that you don't need to download them separately.

# Getting help

Note: The information below is identical to the one that you can find in the previous tutorial, which dealt with simulating and estimating EEG sources. So you might want to go directly to the end of this page.

The tutorial instructions explain just a small fraction of the tutorial scripts' features. You can always get a more detailed help of individual MATLAB functions using the command help followed by the name of the relevant function. For instance, the command:

help plot

will display the help of MATLAB's built-in plot command.

# MATLAB classes

### What are classes and objects?

The tutorial makes use of MATLAB's classes. Do not get get intimidated by the term. A class is just a user-defined data type. MATLAB comes with lots of built-in data types. For instance double and single are two types that can store numeric data:

x = 5;

The variable x above is now an instance (also called an object) of class double. You can find out the classes of the variables in your MATLAB's workspace using the command whos. The result could be something like this:

>> whos
Name        Size              Bytes  Class       Attributes
  myHead      1x1             2805970  head.mri
x           1x1                   8  double
y           1x1                   8  double              

where you can see that variable x is an object of class double and variable myHead is an object of class head.mri. The latter is a class that we have defined specifically for the purposes of this tutorial.

It is important to realize the difference between a class and an object. In the example above, x and y are two different objects of the same class.

### What are class methods?

One of the great advantages of using objects with MATLAB is that it allows you to overloading function names. For instance, if you run the command:

plot(myHead);

MATLAB will first check whether a specialized method plot() has been defined for class head.mri. If such method exists then it will run that method instead of MATLAB's built-in function plot(). A head.mri object contains a head model and a double object contains just numbers. Indeed, plotting such different data types involve very different operations. Thus, it makes sense that different versions of plot are called, depending on the class of what you want to be plotted. Remember: the specialized version of plot() that takes care of plotting mri.head objects is called a method of class mri.head.

### Getting help on class' methods

Imagine that you want to get some help on method plot() for objects of class mri.head. You could try to do this:

help plot

but you will find that the help that is displayed corresponds to MATLAB's built-in plot() instead of corresponding to method plot() of class mri.head. Only if you read until the end of the help that is displayed you will see a section that reads Overloaded methods and that lists several other functions that are also called plot(), and that will be called instead of the built-in, depending on the type of the input argument. If you already installed the tutorial scripts you should see in that list a link reading head.mri. If you click that link you will get the help that you were looking for. Alternatively, you could have just used the command:

help head.mri.plot

# Questions and feedback

This tutorial has been prepared for the course Advanced Human Neurophysiology, given at the VU University, and organized by Klaus Linkenkaer-Hansen. The author of the tutorial is German Gomez-Herrero.

As both code and documentation has been made from scratch for the year 2011 course, it is likely that you will find bugs and typos. Please report those to german.gomezherrero@kasku.org so that I can fix them. I would also appreciate any feedback (positive or negative) on the tutorial contents so that I can improve it.

# Tutorial steps

The tutorial consists of four parts. Follow the links below to each of those parts: