# Comparing similarity of two simultaneously recorded EEGs in freq domain

I have two EEG signals that are simultaneously recorded during the night (sleep). Imagine one device recorded from channel F4 and the other from Fp2. Now I would like to check the similarity of these signals, so, the first step is to sync them which has been done successfully using cross-correlation :)

I can also report some similarity metrics in time-domain, e.g. Pearson correlation per window (e.g. each 30 s) to quantify the similarity of signals.

The problem arises when I want to compare (or let's say quantify) them in the freq domain. When I plot e.g. spectrogram or PSD we can see their similarity visually; however, I don't know how to quantify this similarity in the frequency domain. By vision the spectrograms (or PSDs) are quite similar but I guess it is not a powerful reason without reporting any similarity metric as a number. Is there any metric by which I can report similarity of PSDs or spectrograms window-by-window and based on each frequency bin (Delta, Theta, etc)?

• What is wrong with something like $mean(abs(\text{F4} - \text{Fp2}))$? Commented Jul 16, 2020 at 11:18

You can express correlation in the frequency domain but the closest thing to what you are describing would be Coherence.

It returns a number between 0 and 1 per each frequency bin of the spectrum. The closest this number is to 1 the more "similar" the signals would be and you can average this number over the whole spectrum or over a frequency range.

Hope this helps.

• Thanks, A_A for your response. I am indeed using Coherence but I am doubtful why the values are too low. When I look at 30-s windows of data, the cross-correlations (pearson corr) are quite high (>70%) but when it comes to Coherence, the values are unexpectedly low (even the peak amplitudes do not exceed e.g. 0.4- 0.5! I was wondering if I just need to look at the frequency bins in which I have peak or the amplitude of the peak in Coherence also plays an essential role? Commented Jul 16, 2020 at 13:30
• I know in general that any value above 0.3 - 0.4 in cross-correlation shows there exists a similarity between data. Do we have such a range in Coherence also? Commented Jul 16, 2020 at 13:32
• @TheJohn Coherence is versus frequency and therefore you would have to look at the frequency ranges of interest. In general, coherence and correlation should agree. Beyond this, you could check the relative linearity between the two recorded waveforms and the parameters of coherence (assuming you are using something like this (?)).
– A_A
Commented Jul 16, 2020 at 15:39

Thanks again @A_A! Yes, I am using exactly the same function (scipy.signal.coherence). I have a roughly flat coherence over all frequencies (f > 5Hz) which is good: it means that the 2nd device doesn't magnify some specific freqs unnecessarily and have the same similarity with device 1 over all freq ranges.

Just as a short recap: my aim is to kind of prove that 2nd EEG device collects similar signals with respect to the ground truth (EEG device 1) --> So device 2 can be used also as a reliable EEG recorder. Please note that device 1 has an electrode at Fp1 location, though the electrode of device 2 was placed at F4 location, so we cannot expect extremely high correlation or coherence (I guess, right?).

My problem now is that the mean of coherence plot is around 0.20, however, I had almost 0.5 and 0.40 when talking about Pearson correlation and spearman, respectively. Does this difference between coherence and time-domain correlations (pearson or spearman) make sense? Can we accept 20% coherence as an acceptable value that the both signals are similar? I know that the pearson of 50% shows a good similarity, but I have no clue about coherence (and couldn't find anywhere any clear answer to this).

I show the coherence plot during different sleep stages and different freq bins bellow: Coherence between F4 (EEG device 1) and Fp2 (EEG device 2) during sleep. Freq range of interest is 0-30 Hz. Coherence is calculated over windows of 5 seconds.