0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017 function eyeTrack = filterEyeTrackInfant( eyeTrack, smoothParam )
0018
0019
0020
0021
0022
0023
0024 eyeTrack = [real(eyeTrack) imag(eyeTrack) ];
0025 eyeTrack( eyeTrack == -1) = nan;
0026
0027 t = ones( 1, length( eyeTrack ) );
0028 t( isnan( eyeTrack(:,1) )) = -1;
0029
0030 if nargin < 2 || isempty( smoothParam)
0031 smoothParam = .0003;
0032
0033
0034 end
0035
0036 known = find( t == 1);
0037 while(known(2)-known(1) >1)
0038 known(1) = [];
0039 end
0040
0041
0042
0043 missingWindow = 4;
0044 interpThese = ones( 1, length( eyeTrack ) );
0045 for i1 =missingWindow:length(interpThese)
0046 i1_check = i1 - [missingWindow-1:-1:0];
0047 if sum( t(i1_check) == -1) == missingWindow
0048 interpThese( i1_check ) = 0;
0049 end
0050 end
0051
0052 k1 = 1;
0053 inABlock = 0;
0054 for i1 = 1:length(interpThese)
0055 if (inABlock==0) && (interpThese(i1) ==1)
0056 startInterp(k1) = i1;
0057 inABlock = 1;
0058 end
0059 if (inABlock==1) && (interpThese(i1) ==0)
0060 endInterp(k1) = i1-1;
0061 inABlock = 0;
0062 k1 = k1+1;
0063 end
0064
0065 if (i1 ==length(interpThese)) && (inABlock==1)
0066 endInterp(k1) = i1;
0067 end
0068 end
0069
0070
0071 for i1 = 1:length( startInterp )
0072 [eyeTrack1]=kalmanMissingData( eyeTrack(startInterp(i1):endInterp(i1),:)', t(startInterp(i1):endInterp(i1)), smoothParam)';
0073 eyeTrack(startInterp(i1):endInterp(i1),:) = eyeTrack1;
0074 end
0075
0076 eyeTrack(isnan(eyeTrack)) = -1;
0077 eyeTrack = eyeTrack(:,1)+1i*eyeTrack(:,2);
0078
0079