<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">
Hi Manuela,
<div class=""><br class="">
</div>
<div class="">The code in ft_mvaranalysis (at least the part that is supposed to support the time-resolved models) is a bit messy. I patched it for now, making the function a bit more robust with respect to rounding off errors in the conversion between sample
 indices and time windows. I hope that the newer version now works for you.</div>
<div class=""><br class="">
</div>
<div class="">Best wishes,</div>
<div class="">Jan-Mathijs</div>
<div class=""><br class="">
</div>
<div class=""><br class="">
<div>
<blockquote type="cite" class="">
<div class="">On 4 Sep 2018, at 10:42, Manuela Costa <<a href="mailto:manuela.costa@ctb.upm.es" class="">manuela.costa@ctb.upm.es</a>> wrote:</div>
<br class="Apple-interchange-newline">
<div class="">
<div dir="ltr" class="">
<div dir="ltr" class="">
<div dir="ltr" class="">
<div dir="ltr" class="">
<div class="">
<div class="">Dear Jan-Mathijs, </div>
<div class=""><br class="">
</div>
<div class="">thank you very much for fixing the typo in the code. </div>
<div class="">I do not get anymore the same error but as you predicted I get a new one. </div>
<div class="">I hope you can help me with that as well. </div>
<div class=""><br class="">
</div>
<div class="">Best wishes</div>
<div class="">Manuela</div>
</div>
<div class=""><br class="">
</div>
<div class=""><br class="">
</div>
<div class="">
<div class="">Matrix dimensions must agree.</div>
<div class=""><br class="">
</div>
<div class="">Error in ft_mvaranalysis>catnan (line 607)</div>
<div class="">    datamatrix(:,begsmp:endsmp) = datacells{trials(k)}(chanindx,:).*taper(ones(nchan,1),:);</div>
<div class=""><br class="">
</div>
<div class="">Error in ft_mvaranalysis (line 425)</div>
<div class=""><span style="white-space:pre" class=""></span>dat = catnan(tmpdata.trial, chanindx, rpt{rlop}, tap(m,:), nnans, dobvar);</div>
<div class=""><br class="">
</div>
<div class="">Error in Step2_Calculate_Granger_time_freq_updated_MC (line 124)</div>
<div class="">    mdata_emotional_Rem{subj} = ft_mvaranalysis(cfg, preprocessing_emotional_Rem_ds{subj});</div>
</div>
<div class=""><br class="">
</div>
<div class=""><br class="">
</div>
<div class="">I copy here the information about the structure (it's the same as before)</div>
<div class=""><br class="">
</div>
<div class=""><span lang="EN-US" style="font-size: 10pt; font-family: 'Courier New';" class="">The data is downsampled at 250 Hz. The fields of my data structure are fsample, trial, time, label and cfg. The size of preprocessing_emotional_Rem_<wbr class="">ds{1}.trial{1} </span><span style="font-family: 'Courier New'; font-size: 10pt;" class="">is
 3x3751 (channels, data points).</span> <br class="">
</div>
<div class=""><br class="">
</div>
<div class="">
<div style="margin: 0cm 0cm 0.0001pt; background-color: rgb(255, 255, 255); line-height: normal; font-size: 11pt; font-family: Calibri, sans-serif;" class="">
<span lang="EN-US" style="font-size: 10pt; font-family: 'Courier New';" class="">Configuration structure:<span class=""></span></span></div>
<p class="MsoNormal" style="margin:0cm 0cm 0.0001pt;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial;line-height:normal;font-size:11pt;font-family:Calibri,sans-serif">
<span lang="EN-US" style="font-size: 10pt; font-family: 'Courier New';" class=""><span class=""> </span></span></p>
<div style="margin: 0cm 0cm 0.0001pt; background-color: rgb(255, 255, 255); line-height: normal; font-size: 11pt; font-family: Calibri, sans-serif;" class="">
<span lang="EN-US" style="font-size: 10pt; font-family: 'Courier New';" class="">cfg = [];<span class=""></span></span></div>
<div style="margin: 0cm 0cm 0.0001pt; background-color: rgb(255, 255, 255); line-height: normal; font-size: 11pt; font-family: Calibri, sans-serif;" class="">
<span lang="EN-US" style="font-size: 10pt; font-family: 'Courier New';" class=""><span class="">   <span class=""> </span></span>cfg.toolbox = 'bsmart';<span class=""></span></span></div>
<div style="margin: 0cm 0cm 0.0001pt; background-color: rgb(255, 255, 255); line-height: normal; font-size: 11pt; font-family: Calibri, sans-serif;" class="">
<span lang="EN-US" style="font-size: 10pt; font-family: 'Courier New';" class=""><span class="">   <span class=""> </span></span>cfg.order<span class="">  <span class=""> </span></span>= 10;<span class=""></span></span></div>
<div style="margin: 0cm 0cm 0.0001pt; background-color: rgb(255, 255, 255); line-height: normal; font-size: 11pt; font-family: Calibri, sans-serif;" class="">
<span lang="EN-US" style="font-size: 10pt; font-family: 'Courier New';" class=""><span class="">   <span class=""> </span></span>cfg.toi<span class="">      <span class=""> </span></span>= -0.5:0.01:3; %% the time points at which the windows are centered<span class=""></span></span></div>
<div style="margin: 0cm 0cm 0.0001pt; background-color: rgb(255, 255, 255); line-height: normal; font-size: 11pt; font-family: Calibri, sans-serif;" class="">
<span lang="EN-US" style="font-size: 10pt; font-family: 'Courier New';" class=""><span class="">   <span class=""> </span></span>cfg.t_ftimwin = 0.25; %% length of time window in second<span class=""></span></span></div>
<div style="margin: 0cm 0cm 0.0001pt; background-color: rgb(255, 255, 255); line-height: normal; font-size: 11pt; font-family: Calibri, sans-serif;" class="">
<span lang="EN-US" style="font-size: 10pt; font-family: 'Courier New';" class=""><span class="">   <span class=""> </span></span>mdata_emotional_Rem{subj} = ft_mvaranalysis(cfg, preprocessing_emotional_Rem_ds<wbr class="">{subj});</span></div>
<br class="">
</div>
</div>
</div>
</div>
</div>
<div class="gmail_extra"><br class="">
<div class="gmail_quote">2018-08-31 11:32 GMT+02:00 Schoffelen, J.M. (Jan Mathijs)
<span dir="ltr" class=""><<a href="mailto:jan.schoffelen@donders.ru.nl" target="_blank" class="">jan.schoffelen@donders.ru.nl</a>></span>:<br class="">
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div style="word-wrap:break-word" class="">Dear Manuela,
<div class=""><br class="">
</div>
<div class="">This looks like a typo in the code, which I will fix (and once fixed will become available in the daily release version of the code). To give myself some time: probably not tonight, but perhaps after the weekend :). However, the fact that this
 part of the code clearly doesn’t work, I am not entirely sure whether the rest will work smoothly as well, as soon as the current hurdle is fixed. But let’s see</div>
<div class=""><br class="">
</div>
<div class="">Best wishes,</div>
<div class="">Jan-Mathijs</div>
<div class=""><br class="">
</div>
<div class=""><br class="">
</div>
<div class="">
<div class="">
<blockquote type="cite" class="">
<div class="">
<div class="h5">
<div class="">On 29 Aug 2018, at 13:34, Manuela Costa <<a href="mailto:manuela.costa@ctb.upm.es" target="_blank" class="">manuela.costa@ctb.upm.es</a>> wrote:</div>
<br class="m_4496529063514022616Apple-interchange-newline">
</div>
</div>
<div class="">
<div class="">
<div class="h5">
<div dir="ltr" class="">
<div dir="ltr" class="">
<div style="margin:0cm 0cm 0.0001pt;line-height:normal;background-color:white;font-size:11pt;font-family:Calibri,sans-serif;background-position:initial initial;background-repeat:initial initial" class="">
<span lang="EN-US" style="font-size:10pt;font-family:'Courier New'" class="">Dear community,<span class=""></span></span></div>
<p class="MsoNormal" style="margin:0cm 0cm 0.0001pt;line-height:normal;background:white;font-size:11pt;font-family:Calibri,sans-serif">
<span lang="EN-US" style="font-size:10pt;font-family:'Courier New'" class=""><span class=""> </span></span></p>
<div style="margin:0cm 0cm 0.0001pt;line-height:normal;background-color:white;font-size:11pt;font-family:Calibri,sans-serif;background-position:initial initial;background-repeat:initial initial" class="">
<span lang="EN-US" style="font-size:10pt;font-family:'Courier New'" class="">I'm planning to do granger causality analysis on human iEEG data. I'm using ft_mvaranalysis to get time-dependent coefficient sets based on a sliding window, but I get an error. </span></div>
<div style="margin:0cm 0cm 0.0001pt;line-height:normal;background-color:white;font-size:11pt;font-family:Calibri,sans-serif;background-position:initial initial;background-repeat:initial initial" class="">
<span lang="EN-US" style="font-size:10pt;font-family:'Courier New'" class=""><br class="">
</span></div>
<div style="margin:0cm 0cm 0.0001pt;line-height:normal;background-color:white;font-size:11pt;font-family:Calibri,sans-serif;background-position:initial initial;background-repeat:initial initial" class="">
<span lang="EN-US" style="font-size:10pt;font-family:'Courier New'" class="">The data is downsampled at 250 Hz. The fields of my data structure are fsample, trial, time, label and cfg. The size of preprocessing_emotional_Rem_<wbr class="">ds{1}.trial{1} </span><span style="font-family:'Courier New';font-size:10pt" class="">is
 3x3751 (channels, data points). Below is the configuration structure and the error message. The ft_mvaranalysis function works if I do not use the sliding window approach. I tried to use different cfg.toi and cfg.t_ftimwin but I could not find a solution.
 I hope you can help me.</span></div>
<p class="MsoNormal" style="margin:0cm 0cm 0.0001pt;line-height:normal;background:white;font-size:11pt;font-family:Calibri,sans-serif">
<span lang="EN-US" style="font-size:10pt;font-family:'Courier New'" class=""><span class=""> </span></span></p>
<div style="margin:0cm 0cm 0.0001pt;line-height:normal;background-color:white;font-size:11pt;font-family:Calibri,sans-serif;background-position:initial initial;background-repeat:initial initial" class="">
<span lang="EN-US" style="font-size:10pt;font-family:'Courier New'" class="">Best wishes,<span class=""></span></span></div>
<p class="MsoNormal" style="margin:0cm 0cm 0.0001pt;line-height:normal;background:white;font-size:11pt;font-family:Calibri,sans-serif">
<span lang="EN-US" style="font-size:10pt;font-family:'Courier New'" class=""><span class=""> </span></span></p>
<div style="margin:0cm 0cm 0.0001pt;line-height:normal;background-color:white;font-size:11pt;font-family:Calibri,sans-serif;background-position:initial initial;background-repeat:initial initial" class="">
<span lang="EN-US" style="font-size:10pt;font-family:'Courier New'" class="">Manuela Costa<span class=""></span></span></div>
<p class="MsoNormal" style="margin:0cm 0cm 0.0001pt;line-height:normal;font-size:11pt;font-family:Calibri,sans-serif">
<span style="font-size:10pt;font-family:'Courier New'" class=""><span class=""> </span></span></p>
<div style="margin:0cm 0cm 0.0001pt;line-height:normal;font-size:11pt;font-family:Calibri,sans-serif" class="">
<span lang="EN-US" style="font-size:10pt;font-family:'Courier New'" class="">Configuration structure:<span class=""></span></span></div>
<p class="MsoNormal" style="margin:0cm 0cm 0.0001pt;line-height:normal;font-size:11pt;font-family:Calibri,sans-serif">
<span lang="EN-US" style="font-size:10pt;font-family:'Courier New'" class=""><span class=""> </span></span></p>
<div style="margin:0cm 0cm 0.0001pt;line-height:normal;font-size:11pt;font-family:Calibri,sans-serif" class="">
<span lang="EN-US" style="font-size:10pt;font-family:'Courier New'" class="">cfg = [];<span class=""></span></span></div>
<div style="margin:0cm 0cm 0.0001pt;line-height:normal;font-size:11pt;font-family:Calibri,sans-serif" class="">
<span lang="EN-US" style="font-size:10pt;font-family:'Courier New'" class=""><span class="">   
</span>cfg.toolbox = 'bsmart';<span class=""></span></span></div>
<div style="margin:0cm 0cm 0.0001pt;line-height:normal;font-size:11pt;font-family:Calibri,sans-serif" class="">
<span lang="EN-US" style="font-size:10pt;font-family:'Courier New'" class=""><span class="">   
</span>cfg.order<span class="">   </span>= 10;<span class=""></span></span></div>
<div style="margin:0cm 0cm 0.0001pt;line-height:normal;font-size:11pt;font-family:Calibri,sans-serif" class="">
<span lang="EN-US" style="font-size:10pt;font-family:'Courier New'" class=""><span class="">   
</span>cfg.toi<span class="">       </span>= -0.5:0.01:3; %% the time points at which the windows are centered<span class=""></span></span></div>
<div style="margin:0cm 0cm 0.0001pt;line-height:normal;font-size:11pt;font-family:Calibri,sans-serif" class="">
<span lang="EN-US" style="font-size:10pt;font-family:'Courier New'" class=""><span class="">   
</span>cfg.t_ftimwin = 0.25; %% length of time window in second<span class=""></span></span></div>
<div style="margin:0cm 0cm 0.0001pt;line-height:normal;font-size:11pt;font-family:Calibri,sans-serif" class="">
<span lang="EN-US" style="font-size:10pt;font-family:'Courier New'" class=""><span class="">   
</span>mdata_emotional_Rem{subj} = ft_mvaranalysis(cfg, preprocessing_emotional_Rem_ds<wbr class="">{subj});<span class=""></span></span></div>
<p class="MsoNormal" style="margin:0cm 0cm 0.0001pt;line-height:normal;font-size:11pt;font-family:Calibri,sans-serif">
<span lang="EN-US" style="font-size:10pt;font-family:'Courier New'" class=""><span class=""> </span></span></p>
<p class="MsoNormal" style="margin:0cm 0cm 0.0001pt;line-height:normal;font-size:11pt;font-family:Calibri,sans-serif">
<span lang="EN-US" style="font-size:10pt;font-family:'Courier New'" class=""><span class=""> </span></span></p>
<p class="MsoNormal" style="margin:0cm 0cm 0.0001pt;line-height:normal;font-size:11pt;font-family:Calibri,sans-serif">
<span lang="EN-US" style="font-size:10pt;font-family:'Courier New'" class=""><span class=""> </span></span></p>
<pre style="margin:0cm 0cm 0.0001pt;font-size:10pt;font-family:"Courier New"" class=""><span class="">Error message:<span class=""></span></span></pre>
<p class="MsoNormal" style="margin:0cm 0cm 0.0001pt;line-height:normal;font-size:11pt;font-family:Calibri,sans-serif">
<span lang="EN-US" style="font-size:10pt;font-family:'Courier New'" class=""><span class=""> </span></span></p>
<p class="MsoNormal" style="margin:0cm 0cm 0.0001pt;line-height:normal;font-size:11pt;font-family:Calibri,sans-serif">
<span lang="EN-US" style="font-size:10pt;font-family:'Courier New'" class=""><span class=""> </span></span></p>
<div style="margin:0cm 0cm 0.0001pt;line-height:normal;background-color:white;font-size:11pt;font-family:Calibri,sans-serif;background-position:initial initial;background-repeat:initial initial" class="">
<span lang="EN-US" style="font-size:10pt;font-family:'Courier New'" class="">Matrix dimensions must agree.<span class=""></span></span></div>
<p class="MsoNormal" style="margin:0cm 0cm 0.0001pt;line-height:normal;font-size:11pt;font-family:Calibri,sans-serif">
<span lang="EN-US" style="font-size:10pt;font-family:'Courier New'" class=""><span class=""> </span></span></p>
<div style="margin:0cm 0cm 0.0001pt;line-height:normal;font-size:11pt;font-family:Calibri,sans-serif" class="">
<span lang="EN-US" style="font-size:10pt;font-family:'Courier New'" class="">Error in ft_mvaranalysis (line 185)<span class=""></span></span></div>
<div style="margin:0cm 0cm 0.0001pt;line-height:normal;font-size:11pt;font-family:Calibri,sans-serif" class="">
<span lang="EN-US" style="font-size:10pt;font-family:'Courier New'" class="">latency(k,:) = cfg.toi + cfg.t_ftimwin.*[-0.5 0.5];<span class=""></span></span></div>
<p class="MsoNormal" style="margin:0cm 0cm 0.0001pt;line-height:normal;font-size:11pt;font-family:Calibri,sans-serif">
<span lang="EN-US" style="font-size:10pt;font-family:'Courier New'" class=""><span class=""> </span></span></p>
<div style="margin:0cm 0cm 0.0001pt;line-height:normal;background-color:white;font-size:11pt;font-family:Calibri,sans-serif;background-position:initial initial;background-repeat:initial initial" class="">
<span lang="EN-US" style="font-size:10pt;font-family:'Courier New'" class="">Error in Step2_Calculate_Granger_time_f<wbr class="">req(line 108)<span class=""></span></span></div>
<div style="margin:0cm 0cm 0.0001pt;line-height:normal;background-color:white;font-size:11pt;font-family:Calibri,sans-serif;background-position:initial initial;background-repeat:initial initial" class="">
<span lang="EN-US" style="font-size:10pt;font-family:'Courier New'" class="">    mdata_emotional_Rem{subj} = ft_mvaranalysis(cfg,preprocess<wbr class="">ing_emotional_Rem_ds{subj});<span class=""></span></span></div>
<p class="MsoNormal" style="margin:0cm 0cm 0.0001pt;line-height:normal;font-size:11pt;font-family:Calibri,sans-serif">
<span lang="EN-US" style="font-size:10pt;font-family:'Courier New'" class=""><span class=""> </span></span></p>
<div style="margin:0cm 0cm 0.0001pt;line-height:normal;font-size:11pt;font-family:Calibri,sans-serif" class="">
<br class="">
<br class="">
</div>
</div>
</div>
</div>
</div>
______________________________<wbr class="">_________________<br class="">
fieldtrip mailing list<br class="">
<a href="https://mailman.science.ru.nl/mailman/listinfo/fieldtrip" target="_blank" class="">https://mailman.science.ru.nl/<wbr class="">mailman/listinfo/fieldtrip</a><br class="">
<a href="https://doi.org/10.1371/journal.pcbi.1002202" target="_blank" class="">https://doi.org/10.1371/<wbr class="">journal.pcbi.1002202</a><br class="">
</div>
</blockquote>
</div>
<br class="">
</div>
</div>
<br class="">
______________________________<wbr class="">_________________<br class="">
fieldtrip mailing list<br class="">
<a href="https://mailman.science.ru.nl/mailman/listinfo/fieldtrip" rel="noreferrer" target="_blank" class="">https://mailman.science.ru.nl/<wbr class="">mailman/listinfo/fieldtrip</a><br class="">
<a href="https://doi.org/10.1371/journal.pcbi.1002202" rel="noreferrer" target="_blank" class="">https://doi.org/10.1371/<wbr class="">journal.pcbi.1002202</a><br class="">
<br class="">
</blockquote>
</div>
<br class="">
</div>
_______________________________________________<br class="">
fieldtrip mailing list<br class="">
<a href="https://mailman.science.ru.nl/mailman/listinfo/fieldtrip" class="">https://mailman.science.ru.nl/mailman/listinfo/fieldtrip</a><br class="">
https://doi.org/10.1371/journal.pcbi.1002202<br class="">
</div>
</blockquote>
</div>
<br class="">
</div>
</body>
</html>