今天为了研究生工作需要,一直在找PLV的代码。因为有的代码很难用,在这里分享一下我找到的相对好用的代码。
代码地址如下:
https://ww2.mathworks.cn/matlabcentral/fileexchange/71739-plv-phase-locking-value?s_tid=srchtitle
代码如下:
function [ plv ] = PLV( phase_sig1, phase_sig2 )
% Compute the Phase Locking Value between two signals across trials, according to Lachaux,
% Rodriguez, Martinerie, and Varela (1999). The PLV value ranges from 0, indicating random
% phase differences, to 1 indicating a fixed phase difference.
% phase_sig1 and phase_sig2 should be the phase values of the signals in radians, arranged as
% Samples x Trials. These can bed
% computed using the Wavelet or Hilbert transform, for example:
% phase_sig = angle(hilbert(BPS));
% Where BPS is the signal after band-pass filtering around the frequency range of interest.
%
% Written by Edden Gerber 2012
[~, Ntrials] = size(phase_sig1);
% compute PLV
e = exp(1i*(phase_sig1 - phase_sig2));
plv = abs(sum(e,2)) / Ntrials;
end
这个代码在用之前需要我们手动计算信号的相位值,具体见代码自带注释,大概是angle(hilbert(信号))这样。
……第一次投稿,代码不是我写的 但是这博客是我写的,姑且先用原创这个分类