<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 Akshay,
<div class=""><br class="">
</div>
<div class="">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:</div>
<div class=""><br class="">
</div>
<div class="">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’’.</div>
<div class=""><br class="">
</div>
<div class="">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).</div>
<div class=""><br class="">
</div>
<div class="">Best wishes,</div>
<div class="">Jan-Mathijs</div>
<div class=""><br class="">
<div><br class="">
<blockquote type="cite" class="">
<div class="">On 2 Aug 2020, at 23:35, Akshay Ravindran <<a href="mailto:akshay.s.ravindran@gmail.com" class="">akshay.s.ravindran@gmail.com</a>> wrote:</div>
<br class="Apple-interchange-newline">
<div class="">
<div dir="ltr" class="">
<div class="gmail_quote">
<div dir="ltr" class="gmail_attr">Good Evening,<br class="">
</div>
<div dir="ltr" class="">
<div class=""><br class="">
</div>
I tried estimating the functional connectivity using different phase-based measures like PLV and wPLI_debiased. I tried testing the two measures using<i class=""> cfg.output</i> set to either <i class="">'fourier' or</i> <i class="">'powandcsd'
</i>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.  
<div class=""><br class="">
</div>
<div class="">Even though I think <i class="">'fourier'</i> is the right way to implement these, to test for the validity of it, I tested this on the artificial data created using the
<i class="">ft_connectivitysimulation function</i> ( 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).</div>
<div class=""><br class="">
<div class=""><b class=""><i class="">My question is mainly the following</i></b></div>
<div class=""><u class="">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? </u>
<div class=""><u class="">2) Is there any recommended instance of using 'powandcsd ' over 'fourier'  in any of the connectivity measures?</u></div>
<div class=""><br class="">
</div>
<div class="">
<div class=""><br class="">
</div>
<div class="">% EEG sampled at 200 Hz, 60 channels with events. The epoching is fine as the ERP was validated after epoching. <br class="">
<div class="">data              = ft_connectivitysimulation(cfg);
<div class="">
<div class="">cfg = [];<br class="">
cfg.channel = ['all']; <br class="">
cfg.dataset                 = 'Dataset_Epochs.set';<br class="">
cfg.trialfun                = 'ft_trialfun_general'; % this is the default<br class="">
cfg.trialdef.eventtype      = 'trigger';<br class="">
cfg.trialdef.eventvalue     = 'Onset'; <br class="">
cfg.trialdef.prestim        = 0.2; % in seconds<br class="">
cfg.trialdef.poststim       = 0.6; % in seconds<br class="">
cfg = ft_definetrial(cfg);<br class="">
data= ft_preprocessing(cfg); </div>
<div class=""><br class="">
</div>
<div class="">
<div class=""><br class="">
</div>
<div class="">cfg           = [];</div>
<div class="">cfg.pad       = 'nextpow2'; <br class="">
cfg.method    = 'mtmfft';<br class="">
cfg.taper     = 'hanning';<br class="">
cfg.output    = 'fourier';; % Tried replacing this with powandcsd and both yielded different results<br class="">
cfg.keeptrials  = 'yes'<br class="">
cfg.tapsmofrq = 1;<br class="">
spectral_decomp          = ft_freqanalysis(cfg, data); </div>
<div class="">% Compute the functional connectivity using PLV               <br class="">
cfg            = [];<br class="">
cfg.method    = 'plv'<br class="">
</div>
<div class="">fc  = ft_connectivityanalysis(cfg, spectral_decomp);            </div>
</div>
<div class=""><br class="">
</div>
<div class=""><br class="">
</div>
<div class="">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</div>
<div class=""> % cfg.dataset                 = 'Dataset_RS.set';  <br class="">
</div>
<div class="">
<div class=""> % [data] = ft_preprocessing(cfg)  <br class="">
</div>
<div class=""></div>
%cfg = [];<br class="">
%cfg.length  = 6;<br class="">
%cfg.overlap = 0;<br class="">
%data_segmented = ft_redefinetrial(cfg, data);</div>
<div class=""><br class="">
</div>
<div class=""> Thanks,</div>
<div class="">
<div class=""><br class="">
</div>
-- <br class="">
<div dir="ltr" data-smartmail="gmail_signature" class="">
<div dir="ltr" class="">
<div dir="ltr" class="">
<div dir="ltr" class="">
<div dir="ltr" class="">
<div dir="ltr" class="">
<div dir="ltr" class="">
<div dir="ltr" class="">
<div dir="ltr" class="">
<div dir="ltr" class="">
<div dir="ltr" class="">
<div dir="ltr" class="">
<div dir="ltr" class="">
<div dir="ltr" class="">
<div dir="ltr" class="">
<div dir="ltr" class="">
<div style="color:rgb(80,0,80);font-size:12.8px" class=""><span style="font-size:12.8px" class="">Regards,</span></div>
<div style="color:rgb(80,0,80);font-size:12.8px" class=""><span style="font-size:12.8px" class=""><br class="">
</span></div>
<div style="color:rgb(80,0,80);font-size:12.8px" class="">ASR</div>
<div style="color:rgb(80,0,80);font-size:12.8px" class=""><br class="">
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<div dir="ltr" class="gmail_signature" data-smartmail="gmail_signature">
<div dir="ltr" class="">
<div class="">
<div dir="ltr" class="">
<div dir="ltr" class="">
<div dir="ltr" class="">
<div dir="ltr" class="">
<div dir="ltr" class="">
<div dir="ltr" class="">
<div dir="ltr" class="">
<div dir="ltr" class="">
<div dir="ltr" class="">
<div dir="ltr" class="">
<div dir="ltr" class="">
<div dir="ltr" class="">
<div dir="ltr" class="">
<div dir="ltr" class="">
<div style="color:rgb(80,0,80);font-size:12.8px" class=""><br class="">
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</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>