Home > bml > annot > bml_annot_t0.m

bml_annot_t0

PURPOSE ^

BML_ANNOT_T0 changes the time reference of an annot table

SYNOPSIS ^

function shifted = bml_annot_t0(cfg,annot)

DESCRIPTION ^

 BML_ANNOT_T0 changes the time reference of an annot table

 Use as 
   shifted = bml_annot_t0(cfg,annot)
   shifted = bml_annot_t0(t0,annot)

 cfg.t0
 cfg.starts
 cfg.roi

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function shifted = bml_annot_t0(cfg,annot)
0002 
0003 % BML_ANNOT_T0 changes the time reference of an annot table
0004 %
0005 % Use as
0006 %   shifted = bml_annot_t0(cfg,annot)
0007 %   shifted = bml_annot_t0(t0,annot)
0008 %
0009 % cfg.t0
0010 % cfg.starts
0011 % cfg.roi
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

Generated on Tue 25-Sep-2018 10:08:19 by m2html © 2005