clear % Images of the representative videos. Using the 2/80 bandpass filter and % okada filtered videos to make these images. %% Generate projection images okadafiltfold = '..\datasets\videos\okada\'; video = h5read(strcat(okadafiltfold, '031220-10x-2xbin-p40-chatgc3-%5B2.041-0.06%5DA30stim006_Green_okada1.h5'), '/video'); regfiltfold = '..\datasets\videos\registered\'; regvid = h5read(strcat(regfiltfold, '031220-10x-2xbin-p40-chatgc3-%5B2.041-0.06%5DA30stim006_Green_okada1cubic_registered.h5'), '/video3'); load(strcat(regfiltfold, '031220-10x-2xbin-p40-chatgc3-%5B2.041-0.06%5DA30stim006_Green_okada1cubic_registered_associated.mat'), 'maxmove'); simfield = sum(maxmove(1:3, :)); svid = video(simfield(3)+1:end-simfield(4), simfield(1)+1:end-simfield(2), :); sframe = 600; eframe = 750; subplot(2, 2, 1) imshowpair(svid(:, :, sframe), svid(:, :, eframe)); title('Overlap before registration') axis equal axis normal subplot(2, 2, 2) imshowpair(regvid(:, :, sframe), regvid(:, :, eframe)); title('Overlap following registration') axis equal axis normal subplot(2, 2, 3) imagesc(mean(svid(:, :, sframe:eframe), 3), [0 60]) title('Unregistered average projection') colormap gray axis equal axis normal subplot(2, 2, 4) imagesc(mean(regvid(:, :, sframe:eframe), 3), [0 60]) title('Registered average projection') colormap gray axis equal axis normal figure subplot(2, 2, 1) imagesc(max(svid(:, :, sframe:eframe), [], 3), [0 80]) title('Unregistered maximum projection') colormap gray axis equal axis normal subplot(2, 2, 2) imagesc(max(regvid(:, :, sframe:eframe), [], 3), [0 80]) title('Registered maximum projection') colormap gray axis equal axis normal subplot(2, 2, 3) imagesc(min(svid(:, :, sframe:eframe), [], 3), [0 40]) title('Unregistered minimum projection') colormap gray axis equal axis normal subplot(2, 2, 4) imagesc(min(regvid(:, :, sframe:eframe), [], 3), [0 40]) title('Registered minimum projection') colormap gray axis equal axis normal %% Correlation comparison between different fields of view load('..\datasets\figure_1-3\comparison-of-correlation.mat') logcorr = zeros(35, 18); mcorr = zeros(3, 18); stdcorr = zeros(3, 18); type = {'300', '300+150', '300+150+100'}; color = [0.5 0.2 0.2; 0.2 0.2 0.8; 0.5 0.1 0.5; 0.2 0.2 0.2]; %Figure used in manuscript is the 23 generated in this list f = figure; f.Position(1) = f.Position(1) - f.Position(3)/2; f.Position(3) = f.Position(3)*2; tg = uitabgroup; for nn = 1:length(okC) thistab = uitab(tg); for tt = 1:size(okC{nn}, 1) logcorr(nn, tt) = nanmean(unmC{nn}(tt, :)-compC{nn}(tt, :)); logcorr(nn, tt+3) = nanmean(bpnmC{nn}(tt, :)-compC{nn}(tt, :)); logcorr(nn, tt+6) = nanmean(oknmC{nn}(tt, :)-compC{nn}(tt, :)); logcorr(nn, tt+9) = nanmean(uC{nn}(tt, :)-compC{nn}(tt, :)); logcorr(nn, tt+12) = nanmean(bpC{nn}(tt, :)-compC{nn}(tt, :)); logcorr(nn, tt+15) = nanmean(okC{nn}(tt, :)-compC{nn}(tt, :)); axes('Parent',thistab); subplot(1, 3, tt) plot(compC{nn}(tt, :), 'k') hold on plot(unmC{nn}(tt, :), '--') plot(bpnmC{nn}(tt, :), '--') plot(oknmC{nn}(tt, :), '--') plot(uC{nn}(tt, :)) plot(bpC{nn}(tt, :)) plot(okC{nn}(tt, :)) legend({'Unregistered', 'Unfiltered no memory', 'BP no mem', 'BP+OK no mem', 'Unfiltered', 'Bandpass', 'Bandpass+Okada'},'Location','South') title(type{tt}) xlabel('Frame') ylabel('Correlation') ylim([-1 1]) end thistab.Title = num2str(nn); end figure %Make the barplot to show the change in correlation for the 6 different %filtering and memory vs no memory conditions for a fixed field of view mcorr = mean(logcorr); mcorr = reshape(mcorr, [3 6])'; stdcorr = std(logcorr); stdcorr = reshape(stdcorr, [3 6])'; dist = [0.4 0.6 0.8 1.2 1.4 1.6]; dist = dist'+[0 2 4]; order = [1 2 3]; for fn = 1:6 b = bar(dist(fn, :), mcorr(fn, :)', 0.1); b.FaceColor = 'flat'; hold on end xticks([1 3 5]) xticklabels({'300', '300+150', '300+150+100'}) xlabel('Patch size (pixels)') ylabel('\Delta Correlation') legend({'Unfiltered no memory', 'BP no memory', 'BP+OK no memory', 'Unfiltered', 'Bandpass', 'Bandpass+Okada'}, 'AutoUpdate', 'off') for fn = 1:6 er = errorbar(dist(fn, :), mcorr(fn,:),stdcorr(fn, :)); er.Color = [0 0 0]; er.LineStyle = 'none'; end plot(dist(1:3, 1), logcorr(:, [1 4 7]), 'k.', 'MarkerSize', 10); plot(dist(1:3, 2), logcorr(:, [1 4 7]+1), 'k.', 'MarkerSize', 10); plot(dist(1:3, 3), logcorr(:, [1 4 7]+2), 'k.', 'MarkerSize', 10); plot(dist(4:6, 1), logcorr(:, [10 13 16]), 'k.', 'MarkerSize', 10); plot(dist(4:6, 2), logcorr(:, [10 13 16]+1), 'k.', 'MarkerSize', 10); plot(dist(4:6, 3), logcorr(:, [10 13 16]+2), 'k.', 'MarkerSize', 10); %% Get the path finding example with Dijkstra's clearvars -except regfiltfold hmfolder = pwd; cd(regfiltfold) load('050720-10x-2xbin-Mp50-chatgc3-%5B2.041-0.06%5D30Astim004_Green_okada1cubic_registered_associated.mat'); cd(hmfolder) NCparamStruct.maxshift = [200 75 40]; NCparamStruct.distthresh = [200 40 20]; NCparamStruct.fillthresh = [60 30 30]; NCparamStruct.buffer = [40 40 40]; fn = 1; %Plot used in the figure is the 4th plot generated peakshift = DijkstraPeakSearch(peaks{fn+1}, shifts2{fn+1}, transKey{fn+1}, NCparamStruct.distthresh(fn), NCparamStruct.fillthresh(fn), NCparamStruct.buffer(fn), NCparamStruct.maxshift(fn), 1);