function out=legTrackerPrepCorrs(data,windowSize) %legTrackerPrepCorrs takes instrument data and returns the pairwise %correlation coefficients between data vectors within a sliding window. %Padded by zeros. Evaluated in Figure 2d, but NOT USED for the final %classification protocol in Kain et al. %Usage: %out=legTrackerPrepCorrs(data,windowSize) %data = raw data from instrument. %windowSize = 1/2 length of sliding window for calculating local % correlation coefficients %allocate space in memory for output numFrames=size(data,1); temp=zeros(size(data,1),66); %constant for which coordinates of cross-correlation matrix to retain triangle=triu(ones(12,12),1); triangle=triangle(:); %for all frames, excluding those when the window overflows for i=windowSize+1:numFrames-windowSize %pairwise correlations between data vectors in each window corrs=corr(data(i-windowSize:i+windowSize,1:12)); %take 1 per pair. corrs=corrs(:); corrs=corrs(triangle==1); temp(i,:)=corrs'; end %replace nans with 0s and output temp(isnan(temp))=0; out=temp;