function [newshift] = convertShiftsBack(cshift, shiftso) %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %NoRMCorre outputs the shifts as a struct. This is hard to visualize, so I %transform the shifts to a vector and sometimes calculate them as a vector. %This function takes a vector and turns it back into the corresponding %NoRMCorre shifts % Inputs: % - cshift: struct containing vectors of the x, y, x upsampled, and y upsampled % movements % - shiftso: The original struct generated by NoRMCorre % Output: % - filtIm: the filtered image %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ogsize = size(shiftso(1).shifts(:, :, 1, 1)); for fn = 1:size(cshift.x, 1) newshift(fn).shifts(:, :, 1, 1) = reshape(cshift.y(fn, :), ogsize); newshift(fn).shifts(:, :, 1, 2) = reshape(cshift.x(fn, :), ogsize); newshift(fn).shifts_up(:, :, 1, 1) = reshape(cshift.yu(fn, :), ogsize); newshift(fn).shifts_up(:, :, 1, 2) = reshape(cshift.xu(fn, :), ogsize); newshift(fn).diff = shiftso(fn).diff; end end