1function sd = makeSoftDelay(varargin)
2%makeSoftDelay Create a soft delay extension event.
3% softDelay=makeSoftDelay() Create a soft delay event, that can be used in
4% combionation with an empty (pure delay) block
5% e.g. to adjust TE, TR or other delays. The soft delay
6% extension acts by rewriting the block duration
7% based on the user input (to the interpreter)
8% according to the equation dur=input/factor+offset.
9% Required parameters are 'numeric ID' and 'string
10% hint'. Optional parameter 'factor' can be either
11% positive and negative. Optional parameter 'offset'
12% given in seconds can also be either positive and
13% negative. The 'hint' parameter is expected to be
14% for identical 'numID'.
15%
16% See also Sequence.addBlock() Sequence.applySoftDelay()
18persistent parser
19if isempty(parser)
20 parser = mr.aux.InputParserCompat;
21 parser.FunctionName = 'makeSoftDelay';
23 addRequired(parser, 'numID', @isnumeric);
24 addRequired(parser, 'hint', @(x) ischar(x)&&~isempty(x));
25 addOptional(parser, 'offset', 0, @isnumeric);
26 addOptional(parser, 'factor', 1, @isnumeric);
27end
29parse(parser, varargin{:});
30opt = parser.Results;
32if length(regexp(opt.hint, '(\s+)','split'))>1
33 error('makeSoftDelay: parameter ''hint'' may not contain white space characters');
34end
36if opt.factor==0
37 error('makeSoftDelay: parameter ''factor'' must be nonzero');
38end
40sd.type = 'softDelay';
41sd.num = opt.numID;
42sd.hint = opt.hint;
43sd.offset = opt.offset;
44sd.factor = opt.factor;
46end