[FieldTrip] Questions on Functional Connectivity results using debiased wPLI

Schoffelen, J.M. (Jan Mathijs) janmathijs.schoffelen at donders.ru.nl
Thu Sep 23 09:43:57 CEST 2021


Hi Sergio,

As an addition to the previous e-mail: please define cfg.latency as a 2-element vector with a begin and end point, not as a multiple-element vector, as per the documentation.

Best wishes,
Jan-Mathijs

On 23 Sep 2021, at 03:08, SERGIO OSORIO GALEANO via fieldtrip <fieldtrip at science.ru.nl<mailto:fieldtrip at science.ru.nl>> wrote:

Dear Jan,

Here's a follow up question on this thread.

I understand now that 'mtmfft' provides an estimate of the spectrum using the whole trial. I also understand that if I want to estimate the wPLI for a specific time window within my trial, I should either 1) use a time-resolved method when calling ft_freqanalysis (e.g. wavelet) or 2) call ft_selectdata prior to using 'mtmfft' in ft_freqanalysis.

Because it is less computationally demanding, I tried the second option. However, I've noticed that ft_freqanalysis throws an error if I try to use ft_selectdata with a time window shorter than one second. After inspecting the output structure of ft_selectdata, it seems as though the function performs an average on the second dimension for the first trial only. When I use a latency over a second, this does not happen and all trials have the same dimensions. My question is: am I doing anything wrong or have I again made a wrong assumption while implementing this pipeline? Is there any reason for this strange output? See code snippet below. Thanks a lot in advance!

        cfg                  = [ ];
        data                = ft_preprocessing(cfg,rwdata);

        % resample data
        cfg                       = [];
        cfg.resamplefs    = 250;
        data                    = ft_resampledata(cfg, data);

data =

struct with fields:

      fsample: 250
      trial: {1×117 cell}
      time: {1×117 cell}
      label: {100×1 cell}
      cfg: [1×1 struct]

        % select the portion of the data I want to compute the wPLI for
        cfg               = [ ];
        cfg.latency   = .15:.25;                          <<<<<<<<<<<<<< if I use 0:1 or 1:1.5, ft_freqanaylisis runs without any problem, but if I use any other latency within 1 second it doesn't work.
        data             = ft_selectdata(cfg,data);

       % here's the output structure
data =

struct with fields:

      fsample: 250
      trial: {1×117 cell}
      time: {1×117 cell}
      label: {100×1 cell}
      cfg: [1×1 struct]

data.trial

ans =
  1×117 cell array
  Columns 1 through 9

    {100×1 double}    {100×1251 double}    {100×1251 double}   % averaged first trial in the 2nd dimension instead of selecting the time interval of interest

data.time
ans =
  1×117 cell array
  Columns 1 through 10

    {[0.1480]}    {1×1251 double}    {1×1251 double}

        % Now call the ft_freqanalysis function
        cfg                  = [ ];
        cfg.output       = 'fourier';
        cfg.method     = 'mtmfft';
        cfg.taper         = 'dpss';
        cfg.foi             = linspace(1,31,60);
        cfg.tapsmofrq = 4;
        tf_data            = ft_freqanalysis(cfg,data);

Error using dpss>parseinputs (line 308)
Time-bandwidth product NW must be a positive number.

Error in dpss (line 62)
[method,k,Ni,traceFlag,N,NW] = parseinputs(N,NW,varargin{:});

Error in ft_specest_mtmfft>double_dpss (line 362)
tap = dpss(double(a), double(b), varargin{:});

Error in ft_specest_mtmfft (line 151)
      tap = double_dpss(ndatsample,ndatsample*(tapsmofrq./fsample))';

Error in ft_freqanalysis (line 563)
      [spectrum,ntaper,foi] = ft_specest_mtmfft(dat, time, 'taper', cfg.taper, options{:}, 'feedback', fbopt);

Error in Connectivity_wPLI (line 68)
       tf_data           = ft_freqanalysis(cfg,data);


All best,

Sergio.



El mié, 15 sept 2021 a las 15:09, SERGIO OSORIO GALEANO (<srosorio at uc.cl<mailto:srosorio at uc.cl>>) escribió:
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.

Oh, that makes perfect sense. Cheers Jan! Really appreciate it.

Sergio.



El mié, 15 sept 2021 a las 14:29, Schoffelen, J.M. (Jan Mathijs) via fieldtrip (<fieldtrip at science.ru.nl<mailto:fieldtrip at science.ru.nl>>) escribió:
Hi Sergio,
>
> 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?

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.

> 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.

I think that this is just a property of the data.

Best wishes,
Jan-Mathijs


>
> Thanks a lot in advance for any help anyone can provide!
>
> -----------
>
> cfg                 = [ ];
> data               = ft_preprocessing(cfg,rwdata);
>
> %resample data
> cfg                      = [ ];
> cfg.resamplefs   = 250;
> data                    = ft_resampledata(cfg, data);
>
> data =
>   struct with fields:
>
>       fsample: 250
>       trial:   {1×117 cell}
>       time:  {1×117 cell}
>       label: {100×1 cell}
>       cfg:    [1×1 struct]
>
> % next, call the ft_freqanalysis function in our source data
> cfg                     = [ ];
> cfg.output          = 'fourier';
> cfg.method        = 'mtmfft';
> cfg.taper            = 'dpss';
> cfg.foi                 = linspace(4,30,30);
> cfg.tapsmofrq     = 4;
> cfg.toi                 = 0:.02:1.5;   % try 0:.02:.7 and .7:.02:1.5
> tf_data                = ft_freqanalysis(cfg,data);
>
> tf_data =
>   struct with fields:
>
>             label:     {100×1 cell}
>             dimord: 'rpttap_chan_freq'
>             freq:       [1×30 double]
>             fourierspctrm: [4563×100×30 double]
>             cumsumcnt: [117×1 double]
>             cumtapcnt:   [117×1 double]
>             cfg:               [1×1 struct]
>
> % estimate wPLI values
> cfg                    = [ ];
> cfg.method       = 'wpli_debiased';
> connect_data   = ft_connectivityanalysis(cfg,tf_data);
>
> connect_data =
>   struct with fields:
>
>                label:     {100×1 cell}
>                dimord:  'chan_chan_freq'
>                wpli_debiasedspctrm: [100×100×30 double]
>                freq:  [1×30 double]
>                cfg:   [1×1 struct]
>
> Best,
>
> Sergio.
>
> _______________________________________________
> fieldtrip mailing list
> https://mailman.science.ru.nl/mailman/listinfo/fieldtrip
> https://urldefense.com/v3/__https://doi.org/10.1371/journal.pcbi.1002202__;!!HJOPV4FYYWzcc1jazlU!v6GcyYsHF6VUmzXm8BB3M6rFfwWnSYCxD7hg5IzSXjBU2SvnlyfRyykO5BhpyzahCLvCtBzdjU2HPc4$


_______________________________________________
fieldtrip mailing list
https://mailman.science.ru.nl/mailman/listinfo/fieldtrip
https://doi.org/10.1371/journal.pcbi.1002202<https://urldefense.com/v3/__https://doi.org/10.1371/journal.pcbi.1002202__;!!HJOPV4FYYWzcc1jazlU!usewI1PbndK5LPja3Ngfqvfn3tRpdRV73OimKW6NrcohdNrX6G3vkgQuzYR9QRioc7pHSLvRNfscdfs$>
_______________________________________________
fieldtrip mailing list
https://mailman.science.ru.nl/mailman/listinfo/fieldtrip
https://urldefense.com/v3/__https://doi.org/10.1371/journal.pcbi.1002202__;!!HJOPV4FYYWzcc1jazlU!usewI1PbndK5LPja3Ngfqvfn3tRpdRV73OimKW6NrcohdNrX6G3vkgQuzYR9QRioc7pHSLvRNfscdfs$

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.science.ru.nl/pipermail/fieldtrip/attachments/20210923/9497fd03/attachment.htm>


More information about the fieldtrip mailing list