Skip to content
Merged
Show file tree
Hide file tree
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
16 changes: 12 additions & 4 deletions code/wrappers/+nansen/+wrapper/+flowreg/@Processor/Processor.m
Original file line number Diff line number Diff line change
Expand Up @@ -178,9 +178,12 @@ function updateCorrectionStats(obj, IND)
meanDivergence = get_mean_divergence(W);
meanTranslation = get_mean_translation(W);

% Compute quantities
xOffset = squeeze(mean(mean(W(:,:,2,:), 1), 2)); %Todo: Is 2nd x-offsets?
yOffset = squeeze(mean(mean(W(:,:,1,:), 1), 2)); %Todo: Is 1st y-offsets?
% Compute quantities. The displacement field of flowreg holds
% the displacement in x in its first channel and the
% displacement in y in its second, which is the order that
% imwarp takes a displacement field in.
xOffset = squeeze(mean(mean(W(:,:,1,:), 1), 2));
yOffset = squeeze(mean(mean(W(:,:,2,:), 1), 2));
rmsmov = sqrt(mean( W(:).^2) );

% Add results to struct
Expand Down Expand Up @@ -375,7 +378,12 @@ function onInitialization(obj)
end

function shifts = addShifts(shifts, offset)
% Add rigid shifts to struct of normcorre nonrigid shifts.
% Add a rigid offset to the displacement fields of flowreg.
%
% The offset is [dx, dy], as it comes from correctDrift, and
% the field holds the displacement in x in its first channel
% and the displacement in y in its second, so the two are in
% the same order.
for k = 1:numel(shifts)
shifts{k}(:, :, 1, :) = shifts{k}(:, :, 1, :) + offset(1);
shifts{k}(:, :, 2, :) = shifts{k}(:, :, 2, :) + offset(2);
Expand Down
15 changes: 10 additions & 5 deletions code/wrappers/+nansen/+wrapper/+normcorre/@Processor/Processor.m
Original file line number Diff line number Diff line change
Expand Up @@ -286,12 +286,17 @@ function onCompletion(obj)
methods (Static)

function ncShifts = addShifts(ncShifts, offset)
% Add rigid shifts to struct of normcorre nonrigid shifts.
% Add a rigid offset to a struct of normcorre shifts.
%
% The offset is [dx, dy], as it comes from correctDrift, while
% normcorre follows the MATLAB array convention and holds the
% shift in y in the first plane of its shifts and the shift in
% x in the second, so the two are in opposite order.
for k = 1:numel(ncShifts)
ncShifts(k).shifts(:,:,:,1) = ncShifts(k).shifts(:,:,:,1) + offset(1);
ncShifts(k).shifts(:,:,:,2) = ncShifts(k).shifts(:,:,:,2) + offset(2);
ncShifts(k).shifts_up(:,:,:,1) = ncShifts(k).shifts_up(:,:,:,1) + offset(1);
ncShifts(k).shifts_up(:,:,:,2) = ncShifts(k).shifts_up(:,:,:,2) + offset(2);
ncShifts(k).shifts(:,:,:,1) = ncShifts(k).shifts(:,:,:,1) + offset(2);
ncShifts(k).shifts(:,:,:,2) = ncShifts(k).shifts(:,:,:,2) + offset(1);
ncShifts(k).shifts_up(:,:,:,1) = ncShifts(k).shifts_up(:,:,:,1) + offset(2);
ncShifts(k).shifts_up(:,:,:,2) = ncShifts(k).shifts_up(:,:,:,2) + offset(1);
end
end
end
Expand Down
Loading