function [blank, totalmove, video] = finalFOV(folder, vidname, it) %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %Generates the cropped down version of a video following registration. %Useful for getting multiple different registrations from the same video %into the same reference frame % Inputs: % - folder: str of the folder the video is located in % - vidname: name of the video % - it: iteration of the registration to crop to % Output: % - blank: MxN image displaying which pixels in the original image size % the current video was cropped down to % - totalmove: Vector of the total pixels cropped for the iteration % - video: The cropped video (including the current iteration, which is not typically cropped out) %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% cd(folder) % Read in the data from the relevant folder gind = strfind(vidname, 'Green'); A = dir(strcat(vidname(1:gind), '*_associated.mat')); load(A(1).name); A = dir(strcat(vidname(1:gind), '*egis*.h5')); subdat = strcat('/video', num2str(it)); video = h5read(A(1).name, subdat); % Determine how much to crop the video by to account for the current % iteration of the registration itmove = sum(maxmove((it+1), :),1); video = video(itmove(3)+1:end-itmove(4), itmove(1)+1:end-itmove(2), :); %determine how many pixels was the video cropped down to for the current iteration %from the original video totalmove = sum(maxmove(1:(it+1), :), 1); blank = zeros(d1(1), d2(2)); blank(totalmove(3)+1:end-totalmove(4), totalmove(1)+1:end-totalmove(2)) = 1; end