function deleteRowsByCondition
[filePaths, ~, ~] = getFilepnAllCell('Select label files', 'mat');
savePath = uigetdir('Select the folder to save the results');
iedResults = NaN(size(filePaths));
for kf = 1:numel(filePaths)
load(filePaths{kf}, 'lblSet');
disp(['Error loading file: ' filePaths{kf}]);
if exist('lblSet', 'var') && ~isempty(lblSet)
lblSet.Start.Format = 'yyyy-MM-dd HH:mm:ss';
lblSet.End.Format = 'yyyy-MM-dd HH:mm:ss';
seizureRows = lblSet(strcmp(lblSet.ClassName, "Seizure"), :);
iedRows = lblSet(strcmp(lblSet.ClassName, "Detection"), :);
timesAndValues = [datetime(lblSet.Start), datetime(lblSet.End); ones(size(lblSet, 1), 1), -ones(size(lblSet, 1), 1)];
sortedTimesAndValues = sortrows(timesAndValues', 1)';
cumSumValues = cumsum(sortedTimesAndValues(3, :));
seizureBeginIndices = find(cumSumValues == 1);
seizureEndIndices = find(cumSumValues == 0);
lblSetSz = table(sortedTimesAndValues(1, seizureBeginIndices)',...
sortedTimesAndValues(2, seizureEndIndices)',...
'VariableNames', {'Start', 'End'});
[~, name, ext] = fileparts(filePaths{kf});
save(fullfile(savePath, [name '_SzOnly' ext]), 'lblSet');
deleteRow = false(size(iedRows, 1), 1);
for j = 1:size(iedRows, 1)
startTime = iedRows.Start(j);
endTime = iedRows.End(j);
if any((startTime >= lblSetSz.Start & startTime <= lblSetSz.End) | ...
(endTime >= lblSetSz.Start & endTime <= lblSetSz.End))
lblSet(deleteRow, :) = [];
warning(['lblSet not found or is empty in file: ' filePaths{kf}]);