fitFCS

A Matlab program to fit FCS autocorrelation curves.

Written by Peter Nagy (peter.v.nagy@gmail.com)

https://peternagyweb.hu

https://peternagygroup.com

Synopsis

The program fits FCS autocorrelation curves using a model involving 2-D and 3-D diffusion components and a triplet component. The program requires the Optimization Toolbox to run. Two advanced fitting algoritms, global search and simulated annealing, are only available if the Global Optimization Toolbox is installed in Matlab.

The program can be executed in two modes: command-prompt or graphical user interface (GUI)-mode.

GUI-mode

Type 'fitFCS' at the Matlab command prompt without any input or output arguments. The following GUI will be dsiplayed.

Variable names: You have to enter the names of variables containing time, the autocorrelation curves (one or more curves columnwise) and the weights for the fitting (one or more, columnwise). Variables can be Matlab arrays or tables. If a table variable type is used as an input for the autocorrelation curves, the table headers will be used for identifying the curve in the output. If the struct variable output of 'extractCurvesFromZeissFCS' or 'extractCurvesFromNikonFCS' is used, and multiple fields are to be concatenated, type the following in the variable field to import all curves in the 'ac' field of all conditions (assuming 'curvesNikon' is the name of the structure variable): [curvesNikon.ac]
Providing weights is optional. The squared difference will be multiplied by the weight during fitting. If weights are not specified, every value will have the same weight. Once the fields for variable names are filled in, press the "Load" button to import them. The curve (or the first curve if multiple ones are present) will be plotted. If multiple curves are present, you can select which one is plotted in the "Which curve" drop-down menu.

Batch processing: If this option is selected, all curves in the variable specified for the autocorrelation curves will be fitted. Only the curve specified in the "Which curve" drop-down menu will be displayed. After the fitting, not only the original curve, but the fitted one is shown as well.

Feed results to initial box: If this option is selected, the fit results will overwrite the initial values in the Parameters window.

Diffusion components: You can specify if the diffusion correlation time or the diffusion coefficient is present in the model. If the diffusion coefficient will be fitted, the radius of the point-spread function in the X-Y plane, parameter ω, will have to be included in the model as well.

Load/Save model: The model specified in the program can be saved to a structure variable in the Matlab workspace. The structure variable will have two fields, modelType and parameterList. This structure variable can be loaded with the Load model button, and it can also be used when running the program in command-prompt mode (see later).

Fitting algorithm: Three fitting algorithms are implemented.

Model: You can add 2-D or 3-D diffusion components (up to 3) and one triplet component to the model by ticking the "Add" box and specifying the number of such components in the corresponding drop-down menu. The model is based on the following equations:

where

As it can be seen, the offset of the autocorrelation function at t=∞ is 1. If the autocorrelation function to be fitted approaches zero at t=∞, you have to add one to it.

The parameters window on the right will be populated according to the model. For every parameter, you can specify whether it is a constant or a fitted parameter. If it is a constant, its value must be specified. If if is a fitted parameter, its initial value as well as lower and upper bounds must be given.

The fitted curve will be displayed in the same graph as the original data. By sliding the markers you can specify which part of the original data set will be used for fitting.

Output: The program generates three different kinds of ouput.

Fitting is performed by clicking on the "Fit" button.

Command-prompt mode

Syntax:

8 input arguments:
[fittedParams,parameterNames,treatAsConstant,resultTable,figureStructures,plotData] = fitFCS(time,ACcurve,weights,range,modelType,parameterList,typeOfFittingAlgorithm,calculateD);

7 input arguments (calculateD is assumed to be false in this case):
[...]=fitFCS(time,ACcurve,weights,range,modelType,parameterList,typeOfFittingAlgorithm);

7 input arguments:
[...]=fitFCS(time,ACcurve,weights,range,modelStructure,typeOfFittingAlgorithm,calculateD);

6 input arguments (calculateD is assumed to be false in this case):
[...]=fitFCS(time,ACcurve,weights,range,modelStructure,typeOfFittingAlgorithm);

Input parameters:

E.g. fitFCS(t,ac(:,1),error(:,1),[5 205],{'diff3d',2,'diff2d',2,'triplet',1},{'tauD3d',[0 100;0 200],'tauD2d',[0 50;0 20],'tauTriplet',[0 0.1],'tripletFraction',[0 0.5],'N',[0 0.5]},2,0);
to fit a model consisting of two 3D diffusion components, two 2D diffusion components and one triplet component using the correlation times (and not the diffusion coefficients) using global fitting

The same result is achieved with the following command:
fitFCS(t,ac(:,1),error(:,1),[5 205],modelStruct,2,0);

Output parameters: