Home > GVSToolbox > extractVarsDist.m

extractVarsDist

PURPOSE ^

extract all variables from a cell of eye tracks

SYNOPSIS ^

function [ featureVect, varParams ] = extractVarsDist( trackCell, aoiPositions, maxDist, relevantAOIs, varParams )

DESCRIPTION ^

 extract all variables from a cell of eye tracks
 
 Syntax: [ featureVect  varParams ] = extractVarsDist( trackCell, aoiPositions, maxDist, relevantAOIs, varParams )
 
 Inputs: 
   trackCell: (1 by numSamples) cell with all the mean test tracks
       extracted.  trackCell{1} will have an (numSample by 1) complex
       vector of eye coordinates.  It will upscale them to varParams.imageSize 
       if they are still within the [ 0+0i, 1+1i] range (line 84 )
 
   aoiPositions: AOI positions in image
           with respect original image size,  in format [ x x ... x; 
                                                          y y ... y]
   maxDist: max Euclidean distance from each AOI center (in pixels)
       until it is considered not within the AOI
 
   relevantAOIs = [4;11]; % index of the AOI positions which are the 
       relevant ones for a particular category  
 
   varParams: struct with the paramters for fixation, saccades, image size,
         and histogram bins, etc. scroll down (line 32-44) to see struct fields
   
 
 Outputs:
   featureVect: (d by numSamples) matrix with all the data
   varParams: struct with variable information in addition to paramters

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 % extract all variables from a cell of eye tracks
0002 %
0003 % Syntax: [ featureVect  varParams ] = extractVarsDist( trackCell, aoiPositions, maxDist, relevantAOIs, varParams )
0004 %
0005 % Inputs:
0006 %   trackCell: (1 by numSamples) cell with all the mean test tracks
0007 %       extracted.  trackCell{1} will have an (numSample by 1) complex
0008 %       vector of eye coordinates.  It will upscale them to varParams.imageSize
0009 %       if they are still within the [ 0+0i, 1+1i] range (line 84 )
0010 %
0011 %   aoiPositions: AOI positions in image
0012 %           with respect original image size,  in format [ x x ... x;
0013 %                                                          y y ... y]
0014 %   maxDist: max Euclidean distance from each AOI center (in pixels)
0015 %       until it is considered not within the AOI
0016 %
0017 %   relevantAOIs = [4;11]; % index of the AOI positions which are the
0018 %       relevant ones for a particular category
0019 %
0020 %   varParams: struct with the paramters for fixation, saccades, image size,
0021 %         and histogram bins, etc. scroll down (line 32-44) to see struct fields
0022 %
0023 %
0024 % Outputs:
0025 %   featureVect: (d by numSamples) matrix with all the data
0026 %   varParams: struct with variable information in addition to paramters
0027 %
0028 
0029 function [ featureVect,  varParams ] = extractVarsDist( trackCell, aoiPositions, maxDist, relevantAOIs, varParams )
0030                                    
0031  
0032 %initialize default parameters for variable extraction
0033 if ~isfield( 'varParams', 'imageSize'); varParams.imageSize = [1024; 1280]; end % [Height; Width] of display
0034     % We identify fixations using the IDT algorithm
0035 if ~isfield( 'varParams', 'fixMinNumSamples'); varParams.fixMinNumSamples = 6;  end % in number neighboring samples
0036 if ~isfield( 'varParams', 'fixMaxCircleRadius'); varParams.fixMaxCircleRadius = 15;  end % in pixels, half diameter
0037     % identify saccades as exceeding a certain velocity, then slow down
0038 if ~isfield( 'varParams', 'velThreshold'); varParams.velThreshold = 20; end
0039 if ~isfield( 'varParams', 'stopThreshold'); varParams.stopThreshold = 8; end
0040     
0041 if ~isfield( 'varParams', 'startFixation'); varParams.startFixation = 1; end
0042 if ~isfield( 'varParams', 'numFixationInSeq'); varParams. numFixationInSeq = 7;  end
0043 if ~isfield( 'varParams', 'startSaccade'); varParams.startSaccade = 1; end
0044 if ~isfield( 'varParams', 'numSaccadesInSeq'); varParams.numSaccadesInSeq = 7; end
0045 % if ~isfield( 'varParams', 'numHistBins'); varParams.numHistBins = 15; end
0046 
0047 
0048 
0049 % setup the variables for later use
0050 imageSize = varParams.imageSize;
0051 fixMinNumSamples = varParams.fixMinNumSamples;
0052 fixMaxCircleRadius = varParams.fixMaxCircleRadius;
0053 velThreshold = varParams.velThreshold;
0054 stopThreshold = varParams.stopThreshold;
0055 startFixation = varParams.startFixation; 
0056 numFixationInSeq = varParams.numFixationInSeq;  
0057 startSaccade = varParams.startSaccade; 
0058 numSaccadesInSeq = varParams.numSaccadesInSeq;
0059 % numHistBins = varParams.numHistBins;
0060 
0061 
0062 %----------------------------------------------
0063 % initialize basic things
0064 if ~iscell( trackCell );
0065     temp = trackCell; clear trackCell
0066     trackCell{1} = temp; clear temp
0067 end
0068 numSamples = length(trackCell );
0069 %histDim = numHistBins*length(relevantAOIs);
0070 numAOI = size( aoiPositions,2);   
0071 
0072 
0073 varParams.dimPerFeat = [ numAOI; numAOI*numFixationInSeq; numFixationInSeq; 1; ...
0074                          1; 1; 1; ... %histDim; 1; 1; 1; ...
0075                          numAOI*numSaccadesInSeq; numAOI; 1;
0076                          2*numFixationInSeq ; 2*numSaccadesInSeq ];
0077 varParams.dimNames = { 'AOIFixDensity'; 'AOIFixationSeq'; 'AOIFixationDuration'; 'relevantAOIFixDensVersusAll'; ...
0078                         'totalDistTraveled'; 'numUniqueAOIsVisitedFixation'; 'latencyFirstRelAOIFixation'; ... %'AOIFixationDistHistogram'; 'totalDistTraveled'; 'numUniqueAOIsVisitedFixation'; 'latencyFirstRelAOIFixation'; ...
0079                         'AOISaccadeSeq'; 'AOISaccadeToDensity'; 'latencyFirstRelAOISaccade'; ...
0080                         'relNonRelFixSeq'; 'relNonRelSacSeq'};
0081 featureVect = zeros( sum(varParams.dimPerFeat ), numSamples);
0082 
0083 
0084 %---------------------------------------------------
0085 % extract all the variables
0086  for k1 =1:numSamples
0087     if max(real(trackCell{k1})) <= 1
0088         eyePos = trackCell{k1}; % scale eye track if it is within the [0 1] range
0089     end
0090     [ eyePos ] = scaleEyeTrack( eyePos,  imageSize ); 
0091     
0092     [ fixStruct ] = codeFixationsDist( eyePos, fixMinNumSamples, fixMaxCircleRadius );
0093     [ sacStruct ] = codeSaccadesDist( eyePos, velThreshold, stopThreshold);
0094         
0095     
0096     % ------------------- extract all variables --------------------
0097     % calculate AOI fixation density
0098      [ AOIDensity numRealFix]  = calcAOIFixDensityDist( fixStruct, aoiPositions, maxDist );    
0099     
0100     % calc relevant AOI fixation versus All
0101     relAOIVersusAll = [ sum(AOIDensity(relevantAOIs))]; %; sum(AOIDensity(nonRelevantAOIs))];
0102    
0103     % caculate AOI fixation sequence and duration
0104     [ AOISeq AOIDur  ] =calcAOIFixSequenceDist( fixStruct, aoiPositions, maxDist, numFixationInSeq+startFixation-1 );            
0105     AOISeq = AOISeq(:, startFixation:end);         
0106     AOIDur = AOIDur(startFixation:end);
0107     
0108 % %     % histogram distance to relevant AOI
0109 % %     histMatrix =calcAOIFixDistHistDist( fixStruct,  aoiPositions, numHistBins, relevantAOIs, imageSize );
0110     
0111     % calculate distance traveled
0112     distTraveled =calcDistTraveled( eyePos );
0113     
0114     % calculate number unique AOI's visited
0115     numUniqAOIs = length(find( AOIDensity>0));
0116     
0117     % calculate latency to first relevant AOI fixation
0118     latencyFirstRelAOI =calcLatencyRelAOIFixDist( fixStruct, aoiPositions, maxDist, relevantAOIs);
0119         
0120     % calc relative number saccades to an AOI
0121     [AOIDensitySac ] =calcAOISacDensityDist( sacStruct, aoiPositions, maxDist );
0122     
0123     % calculate saccade sequence
0124     [ AOISacSequence ] = calcAOISacSequenceDist( sacStruct, aoiPositions,  maxDist, numSaccadesInSeq+startSaccade-1 );
0125     AOISacSequence = AOISacSequence(:,startSaccade:end);        
0126  
0127     % calcualate latency to first saccade to relevant region
0128     latencyFirstRelAOISac = calcLatencyRelAOISacDist( sacStruct, aoiPositions, maxDist, relevantAOIs );
0129     
0130     
0131     % calculate sequence as relevant/irrelevant
0132     relIrelFixSeq =calcIrrRelSeq( AOISeq, relevantAOIs );
0133     relIrelSacSeq =calcIrrRelSeq( AOISacSequence, relevantAOIs );
0134     
0135         
0136     %---------------------------------------------------------------
0137     
0138     % put in output matrix
0139     featureVect(:,k1) = [ AOIDensity; AOISeq(:); AOIDur(:); relAOIVersusAll; ...
0140                         distTraveled; numUniqAOIs; latencyFirstRelAOI; ... %histMatrix(:); distTraveled; numUniqAOIs; latencyFirstRelAOI; ...
0141                         AOISacSequence(:); AOIDensitySac; latencyFirstRelAOISac; ...
0142                         relIrelFixSeq(:); relIrelSacSeq(:) ];
0143                     
0144 
0145 
0146 % %     %--------------------------------------------------
0147 % % % Obsolete
0148 % % % extract fixation density over grid
0149 % % %fixScape = calcFixDensity(eyePos, sigma, numYandXSamples);
0150 %
0151 %     featureVect(:,k1) = AOIDensity;
0152 %     featureVect(:,k1) = [AOIDensity; fixScape(:)];
0153 %
0154 % %     % Show it
0155 % %     visualizeTrackSingle(  eyePos, [], 'test' )
0156 % %     distTraveled
0157 
0158             
0159 end

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