Home > src > visualizeTrackDist.m

visualizeTrackDist

PURPOSE ^

visualize the gaze data

SYNOPSIS ^

function visualizeTrackDist( leftEyePos, leftOri, imgFile, varParams, stimSize )

DESCRIPTION ^

 visualize the gaze data

 Syntax:  visualizeTrackSingle(  leftEyePos, leftOri, imgFile, varParams, stimSize)
 
 Inputs: 
        leftEyePos: vector of complex eye tracks in [0,1] range 
        leftOri: optional unfiltered tracks( if leftEyePos filtered), 
           leave [] to not plot 
        imgFile: a string specifying the image stimulus file, like 'image.bmp',
        varParams: struct which specifies the parameters for detecting
           fixations (using IDT algorithm) and saccades. See lines 20-24
           for the possible parameters

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 % visualize the gaze data
0002 %
0003 % Syntax:  visualizeTrackSingle(  leftEyePos, leftOri, imgFile, varParams, stimSize)
0004 %
0005 % Inputs:
0006 %        leftEyePos: vector of complex eye tracks in [0,1] range
0007 %        leftOri: optional unfiltered tracks( if leftEyePos filtered),
0008 %           leave [] to not plot
0009 %        imgFile: a string specifying the image stimulus file, like 'image.bmp',
0010 %        varParams: struct which specifies the parameters for detecting
0011 %           fixations (using IDT algorithm) and saccades. See lines 20-24
0012 %           for the possible parameters
0013 
0014 function visualizeTrackDist(  leftEyePos, leftOri, imgFile, varParams, stimSize )
0015 
0016 
0017 % default fixation paramters
0018 if ~isfield( 'varParams', 'fixMinNumSamples'); varParams.fixMinNumSamples = 6;  end  % in number neighboring samples, 6 scamples correspond to 100ms at 60Hz
0019 if ~isfield( 'varParams', 'fixMaxCircleRadius'); varParams.fixMaxCircleRadius = 15;  end % in pixels, half diameter
0020 % identify saccades as exceeding a certain velocity, then slow down
0021 if ~isfield( 'varParams', 'velThreshold'); varParams.velThreshold = 20; end
0022 if ~isfield( 'varParams', 'stopThreshold'); varParams.stopThreshold = 8; end
0023 
0024 fixMinNumSamples = varParams.fixMinNumSamples;
0025 fixMaxCircleRadius = varParams.fixMaxCircleRadius;
0026 velThreshold = varParams.velThreshold;
0027 stopThreshold = varParams.stopThreshold;
0028 
0029 
0030 % load stimulus image
0031 if isempty(imgFile)
0032     A = zeros( stimSize(1), stimSize(2), 3);
0033 else
0034     A = imread( imgFile ); 
0035 end
0036 
0037 % setup figure
0038 % close all
0039 hFig=figure(2);
0040 set( hFig, 'renderer', 'opengl')
0041 axis off;
0042 set(hFig,'renderermode','auto');
0043 
0044 
0045 % scale acoording to image size (if it is within the [0 1] range)
0046 if max(real(leftEyePos)) <= 1
0047     leftEyePos = scaleEyeTrack( leftEyePos, size(A(:,:,1)) );
0048     if ~isempty( leftOri )
0049         leftOri = scaleEyeTrack(leftOri, size(A(:,:,1)) );
0050     end
0051 end
0052 numSamples = length( leftEyePos );
0053 
0054 % extract fixation information
0055 fprintf( 'Finding fixations and saccades... ');
0056 fixStruct = codeFixationsDist( leftEyePos, fixMinNumSamples, fixMaxCircleRadius );
0057 leftFixation = fixStruct.fixationVector;
0058 sacStruct = codeSaccadesDist( leftEyePos, velThreshold, stopThreshold);       
0059 leftSaccade =  sacStruct.saccadeVec;    
0060 fprintf( 'done!\n');
0061 
0062 % now plot the eye tracks
0063 secCount = 0;
0064 for i1 = 2:1:numSamples  % for (near) real time, step by 2
0065     % show appropriate image
0066     imshow( A );  % imagesc faster than imshow
0067     %show fixations and saccades
0068     if  leftFixation(i1)~=0
0069         % left fixations
0070         text(100,60, ['F' int2str(leftFixation(i1))], 'fontsize', 30, 'color', 'b' ); 
0071     end        
0072     if  leftSaccade(i1)~=0 
0073         %left Saccade
0074         text(100,100, ['S' int2str(leftSaccade(i1))], 'fontsize', 30, 'color', 'b' ); 
0075     end
0076     % plot the eye tracks
0077     hold on; 
0078     plot( leftEyePos(i1), 'b*' );        
0079     if ~isempty( leftOri )
0080         plot( leftOri(i1), 'w.' );
0081     end
0082     pause(.02);
0083     % update time, assuming sampling at 60Hz
0084     if mod( i1, 60 ) == 0
0085         secCount = secCount+1;
0086     end
0087 
0088     hold off;
0089 end

Generated on Wed 20-Jan-2016 11:50:43 by m2html © 2005