


removes significant sine waves from data (continuous data).
Usage: data=rmlinesc(data,params, p)
Inputs:
Note that units of Fs, fpass have to be consistent.
data (data in [N,C] i.e. time x channels/trials) - required.
params structure containing parameters - params has the
following fields: tapers, Fs, fpass, pad
tapers (parameters for calculating tapers [NW,K]) - optional. Defaults to [3 5]
Fs (sampling frequency) -- optional. Defaults to 1.
fpass (frequency band to be used in the calculation in the form
[fmin fmax])- optional.
Default all frequencies between 0 and Fs/2
pad (padding factor for the FFT) - optional. Defaults to 0.
e.g. For N = 500, if PAD = 0, we pad the FFT
to 512 points; if PAD = 2, we pad the FFT
to 2048 points, etc.
p (P-value to calculate error bars for) - optional. Defaults to 0.05 (95% confidence).
Outputs:
data (data with significant lines removed)

0001 function data=rmlinesc(data,params, p) 0002 % removes significant sine waves from data (continuous data). 0003 % 0004 % Usage: data=rmlinesc(data,params, p) 0005 % 0006 % Inputs: 0007 % Note that units of Fs, fpass have to be consistent. 0008 % data (data in [N,C] i.e. time x channels/trials) - required. 0009 % params structure containing parameters - params has the 0010 % following fields: tapers, Fs, fpass, pad 0011 % tapers (parameters for calculating tapers [NW,K]) - optional. Defaults to [3 5] 0012 % Fs (sampling frequency) -- optional. Defaults to 1. 0013 % fpass (frequency band to be used in the calculation in the form 0014 % [fmin fmax])- optional. 0015 % Default all frequencies between 0 and Fs/2 0016 % pad (padding factor for the FFT) - optional. Defaults to 0. 0017 % e.g. For N = 500, if PAD = 0, we pad the FFT 0018 % to 512 points; if PAD = 2, we pad the FFT 0019 % to 2048 points, etc. 0020 % p (P-value to calculate error bars for) - optional. Defaults to 0.05 (95% confidence). 0021 % 0022 % 0023 % Outputs: 0024 % data (data with significant lines removed) 0025 % 0026 0027 [N,C]=size(data); 0028 if nargin < 2 || isempty(params); params=[]; end; 0029 [tapers,pad,Fs,fpass,err,trialave,params]=getparams(params); 0030 if nargin<3;p=0.05;end; 0031 params.tapers=dpsschk(tapers,N,Fs); % calculate the tapers 0032 [Fval,A,f,sig] = ftestc(data,params,p); 0033 fmax=findpeaks(Fval,sig); 0034 for ch=1:C; 0035 fsig=f(fmax(ch).loc); 0036 Nf=length(fsig); 0037 fprintf('The significant lines for channel %d and the amplitudes are \n',ch); 0038 for nf=1:Nf; 0039 fprintf('%12.8f\n',fsig(nf)); 0040 fprintf('%12.8f\n',real(A(fmax(ch).loc,ch))); 0041 fprintf('%12.8f\n',imag(A(fmax(ch).loc,ch))); 0042 end; 0043 datasine(:,ch)=exp(i*2*pi*(1:N)'*fsig/Fs)*A(fmax(ch).loc,ch)+exp(-i*2*pi*(1:N)'*fsig/Fs)*conj(A(fmax(ch).loc,ch)); 0044 end; 0045 datan=data-datasine; 0046 if nargout==0; 0047 figure;subplot(211); plot(f,Fval); line(get(gca,'xlim'),[sig sig]); 0048 px1=pmtm(data(:,1)); 0049 px2=pmtm(datan(:,1)); 0050 subplot(212);plot(1:length(px1),10*log10(px1),1:length(px2),10*log10(px2)); 0051 end; 0052 data=datan;