Home > database > report_timing.m

report_timing

PURPOSE ^

Generates timing reports for given datasets.

SYNOPSIS ^

function rp = report_timing(as,rp)

DESCRIPTION ^

 Generates timing reports for given datasets.
 report_timing.m

 Generate various reports and plots pertaining to timing aspects of the data
 contained in the analysis structure (as).  See repack_formdata.m for more
 information on the as structure.

 rp is a structure containing the report parameters, including the id of the
 report type. rp can be a structure array in which each element corresponds to
 a different report type.

 Current report types:

   'time_to_completion'

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function rp = report_timing(as,rp)
0002 % Generates timing reports for given datasets.
0003 % report_timing.m
0004 %
0005 % Generate various reports and plots pertaining to timing aspects of the data
0006 % contained in the analysis structure (as).  See repack_formdata.m for more
0007 % information on the as structure.
0008 %
0009 % rp is a structure containing the report parameters, including the id of the
0010 % report type. rp can be a structure array in which each element corresponds to
0011 % a different report type.
0012 %
0013 % Current report types:
0014 %
0015 %   'time_to_completion'
0016 %
0017 
0018 % 09/12/06 Petr Janata - modified from report_autobio
0019 
0020 nrep = length(rp);
0021 
0022 for irep = 1:nrep
0023   rep_id = rp(irep).id;
0024   switch rep_id
0025     case 'time_to_completion'
0026       starttime = [];
0027       stoptime = [];
0028       
0029       % Generate a matrix with subjects in columns
0030       if isfield(as,'nnum')
0031     if isfield(as.num.datenum,'by_question')
0032       data_dims = size(as.num.datenum.by_question);
0033       data = reshape(as.num.datenum.by_question, [data_dims(1) ...
0034         prod(data_dims(2:3))])';
0035       
0036       exist_mask = data > 0;
0037       data(~exist_mask) = NaN;
0038       
0039       starttime = nanmin(data);
0040       stoptime = nanmax(data);
0041     end
0042       elseif isfield(as,'sess')
0043     starttime = as.sess.start_time;
0044     stoptime = as.sess.stop_time;
0045       end
0046       
0047       % Generate a figure showing the distribution of completion times
0048       elapsed_time = etime(datevec(stoptime),datevec(starttime));
0049       min_time = min(elapsed_time);
0050       max_time = max(elapsed_time);
0051       mean_time = mean(elapsed_time);
0052       median_time = median(elapsed_time);
0053       
0054       fprintf('Distribution of times in raw data:\n');
0055       fprintf('Minimum elapsed time (min): %1.2f\n', min_time/60);
0056       fprintf('Maximum elapsed time (min): %1.2f\n', max_time/60);
0057       fprintf('Mean elapsed time(min): %1.2f\n', mean_time/60);
0058       fprintf('Median elapsed time(min): %1.2f\n', median_time/60);
0059       
0060       % Limit the display by range
0061       if isfield(rp,'range')
0062     hist_min = rp.range(1);
0063     hist_max = rp.range(2);
0064       else
0065     hist_min = min_time;
0066     hist_max = max_time;
0067       end
0068       
0069       rp.results.starttime = starttime;
0070       rp.results.stoptime = stoptime;
0071       rp.results.elapsed_time = elapsed_time;
0072       
0073       % Generate a mask of for data are in range
0074       valid_mask = (elapsed_time >= hist_min) & (elapsed_time <= hist_max);
0075       
0076       xscale = linspace(hist_min,hist_max,100);
0077       [histdata] = histc(elapsed_time(valid_mask), xscale);
0078       
0079       if rp.plot_data
0080     figure(1),clf
0081     bar(xscale/60,histdata);
0082     if isfield(rp,'tick_interval')
0083       set(gca,'xtick',min(xscale):rp.tick_interval:max(xscale));
0084     end
0085       end
0086       
0087     otherwise
0088       fprintf('No handling for report type: %s\n', rep_id);
0089   end
0090 end % for irep=

Generated on Sat 24-Aug-2019 04:00:39 by m2html © 2003