0001 function [onsets, durations] = event_onsets(D, e_spec)
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
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