Getting Started - A Simple Example

Note

PyAMARES can function as a standalone program or be integrated into users’ existing Python MRS processing pipelines. We recommend using pyAMARES in Jupyter notebooks for greater flexibility. However, you can also copy and edit ./pyAMARES/pyAMARES/script/amaresfit.py according to your needs.

Run pyAMARES

Run pyAMARES in any web browser:

Note

New: PyAMARES now offers a user-friendly web interface for fitting AMARES models without writing any code. The web app provides a graphical interface to:

Try pyAMARES in your browser

  • Upload your FID data file

  • Upload the prior knowledge spreadsheet (Excel or CSV)

  • Edit the prior knowledge spreadsheet as needed

  • Set MR parameters (MHz, spectrum width, deadtime, etc)

  • Visualize results with interactive plots

  • Download fitted results and figures

Streamlit App

No installation required - just visit the link and start analyzing your MRS data right away!

Fitting Result

_images/simple_example.svg _images/simple_example_html.jpeg

Prior Knowledge Spreadsheet

An Example Prior Knowledge Spreadsheet

Index

BATP

BATP2

BATP3

AATP

AATP2

Initial Values

amplitude

1.41

BATP/2

BATP/2

1.545

AATP

chemicalshift

-16.15

BATP-15Hz

BATP+15Hz

-7.56

AATP-16Hz

linewidth

58.12

BATP

BATP

32.28

AATP

phase

0

BATP

BATP

BATP

BATP

g

0

0

0

0

0

Bounds

amplitude

(0,

(0,

(0,

(0,

(0,

chemicalshift

(-16.20,-16.10)

(-16.20, -16.10)

(-16.20, -16.10)

(-7.58,-7.54)

(-7.58,-7.54)

linewidth

(54.335, 61.911)

(54.335, 61.911)

(54.335, 61.911)

(31.226, 33.327)

(31.226, 33.327)

phase

(-180, 180)

(-180, 180)

(-180, 180)

(-180, 180)

(-180, 180)

g

(0,1)

(0,1)

(0,1)

(0,1)

(0,1)

Spreadsheet Format

  • Index Column: Always use the terms amplitude, chemicalshift, linewidth, phase, and g as index labels in the spreadsheet for both initial values and constraints.

  • Setup Constraints:
    • Constraints are set using brackets. For example, (-180, 180) indicates a range from -180 to 180.

    • If only a lower bound is needed, omit the second half of the bracket. For example, (0, specifies a range of 0 and above.

    • (New after version 0.3.4) If only a single value is specified in a constraint cell, the corresponding parameter is fixed and will not be fitted.

  • Physical Units:
    • In the spreadsheet, the values for amplitude and g are unitless. chemicalshift is measured in ppm, linewidth in Hz, and phase in degrees.

  • Peak Name Suffix:

    • To set up a multiplet, designate the main sublet peak using ASCII letters, and define other sublets by adding numeric suffixes to the main peak name. For instance, the triplet for β-ATP is labeled BATP, BATP2, and BATP3.

    Therefore, numbers are not allowed in other peak names.

    Similarly, the doublet for γ-ATP is labeled GATP and GATP2.

  • Constraints for Multiplets:

    • Parameters can be constrained using mathematical expressions, which is especially useful for multiplet setups.

    • Multiplets separated by J-coupling share parameters like phase and linewidth (LW). Constraints for these can be linked to the main peak name; for example, BATP in the LW and phase rows.

    • The chemicalshifts of sublets can be constrained relative to the main peak using its peak name and the J-coupling constants. For example, BATP-15Hz indicates the chemicalshift is set 15 Hz lower than that of β-ATP. If ppm is used, it will be converted to Hz using the MHz argument.

    • The amplitude of sublets can be related to the main peak. For instance, with β-ATP as a triplet having 1:2:1 amplitude ratios, the amplitude constraints for the sublets could be set as BATP/2. Similarly, for γ-ATP, where two sublets have a 1:1 amplitude ratio, the amplitude can be set as GATP.

    • Since the prior knowledge dataset spreadsheet is parsed from left to right, the peak that will be mathematically constrained to it must always be put to the left of the peaks that will be constrained. For example, for the multiplets, the main peak, such as BATP, will always be put to the left of BATP2 or BATP3, whose amplitude constraints will be fixed as BATP/2.

  • Comments

    • Comments can be added to the prior knowledge spreadsheet (CSV or XLSX) by starting lines with #.

    • In the spreadsheet in CSV format, comments cannot be added to the first rows. However, this limitation does not apply to spreadsheets in Excel xlsx format.

Note

See Tutorial for more details on how to import a prior knowledge spreadsheet using pyAMARES.