# Compute phase coherence between two eeg signals

I have two EEG signals/channels and I would like to compute phase coherence in MATLAB. I have this paper: https://www.nature.com/npp/journal/v39/n5/full/npp2013330a.html but it does not say what Sij is so I don't know the formula.

Can anyone advise me on how to do this or does anyone have MATLAB code?

Many thanks.

• Wouldn't the cross correlation function give you this (xcorr is Matlab)? It will give you relative coherence versus time delay between the two signals. Commented Jun 24, 2017 at 17:18
• @DanBoschen Phase coherence outputs a value between 0 and 1. I don't think xcorr does that. Commented Jun 24, 2017 at 17:28
• Sure it does, you just need to normalize it by dividing by the total number of samples and the standard deviations of both signals. Commented Jun 24, 2017 at 17:30
• He is asking for phase coherence
– user28715
Commented Jun 24, 2017 at 17:34
• @StanleyPawlukiewicz Correlation implies phase coherence; the only way you can get a normalized correlation magnitude of 1 between two signals is if they are coherent in phase. The complex result will indicate the phase shift between the signals and by using the cross correlation function you can detect if there is a gross time delay between the signals (yet they are still phase coherent once aligned in time by the static offset) Commented Jun 25, 2017 at 11:01

## 1 Answer

Perhaps the built-in 'mscohere' and 'cpsd' functions may help you.

The mscohere function returns a value between 0 and 1 that measures the correlation between the signals, and the phase delay can be computed using the cpsd function, as per this example from the Mathworks website. It suggests that the relative phase between the correlated components can be estimated with the cross-spectrum phase.

https://uk.mathworks.com/help/signal/examples/measuring-signal-similarities.html#d119e1563

Taken from the Mathworks page above

[Cxy,f] = mscohere(sig1,sig2,[],[],[],Fs);
Pxy     = cpsd(sig1,sig2,[],[],[],Fs);
phase   = -angle(Pxy)/pi*180;