Real vs. spurious interactions We located the peaks in the spectral estimation and then visualized the coherences at different frequencies and locations using the following Matlab code: clear close all load P1_connectivity_data.mat [spectra, f] = pwelch(funct_data', [], [], 2^nextpow2(4*sff), sff); d = diff(f); n = round(2/d(1)); win = hamming(n); win = win/sum(win); f30 = f(f<30); % Find peak locations [~, inds] = sort(max(spectra, [], 1)); inds = inds(end-1:end); %% figure spectra1_2Hz = conv(spectra(:,inds(1)),win,'same'); spectra15_2Hz = conv(spectra(:,14),win,'same'); semilogy(f30, spectra1_2Hz(f<30), 'linewidth', 2 ) hold on semilogy(f30, spectra15_2Hz(f<30), 'linewidth', 2 ) xlabel('frequency [Hz]'); ylabel('Spectral density'); legend('Appropriate reference','Inappropriate reference', 'Location', 'Best'); Cxy = zeros(2,1025,29); [Cxy(1,:,:), f] = mscohere(funct_data(inds(1),:)', funct_data', [], [], 2^nextpow2(4*sff), sff); [Cxy(2,:,:), f] = mscohere(funct_data(14,:)', funct_data', [], [], 2^nextpow2(4*sff), sff); % Convolve with 2 Hz window Cxy2Hz = zeros(size(Cxy)); for i=1:2 for j=1:29 Cxy2Hz(i,:,j) = conv(Cxy(i,:,j), win, 'same'); end end Cxy30 = Cxy2Hz(:,f<30,:); %% figure; plot( locations, mean(squeeze(Cxy30(1,n:end,:)), 1), 'linewidth', 2 ); axis tight; hold on plot( locations, mean(squeeze(Cxy30(2,n:end,:)), 1), 'linewidth', 2 ); axis tight; xlabel('Distance'); ylabel('Coherence'); legend('Appropriate reference','Inappropriate reference', 'Location', 'Best'); % Plot magnitude squared coherence of the two source points figure; subplot(1,2,1); surf(locations, f30(n:4:end), squeeze(Cxy30(1,n:4:end,:)),'edgealpha',0.3, 'FaceColor','interp'); xlabel('location'); ylabel('frequency'); title('Appropriate reference') subplot(1,2,2); surf(locations, f30(n:4:end), squeeze(Cxy30(2,n:4:end,:)),'edgealpha', 0.3, 'FaceColor','interp'); xlabel('location'); ylabel('frequency'); title('Inappropriate reference')