Home > marsbar > @mardo_2 > event_onsets.m

event_onsets

PURPOSE ^

method gets onsets and durations for event/session

SYNOPSIS ^

function [onsets, durations] = event_onsets(D, e_spec)

DESCRIPTION ^

 method gets onsets and durations for event/session
 FORMAT [onsets durations] = event_onsets(D, e_spec)

 D          - design object
 e_spec     - event specification (see event_fitted for details)
 
 Returns
 onsets     - onset times in TRs
 durations  - duration of events in TRs

 $Id$

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function [onsets, durations] = event_onsets(D, e_spec)
0002 % method gets onsets and durations for event/session
0003 % FORMAT [onsets durations] = event_onsets(D, e_spec)
0004 %
0005 % D          - design object
0006 % e_spec     - event specification (see event_fitted for details)
0007 %
0008 % Returns
0009 % onsets     - onset times in TRs
0010 % durations  - duration of events in TRs
0011 %
0012 % $Id$
0013   
0014 if nargin < 2
0015   error('Need design and event spec');
0016 end
0017 if ~is_fmri(D)
0018   error('Needs FMRI design');
0019 end
0020 if prod(size(e_spec)) > 2
0021   error('Can only deal with one event at a time'); 
0022 end
0023 
0024 s = e_spec(1);
0025 e = e_spec(2);
0026 SPM   = des_struct(D);
0027 
0028 U = SPM.Sess(s).U(e);
0029 onsets =    U.ons;
0030 durations = U.dur;
0031 
0032 if strcmp(SPM.xBF.UNITS, 'secs')
0033   TR = tr(D);
0034   onsets = onsets / TR;
0035   durations = durations / TR;
0036 end
0037 
0038 if prod(size(durations)) == 1
0039   durations = ones(size(onsets)) * durations;
0040 end

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