Home > GVSToolbox > calcAOIFixSequenceDist.m

calcAOIFixSequenceDist

PURPOSE ^

calculate matrix representing the sequence of AOIs fixated

SYNOPSIS ^

function [ AOISequence AOIDuration ] =calcAOIFixSequenceDist( fixStruct, aoiCenter, maxDist, maxFixations )

DESCRIPTION ^

 calculate matrix representing the sequence of AOIs fixated
 
 Syntax: [ AOISequence AOIDuration] =calcAOIFixSequence( eyePos, aoiCenter, maxDist, maxFixations) 
 
 Inputs:
  fixStruct: returned from codeFixationsDist
  aoiCenter: coordinates of AOI in image scale, returned by 'returnAOICenters.m'
  maxDist: maximum distance to a nearest AOI, anything further
   considered not part of any AOI, returned by 'returnAOICenters.m'
  maxFixations: number of fixations in the sequence to keep
 
 Outputs:
  AOISequence: matrix (numAOI x numFix) with an indicator (1) for
       in each column corresponding to the AOI of interest.  If no
       AOI, it will be an all 0;
  AOIDuration: matrix (1 x numFix) for duration in number samples at that
       AOI, will be 0 if no AOI

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 % calculate matrix representing the sequence of AOIs fixated
0002 %
0003 % Syntax: [ AOISequence AOIDuration] =calcAOIFixSequence( eyePos, aoiCenter, maxDist, maxFixations)
0004 %
0005 % Inputs:
0006 %  fixStruct: returned from codeFixationsDist
0007 %  aoiCenter: coordinates of AOI in image scale, returned by 'returnAOICenters.m'
0008 %  maxDist: maximum distance to a nearest AOI, anything further
0009 %   considered not part of any AOI, returned by 'returnAOICenters.m'
0010 %  maxFixations: number of fixations in the sequence to keep
0011 %
0012 % Outputs:
0013 %  AOISequence: matrix (numAOI x numFix) with an indicator (1) for
0014 %       in each column corresponding to the AOI of interest.  If no
0015 %       AOI, it will be an all 0;
0016 %  AOIDuration: matrix (1 x numFix) for duration in number samples at that
0017 %       AOI, will be 0 if no AOI
0018 
0019 function [ AOISequence AOIDuration  ] =calcAOIFixSequenceDist( fixStruct, aoiCenter, maxDist, maxFixations ) 
0020 
0021 
0022 fixPosVector = fixStruct.fixPosVector;
0023 fixDurVector = fixStruct.fixDurVector;
0024 
0025 % % % initialize some paramters
0026 % % fixationWinSize = 6;
0027 % % fixationThreshold = 15;
0028 if nargin < 4 || isempty( maxFixations )
0029     maxFixations = 4;
0030 end
0031 % %
0032 % % % scale eye tracks(using default value ), calculate fixations
0033 % % [ eyePos imRange] = scaleEyeTrack( eyePos,  [] );
0034 % % [ fixationVector P ]  = codeFixations( eyePos, fixationWinSize, fixationThreshold );
0035 
0036 % initialize some variables
0037 numAOI = size(aoiCenter,2);
0038 numFixation = size( fixPosVector,2);
0039 AOIOrderList = zeros(numFixation,1); 
0040 AOIDurationList =  zeros(numFixation,1);
0041 effectivNumFixation = 0;
0042 
0043 % find AOI fixation sequence
0044 for i1 = 1:numFixation  
0045     dist = calc2Dist( fixPosVector(:,i1), aoiCenter); % 2-norm
0046     [minDist minIdx] = min( dist);    
0047     if minDist < maxDist         
0048         effectivNumFixation = effectivNumFixation+1;        
0049         AOIOrderList(effectivNumFixation) = minIdx;
0050         AOIDurationList(effectivNumFixation ) = fixDurVector(i1); %length(find(fixationVector==i1));
0051     end
0052 end
0053 
0054 % code as a matrix of indicator variables
0055 if effectivNumFixation >0  
0056     AOISequence = zeros( numAOI, maxFixations); 
0057     AOIDuration = zeros( 1, maxFixations);
0058     for i1 = 1:min(effectivNumFixation, maxFixations) 
0059         AOISequence(AOIOrderList(i1),i1) = 1; % indicator for AOI (1)
0060         AOIDuration(i1) = AOIDurationList(i1);
0061     end
0062     
0063 else % all 0 if no relevant AOI
0064     AOISequence = zeros( numAOI,maxFixations);
0065     AOIDuration = zeros( 1, maxFixations);
0066 end
0067 
0068 
0069 
0070

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