0001 function out_st = ensemble_report_subject_meta(data_st,params)
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013 out_st = ensemble_init_data_struct;
0014 out_st.vars = {'subject_id','age','gender'};
0015 ocols = set_var_col_const(out_st.vars);
0016 out_st.data = cell(1,length(out_st.vars));
0017
0018
0019 idx = ensemble_find_analysis_struct(data_st, struct('type','subject_info'));
0020 if isempty(idx)
0021 error('Could not find subject info structure');
0022 end
0023
0024 subst = data_st{idx};
0025 subcols = set_var_col_const(subst.vars);
0026
0027
0028 if isfield(params,'filt')
0029 subst = ensemble_filter(subst, params.filt);
0030 end
0031
0032
0033 idx = ensemble_find_analysis_struct(data_st, struct('type','session_info'));
0034 if isempty(idx)
0035 error('Could not find session info structure')
0036 end
0037 sessst = data_st{idx};
0038 sesscols = set_var_col_const(sessst.vars);
0039
0040
0041 if isfield(params,'filt')
0042 sessst = ensemble_filter(sessst, params.filt);
0043 end
0044 fid = 1;
0045
0046
0047
0048
0049
0050
0051
0052 [~, srcidx] = ismember(sessst.data{sesscols.subject_id}, subst.data{subcols.subject_id});
0053
0054 expdate = sessst.data{sesscols.date_time};
0055 dob = subst.data{subcols.dob}(srcidx);
0056 female_mask = strcmp(subst.data{subcols.gender}(srcidx),'F');
0057 agevect_s = etime(datevec(expdate),datevec(dob));
0058 agevect_y = agevect_s/(60*60*24*365);
0059 fprintf(fid,'N=%d (%d females)\n', length(agevect_y), sum(female_mask));
0060 fprintf(fid,'Age range: %d - %d\n', fix(min(agevect_y)), fix(max(agevect_y)));
0061 fprintf(fid,'Age (mean +/- std): %2.1f (%2.1f)\n', mean(agevect_y), std(agevect_y));
0062
0063
0064 out_st.data{ocols.subject_id} = subst.data{subcols.subject_id}(srcidx);
0065 out_st.data{ocols.gender} = subst.data{subcols.gender}(srcidx);
0066 out_st.data{ocols.age} = agevect_y;
0067
0068
0069 return