0001 function shadow = bml_annot_shadow(cfg,annot)
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
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
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
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);