-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcCRLB_demo.m
76 lines (63 loc) · 2.69 KB
/
cCRLB_demo.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
%------ Demo code for constrained Cramer Rao Lower bound calculation
% software requirement: Matlab R2015a or later
%
% (C) Copyright 2020 The Huang Lab
% All rights reserved Weldon School of Biomedical Engineering
% Purdue University
% West Lafayette, Indiana
% USA
% Yilun Li, April 2017
%% create parallel pool, it usually takes 1 to 6 minutes
clc
clearvars;
close all;
if isempty(gcp)
distcomp.feature('LocalUseMpiexec', false);
c = parcluster;
pool = parpool(c.NumWorkers);
end
%% create normalized ideal image
realstrsz = 1024; % number of pixels for underlying structure (ought to be infinite)
strsize = 0.005; % the pixel size of underlyin structure on sample plane, unit is micron
NA = 1.4; % numerical aperture of the microscope system
Lambda = 0.7; % emission wavelength of the sample, unit is micron
imgsz = 64; % number of pixels for ideal image
Rb = realstrsz/imgsz; % Rate of binning
Pixelsize=strsize*Rb; % the pixel size of ideal image on sample plane, unit is micron
%% creat Siemens star ideal norm
OTF_mask=gen_otf(NA,Lambda,strsize,realstrsz);
strip_n=14; % Number of branches of Siemens star
star=im_radial_stripe(realstrsz,strip_n);
idealimgnorm=lpf(star,OTF_mask); % ideal norm image with many (shoule be infinite) pixels
ideal_norm=binimg(idealimgnorm,Rb)./(Rb^2); % ideal norm image with limited pixels
%% generate ideal image
I = 20; % total photon count of per area
bg = 10; % background photon count
ideal_img=ideal_norm.*I+bg;
OTF=gen_otf(NA,Lambda,Pixelsize,imgsz);
imagesc(OTF)
title('Optical transfer function')
%% select variance map from calibrated map data
% the calibrated maps are 512 by 512 pixels
% varsub: selected variance map, size is the same as the ideal image size
% gainsub: selected gain map, size is the same as the ideal image size
% test gain calibration file: gaincalibration_561_gain.mat
gainfile = 'gaincalibration_561_gain.mat';
[varsub,gainsub] = gennoisemap(imgsz,gainfile);%% select variance map from calibrated map data
%% CRLB calculation
% CRLB=genCRLB(ideal_img,gainsub,varsub); % original CRLB calculation
CRLB=ideal_img+varsub./gainsub.^2; % Maximum likelihood function estimates approaches CRLB asymptotically, generating same results as previous approach but much faster.
figure
imagesc(CRLB)
colorbar
title('CRLB')
axis equal
axis off
%% cCRLB calculation This may take 5-10 minutes
cCRLB=gencCRLB(ideal_img,CRLB,OTF);
figure
imagesc(cCRLB)
colorbar
title('cCRLB')
axis equal
axis off