function [] = applyIterativeReg(vidName, datName, regMatName, outputName) %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %Applies the registration with iteratively changing patch sizes (2x2 -> 3x3 -> %6x6) % Inputs: % - vidname: The name of the video to apply registration coordinates to % - datName: The name of the data in the h5 file % - regMatName: The name of the mat file containing the registration % information % - outputName: The name of the output file to use % Output: (none) % - %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% video = h5read(vidName, datName); load(regMatName) numit = length(NCparamStruct.gridsize); %Apply the registration over the different iterations for fn = 1:numit video = video(maxmove(fn, 3)+1:end-maxmove(fn, 4), maxmove(fn, 1)+1:end-maxmove(fn, 2), :); [d1 d2 d3] = size(video); options_nr = NoRMCorreSetParms('d1',d1,'d2',d2,'bin_width',50, ... 'grid_size',NCparamStruct.gridsize(fn, :),'mot_uf',NCparamStruct.motuf(fn),'correct_bidir',false, ... 'overlap_pre',NCparamStruct.overlap(fn),'overlap_post', NCparamStruct.overlap(fn),'max_shift',.... NCparamStruct.maxshift(fn), 'upd_template', true, 'shifts_method', NCparamStruct.interp); video = apply_shifts(video,shifts2{fn+1},options_nr,0, 0); itname = strcat('/video', num2str(fn)); h5create(outputName, itname, size(video), 'Datatype', 'uint8'); h5write(outputName, itname, video); end end