import_entire_log() - import log information about events listed in blf file Usage: >> log_info=import_log(asciilogfile,blf_evnum) Inputs: asciilogfile = name of ascii version of Kutaslab .log file (a string). This can be generated by log2asci or logcat2. If generated by log2asci the sampling rate must have been specified so that event times columns are in ascii file. Outputs: log_info = a matrix of log information. Each row corresponds to an event. The columns are: 1) Item Number 2) Event Number (stim/resp code) 3) Condition Code 4) Flag 5) Time of Occurrence (in sec) Author: David Groppe Kutaslab, 6/2011
0001 function log_file_info=import_entire_log(asciilogfile) 0002 % import_entire_log() - import log information about events listed in blf file 0003 % 0004 % Usage: 0005 % >> log_info=import_log(asciilogfile,blf_evnum) 0006 % 0007 % Inputs: 0008 % asciilogfile = name of ascii version of Kutaslab .log file (a 0009 % string). This can be generated by log2asci or logcat2. If 0010 % generated by log2asci the sampling rate must have been 0011 % specified so that event times columns are in ascii file. 0012 % 0013 % Outputs: 0014 % log_info = a matrix of log information. Each row corresponds to 0015 % an event. The columns are: 0016 % 1) Item Number 0017 % 2) Event Number (stim/resp code) 0018 % 3) Condition Code 0019 % 4) Flag 0020 % 5) Time of Occurrence (in sec) 0021 % 0022 % 0023 % Author: 0024 % David Groppe 0025 % Kutaslab, 6/2011 0026 0027 % Load log information ... 0028 enum = []; ecode = []; ccode = []; flag =[]; tick = []; sec =[]; deltaT = []; 0029 0030 %check to find out how ascii version of log file was created 0031 fid_ascii=fopen(asciilogfile,'r'); 0032 lyne=fgetl(fid_ascii); %read in first line 0033 if (lyne(1)=='*') %file was generated with log2asci 0034 for dumb_loop=1:13, 0035 lyne=fgetl(fid_ascii); %read in headerlines 0036 end 0037 if strcmpi(lyne(length(lyne)-4:end),'Delta') %file was generated with sampling rate 0038 fclose(fid_ascii); 0039 [enum, ecode, ccode, flag, tick, sec, deltaT]=textread(asciilogfile,['%d' ...% 0040 ' %d %d %d %d %f %f'],'headerlines',14); 0041 else 0042 err_str=sprintf('ERROR: ASCII version of logfile %s was not generated with sampling rate.\n', ... 0043 asciilogfile); 0044 error([err_str 'Please correct.']); 0045 end 0046 else %file was generated with logcat2 0047 fclose(fid_ascii); 0048 [enum, ecode, ccode, flag, tick, sec, deltaT]=textread(asciilogfile,['%d' ... 0049 ' %d %d %d %d %f %f'],'headerlines',1); 0050 end 0051 log_file_info=[enum, ecode, ccode, flag, sec]; 0052 n_logevents=size(log_file_info, 1); 0053 0054 %Select only logfile information for events that are listed in the 0055 %blf file 0056 % log_info=zeros(length(blf_evnum),5); %preallocate memory 0057 % ct=0; 0058 % for blf_ev=blf_evnum, 0059 % ct=ct+1; 0060 % log_info(ct,:)=log_file_info(find(enum==blf_ev),:); 0061 % end 0062