[FieldTrip] Adjacency matrix for debiased weighted phase lag index

Tyler Durdern ty_du at gmx.de
Wed Mar 15 16:43:58 CET 2023


Hi Jan-Mathijs,

thank you, that clears it up for me.

Best,

Tyler

> Am 13.03.2023 um 16:55 schrieb Schoffelen, J.M. (Jan Mathijs) via fieldtrip <fieldtrip at science.ru.nl>:
> 
> Hi Tyler,
> 
> As far as I remember the original WPLI defines the metric as an absolute quantity, which is obviously what you also requested as per the cfg that you pasted in your e-mail. Many of the classical (and also the less classical) connectivity metrics are symmetric around the diagonal, so I don’t think that anything untowards is happening.
> 
> Best wishes,
> Jan-Mathijs
> 
> 
>> On 13 Mar 2023, at 10:04, Tyler Durdern via fieldtrip <fieldtrip at science.ru.nl <mailto:fieldtrip at science.ru.nl>> wrote:
>> 
>> Dear Jan-Mathijs,
>> 
>> 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. 
>> 
>> 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:
>> 
>>> % Load the data into FieldTrip data structure
>>> cfg = [];
>>> cfg.dataset = ftfile;
>>> cfg.continuous = 'yes';
>>> ft_data = ft_preprocessing(cfg);
>>> 
>>> % Define the resampling parameters
>>> cfg = [];
>>> cfg.resamplefs = 250;    
>>> 
>>> % Resample the data
>>> ft_data_rs = ft_resampledata(cfg, ft_data);
>>> 
>>> % Cut data into multiple trials (necessary for wpli computation)
>>> cfg = [];
>>> cfg.length  = 10; 
>>> cfg.overlap = 0;
>>> ft_data_rs_seg = ft_redefinetrial(cfg, ft_data_rs);
>>> 
>>> % Freq analysis I
>>> cfg = [];
>>> cfg.method = 'mtmfft';          
>>> cfg.output = 'fourier';         
>>> cfg.taper = 'dpss';             
>>> cfg.foi = 13:30;                  
>>> cfg.keeptrials = 'yes';         
>>> cfg.channel = 'all';
>>> cfg.trials = 'all';             
>>> cfg.tapsmofrq = 8;              
>>> cfg.pad = 'nextpow2';           
>>> cfg.channelcmb = ft_channelcombination('all', ft_data_rs_seg.label, 1, 2); 
>>> 
>>> freq=ft_freqanalysis(cfg,ft_data_rs_seg);
>>> 
>>> % Define the connectivity parameters
>>> cfg = [];
>>> cfg.method = 'wpli_debiased'; 
>>> cfg.complex = 'abs';
>>> 
>>> wpli_data = ft_connectivityanalysis(cfg, freq);
>> 
>> 
>> 
>> Is there any mistake in the code that leads to the wpli values being identical for both directions?
>> 
>> All the best,
>> 
>> Tyler
>> 
>> 
>>>> Am 07.03.2023 um 16:30 schrieb Schoffelen, J.M. (Jan Mathijs) via fieldtrip <fieldtrip at science.ru.nl <mailto:fieldtrip at science.ru.nl>>:
>>>> 
>>>> Hi Tyler,
>>>> 
>>>> Probably you should either use
>>>> 
>>>> cfg.output = ‘fourier’ in the call to ft_freqanalysis, or
>>>> 
>>>> specify cfg.channelcmb in your call to ft_freqanalysis should do it. 
>>>> 
>>>> (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)
>>>> 
>>>> 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.
>>>> 
>>>> Best wishes and good luck with your analysis,
>>>> 
>>>> Jan-Mathijs
>>>> 
>>>> 
>>>> 
>>>>> On 7 Mar 2023, at 15:25, Tyler Durdern via fieldtrip <fieldtrip at science.ru.nl <mailto:fieldtrip at science.ru.nl>> wrote:
>>>>> 
>>>>> Dear all,
>>>>> 
>>>>> I asked this question but I did not receive a response yet:
>>>>> 
>>>>>> 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? 
>>>>> 
>>>>> 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 ft_channelcombination and although this yields the correct channel combinations, it doesn’t change the wpli output. Looking into the code
>>>>> I found that this is probably due to the fact that my data is bivariate and the code states that „ This only
>>>>>  has an effect when the input data
>>>>> is univariate“.
>>>>> 
>>>>> 
>>>>> Here is the code I’ve used so far:
>>>>> 
>>>>> 
>>>>>> % Define the resampling parameters
>>>>>> cfg = [];
>>>>>> cfg.resamplefs = 125;
>>>>>> 
>>>>>> 
>>>>>> % Resample the data
>>>>>> ft_data_rs = ft_resampledata(cfg, ft_data);
>>>>>> 
>>>>>> 
>>>>>> % Cut data into multiple trials
>>>>>> cfg = [];
>>>>>> cfg.length = 1; 
>>>>>> % 1 sec. segments
>>>>>> cfg.overlap = 0;
>>>>>> ft_data_rs_seg = ft_redefinetrial(cfg, ft_data_rs);
>>>>>> 
>>>>>> 
>>>>>> % Freq analysis I
>>>>>> cfg = [];
>>>>>> cfg.method = 
>>>>>> 'mtmfft'; % use multitaper frequency transformation
>>>>>> cfg.output = 
>>>>>> 'powandcsd'; % compute power spectrum and cross-spectral density
>>>>>> cfg.taper = 
>>>>>> 'dpss'; % use DPSS taper window
>>>>>> cfg.foi = 1:30; 
>>>>>> % frequency range of interest
>>>>>> cfg.keeptrials = 
>>>>>> 'yes'; % average over trials
>>>>>> cfg.channel = 
>>>>>> 'all'; % use all channels
>>>>>> cfg.trials = 
>>>>>> 'all'; % use all trials
>>>>>> cfg.tapsmofrq = 8;
>>>>>> % specify the smoothing parameter for DPSS
>>>>>> cfg.pad = 
>>>>>> 'nextpow2'; % should increase computation speed
>>>>>> freq=ft_freqanalysis(cfg,ft_data_rs_seg);
>>>>>> 
>>>>>> % Define the connectivity parameters
>>>>>> cfg = [];
>>>>>> cfg.method = 
>>>>>> 'wpli_debiased'; 
>>>>>> cfg.channelcmb = {'all'
>>>>>> 'all'};
>>>>>> cfg.complex = 
>>>>>> 'abs';
>>>>>> 
>>>>>> wpli_data = ft_connectivityanalysis(cfg, freq);
>>>>> 
>>>>> 
>>>>> 
>>>>> To summarize: I would like to compute debiased wpli for all channels (even identical ones) in both directions. Further, I would like to store
>>>>> the debiased wpli output in a 30x30 adjacency/connectivity matrix.
>>>>> 
>>>>> 
>>>>> As I am still quite new to FieldTrip I am stuck here and I would really appreciate your help on this issue.
>>>>> 
>>>>> Thanks in advance and all the best,
>>>>> 
>>>>> Tyler 
>>>>> 
>>>>> _______________________________________________
>>>>> fieldtrip mailing list
>>>>> https://mailman.science.ru.nl/mailman/listinfo/fieldtrip <https://mailman.science.ru.nl/mailman/listinfo/fieldtrip>
>>>>> https://urldefense.com/v3/__https://doi.org/10.1371/journal.pcbi.1002202__;!!HJOPV4FYYWzcc1jazlU!8mwcfczjzqZxkKO2dAWjyEaLc9exEHMp0N2DmbF_qrB8_J104ES-INo06rwjXquNN8Z0H3QkMYyrN9SUUxoEN5zBk_5C58M8w42Quw$ <https://urldefense.com/v3/__https://doi.org/10.1371/journal.pcbi.1002202__;!!HJOPV4FYYWzcc1jazlU!8mwcfczjzqZxkKO2dAWjyEaLc9exEHMp0N2DmbF_qrB8_J104ES-INo06rwjXquNN8Z0H3QkMYyrN9SUUxoEN5zBk_5C58M8w42Quw$> 
>>>> 
>>>> _______________________________________________
>>>> fieldtrip mailing list
>>>> https://mailman.science.ru.nl/mailman/listinfo/fieldtrip <https://mailman.science.ru.nl/mailman/listinfo/fieldtrip>
>>>> https://urldefense.com/v3/__https://doi.org/10.1371/journal.pcbi.1002202__;!!HJOPV4FYYWzcc1jazlU!8S1TsJiRG65grM_aJserUlV8Fg61MQ8l1w2KAzL5QOFhM_44qxqlBxp_j17mvholn44jMr2lW3OyQLXyuQ$  <https://urldefense.com/v3/__https://doi.org/10.1371/journal.pcbi.1002202__;!!HJOPV4FYYWzcc1jazlU!_VIpM4ghDQ68RPiJf0gTPHPbqEALBIlPVHTwzBgbRzyUnVntFM80leE-tskp4Qf3UQzJxzRrIk_S2Bk0WA$>
>>> 
>> _______________________________________________
>> fieldtrip mailing list
>> https://mailman.science.ru.nl/mailman/listinfo/fieldtrip <https://mailman.science.ru.nl/mailman/listinfo/fieldtrip>
>> https://urldefense.com/v3/__https://doi.org/10.1371/journal.pcbi.1002202__;!!HJOPV4FYYWzcc1jazlU!5nYDiviMydBKAIUumUoC-7Wc0TSgaG1O1dnjKB8nSa6FSASMoLYo1RmOxS7vdHXXhw3sF9AH-4b1u-A7aVrnCIZaVO0vAZ12NGlReA$ <https://urldefense.com/v3/__https://doi.org/10.1371/journal.pcbi.1002202__;!!HJOPV4FYYWzcc1jazlU!5nYDiviMydBKAIUumUoC-7Wc0TSgaG1O1dnjKB8nSa6FSASMoLYo1RmOxS7vdHXXhw3sF9AH-4b1u-A7aVrnCIZaVO0vAZ12NGlReA$>
> _______________________________________________
> fieldtrip mailing list
> https://mailman.science.ru.nl/mailman/listinfo/fieldtrip
> https://urldefense.com/v3/__https://doi.org/10.1371/journal.pcbi.1002202__;!!HJOPV4FYYWzcc1jazlU!8S1TsJiRG65grM_aJserUlV8Fg61MQ8l1w2KAzL5QOFhM_44qxqlBxp_j17mvholn44jMr2lW3OyQLXyuQ$ 

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


More information about the fieldtrip mailing list