0001 function [out_st] = ensemble_completion_info(data_st,params)
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011 out_st.type = 'ensemble_completion_info';
0012 out_st.vars = {};
0013 out_st.data = {};
0014
0015
0016 if isfield(params,'filt')
0017 data_st = ensemble_filter(data_st, params.filt);
0018 end
0019
0020
0021 INCOL = set_form_col_const(data_st.vars);
0022
0023
0024 if isempty(INCOL.SESS_ID)
0025 fprintf('ensemble_completion_info: Could not find session_id variable\n');
0026 return
0027 end
0028
0029
0030
0031 out_vars = {'session_id','start_time','stop_time','elapsed_time','form_id'};
0032 outcol = set_var_col_const(out_vars);
0033
0034 out_st.vars = out_vars;
0035 sesslist = unique(data_st.data{INCOL.SESS_ID});
0036 out_st.data{outcol.session_id} = sesslist;
0037
0038
0039 nsess = length(sesslist);
0040
0041 for isess = 1:nsess
0042
0043 sess_mask = data_st.data{INCOL.SESS_ID} == sesslist(isess);
0044 sess_idxs = find(sess_mask);
0045
0046
0047 start_time = min(data_st.data{INCOL.DATE_TIME}(sess_mask));
0048 out_st.data{outcol.start_time}(isess) = start_time;
0049
0050
0051 [stop_time, stop_idx] = max(data_st.data{INCOL.DATE_TIME}(sess_mask));
0052 out_st.data{outcol.stop_time}(isess) = stop_time;
0053
0054
0055 elapsed_time = etime(datevec(stop_time),datevec(start_time));
0056 out_st.data{outcol.elapsed_time}(isess) = elapsed_time;
0057
0058
0059 last_form_id = data_st.data{INCOL.FORM_ID}(sess_idxs(stop_idx));
0060 out_st.data{outcol.form_id}(isess) = last_form_id;
0061
0062 end
0063
0064
0065 report.min_time = min(out_st.data{outcol.elapsed_time});
0066 report.max_time = max(out_st.data{outcol.elapsed_time});
0067 report.mean_time = mean(out_st.data{outcol.elapsed_time});
0068 report.std_time = std(out_st.data{outcol.elapsed_time});
0069 report.median_time = median(out_st.data{outcol.elapsed_time});
0070
0071
0072
0073
0074 if isfield(params,'display')
0075 if isfield(params.display, 'figs')
0076 figtypes = fieldnames(params.display.figs);
0077 ntypes = length(figtypes);
0078 for itype = 1:ntypes
0079 curtype = figtypes{itype};
0080 st = params.display.figs.(curtype);
0081 switch curtype
0082 case 'hist'
0083 try hist_min = st.min_time; catch hist_min = 0; end
0084 try hist_max = st.max_time; catch hist_max = report.max_time; end
0085 try nbins = st.nbins; catch nbins=20; end
0086 try doplot = st.plot; catch doplot=1; end
0087 try tick_interval = st.tick_interval; catch tick_interval=15; end
0088
0089 histscale = linspace(hist_min,hist_max,nbins);
0090 histdata = histc(out_st.data{outcol.elapsed_time}, histscale);
0091 histscale = histscale/60;
0092 report.hist.xscale = histscale;
0093 report.hist.data = histdata;
0094
0095 if doplot
0096 figure
0097 bar(histscale,histdata)
0098 set(gca,'xtick',min(histscale):tick_interval:max(histscale), ...
0099 'xlim',[min(histscale) max(histscale)])
0100 report.hist.axes = gca;
0101 end
0102 end
0103 end
0104 end
0105
0106 if isfield(params.display, 'tables')
0107 if isfield(params.display.tables,'group_stats') && ...
0108 params.display.tables.group_stats
0109 fprintf('\nCompletion time statistics\n');
0110 fprintf('Minimum elapsed time (min): %1.2f\n', report.min_time/60);
0111 fprintf('Maximum elapsed time (min): %1.2f\n', report.max_time/60);
0112 fprintf('Mean elapsed time(min): %1.2f\n', report.mean_time/60);
0113 fprintf('Std. dev elapsed time(min): %1.2f\n', report.std_time/60);
0114 fprintf('Median elapsed time(min): %1.2f\n', report.median_time/60);
0115
0116 end
0117 end
0118 end
0119
0120 out_st.report = report;