Home > NoiseTools > nt_find_clipped_trials.m

nt_find_clipped_trials

PURPOSE ^

SYNOPSIS ^

function [idx,n_clipped]=nt_find_clipped_trials(x,threshold,bounds)

DESCRIPTION ^

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function [idx,n_clipped]=nt_find_clipped_trials(x,threshold,bounds)
0002 
0003 error('not yet implemented')
0004 
0005 %[idx,n_clipped]=nt_find_clipped_trials(x,threshold,bounds) - find clipped trials
0006 %
0007 %  idx: indices of trials to keep
0008 %  n_clipped: number of clipped samples per trial
0009 %
0010 %  x: data (time * channels * trials)
0011 %  threshold: admissible proportion of clipped samples [default: 0]
0012 %  bounds: clipping bounds [default: max & min of data]
0013 %
0014 %
0015 % NoiseTools
0016 
0017 if nargin<2; threshold=0; end
0018 if nargin<3; bounds=[]; end
0019 if threshold>1; error('proportion should be within [0 1])'); end
0020 
0021 if nargout==0;
0022     [idx,n]=nt_find_outlier_trials(x,proportion,mn);
0023     plot(n);
0024     xlabel('trial'); ylabel('number clipped'); 
0025     clear idx n
0026     return
0027 end
0028 
0029 [m,n,o]=size(x);
0030 
0031 mx=max(nt_unfold(x));
0032 mn=min(nt_unfold(x));
0033 
0034 x1=repmat(mx,[m,1,o])-x; % zero for clipped, pos for OK
0035 x1=min(x1,[],2); % min over channels
0036 x2=x-repmat(mn,[m,1,o]); % zero for clipped, pos for OK
0037 x2=min(x2,[],2); % min over channels
0038 xx=min(x1,x2); % zero for clipped samples
0039 
0040 y=zeros([m,1,o]);
0041 y(find(xx==0))=1;
0042 y=reshape(y,[m,o]); y=sum(y);
0043 
0044 plot(y);
0045

Generated on Mon 10-Nov-2014 14:40:42 by m2html © 2005