1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495 |
- function [eyedata] = getEyeTracks(subjdata,sesn,timeStartAlgn,timeEndAlgn)
- if nargin < 4
- if nargin < 3
- if nargin < 2
- if nargin< 1
- error('Provide subject data.');
- end
- sesn='all';
- end
- timeStartAlgn='offer1';
- end
- timeEndAlgn='choicemade';
- end
- if strcmpi(sesn,'all')
- sesn=1:length(subjdata);
- end
- for sn=sesn
- for tr=1:length(subjdata{sn}.timings)
- curroff1ref=round(subjdata{sn}.timings(tr).appearOffer1Time);
- if strcmpi(timeStartAlgn,'offer1')
- timeStartBin=0;
- elseif strcmpi(timeStartAlgn,'delay1')
- timeStartBin=round(subjdata{sn}.timings(tr).disappearOffer1Time)-curroff1ref;
- elseif strcmpi(timeStartAlgn,'offer2')
- timeStartBin=round(subjdata{sn}.timings(tr).appearOffer2Time)-curroff1ref;
- elseif strcmpi(timeStartAlgn,'delay2')
- timeStartBin=round(subjdata{sn}.timings(tr).disappearOffer2Time)-curroff1ref;
- elseif strcmpi(timeStartAlgn,'fixdot')
- timeStartBin=round(subjdata{sn}.timings(tr).appearFixDotTime)-curroff1ref;
- elseif strcmpi(timeStartAlgn,'choicego')
- timeStartBin=round(subjdata{sn}.timings(tr).choiceGoTime)-curroff1ref;
- elseif strcmpi(timeStartAlgn,'feedback')
- timeStartBin=round(subjdata{sn}.timings(tr).feedbackTime)-curroff1ref;
- elseif strcmpi(timeStartAlgn,'startfix')
- timeStartBin=round(subjdata{sn}.timings(tr).fixStartFixnDotTime)-curroff1ref;
- elseif strcmpi(timeStartAlgn,'choicemade')
- timeStartBin=round(subjdata{sn}.timings(tr).choiceMadeTime)-curroff1ref;
- elseif strcmpi(timeStartAlgn,'choicesacc')
- timeStartBin=round(min([subjdata{sn}.timings(tr).fixStartRightOfferTime subjdata{sn}.timings(tr).fixStartLeftOfferTime]))-curroff1ref;
- elseif strcmpi(timeStartAlgn,'preoffer1')
- timeStartBin=-3000;
- end
-
-
- if strcmpi(timeEndAlgn,'offer1')
- timeEndBin=0;
- elseif strcmpi(timeEndAlgn,'delay1')
- timeEndBin=round(subjdata{sn}.timings(tr).disappearOffer1Time)-curroff1ref;
- elseif strcmpi(timeEndAlgn,'offer2')
- timeEndBin=round(subjdata{sn}.timings(tr).appearOffer2Time)-curroff1ref;
- elseif strcmpi(timeEndAlgn,'delay2')
- timeEndBin=round(subjdata{sn}.timings(tr).disappearOffer2Time)-curroff1ref;
- elseif strcmpi(timeEndAlgn,'fixdot')
- timeEndBin=round(subjdata{sn}.timings(tr).appearFixDotTime)-curroff1ref;
- elseif strcmpi(timeEndAlgn,'choicego')
- timeEndBin=round(subjdata{sn}.timings(tr).choiceGoTime)-curroff1ref;
- elseif strcmpi(timeEndAlgn,'feedback')
- timeEndBin=round(subjdata{sn}.timings(tr).feedbackTime)-curroff1ref;
- elseif strcmpi(timeEndAlgn,'startfix')
- timeEndBin=round(subjdata{sn}.timings(tr).fixStartFixnDotTime)-curroff1ref;
- elseif strcmpi(timeEndAlgn,'choicemade')
- timeEndBin=round(subjdata{sn}.timings(tr).choiceMadeTime)-curroff1ref;
- elseif strcmpi(timeEndAlgn,'choicesacc')
- timeEndBin=round(min([subjdata{sn}.timings(tr).fixStartRightOfferTime subjdata{sn}.timings(tr).fixStartLeftOfferTime]))-curroff1ref;
- elseif strcmpi(timeEndAlgn,'trialend')
- timeEndBin=7000;
- end
-
- currsn_eyedata_str{tr}.posX(1:(timeEndBin-timeStartBin))=subjdata{sn}.eyetracks.posX(tr,(timeStartBin+1:timeEndBin)+3000);
- currsn_eyedata_str{tr}.posY(1:(timeEndBin-timeStartBin))=subjdata{sn}.eyetracks.posY(tr,(timeStartBin+1:timeEndBin)+3000);
- end
- maxntp=max(arrayfun(@(tr) size(currsn_eyedata_str{tr}.posX,2),1:length(subjdata{sn}.timings)));
- eyedata_str{sn}.posX=nan(length(subjdata{sn}.timings),maxntp);
- eyedata_str{sn}.posY=nan(length(subjdata{sn}.timings),maxntp);
- for tr=1:length(subjdata{sn}.timings)
- eyedata_str{sn}.posX(tr,1:size(currsn_eyedata_str{tr}.posX,2))=currsn_eyedata_str{tr}.posX;
- eyedata_str{sn}.posY(tr,1:size(currsn_eyedata_str{tr}.posY,2))=currsn_eyedata_str{tr}.posY;
- end
- clearvars currsn_eyedata_str
- end
- maxlen=max(arrayfun(@(xx) size(eyedata_str{xx}.posX,2),sesn));
- eyedata_str{sn}.posX(:,maxlen+1:end)=[];
- eyedata.posX=[]; eyedata.posY=[];
- for sn=sesn
- eyedata.posX=cat(1,eyedata.posX,[eyedata_str{sn}.posX nan(size(eyedata_str{sn}.posX,1), maxlen-size(eyedata_str{sn}.posX,2))]);
- eyedata.posY=cat(1,eyedata.posY,[eyedata_str{sn}.posY nan(size(eyedata_str{sn}.posY,1), maxlen-size(eyedata_str{sn}.posY,2))]);
- end
- end
|