0001 function confluent = bml_roi_confluence(cfg)
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016 if istable(cfg)
0017 cfg = struct('roi',cfg);
0018 end
0019 complete = bml_getopt(cfg,'complete',true);
0020
0021 roi = bml_roi_table(bml_getopt(cfg,'roi'));
0022
0023 roi.fullfile = fullfile(roi.folder,roi.name);
0024 uff = unique(roi.fullfile);
0025 confluent = table();
0026
0027 for i_uff=1:length(uff)
0028 i_roi = roi(strcmp(roi.fullfile,uff(i_uff)),:);
0029
0030
0031 if complete
0032 i_roi.starts(1) = bml_idx2time(i_roi(1,:),1) - 0.5 ./ i_roi.Fs(1);
0033 end
0034
0035
0036 for i=1:(height(i_roi)-1)
0037 midpoint = (i_roi.t2(i) + i_roi.t1(i+1))/2;
0038 i_roi.ends(i) = midpoint;
0039 i_roi.starts(i+1) = midpoint;
0040 end
0041
0042
0043 if complete
0044 i_roi.ends(end) = bml_idx2time(i_roi(end,:),i_roi.nSamples(end)) + 0.5 ./ i_roi.Fs(end);
0045 end
0046
0047 confluent = [confluent; i_roi];
0048 end
0049
0050 confluent = bml_roi_table(confluent);
0051