<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class="">
Hi Sergio,
<div class=""><br class="">
</div>
<div class="">Yes, you are doing something wrong:</div>
<div class=""><br class="">
<div>
<blockquote type="cite" class="">
<div class="">
<div dir="ltr" style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 14px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;" class="">
<div class=""><font class="">        % select the portion of the data I want to compute the wPLI for  </font></div>
<div class=""><font class="">        cfg               = [ ];<br class="">
        cfg.latency   = .15:.25;                          <<<<<<<<<<<<<< if I use 0:1 or 1:1.5,<span class="Apple-converted-space"> </span><i class="">ft_freqanaylisis</i><span class="Apple-converted-space"> </span>runs without any problem, but if I use any
 other latency within 1 second it doesn't work.<br class="">
        data             = ft_selectdata(cfg,data);</font></div>
<div class=""><font class="">        </font></div>
<div class=""><font class="">       % here's the output structure</font></div>
<div class="">
<blockquote style="margin: 0px 0px 0px 40px; border: none; padding: 0px;" class="">
<div class=""><font class="">data =</font></div>
</blockquote>
<blockquote style="margin: 0px 0px 0px 40px; border: none; padding: 0px;" class="">
<blockquote style="margin: 0px 0px 0px 40px; border: none; padding: 0px;" class="">
<blockquote style="margin: 0px 0px 0px 40px; border: none; padding: 0px;" class="">
<blockquote style="margin: 0px 0px 0px 40px; border: none; padding: 0px;" class="">
<div class=""><font class=""><br class="">
</font></div>
</blockquote>
</blockquote>
</blockquote>
</blockquote>
<blockquote style="margin: 0px 0px 0px 40px; border: none; padding: 0px;" class="">
<blockquote style="margin: 0px 0px 0px 40px; border: none; padding: 0px;" class="">
<font class="">struct with fields:<br class="">
</font></blockquote>
</blockquote>
<blockquote style="margin: 0px 0px 0px 40px; border: none; padding: 0px;" class="">
<blockquote style="margin: 0px 0px 0px 40px; border: none; padding: 0px;" class="">
<div class=""><font class=""><br class="">
</font></div>
</blockquote>
<blockquote style="margin: 0px 0px 0px 40px; border: none; padding: 0px;" class="">
<div class=""><font class="">      fsample: 250</font></div>
</blockquote>
<blockquote style="margin: 0px 0px 0px 40px; border: none; padding: 0px;" class="">
<div class=""><font class="">      trial: {1×117 cell}</font></div>
</blockquote>
<blockquote style="margin: 0px 0px 0px 40px; border: none; padding: 0px;" class="">
<div class=""><font class="">      time: {1×117 cell}</font></div>
</blockquote>
<blockquote style="margin: 0px 0px 0px 40px; border: none; padding: 0px;" class="">
<div class=""><font class="">      label: {100×1 cell}</font></div>
</blockquote>
<blockquote style="margin: 0px 0px 0px 40px; border: none; padding: 0px;" class="">
<div class=""><font class="">      cfg: [1×1 struct]</font></div>
<div class=""><font class=""><br class="">
</font></div>
<div class="">
<blockquote style="margin: 0px 0px 0px 40px; border: none; padding: 0px;" class="">
<font class="">data.trial<br class="">
</font></blockquote>
<blockquote style="margin: 0px 0px 0px 40px; border: none; padding: 0px;" class="">
<blockquote style="margin: 0px 0px 0px 40px; border: none; padding: 0px;" class="">
<div class=""><font class=""><br class="">
ans =<br class="">
  1×117 cell array<br class="">
  Columns 1 through 9<br class="">
<br class="">
</font></div>
</blockquote>
</blockquote>
<blockquote style="margin: 0px 0px 0px 40px; border: none; padding: 0px;" class="">
<blockquote style="margin: 0px 0px 0px 40px; border: none; padding: 0px;" class="">
<blockquote style="margin: 0px 0px 0px 40px; border: none; padding: 0px;" class="">
<div class=""><font class="">    {100×1 double}    {100×1251 double}    {100×1251 double}   % averaged first trial in the 2nd dimension instead of selecting the time interval of interest</font></div>
</blockquote>
</blockquote>
</blockquote>
</div>
</blockquote>
</blockquote>
</div>
</div>
</div>
</blockquote>
<div><br class="">
</div>
<div><br class="">
</div>
<div>Your first trial only has a single sample. It is impossible to spectrally transform a single sample time course, this causes all kinds of low-level errors, the one you reported below.</div>
<div><br class="">
</div>
<div>I don’t know what you mean with the statement that ft_selectdata does not work with ‘any other latency within 1 second’, but I suggest you first inspect your data, and specifically the time axes of the individual trials. </div>
<div><br class="">
</div>
<div>Best wishes,</div>
<div>Jan-Mathijs</div>
<div><br class="">
</div>
<div><br class="">
</div>
<br class="">
<blockquote type="cite" class="">
<div class="">
<div dir="ltr" style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 14px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;" class="">
<div class="">
<blockquote style="margin: 0px 0px 0px 40px; border: none; padding: 0px;" class="">
<blockquote style="margin: 0px 0px 0px 40px; border: none; padding: 0px;" class="">
<div class="">
<blockquote style="margin: 0px 0px 0px 40px; border: none; padding: 0px;" class="">
<blockquote style="margin: 0px 0px 0px 40px; border: none; padding: 0px;" class="">
<div class=""><font class=""><br class="">
</font></div>
</blockquote>
</blockquote>
<blockquote style="margin: 0px 0px 0px 40px; border: none; padding: 0px;" class="">
<font class="">data.time<br class="">
</font></blockquote>
<blockquote style="margin: 0px 0px 0px 40px; border: none; padding: 0px;" class="">
<blockquote style="margin: 0px 0px 0px 40px; border: none; padding: 0px;" class="">
<div class=""><font class="">ans =<br class="">
  1×117 cell array<br class="">
  Columns 1 through 10<br class="">
<br class="">
</font></div>
</blockquote>
</blockquote>
<blockquote style="margin: 0px 0px 0px 40px; border: none; padding: 0px;" class="">
<blockquote style="margin: 0px 0px 0px 40px; border: none; padding: 0px;" class="">
<blockquote style="margin: 0px 0px 0px 40px; border: none; padding: 0px;" class="">
<div class=""><font class="">    {[0.1480]}    {1×1251 double}    {1×1251 double}</font></div>
</blockquote>
</blockquote>
</blockquote>
</div>
</blockquote>
</blockquote>
<font class="">       <span class="Apple-converted-space"> </span><br class="">
        % Now call the ft_freqanalysis function<span class="Apple-converted-space"> </span><br class="">
        cfg                  = [ ];<br class="">
        cfg.output       = 'fourier';<br class="">
        cfg.method     = 'mtmfft';<br class="">
        cfg.taper         = 'dpss';<br class="">
        cfg.foi             = linspace(1,31,60);<br class="">
        cfg.tapsmofrq = 4;<br class="">
        tf_data            = ft_freqanalysis(cfg,data);</font></div>
<div class=""><font class=""><br class="">
</font></div>
<blockquote style="margin: 0px 0px 0px 40px; border: none; padding: 0px;" class="">
<div class=""><font class="">Error using dpss>parseinputs (line 308)</font></div>
<div class=""><font class="">Time-bandwidth product NW must be a positive number.</font></div>
</blockquote>
<div class=""><font class=""><br class="">
</font></div>
<blockquote style="margin: 0px 0px 0px 40px; border: none; padding: 0px;" class="">
<div class=""><font class="">Error in dpss (line 62)</font></div>
<div class=""><font class="">[method,k,Ni,traceFlag,N,NW] = parseinputs(N,NW,varargin{:});</font></div>
</blockquote>
<div class=""><font class=""><br class="">
</font></div>
<blockquote style="margin: 0px 0px 0px 40px; border: none; padding: 0px;" class="">
<div class=""><font class="">Error in ft_specest_mtmfft>double_dpss (line 362)</font></div>
<div class=""><font class="">tap = dpss(double(a), double(b), varargin{:});</font></div>
</blockquote>
<div class=""><font class=""><br class="">
</font></div>
<blockquote style="margin: 0px 0px 0px 40px; border: none; padding: 0px;" class="">
<div class=""><font class="">Error in ft_specest_mtmfft (line 151)</font></div>
</blockquote>
<blockquote style="margin: 0px 0px 0px 40px; border: none; padding: 0px;" class="">
<div class=""><font class="">      tap = double_dpss(ndatsample,ndatsample*(tapsmofrq./fsample))';</font></div>
</blockquote>
<div class=""><font class=""><br class="">
</font></div>
<blockquote style="margin: 0px 0px 0px 40px; border: none; padding: 0px;" class="">
<div class=""><font class="">Error in ft_freqanalysis (line 563)</font></div>
</blockquote>
<blockquote style="margin: 0px 0px 0px 40px; border: none; padding: 0px;" class="">
<div class=""><font class="">      [spectrum,ntaper,foi] = ft_specest_mtmfft(dat, time, 'taper', cfg.taper, options{:}, 'feedback', fbopt);</font></div>
</blockquote>
<div class=""><font class=""><br class="">
</font></div>
<blockquote style="margin: 0px 0px 0px 40px; border: none; padding: 0px;" class="">
<div class=""><font class="">Error in Connectivity_wPLI (line 68)</font></div>
</blockquote>
<blockquote style="margin: 0px 0px 0px 40px; border: none; padding: 0px;" class="">
<div class=""><font class="">       tf_data           = ft_freqanalysis(cfg,data);</font></div>
</blockquote>
<div class=""><br class="">
</div>
<blockquote style="margin: 0px 0px 0px 40px; border: none; padding: 0px;" class="">
<br class="">
</blockquote>
<div class="">All best,</div>
<div class=""><br class="">
</div>
<div class="">
<div class="">
<div dir="ltr" data-smartmail="gmail_signature" class="">
<div dir="ltr" class=""><font size="4" class=""><b class="">Sergio. </b></font><br class="">
<div class="">
<div class=""><br class="">
<div class=""></div>
<div class=""></div>
</div>
</div>
</div>
</div>
</div>
<br class="">
</div>
</div>
<br style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 14px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;" class="">
<div class="gmail_quote" style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 14px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;">
<div dir="ltr" class="gmail_attr">El mié, 15 sept 2021 a las 15:09, SERGIO OSORIO GALEANO (<<a href="mailto:srosorio@uc.cl" target="_blank" class="">srosorio@uc.cl</a>>) escribió:<br class="">
</div>
<blockquote class="gmail_quote" style="margin: 0px 0px 0px 0.8ex; border-left-width: 1px; border-left-style: solid; border-left-color: rgb(204, 204, 204); padding-left: 1ex;">
<div dir="ltr" class="">
<blockquote style="margin: 0px 0px 0px 40px; border: none; padding: 0px;" class="">
<div class="">Yes, you made a mistake in the (assumptions underlying) the implementation: the cfg.toi that you supply before ft_freqanalysis is not going to have any effect if you use ‘mtmfft’ as a method, since this method just provides a single estimate of
 the spectrum using the whole ’trial’ for the estimation.</div>
</blockquote>
<div class=""><br class="">
</div>
Oh, that makes perfect sense. Cheers Jan! Really appreciate it. 
<div class=""><b class=""><br clear="all" class="">
</b>
<div class="">
<div dir="ltr" class="">
<div dir="ltr" class=""><b class="">Sergio.</b>
<div class="">
<div class=""><br class="">
<div class=""></div>
<div class=""></div>
</div>
</div>
</div>
</div>
</div>
<br class="">
</div>
</div>
<br class="">
<div class="gmail_quote">
<div dir="ltr" class="gmail_attr">El mié, 15 sept 2021 a las 14:29, Schoffelen, J.M. (Jan Mathijs) via fieldtrip (<<a href="mailto:fieldtrip@science.ru.nl" target="_blank" class="">fieldtrip@science.ru.nl</a>>) escribió:<br class="">
</div>
<blockquote class="gmail_quote" style="margin: 0px 0px 0px 0.8ex; border-left-width: 1px; border-left-style: solid; border-left-color: rgb(204, 204, 204); padding-left: 1ex;">
Hi Sergio,<br class="">
><span class="Apple-converted-space"> </span><br class="">
> 1) Regardless of whether I use my full time window of interest (0-1.5 s) or whether I estimate wPLI for two separate shorter time windows (0-.7 s and .7-1.5 s), the results are always identical to one another. Is this normal behaviour in wPLI analyses or
 is there something potentially wrong with how I've implemented it?<span class="Apple-converted-space"> </span><br class="">
<br class="">
Yes, you made a mistake in the (assumptions underlying) the implementation: the cfg.toi that you supply before ft_freqanalysis is not going to have any effect if you use ‘mtmfft’ as a method, since this method just provides a single estimate of the spectrum
 using the whole ’trial’ for the estimation.<br class="">
<br class="">
> 2) I notice that wPLI values are way lower for low-frequencies (4-7hz) than for higher-frequencies (8-12hz and 15-30hz). While this could be a real effect associated with my task, the fact that this result is consistent across different conditions makes me
 wonder whether I've done something wrong in the ft_freqanalysis configuration.<span class="Apple-converted-space"> </span><br class="">
<br class="">
I think that this is just a property of the data.<br class="">
<br class="">
Best wishes,<br class="">
Jan-Mathijs<br class="">
<br class="">
<br class="">
><span class="Apple-converted-space"> </span><br class="">
> Thanks a lot in advance for any help anyone can provide!<span class="Apple-converted-space"> </span><br class="">
><span class="Apple-converted-space"> </span><br class="">
> -----------<br class="">
><span class="Apple-converted-space"> </span><br class="">
> cfg                 = [ ];<br class="">
> data               = ft_preprocessing(cfg,rwdata);<br class="">
>         <br class="">
> %resample data<br class="">
> cfg                      = [ ];<br class="">
> cfg.resamplefs   = 250;<br class="">
> data                    = ft_resampledata(cfg, data);<br class="">
><span class="Apple-converted-space"> </span><br class="">
> data =<br class="">
>   struct with fields:<br class="">
><span class="Apple-converted-space"> </span><br class="">
>       fsample: 250<br class="">
>       trial:   {1×117 cell}<br class="">
>       time:  {1×117 cell}<br class="">
>       label: {100×1 cell}<br class="">
>       cfg:    [1×1 struct]<br class="">
>         <br class="">
> % next, call the ft_freqanalysis function in our source data<br class="">
> cfg                     = [ ];<br class="">
> cfg.output          = 'fourier';<br class="">
> cfg.method        = 'mtmfft';<br class="">
> cfg.taper            = 'dpss';<br class="">
> cfg.foi                 = linspace(4,30,30);<br class="">
> cfg.tapsmofrq     = 4;<br class="">
> cfg.toi                 = 0:.02:1.5;   % try 0:.02:.7 and .7:.02:1.5<br class="">
> tf_data                = ft_freqanalysis(cfg,data);<br class="">
><span class="Apple-converted-space"> </span><br class="">
> tf_data =<span class="Apple-converted-space"> </span><br class="">
>   struct with fields:<br class="">
><span class="Apple-converted-space"> </span><br class="">
>             label:     {100×1 cell}<br class="">
>             dimord: 'rpttap_chan_freq'<br class="">
>             freq:       [1×30 double]<br class="">
>             fourierspctrm: [4563×100×30 double]<br class="">
>             cumsumcnt: [117×1 double]<br class="">
>             cumtapcnt:   [117×1 double]<br class="">
>             cfg:               [1×1 struct]<br class="">
>         <br class="">
> % estimate wPLI values<br class="">
> cfg                    = [ ];<br class="">
> cfg.method       = 'wpli_debiased';<span class="Apple-converted-space"> </span><br class="">
> connect_data   = ft_connectivityanalysis(cfg,tf_data);<br class="">
><span class="Apple-converted-space"> </span><br class="">
> connect_data =<span class="Apple-converted-space"> </span><br class="">
>   struct with fields:<br class="">
><span class="Apple-converted-space"> </span><br class="">
>                label:     {100×1 cell}<br class="">
>                dimord:  'chan_chan_freq'<br class="">
>                wpli_debiasedspctrm: [100×100×30 double]<br class="">
>                freq:  [1×30 double]<br class="">
>                cfg:   [1×1 struct]<br class="">
><span class="Apple-converted-space"> </span><br class="">
> Best,<br class="">
><span class="Apple-converted-space"> </span><br class="">
> Sergio.<br class="">
><span class="Apple-converted-space"> </span><br class="">
> _______________________________________________<br class="">
> fieldtrip mailing list<br class="">
><span class="Apple-converted-space"> </span><a href="https://mailman.science.ru.nl/mailman/listinfo/fieldtrip" rel="noreferrer" target="_blank" class="">https://mailman.science.ru.nl/mailman/listinfo/fieldtrip</a><br class="">
><span class="Apple-converted-space"> </span><a href="https://urldefense.com/v3/__https://doi.org/10.1371/journal.pcbi.1002202__;!!HJOPV4FYYWzcc1jazlU!v6GcyYsHF6VUmzXm8BB3M6rFfwWnSYCxD7hg5IzSXjBU2SvnlyfRyykO5BhpyzahCLvCtBzdjU2HPc4$" rel="noreferrer" target="_blank" class="">https://urldefense.com/v3/__https://doi.org/10.1371/journal.pcbi.1002202__;!!HJOPV4FYYWzcc1jazlU!v6GcyYsHF6VUmzXm8BB3M6rFfwWnSYCxD7hg5IzSXjBU2SvnlyfRyykO5BhpyzahCLvCtBzdjU2HPc4$</a><span class="Apple-converted-space"> </span><br class="">
<br class="">
<br 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/mailman/listinfo/fieldtrip</a><br class="">
<a href="https://urldefense.com/v3/__https://doi.org/10.1371/journal.pcbi.1002202__;!!HJOPV4FYYWzcc1jazlU!usewI1PbndK5LPja3Ngfqvfn3tRpdRV73OimKW6NrcohdNrX6G3vkgQuzYR9QRioc7pHSLvRNfscdfs$" rel="noreferrer" target="_blank" class="">https://doi.org/10.1371/journal.pcbi.1002202</a><br class="">
</blockquote>
</div>
</blockquote>
</div>
<span style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 14px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none; float: none; display: inline !important;" class="">_______________________________________________</span><br style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 14px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;" class="">
<span style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 14px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none; float: none; display: inline !important;" class="">fieldtrip
 mailing list</span><br style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 14px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;" class="">
<span style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 14px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none; float: none; display: inline !important;" class=""><a href="https://mailman.science.ru.nl/mailman/listinfo/fieldtrip" class="">https://mailman.science.ru.nl/mailman/listinfo/fieldtrip</a></span><br style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 14px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;" class="">
<a href="https://urldefense.com/v3/__https://doi.org/10.1371/journal.pcbi.1002202__;!!HJOPV4FYYWzcc1jazlU!usewI1PbndK5LPja3Ngfqvfn3tRpdRV73OimKW6NrcohdNrX6G3vkgQuzYR9QRioc7pHSLvRNfscdfs$" style="font-family: Helvetica; font-size: 14px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px;" class="">https://urldefense.com/v3/__https://doi.org/10.1371/journal.pcbi.1002202__;!!HJOPV4FYYWzcc1jazlU!usewI1PbndK5LPja3Ngfqvfn3tRpdRV73OimKW6NrcohdNrX6G3vkgQuzYR9QRioc7pHSLvRNfscdfs$</a><span style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 14px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none; float: none; display: inline !important;" class=""></span></div>
</blockquote>
</div>
<br class="">
</div>
</body>
</html>