Home > NoiseTools > nt_qpca.m

nt_qpca

PURPOSE ^

[squares,quads]=nt_qpca(x,npcs,nsmooth,nquads) - quadratic PCA

SYNOPSIS ^

function [squares,quads,D]=nt_qpca(x,npcs,nsmooth,nquads)

DESCRIPTION ^

[squares,quads]=nt_qpca(x,npcs,nsmooth,nquads) - quadratic PCA

  squares: linear components closest to largest quadratic component 
  quads: largest quadratic component(s)
  D: eigenvalues

  x: data (time*channel*trial)
  npcs: maximum number of data PCs to use [default: all]
  nsmooth: square smoothing window to apply to xproducts [default: 1]
  nquads: number of quadratic components to return [default: 1]

 NoiseTools.

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function [squares,quads,D]=nt_qpca(x,npcs,nsmooth,nquads)
0002 %[squares,quads]=nt_qpca(x,npcs,nsmooth,nquads) - quadratic PCA
0003 %
0004 %  squares: linear components closest to largest quadratic component
0005 %  quads: largest quadratic component(s)
0006 %  D: eigenvalues
0007 %
0008 %  x: data (time*channel*trial)
0009 %  npcs: maximum number of data PCs to use [default: all]
0010 %  nsmooth: square smoothing window to apply to xproducts [default: 1]
0011 %  nquads: number of quadratic components to return [default: 1]
0012 %
0013 % NoiseTools.
0014 
0015 
0016 if nargin<4||isempty(nquads); nquads=1; end
0017 if nargin<3||isempty(nsmooth); nsmooth=1; end
0018 if nargin<2; error('!'); end
0019 [nsamples,nchans,ntrials]=size(x);
0020 
0021 x=[x,ones(nsamples,1,ntrials)*max(abs(x(:)))]; % append a DC component to absorb DC
0022 
0023 if nargout==1;
0024     tosquares=nt_qpca0(x,npcs,nsmooth,nquads);
0025 else
0026     [tosquares,quads,D]=nt_qpca0(x,npcs,nsmooth,nquads);
0027     quads=quads(:,2:end,:); % discard first (DC)
0028 end
0029 
0030 squares=nt_mmat(x,tosquares);
0031 squares=nt_demean2(squares);
0032 
0033 
0034 
0035 
0036

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