XFIT: 1-D Peak Fitting

Introduction

Xfit is a OSF/Motif-based graphical user interface (GUI) for the program Fit, which allows the fitting of peaks to data in OTOKO-style format. The program has been written with time-resolved data in mind and so should make the fitting of a large number of data frames convenient. Fit uses PGPLOT graphics.

Start up

On typing xfit in a command window, two windows should appear:

• The xfit main window, labelled "xfit". This has a menu bar with three pull-down menus attached: File, Mode and Help. It also has a scrolled text window for displaying messages from the Fit program. Initially, this should contain information about the last update of the xfit GUI and the last update of the Fit program. A file name prompt will also appear - a file name cannot be entered here, this is treated merely as a message from Fit that it is ready to accept file names selected using the interface.
• The PGPLOT graphics window, labelled "PGPLOT Window 1". This window will be empty on starting up the program.

The File menu contains the following options:

• Save Parameters...
• Quit
File names can be specified by selecting the appropriate file type from the File menu on the Xfit main window and entering the filename in the Otoko File Selection box which subsequently appears (the desired files must be in the current working directory). The files have the following significance:

• Y - this is the data which you wish to fit.
• X - this gives the X values for each channel in the Y file. If no file is entered for the X axis, the channel numbers will be used by default. If the number of channels in the X-axis file is not equal to the number of channels in the Y file or the number of frames is not equal to 1, the default X-axis is used. The X-axis is expected to monotonically increasing or decreasing but this is not checked.
• SD's - this is a file of the standard deviations for each channel. These are then used in weighting the fit. If no file is specified, unit weights are applied.
• Load/Save Parameters - values for the fitted parameters can be saved in a file, the format of which is explained in Output. Saved parameters can then be loaded and used to initialize parameters for a new fitting run.
• The Quit option causes a Confirm dialog box to appear to verify the intention to exit xfit.

There are the following stages in opening a file for input using the Otoko File Selection box:

• click on the desired file in the right hand column.
• select the appropriate file type from the Binary Data option menu.
• enter the first frame, last frame and increment in the corresponding text fields.

Fit has three modes, Fit, Plot and Auto. When any of these options are selected from the Mode menu, the file names selected will be processed. If no Y file has been selected, the options under the mode button will be unavailable. The actions performed under the Fit option are described below. Plot merely allows the user to view the data. Auto is similar to Fit except that when processing multiple frames, all the selected frames subsequent to the first will be fitted automatically. If the value of chi-squared increases by a factor of 10 from last frame to the current frame, automatic fitting will be halted and the user can refit the current frame. Automatic fitting will then proceed for subsequent frames.

This has only one item available - Help. Selecting Help causes the xfit.html file to be displayed in (an already existing) Netscape browser, if the environment variable CCP13HOME has been set to the base directory of the CCP13 files. For example, this can be done by

setenv CCP13HOME ~/CCP13

if the CCP13 files are in a directory called CCP13 which is in your home directory.

Threshold selection

When the data for the first frame are plotted, the thresholds for the plot will be the minimum and maximum Y values present in the selected channels. If necessary, these can be altered by entering the appropriate values into the Threshold dialog box. Subsequent frames will initially be displayed with the thresholds chosen with the previous frame. Clicking on the Cancel button in the Threshold dialog box will cause xfit to move on to the next frame of data.

Selection of the region to be used in the fit

If the data is to be fitted, the user can choose to delimit the region to be used in the fit using the Limit dialog box. The limits can then be selected by clicking on the plot with the left mouse button. Once the limits of the region have been selected, the plot will be redrawn using only the required region.

Peak type selection

Peak selection is required for the first frame in the sequence if no parameters have been loaded as input. Six peak types are available:

Peak type Key Parameters
Gaussian g 3
Lorentzian c 3
Pearson VII p 4
Voigt v 4
Debye Gaussian chain scattering d 3
Double exponential x 4
Leibler diblock copolymer scattering l 6

The selection is made by pressing the appropriate key while the focus is in the plot window. All subsequent peaks will be of the same type until a different peak type is selected. The default type is Gaussian.

Peak Parameters

The formulae used for the different peak types give different meanings to the descriptions width and shape. In what follows, the position of the peak is assumed to be at the origin of the x-axis, h is the height of the peak, w is the width and s is the shape. Peak widths are the full width at half maximum (FWHM) unless otherwise stated.

• Gaussian
$y = he-4ln2\left(x/w\right)2$
• Lorentzian
$y = h/\left[1 + 4\left(x/w\right)2\right]$
• Pearson VII
$y = h/\left[1 + 4\left(x/w\right)2\left(21/s-1\right)\right]s$
When s = 1, the Pearson VII is equivalent to a Lorentzian but as s increases, the peak becomes more Gaussian in character.
• Voigt
The Voigt is a convolution of a Lorentzian with a Gaussian. The shape parameter, s, corresponds to the ratio of the width of the Lorentzian to the width of the Gaussian, w. Therefore, when s = 0, the resulting curve is a Gaussian of width w.

This can be expressed as: $y = h Integrale-4ln2\left(t/w\right)2/ \left[\left(x+\left(2ln2/w\right)2+ ln2s2\right]dt$

An approximation is used:
$y = h\left[\Sigma$i=14 (Ci(s/2 - Ai) + Di(2ln2x/w - Bi)) / ( (s/2 - Ai)2 + (2ln2x/w - Bi)2) ] /i=14 (Cis/2 - CiAi + DiBi) / (s2/4 - sAi + Ai2 + Bi2) ]
where the constants have the following values,

i = 1 2 3 4
A -1.2150 -1.3509 -1.2150 -1.3509
B 1.2359 0.3786 -1.2359 -0.3786
C -0.3085 0.5906 -0.3085 0.5906
D 0.0210 -1.1858 -0.0210 1.1858

• Debye Gaussian Chain Scattering
$y = 2h\left[e-\left(x/w\right)2- \left(1-\left(x/w\right)2\right)\right]/\left(x/w\right)4$
Here, w corresponds to 1/Rg if the x-axis corresponds to a q-axis. The central (guinier) region of the peak is Gaussian in character while the tail (power law) region is Lorentzian in character.
• Double Exponential
$y = 2h/\left[e-x/w+ e+x/s\right]$
This peak is asymmetric; w corresponds to the rate at which the peak grows, approaching from the left, while s corresponds to the rate of growth, approaching from the right.
• Leibler Diblock Copolymer Scattering
This curve is described by a different set of parameters to those above:
1. Scale factor - overall scale factor
2. Position - position on the x-axis of the origin of the q-axis
3. Length - length of a Kuhn step
4. Number - number of Kuhn steps
5. Fraction - the volume fraction of A:B
6. Flory - the Flory interaction parameter
(see L. Leibler, Macromolecules 13 (1980) 1602-1617 eqns IV-2 to IV-8)

Peak parameter selection

A peak of the current type is initialized for fitting to the data when the left mouse button is pressed. The position of the peak is determined by the X coordinate of the cursor when the button is pressed. The width of the peak is determined simultaneously by the Y coordinate of the cursor. The height of the peak is given by the Y value of the data point nearest to the peak position.

Background selection

A polynomial of degree 4 or less, expressed as $a$0 + a1.x + a2.x2 + a3.x3 + a4.x4 can be fitted as background to the data. The degree of the polynomial can be selected by using the keys <1>,...,<4> while the focus is in the plot window. The default polynomial degree is 3.

An exponential component can be added into the background by pressing <e> while the focus is in the plot window. This will add two parameters to the fit to define the exponential curve, $e$1.ee2.x .

Ending peak and background selection

Once all the required peak and background parameters have been initialized, selection can be terminated by clicking on the right mouse button while the focus is in the plot window.

Controlling the fit

Some control over the fitting procedure can be excercised through the Setup dialog box. The Setup dialog box provides a list of all the parameters in the fit with their current values displayed in text fields so that they can be easily modified. There is also an option menu associated with each parameter. The following selections can be made from this menu:

• Free - if a parameter has been previously constrained using the other options, it is released to be a free parameter in the fit.
• Set - fix the value of a parameter to the value in the text field. The parameter is effectively removed from the fit.
• Limit... - this causes the Limit dialog box to appear. This has a label to show you the parameter number you are limiting and a brief description of the parameter. Two text fields are available for setting limits on the value of the parameter. The parameter number can be incremented by use of the arrow buttons next to the parameter number. Activation of the arrow buttons has the effect of applying the limits to the previous parameter.
• Tie... - this causes the Tie dialog box to appear. This has a label to show you which parameter you are tying and a brief description of the parameter. A text field is available for setting the parameter number to which the dependent parameter will be tied. A brief description of the independent parameter is updated when the apply button is activated. An option menu is available to specify the type of constraint to be applied to the dependent parameter. These are either an equality constraint or simple lattice constraints, i.e. applying (h,k) indices for hexagonal and tetragonal lattice positions or (h,k,l) indices for cubic lattice positions. These must be relative to the (1,0) or (1,0,0) positions, respectively. The parameter number can be incremented by use of the arrow buttons next to the parameter number. Activation of the arrow buttons has the effect of applying the tie constraint for the previous parameter. N.B. xfit always ties the higher parameter number to the lower one and modifies the Tie dialog and Setup dialog boxes to reflect this. It is not possible to make a compound tie constraint unless the constraint is one of equality, e.g. to tie parameter 8 to parameter 5 as the (1,1) hexagonal position and then tie parameter 5 to parameter to parameter 2 as the (2,0) tetragonal position.
The three buttons at the bottom of the Setup dialog box have the following effects:

• PLOT - this allows you to plot the curve corresponding to the (modified) parameter set.
• STEP - this makes one linearized least-squares step. This is useful in seeing if the current model has a good chance of converging to the global minimum. The refinement may converge after a step. If the converged solution is satisfactory click on RUN to continue.
• RUN - this allows the algorithm to continue to convergence or to the maximum number of iterations (50 + number of steps taken).

After the RUN button has been activated, the parameter entries and the buttons in the Setup dialog box will be made insensitive and the Try Again confirm dialog box will appear.

Trying again

Clicking on Yes in the Try Again confirm dialog box will give you another attempt at fitting the current frame starting from the point where you select the peak types, positions, etc. The Setup dialog box will disappear and an Information dialog box will appear, reiterating the procedure for setting up the initial model. Clicking on No will cause xfit to proceed onto the next frame. If Auto had been selected as the mode option, the user will not be required to set up the subsequent fits and the program will run through to the final frame automatically.

Output

The fitted parameter values are written to an OTOKO-style file. Each channel of the output file corresponds to a frame of the input Y file. For most peak types, the parameters have the same meaning (in the case of the Debye function for small-angle scattering from Gaussian polymers, the width is equal to 1/radius of gyration). However, the Leibler function for small-angle scattering from diblock copolymers has some specific parameters detailed below. The frames of the output file are organised in the following way:
Background and origin
Frame Parameter
1 Background polynomial degree
2 a0
3 a1
4 a2
5 a3
6 a4
7 No. of exponential background parameters
8 e1
9 e2
10 Origin for lattice constraints
Peak 1 Parameter Leibler parameter
11 height scale
12 position origin of q-axis
13 width Kuhn step size
14 shape number of steps
15 integrated area volume fraction
16 unused Flory interaction parameter
17 unused unused
18 unused unused
19 unused unused
20 unused unused
Peak 2 Parameter Leibler parameter
21 height scale
etc etc etc

Diamond Light Source is the UK's national synchrotron science facility, located at the Harwell Science and Innovation Campus in Oxfordshire.

Diamond Light Source Ltd
Diamond House
Harwell Science & Innovation Campus
Didcot
Oxfordshire
OX11 0DE

Diamond Light Source® and the Diamond logo are registered trademarks of Diamond Light Source Ltd

Registered in England and Wales at Diamond House, Harwell Science and Innovation Campus, Didcot, Oxfordshire, OX11 0DE, United Kingdom. Company number: 4375679. VAT number: 287 461 957. Economic Operators Registration and Identification (EORI) number: GB287461957003.

feedback