function [pupdat] = a_setuppupdatstruct(subjname,logday_num,logday_tsk,fpath)

%make eyetrackdata compatible for the GUI  

%when run without subjname
if ~exist('subjname')
    subjname=inputdlg('Which subject?');
end
if ~exist('logday_num')
    logday_num=inputdlg('Which day?');
    logday_num=str2num(char(logday_num));
end
if ~exist('logday_tsk')
    logday_tsk=inputdlg('Which task?');
    logday_tsk=str2num(char(logday_tsk));
end

%get path defs
padi=fpath;

% GET DATA
%--------------------------------------------------------------------------
%load eyetrackdata
load(fullfile(fpath,'eyetrackdat.mat'));

tasknum = logday_tsk;
%get codes
% stimonsets=find(diff(eyetrackdat.prescodes{tasknum})>0)+1;
% stimcodes=eyetrackdat.prescodes{tasknum}(stimonsets);
%  
stimonsets=find(diff(eyetrackdat.prescodes)>0)+1;
stimcodes=eyetrackdat.prescodes(stimonsets);

%put in struct
% pupdat.rawdat={...
%     [eyetrackdat.diameter{tasknum}],...
%     };
pupdat.rawdat={eyetrackdat.diameter};
pupdat.names={'xdiam'};
pupdat.trialonsets={...
    [stimonsets],...
};
pupdat.stimcodes=stimcodes;
pupdat.trialwindow={[-1 4]};
pupdat.samplerate=1000;

%save
save(fullfile(padi,strcat('pupil_day',num2str(logday_num),...
    '_',num2str(logday_tsk),'.mat')),'pupdat');

