function fix_lut(fld,monkey) % we use a LUT to store information about trials. this is created by % converting the log structure to a table and adding some extra columns. % however, apparently the log structure does't always have the same fields, % but the LUT needs to have the same columns to be able to concatenate. % this fucntion adds two empty columns, for stimonset and targonset, which % apparently were added to the log structure halfway throughout recording. % also, TarChoice is sometimes a cell, but it doesn't have to be because % it's only ever 1 value. datadir = fld.procdatadir; datainfo = session_info(); fprintf('\n======================================================\n'); fprintf(['-- Running fix_lut for ' monkey ' --\n']); fprintf('======================================================\n'); if strcmp(monkey,'M1') info = datainfo(1); else info = datainfo(2); end sessions = info.dates; for sid = 1:length(sessions) % session info session = sessions{sid}; q = strsplit(session,'_'); cdate = q{2}; block = str2num(q{3}(end-4)); % load the data session_id = [monkey '_' cdate '_' num2str(block)]; sessiondir = fullfile(datadir, monkey, session_id); % load the data for this session for this channel load(fullfile(sessiondir, [session_id '_LUT.mat'])); % loads 'lut' % add nans for stimonset if ~sum(strcmp('StimOnset',lut.Properties.VariableNames)) StimOnset = nan(size(lut,1),1); lut = addvars(lut,StimOnset,'After','RewValue'); end % add nans for targonset if ~sum(strcmp('TargOnset',lut.Properties.VariableNames)) TargOnset = nan(size(lut,1),1); lut = addvars(lut,TargOnset,'After','StimOnset'); end % make TarChoice not be a cell if iscell(lut.TarChoice) qq = nan(size(lut,1),1); qq(cellfun('isempty',lut.TarChoice)==0,1) = cell2mat(lut.TarChoice); lut.TarChoice = qq; end save(fullfile(sessiondir, [session_id '_LUT.mat']),'lut'); end