FITMAN Chapter 1.5 - dwong263/MAGIQ GitHub Wiki

Fitting Spectra

Background

Following water removal, the spectrum is now ready for fitting. Fitting is accomplished incorporating prior knowledge of metabolite lineshapes. Nineteen metabolite lineshapes are currently included in the in-vivo brain prior-knowledge template.

Implementation

Fitting can be done on the command line or within fitMANSuite.

Command Line

The command line fitting program, ultra_fitman is located in the the fitman/bin folder. Type ultra_fitman to see the usage options.

Fitman Compiled: Jul  1 2020 10:24:15
Copyright    John J. Potwarka and Robert Bartha
usage: fitman <data file> <guess file> <constraints file> <guess out> [parameters]
       Date: Jul  1 2020

  Parameters
  ----------
-b                      - input data file is NMR286 binary format
-t                      - input data file is NMR286 text format
-fr                     - perform fit in frequency domain
-ti                     - perform fit in time domain
-t1                     - perform fit of T1 data
-t2                     - perform fit of T2 data
-z <n>                  - zero fill to point <n> (Frequency fitting only)
-ew <n>                 - apply <n> Hz FWHM exponential weighting
-gw <n>                 - apply <n> Hz FWHM Gaussian weighting
-v <label> <n>          - set variable
-vf <filename>          - read variable file
-fp <paramter> [args]   - set or override fitting parameter
-c <filename>           - output file for covariance matrix

To fit the spectrum type something similar to the following:

ultra_fitman FULL_SPECTRUM_FILENAME.dat GUESS_FILE.ges CONSTRAINT_FILE.cst
OUTPUT_FILE.out

fitMAN Suite

To use fitMANSuite to fit data, load data into the middle window.

  • File > Data > Choose file

Load constraints file:

  • File > Constraints > Choose file

Load guess file:

  • File > Guess > Choose file

The middle window will now display three lines:

  1. Original data spectrum (yellow)
  2. The initial guess spectrum (red)
  3. The residual (blue)

Prior to fitting we must ensure that the initial parameter value estimates are “close” to the data. This is particularly important for the shift parameter. Amplitude, and width parameters are significantly more robust.

To alter the initial parameter estimates, we must open the guess file in a text editor.

The top of the guess file looks something like:

****_Guess_File_Begins_**** <--- Do not remove this line
[Parameters]
number_peaks    682
shift_units    ppm

[Variables]
sfactor 4.660000
afactor 0.100000
dfactor 0.000000
wfactor 9.000000
pfactor -3.141593

The variables section contains all the parameters that may need to be adjusted prior to fitting.

  • sfactor: shifts the frequency of all metabolites
  • afactor: scales the amplitude of all metabolites
  • dfactor: changes the delay time of all metabolites
  • wfactor: changes the width of all metabolites
  • pfactor: changes the phase of all metabolites

You can also add your own variables to the guess file.

Adjust values as needed and then reload the guess file into fitMANSuite

  • File > Reload Guess File

Continue to adjust parameters until an adequate match is obtained.

Then, to fit the spectrum:

  • File > Generate Fit

Fill in the required information and click OK.

The fitting will begin, with the terminal window showing the progress of the fit.

When fit is complete, the specified output file will be created and can be visually inspected by loading it into fitMANSuite:

  • File > Output

The specified output file can also be visually inspected by loading it into SpICeS program.

Fitting Unsuppressed Water

Fitting the unsuppressed water signal is required if the water signal is to be used as an internal reference standard. Water is fit to a single exponential decay.

Similar to the steps above, a water signal can be fit on the command line or in the fitMANSuite. The constraint and guess files required for fitting the water signal can be found in the folder pints/experiments.

Load water unsuppressed spectrum. This spectrum is generated during the conversion process and has a file name with _uns appended.

  • File > Data > Select unsuppressed water file

Load in the appropriate constraints and guess files:

  • File > Constraints > Select constraints file
  • File > Guess > Select guess file

It is best to visualize the parameter estimates in the time domain to alter the Guess file until an appropriate starting point is achieved.

Edit and reload Guess file as needed.

Finally, generate the fit:

  • File > Generate the fit > specify an appropriate output file name

The output file will be generated with information for each iteration of the fitting process displayed in the terminal window.

⚠️ **GitHub.com Fallback** ⚠️