Within subjects permutation for dwPLI

Hi Mike,

I was wondering if I might be able to have some advice on 2 aspects of computing EEG inter-site connectivity using de-biased weighted PLI using phase-angles extracted via the Hilbert transform.

I have attached two screen shots (below) of some MATLAB code which I have pieced together from lessons in ANTSD and your Udemy course.

The screen shot starting with “General procedure” outlines computing dwPLI following the Hilbert transform (steps 1-5; the signals are filtered at 2-7 Hz based off prior work/separate analyses). I am not 100% sure however if I am computing all steps correctly up to the dwPLI.

In the screen shot starting with “Create Null Distribution…”, I am wanting to z-score normalise dwPLI for each individual subject. To create a null distribution reflecting no connectivity, I have (attempted to) randomly shifting the phase-angle time series at each trial for one channel relative to the other. However, I am not quite sure if I have shifted/shuffled correctly.

Any help, advice or tips on the code would be great thank you (but no worries if not or if there’s too much going on here :slight_smile: )
All the best,

Hi James. It looks OK to me. Always a good idea to plot the phase angle time series from a few random trials to make sure there are no transposing errors.

But you don’t actually compute fake_dwPLI in the permutation loop. Make sure that gets included :wink: It’s also a good idea to inspect that null distribution to make sure you’re really creating a distribution and it isn’t the same value computed N times.

Thanks so much Mike.

I’m not quite sure about where to compute the “fake_dwPLI”- so I wouldn’t have 1000 (permutes) x dwPLI on phase-shuffled data?

I’ve attached a copy of the full code (please see below) that I would have used to compute the permuted dwPLI values (but based on not computing “fake_dwPLI” in the permutation loop I assume this isn’t correct).

I’ve also attached a histogram of the null distribution generated from the attached code, which initially I feel doesn’t look right, although I am wondering if this is related to the fact that dwPLI values range between 0-1 (with some negative values)?

Thanks again :slight_smile:


That looks right to me. The “d” is for debiased and the “w” is for weighted; those normalization terms can make the PLI dip below zero.

Fantastic! Thanks so much again Mike :slight_smile: