[FieldTrip] PLV, wPLI: Discripancy using powandcsd and fourier

Akshay Ravindran akshay.s.ravindran at gmail.com
Tue Aug 4 00:30:54 CEST 2020


Thank you, yes so I do get the same figures when I plot the two using
ft_connectivityplot while feeding the EEG data. However, my intent is to
get the actual numerical PLV values rather than the plot so I believe I
should be calling  plv3 = ft_checkdata(plv3, 'cmbrepresentation', 'full');
to get the channel x channel x frequency representation. The
discrepancy happens when I evaluate the numerical values using this method.

 I did some exploration as I understand it is very difficult to explain the
anomaly considering that as you said it should not matter irrespective of
whether the data being fed in is EEG or random numbers as the function just
sees them as numbers. Upon following the lines of code for
ft_connectivityplot   I came to know that inside the function there are
instances wherein it first adjusts the data using ft_checkdata and also
does some operations on intersecting the channels to make them align. And I
suspected there are some internal corrections being done to align the
values and suspected it had to do with the naming of the labels.

So, when I run your script with the following additional lines I do get the
same answers in plv3 and plv1 printed out ( changed nchan = 5).
 plv3 = ft_checkdata(plv3, 'cmbrepresentation', 'full');

disp(plv1.plvspctrm(1,:,1));
  >>1.0000    0.1000    0.1000    0.5000    0.3000

disp( plv_csd.plvspctrm(1,:,1));
     >>NaN    0.1000    0.1000    0.5000    0.3000


Then I replaced the following lines accordingly and reran the same set of
code

for k = 1:nchan
     if k==1
        data.label{k} =   sprintf('chan%02d',k);
    elseif k==2
        data.label{k} =   sprintf('Nchan%02d',k);
    else
        data.label{k} =   sprintf('N1chan%02d',k);
    end
end
...
...
...

Here, the output is different for both powandcsd as well as fourier when
the label size is different.
  disp(plv1.plvspctrm(1,:,1));
   >>  1.0000    0.1000    0.1000    0.2000    0.3000
  disp( plv_csd.plvspctrm(1,:,1));
    >>   NaN    0.1000         0         0    0.1000

So by default, the EEG labels are not having the same size, some are
two-letter names(Cz)  whereas others are 3 letter names (FCz). So there is
an influence on the channel labels on how the results come about and I
suspect that is causing this anomaly.

Now this is with my understanding that I am supposed to call  *plv3 =
ft_checkdata(plv3, 'cmbrepresentation', 'full');* after powandcsd to get
the data  in correct dimension (ch x ch x freq) and I might be wrong if
this is not the way to extract the values in the format. If there is
another way to get the data, if you could kindly inform me, that will be
greatly appreciated.




On Mon, Aug 3, 2020 at 11:18 AM Schoffelen, J.M. (Jan Mathijs) <
jan.schoffelen at donders.ru.nl> wrote:

> Hi Akshay,
>
> I cannot reproduce your problem. A data structure is a data structure, so
> I don’t see why a FT-structure that some numbers in a trial cell-array
> should behave different when it is obtained from EEGLAB or from
> ft_connectivitysimulation. For that matter, it shouldn’t make a difference
> whether you just put in random numbers. Using the below snippet of code I
> can reproduce your observation that it shouldn’t matter whether plv is
> computed from singletrial powandcsd, or from singletrial fourier.
>
> Best wishes,
> JM
>
>
> % create some data
> nsmp = 1000;
> ntrl = 20;
> nchan = 3;
> for k = 1:ntrl
>   trial{1,k} = randn(nchan,nsmp);
>   time{1,k}  = (0:(nsmp-1))./1000;
> end
> data = [];
> data.trial = trial;
> data.time  = time;
> for k = 1:nchan
>   data.label{k} = sprintf('chan%02d',k);
> end
>
>
> % spectral transformation
> cfg = [];
> cfg.method = 'mtmfft';
> cfg.output = 'fourier';
> cfg.pad = 1;
> cfg.tapsmofrq = 1;
> freq1 = ft_freqanalysis(cfg, data);
> cfg.output = 'powandcsd';
> freq2 = ft_freqanalysis(cfg, data);
> cfg.keeptrials = 'yes';
> freq3 = ft_freqanalysis(cfg, data);
>
>
> % connectivity estimation
> cfg = [];
> cfg.method = 'plv';
> plv1 = ft_connectivityanalysis(cfg, freq1);
> plv2 = ft_connectivityanalysis(cfg, freq2); % this one is not correct,
> since wrong normalisation
> plv3 = ft_connectivityanalysis(cfg, freq3);
>
>
>
>
> % these should be the same
> cfg = [];
> cfg.parameter = 'plvspctrm';
> ft_connectivityplot(cfg, plv1, plv3);
>
>
>
>
>
> On 3 Aug 2020, at 15:38, Akshay Ravindran <akshay.s.ravindran at gmail.com>
> wrote:
>
> Hi Jan,
>
> Thanks for the explanation. However yes so I do do understand the
> normalization done in PLV and for the same reason I had done
> keep_trials='yes' for powandcsd. I forgot to write it in the line of code
> below. I was getting that difference when using powandcsd though.
>
> The Nan and 1, I understood came from the way the implementation was done
> but my concern was the discrepancy in the off diagonal element which was
> the same for the artificial data whereas for actual EEG, they came out to
> be quite different. Is there something I can do to make it replicable?
> Maybe can I send the data?
>
>
>
>
> On Mon, Aug 3, 2020, 4:03 AM Schoffelen, J.M. (Jan Mathijs) <
> jan.schoffelen at donders.ru.nl> wrote:
>
>> Hi Akshay,
>>
>> I understand your question, but honestly the pasted code is not
>> sufficient for me to try and reproduce. Nonetheless, a few things can be
>> said:
>>
>> PLV is a measure (as is wPLI) that requires single trial spectrally
>> resolved data as an input. This is because the algorithmic steps that are
>> needed to compute the connectivity measure include a per-trial
>> normalisation of the fourier coefficients by their magnitude (plv), or some
>> other fancy non-linear manipulation of the single trial phase difference
>> estimates (wPLI). If you ask ft_freqanalysis to output ‘powandcsd’, without
>> explicitly specifying cfg.keeptrials = ‘yes’, then the single trial
>> dimension is lost for posterity, and the consequent computation of the
>> PLV/wPLI is nonsense (unless you used as an input a single epoch’s
>> spectrally transformed data with massive multitapering, keeping the
>> information of the individual tapers, but that’s a different story
>> altogether). In other words, where you mention that you think that
>> ‘fourier’ is the right way to implement these, you are right, but as an
>> alternative you could have used ‘powandcsd’ + ‘keeptrials = ‘yes’’.
>>
>> The NaNs versus 1 are easily explained by the fact that with ‘powandcsd’
>> the diagonal elements are explicitly set to NaN (i.e. they are not
>> computed), whereas in the ‘fourier’ case they are, and they trivially
>> result in an all(ones).
>>
>> Best wishes,
>> Jan-Mathijs
>>
>>
>> On 2 Aug 2020, at 23:35, Akshay Ravindran <akshay.s.ravindran at gmail.com>
>> wrote:
>>
>> Good Evening,
>>
>> I tried estimating the functional connectivity using different
>> phase-based measures like PLV and wPLI_debiased. I tried testing the two
>> measures using* cfg.output* set to either *'fourier' or* *'powandcsd' *as
>> I have seen people implementing PLV with both. However, I am getting quite
>> varying results using either of these on an EEG data saved in .set file
>> loaded and run using the commands shown at the end of this question.
>>
>> Even though I think *'fourier'* is the right way to implement these, to
>> test for the validity of it, I tested this on the artificial data created
>> using the *ft_connectivitysimulation function* ( 3 channel, 200 Hz Fs,
>> the same number of trials as EEG, default noise covariance and params as in
>> the example). In this case however, I am getting the very same results
>> using either output (off-diagonal elements are the same in either; diagonal
>> elements are NAN in using powandcsd whereas 1 while using Fourier).
>>
>> *My question is mainly the following*
>> *1) Am I missing something while testing on EEG data? If not,  why is
>> there a discrepancy found while testing on EEG but not on the simulated
>> data? *
>> *2) Is there any recommended instance of using 'powandcsd ' over
>> 'fourier'  in any of the connectivity measures?*
>>
>>
>> % EEG sampled at 200 Hz, 60 channels with events. The epoching is fine as
>> the ERP was validated after epoching.
>> data              = ft_connectivitysimulation(cfg);
>> cfg = [];
>> cfg.channel = ['all'];
>> cfg.dataset                 = 'Dataset_Epochs.set';
>> cfg.trialfun                = 'ft_trialfun_general'; % this is the default
>> cfg.trialdef.eventtype      = 'trigger';
>> cfg.trialdef.eventvalue     = 'Onset';
>> cfg.trialdef.prestim        = 0.2; % in seconds
>> cfg.trialdef.poststim       = 0.6; % in seconds
>> cfg = ft_definetrial(cfg);
>> data= ft_preprocessing(cfg);
>>
>>
>> cfg           = [];
>> cfg.pad       = 'nextpow2';
>> cfg.method    = 'mtmfft';
>> cfg.taper     = 'hanning';
>> cfg.output    = 'fourier';; % Tried replacing this with powandcsd and
>> both yielded different results
>> cfg.keeptrials  = 'yes'
>> cfg.tapsmofrq = 1;
>> spectral_decomp          = ft_freqanalysis(cfg, data);
>> % Compute the functional connectivity using PLV
>> cfg            = [];
>> cfg.method    = 'plv'
>> fc  = ft_connectivityanalysis(cfg, spectral_decomp);
>>
>>
>> To further test if it is something with the particular dataset, I also
>> tried on separate continuous EEG data  which was segmented in fieldtrip.
>> However this yielded similar quite varying results when using either output
>>  % cfg.dataset                 = 'Dataset_RS.set';
>>  % [data] = ft_preprocessing(cfg)
>> %cfg = [];
>> %cfg.length  = 6;
>> %cfg.overlap = 0;
>> %data_segmented = ft_redefinetrial(cfg, data);
>>
>>  Thanks,
>>
>> --
>> Regards,
>>
>> ASR
>>
>>
>> _______________________________________________
>> fieldtrip mailing list
>> https://mailman.science.ru.nl/mailman/listinfo/fieldtrip
>> https://doi.org/10.1371/journal.pcbi.1002202
>>
>>
>> _______________________________________________
>> fieldtrip mailing list
>> https://mailman.science.ru.nl/mailman/listinfo/fieldtrip
>> https://doi.org/10.1371/journal.pcbi.1002202
>>
> _______________________________________________
> fieldtrip mailing list
> https://mailman.science.ru.nl/mailman/listinfo/fieldtrip
> https://doi.org/10.1371/journal.pcbi.1002202
>
>
> _______________________________________________
> fieldtrip mailing list
> https://mailman.science.ru.nl/mailman/listinfo/fieldtrip
> https://doi.org/10.1371/journal.pcbi.1002202
>


-- 
Regards,

Akshay Sujatha Ravindran

Graduate Research Assistant
Department of Electrical & Computer Engineering
Laboratory for Noninvasive Brain-Machine Interface Systems
University of Houston
Engineering Building 2, E 413

President | BRAIN Student Group (UoH)
Vice President | Graduate and Professional Students Association (UoH)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.science.ru.nl/pipermail/fieldtrip/attachments/20200803/0f70c8f3/attachment.htm>


More information about the fieldtrip mailing list