Home > NoiseTools > nt_find_clipped.m

nt_find_clipped

PURPOSE ^

w=nt_find_clipped_trials(x,bounds) - find clipped trials

SYNOPSIS ^

function w=nt_find_clipped(x,bounds)

DESCRIPTION ^

w=nt_find_clipped_trials(x,bounds) - find clipped trials

  w: 0: clipped, 1: OK
  
  x: data (time * channels * trials)
  bounds: data bounds matrix (nchans x 2) [default: max & min of data in each channel]
 
 Clipping is presumed to occur on a channel if:
  - the value is greater than 'bounds' for that channel, or
  - the value remains at min or max for at least 3 consecutive samples and
  min and max are not zero

 NoiseTools

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function w=nt_find_clipped(x,bounds)
0002 %w=nt_find_clipped_trials(x,bounds) - find clipped trials
0003 %
0004 %  w: 0: clipped, 1: OK
0005 %
0006 %  x: data (time * channels * trials)
0007 %  bounds: data bounds matrix (nchans x 2) [default: max & min of data in each channel]
0008 %
0009 % Clipping is presumed to occur on a channel if:
0010 %  - the value is greater than 'bounds' for that channel, or
0011 %  - the value remains at min or max for at least 3 consecutive samples and
0012 %  min and max are not zero
0013 %
0014 % NoiseTools
0015 
0016 if nargin<2; bounds=[]; end
0017 
0018 [m,n,o]=size(x);
0019 
0020 w=zeros(m,1,o);
0021 for k=1:n
0022     xx=x(:,k,:);
0023     mx=max(nt_unfold(xx));
0024     mn=min(nt_unfold(xx));
0025     ww=zeros(m,1,o);
0026     ww(find(xx==mx))=1;
0027     ww(find(xx==mn))=1;
0028     www=ww(1:end-2,:,:).*ww(2:end-1,:,:).*ww(3:end,:,:);
0029     if find(www>0) % clipping occured
0030         w=max(w,ww);
0031     end
0032 end
0033 
0034 w=1-w;

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