%% Convert Binary Sequence to ROI Limits
% Consider a logical sequence that is true for samples belonging to four possible regions of interest of a signal. Convert the sequence to a two-column matrix of ROI limits.

mask = logical([0 0 1 1 1 1 0 0 0 0 1 1 1 0 0 0 0 0 1 1 1 1 1 1 1 1 1 0 0 0 1 1 0 0]);

roilims = binmask2sigroi(mask)

% Copyright 2020 The MathWorks, Inc.