0001 function [tc, dt] = event_fitted(D, e_spec, dur)
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018 if nargin < 2
0019 error('Need event specification');
0020 end
0021 if nargin < 3
0022 dur = 0;
0023 end
0024
0025 if ~is_fmri(D) | isempty(e_spec)
0026 tc = [];
0027 return
0028 end
0029 if ~is_mars_estimated(D)
0030 error('Need a MarsBaR estimated design');
0031 end
0032 if size(e_spec, 1) == 1, e_spec = e_spec'; end
0033
0034 e_s_l = size(e_spec, 2);
0035 SPM = des_struct(D);
0036 betas = SPM.betas;
0037 tc = zeros(1, size(betas, 2));
0038 for e_i = 1:e_s_l
0039 es = e_spec(:, e_i);
0040 ss = es(1);
0041 [X dt]= event_regressor(D, es, dur);
0042 B = betas(event_cols(D, es), :);
0043 Yh = X*B;
0044
0045
0046 sz = size(Yh, 1);
0047 szo = size(tc, 1);
0048 if sz > szo
0049 tc(end+1:sz, :) = 0;
0050 end
0051 tc(1:sz,:) = tc(1:sz,:) + Yh;
0052
0053 end
0054 tc = tc / e_s_l;