Home > matlabmk > parse_log_by_cc.m

parse_log_by_cc

PURPOSE ^

parse_log_by_cc() - Returns the item boundaries of chunks of time

SYNOPSIS ^

function [cc_bounds, cc_bounds_codes]=parse_log_by_cc(log_info)

DESCRIPTION ^

 parse_log_by_cc() - Returns the item boundaries of chunks of time
                     corresponding to different codes in a log file.
                     Useful for importing data corresponding to specific
                     condition codes via erpio2.
 
 Usage:
  >> [cc_bounds, cc_bounds_codes]=find_cc0(log_info);

 Inputs:
  log_info - 2D matrix of log file information obtained from an ascii
             version of a Kutaslab logfile and import_entire_log.m. Each 
             row of log_info corresponds to a different item and each
             column corresponds:
               1. Log Item Number
               2. Event Code
               3. Condition Code
               4. Log Flag (40=nonblink art; 60=blink art)
               5. Time
 
 Outputs:
  cc_bounds       - 2D matrix of the item numbers that begin and end a
                    period of time with the same condition code. Note,
                    boundaries are inclusive.
  cc_bounds_codes - Vector of condition codes corresponding to each period
                    of the logfile specified by cc_bounds

 Notes:
 -This code relies on the fact that pausing the dig machines results in an
 event code of -16384

 Author:
 David Groppe
 Kutaslab, 6/2011

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function [cc_bounds, cc_bounds_codes]=parse_log_by_cc(log_info)
0002 % parse_log_by_cc() - Returns the item boundaries of chunks of time
0003 %                     corresponding to different codes in a log file.
0004 %                     Useful for importing data corresponding to specific
0005 %                     condition codes via erpio2.
0006 %
0007 % Usage:
0008 %  >> [cc_bounds, cc_bounds_codes]=find_cc0(log_info);
0009 %
0010 % Inputs:
0011 %  log_info - 2D matrix of log file information obtained from an ascii
0012 %             version of a Kutaslab logfile and import_entire_log.m. Each
0013 %             row of log_info corresponds to a different item and each
0014 %             column corresponds:
0015 %               1. Log Item Number
0016 %               2. Event Code
0017 %               3. Condition Code
0018 %               4. Log Flag (40=nonblink art; 60=blink art)
0019 %               5. Time
0020 %
0021 % Outputs:
0022 %  cc_bounds       - 2D matrix of the item numbers that begin and end a
0023 %                    period of time with the same condition code. Note,
0024 %                    boundaries are inclusive.
0025 %  cc_bounds_codes - Vector of condition codes corresponding to each period
0026 %                    of the logfile specified by cc_bounds
0027 %
0028 % Notes:
0029 % -This code relies on the fact that pausing the dig machines results in an
0030 % event code of -16384
0031 %
0032 % Author:
0033 % David Groppe
0034 % Kutaslab, 6/2011
0035 %
0036 
0037 bndry_ids=[0; find(log_info(:,2)==-16384)];
0038 current_ccode=log_info(1,3);
0039 current_bndry_start=1;
0040 cc_bounds=[];
0041 cc_bounds_codes=[];
0042 for a=1:(length(bndry_ids)-1),
0043     start_item=bndry_ids(a);
0044     stop_item=bndry_ids(a+1);
0045     ccodes=unique(log_info(start_item+1:stop_item,3));
0046     if length(ccodes)==1
0047         fprintf('Chunk %d: ccode %d\n',a,ccodes);
0048     else
0049         error('Chunk %d has more than one condition code.',a);
0050     end
0051     if ccodes~=current_ccode,
0052         cc_bounds=[cc_bounds; current_bndry_start start_item];
0053         cc_bounds_codes=[cc_bounds_codes current_ccode];
0054         current_bndry_start=start_item+1;
0055         current_ccode=ccodes;
0056     end
0057 end
0058 cc_bounds=[cc_bounds; current_bndry_start size(log_info,1)];
0059 cc_bounds_codes=[cc_bounds_codes current_ccode];

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