0001 function Twindow = vb_calc_timewindow(Tsample,Tperiod,Tnext)
0002
0003
0004
0005
0006
0007 if length(Tnext)==1,
0008 Nperiod = ceil((Tsample - Tperiod)/Tnext + 1);
0009 Tbegin = 1:Tnext:((Nperiod-1)*Tnext + 1);
0010 Tend = min(Tbegin + Tperiod - 1, Tsample);
0011 elseif length(Tnext)~=length(Tperiod),
0012 error('Tnext and Tperiod must be the same length.');
0013 else
0014 Nperiod = length(Tnext);
0015 Tbegin = Tnext;
0016 Tend = Tbegin+Tperiod-1;
0017 if max(Tend)>Tsample,
0018 error(['Time window exceeds the length of the MEG' ...
0019 ' meassurement.']);
0020 end
0021 end
0022 Twindow = [Tbegin' Tend'];