0001 function shifted = bml_annot_t0(cfg,annot)
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013 if isa(cfg,'double')
0014 cfg = struct('t0',cfg);
0015 elseif istable(cfg)
0016 cfg = struct('roi',cfg);
0017 end
0018
0019 t0 = bml_getopt(cfg,'t0');
0020 starts = bml_getopt(cfg,'starts');
0021 roi = bml_getopt(cfg,'roi');
0022
0023 if ~isempty(starts)
0024 t0 = starts;
0025 elseif ~isempty(roi)
0026 t0 = min(roi.starts);
0027 end
0028
0029 annot.starts = annot.starts - t0;
0030 annot.ends = annot.ends - t0;
0031 if all(ismember({'t1','t2'},annot.Properties.VariableNames))
0032 annot.t1 = annot.t1 - t0;
0033 annot.t2 = annot.t2 - t0;
0034 end
0035
0036 shifted = annot;
0037
0038
0039
0040