0001 function rp = report_timing(as,rp)
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
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
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
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
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
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