Home > matlabmk > import_log.m

import_log

PURPOSE ^

import_log() - import log information about events listed in blf file

SYNOPSIS ^

function log_info=import_log(asciilogfile,blf_evnum)

DESCRIPTION ^

 import_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.
   blf_evnum    = a vector of log item integers for all events that
                  are listed in the corresponding blf 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, 8/2009

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function log_info=import_log(asciilogfile,blf_evnum)
0002 % import_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 %   blf_evnum    = a vector of log item integers for all events that
0013 %                  are listed in the corresponding blf file.
0014 %
0015 % Outputs:
0016 %   log_info = a matrix of log information. Each row corresponds to
0017 %              an event.  The columns are:
0018 %              1) Item Number
0019 %              2) Event Number (stim/resp code)
0020 %              3) Condition Code
0021 %              4) Flag
0022 %              5) Time of Occurrence (in sec)
0023 %
0024 %
0025 % Author:
0026 % David Groppe
0027 % Kutaslab, 8/2009
0028 
0029 % Load log information ...
0030 enum = []; ecode = []; ccode = []; flag =[]; tick = []; sec =[]; deltaT = [];
0031 %check to find out how ascii version of log file was created
0032 fid_ascii=fopen(asciilogfile,'r');
0033 lyne=fgetl(fid_ascii); %read in first line
0034 if (lyne(1)=='*') %file was generated with log2asci
0035   for dumb_loop=1:13,
0036     lyne=fgetl(fid_ascii); %read in headerlines
0037   end
0038   if strcmpi(lyne(length(lyne)-4:end),'Delta') %file was generated with sampling rate
0039     fclose(fid_ascii);
0040     [enum, ecode, ccode, flag, tick, sec, deltaT]=textread(asciilogfile,['%d' ...%
0041             ' %d %d %d %d %f %f'],'headerlines',14);
0042   else
0043     err_str=sprintf('ERROR: ASCII version of logfile %s was not generated with sampling rate.\n', ...
0044             asciilogfile);
0045     error([err_str 'Please correct.']);
0046   end
0047 else %file was generated with logcat2
0048   fclose(fid_ascii);
0049   [enum, ecode, ccode, flag, tick, sec, deltaT]=textread(asciilogfile,['%d' ...
0050             ' %d %d %d %d %f %f'],'headerlines',1);
0051 end        
0052 log_file_info=[enum, ecode, ccode, flag, sec];
0053 n_logevents=size(log_file_info, 1);
0054 
0055 %Select only logfile information for events that are listed in the
0056 %blf file
0057 log_info=zeros(length(blf_evnum),5); %preallocate memory
0058 ct=0;
0059 for blf_ev=blf_evnum,
0060   ct=ct+1;
0061   log_info(ct,:)=log_file_info(find(enum==blf_ev),:);
0062 end
0063

Generated on Tue 10-May-2016 16:37:45 by m2html © 2005