Home > NoiseTools > nt_xprod2.m

nt_xprod2

PURPOSE ^

[y,ind]=nt_xprod(x1,x2,dsratio) - form all crossproducts

SYNOPSIS ^

function [y]=nt_xprod2(x1,x2,dsratio)

DESCRIPTION ^

[y,ind]=nt_xprod(x1,x2,dsratio) - form all crossproducts

  y: crossproducts 
 
  x1,x2: data (time*channels*trials)
  dsratio: ratio by which to downsample cross-product.

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function [y]=nt_xprod2(x1,x2,dsratio)
0002 %[y,ind]=nt_xprod(x1,x2,dsratio) - form all crossproducts
0003 %
0004 %  y: crossproducts
0005 %
0006 %  x1,x2: data (time*channels*trials)
0007 %  dsratio: ratio by which to downsample cross-product.
0008 
0009 if nargin<3 || isempty(dsratio); dsratio=1; end
0010 if nargin<2 ; error('!'); end
0011 
0012 if ndims(x1) ~= ndims(x2); error('!'); end
0013 if size(x1,1)~=size(x2,1); error('!'); end
0014 
0015 if ndims(x1)==3
0016     y=nt_fold(nt_xprod2(nt_unfold(x1),nt_unfold(x2),dsratio),size(x1,1));
0017 else
0018     [nsamples,nchans1]=size(x1);
0019     [nsamples,nchans2]=size(x2);
0020     nsamples=floor(nsamples/dsratio);
0021 
0022     for iChan1=1:nchans1
0023         xx=bsxfun(@times,x2,x1(:,iChan1));
0024         y(:,(iChan1-1)*nchans2+(1:nchans2))=nt_dsample(xx,dsratio);
0025     end
0026 end

Generated on Sat 29-Apr-2023 17:15:46 by m2html © 2005