<div dir="auto"><div>Hi Jan,<div dir="auto"><br></div><div dir="auto">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.</div><div dir="auto"><br></div><div dir="auto">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?</div><div dir="auto"><br></div><div dir="auto"><br></div><br><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Mon, Aug 3, 2020, 4:03 AM Schoffelen, J.M. (Jan Mathijs) <<a href="mailto:jan.schoffelen@donders.ru.nl">jan.schoffelen@donders.ru.nl</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">



<div style="word-wrap:break-word;line-break:after-white-space">
Hi Akshay,
<div><br>
</div>
<div>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><br>
</div>
<div>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><br>
</div>
<div>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><br>
</div>
<div>Best wishes,</div>
<div>Jan-Mathijs</div>
<div><br>
<div><br>
<blockquote type="cite">
<div>On 2 Aug 2020, at 23:35, Akshay Ravindran <<a href="mailto:akshay.s.ravindran@gmail.com" target="_blank" rel="noreferrer">akshay.s.ravindran@gmail.com</a>> wrote:</div>
<br>
<div>
<div dir="ltr">
<div class="gmail_quote">
<div dir="ltr" class="gmail_attr">Good Evening,<br>
</div>
<div dir="ltr">
<div><br>
</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> cfg.output</i> set to either <i>'fourier' or</i> <i>'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><br>
</div>
<div>Even though I think <i>'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>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><br>
<div><b><i>My question is mainly the following</i></b></div>
<div><u>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><u>2) Is there any recommended instance of using 'powandcsd ' over 'fourier'  in any of the connectivity measures?</u></div>
<div><br>
</div>
<div>
<div><br>
</div>
<div>% EEG sampled at 200 Hz, 60 channels with events. The epoching is fine as the ERP was validated after epoching. <br>
<div>data              = ft_connectivitysimulation(cfg);
<div>
<div>cfg = [];<br>
cfg.channel = ['all']; <br>
cfg.dataset                 = 'Dataset_Epochs.set';<br>
cfg.trialfun                = 'ft_trialfun_general'; % this is the default<br>
cfg.trialdef.eventtype      = 'trigger';<br>
cfg.trialdef.eventvalue     = 'Onset'; <br>
cfg.trialdef.prestim        = 0.2; % in seconds<br>
cfg.trialdef.poststim       = 0.6; % in seconds<br>
cfg = ft_definetrial(cfg);<br>
data= ft_preprocessing(cfg); </div>
<div><br>
</div>
<div>
<div><br>
</div>
<div>cfg           = [];</div>
<div>cfg.pad       = 'nextpow2'; <br>
cfg.method    = 'mtmfft';<br>
cfg.taper     = 'hanning';<br>
cfg.output    = 'fourier';; % Tried replacing this with powandcsd and both yielded different results<br>
cfg.keeptrials  = 'yes'<br>
cfg.tapsmofrq = 1;<br>
spectral_decomp          = ft_freqanalysis(cfg, data); </div>
<div>% Compute the functional connectivity using PLV               <br>
cfg            = [];<br>
cfg.method    = 'plv'<br>
</div>
<div>fc  = ft_connectivityanalysis(cfg, spectral_decomp);            </div>
</div>
<div><br>
</div>
<div><br>
</div>
<div>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> % cfg.dataset                 = 'Dataset_RS.set';  <br>
</div>
<div>
<div> % [data] = ft_preprocessing(cfg)  <br>
</div>
<div></div>
%cfg = [];<br>
%cfg.length  = 6;<br>
%cfg.overlap = 0;<br>
%data_segmented = ft_redefinetrial(cfg, data);</div>
<div><br>
</div>
<div> Thanks,</div>
<div>
<div><br>
</div>
-- <br>
<div dir="ltr" data-smartmail="gmail_signature">
<div dir="ltr">
<div dir="ltr">
<div dir="ltr">
<div dir="ltr">
<div dir="ltr">
<div dir="ltr">
<div dir="ltr">
<div dir="ltr">
<div dir="ltr">
<div dir="ltr">
<div dir="ltr">
<div dir="ltr">
<div dir="ltr">
<div dir="ltr">
<div dir="ltr">
<div style="color:rgb(80,0,80);font-size:12.8px"><span style="font-size:12.8px">Regards,</span></div>
<div style="color:rgb(80,0,80);font-size:12.8px"><span style="font-size:12.8px"><br>
</span></div>
<div style="color:rgb(80,0,80);font-size:12.8px">ASR</div>
<div style="color:rgb(80,0,80);font-size:12.8px"><br>
</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" data-smartmail="gmail_signature">
<div dir="ltr">
<div>
<div dir="ltr">
<div dir="ltr">
<div dir="ltr">
<div dir="ltr">
<div dir="ltr">
<div dir="ltr">
<div dir="ltr">
<div dir="ltr">
<div dir="ltr">
<div dir="ltr">
<div dir="ltr">
<div dir="ltr">
<div dir="ltr">
<div dir="ltr">
<div style="color:rgb(80,0,80);font-size:12.8px"><br>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
_______________________________________________<br>
fieldtrip mailing list<br>
<a href="https://mailman.science.ru.nl/mailman/listinfo/fieldtrip" target="_blank" rel="noreferrer">https://mailman.science.ru.nl/mailman/listinfo/fieldtrip</a><br>
<a href="https://doi.org/10.1371/journal.pcbi.1002202" target="_blank" rel="noreferrer">https://doi.org/10.1371/journal.pcbi.1002202</a><br>
</div>
</blockquote>
</div>
<br>
</div>
</div>

_______________________________________________<br>
fieldtrip mailing list<br>
<a href="https://mailman.science.ru.nl/mailman/listinfo/fieldtrip" rel="noreferrer noreferrer" target="_blank">https://mailman.science.ru.nl/mailman/listinfo/fieldtrip</a><br>
<a href="https://doi.org/10.1371/journal.pcbi.1002202" rel="noreferrer noreferrer" target="_blank">https://doi.org/10.1371/journal.pcbi.1002202</a><br>
</blockquote></div></div></div>