Weighted phase lag index

There is no "weighted phase lag index" in the connectivity menu bar. There is also no .m script for WPLI in the dir "brainstorm3\toolbox\process\functions". I think it is impossible for me to save and modify an existing script for the index. There is an FieldTrip function for calculating WPLI at senser level. Is there any possible way in Brainstorm to calculate the WPLI at source level?

1 Like

@Sylvain @leahy @hossein27en @peterd @Guiomar?

Hello:

WPLI is indeed not part of Brainstorm’s distribution. We encourage you to use directed phase transfer entropy as a an alternative method. If you can provide a generic Matlab function (maybe adapted from Fieldtrip’s) that can produce WPLI measures on basic time series, we could then easily add it to Brainstorm’s library.

Thank you,

Hi everyone!
I just want to suggest that maybe BS can include this connectivity metric (wPLI), I was reading about it and it seems to be the best today EEG connectivity measure, It could be so useful to compute it in BS!

Well, it just a suggestion, I know it is not and easy thing to do and I'm grateful with all the BS team for the software they free offer to us: Thank you!

Pd: Would you consider add directional (causal) Connectivity Graphs (with bows) to BS, it could be wonderful to compute an EEG connectome using BS! (yes, I know, it's just and idea)

Thanks in advance

@hossein27en @Sylvain ?

I hope BS will have in the future this measure, and the chance to display directed measures on the graph option, with arrows, :slight_smile: just saying...

Yes please!
I've always wanted to compute wPLI with Brainstorm!!!
:smiley:
(I guess it will be the debiased form?)
Thank in advances!!!

I opened a PR to discuss the implementation:
https://github.com/brainstorm-tools/brainstorm3/pull/497

Can you please comment directly in there?
Thanks

Merged here:

just to be sure: that feature is not available on the GUI yet, right? :slight_smile:

Yes, it is, from the PLV process:
https://neuroimage.usc.edu/brainstorm/Tutorials/Connectivity#Phase_locking_value

1 Like

Awesome!!!
just one more doubt: is this wPLI version the same as fieldtrip (debiased), since wPLI sometimes has a positive bias?

https://www.fieldtriptoolbox.org/reference/ft_connectivityanalysis/

" ```
'wpli', weighted phase lag index (signed one, still have to
take absolute value to get indication of strength of
interaction. Note that this measure has a positive
bias. Use wpli_debiased to avoid this.
'wpli_debiased' debiased weighted phase lag index (estimates squared wpli)

Thanks in advance

just one more doubt: is this wPLI version the same as fieldtrip (debiased), since wPLI sometimes has a positive bias?
https://www.fieldtriptoolbox.org/reference/ft_connectivityanalysis/

@danielemarinazzo?

This is a different version with respect to the one implemented in fieldtrip, as a matter of fact they only have one possible over multiple trials, here we have an implementation keeping the time information, and one which you can in principle calculate on a single trial, as the difference between the angles.

Apart from this, I find this ironic

and I would not wrap my head too much around these issues :slight_smile:

2 Likes

thanks a lot!!! :smiley:

No worries. If you really are into it, the implementation is not difficult, but I wouldn't know how to put it in Brainstorm for the way trials are handled/averaged.

Here the code, in case @Francois or others have an idea on how to deal with the final part, I'll be happy to assist

wRs=complex(zeros(nt,4),0);

% initializations below for the debiased version
wRsnum1=wRs;wRsden1=wRs;wRsnum2=wRs;wRsden2=wRs;

for itrials=1:ntrials
    HA=squeeze(datah(:,itrials,:));HB=squeeze(datah(:,itrials,:));
    phaseA = HA(iA,:) ./ abs(HA(iA,:));
    phaseB = HB(iB,:) ./ abs(HB(iB,:));
     cdd = phaseA .* conj(phaseB);
    cdi = imag(cdd);
    wRs=wRs+(abs(cdi).*sign(cdi))'./abs(cdi)';

% below here the extra part for the debiased version

    wRsnum1=wRsnum1+(abs(cdi).*sign(cdi))';
    wRsnum2=wRsnum2-(((abs(cdi).*sign(cdi))').^2)/ntrials;
    wRsden1=wRsden1+abs(cdi)';
    wRsden2=wRsden2-(((abs(cdi).*sign(cdi))').^2)/ntrials;
end

After this loop, Brainstorm simply does the average, that would be
wPLI=abs(wRs/ntrials);

On the other hand for the debiased version, this should be done after collecting the info from all the trials
wPLI_db=sqrt((wRsnum1.^2-wRsnum2)./((wRsden1.^2-wRsden2)));

and I don't know how to do this without breaking too much stuff.

1 Like