Home > NoiseTools > EXAMPLE > example1.m

# example1

## PURPOSE

Find the linear combinations of multichannel data that

## SYNOPSIS

This is a script file.

## DESCRIPTION

     Find the linear combinations of multichannel data that
     maximize repeatability over trials.  Data are time*channel*trials.

     Uses nt_dss0().

## CROSS-REFERENCE INFORMATION

This function calls:

This function is called by:

## SOURCE CODE

    0001 % Find the linear combinations of multichannel data that
    0002 % maximize repeatability over trials.  Data are time*channel*trials.
    0003 %
    0004 % Uses nt_dss0().
    0005
    0006 clear;
    0007 disp(mfilename);
    0008 help(mfilename)
    0009
    0010 % create synthetic data
    0011 nsamples=100*3;
    0012 nchans=30;
    0013 ntrials=100;
    0014 noise_dim=20; % dimensionality of noise
    0015 source=[zeros(nsamples/3,1);sin(2*pi*(1:nsamples/3)/(nsamples/3))';zeros(nsamples/3,1)];
    0016 s=source*randn(1,nchans);
    0017 s=repmat(s,[1,1,100]); % evoked
    0018 SNR=0.1;
    0019 noise=nt_mmat(randn(nsamples,noise_dim,ntrials), randn(noise_dim,nchans));
    0020 data=noise/rms(noise(:))+SNR*s/nt_rms(s(:));
    0021
    0022 % apply DSS to clean them
    0023 c0=nt_cov(data);
    0024 c1=nt_cov(mean(data,3));
    0025 [todss,pwr0,pwr1]=nt_dss0(c0,c1);
    0026 z=nt_mmat(data,todss);
    0027
    0028
    0029 % plot results
    0030 figure(1); clf
    0031 subplot 131;
    0032 plot(source); title('source');
    0033 subplot 132;
    0034 plot(mean(data,3)); title('data');
    0035 subplot 133;
    0036 nt_bsplot(z(:,1,:)); title('recovered');
    0037