Home > NoiseTools > nt_qca2.m

# nt_qca2

## PURPOSE

[square,quad,square2,quad2,D]=nt_qca(x,npcs,nsmooth) - maximize induced power using quadratic component analysis

## SYNOPSIS

function [squares,quad,squares2,quad2,D]=nt_qca2(x,npcs,nsmooth)

## DESCRIPTION

    [square,quad,square2,quad2,D]=nt_qca(x,npcs,nsmooth) - maximize induced power using quadratic component analysis

      square: linear component closest to most repeatable quadratic component
      quad: most reproducible quadratic component
      square2: linear component closest to least repeatable quadratic component
      quad: least reproducible quadratic component
      D: eigenvalues

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

      Usually we are interested in the first component of 'squares'
      (component with square closest to best quadratic component).

     NoiseTools.

## CROSS-REFERENCE INFORMATION

This function calls:

- nt_demean2 y=nt_demean2(x,w) - remove mean of each row and page
- nt_mmat y=nt_mmat(x,m) - matrix multiplication (with convolution)
- nt_qca02 [tosquare,quad,tosquare2,quad2,D]=nt_qca02(x,npcs,nsmooth) - maximize induced power using quadratic component analysis

This function is called by:

## SOURCE CODE

    0001 function [squares,quad,squares2,quad2,D]=nt_qca2(x,npcs,nsmooth)
    0002 %[square,quad,square2,quad2,D]=nt_qca(x,npcs,nsmooth) - maximize induced power using quadratic component analysis
    0003 %
    0004 %  square: linear component closest to most repeatable quadratic component
    0005 %  quad: most reproducible quadratic component
    0006 %  square2: linear component closest to least repeatable quadratic component
    0007 %  quad: least reproducible quadratic component
    0008 %  D: eigenvalues
    0009 %
    0010 %  x: data (time*channel*trial)
    0011 %  npcs: maximum number of data PCs to use
    0012 %  nsmooth: square smoothing window to apply to xproducts [default: 1]
    0013 %
    0014 %  Usually we are interested in the first component of 'squares'
    0015 %  (component with square closest to best quadratic component).
    0016 %
    0017 % NoiseTools.
    0018
    0019
    0020 if nargin<3||isempty(nsmooth); nsmooth=1; end
    0021 if nargin<2; error('!'); end
    0022 [nsamples,nchans,ntrials]=size(x);
    0023
    0024 x=[x,ones(nsamples,1,ntrials)*max(abs(x(:)))]; % append a DC component to absorb DC
    0025
    0026 [tosquares,quad,tosquares2,quad2,D]=nt_qca02(x,npcs,nsmooth);
    0027
    0028 squares=nt_mmat(x,tosquares);
    0029 squares=nt_demean2(squares);
    0030 r=nt_repeatability(squares.^2);
    0031
    0032 %figure(10); plot(r); pause
    0033
    0034 [dummy,idx]=sort(r,'descend');
    0035 squares=squares(:,idx,:);
    0036
    0037 squares2=nt_mmat(x,tosquares2(:,1));
    0038
    0039
    0040
    0041