Home > NoiseTools > nt_narrowband_scan.m

nt_narrowband_scan

PURPOSE ^

A=nt_narrowband_scan(x,freqs,sr,Q,plotflag) - scan for narrowband components using DSS

SYNOPSIS ^

function A=nt_narrowband_scan(x,freqs,sr,Q,plotflag,yulewalk_order)

DESCRIPTION ^

A=nt_narrowband_scan(x,freqs,sr,Q,plotflag) - scan for narrowband components using DSS

  A: cell array of DSS matrices

  x: data (time*channels or time*channels*trials)
  freqs: Hz, array of bias frequencies
  sr: Hz, sampling rate
  Q: quality factors of scanning filter (default: [8 4])
  plotflag: if true plot (default: 1)
  yulewalk_order: if present apply inverse filtering with this order

 If no output arguments, plots spectra of first DSS components for each
 bias

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function A=nt_narrowband_scan(x,freqs,sr,Q,plotflag,yulewalk_order)
0002 %A=nt_narrowband_scan(x,freqs,sr,Q,plotflag) - scan for narrowband components using DSS
0003 %
0004 %  A: cell array of DSS matrices
0005 %
0006 %  x: data (time*channels or time*channels*trials)
0007 %  freqs: Hz, array of bias frequencies
0008 %  sr: Hz, sampling rate
0009 %  Q: quality factors of scanning filter (default: [8 4])
0010 %  plotflag: if true plot (default: 1)
0011 %  yulewalk_order: if present apply inverse filtering with this order
0012 %
0013 % If no output arguments, plots spectra of first DSS components for each
0014 % bias
0015 %
0016 nt_greetings;
0017 
0018 if nargin<6; yulewalk_order=[]; end
0019 if nargin<5; plotflag=[]; end
0020 if nargin<4||isempty(Q); Q=[8 4]; end
0021 if nargin<3; error('!'); end
0022 
0023 freqs=freqs(:);
0024 
0025 
0026 current_figure=get(0,'CurrentFigure');
0027 A={};
0028 for iFreqs=1:numel(freqs)
0029     freq=freqs(iFreqs);
0030     [b,a]=nt_filter_peak(freq/(sr/2),Q(1));
0031     [c0,c1]=nt_bias_filter(x,b,a);
0032     if numel(Q)==2
0033         [b,a]=nt_filter_peak(freq/(sr/2),Q(2));
0034         [~,c0]=nt_bias_filter(x,b,a);
0035     end
0036     [todss,pwr0,pwr1]=nt_dss0(c0,c1);
0037     
0038     if 1; figure(100); clf; plot(pwr1./pwr0,'.-'); title([num2str(freq), 'Hz bias']); ylabel('score');  drawnow;end
0039     
0040     A{iFreqs}=todss;
0041 end
0042 
0043 
0044 if ~nargout || ~isempty(plotflag)
0045     if isempty(current_figure);
0046         figure; 
0047     else
0048         figure(current_figure);
0049     end
0050     AA=zeros(size(x,2),numel(freqs));
0051     for iFreqs=1:numel(freqs)
0052         AA(:,iFreqs)=A{iFreqs}(:,1);
0053     end
0054     x=nt_mmat(x,AA);
0055     nfft=2.^nextpow2(size(x,1)+1)/2;
0056     MAX_NFFT=1024;  
0057     nfft=min(nfft,MAX_NFFT);
0058     nt_spect_plot2(nt_normcol(x),nfft,[],[],sr);
0059     K=round(numel(freqs)/6);
0060     set(gca,'ytick',1:K:numel(freqs), 'yticklabel',num2str(freqs(1:K:end), '%.3g')); ylabel('Hz');
0061     set(gca,'xgrid','on','xminortick','on');
0062     drawnow;
0063 end
0064 
0065 if ~nargout;     clear A; end

Generated on Thu 30-Nov-2017 17:26:18 by m2html © 2005