Commit de7a527c authored by Antonio Politi's avatar Antonio Politi
Browse files

FCS has moved to FCSAnalyze repo

parent a15e9107
<?xml version="1.0"?>
<xml>
<Image Name="D:\Antonio\mEGFP-Nup107\160308\mEGFP\0001.czi">
<x unit="pixel">127.5</x>
<y unit="pixel">127.5</x>
<z unit="pixel">0</x>
</Image>
<stage>
<x unit="um">-28957.75</x>
<y unit="um">11779.75</y>
<z unit="um">2789.802</z>
</stage>
</xml>
<xml>
<Image Name="D:\Antonio\mEGFP-Nup107\160308\mEGFP\0001.czi" />
<stage>
<x unit="um">-28957.75</x>
<y unit="um">11779.75</y>
<z unit="um">2789.802</z>
</stage>
<object ID="1">
<class>nuc</class>
<x unit="px">232</x>
<y unit="px">110</y>
<z unit="px">0</z>
<ch nr="1">
<fcsch>Ch1</fcsch>
<intensity px="1">10694.0</intensity>
<intensity px="3">17304.8888889</intensity>
<intensity px="5">14833.16</intensity>
</ch>
</object>
<object ID="1">
<class>cyt</class>
<x unit="px">212</x>
<y unit="px">138</y>
<z unit="px">0</z>
<ch nr="1">
<fcsch>Ch1</fcsch>
<intensity px="1">16529.0</intensity>
<intensity px="3">17612.3333333</intensity>
<intensity px="5">17628.56</intensity>
</ch>
</object>
</xml>
function [average_traces] = average_autocorrelation_traces(traces)
% INPUT:
% traces = autocrrelation traces as a function of time in the
% matrix. Time increases along the rows. All should have the
% same time.
%NOTE: The 1/N fitting parameter is meaningless here since the traces have been rescaled
fittedG0 = traces{3}(1,:); %1/N Scaling parameter from the fits to reduce noise
traces_rescaled_f = traces{3}*((1./fittedG0)'); % Averaging the rescaled data, fits and the errors
traces_rescaled = traces{2}*((1./fittedG0)');
traces_rescaled_er = sum(traces{4},2);
average_traces{1} = traces{1}(:,1);
average_traces{2} = traces_rescaled./size(traces{2},2);
average_traces{3} = traces_rescaled_f./size(traces{3},2);
average_traces{4} = traces_rescaled_er./size(traces{4},2);
end
\ No newline at end of file
function [G] = dye_diffusion_triplet(par,tau)
%Global Fitting for dye
no_traces = (size(par,2)-5)./4;
for i = 1:no_traces
%Defaults
N = par(6+4*(i-1));
Theta_T = par(7+4*(i-1));
Tau_T = par(8+4*(i-1));
f1 = par(9+4*(i-1));
Tau_D1 = par(1);
Alpha1 = par(2);
Kappa = par(5);
Tau_D2 = par(3);
Alpha2 = par(4);
G(:,i) = (1- Theta_T.*(1-exp(-tau./Tau_T))).*(f1.*((1+(tau./Tau_D1).^Alpha1).^-1)...
.*((1+((tau./Tau_D1).^Alpha1)./(Kappa^2)).^-0.5) + (1-f1)...
.*((1+(tau./Tau_D2).^Alpha2).^-1).*((1+((tau./Tau_D2).^Alpha2)./(Kappa^2)).^-0.5))./(N.*(1-Theta_T));
end
\ No newline at end of file
function [G] = dye_diffusion_triplet2(par,tau)
%Global Fitting for dye
no_traces = (size(par,2)-5)./3;
for i = 1:no_traces
%Defaults
N = par(6);
Theta_T = par(7+3*(i-1));
Tau_T = par(8+3*(i-1));
f1 = par(9+3*(i-1));
Tau_D1 = par(1);
Alpha1 = par(2);
Kappa = par(5);
Tau_D2 = par(3);
Alpha2 = par(4);
G(:,i) = (1- Theta_T.*(1-exp(-tau./Tau_T))).*(f1.*((1+(tau./Tau_D1).^Alpha1).^-1)...
.*((1+((tau./Tau_D1).^Alpha1)./(Kappa^2)).^-0.5) + (1-f1)...
.*((1+(tau./Tau_D2).^Alpha2).^-1).*((1+((tau./Tau_D2).^Alpha2)./(Kappa^2)).^-0.5))./(N.*(1-Theta_T));
end
\ No newline at end of file
function [fit_par,resnorm,par_table] = fcs_fitting(traces,method,Kappa,file_list)
%Defaults
N = 10;
Theta_T = 0.2;
Tau_T = 100;
f1 = 1;
Tau_D1 = 500;
Alpha1 = 1;
%Kappa = 5.5;
Tau_D2 = 5000;
Alpha2 = 1;
Tau_gfp = 271;
Alpha_gfp = 0.9074;
no_traces = size(traces{1},2); %The number of traces to be fitted
%Initialization
par_i = [N Theta_T Tau_T f1 Tau_D1 Alpha1 Kappa Tau_D2 Alpha2];
switch method
case 1 %One component non-anamolous
par_lb = [.0001 0 100 1 1 1 Kappa 5000 1];
par_ub = [10000 1 100 1 50000 1 Kappa 5000 1];
case 2 %Two component non-anamolous
par_lb = [.0001 0 100 0.5 100 1 Kappa 500 1];
par_ub = [10000 1 100 1 50000 1 Kappa 5000000 1];
case 3 %One Component anamolous
par_lb = [.0001 0 100 1 100 0.5 Kappa 5000 0.5];
par_ub = [10000 1 100 1 50000 1.2 Kappa 5000 2];
case 4 %Two component anamolous
par_lb = [.0001 0 100 0.5 100 0.5 Kappa 500 0.5];
par_ub = [10000 1 100 1 50000 1.2 Kappa 5000000 2];
case 5 %Fixing one component to mEGFP and other component non-anamolous
Tau_gfp = 400;
Alpha_gfp = 1;
par_i = [N Theta_T Tau_T f1 Tau_gfp Alpha_gfp Kappa Tau_D2 Alpha2];
par_lb = [.0001 0 100 0.5 Tau_gfp Alpha_gfp Kappa 500 1];
par_ub = [10000 1 100 1 Tau_gfp Alpha_gfp Kappa 5000000 1];
case 6 %Fixing one component to mEGFP and other component anamolous
Tau_gfp = 400;
Alpha_gfp = 1;
par_i = [N Theta_T Tau_T f1 Tau_gfp Alpha_gfp Kappa Tau_D2 Alpha2];
par_lb = [.0001 0 100 0.5 Tau_gfp Alpha_gfp Kappa 500 0.5];
par_ub = [10000 1 100 1 Tau_gfp Alpha_gfp Kappa 5000000 2];
case 7 %Global Fitting keeping one component initialized to gfp globally fitted and others free
for i = 1:no_traces
par_i(1) = Tau_gfp;
par_i(2) = Alpha_gfp;
par_i(3+7*(i-1)) = N;
par_i(4+7*(i-1)) = Theta_T;
par_i(5+7*(i-1)) = Tau_T;
par_i(6+7*(i-1)) = f1;
par_i(7+7*(i-1)) = Kappa;
par_i(8+7*(i-1)) = Tau_D2;
par_i(9+7*(i-1)) = Alpha2;
par_lb(1) = 100;
par_lb(2) = 0.5;
par_lb(3+7*(i-1)) = .0001;
par_lb(4+7*(i-1)) = 0;
par_lb(5+7*(i-1)) = 100;
par_lb(6+7*(i-1)) = 0.5;
par_lb(7+7*(i-1)) = Kappa;
par_lb(8+7*(i-1)) = 500;
par_lb(9+7*(i-1)) = 0.5;
par_ub(1) = 50000;
par_ub(2) = 1.2;
par_ub(3+7*(i-1)) = 10000;
par_ub(4+7*(i-1)) = 1;
par_ub(5+7*(i-1)) = 100;
par_ub(6+7*(i-1)) = 1;
par_ub(7+7*(i-1)) = Kappa;
par_ub(8+7*(i-1)) = 5000000;
par_ub(9+7*(i-1)) = 2;
end
%TODO: Implememt the global fitting of with alpha2 fixed as
%well
case 8 %Global Fitting of both of the diffusion coefficient and alpha for both the compenents
for i = 1:no_traces
par_i(1) = Tau_gfp;
par_i(2) = Alpha_gfp;
par_i(3) = Tau_D2;
par_i(4) = Alpha2;
par_i(5+5*(i-1)) = N;
par_i(6+5*(i-1)) = Theta_T;
par_i(7+5*(i-1)) = Tau_T;
par_i(8+5*(i-1)) = f1;
par_i(9+5*(i-1)) = Kappa;
par_lb(1) = 100;
par_lb(2) = 0.5;
par_lb(3) = 500;
par_lb(4) = 0.5;
par_lb(5+5*(i-1)) = .0001;
par_lb(6+5*(i-1)) = 0;
par_lb(7+5*(i-1)) = 100;
par_lb(8+5*(i-1)) = 0.5;
par_lb(9+5*(i-1)) = Kappa;
par_ub(1) = 50000;
par_ub(2) = 1.2;
par_ub(3) = 5000000;
par_ub(4) = 2;
par_ub(5+5*(i-1)) = 10000;
par_ub(6+5*(i-1)) = 1;
par_ub(7+5*(i-1)) = 100;
par_ub(8+5*(i-1)) = 1;
par_ub(9+5*(i-1)) = Kappa;
end
case 9 %Global fitting with only one component
for i = 1:no_traces
par_i(1) = Tau_gfp;
par_i(2) = Alpha_gfp;
par_i(3) = Tau_D2;
par_i(4) = Alpha2;
par_i(5+5*(i-1)) = N;
par_i(6+5*(i-1)) = Theta_T;
par_i(7+5*(i-1)) = Tau_T;
par_i(8+5*(i-1)) = f1;
par_i(9+5*(i-1)) = Kappa;
par_lb(1) = 100;
par_lb(2) = 0.5;
par_lb(3) = Tau_D2;
par_lb(4) = Alpha2;
par_lb(5+5*(i-1)) = .0001;
par_lb(6+5*(i-1)) = 0;
par_lb(7+5*(i-1)) = 100;
par_lb(8+5*(i-1)) = 1;
par_lb(9+5*(i-1)) = Kappa;
par_ub(1) = 500000;
par_ub(2) = 2;
par_ub(3) = Tau_D2;
par_ub(4) = Alpha2;
par_ub(5+5*(i-1)) = 10000;
par_ub(6+5*(i-1)) = 1;
par_ub(7+5*(i-1)) = 100;
par_ub(8+5*(i-1)) = 1;
par_ub(9+5*(i-1)) = Kappa;
end
case 10 %Global Fitting of both of the diffusion coefficient and alpha for both the compenents ON LOG SCALE
for i = 1:no_traces
par_i(1) = Tau_gfp;
par_i(2) = Alpha_gfp;
par_i(3) = Tau_D2;
par_i(4) = Alpha2;
par_i(5+5*(i-1)) = N;
par_i(6+5*(i-1)) = Theta_T;
par_i(7+5*(i-1)) = Tau_T;
par_i(8+5*(i-1)) = f1;
par_i(9+5*(i-1)) = Kappa;
par_lb(1) = 100;
par_lb(2) = 0.5;
par_lb(3) = 500;
par_lb(4) = 0.5;
par_lb(5+5*(i-1)) = .0001;
par_lb(6+5*(i-1)) = 0;
par_lb(7+5*(i-1)) = 100;
par_lb(8+5*(i-1)) = 0.5;
par_lb(9+5*(i-1)) = Kappa;
par_ub(1) = 50000;
par_ub(2) = 1.2;
par_ub(3) = 5000000;
par_ub(4) = 2;
par_ub(5+5*(i-1)) = 10000;
par_ub(6+5*(i-1)) = 1;
par_ub(7+5*(i-1)) = 100;
par_ub(8+5*(i-1)) = 1;
par_ub(9+5*(i-1)) = Kappa;
end
case 11 % Global fitting of one component and the othe component fixed to GFP
for i = 1:no_traces
par_i(1) = Tau_gfp;
par_i(2) = Alpha_gfp;
par_i(3) = Tau_D2;
par_i(4) = Alpha2;
par_i(5+5*(i-1)) = N;
par_i(6+5*(i-1)) = Theta_T;
par_i(7+5*(i-1)) = Tau_T;
par_i(8+5*(i-1)) = f1;
par_i(9+5*(i-1)) = Kappa;
par_lb(1) = Tau_gfp;
par_lb(2) = Alpha_gfp;
par_lb(3) = 100;
par_lb(4) = 0.5;
par_lb(5+5*(i-1)) = .0001;
par_lb(6+5*(i-1)) = 0;
par_lb(7+5*(i-1)) = 100;
par_lb(8+5*(i-1)) = 0.5;
par_lb(9+5*(i-1)) = Kappa;
par_ub(1) = Tau_gfp;
par_ub(2) = Alpha_gfp;
par_ub(3) = 500000;
par_ub(4) = 2;
par_ub(5+5*(i-1)) = 10000;
par_ub(6+5*(i-1)) = 1;
par_ub(7+5*(i-1)) = 100;
par_ub(8+5*(i-1)) = 1;
par_ub(9+5*(i-1)) = Kappa;
end
end
%LEAST SQUARE CURVE FITTING
if method ~= 7 && method ~= 8 && method ~= 9 && method ~=10 && method ~=11
%Non-Global Fitting
figure;
hold on;
for i = 1:no_traces
[fit_par(:,i),resnorm(i)] = lsqcurvefit(@two_comp_anamolous_protein_blinking,...
par_i,traces{1}(:,i),traces{2}(:,i),par_lb,par_ub);
end
%Create the Parameter Table
par_table = table;
par_table.File = file_list;
par_table.N = fit_par(1,:)';
par_table.Tau_D1 = fit_par(5,:)';
par_table.Alpha1 = fit_par(6,:)';
par_table.Tau_D2 = fit_par(8,:)';
par_table.Alpha2 = fit_par(9,:)';
par_table.f1 = fit_par(4,:)';
par_table.Theta_T = fit_par(2,:)';
par_table.Tau_T = fit_par(3,:)';
par_table.Kappa = fit_par(7,:)';
elseif method == 7
%Global Fitting
[fit_par,resnorm] = lsqcurvefit(@two_comp_anamolous_protein_blinking_global1,par_i,traces{1}(:,1),traces{2},par_lb,par_ub);
%Create the Parameter Table
par_table = table;
par_table.File = file_list;
par_table.N = fit_par(3:7:end)';
par_table.Tau_D1 = fit_par(1) + zeros(no_traces,1);
par_table.Alpha1 = fit_par(2) + zeros(no_traces,1);
par_table.Tau_D2 = fit_par(8:7:end)';
par_table.Alpha2 = fit_par(9:7:end)';
par_table.f1 = fit_par(8:5:end)';
par_table.Theta_T= fit_par(4:7:end)';
par_table.Tau_T = fit_par(5:7:end)';
par_table.Kappa = fit_par(7:7:end)';
elseif method == 8 || method == 9 || method == 11
[fit_par,resnorm] = lsqcurvefit(@two_comp_anamolous_protein_blinking_global2,par_i,traces{1}(:,1),traces{2},par_lb,par_ub);
%Create the Parameter Table
par_table = table;
par_table.File = file_list;
par_table.N = fit_par(5:5:end)';
par_table.Tau_D1 = fit_par(1) + zeros(no_traces,1);
par_table.Alpha1 = fit_par(2) + zeros(no_traces,1);
par_table.Tau_D2 = fit_par(3) + zeros(no_traces,1);
par_table.Alpha2 = fit_par(4) + zeros(no_traces,1);
par_table.f1 = fit_par(8:5:end)';
par_table.Theta_T= fit_par(6:5:end)';
par_table.Tau_T = fit_par(7:5:end)';
par_table.Kappa = fit_par(9:5:end)';
elseif method == 10
[fit_par,resnorm] = lsqcurvefit(@two_comp_anamolous_protein_blinking_global2_log,par_i,traces{1}(:,1),log(traces{2}),par_lb,par_ub);
%Create the Parameter Table
par_table = table;
par_table.File = file_list;
par_table.N = fit_par(5:5:end)';
par_table.Tau_D1 = fit_par(1) + zeros(no_traces,1);
par_table.Alpha1 = fit_par(2) + zeros(no_traces,1);
par_table.Tau_D2 = fit_par(3) + zeros(no_traces,1);
par_table.Alpha2 = fit_par(4) + zeros(no_traces,1);
par_table.f1 = fit_par(8:5:end)';
par_table.Theta_T= fit_par(6:5:end)';
par_table.Tau_T = fit_par(7:5:end)';
par_table.Kappa = fit_par(9:5:end)';
end
end
\ 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