0001 function [cross_trial, fft_trial] = fastcsdm(trialdata)
0002
0003
0004
0005
0006
0007
0008 trialdata = zeromean(trialdata);
0009 fft_trial = fft(trialdata)./(size(trialdata,1)+1);
0010
0011 nfreq = size(trialdata,1)/2;
0012 nchan = size(trialdata,2);
0013
0014 cross_trial = zeros(nfreq,(nchan.^2+nchan)/2);
0015 cross_prod = zeros(nchan);
0016
0017 relevant_indices = find(tril((1:nchan)'*(1:nchan)));
0018
0019 if strcmp(computer, 'MAC2')
0020 disp('Run this on a real machine')
0021 else
0022 for ifreq = 1:nfreq
0023 chanvect = fft_trial(ifreq,:);
0024 cross_prod = chanvect.'*conj(chanvect);
0025 cross_trial(ifreq,:) = cross_prod(relevant_indices)';
0026 end;
0027 end