forked from jries/fit3Dcspline
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsimSplinePSF.m
More file actions
76 lines (61 loc) · 2.1 KB
/
simSplinePSF.m
File metadata and controls
76 lines (61 loc) · 2.1 KB
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
% Copyright (c)2017 Ries Lab, European Molecular Biology Laboratory,
% Heidelberg.
%
% This file is part of GPUmleFit_LM Fitter.
%
% GPUmleFit_LM Fitter is free software: you can redistribute it and/or modify
% it under the terms of the GNU General Public License as published by
% the Free Software Foundation, either version 3 of the License, or
% (at your option) any later version.
%
% GPUmleFit_LM Fitter is distributed in the hope that it will be useful,
% but WITHOUT ANY WARRANTY; without even the implied warranty of
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
% GNU General Public License for more details.
%
% You should have received a copy of the GNU General Public License
% along with GPUmleFit_LM Fitter. If not, see <http://www.gnu.org/licenses/>.
%
%
% Additional permission under GNU GPL version 3 section 7
%%
function [out] = simSplinePSF(Npixels,coeff,I,bg,cor)
t=tic;
if (nargin <5)
error('Minimal usage: simSplinePSF(Npixels,coeff,I,bg,cor)');
end
% if (bg == 0)
% bg = 10^-10;
% end
Nfits = size(cor,1);
spline_xsize = size(coeff,1);
spline_ysize = size(coeff,2);
spline_zsize = size(coeff,3);
off = floor(((spline_xsize+1)-Npixels)/2);
data = zeros(Npixels,Npixels,Nfits,'single');
for kk = 1:Nfits
xcenter = cor(kk,1);
ycenter = cor(kk,2);
zcenter = cor(kk,3);
xc = -1*(xcenter - Npixels/2+0.5);
yc = -1*(ycenter - Npixels/2+0.5);
zc = zcenter - floor(zcenter);
xstart = floor(xc);
xc = xc - xstart;
ystart = floor(yc);
yc = yc - ystart;
zstart = floor(zcenter);
[delta_f,delta_dxf,delta_ddxf,delta_dyf,delta_ddyf,delta_dzf,delta_ddzf]=computeDelta3Dj_v2(single(xc),single(yc),single(zc));
for ii = 0:Npixels-1
for jj = 0:Npixels-1
temp = fAt3Dj_v2(ii+xstart+off,jj+ystart+off,zstart,spline_xsize,spline_ysize,spline_zsize,delta_f,coeff);
model = temp*I+bg;
data(ii+1,jj+1,kk)=model;
end
end
if toc(t)>1
disp(kk/Nfits)
t=tic;
end
end
out = (poissrnd(data,Npixels,Npixels,Nfits));