Commit 44fa1f22 authored by Balint Balazs's avatar Balint Balazs
Browse files

adds paper_figures folder

parent 2e66a4cd
B3D_0.00 B3D_1.00
filename compression ratio psnr write speed read speed compression ratio psnr write speed read speed
drosophila_D2re_BG-_masked24_768x1600x211 7.5235 1.#INF 374.789 492.986 25.6341 66.6207 299.196 461.656
zebrafish_masked8_2048x2048x301 8.49257 1.#INF 489.901 509.816 26.7593 78.7571 414.791 604.839
phallusia_T05_S0CL_masked_1800x1600x241 18.4218 1.#INF 504.163 623.433 44.0417 64.4763 389.668 588.228
B3D_LL B3D_0.5 B3D_1.0 B3D_2.0
filename compression ratio psnr write speed read speed compression ratio psnr write speed read speed compression ratio psnr write speed read speed compression ratio psnr write speed read speed
dapi_-100_masked100_1344x1024x383 22.3952 1.#INF 389.664 524.774 30.4332 79.3807 311.321 497.25 37.1014 73.4275 311.707 492.861 47.4248 67.4311 312.288 503.983
vsvg-cfp_-100_masked120_1344x1024x383 9.96477 1.#INF 368.111 508.06 13.9431 78.5154 302.694 474.03 18.3218 72.4373 304.251 468.505 25.1763 66.5393 308.17 491.174
pm-647_-100_masked108_1344x1024x383 8.2781 1.#INF 352.117 486.891 11.3634 77.8411 294.187 439.415 14.7448 71.9307 299.447 443.879 20.1478 65.9668 302.785 449.639
B3D_LL B3D_0.5 B3D_1.0 B3D_2.0
filename compression ratio psnr write speed read speed compression ratio psnr write speed read speed compression ratio psnr write speed read speed compression ratio psnr write speed read speed
MT0.N1.LD-2D-Exp_64x64x19968 1.57368 1.#INF 231.785 313.235 3.37133 60.3995 262.611 367.904 4.59218 54.3817 285.176 394.915 6.88483 48.3601 304.67 460.151
ROI6_MT647_10ms_EM100_10MHz_MM_100perc_1_2_280x231x13312 1.43584 1.#INF 160.077 297.124 3.76235 50.3882 168.816 404.51 5.28491 50.315 177.888 429.257 8.02211 49.9352 185.108 462.9
ROI8_100perc561_25ms_EM200_10MHZ_MM_1_263x220x30016 1.3131 1.#INF 135.215 271.282 3.64431 61.3131 258.432 430.609 5.08952 56.6057 270.506 429.213 7.74299 51.1868 278.725 468.697
B3D_LL B3D_0.5 B3D_1.0 B3D_2.0
filename compression ratio psnr write speed read speed compression ratio psnr write speed read speed compression ratio psnr write speed read speed compression ratio psnr write speed read speed
MT0.N1.LD-2D-Exp_64x64x19968 1.57368 1.#INF 252.005 338.376 3.36726 60.3995 330.49 498.375 4.56871 54.3772 315.134 521.709 6.8286 48.356 369.647 547.338
ROI6_MT647_10ms_EM100_10MHz_MM_100perc_1_2_280x231x13312 1.43584 1.#INF 157.12 307.128 3.72778 62.3403 329.965 488.517 5.24192 60.3586 346.394 516.81 7.9035 55.6931 364.787 545.484
ROI8_100perc561_25ms_EM200_10MHZ_MM_1_263x220x30016 1.3131 1.#INF 136.886 284.887 3.64242 60.331 311.553 454.295 5.07573 57.6609 335.407 475.562 7.67029 51.1715 344.55 501.334
%% define data
baseFolder = fileparts(matlab.desktop.editor.getActiveFilename);
labels = {'drosophila',...
'phallusia',...
'zebrafish',...
'simulation',...
'microtubules',...
'lifeact',...
'dapi',...
'membrane',...
'vsvg'};
% labels = {'SPIM-drosophila',...
% 'SPIM-phallusia',...
% 'SPIM-zebrafish',...
% 'SMLM-simulation',...
% 'SMLM-microtubules',...
% 'SMLM-lifeact',...
% 'screening-dapi',...
% 'screening-pm-647',...
% 'screening-vsvg-cfp'};
compressions = {'B3D lossless', 'B3D WNL'};
ratios = [7.523498676 24.634113;... % drosophila - DONE
18.4218 44.0417;... % phallusia - DONE
8.492567 26.759312;... % zebrafish - DONE
1.573679 4.567811;... % simu - DONE swapped
1.435835 5.241922;... % MT ROI6 - DONE swapped
1.313104 5.075731;... % lifeact ROI8 - DONE swapped
22.395218 37.101418;... % dapi - DONE
8.278097 14.744775;... % pm647 - DONE
9.964772 18.321808]; % vsvg - DONE
%%
figureSize = 500;
borderWidth = 1.5;
lineWidth = 1.5;
scheme = 'RdYlBu';
numColumns = 9;
%% bar plot ratios
f5 = figure(5);
cla reset;
set(f5, 'Position', [50,550,figureSize,figureSize])
hold on
axis square
set(gcf, 'Color', 'w')
set(gca, 'LineWidth', 1)
h = gca;
h.YRuler.LineWidth = borderWidth;
h.XRuler.LineWidth = borderWidth;
h.GridColor = g(1);
grid on
set(gca, 'Box', 'on', 'Color', g(0.9), 'FontSize', 14)
colors = flip(brewermap(5, scheme));
barh(flip(ratios,2));
barh(flip(ratios,2));
colormap(colors);
ylim([0.5, numColumns+0.5]);
yticklabels(labels);
% ylim([0, 1000]);
% xlabel('compression speed (MB/s)');
xlabel('compression ratio');
title({'\fontsize{16}Comparing compression ratios'})
% set(gca, 'Xscale', 'log', 'Yscale', 'log')
set(gca, 'YDir', 'Reverse')
leg3 = legend(flip(compressions));
set(leg3, 'Location', 'SouthEast');
set(leg3, 'Color', 'w', 'LineWidth', borderWidth);
%% save figure
export_fig([baseFolder, '\Fig1c_compressionBars.pdf'])
%% Parameters
spacing = 21.1; % fluorophore spacing
gridSize = 10; % grid size
Cam_Bg = 10; % camera background offset in DN
pixsize = 1; % um
sig = 1; % sigma in number of pix
gauss = 0; % gaussian noise
S = round(spacing*11); % image size
Nim = 10000; % number of images generated
NPH = [100,500,1000,5000,10000,50000,5000,50000]; % mean number of photons per molecule
BG = [20,20,20,20,20,20,100,200]; % background illumination in photons
N = size(NPH, 2);
%%
for I=2:6
% for J=1:N
tic
Nph = NPH(I);
Nph_bg = BG(I);
%% generating coordinate system
x = 1:S;
y = x;
[X, Y] = meshgrid(x,y);
%%
Z = zeros(S,S);
for i=1:gridSize
for j=1:gridSize
Z = Z + ...
0.5 .* ( erf((X-spacing*i+0.5)/sqrt(2*sig^2)) - erf((X-spacing*i-0.5)/sqrt(2*sig^2)) ) .* ...
0.5 .* ( erf((Y-spacing*j+0.5)/sqrt(2*sig^2)) - erf((Y-spacing*j-0.5)/sqrt(2*sig^2)) );
end
end
%% scaling by number of photons
GndTruth = Z*Nph;
%% adding illumination background
GndTruth = GndTruth + Nph_bg;
%% Shot noise (poisson)
im = zeros(S,S,Nim);
for i=1:Nim
im(:,:,i) = poissrnd(GndTruth);
end
%% image background
im = im + Cam_Bg;
%% Camera noise (gaussian)
im = im + gauss*randn(S,S,Nim);
%% save generated stack
fn = ['spotsSimulation_NPH', num2str(Nph),'_BG', num2str(Nph_bg), '.h5'];
h5create(fn, '/Data', size(im), 'Datatype', 'uint16')
h5write(fn, '/Data', im);
% end
toc
end
% end
% %%
% figure(1)
% imagesc(GndTruth);
% colorbar
% axis image
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Simulating SMLM experiments with various SNR
% Author: Balint Balazs
% contact: balint.balazs@embl.de
% 23.06.2017
% EMBL Heidelberg, Cell Biology and Biophysics
%
%
% NPhtoons = (100,500,1000,5000,10000,50000)
% BGPhotons = 20 for all
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
clear variables;
%%
baseFolder = 'D:\GPU_compression\STORM_From_Joran\simulateLocalizationData\newSimulations10000\compressed_102\';
Nphotons = [500,1000,5000,10000,50000];
BGlevel = 20;
compressionLevels = [0, 0.25, 0.5, 0.75, 1, 1.5, 2, 3, 4];
pixelSizeNm = 100;
%%
fileFormat = 'spotsSimulation_NPH%d_BG%d_B3D%.2f_sml.mat';
compressedFileFormat = 'spotsSimulation_NPH%d_BG%d_B3D%.2f.h5';
%%
cmax = size(compressionLevels,2);
Nmax = size(Nphotons,2);
%% get compression ratio
compressionRatios = zeros(cmax, Nmax);
for c = 1:cmax
for N = 1:Nmax
fid = H5F.open([baseFolder sprintf(compressedFileFormat, Nphotons(N), BGlevel, compressionLevels(c))]);
dset_id = H5D.open(fid, '/Data');
compressedSize = H5D.get_storage_size(dset_id);
space_id = H5D.get_space(dset_id);
[ndims,h5_dims] = H5S.get_simple_extent_dims(space_id);
fullSize = prod(h5_dims);
H5S.close(space_id);
type_id = H5D.get_type(dset_id);
type_size = H5T.get_size(type_id);
H5T.close(type_id);
H5D.close(dset_id);
compressionRatios(c,N) = type_size*fullSize/compressedSize;
H5F.close(fid);
end
end
%%
locprec = zeros(cmax, Nmax);
locprecFromFitting = locprec;
%%
for c =1:cmax
for N = 1:Nmax
%%
load([baseFolder, sprintf(fileFormat, Nphotons(N), BGlevel, compressionLevels(c))]);
locX = saveloc.loc.xnm;
locY = saveloc.loc.ynm;
errX = mod(locX, 2110);
errX(errX > 1055) = errX(errX > 1055) - 2110;
errX = errX(abs(errX)<300);
errY = mod(locY, 2110);
errY(errY > 1055) = errY(errY > 1055) - 2110;
errY = errY(abs(errY)<300);
% errD = sqrt(errX .* errX + errY.* errY);
%%
locprec(c,N) = std(errX);
locprecFromFitting(c,N) = mean(saveloc.loc.xerr);
end
end
%%
for N=1:Nmax
temp = cramer_rao(BGlevel, Nphotons(N));
cr(N) = temp(1)*pixelSizeNm;
end
%%
crNormLocPrec = bsxfun(@rdivide, locprec, cr);
normLocPrec = bsxfun(@rdivide, locprec, locprec(1,:));
normLocPrecFromFitting = bsxfun(@rdivide, locprec, locprecFromFitting(1,:));
%% plot stuff
figureSize = 300;
borderWidth = 1.5;
lineWidth = 1.5;
msMult = 6;
scheme = 'RdYlBu';
colors = flip(brewermap(5, scheme));
xmax = 4;
column = 3;
%%
f31 = figure(1175);
cla reset;
pos = get(f31, 'Position');
set(f31, 'Position', [pos(1), pos(2), figureSize*1.4, figureSize])
hold on
xx = 0:.1:xmax;
interp = spline(compressionLevels, crNormLocPrec(:,column)', xx);
plot(xx,interp, 'LineWidth', lineWidth, 'Color', colors(end,:));
plot(compressionLevels, crNormLocPrec(:,column)', '+', 'LineWidth', 2*lineWidth, 'MarkerSize', msMult*lineWidth, 'Color', colors(end,:))
% plot(xx, sqrt(1+xx.^2/12), 'g-', 'LineWidth', 2*lineWidth)
axis square
set(gcf, 'Color', 'w')
set(gca, 'LineWidth', 1)
h = gca;
h.YRuler.LineWidth = borderWidth;
h.XRuler.LineWidth = borderWidth;
h.GridColor = g(1);
grid on
set(gca, 'Box', 'on', 'Color', g(0.9), 'FontSize', 14)
xlabel('compression level')
ylabel('relative localization error', 'Color', colors(end,:));
set(gca, 'XTick', 0:xmax, 'YTick', 1:0.1:1.6,'YTickLabels', {'1', '', '1.2', '', '1.4', '', '1.6'})
ylim([0.94,1.66])
xlim([0,xmax])
ax1_pos = h.Position; % position of first axes
ax2 = axes('Position',ax1_pos,...
'XAxisLocation','bottom',...
'YAxisLocation','right',...
'Color','none');
set(ax2, 'Box', 'on', 'FontSize', 14)
set(ax2, 'XTick', [], 'YTick', 0:5:15)
hold on
interp2 = spline(compressionLevels, compressionRatios(:,column), xx);
plot(xx,interp2, 'LineWidth', lineWidth, 'Color', colors(1,:));
plot(compressionLevels, compressionRatios(:,column), '+', 'LineWidth', 2*lineWidth, 'MarkerSize', msMult*lineWidth, 'Color', colors(1,:))
xlim([0,xmax])
ylim([-1.5, 16.5])
ylabel('compression ratio', 'Color', colors(1,:))
axis square
%%
saveFolder = fileparts(matlab.desktop.editor.getActiveFilename);
export_fig([saveFolder, '\locprecVSquantStep_Fig2h_Joran.png'])
export_fig([saveFolder, '\locprecVSquantStep_Fig2h_Joran.pdf'])
%% plot multiple
figureSize = 500;
colors = brewermap(9, 'set1');
%%
f1171 = figure(1171);
cla reset;
pos = get(f1171, 'Position');
set(f1171, 'Position', [pos(1), pos(2), figureSize*1.4, figureSize])
hold on
xx = 0:.1:xmax;
interp = spline(compressionLevels, crNormLocPrec', xx);
for N=2:Nmax
%plot(xx,interp(N,:), 'LineWidth', lineWidth, 'Color', colors(N,:));
plot(compressionLevels, crNormLocPrec(:,N)', '-', 'LineWidth', 2*lineWidth, 'MarkerSize', msMult*lineWidth, 'Color', colors(N-1,:))
end
axis square
set(gcf, 'Color', 'w')
set(gca, 'LineWidth', 1)
h = gca;
h.YRuler.LineWidth = borderWidth;
h.XRuler.LineWidth = borderWidth;
h.GridColor = g(1);
grid on
set(gca, 'Box', 'on', 'Color', g(0.9), 'FontSize', 14)
leg1171 = legend({'1000,','5000','10000','50000'}, 'Location', 'NorthWest');
set(leg1171, 'Color', 'w');
xlabel('compression level')
ylabel('relative localization error');
set(gca, 'XTick', 0:xmax, 'YTick', 1:0.2:1.8,'YTickLabels', {'1', '', '1.4', '', '1.8'})
ylim([0.92,1.88])
xlim([0,xmax])
%% plot multiple
figureSize = 500;
f1172 = figure(1172);
cla reset;
pos = get(f1172, 'Position');
set(f1172, 'Position', [pos(1), pos(2), figureSize*1.4, figureSize])
hold on
for c=1:cmax-1
%%plot(xx,interp(N,:), 'LineWidth', lineWidth, 'Color', colors(N,:));
plot(Nphotons, crNormLocPrec(c,:), '-', 'LineWidth', 2*lineWidth, 'MarkerSize', msMult*lineWidth, 'Color', colors(c,:))
end
axis square
set(gcf, 'Color', 'w')
set(gca, 'LineWidth', 1)
h = gca;
h.YRuler.LineWidth = borderWidth;
h.XRuler.LineWidth = borderWidth;
h.GridColor = g(1);
grid on
set(gca, 'Box', 'on', 'Color', g(0.9), 'FontSize', 14)
set(gca, 'Xscale', 'log')
xlabel('number of photons/localizaiton')
ylabel('relative localization error');
set(gca, 'XTick', Nphotons, 'YTick', 1:0.1:1.4)
ylim([0.96,1.44])
xlim([500,50000])
leg = legend({'lossless','0.25\sigma','0.5\sigma','0.75\sigma', '1\sigma','1.5\sigma', '2\sigma', '2.5\sigma','3\sigma'}, 'Location', 'NorthEastOutside');
set(leg, 'Color', 'w', 'LineWidth', borderWidth);
%%
saveFolder = fileparts(matlab.desktop.editor.getActiveFilename);
export_fig([saveFolder, '\locprecVsNphotons_SFig_6.png'])
export_fig([saveFolder, '\locprecVsNphotons_SFig_6.pdf'])
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment