# [Eeglablist] EEG parameterization

Tim Mullen mullen.tim at gmail.com
Mon Jan 27 18:33:32 PST 2014

```OK, there are two ways to do this.

You can do it by hand, or you can do it automatically using SIFTs
simulation package.

For the former: you have write out the system matrix which contains the
interaction coefficients at each lag.

Let me demonstrate for a simple 2-dim VAR process of order 2:

x1(t) = 0.95√2x1(t − 1) − 0.9025x1(t − 2) + e1(t)
x2(t) = 0.5x1(t − 2) + e2(t)

The lag-1 AR coefficient matrix is:

[image: Inline image 4]

and the lag-2 AR coefficient matrix is:
[image: Inline image 3]

The linear equation describing this system is then:

[image: Inline image 7]
where
[image: Inline image 8]
and
[image: Inline image 9]

For more complex systems, you will want to generate the A matrices
automatically.
For this you can use the SIFT function sim_genVARModelFromEq().

You can also simulate data from this system of equations other routines in
the SIFT simulation package.
See the example in */scripts/SimulationExample.m. *Or, for a GUI
experience, try this: *EEG = pop_sim_varmodel()*

Here is an example of how to generate the "A" (system) matrices:

format short
% First, we write out the system of equations as a cell array of
strings:% Although, this is very similar to how it will appear in most
papers, we% must follow a precise convention as described in the help
doc for% sim_genVARModelFromEq(). Particularly, notice how we use
{<arg>} % when we wish to provide an inline expression (e.g.
{0.95*sqrt(2)}) for a% coefficient, rather than a numeric value. Also
note the use of "+" to% separate all terms of the equations and the
convention xi and ei to% denote the ith data and noise terms.
expr = {...'x1(t) = {0.95*sqrt(2)}*x1(t-1) + -0.9025*x1(t-2) + e1(t)',
...'x2(t) = 0.5*x1(t-2) + e2(t)', ...'x3(t) = -0.4*x1(t-3) + e3(t)',
...'x4(t) = -0.5*x1(t-2) + {0.25*sqrt(2)}*x4(t-1) +
{0.25*sqrt(2)}*x5(t-1) + e4(t)', ...'x5(t) = {-0.25*sqrt(2)}*x4(t-1) +
{0.25*sqrt(2)}*x5(t-1) + e5(t)'};
ModelOrder = 3;
NumChans = 5;
% parse the equation expression and generate the system matrix [A1 A2 ... Ap]
A = sim_genVARModelFromEq(expr,ModelOrder)

A =

'0.95*sqrt(2)'    [0]    [0]    [            0]    [           0]
[-0.9025]    [0]    [0]    [0]    [0]    [      0]    [0]    [0]
[0]    [0]
[           0]    [0]    [0]    [            0]    [           0]
[ 0.5000]    [0]    [0]    [0]    [0]    [      0]    [0]    [0]
[0]    [0]
[           0]    [0]    [0]    [            0]    [           0]
[      0]    [0]    [0]    [0]    [0]    [-0.4000]    [0]    [0]
[0]    [0]
[           0]    [0]    [0]    '0.25*sqrt(2)'     '0.25*sqrt(2)'
[-0.5000]    [0]    [0]    [0]    [0]    [      0]    [0]    [0]
[0]    [0]
[           0]    [0]    [0]    '-0.25*sqrt(2)'    '0.25*sqrt(2)'
[      0]    [0]    [0]    [0]    [0]    [      0]    [0]    [0]
[0]    [0]

% evaluate the inline terms involving sqrt():
A = [cellfun(@(x) eval(num2str(x)), Aproto)]
% NOTE: we could also do the evaluation using this code:% A =
sim_genTVARcoeffs('Aproto',A,'ModelOrder',ModelOrder,'Nl',1,'ndisc',0);%
A = A{1};

A =

1.3435         0         0         0         0   -0.9025         0
0         0         0         0         0         0         0
0
0         0         0         0         0    0.5000         0
0         0         0         0         0         0         0
0
0         0         0         0         0         0         0
0         0         0   -0.4000         0         0         0
0
0         0         0    0.3536    0.3536   -0.5000         0
0         0         0         0         0         0         0
0
0         0         0   -0.3536    0.3536         0         0
0         0         0         0         0         0         0
0

% print the VAR coefficient matrices for each lagfor k=1:ModelOrder
fprintf('------------------------------------------------\n');
fprintf('A%d = \n',k); disp(A(:,(k-1)*NumChans+1:k*NumChans));end

------------------------------------------------
A1 =
1.3435         0         0         0         0
0         0         0         0         0
0         0         0         0         0
0         0         0    0.3536    0.3536
0         0         0   -0.3536    0.3536

------------------------------------------------
A2 =
-0.9025         0         0         0         0
0.5000         0         0         0         0
0         0         0         0         0
-0.5000         0         0         0         0
0         0         0         0         0

------------------------------------------------
A3 =
0         0         0         0         0
0         0         0         0         0
-0.4000         0         0         0         0
0         0         0         0         0
0         0         0         0         0

Published with MATLAB® 7.14

Best,

Tim

On Mon, Jan 27, 2014 at 4:10 PM, Ibtissem KHOUAJA BENFRADJ <
ibtissem.khouaja at live.fr> wrote:

>
> andhelp me to better understand the needs of my work.
>
>
> I extrcted the matrix chains EEG from an (.edf) file,
> I want to find the linear equation that characterizes the dynamics of
> these signals as described in the article:
>  "A MATLAB toolbox for Granger causal connectivity analysis",
>
> x1(t) = 0.95 √2x1(t − 1) − 0.9025x1(t − 2) + w1(t)
> x2(t) = 0.5x1(t − 2) + w2(t)
> x3(t) = −0.4x1(t − 3) + w3(t)
> x4(t) = −0.5x1(t − 2) + 0.25√2x4(t − 1) + 0.25√2x5(t − 1)+w4(t)
> x5(t) = −0.25√2x4(t − 1) + 0.25√2x5(t − 1) +w5(t)
>
> how these factors can be extracted?
>
>
>
> PhD in computer science
> Speciality Signal Processing
> Laboratory LTIM, University of Monastir, Tunisia
> http://www.labtim.org/accueil.php
> Laboratory LIGM, Univerisity of Paris-East, France
> http://ligm.u-pem.fr/
>
>
>
>
> ------------------------------
> From: mullen.tim at gmail.com
> Date: Wed, 15 Jan 2014 18:26:48 -0800
> Subject: Re: [Eeglablist] EEG parameterization
> To: ibtissem.khouaja at live.fr
> CC: eeglablist at sccn.ucsd.edu
>
> The function (<sift-root>/est/est_fitMVAR_DEKF.m) is included in SIFT
> 1.0-beta and later, which you can obtain from the EEGLAB plugin manager or
> the SIFT website.
>
> Best,
> Tim
>
>
> On Wed, Jan 15, 2014 at 5:28 AM, Ibtissem KHOUAJA BENFRADJ <
> ibtissem.khouaja at live.fr> wrote:
>
>
> Thank you Tim,
> I actually need the non linear filter to study the EEG signaland to
> extract these features.
>
> I find the linear filte (est_fitMVARKalman) on the net but I can't find
> the socond one (est_fitMVAREKF).
> Can you send me the link.
>
> thanks a lot.
> -----------
> PhD in computer science
> Speciality Signal Processing
> Laboratory LTIM, University of Monastir, Tunisia
> http://www.labtim.org/accueil.php
> Laboratory LIGM, Univerisity of Paris-East, France
> http://ligm.u-pem.fr/
>
>
>
>
> > Date: Wed, 8 Jan 2014 18:04:46 -0800
>
> > Subject: Re: [Eeglablist] EEG parameterization
> > From: mullen.tim at gmail.com
> > To: ibtissem.khouaja at live.fr; eeglablist at sccn.ucsd.edu
> > CC:
> >
> > There are linear and nonlinear kalman filter-based multivariate
> autoregressive implementations in the Source Information Flow Toolbox for
> EEGLAB. See est_fitMVARKalman and est_fitMVARDEKF.
> >
> > Tim
> >
> > -----Original Message-----
> > Date: Wednesday, January 08, 2014 1:40:42 pm
> > To: "EEGLAB-list" <eeglablist at sccn.ucsd.edu>
> > From: "Ibtissem KHOUAJA BENFRADJ" <ibtissem.khouaja at live.fr>
> > Subject: Re: [Eeglablist] EEG parameterization
> >
> >
> >
> >
> >
> > Thank you very much for your answers and happy new year 2014.
> > On my first question, I am based on your set and literature and I will
> present the EEG signal from a set of evolutionary parameters based on the
> Kalman filter.
> > This gives the possibility of reconstructing the signal and to predict
> its evolution.
> > Is there someone who work with this type of auto-regressive filter?I
> need the algorithm in Matlab.
> > Thank a lot for your precious help, Ibtissem
> >
> >
> >
> >
> ---------------------------------------------------------------------------
> >
> ---------------------------------------------------------------------------
> > > From: poil.simonshlomo at gmail.com
> > > Date: Thu, 19 Dec 2013 21:43:51 +0100
> > > Subject: Re: [Eeglablist] EEG parameterization
> > > To: ibtissem.khouaja at live.fr
> > > CC: eeglablist at sccn.ucsd.edu
> > >
> > > Dear Ibtissem,
> > >
> > > There are several ways you can characterize an EEG signal. The two
> > > basic are frequency and amplitude in different frequency bands (and
> > > spatial location). You can see more here:
> >
>
>
>
>
> --
> ---------  αντίληψη -----------
>
> _______________________________________________ Eeglablist page:
> http://sccn.ucsd.edu/eeglab/eeglabmail.html To unsubscribe, send an empty
> email to eeglablist-unsubscribe at sccn.ucsd.edu For digest mode, send an
> email with the subject "set digest mime" to
> eeglablist-request at sccn.ucsd.edu
>

--
---------  αντίληψη -----------
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://sccn.ucsd.edu/pipermail/eeglablist/attachments/20140127/385bbb95/attachment-0001.html
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: image/png
Size: 1369 bytes
Desc: not available
Url : http://sccn.ucsd.edu/pipermail/eeglablist/attachments/20140127/385bbb95/attachment-0005.png
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: image/png
Size: 1479 bytes
Desc: not available
Url : http://sccn.ucsd.edu/pipermail/eeglablist/attachments/20140127/385bbb95/attachment-0006.png
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: image/png
Size: 1172 bytes
Desc: not available
Url : http://sccn.ucsd.edu/pipermail/eeglablist/attachments/20140127/385bbb95/attachment-0007.png
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: image/png
Size: 2236 bytes
Desc: not available
Url : http://sccn.ucsd.edu/pipermail/eeglablist/attachments/20140127/385bbb95/attachment-0008.png
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: image/png
Size: 1439 bytes
Desc: not available
Url : http://sccn.ucsd.edu/pipermail/eeglablist/attachments/20140127/385bbb95/attachment-0009.png
```