function [] = allCorrCompare(locArray) %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % Calculate the correlation for the 6 way comparison between registrations % with and without memory and under different filtering conditions. This is % a time intesntive process. To account for the differences in FOV size % between different registrations, the correlation is performed on a % fixed field of view from the unregistered video where registered pixels % are replaced with the registered video. % Inputs: % - locArray: string array of 7 file paths: % 1. raw video [filepath] % 2. unfiltered without memory [filepath] % 3. bandpass filtered without memory [filepath] % 4. bandpass & Okada filtered without memory [filepath] % 5. unfiltered with memory [filepath] % 6. bandpass filtered with memory [filepath] % 7. bandpass & Okada filtered with memory [filepath] % Output: (none) % - %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %% Parse folder locations from locArray %Folder names with the different conditions. origvidfolder = locArray(1); % raw video [filepath] unomem = locArray(2); % unfiltered without memory [filepath] bpnomem = locArray(3); % bandpass filtered without memory [filepath] oknomem = locArray(4); % bandpass & Okada filtered without memory [filepath] unfiltfolder = locArray(5); % unfiltered with memory [filepath] bandpassfolder = locArray(6); % bandpass filtered with memory [filepath] okadafolder = locArray(7); % bandpass & Okada filtered with memory [filepath] cd(unomem) %% Identify and calculate correlation for all registered videos A = dir('*egis*.h5'); for fn = 1:length(A) vidname = A(fn).name; gind = strfind(vidname, 'Green'); cd(origvidfolder) v = dir(strcat(vidname(1:gind), '*okada1.h5')); ov = h5read(v(1).name, '/video'); for it = 1:3 % Obtains the FOV for that iteration of the registration [unmFOV unmmax unmvid1] = finalFOV(unomem, vidname, it); [bpnmFOV bpnmmax bpnmvid1] = finalFOV(bpnomem, vidname, it); [oknmFOV oknmmax oknmvid1] = finalFOV(oknomem, vidname, it); [okadaFOV okadamax okvid1] = finalFOV(okadafolder, vidname, it); [bpFOV bpmax bpvid1] = finalFOV(bandpassfolder, vidname, it); [uFOV umax uvid1] = finalFOV(unfiltfolder, vidname, it); sumimg = unmFOV+okadaFOV+bpFOV+uFOV; % Find the bounding box that contains the pixels associated with at % least 1 registered video. [r c] = ind2sub(size(sumimg), find(sumimg >= 1)); r = [min(r) max(r)]; c = [min(c) max(c)]; compvid = ov(r(1):r(2), c(1):c(2), :); % Generate the videos so that each registration uses the same field % of view in the unregistered video. Then replace any pixels for % which there is a registered video with the registered data. unmvid = compvid; [do1 do2 do3] = size(unmvid1); unmvid((1:(do1))+unmmax(3)-r(1)+1, (1:(do2))+unmmax(1)-c(1)+1, :) = unmvid1; clear unmvid1 bpnmvid = compvid; [do1 do2 do3] = size(bpnmvid1); bpnmvid((1:(do1))+bpnmmax(3)-r(1)+1, (1:(do2))+bpnmmax(1)-c(1)+1, :) = bpnmvid1; clear bpnmvid1 oknmvid = compvid; [do1 do2 do3] = size(oknmvid1); oknmvid((1:(do1))+oknmmax(3)-r(1)+1, (1:(do2))+oknmmax(1)-c(1)+1, :) = oknmvid1; clear oknmvid1 okadavid = compvid; [do1 do2 do3] = size(okvid1); okadavid((1:(do1))+okadamax(3)-r(1)+1, (1:(do2))+okadamax(1)-c(1)+1, :) = okvid1; clear okvid1 bpvid = compvid; [do1 do2 do3] = size(bpvid1); bpvid((1:(do1))+bpmax(3)-r(1)+1, (1:(do2))+bpmax(1)-c(1)+1, :) = bpvid1; clear bpvid1 uvid = compvid; [do1 do2 do3] = size(uvid1); uvid((1:(do1))+umax(3)-r(1)+1, (1:(do2))+umax(1)-c(1)+1, :) = uvid1; clear uvid1 % Calculate the correlation [unmC{fn}(it, :),mM2f,vM2f] = motion_metrics(unmvid, 0); [bpnmC{fn}(it, :),mM2f,vM2f] = motion_metrics(bpnmvid, 0); [oknmC{fn}(it, :),mM2f,vM2f] = motion_metrics(oknmvid, 0); [okC{fn}(it, :),mM2f,vM2f] = motion_metrics(okadavid, 0); [bpC{fn}(it, :),mM2f,vM2f] = motion_metrics(bpvid, 0); [uC{fn}(it, :),mM2f,vM2f] = motion_metrics(uvid, 0); [compC{fn}(it, :), m, vv] = motion_metrics(compvid, 0); it end clear ov compvid bpvid uvid okvid fn end %% Save the data cd(okadafolder) savename = strcat(datestr(now,"yyyy.mm.dd_HH.MM.SS"), '_comparisonofcorrelation_1vidmatch_allsix.mat'); save(savename, 'bpnmC', 'oknmC', 'uC', 'bpC', 'unmC', 'okC', 'compC'); end