Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prevent normcorre from failing if shifts are too large relative to patch size #34

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions remove_boundaries.m
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,17 @@
add_value = NaN;
end

% Make sure shifts are not larger than size of image/patch (to prevent
% crashes, and issue a warning if shifts are too large.
if abs( shifts(1) ) >= sz(1)
shifts(1) = sign(shifts(1)) * (sz(1)-1);
warning('Detected y-shifts are larger than height of patches. Consider inceasing the height of patches!')
end
if abs( shifts(2) ) >= sz(2)
shifts(2) = sign(shifts(2)) * (sz(2)-1);
warning('Detected x-shifts are larger than width of patches. Consider inceasing the width of patches!')
end

switch lower(method)
case 'zero'
if shifts(1); X((1:abs(shifts(1)))*sign(shifts(1)) + (sz(1)+1)*(shifts(1)<0),:,:) = add_value; end
Expand Down