<div dir="ltr">Hi Julien,<div><br></div><div><div>I suppose you may to try to use cfg.keeptapers = 'yes' with ft_freqanalysis. It's working for me.</div></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">Best,</span></div><div><span style="font-family:arial,sans-serif;font-size:13px">Maxim Lukoyanov</span></div><div class="gmail_extra"><br><br><div class="gmail_quote">
2014-02-14 2:18 GMT+04:00 Julien Catanese <span dir="ltr"><<a href="mailto:catanese.julien@gmail.com" target="_blank">catanese.julien@gmail.com</a>></span>:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
<div dir="ltr">It works fine if I artificially slice the data into trials.  <div><span style="font-family:arial,sans-serif;font-size:12.800000190734863px"><br></span></div><div><span style="font-family:arial,sans-serif;font-size:12.800000190734863px">(nb: MATLAB's mscohere() works fine without chopping into trials, so I was guessing it was also possible with the fieldtrip functions, but apparently not, sorry about that, not a big deal).    </span><br>


<div><div><div><br></div><div>Julien C <br><div> </div></div></div></div></div></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Wed, Jan 22, 2014 at 1:22 PM, Julien Catanese <span dir="ltr"><<a href="mailto:catanese.julien@gmail.com" target="_blank">catanese.julien@gmail.com</a>></span> wrote:<br>


<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div dir="ltr"><div><br></div><div>Hi dear FieldTrip community, </div>
<div><br></div><div>I'm trying to get the coherence spectrum between 2 LFP signals (based on the tutorial: "Analysis of sensor- and source-level connectivity"). </div>


<div><br></div><div>This is sleep data, so I have only one long "trial" generated with ft_redefinetrial().</div><div><br></div><div>I can run ft_freqanalysis() without problems, but both for 'mtmconvol' and 'mtmfft' the next step, ft_connectivityanalysis(), fails:  </div>



<div> </div><div>1/ using 'mtmconvol':  the cohspctrum consists of all '1' (the same happens when using 'fourier' instead of 'powandcsd')</div><div>2/ using 'mtmfft': "Error using ft_connectivityplot (line 99) the data should have a dimord of chan_chan_freq or chancmb_freq"</div>



<div><br></div><div>How can I get a coherence spectrum for this data? Do I have to artificially chop it up into say, 2-second "fake trials"? </div><div><br></div><div>notice that MATLAB's mscohere() works fine on the same data (so data are ok). </div>



<div><br></div><div><br></div><div><br></div><div>More details below:</div><div><br></div><div> 1/ using mtmconvol :  </div><div><br></div><div>%% starting point: loaded data </div><div> data = </div><div>            hdr: [1x1 struct]</div>



<div>          label: {'LFP1'  'LFP2'}</div><div>           time: {[1x200000 double]}</div><div>          trial: {[2x200000 double]}</div><div>        fsample: 2000</div><div>            cfg: [1x1 struct]</div>



<div>     sampleinfo: [1 200000]</div><div><br></div><div>%% make one long trial</div><div>cfg = [];</div><div>cfg.trl = [1 200000 0];</div><div>data_faketrl = ft_redefinetrial(cfg,data); </div><div><br></div><div>%% do frequqency anlaysis</div>



<div>    cfg              = [];</div><div>    cfg.output       = 'powandcsd';</div><div>    cfg.method       = 'mtmconvol';</div><div>    cfg.taper        = 'hanning';</div><div>    cfg.foi          = 1:1:150;</div>



<div>    cfg.t_ftimwin    =  ones(size(cfg.foi)).*2; % 2-second window</div><div>    cfg.toi          =  0:1:10;</div><div>    cfg.keeptrials   = 'yes';</div><div>    cfg.channel      = {'LFP1', 'LFP2'};</div>



<div>    cfg.channelcmb   = {'LFP1', 'LFP2'};</div><div>   </div><div>>> freq = ft_freqanalysis(cfg, data_faketrl)</div><div><br></div><div>freq = </div><div>        label: {'LFP1'  'LFP2'}</div>



<div>        dimord: 'rpt_chan_freq_time'</div><div>          freq: [1x150 double]</div><div>          time: [0 1 2 3 4 5 6 7 8 9 10]</div><div>     powspctrm: [4-D double]</div><div>      labelcmb: {'LFP1'  'LFP2'}</div>



<div>     crsspctrm: [4-D double]</div><div>     cumtapcnt: [1x150 double]</div><div>           cfg: [1x1 struct]</div><div><br></div><div>%% coherence spectrum has all ones</div><div>cfg           = [];</div><div>cfg.method    = 'coh';</div>



<div>coh           = ft_connectivityanalysis(cfg, freq);</div><div><br></div><div> coh = </div><div> </div><div>      labelcmb: {'LFP1'  'LFP2'}</div><div>        dimord: 'chan_freq_time'</div><div>



     cohspctrm: [1x150x11 double]</div><div>          freq: [1x150 double]</div><div>          time: [0 1 2 3 4 5 6 7 8 9 10]</div><div>           dof: 150</div><div>           cfg: [1x1 struct]</div><div><br></div><div>


% coh.cohspctrm(:,:,2:end) is all ones --> fail</div>
<div><br></div><div>2/ using mtmfft: </div><div>%%</div><div>cfg              = [];</div><div>cfg.output       = 'powandcsd'</div><div>cfg.method       = 'mtmfft';</div><div>cfg.taper        = 'hanning';</div>



<div>cfg.foi          = 1:1:150;</div><div>cfg.channel      = {'LFP1', 'LFP2'};</div><div>cfg.channelcmb   = {'LFP1', 'LFP2'};</div><div><br></div><div>>> freq = ft_freqanalysis(cfg, data_faketrl)</div>



<div><br></div><div>freq = </div><div><br></div><div>        label: {'LFP1'  'LFP2'}</div><div>       dimord: 'rpt_chan_freq'</div><div>         freq: [1x150 double]</div><div>    powspctrm: [1x2x150 double]</div>



<div>     labelcmb: {'LFP1'  'LFP2'}</div><div>    crsspctrm: [1x1x150 double]</div><div>    cumsumcnt: 200000</div><div>    cumtapcnt: 1</div><div>          cfg: [1x1 struct]</div><div><span style="white-space:pre-wrap">         </span>  </div>



<div>%% coherence spectrum fails:</div><div>cfg           = [];</div><div>cfg.parameter = 'cohspctrm';</div><div>cfg.channelcmb   = {'LFP1', 'LFP2'};</div><div><br></div><div>>> ft_connectivityplot(cfg,  coh);</div>



<div><br></div><div>Error using ft_connectivityplot (line 99)</div><div>the data should have a dimord of chan_chan_freq or chancmb_freq</div><div><br></div><div>coh = </div><div>     labelcmb: {'LFP1'  'LFP2'}</div>



<div>       dimord: 'chan_freq'</div><div>    cohspctrm: [1x150 double]</div><div>         freq: [1x150 double]</div><div>          dof: 1</div><div>          cfg: [1x1 struct]</div><div><br></div><div>>> unique([coh.cohspctrm(:)])</div>



<div><br></div><div>ans =</div><div><br></div><div>   1.000000000000000</div><div>   1.000000000000000</div><div>   1.000000000000000</div><div>   1.000000000000000</div><div>   1.000000000000000</div><div><br></div><div>



<br></div><div>Thanks for your help,  </div><div><br></div><div>Julien C</div><span class=""><font color="#888888"><span><font color="#888888"><div><br></div>-- <br><font size="1"><font><i>Dr. Julien Catanese<br></i></font></font><font size="1"><i>VanderMeerLab post-doc.   <br>


University of Waterloo, Ontario, Canada.<br>
</i></font><div><font size="1"><i>cell : <a href="tel:%2B1%20%28519%29%20781%207575" value="+15197817575" target="_blank">+1 (519) 781 7575</a></i></font></div><div><font size="1"><i>tel lab : <a href="tel:%2B1%20%28519%29%20888%204567%20ext%2031354" value="+15198884567" target="_blank">+1 (519) 888 4567 ext 31354</a></i></font></div>



</font></span></font></span></div><span class=""><font color="#888888">
</font></span></blockquote></div><span class=""><font color="#888888"><br><br clear="all"><div><br></div>-- <br><font size="1"><font><i>Dr. Julien Catanese<br></i></font></font><font size="1"><i>VanderMeerLab post-doc.   <br>
University of Waterloo, Ontario, Canada.<br></i></font><div>

<font size="1"><i>cell : +1 (519) 781 7575</i></font></div><div><font size="1"><i>tel lab : +1 (519) 888 4567 ext 31354</i></font></div>
</font></span></div>
<br>_______________________________________________<br>
fieldtrip mailing list<br>
<a href="mailto:fieldtrip@donders.ru.nl">fieldtrip@donders.ru.nl</a><br>
<a href="http://mailman.science.ru.nl/mailman/listinfo/fieldtrip" target="_blank">http://mailman.science.ru.nl/mailman/listinfo/fieldtrip</a><br></blockquote></div><br></div></div>