function [] = applyIterativeReg_memory(vidName, datName, regMatName, outputName) %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %Applies the registration with iteratively changing patch sizes (2x2 -> 3x3 -> %6x6) using the registration from the watershed algorithm (ID all peaks, %set a registration path, and apply). Biggest change is that the variable %being applied is peakshift. % 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); %Go through each iteration of the registration and apply the appropriate %shifts 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,peakshift{fn+1},options_nr,0, 0); itname = strcat('/video', num2str(fn)); h5create(outputName, itname, size(video), 'Datatype', 'uint8'); h5write(outputName, itname, video); end end