Home > bml > annot > bml_annot_shadow.m

bml_annot_shadow

PURPOSE ^

BML_ANNOT_SHADOW creates annotations that 'shadow' the ones in annot

SYNOPSIS ^

function shadow = bml_annot_shadow(cfg,annot)

DESCRIPTION ^

 BML_ANNOT_SHADOW creates annotations that 'shadow' the ones in annot

 Use as
   shadow = bml_annot_shadow(cfg,annot)

 cfg.direction - double: if positive the shadow is in future time 
           (defaults to 1)
 cfg.max_duration - double: maximal allowed duration of shadow
 cfg.gap_duration - double: duraton of gap between annot and shadow

 shadow inherits all variable names from annot

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function shadow = bml_annot_shadow(cfg,annot)
0002 
0003 % BML_ANNOT_SHADOW creates annotations that 'shadow' the ones in annot
0004 %
0005 % Use as
0006 %   shadow = bml_annot_shadow(cfg,annot)
0007 %
0008 % cfg.direction - double: if positive the shadow is in future time
0009 %           (defaults to 1)
0010 % cfg.max_duration - double: maximal allowed duration of shadow
0011 % cfg.gap_duration - double: duraton of gap between annot and shadow
0012 %
0013 % shadow inherits all variable names from annot
0014 
0015 direction      = bml_getopt(cfg,'direction',1);
0016 gap_duration    = bml_getopt(cfg,'gap_duration',0);
0017 max_duration    = bml_getopt(cfg,'max_duration');
0018 
0019 assert(isempty(bml_annot_overlap(annot)),"annot should not contain overlaps")
0020 
0021 shadow = annot;
0022 if direction > 0 %shadow into future
0023   
0024   for i=1:(height(annot)-1)
0025     shadow.starts(i) = annot.ends(i) + gap_duration;
0026     shadow.ends(i) = annot.starts(i+1);
0027   end
0028   shadow.starts(end) = annot.ends(end) + gap_duration;
0029   shadow.ends(end) = inf;
0030   if ~isempty(max_duration)
0031     filtvec = shadow.ends-shadow.starts>max_duration;
0032     shadow.ends(filtvec) = shadow.starts(filtvec) + max_duration;
0033   end
0034   
0035 else %shadow into pass
0036   
0037   shadow.starts(1) = -inf;
0038   shadow.ends(1) = annot.starts(1) - gap_duration;
0039   for i=2:height(annot)
0040     shadow.starts(i) = annot.ends(i-1) ;
0041     shadow.ends(i) = annot.starts(i) - gap_duration;
0042   end
0043   if ~isempty(max_duration)
0044     filtvec = shadow.ends-shadow.starts>max_duration;
0045     shadow.starts(filtvec) = shadow.ends(filtvec) - max_duration;
0046   end
0047   
0048 end
0049 
0050 shadow = bml_annot_table(shadow);

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