The Neurophysiological Biomarker Toolbox (NBT)



2. Effect of noise on coherence computation

noise1 = randn(N,1); % noise 1
noise2 = randn(N,1); % noise 2

%--- extract  coherence function
[C,f]=mscohere(noise1,noise2,W,[],W_length,fs);

figure
subplot(2,2,1)
plot(t,noise1,'b')
hold on
plot(t,noise2,'r')
axis tight
xlabel('time sec')
subplot(2,2,2)
plot(f,C)
ylabel('MSC')
xlabel('frequency')
axis tight
ylim([0 1])
% we compute MSC for increasing noise in the signals
for n = 0:0.1:1; % level of noise influence
    % s1 and s2 with added noise
    s1 = A1*sin(2*pi*t*f1)+A2*sin(2*pi*t*f2)+n*randn(size(t));
    s2 = A1*sin(2*pi*t*f1/2)+A2*sin(2*pi*t*f2)+n*randn(size(t));
    [C,f]=mscohere(s1,s2,W,[],W_length,fs);
    hold on
    subplot(2,2,3)
    plot(t,s1,'b')
    hold on
    axis tight
    plot(t,s2,'r')
    xlabel('time sec')
    subplot(2,2,4)
    hold on
    plot(f,C)
    ylabel('MSC')
    xlabel('frequency')
    axis tight
    ylim([0 1])
end
tutorial/coherence/cohercode2.txt · Last modified: 2012/01/09 15:23 by Giusi Schiavone
The NBTwiki platform - version 2.8 - 9 May 2013
Copyright (C) 2008-2015