Home > marsbar > @mardo_99 > event_regressor.m

event_regressor

PURPOSE ^

method gets estimated regressor for single event

SYNOPSIS ^

function [X, dt] = event_regressor(D, e_spec, dur)

DESCRIPTION ^

 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$

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

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 xX    = SPM.xX;
0031 dt    = xX.dt;
0032 ss    = e_spec(1);
0033 en    = e_spec(2);
0034 bf    = full(Sess{ss}.bf{en});
0035 
0036 if ~dur  
0037   % SPM99 uses one time bin for events with no duration
0038   sf = 1; 
0039 else
0040   sf    = ones(round(dur/dt), 1);
0041 end
0042 X = [];
0043 
0044 for b = 1:size(bf,2)
0045   X = [X conv(sf, bf(:,b))];
0046 end
0047 
0048 return
0049 
0050 % In SPM99 spm_graph, we also apply the filter
0051 K{1}  = struct('HChoice',    'none',...
0052            'HParam',    [],...
0053            'LChoice',    xX.K{ss}.LChoice,...
0054            'LParam',    xX.K{ss}.LParam,...
0055            'row',        1:size(X,1),...
0056            'RT',        dt);
0057 X    = pr_spm_filter('apply',K,X);

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