Commit e5f18bca authored by Antonio Politi's avatar Antonio Politi

matlab code

parent 4c332351
%%
pari = MO.par;
pari.kappa = 1;
[parf, norm] = MO.fitmodel([10, 20], {'N', 'tauD1'}, MO.par, data, 2, 10000)
[parf, norm] = MO.fitmodel([parf.N, parf.tauD1, parf.tauT, parf.thetaT], {'N', 'tauD1', 'tauT', 'thetaT'}, parf, data, 2, 10000)
pari.kappa = 2;
[parf, norm] = MO.fitmodel([10, 20], {'N', 'tauD1'}, pari, data, 2, 10000)
[parf, norm] = MO.fitmodel([parf.N, parf.tauD1, parf.tauT, parf.thetaT], {'N', 'tauD1', 'tauT', 'thetaT'}, parf, data, 2, 10000)
This diff is collapsed.
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 [] = chi_square()
%Calculates the Chi Square value of the the fittings
end
\ No newline at end of file
classdef dyeFcsmodel < absFcsmodel
properties (Access = public)
% these are the default parameters for a dye
par = struct('N', 10, 'thetaT', 0.2, 'tauT', 7, 'f1', 1, 'tauD1', 20, 'alpha1', 1, 'tauD2', 5000, 'alpha2', 1, 'kappa', 5.5);
lb = struct('N', 0.0001, 'thetaT', 0.001,'tauT', 0.1, 'f1', 1, 'tauD1', 1, 'alpha1', 0.5, 'tauD2', 500, 'alpha2', 0.5, 'kappa', 1);
hb = struct('N', 10000, 'thetaT', 1, 'tauT', 15, 'f1', 1, 'tauD1', 50000,'alpha1', 1.2, 'tauD2', 500000, 'alpha2', 2, 'kappa', 20);
end
methods
function MO = dyeFcsmodel(parnames, parvalues, lbvalues, hbvalues)
par = struct('N', 10, 'thetaT', 0.2, 'tauT', 7, 'f1', 1, 'tauD1', 20, 'alpha1', 1, 'tauD2', 5000, 'alpha2', 1, 'kappa', 5.5);
lb = struct('N', 0.0001, 'thetaT', 0.05,'tauT', 0.1, 'f1', 1, 'tauD1', 1, 'alpha1', 0.5, 'tauD2', 500, 'alpha2', 0.5, 'kappa', 1);
hb = struct('N', 10000, 'thetaT', 1, 'tauT', 15, 'f1', 1, 'tauD1', 50000,'alpha1', 1.2, 'tauD2', 500000, 'alpha2', 2, 'kappa', 20);
if nargin < 1
parnames = fieldnames(par);
end
if nargin < 2
parvalues = struct2array(par);
end
if nargin < 3
lbvalues = struct2array(lb);
end
if nargin < 4
hbvalues = struct2array(hb);
end
MO@absFcsmodel(parnames, parvalues, lbvalues, hbvalues)
end
function G = Gcomp(MO, par, tau)
% GCOMP returns ACF for dye like blinking
% par - struct of parameter values
% tau - time points to evaluate function
triplet = (1 - par.thetaT + par.thetaT*exp(-tau/par.tauT))/(1-par.thetaT);
comp1 = ((1+(tau/par.tauD1).^par.alpha1).^-1).*((1+1/par.kappa^2*(tau/par.tauD1).^par.alpha1).^-0.5);
comp2 = ((1+(tau/par.tauD2).^par.alpha2).^-1).*((1+1/par.kappa^2*(tau/par.tauD2).^par.alpha2).^-0.5);
G = 1/par.N*triplet.*(par.f1*comp1 + (1-par.f1)*comp2);
end
function vol = computeVolume(MO, par, dyetype)
% COMPUTEVOLUME Compute focal volume return value in picoliter
% par - vector or struct of parameters
if dyetype == 1
D = 464; %Alexe488 at 37 degrees
end
if dyetype == 2
D = 521; %Alexe568 at 37 degrees
end
if isstruct(par)
vol = pi^(3/2).*((2*sqrt(D*par(:,5))/1000).^3).*par(:,9);
else
vol = pi^(3/2).*((2*sqrt(D*par.tauD1)/1000).^3).*par.kappa;
end
end
function w0 = computeRadius(MO, par, dyetype)
% COMPUTERADIUS Compute focal radius ans return value in um
% par - vector or struct of parameters
if dyetype == 1
D = 464; %Alexe488 at 37 degrees
end
if dyetype == 2
D = 521; %Alexe568 at 37 degrees
end
if isstruct(par)
w0 = 2*sqrt(D*par.tauD1)/1000;
else
w0 = 2*sqrt(D*par(:,5))/1000;
end
end
%% fit thetaTtauT for a fixed kappa value
function [outPar, norm] = fitThetaTtauT(MO, data, kappa, weight)
if nargin < 3
kappa = 5;
end
if nargin < 4
weight = 1;
end
%first find optimal tauT
pari = MO.par;
pari.kappa = kappa;
%find initial value for tauD1 and N
for itry = 1:5
[N, tauD1, tauD2] = MO.initialGuess(data, 2, 10000);
if weight
[parf{itry}, normT(itry)] = MO.fitmodel([N, tauD1], {'N', 'tauD1'}, pari, data, 2, 10000);
else
[parf{itry}, normT(itry)] = MO.fitmodel_unw([N, tauD1], {'N', 'tauD1'}, pari, data, 2, 10000);
end
end
[val, pos] = min(normT);
parf1 = parf{pos};
%fit thetaT and tauT
for itry = 1:5
if weight
[parf{itry}, normT(itry)] = MO.fitmodel([parf1.N, parf1.tauD1, pari.thetaT+(1-2*rand)*pari.thetaT/8, pari.tauT+(1-2*rand)*pari.tauT/8], {'N', 'tauD1', 'thetaT', 'tauT'}, parf1, data, 2, 10000);
else
[parf{itry}, normT(itry)] = MO.fitmodel_unw([parf1.N, parf1.tauD1, pari.thetaT+(1-2*rand)*pari.thetaT/8, pari.tauT+(1-2*rand)*pari.tauT/8], {'N', 'tauD1', 'thetaT', 'tauT'}, parf1, data, 2, 10000);
end
end
[val, pos] = min(normT);
parf2 = parf{pos};
outPar(1,:) = struct2array(parf2);
norm(1,1) = normT(pos);
end
%% fit thetaTtauT for a fixed kappa value for an array of files
function [thetaT, tauT] = fitThetaTtauTArray(MO, dataC, kappa, weight)
if ~iscell(dataC)
dataC = {dataC};
warning('fitThetaTtauTArray: data is not a cell array');
end
outParCorr = [];
outParCorr_thetaT = [];
for idata = 1:length(dataC)
data = dataC{idata}(:,[1 2 3]);
[thetTfit(idata,:), normCorr_thetaT(:,idata)] = MO.fitThetaTtauT(data, kappa, weight);
end
tauT = mean(thetTfit(:,3));
thetaT = mean(thetTfit(:,2));
end
%%
function [outPar, norm] = fitKappaVal(MO, data, kappaVal, weight)
if nargin < 4
weight = 1;
end
for i = 1:length(kappaVal)
pari = MO.par;
pari.kappa = kappaVal(i);
clear('parf')
for itry = 1:5
[N, tauD1, tauD2] = MO.initialGuess(data, 2, 10000);
if weight
[parf{itry}, normT(itry)] = MO.fitmodel([N, tauD1], {'N', 'tauD1'}, pari, data, 2, 10000);
else
[parf{itry}, normT(itry)] = MO.fitmodel_unw([N, tauD1], {'N', 'tauD1'}, pari, data, 2, 10000);
end
end
[val, pos] = min(normT);
parf1 = parf{pos};
if weight
[parf, norm(i,1)] = MO.fitmodel([parf1.N, parf1.tauD1], {'N', 'tauD1'}, parf1, data, 2, 10000);
else
[parf, norm(i,1)] = MO.fitmodel_unw([parf1.N, parf1.tauD1], {'N', 'tauD1'}, parf1, data, 2, 10000);
end
outPar(i,:) = struct2array(parf);
end
end
function [outPar, norm] = fitKappaValThetaT(MO, data, kappaVal, weight)
if nargin < 4
weight = 1;
end
%fit data varying kappaVal
for i = 1:length(kappaVal)
pari = MO.par;
pari.kappa = kappaVal(i);
for itry = 1:5
[N, tauD1, tauD2] = MO.initialGuess(data, 2, 10000);
if weight
[parf{itry}, normT(itry)] = MO.fitmodel([N, tauD1], {'N', 'tauD1'}, pari, data, 2, 10000);
else
[parf{itry}, normT(itry)] = MO.fitmodel_unw([N, tauD1], {'N', 'tauD1'}, pari, data, 2, 10000);
end
end
[val, pos] = min(normT);
parf1 = parf{pos};
%just fit thetaT
for itry = 1:5
if weight
[parf{itry}, normT(itry)] = MO.fitmodel([parf1.N, parf1.tauD1, pari.thetaT+(1-2*rand)*pari.thetaT/10 ], {'N', 'tauD1', 'thetaT'}, parf1, data, 2, 10000);
else
[parf{itry}, normT(itry)] = MO.fitmodel_unw([parf1.N, parf1.tauD1, pari.thetaT+(1-2*rand)*pari.thetaT/10 ], {'N', 'tauD1', 'thetaT'}, parf1, data, 2, 10000);
end
end
[val, pos] = min(normT);
parf2 = parf{pos};
norm(i,1) = normT(pos);
outPar(i,:) = struct2array(parf2);
end
end
end
end
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
This diff is collapsed.
classdef fcsmodel()
properties (Abstract, Access = public)
par; % parameter of model
type; % name of model
end
function model
G = (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;
end
G = (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;
end
function [kappa,dye_conc] = fitting_dye_kappa(traces)
%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 = 300;
Alpha_gfp = 1;
no_traces = size(traces{1},2); %The number of traces to be fitted
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) = Kappa;
par_i(6+4*(i-1)) = N;
par_i(7+4*(i-1)) = Theta_T;
par_i(8+4*(i-1)) = Tau_T;
par_i(9+4*(i-1)) = f1;
par_lb(1) = 1;
par_lb(2) = 0.5;
par_lb(3) = Tau_D2;
par_lb(4) = Alpha2;
par_lb(5) = 1;
par_lb(6+4*(i-1)) = .0001;
par_lb(7+4*(i-1)) = 0;
par_lb(8+4*(i-1)) = 100;
par_lb(9+4*(i-1)) = 1;
par_ub(1) = 5000;
par_ub(2) = 2;
par_ub(3) = Tau_D2;
par_ub(4) = Alpha2;
par_ub(5) = 15;
par_ub(6+4*(i-1)) = 10000;
par_ub(7+4*(i-1)) = 1;
par_ub(8+4*(i-1)) = 100;
par_ub(9+4*(i-1)) = 1;
end
[fit_par,~] = lsqcurvefit(@dye_diffusion_triplet,par_i,traces{1}(:,1),traces{2},par_lb,par_ub);
kappa = fit_par(5);
dye_conc = fit_par(6:4:end);
G = dye_diffusion_triplet(fit_par,traces{1}(:,1));
subplotting_fcs(traces,G);
title('DYE');
%Plot the Distribution of the two parameters, the fraction and
%theta_T and Separately for N
figure
hold on
histogram(fit_par(9:4:end),size(traces{1},2),'FaceAlpha',0.5,'EdgeColor','none');
title('DYE');
histogram(fit_par(7:4:end),size(traces{1},2),'FaceAlpha',0.5,'EdgeColor','none');
legend('f1','\theta_T');
figure
histogram(fit_par(6:4:end),size(traces{1},2),'EdgeColor','none');
title('DYE');
legend('N');
end
\ No newline at end of file
function [kappa,dye_conc] = fitting_dye_kappa2(traces)
%UPDATE: Also keep the concentration Global
%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 = 300;
Alpha_gfp = 1;
no_traces = size(traces{1},2); %The number of traces to be fitted
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) = Kappa;
par_i(6) = N;
par_i(7+3*(i-1)) = Theta_T;
par_i(8+3*(i-1)) = Tau_T;
par_i(9+3*(i-1)) = f1;
par_lb(1) = 1;
par_lb(2) = 0.5;
par_lb(3) = Tau_D2;
par_lb(4) = Alpha2;
par_lb(5) = 1;
par_lb(6) = .0001;
par_lb(7+3*(i-1)) = 0;
par_lb(8+3*(i-1)) = 100;
par_lb(9+3*(i-1)) = 1;
par_ub(1) = 5000;
par_ub(2) = 2;
par_ub(3) = Tau_D2;
par_ub(4) = Alpha2;
par_ub(5) = 15;
par_ub(6) = 10000;
par_ub(7+3*(i-1)) = 1;
par_ub(8+3*(i-1)) = 100;
par_ub(9+3*(i-1)) = 1;
end
[fit_par,~] = lsqcurvefit(@dye_diffusion_triplet2,par_i,traces{1}(:,1),traces{2},par_lb,par_ub);
kappa = fit_par(5);
dye_conc = fit_par(6);
G = dye_diffusion_triplet2(fit_par,traces{1}(:,1));
subplotting_fcs(traces,G);
title('DYE');
%Plot the Distribution of the two parameters, the fraction and
%theta_T and Separately for N
figure
hold on
histogram(fit_par(9:3:end),size(traces{1},2),'FaceAlpha',0.5,'EdgeColor','none');
title('DYE');
histogram(fit_par(7:3:end),size(traces{1},2),'FaceAlpha',0.5,'EdgeColor','none');
legend('f1','\theta_T');
figure
histogram(fit_par(6),size(traces{1},2),'EdgeColor','none');
title('DYE');
legend('N');
end
\ No newline at end of file
function fileList = getAllFiles(dirName,extention,file_pattern_matching)
%Recursively finds all the files in a folder and its subfolder with the
%extension specified by the 3 digit string 'extension'. Directory name
%should be the name of the parent folder.
%TODO: Add a pattern matching clause to match file names
dirData = dir(dirName); %# Get the data for the current directory
dirIndex = [dirData.isdir]; %# Find the index for directories
dirData2 = dir([dirName '\*.' extention]); %Find only the files with the specific extension
%dirData2 = dirData2(~cellfun('isempty', {dirData2.name})); %To remove the invalid output of dir if the folder is found empty of reqd files
fileList = {dirData2.name}'; %'# Get a list of the files
if ~isempty(fileList)
fileList = cellfun(@(x) fullfile(dirName,x),... %# Prepend path to files
fileList,'UniformOutput',false);
end
subDirs = {dirData(dirIndex).name}; %# Get a list of the subdirectories
validIndex = ~ismember(subDirs,{'.','..'}); %# Find index of subdirectories
%# that are not '.' or '..'
for iDir = find(validIndex) %# Loop over valid subdirectories
nextDir = fullfile(dirName,subDirs{iDir}); %# Get the subdirectory path
fileList = [fileList; getAllFiles(nextDir,extention)]; %# Recursively call getAllFiles
end
end
\ No newline at end of file
function [traces,COF_files] = import_files_as_traces(extension1,extension2)
%Select the folder from UI, obtain all files paths, import the files and
%conctenate them as a single matrix in a cell
%Get all files from the directory
%Opens the selct folder dialog box multiple times to select all the
%folders you want
Directory = uigetdir;
COF_files = getAllFiles(Directory,extension1);
COR_files = getAllFiles(Directory,extension2);
Directory = uigetdir(Directory);
while Directory ~= 0
temp1 = getAllFiles(Directory,extension1);
temp2 = getAllFiles(Directory,extension2);
COF_files = [COF_files;temp1];
COR_files = [COF_files;temp2];
Directory = uigetdir(Directory);
end
%Import Files from the list
delimiterIn = '\t';
headerlinesIn = 1;
for i = 1:size(COF_files)
% COR_import = importdata(COR_files{i},delimiterIn,headerlinesIn);
% traces{1}(:,i) = COR_import.data(:,1);
% traces{2}(:,i) = COR_import.data(:,2);
% traces{3}(:,i) = COR_import.data(:,3);
COF_import = importdata(COF_files{i},delimiterIn,headerlinesIn);
COR_import = importdata(COR_files{i},delimiterIn,headerlinesIn);
traces{1}(:,i) = COF_import.data(:,1);
traces{2}(:,i) = COF_import.data(:,2);
traces{3}(:,i) = COF_import.data(:,3);
traces{4}(:,i) = COR_import.data(:,3);
end
end
\ No newline at end of file
function [resnorm,file_list_all,par_table] = master(method,phase,varargin)
%TODO: Implement fitting on the log scale , this way the errors seem to
%have the same variance.
%TODO: Make use of he averaging function in addition too
%Select the dye traces to get the kappa and the dye concentrations
if isempty(varargin)
[traces_dye,~] = import_files_as_traces('cof','cor');
[Kappa,dye_conc] = fitting_dye_kappa(traces_dye);
Kappa
else
Kappa = varargin{1};
end
%Import Traces from the folder
[traces_all,file_list_all] = import_files_as_traces('cof','cor');
%Mark the traces which were annotated in the 2c file
annotated_list = remove_annotated(file_list_all); %0 are the annotated elememts, 1 are the regular elements
%For Global Fitting of both the components
if strcmp(phase,'meta') %Plot only one trace (no cytoplam/nucleus) distinction if the cell is in metaphase
traces = cellfun(@(x) x(:,find(annotated_list)),traces_all,'UniformOutput',false);
file_list = file_list_all(find(annotated_list));
no_traces = size(traces{1},2);
[fit_par,resnorm...
,par_table] = fcs_fitting(traces,method,Kappa,file_list);
if method == 8 || method == 9 || method == 11
G = two_comp_anamolous_protein_blinking_global2(fit_par,traces{1}(:,1));
elseif method == 7
G = two_comp_anamolous_protein_blinking_global1(fit_par,traces{1}(:,1));
elseif method == 10
G = exp(two_comp_anamolous_protein_blinking_global2_log(fit_par,traces{1}(:,1)));
else
for i = 1:no_traces
G(:,i) = two_comp_anamolous_protein_blinking(fit_par(:,i),traces{1}(:,1));
end
end
subplotting_fcs(traces,G);
%Plot the Distribution of the two parameters, the fraction and
% %theta_T and Separately for N
% figure
% hold on
% histogram(fit_par(8:5:end),size(traces{1},2),'FaceAlpha',0.5,'EdgeColor','none');
% histogram(fit_par(6:5:end),size(traces{1},2),'FaceAlpha',0.5,'EdgeColor','none');
% legend('f1','\theta_T');
% figure
% histogram(fit_par(5:5:end),size(traces{1},2),'EdgeColor','none');
% legend('N');
else %Plot the nucleoplamic and the cytoplamic traces separately
%Separate Nucleoplasmic and Cytoplamic readings (apriori knowledge that
%one point is in the nucleus and other is the cytoplam)
annotated_list_nuc = annotated_list(1:2:end);
annotated_list_cyt = annotated_list(2:2:end);
traces_all_nuc = cellfun(@(x) x(:,1:2:end), traces_all, 'UniformOutput', false);
traces_all_cyt = cellfun(@(x) x(:,2:2:end), traces_all, 'UniformOutput', false);
file_list_nuc_all = file_list_all(1:2:end);
file_list_cyt_all = file_list_all(2:2:end);
file_list_nuc = file_list_nuc_all(find(annotated_list_nuc));
file_list_cyt = file_list_cyt_all(find(annotated_list_cyt));
traces_nuc = cellfun(@(x) x(:,find(annotated_list_nuc)),traces_all_nuc,'UniformOutput',false);
traces_cyt = cellfun(@(x) x(:,find(annotated_list_cyt)),traces_all_cyt,'UniformOutput',false);
%traces_nuc = average_autocorrelation_traces(traces_nuc);
%traces_cyt = average_autocorrelation_traces(traces_cyt);
[fit_par_nuc,resnorm{1}...,
par_table_nuc] = fcs_fitting(traces_nuc,method,Kappa,file_list_nuc);
[fit_par_cyt,resnorm{2}...,
par_table_cyt] = fcs_fitting(traces_cyt,method,Kappa,file_list_cyt);
G_nuc = two_comp_anamolous_protein_blinking_global2(fit_par_nuc,traces_nuc{1}(:,1));
G_cyt = two_comp_anamolous_protein_blinking_global2(fit_par_cyt,traces_cyt{1}(:,1));
subplotting_fcs(traces_nuc,G_nuc);
subplotting_fcs(traces_cyt,G_cyt);
figure
hold on
histogram(fit_par_nuc(8:5:end),size(traces_nuc{1},2),'FaceAlpha',0.5,'EdgeColor','none');
histogram(fit_par_nuc(6:5:end),size(traces_nuc{1},2),'FaceAlpha',0.5,'EdgeColor','none');
histogram(fit_par_cyt(8:5:end),size(traces_cyt{1},2),'FaceAlpha',0.5,'EdgeColor','none');
histogram(fit_par_cyt(6:5:end),size(traces_cyt{1},2),'FaceAlpha',0.5,'EdgeColor','none');
legend('f1 Nuc','\theta_T Nuc','f1 Cyt','\theta_T Cyt');
figure
histogram(fit_par_nuc(5:5:end),size(traces_nuc{1},2),'FaceAlpha',0.5,'EdgeColor','none');
hold on
histogram(fit_par_cyt(5:5:end),size(traces_cyt{1},2),'FaceAlpha',0.5,'EdgeColor','none');
legend('N Nuc','N Cyt');
end
end
\ No newline at end of file
<
function [annotation_list] = remove_annotated(file_list)
%% Pass the indices of the Name and the Annotated file
[Name,Annotation] = import_2c;
[temp1,temp2] = import_2c;
while ~isempty(temp1)
Name = [Name;temp1];
Annotation = [Annotation;temp2];
[temp1,temp2] = import_2c;
end
file_list_short = cellfun(@(x) x(1:end-7), file_list, 'UniformOutput',false);
annotation_list = zeros(size(file_list_short,1),1);
for i = 1:size(file_list_short,1)
temp = find(strcmp(file_list_short{i}, Name));
if ~isempty(temp) && ~isempty(Annotation{temp})
annotation_list(i) = 0;
else
annotation_list(i) = 1;
end
end
end
function [Name,Annotation] = import_2c()
%% Import data from text file.
% Script for importing data from the following text file:
%
% A:\Moshir\Imaging\161004_NUPsFCS\MitoSys2\NUP_interphase_1um\2c.res
%
% To extend the code to different selected data or a different text file,
% generate a function instead of a script.
% Auto-generated by MATLAB on 2016/10/27 13:48:47
%% Initialize variables.
[filename1,pathname1] = uigetfile('*.res','Select the FA TABLE 2c.res file');
filename = [pathname1 filename1];
%filename = 'A:\Moshir\Imaging\161004_NUPsFCS\MitoSys2\NUP_interphase_1um\2c.res';
delimiter = '\t';
startRow = 3;
%% Format string for each line of text:
% column3: text (%s)
% column8: text (%s)
% For more information, see the TEXTSCAN documentation.
formatSpec = '%*s%*s%s%*s%*s%*s%*s%s%*s%*s%*s%*s%*s%*s%*s%*s%*s%*s%*s%*s%*s%*s%*s%*s%*s%*s%*s%*s%*s%*s%*s%*s%*s%*s%*s%*s%*s%*s%*s%*s%*s%*s%*s%*s%*s%*s%*s%*s%*s%*s%*s%*s%*s%*s%*s%*s%*s%*s%*s%*s%*s%*s%*s%*s%*s%*s%*s%*s%*s%*s%*s%*s%*s%*s%*s%*s%*s%*s%*s%*s%*s%*s%*s%*s%*s%*s%*s%*s%*s%*s%*s%*s%*s%*s%*s%*s%*s%*s%*s%*s%*s%*s%*s%*s%*s%*s%*s%*s%*s%*s%*s%*s%*s%*s%*s%*s%*s%*s%*s%*s%*s%*s%*s%*s%*s%*s%*s%*s%*s%*s%*s%*s%*s%*s%*s%*s%*s%*s%*s%*s%*s%*s%*s%*s%*s%*s%*s%*s%*s%*s%*s%*s%*s%*s%*s%*s%*s%*s%*s%*s%*s%*s%*s%*s%*s%*s%*s%*s%*s%[^\n\r]';
if filename1 ~= 0
%% Open the text file.
fileID = fopen(filename,'r+');
%% Read columns of data according to format string.
% This call is based on the structure of the file used to generate this
% code. If an error occurs for a different file, try regenerating the code