<div dir="ltr">PS: of course, X(t) and E(t) in my equations should be column vectors :)<div class="gmail_extra"><br><br><div class="gmail_quote">On Mon, Jan 27, 2014 at 6:33 PM, Tim Mullen <span dir="ltr"><<a href="mailto:mullen.tim@gmail.com" target="_blank">mullen.tim@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">OK, there are two ways to do this.<div><br></div><div>You can do it by hand, or you can do it automatically using SIFTs simulation package.<div>
<br></div><div>For the former: you have write out the system matrix which contains the interaction coefficients at each lag. </div>
<div><br></div><div>Let me demonstrate for a simple 2-dim VAR process of order 2: </div><div><br></div><div><span style="font-family:arial,sans-serif;font-size:13px">x1(t) = 0.95√2x1(t − 1) − 0.9025x1(t − 2) + e1(t)</span><br style="font-family:arial,sans-serif;font-size:13px">
<span style="font-family:arial,sans-serif;font-size:13px">x2(t) = 0.5x1(t − 2) + e2(t)</span><br></div><div><span style="font-family:arial,sans-serif;font-size:13px"><br></span></div><div><span style="font-family:arial,sans-serif;font-size:13px">The lag-1 AR coefficient matrix is:</span></div>
<div><span style="font-family:arial,sans-serif;font-size:13px"><br></span></div><div><span style="font-family:arial,sans-serif;font-size:13px"><img src="cid:ii_143d66b67515e57e" alt="Inline image 4"><br></span></div><div>
<span style="font-family:arial,sans-serif;font-size:13px"><br></span></div><div><font face="arial, sans-serif">and the lag-2 AR coefficient matrix is:</font></div><div><font face="arial, sans-serif"><img src="cid:ii_143d66b24a5b54b4" alt="Inline image 3"><br>
</font></div><div><span style="font-family:arial,sans-serif;font-size:13px"><br></span></div><div><font face="arial, sans-serif">The linear equation describing this system is then:</font></div><div><font face="arial, sans-serif"><br>
</font></div><div><font face="arial, sans-serif"><img src="cid:ii_143d6b0a12748d9a" alt="Inline image 7"><br></font></div><div><font face="arial, sans-serif">where </font></div><div><font face="arial, sans-serif"><img src="cid:ii_143d6b13e9f2cae2" alt="Inline image 8"></font></div>
<div><font face="arial, sans-serif">and</font></div><div><font face="arial, sans-serif"><img src="cid:ii_143d6b18eaeb832d" alt="Inline image 9"><br></font></div><div><font face="arial, sans-serif"><br></font></div><div><font face="arial, sans-serif">For more complex systems, you will want to generate the A matrices </font><span style="font-family:arial,sans-serif">automatically. For this</span><span style="font-family:arial,sans-serif"> you can use the SIFT function sim_genVARModelFromEq(). </span></div>
<div><br></div><div>You can also simulate data from this system of equations other routines in the SIFT simulation package.</div><div><span>See the example in </span><b>/scripts/SimulationExample.m. </b>Or, for a GUI experience, try this: <b>EEG = pop_sim_varmodel()</b></div>
<div><font face="arial, sans-serif"><br></font></div><div>Here is an example of how to generate the "A" (system) matrices:</div><div><br></div><div>
<pre style="vertical-align:baseline;line-height:16.799999237060547px;font-size:12px;background-color:rgb(247,247,247);margin-bottom:20px;margin-top:0px;outline:rgb(0,0,0);border:1px solid rgb(211,211,211);padding:10px">format <span style="margin:0px;padding:0px;border:0px;outline:rgb(0,0,0);vertical-align:baseline;background-color:transparent;color:rgb(160,32,240)">short</span>
<span style="margin:0px;padding:0px;border:0px;outline:rgb(0,0,0);vertical-align:baseline;background-color:transparent;color:rgb(34,139,34)">% First, we write out the system of equations as a cell array of strings:</span>
<span style="margin:0px;padding:0px;border:0px;outline:rgb(0,0,0);vertical-align:baseline;background-color:transparent;color:rgb(34,139,34)">% Although, this is very similar to how it will appear in most papers, we</span>
<span style="margin:0px;padding:0px;border:0px;outline:rgb(0,0,0);vertical-align:baseline;background-color:transparent;color:rgb(34,139,34)">% must follow a precise convention as described in the help doc for</span>
<span style="margin:0px;padding:0px;border:0px;outline:rgb(0,0,0);vertical-align:baseline;background-color:transparent;color:rgb(34,139,34)">% sim_genVARModelFromEq(). Particularly, notice how we use {<arg>} </span>
<span style="margin:0px;padding:0px;border:0px;outline:rgb(0,0,0);vertical-align:baseline;background-color:transparent;color:rgb(34,139,34)">% when we wish to provide an inline expression (e.g. {0.95*sqrt(2)}) for a</span>
<span style="margin:0px;padding:0px;border:0px;outline:rgb(0,0,0);vertical-align:baseline;background-color:transparent;color:rgb(34,139,34)">% coefficient, rather than a numeric value. Also note the use of "+" to</span>
<span style="margin:0px;padding:0px;border:0px;outline:rgb(0,0,0);vertical-align:baseline;background-color:transparent;color:rgb(34,139,34)">% separate all terms of the equations and the convention xi and ei to</span>
<span style="margin:0px;padding:0px;border:0px;outline:rgb(0,0,0);vertical-align:baseline;background-color:transparent;color:rgb(34,139,34)">% denote the ith data and noise terms.</span>
expr = {<span style="margin:0px;padding:0px;border:0px;outline:rgb(0,0,0);vertical-align:baseline;background-color:transparent;color:rgb(0,0,255)">...</span>
<span style="margin:0px;padding:0px;border:0px;outline:rgb(0,0,0);vertical-align:baseline;background-color:transparent;color:rgb(160,32,240)">'x1(t) = {0.95*sqrt(2)}*x1(t-1) + -0.9025*x1(t-2) + e1(t)'</span>, <span style="margin:0px;padding:0px;border:0px;outline:rgb(0,0,0);vertical-align:baseline;background-color:transparent;color:rgb(0,0,255)">...</span>
<span style="margin:0px;padding:0px;border:0px;outline:rgb(0,0,0);vertical-align:baseline;background-color:transparent;color:rgb(160,32,240)">'x2(t) = 0.5*x1(t-2) + e2(t)'</span>, <span style="margin:0px;padding:0px;border:0px;outline:rgb(0,0,0);vertical-align:baseline;background-color:transparent;color:rgb(0,0,255)">...</span>
<span style="margin:0px;padding:0px;border:0px;outline:rgb(0,0,0);vertical-align:baseline;background-color:transparent;color:rgb(160,32,240)">'x3(t) = -0.4*x1(t-3) + e3(t)'</span>, <span style="margin:0px;padding:0px;border:0px;outline:rgb(0,0,0);vertical-align:baseline;background-color:transparent;color:rgb(0,0,255)">...</span>
<span style="margin:0px;padding:0px;border:0px;outline:rgb(0,0,0);vertical-align:baseline;background-color:transparent;color:rgb(160,32,240)">'x4(t) = -0.5*x1(t-2) + {0.25*sqrt(2)}*x4(t-1) + {0.25*sqrt(2)}*x5(t-1) + e4(t)'</span>, <span style="margin:0px;padding:0px;border:0px;outline:rgb(0,0,0);vertical-align:baseline;background-color:transparent;color:rgb(0,0,255)">...</span>
<span style="margin:0px;padding:0px;border:0px;outline:rgb(0,0,0);vertical-align:baseline;background-color:transparent;color:rgb(160,32,240)">'x5(t) = {-0.25*sqrt(2)}*x4(t-1) + {0.25*sqrt(2)}*x5(t-1) + e5(t)'</span>};
ModelOrder = 3;
NumChans = 5;
<span style="margin:0px;padding:0px;border:0px;outline:rgb(0,0,0);vertical-align:baseline;background-color:transparent;color:rgb(34,139,34)">% parse the equation expression and generate the system matrix [A1 A2 ... Ap]</span>
A = sim_genVARModelFromEq(expr,ModelOrder)</pre><pre style="margin-top:0px;margin-bottom:20px;padding:10px;border:1px solid rgb(211,211,211);outline:rgb(0,0,0);vertical-align:baseline;background-color:rgb(247,247,247)"><pre style="background-color:rgb(255,255,255);margin-top:0px;margin-bottom:20px;padding:10px 11px;border:0px;outline:rgb(0,0,0);vertical-align:baseline">
<font color="#4c4c4c"><span style="line-height:16.799999237060547px">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]</span></font></pre></pre><pre style="vertical-align:baseline;line-height:16.799999237060547px;font-size:12px;background-color:rgb(247,247,247);margin-bottom:20px;margin-top:0px;outline:rgb(0,0,0);border:1px solid rgb(211,211,211);padding:10px">
<span style="margin:0px;padding:0px;border:0px;outline:rgb(0,0,0);vertical-align:baseline;background-color:transparent;color:rgb(34,139,34)">% evaluate the inline terms involving sqrt():</span>
A = [cellfun(@(x) eval(num2str(x)), Aproto)]
<span style="margin:0px;padding:0px;border:0px;outline:rgb(0,0,0);vertical-align:baseline;background-color:transparent;color:rgb(34,139,34)">
% NOTE: we could also do the evaluation using this code:</span>
<span style="margin:0px;padding:0px;border:0px;outline:rgb(0,0,0);vertical-align:baseline;background-color:transparent;color:rgb(34,139,34)">% A = sim_genTVARcoeffs('Aproto',A,'ModelOrder',ModelOrder,'Nl',1,'ndisc',0);</span>
<span style="margin:0px;padding:0px;border:0px;outline:rgb(0,0,0);vertical-align:baseline;background-color:transparent;color:rgb(34,139,34)">% A = A{1};</span></pre><pre style="margin-top:0px;margin-bottom:20px;padding:10px;border:1px solid rgb(211,211,211);outline:rgb(0,0,0);vertical-align:baseline;background-color:rgb(247,247,247)">
<pre style="background-color:rgb(255,255,255);margin-top:0px;margin-bottom:20px;padding:10px 11px;border:0px;outline:rgb(0,0,0);vertical-align:baseline"><font color="#4c4c4c"><span style="line-height:16.799999237060547px">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</span></font></pre></pre><pre style="margin-top:0px;margin-bottom:20px;padding:10px;border:1px solid rgb(211,211,211);outline:rgb(0,0,0);font-size:12px;vertical-align:baseline;background-color:rgb(247,247,247);line-height:16.799999237060547px">
<span style="color:rgb(34,139,34);margin:0px;padding:0px;border:0px;outline:rgb(0,0,0);vertical-align:baseline;background-color:transparent">% print the VAR coefficient matrices for each lag</span><font color="#000000">
</font><span style="color:rgb(0,0,255);margin:0px;padding:0px;border:0px;outline:rgb(0,0,0);vertical-align:baseline;background-color:transparent">for</span><font color="#000000"> k=1:ModelOrder
fprintf(</font><span style="color:rgb(160,32,240);margin:0px;padding:0px;border:0px;outline:rgb(0,0,0);vertical-align:baseline;background-color:transparent">'------------------------------------------------\n'</span><font color="#000000">);
fprintf(</font><span style="color:rgb(160,32,240);margin:0px;padding:0px;border:0px;outline:rgb(0,0,0);vertical-align:baseline;background-color:transparent">'A%d = \n'</span><font color="#000000">,k); disp(A(:,(k-1)*NumChans+1:k*NumChans));
</font><span style="color:rgb(0,0,255);margin:0px;padding:0px;border:0px;outline:rgb(0,0,0);vertical-align:baseline;background-color:transparent">end</span><font color="#000000">
</font></pre><pre style="margin-top:0px;margin-bottom:20px;padding:10px;border:1px solid rgb(211,211,211);outline:rgb(0,0,0);font-size:12px;vertical-align:baseline;background-color:rgb(247,247,247);line-height:16.799999237060547px">
<span style="color:rgb(0,0,255);margin:0px;padding:0px;border:0px;outline:rgb(0,0,0);vertical-align:baseline;background-color:transparent"><pre style="background-color:rgb(255,255,255);margin-top:0px;margin-bottom:20px;padding:10px 11px;border:0px;outline:rgb(0,0,0);vertical-align:baseline;color:rgb(76,76,76)">
------------------------------------------------
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</pre></span></pre><p style="margin:25px 0px 0px;padding:10px 0px;border-width:1px 0px 0px;border-top-style:dotted;border-top-color:rgb(135,135,135);outline:rgb(0,0,0);font-size:0.8em;vertical-align:baseline;width:auto;line-height:13.4399995803833px;font-style:italic;color:rgb(135,135,135);float:none;font-family:Arial,Helvetica,sans-serif">
<br>Published with MATLAB® 7.14</p><p><br></p><p><br></p><p>Best,</p><p>Tim</p></div><div><font face="arial, sans-serif"><br></font></div><div><span style="font-family:arial,sans-serif;font-size:13px"><br>
</span></div><div><br></div><div><br></div></div></div><div class="gmail_extra"><div><div><br><br><div class="gmail_quote">On Mon, Jan 27, 2014 at 4:10 PM, Ibtissem KHOUAJA BENFRADJ <span dir="ltr"><<a href="mailto:ibtissem.khouaja@live.fr" target="_blank">ibtissem.khouaja@live.fr</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div><div dir="ltr"><font color="#000000" face="Times New Roman"><br></font>Thank you Tim so much for your answers, <span lang="en"><span>your</span> <span>support</span> <span>keeps me going</span> <span><br>and</span>help me <span>to</span> <span>better understand the needs</span> <span>of my work.</span> <br>
<br><span><br>I extrcted the matrix chains EEG from an (.edf) file, <br></span></span><span lang="en"><span><span lang="en"><span>I want to find</span> <span>the linear equation</span> <span>that characterizes</span> <span>the dynamics of these</span> <span>signals</span> <span>as described</span> <span>in the article:</span><br>
<span>"A</span> <span>MATLAB</span> <span>toolbox</span> <span>for</span> <span>Granger</span> <span>causal</span> <span>connectivity</span> <span>analysis",<br></span></span></span></span><br>x1(t) = 0.95 √2x1(t − 1) − 0.9025x1(t − 2) + w1(t)<br>
x2(t) = 0.5x1(t − 2) + w2(t)<br>x3(t) = −0.4x1(t − 3) + w3(t)<br>x4(t) = −0.5x1(t − 2) + 0.25√2x4(t − 1) + 0.25√2x5(t − 1)+w4(t)<br>x5(t) = −0.25√2x4(t − 1) + 0.25√2x5(t − 1) +w5(t)<br><br><span lang="en"><span>how</span> <span>these factors</span> <span>can be extracted?<br>
<br>thanks in advance,</span></span><div><div><br><br><font style="font-size:10pt" color="#666666" face="Comic Sans MS">Ibtissem KHOUAJA BENFRADJ</font><div><span><font color="#666666" face="Comic Sans MS">PhD in computer science</font></span></div>
<div><span><font color="#666666" face="Comic Sans MS">Speciality Signal Processing</font></span></div><div><span><font color="#666666" face="Comic Sans MS">Laboratory LTIM, University of Monastir, Tunisia</font></span></div>
<div><a href="http://www.labtim.org/accueil.php" target="_blank"><font color="#666666" face="Comic Sans MS">http://www.labtim.org/accueil.php</font></a></div><div><span><font color="#666666" face="Comic Sans MS">Laboratory LIGM, Univerisity of Paris-East, France </font></span></div>
<div><a href="http://ligm.u-pem.fr/" target="_blank"><font color="#666666" face="Comic Sans MS">http://ligm.u-pem.fr/</font></a></div><div><span><font color="#666666" face="Comic Sans MS"><br></font></span></div>
<div><span style="font-size:12pt"><br></span></div><br></div></div><div><div><div><div dir="ltr"><div><br><div><hr>From: <a href="mailto:mullen.tim@gmail.com" target="_blank">mullen.tim@gmail.com</a><br>Date: Wed, 15 Jan 2014 18:26:48 -0800<br>
Subject: Re: [Eeglablist] EEG parameterization<br>To: <a href="mailto:ibtissem.khouaja@live.fr" target="_blank">ibtissem.khouaja@live.fr</a><br>CC: <a href="mailto:eeglablist@sccn.ucsd.edu" target="_blank">eeglablist@sccn.ucsd.edu</a><br>
<br><div dir="ltr">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.<div><br></div><div>Best,</div><div>
Tim</div>
</div><div><br><br><div>On Wed, Jan 15, 2014 at 5:28 AM, Ibtissem KHOUAJA BENFRADJ <span dir="ltr"><<a href="mailto:ibtissem.khouaja@live.fr" target="_blank">ibtissem.khouaja@live.fr</a>></span> wrote:<br>
<blockquote style="border-left:1px #ccc solid;padding-left:1ex">
<div><div dir="ltr"><font color="#000000" face="Times New Roman"><br></font>Thank you Tim,<br>I actually need the non linear filter to study the EEG signaland to extract these features.<br><br>I find the linear filte (est_fitMVARKalman) on the net but I can't find the socond one (est_fitMVAREKF).<br>
Can you send me the link.<br><br>thanks a lot.<br><font style="font-size:10pt" color="#666666" face="Comic Sans MS">-----------</font><font style="font-size:10pt" color="#666666" face="Comic Sans MS"><br>Ibtissem KHOUAJA BENFRADJ</font><div>
<span><font color="#666666" face="Comic Sans MS">PhD in computer science</font></span></div><div><span><font color="#666666" face="Comic Sans MS">Speciality Signal Processing</font></span></div><div><span><font color="#666666" face="Comic Sans MS">Laboratory LTIM, University of Monastir, Tunisia</font></span></div>
<div><a href="http://www.labtim.org/accueil.php" target="_blank"><font color="#666666" face="Comic Sans MS">http://www.labtim.org/accueil.php</font></a></div><div><span><font color="#666666" face="Comic Sans MS">Laboratory LIGM, Univerisity of Paris-East, France </font></span></div>
<div><a href="http://ligm.u-pem.fr/" target="_blank"><font color="#666666" face="Comic Sans MS">http://ligm.u-pem.fr/</font></a></div><div><span><font color="#666666" face="Comic Sans MS"><br></font></span></div>
<div><span style="font-size:12pt"><br></span></div><br><br><div>> Date: Wed, 8 Jan 2014 18:04:46 -0800<div><br>> Subject: Re: [Eeglablist] EEG parameterization<br></div>> From: <a href="mailto:mullen.tim@gmail.com" target="_blank">mullen.tim@gmail.com</a><br>
> To: <a href="mailto:ibtissem.khouaja@live.fr" target="_blank">ibtissem.khouaja@live.fr</a>; <a href="mailto:eeglablist@sccn.ucsd.edu" target="_blank">eeglablist@sccn.ucsd.edu</a><br>> CC: <br><div><div>
> <br>> 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. <br>> <br>> Tim<br>
> <br>> -----Original Message-----<br>> Date: Wednesday, January 08, 2014 1:40:42 pm<br>> To: "EEGLAB-list" <<a href="mailto:eeglablist@sccn.ucsd.edu" target="_blank">eeglablist@sccn.ucsd.edu</a>><br>
> From: "Ibtissem KHOUAJA BENFRADJ" <<a href="mailto:ibtissem.khouaja@live.fr" target="_blank">ibtissem.khouaja@live.fr</a>><br>> Subject: Re: [Eeglablist] EEG parameterization<br>> <br>> <br>
> <br>
> <br>> <br>> Thank you very much for your answers and happy new year 2014.<br>> 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.<br>
> This gives the possibility of reconstructing the signal and to predict its evolution.<br>> Is there someone who work with this type of auto-regressive filter?I need the algorithm in Matlab.<br>> Thank a lot for your precious help, Ibtissem<br>
> <br>> <br>> <br>> ---------------------------------------------------------------------------<br>> ---------------------------------------------------------------------------<br>> > From: <a href="mailto:poil.simonshlomo@gmail.com" target="_blank">poil.simonshlomo@gmail.com</a><br>
> > Date: Thu, 19 Dec 2013 21:43:51 +0100<br>> > Subject: Re: [Eeglablist] EEG parameterization<br>> > To: <a href="mailto:ibtissem.khouaja@live.fr" target="_blank">ibtissem.khouaja@live.fr</a><br>> > CC: <a href="mailto:eeglablist@sccn.ucsd.edu" target="_blank">eeglablist@sccn.ucsd.edu</a><br>
> > <br>> > Dear Ibtissem,<br>> > <br>> > There are several ways you can characterize an EEG signal. The two<br>> > basic are frequency and amplitude in different frequency bands (and<br>> > spatial location). You can see more here:<br>
> <br></div></div></div> </div></div>
</blockquote></div><br><br clear="all"><div><br></div>-- <br>--------- αντίληψη -----------
</div></div></div> </div>
<br></div></div><div>_______________________________________________
Eeglablist page: <a href="http://sccn.ucsd.edu/eeglab/eeglabmail.html" target="_blank">http://sccn.ucsd.edu/eeglab/eeglabmail.html</a>
To unsubscribe, send an empty email to <a href="mailto:eeglablist-unsubscribe@sccn.ucsd.edu" target="_blank">eeglablist-unsubscribe@sccn.ucsd.edu</a>
For digest mode, send an email with the subject "set digest mime" to <a href="mailto:eeglablist-request@sccn.ucsd.edu" target="_blank">eeglablist-request@sccn.ucsd.edu</a></div></div> </div></div>
</blockquote></div><br><br clear="all"><div><br></div></div></div><span><font color="#888888">-- <br>--------- αντίληψη -----------
</font></span></div>
</blockquote></div><br><br clear="all"><div><br></div>-- <br>--------- αντίληψη -----------
</div></div>