Permalink
Switch branches/tags
Nothing to show
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
88 lines (72 sloc) 2.58 KB
function calibrate_globalworkflow(p)
if ~p.isglobalfit %only normal local calibratin, just call old proram
calibrate3D_g(p);
return
end
global S beadpos1 beadpos2
ph=p;
ph.isglobalfit=false;
%set spatial calibration
ph.outputfile={};
splitpos=256;% later to GUI?
switch p.Tmode
case {'up-down','up-down mirror'}
if max(p.yrange)<splitpos %defined only in upper part
yrange1=p.yrange;
yrange2=p.yrange+splitpos;yrange2(yrange2<splitpos)=splitpos;
else
yrange1=([p.yrange splitpos]);yrange1(yrange1>splitpos)=splitpos;yrange1=unique(yrange1);
yrange2=([p.yrange+ splitpos]);yrange2(yrange2>splitpos)=splitpos;yrange2=unique(yrange2);
end
% yrange=unique([p.yrange splitpos p.yrange+splitpos]);
% yrange1=yrange(yrange<=splitpos);yrange2=yrange(yrange>=splitpos);
xrange1=p.xrange;xrange2=p.xrange;
case {'right-left','right-left mirror'}
xrange=unique([p.xrange splitpos p.xrange+splitpos]);
xrange1=xrange(xrange<=splitpos);xrange2=xrange(xrange>=splitpos);
yrange1=p.xrange;yrange2=p.xrange;
end
f=figure('Name','Bead calibration');
tg=uitabgroup(f);
t1=uitab(tg,'Title','first channel');
ph.tabgroup= uitabgroup(t1);
ph.yrange=yrange1;ph.xrange=xrange1;
[S1,beadpos1,parameters1]=calibrate3D_g(ph);
t2=uitab(tg,'Title','second channel');
ph.tabgroup= uitabgroup(t2);
ph.yrange=yrange2;ph.xrange=xrange2;
[S2,beadpos2,parameters2]=calibrate3D_g(ph);
yrangeall=[yrange1(1:end-1) splitpos yrange2(2:end)];
S1.Yrangeall=yrangeall;
S2.Yrangeall=yrangeall;
S2.posind=[1,2];
% [S,beadpos]=calibrate3D_g(ph);
% Later: also do test-fitting with corresponding spline coefficients
p.tabgroup=uitab(tg,'Title','transformation');
% find transform
if p.makeT || isempty(p.Tfile)
transform=transform_locs_simple(beadpos1{1},beadpos2{1},p);
else
transform=load(p.Tfile);
end
ph=p;
ph.outputfile=[];
ph.isglobalfit=true;
ph.Tfile=transform;
ph.outputfile=p.outputfile;
t4=uitab(tg,'Title','global cal');
ph.tabgroup= uitabgroup(t4);
ph.yrange=yrange1;ph.xrange=xrange1;
[S,beadpos,parameters_g]=calibrate3D_g(ph);
SXY(1:length(S1))=S1;
SXY(end+1:end+length(S2))=S2;
SXY_g=S;
transformation=parameters_g.transformation;
if ~isempty(p.outputfile)
if p.smap
parameters1.smappos.P=[]; parameters2.smappos.P=[]; parameters_g.smappos.P=[];
save(p.outputfile,'SXY','SXY_g','parameters_g','parameters1','parameters2','transformation');
else
save(p.outputfile,'gausscal','cspline_all','gauss_sx2_sy2','gauss_zfit','cspline','parameters');
end
end