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

BUGFIX: Modified reconstruct_background to access correct frame range #24

Merged
merged 1 commit into from
Jun 19, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
11 changes: 8 additions & 3 deletions ca_source_extraction/@Sources2D/Sources2D.m
Original file line number Diff line number Diff line change
Expand Up @@ -1263,6 +1263,11 @@ function normalize(obj)
if ~exist('frame_range', 'var')||isempty(frame_range)
frame_range = obj.frame_range;
end
if isempty(obj.frame_range)
frame_shift = 0;
else
frame_shift = 1 - obj.frame_range(1);
end
% frames to be loaded for initialization
T = diff(frame_range) + 1;

Expand Down Expand Up @@ -1298,7 +1303,7 @@ function normalize(obj)
ind = (reshape(mask(:), 1, [])* obj.A_prev>0);

A_patch = obj.A_prev(logical(mask), ind);
C_patch = obj.C_prev(ind, frame_range(1):frame_range(2));
C_patch = obj.C_prev(ind, frame_shift+(frame_range(1):frame_range(2)));

% reconstruct background
% Cmean = mean(C_patch , 2);
Expand All @@ -1322,12 +1327,12 @@ function normalize(obj)
elseif strcmpi(bg_model, 'nmf')
b_nmf = obj.b{mpatch};
f_nmf = obj.f{mpatch};
Ybg(tmp_patch(1):tmp_patch(2), tmp_patch(3):tmp_patch(4),:) = reshape(b_nmf*f_nmf(:, frame_range(1):frame_range(2)), diff(tmp_patch(1:2))+1, [], T);
Ybg(tmp_patch(1):tmp_patch(2), tmp_patch(3):tmp_patch(4),:) = reshape(b_nmf*f_nmf(:, frame_shift+(frame_range(1):frame_range(2))), diff(tmp_patch(1:2))+1, [], T);
else
b_svd = obj.b{mpatch};
f_svd = obj.f{mpatch};
b0_svd = obj.b0{mpatch};
Ybg(tmp_patch(1):tmp_patch(2), tmp_patch(3):tmp_patch(4),:) = reshape(bsxfun(@plus, b_svd*f_svd(:, frame_range(1):frame_range(2)), b0_svd), diff(tmp_patch(1:2))+1, [], T);
Ybg(tmp_patch(1):tmp_patch(2), tmp_patch(3):tmp_patch(4),:) = reshape(bsxfun(@plus, b_svd*f_svd(:, frame_shift+(frame_range(1):frame_range(2))), b0_svd), diff(tmp_patch(1:2))+1, [], T);
end

end
Expand Down