<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="">Dear Jan-Mathijs,<div class=""><br class=""></div><div class="">first, I apologize if my message seemed demanding. This was not my intention as I greatly appreciate the help! Thank you very much for your answer! I implemented your suggestion and now the output is in the desired 30x30 format. </div><div class=""><br class=""></div><div class="">I have a follow-up question, as the values for the upper and lower triangular parts of the debiased wpli adjacency matrix (values in both directions of each channel combination) are identical. I tried numerous approaches to address this issue such as running the same script on numerous datasets, changing the preprocessing (increase in segment length as well as less downsampling), and changing the metric to „wpli“ and „plv" but the results remain the same. Also, I checked the cfg.channelcmb, and the channels are listed properly in both directions for each channel pair, so this also shouldn’t be the root of the issue. Lastly, as my previous dataset was preprocessed in EEGLAB, I reanalyzed the same dataset entirely using FieldTrip functions. Still, the results remain the same. Here is the current code I use:</div><div class=""><br class=""></div><div class=""><div class=""></div><blockquote type="cite" class=""><div class="">% Load the data into FieldTrip data structure</div><div class="">cfg = [];</div><div class="">cfg.dataset = ftfile;</div><div class="">cfg.continuous = 'yes';</div><div class="">ft_data = ft_preprocessing(cfg);</div><div class=""><br class=""></div><div class="">% Define the resampling parameters</div><div class="">cfg = [];</div><div class="">cfg.resamplefs = 250;    </div><div class=""><br class=""></div><div class="">% Resample the data</div><div class="">ft_data_rs = ft_resampledata(cfg, ft_data);</div><div class=""><br class=""></div><div class="">% Cut data into multiple trials (necessary for wpli computation)</div><div class="">cfg = [];</div><div class="">cfg.length  = 10; </div><div class="">cfg.overlap = 0;</div><div class="">ft_data_rs_seg = ft_redefinetrial(cfg, ft_data_rs);</div><div class=""><br class=""></div><div class="">% Freq analysis I</div><div class="">cfg = [];</div><div class="">cfg.method = 'mtmfft';          </div><div class="">cfg.output = 'fourier';         </div><div class="">cfg.taper = 'dpss';             </div><div class="">cfg.foi = 13:30;                  </div><div class="">cfg.keeptrials = 'yes';         </div><div class="">cfg.channel = 'all';</div><div class="">cfg.trials = 'all';             </div><div class="">cfg.tapsmofrq = 8;              </div><div class="">cfg.pad = 'nextpow2';           </div><div class="">cfg.channelcmb = ft_channelcombination('all', ft_data_rs_seg.label, 1, 2); </div><div class=""><br class=""></div><div class="">freq=ft_freqanalysis(cfg,ft_data_rs_seg);</div><div class=""><br class=""></div><div class="">% Define the connectivity parameters</div><div class="">cfg = [];</div><div class="">cfg.method = 'wpli_debiased'; </div><div class="">cfg.complex = 'abs';</div><div class=""><br class=""></div><div class="">wpli_data = ft_connectivityanalysis(cfg, freq);</div></blockquote></div><div class=""><br class=""></div><div class=""><br class=""></div><div class="">Is there any mistake in the code that leads to the wpli values being identical for both directions?</div><div class=""><br class=""></div><div class="">All the best,</div><div class=""><br class=""></div><div class="">Tyler</div><div class=""><br class=""></div><div class=""><div><br class=""><blockquote type="cite" class=""><div class=""></div></blockquote></div><blockquote type="cite" class=""><div><blockquote type="cite" class=""><div class="">Am 07.03.2023 um 16:30 schrieb Schoffelen, J.M. (Jan Mathijs) via fieldtrip <<a href="mailto:fieldtrip@science.ru.nl" class="">fieldtrip@science.ru.nl</a>>:</div><br class="Apple-interchange-newline"><div class="">

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" class="">

<div style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class="">
<div class="">Hi Tyler,</div>
<div class=""><br class="">
</div>
<div class="">Probably you should either use</div>
<div class=""><br class="">
</div>
cfg.output = ‘fourier’ in the call to ft_freqanalysis, or
<div class=""><br class="">
</div>
<div class="">specify cfg.channelcmb in your call to ft_freqanalysis should do it. </div>
<div class=""><br class="">
</div>
<div class="">(actually, the quote from the help docstring of (what I asume to be) ft_connectivityanalysis - which you pasted into your e-mail, sums up the above: cfg.channelcmb in ft_connectivityanalysis does not have a functional effect, because the input
 data was NOT univariate (no ‘fourier’ in output), but the recipe for ft_freqanalysis did not specify the channelcmb, so the data were detected to be bivariate (‘powandcsd’), but only with bivariate auto-pairs)</div>
<div class=""><br class="">
</div>
<div class="">Please note, that questions asked on this discussion list are only answered by people on a voluntary basis. Nobody has it as their job to answer to this list, so you shouldn’t expect people to answer, and certainly not within a particular time
 frame. Also, the quality of the question matters, and to be honest the original question had some room for improvement.</div>
<div class=""><br class="">
</div>
<div class="">Best wishes and good luck with your analysis,</div>
<div class=""><br class="">
</div>
<div class="">Jan-Mathijs</div>
<div class=""><br class="">
</div>
<div class=""><br class="">
<div class=""><br class="">
<blockquote type="cite" class="">
<div class="">On 7 Mar 2023, at 15:25, Tyler Durdern via fieldtrip <<a href="mailto:fieldtrip@science.ru.nl" class="">fieldtrip@science.ru.nl</a>> wrote:</div>
<br class="Apple-interchange-newline">
<div class="">
<div style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class="">
Dear all,
<div class=""><br class="">
</div>
<div class="">I asked this question but I did not receive a response yet:</div>
<div class=""><br class="">
<div class="">
<div class="">
<blockquote type="cite" class="">I computed the debiased weighted phase lag index for all channel combinations of a 30-channel EEG resting state recording. The output file (wpli_debiasedspctrm) has the following dimensions (435x30). I subsequently averaged
 the file across the second dimension to get an average debiased wpli estimate across the frequency band of interest. Now, I want to put this estimate into an adjacency matrix format (30x30) so I can illustrate the connectivity matrix using e.g. imagesc in
 Matlab. Is there a way I can achieve this in fieldtrip? <br class="">
</blockquote>
<div class=""><br class="">
</div>
I tried a few approaches in the mean time but I cannot seem to get the results I want. Using a 30-channel EEG recording, I expect a  900x30 output variable corresponding to wpli values for all possible channel combinations (even identical ones) per frequency
 in both directions (e.g. Cz-Fz and Fz-Cz). I tried to achieve this using f<span style="white-space: pre;" class="">t_channelcombination and although this yields the correct channel combinations, it doesn’t change the wpli output. Looking into the code</span></div>
<div class=""><span style="white-space: pre;" class="">I found that this is probably due to the fact that my data is bivariate and the code states that „</span><span style="white-space: pre;" class=""><span style="color: rgb(0, 128, 19);" class=""> This only
 has an effect when </span></span><span style="color: rgb(0, 128, 19); white-space: pre;" class="">the input data</span></div>
<div class=""><span style="color: rgb(0, 128, 19); white-space: pre;" class="">is univariate</span><span style="white-space: pre;" class="">“.
</span></div>
<div class=""><span style="white-space: pre;" class=""><br class="">
</span></div>
<div class=""><span style="white-space: pre;" class="">Here is the code I’ve used so far:</span></div>
<div class=""><span style="white-space: pre;" class=""><br class="">
</span></div>
<div class="">
<div class="rtcContent">
<div class="lineNode"></div>
<blockquote type="cite" class="">
<div class="lineNode"><span style="white-space: pre" class=""><span style="color: rgb(0, 128, 19);" class="">% Define the resampling parameters</span></span></div>
<div class="lineNode"><span style="white-space: pre" class="">cfg = [];</span></div>
<div class="lineNode"><span style="white-space: pre" class="">cfg.resamplefs = 125;
</span></div>
<div class="lineNode"><span style="white-space: pre" class=""><span style="color: rgb(0, 128, 19);" class=""><br class="">
</span></span></div>
<div class="lineNode"><!--[if mso]><br><![endif]--></div>
<div class="lineNode"><span style="white-space: pre" class=""><span style="color: rgb(0, 128, 19);" class="">% Resample the data</span></span></div>
<div class="lineNode"><span style="white-space: pre" class="">ft_data_rs = ft_resampledata(cfg, ft_data);</span></div>
<div class="lineNode"><span style="white-space: pre" class=""><br class="">
</span></div>
<div class="lineNode"><!--[if mso]><br><![endif]--></div>
<div class="lineNode"><span style="white-space: pre" class=""><span style="color: rgb(0, 128, 19);" class="">% Cut data into multiple trials</span></span></div>
<div class="lineNode"><span style="white-space: pre" class="">cfg = [];</span></div>
<div class="lineNode"><span style="white-space: pre" class="">cfg.length = 1; <span style="color: rgb(0, 128, 19);" class="">
% 1 sec. segments</span></span></div>
<div class="lineNode"><span style="white-space: pre" class="">cfg.overlap = 0;</span></div>
<div class="lineNode"><span style="white-space: pre" class="">ft_data_rs_seg = ft_redefinetrial(cfg, ft_data_rs);</span></div>
<div class="lineNode"><span style="white-space: pre" class=""><br class="">
</span></div>
<div class="lineNode"><!--[if mso]><br><![endif]--></div>
<div class="lineNode"><span style="white-space: pre" class=""><span style="color: rgb(0, 128, 19);" class="">% Freq analysis I</span></span></div>
<div class="lineNode"><span style="white-space: pre" class="">cfg = [];</span></div>
<div class="lineNode"><span style="white-space: pre" class="">cfg.method = <span style="color: rgb(167, 9, 245);" class="">
'mtmfft'</span>; <span style="color: rgb(0, 128, 19);" class="">% use multitaper frequency transformation
</span></span></div>
<div class="lineNode"><span style="white-space: pre" class="">cfg.output = <span style="color: rgb(167, 9, 245);" class="">
'powandcsd'</span>; <span style="color: rgb(0, 128, 19);" class="">% compute power spectrum and cross-spectral density</span></span></div>
<div class="lineNode"><span style="white-space: pre" class="">cfg.taper = <span style="color: rgb(167, 9, 245);" class="">
'dpss'</span>; <span style="color: rgb(0, 128, 19);" class="">% use DPSS taper window
</span></span></div>
<div class="lineNode"><span style="white-space: pre" class="">cfg.foi = 1:30; <span style="color: rgb(0, 128, 19);" class="">
% frequency range of interest</span></span></div>
<div class="lineNode"><span style="white-space: pre" class="">cfg.keeptrials = <span style="color: rgb(167, 9, 245);" class="">
'yes'</span>; <span style="color: rgb(0, 128, 19);" class="">% average over trials</span></span></div>
<div class="lineNode"><span style="white-space: pre" class="">cfg.channel = <span style="color: rgb(167, 9, 245);" class="">
'all'</span>; <span style="color: rgb(0, 128, 19);" class="">% use all channels</span></span></div>
<div class="lineNode"><span style="white-space: pre" class="">cfg.trials = <span style="color: rgb(167, 9, 245);" class="">
'all'</span>; <span style="color: rgb(0, 128, 19);" class="">% use all trials</span></span></div>
<div class="lineNode"><span style="white-space: pre" class="">cfg.tapsmofrq = 8; <span style="color: rgb(0, 128, 19);" class="">
% specify the smoothing parameter for DPSS</span></span></div>
<div class="lineNode"><span style="white-space: pre" class="">cfg.pad = <span style="color: rgb(167, 9, 245);" class="">
'nextpow2'</span>; <span style="color: rgb(0, 128, 19);" class="">% should increase computation speed
</span></span></div>
<div class="lineNode"><!--[if mso]><br><![endif]--></div>
<div class="lineNode"><span style="white-space: pre" class="">freq=ft_freqanalysis(cfg,ft_data_rs_seg);</span></div>
<div class="lineNode"><br class="">
</div>
<div class="lineNode"><!--[if mso]><br><![endif]--></div>
<div class="lineNode"><span style="white-space: pre" class=""><span style="color: rgb(0, 128, 19);" class="">% Define the connectivity parameters</span></span></div>
<div class="lineNode"><span style="white-space: pre" class="">cfg = [];</span></div>
<div class="lineNode"><span style="white-space: pre" class="">cfg.method = <span style="color: rgb(167, 9, 245);" class="">
'wpli_debiased'</span>; </span></div>
<div class="lineNode"><span style="white-space: pre" class="">cfg.channelcmb = {<span style="color: rgb(167, 9, 245);" class="">'all'
</span><span style="color: rgb(167, 9, 245);" class="">'all'</span>};</span></div>
<div class="lineNode"><span style="white-space: pre" class="">cfg.complex = <span style="color: rgb(167, 9, 245);" class="">
'abs'</span>;</span></div>
<div class="lineNode"><br class="">
</div>
<div class="lineNode"><span style="white-space: pre" class="">wpli_data = ft_connectivityanalysis(cfg, freq);</span></div>
</blockquote>
</div>
</div>
<div class=""><span style="white-space: pre;" class=""><br class="">
</span></div>
<div class=""><span style="white-space: pre;" class="">To summarize: I would like to compute debiased wpli for all channels (even identical ones) in both directions. Further, I would like to store
</span></div>
<div class=""><span style="white-space: pre;" class="">the debiased wpli output in a 30x30 adjacency/connectivity matrix.
</span></div>
<div class=""><span style="white-space: pre;" class=""><br class="">
</span></div>
<div class=""><span style="white-space: pre;" class="">As I am still quite new to FieldTrip I am stuck here and I would really appreciate your help on this issue.</span></div>
<div class=""><br class="">
Thanks in advance and all the best,<br class="">
<br class="">
Tyler </div>
</div>
<br class="">
</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="">
<a href="https://urldefense.com/v3/__https://doi.org/10.1371/journal.pcbi.1002202__;!!HJOPV4FYYWzcc1jazlU!8mwcfczjzqZxkKO2dAWjyEaLc9exEHMp0N2DmbF_qrB8_J104ES-INo06rwjXquNN8Z0H3QkMYyrN9SUUxoEN5zBk_5C58M8w42Quw$" class="">https://urldefense.com/v3/__https://doi.org/10.1371/journal.pcbi.1002202__;!!HJOPV4FYYWzcc1jazlU!8mwcfczjzqZxkKO2dAWjyEaLc9exEHMp0N2DmbF_qrB8_J104ES-INo06rwjXquNN8Z0H3QkMYyrN9SUUxoEN5zBk_5C58M8w42Quw$</a>
<br class="">
</div>
</blockquote>
</div>
<br class="">
</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=""><a href="https://urldefense.com/v3/__https://doi.org/10.1371/journal.pcbi.1002202__;!!HJOPV4FYYWzcc1jazlU!_VIpM4ghDQ68RPiJf0gTPHPbqEALBIlPVHTwzBgbRzyUnVntFM80leE-tskp4Qf3UQzJxzRrIk_S2Bk0WA$">https://doi.org/10.1371/journal.pcbi.1002202</a><br class=""></div></blockquote></div><br class=""></blockquote></div></body></html>