generates an averaged fmri regressor from a given set of responses [names,vals] = fmri_regress_average(pinfo,minfo,sess) called by fmri_generate_regress note: expects the same number of responses for all variables in a given set REQUIRES minfo.stim_average.var_sets - cell array of cell array of strings containing cues to be averaged together minfo.stim_average.set_names - cell array of strings that are names for each of the sets defined above RETURNS names = cell array of six regressor names vals = volume X regressor matrix containing motion regressors FB 2010.02.25
0001 function [names,vals] = fmri_regress_average(pinfo,minfo,sess) 0002 0003 % generates an averaged fmri regressor from a given set of responses 0004 % 0005 % [names,vals] = fmri_regress_average(pinfo,minfo,sess) 0006 % 0007 % called by fmri_generate_regress 0008 % 0009 % note: expects the same number of responses for all variables in a given 0010 % set 0011 % 0012 % REQUIRES 0013 % minfo.stim_average.var_sets - cell array of cell array of strings 0014 % containing cues to be averaged together 0015 % minfo.stim_average.set_names - cell array of strings that are names for 0016 % each of the sets defined above 0017 % 0018 % RETURNS 0019 % names = cell array of six regressor names 0020 % vals = volume X regressor matrix containing motion regressors 0021 % 0022 % FB 2010.02.25 0023 0024 % init output vars 0025 names = minfo.stim_average.set_names; 0026 nsets = length(names); 0027 vals = zeros(pinfo.scanner.TR,nsets); 0028 stim_avg_vars = minfo.stim_average.var_sets; 0029 nsav = length(stim_avg_vars); 0030 if nsets ~= nsav, error('different number of sets and names'); end 0031 0032 % init vars 0033 ccm = parse_fh(minfo.cond_cue_map); % function handle for condition to cue mappings 0034 0035 % Now get the vector of stimulus onset times to which these response 0036 % parameters refer 0037 sfilt.include.all = minfo.response_filter; 0038 sinfo = ensemble_filter(pinfo,sfilt); 0039 pc = set_var_col_const(pinfo.vars); 0040 onsets = sinfo.data{pc.RUN_REL_TIME}/1000; 0041 0042 % Durations 0043 if isfield(minfo,'music_dur') 0044 % Durations are constant 0045 durs = ones(size(onsets))*minfo.music_dur; 0046 elseif isfield(minfo,'music_dur_db') && minfo.music_dur_db 0047 sids = sinfo.data{pc.EVENT_CODE}; 0048 durs = fmri_stim_duration(pinfo,minfo,sids); 0049 end 0050 0051 % iterate over stim avg sets, get average resp_params, calculate vals 0052 vals = zeros(pinfo.scanner.actual_nvol,nsav); 0053 for j=1:nsav 0054 vset = stim_avg_vars{j}; 0055 resp_params = []; 0056 for k=1:length(vset) 0057 cue = ccm(vset{k}); % get cue for this regressor 0058 lrp = extract_resp_params_v2(cue,pinfo,minfo,sess); 0059 if isempty(lrp), continue; end 0060 resp_params = [resp_params lrp]; 0061 end % for k=1:length(vset 0062 avg_rp = mean(resp_params,2); 0063 vals(:,j) = fmri_convolve_regress(onsets,durs,avg_rp,pinfo.scanner.TR,... 0064 pinfo.scanner.dt,pinfo.scanner.actual_nvol); 0065 end % for j=1:length(stim_avg_vars