The FitTrace function allows the user to fit a series of spectra simultaneously, for which the amplitudes in those spectra can be described by some user-defined function. In this case, the user must provide the series of spectra, a matrix describing the user-defined function, fitting parameters, and an initial fit. These are detailed below.
fit = FitTrace(spec,trace,par,fit0);
Here, ‘spec’ contains the series of spectra, ‘trace’ gives the user defined function, ‘par’ is the usual set of fitting settings, and ‘fit0’ is an initial guess of the fit.
spec: The ‘spec’ variable is constructed in one of two ways. The first option is that the series of spectra is stored in a cell, with one cell entry per spectrum. The individual spectra are then structures as here. The second option is that a single structure is created, where the field ‘S’ has an additional dimension to contain the series of spectra. This dimension must be the last dimension. Also, it should not have a corresponding frequency axis in the spec structure (for example, a series of 2D spectra should not have a field ‘spec.f3’).
trace.x: This is a 1xN vector which contains a parameter describing the user-defined function to be fitted. For example, if one fits to an exponential decay, ‘trace.x’ would contain all possible rates of decay. Note that FitTrace will not extrapolate between values in ‘trace.x’, so that this variable must be defined finely enough to get the required precision. However, too many values in ‘trace.x’ will increase memory requirements.
trace.Fx: This is an MxN matrix. Each column of ‘trace.Fx’ corresponds to a value in ‘trace.x’, giving the form of the user-defined function for that value of ‘trace.x’. Therefore, the length of the second dimension must match the number of elements in ‘trace.x’. The first dimension must have the same number of elements as there are spectra in the series. Note that the user-defined function must be differentiable with respect to ‘trace.x’ (since it is numeric, this is necessarily the case, but sharp changes in ‘trace.Fx’ will yield poor performance)
par: The ‘par’ structure functions the same way as in the FitSpec function. Note that setup should be done as if for the single spectra (so a series of 2D spectra, even if combined into a 3D structure, should be given 2D setup parameters). The ‘par.fixed’ field may contain one additional entry at the end, allowing one to fix the variable on the user-defined function (although this option is not usually useful- since this is the variable one usually wants to extract)
fit0: The ‘fit0’ structure is required for the FitTrace function (unlike the FitSpec function). Setup is the same as described for FitSpec, although one only provides an initial fit for the single spectra. One may optionally include a vector ‘fit0.x’ which provides an initial value for the variable describing the user-defined function. This will cause the first step described below to be skipped
fit: The output variable, ‘fit’, is the same as for the FitSpec function, except that it contains an additional field, ‘fit.x’, which contains the fitted values for the user-defined function.
The FitTrace function is a special implementation of the FitSpec function. If the field ‘fit0.x’ is not provided, then the function begins by estimating the value of ‘fit0.x’. This is done by running fits of the individual spectra, with peak position and linewidth fixed, so that only the amplitude is allowed to vary. The resulting amplitudes of each peak are then fit to the user-defined function to obtain initial values of fit0.x. FitTrace then constructs a new spectrum which contains the series of spectra. The last dimension becomes the fitting dimension of the user-defined function. FitTrace sets this dimension up so that the position in this dimension does not vary, and the linewidth in this dimension is used as the user-defined variable. Because the user-defined function extends over this entire dimension, it no longer makes sense to break the dimension into sections (see ‘par.grid’, 2.2.1; the other dimensions are still broken up). This increases the memory requirements, so that FitTrace uses more grid sections in the other dimensions than FitSpec. This can be user adjusted to fewer grid sections if problems in fitting arise. Note that if memory requirements for FitTrace get to high, it may be beneficial to disable parallelization (see section 2.2.19).
Note that some series of spectra may include repetition of the same spectra (repetition of time points in a decay curve, for example). This is easily managed in FitTrace, simply by repeating rows in ‘trace.Fx’ to correspond with the repeated experiments.