Home > bml > annot > bml_roi_confluence.m

bml_roi_confluence

PURPOSE ^

BML_ROI_CONFLUENCE expands entries in a roi table to cover all the file

SYNOPSIS ^

function confluent = bml_roi_confluence(cfg)

DESCRIPTION ^

 BML_ROI_CONFLUENCE expands entries in a roi table to cover all the file

 Use as
   confluent = bml_roi_confluence(roi)
   confluent = bml_roi_confluence(cfg)

 cfg.roi - roi table
 cfg.complete - logical: should the file coverage be completed at begging
   and end. Defaults to true.

 Modifies starts and ends of roi to cover all the file, for each file.
 Requires variable nSamples and Fs. Doesn't modify file coords

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function confluent = bml_roi_confluence(cfg)
0002 
0003 % BML_ROI_CONFLUENCE expands entries in a roi table to cover all the file
0004 %
0005 % Use as
0006 %   confluent = bml_roi_confluence(roi)
0007 %   confluent = bml_roi_confluence(cfg)
0008 %
0009 % cfg.roi - roi table
0010 % cfg.complete - logical: should the file coverage be completed at begging
0011 %   and end. Defaults to true.
0012 %
0013 % Modifies starts and ends of roi to cover all the file, for each file.
0014 % Requires variable nSamples and Fs. Doesn't modify file coords
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); %unique fullfile
0025 confluent = table();
0026 
0027 for i_uff=1:length(uff)
0028   i_roi = roi(strcmp(roi.fullfile,uff(i_uff)),:);
0029   
0030   %first
0031   if complete
0032     i_roi.starts(1) = bml_idx2time(i_roi(1,:),1) - 0.5 ./ i_roi.Fs(1);
0033   end
0034 
0035   %middle
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   %last
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

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