Home > marsbar > @mardo > event_fitted.m

event_fitted

PURPOSE ^

method to compute fitted event time course

SYNOPSIS ^

function [tc, dt] = event_fitted(D, e_spec, dur)

DESCRIPTION ^

 method to compute fitted event time course
 FORMAT [tc dt]  = event_fitted(D, e_spec, dur)
 
 D          - design
 e_spec     - 2 by N array specifying events to combine
                 with row 1 giving session number
                 and row 2 giving event number in session
                 This may in due course become an object type
 dur        - duration in seconds of event to estimate for
 
 Returns
 tc         - fitted event time course, averaged over events
 dt         - time units (seconds per row in X)

 $Id$ 

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function [tc, dt] = event_fitted(D, e_spec, dur)
0002 % method to compute fitted event time course
0003 % FORMAT [tc dt]  = event_fitted(D, e_spec, dur)
0004 %
0005 % D          - design
0006 % e_spec     - 2 by N array specifying events to combine
0007 %                 with row 1 giving session number
0008 %                 and row 2 giving event number in session
0009 %                 This may in due course become an object type
0010 % dur        - duration in seconds of event to estimate for
0011 %
0012 % Returns
0013 % tc         - fitted event time course, averaged over events
0014 % dt         - time units (seconds per row in X)
0015 %
0016 % $Id$
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   % Sum over events
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;

Generated on Wed 11-May-2022 16:26:09 by m2html © 2003-2019