Home > GVSToolbox > 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 % for i2 = 1:length(gazeStruct)
0046 
0047     % scale acoording to image size (if it is within the [0 1] range)
0048     if max(real(leftEyePos)) <= 1
0049         leftEyePos = scaleEyeTrack( leftEyePos, size(A(:,:,1)) );
0050         if ~isempty( leftOri )
0051             leftOri = scaleEyeTrack(leftOri, size(A(:,:,1)) );
0052         end
0053     end
0054     numSamples = length( leftEyePos );
0055     
0056     % extract fixation information
0057     fprintf( 'Finding fixations and saccades... ');
0058     fixStruct = codeFixationsDist( leftEyePos, fixMinNumSamples, fixMaxCircleRadius );
0059     leftFixation = fixStruct.fixationVector;
0060     sacStruct = codeSaccadesDist( leftEyePos, velThreshold, stopThreshold);       
0061     leftSaccade =  sacStruct.saccadeVec;    
0062     fprintf( 'done!\n');
0063 
0064     % now plot the eye tracks
0065     secCount = 0;
0066     for i1 = 2:1:numSamples  % for (near) real time, step by 2
0067         % show appropriate image
0068         imshow( A );  % imagesc faster than imshow
0069         %show fixations and saccades
0070         if  leftFixation(i1)~=0
0071             text(100,60, ['F' int2str(leftFixation(i1))], 'fontsize', 30, 'color', 'b' ); %left fixation
0072         end        
0073         if  leftSaccade(i1)~=0
0074             text(100,100, ['S' int2str(leftSaccade(i1))], 'fontsize', 30, 'color', 'b' ); %left Saccade
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             % endTime = toc;
0086             % fprintf( '%d seconds for 60 frames.\n', endTime-startTime );
0087             % startTime = endTime;
0088             secCount = secCount+1;
0089         end
0090 
0091         hold off;
0092     end
0093 
0094 % end
0095 
0096

Generated on Tue 01-Jul-2014 12:35:04 by m2html © 2005