Skip to content

Commit

Permalink
bugfix and additional check
Browse files Browse the repository at this point in the history
  • Loading branch information
Dominik Bach committed Aug 12, 2023
1 parent 05da2fd commit d83eefc
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/pspm_get_timing.m
Original file line number Diff line number Diff line change
Expand Up @@ -381,7 +381,6 @@
if filewarning
warning('File %s is not a valid epochs or onsets file', ...
intiming);

return;
end
else
Expand All @@ -394,6 +393,10 @@
if size(outtiming, 2) ~= 2
warning(['Epochs must be specified by a e x 2 vector', ...
'of onset/offsets.']); return;
else
if any(diff(outtiming, [], 2) < 0)
warning('Offsets must be larger than onsets.'); return;
end
end
else
warning('Unknown epoch definition format.'); return;
Expand All @@ -419,12 +422,14 @@
[~, sortindx] = sort(missepochs(:, 1));
missepochs = missepochs(sortindx,:);
% check for overlap and merge
overlapindx = zeros(size(missepochs, 1), 1);
for k = 2:size(missepochs, 1)
if missepochs(k, 1) <= missepochs(k - 1, 2)
missepochs(k, 1) = missepochs(k - 1, 1);
missepochs(k - 1, :) = [];
overlapindx(k - 1) = 1;
end
end
missepochs(logical(overlapindx), :) = [];
end
outtiming = missepochs;

Expand Down

0 comments on commit d83eefc

Please sign in to comment.