method gets estimated regressor for single event FORMAT [X dt] = event_regressor(D, e_spec, dur) D - design object e_spec - event specification (see event_fitted for details) dur - event duration in seconds (default = 0) Returns X - event regressor for single event (one column per basis function used to model event) dt - time units (seconds per row in X) $Id$
0001 function [X, dt] = event_regressor(D, e_spec, dur) 0002 % method gets estimated regressor for single event 0003 % FORMAT [X dt] = event_regressor(D, e_spec, dur) 0004 % 0005 % D - design object 0006 % e_spec - event specification (see event_fitted for details) 0007 % dur - event duration in seconds (default = 0) 0008 % 0009 % Returns 0010 % X - event regressor for single event 0011 % (one column per basis function used to model event) 0012 % dt - time units (seconds per row in X) 0013 % 0014 % $Id$ 0015 0016 if nargin < 2 0017 error('Need design and event spec'); 0018 end 0019 if nargin < 3 0020 dur = 0; 0021 end 0022 if ~is_fmri(D) 0023 error('Needs FMRI design'); 0024 end 0025 0026 if size(e_spec, 1) == 1, e_spec = e_spec'; end 0027 0028 SPM = des_struct(D); 0029 Sess = SPM.Sess; 0030 dt = SPM.xBF.dt; 0031 bf = SPM.xBF.bf; 0032 ss = e_spec(1); 0033 en = e_spec(2); 0034 0035 if ~dur 0036 % SPM2 does a second's worth of spike for events without durations 0037 sf = 1/dt; 0038 else 0039 sf = ones(round(dur/dt), 1); 0040 end 0041 X = []; 0042 for b = 1:size(bf,2) 0043 X = [X conv(sf, bf(:,b))]; 0044 end