Home > database > ensemble_report_subject_meta.m

ensemble_report_subject_meta

PURPOSE ^

Summarizes subject information, e.g. age, gender

SYNOPSIS ^

function out_st = ensemble_report_subject_meta(data_st,params)

DESCRIPTION ^

 Summarizes subject information, e.g. age, gender

 Requires subject_info structure such as that returned by
 mysql_get_subinfo or mysql_get_expinfo, as well as a session_info
 structure. Both of the required structures are obtained most easilty by
 mysql_get_expinfo().

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function out_st = ensemble_report_subject_meta(data_st,params)
0002 % Summarizes subject information, e.g. age, gender
0003 %
0004 % Requires subject_info structure such as that returned by
0005 % mysql_get_subinfo or mysql_get_expinfo, as well as a session_info
0006 % structure. Both of the required structures are obtained most easilty by
0007 % mysql_get_expinfo().
0008 %
0009 
0010 % 31Dec2012 Petr Janata
0011 % 09Jun2014 PJ - added option to filter, and added returning of data struct
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 % Find the subject info analysis
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 % Perform any filtering on the subject_info structure
0028 if isfield(params,'filt')
0029   subst = ensemble_filter(subst, params.filt);
0030 end
0031 
0032 % Find the session info structure
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 % Perform any filtering on the session_info structure
0041 if isfield(params,'filt')
0042   sessst = ensemble_filter(sessst, params.filt);
0043 end
0044 fid = 1;
0045 
0046 %
0047 % Determine the age at each session.
0048 %
0049 
0050 % Match the subject ID associated with each session with the DOB entry in
0051 % the subject info structure
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 % Populate the output structuresubst.data{subcols.gender}(srcidx)
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

Generated on Wed 20-Sep-2023 04:00:50 by m2html © 2003