Skip to main content

pyAMARES, an Open-Source Python Library for Fitting Magnetic Resonance Spectroscopy Data

Project description

https://raw.githubusercontent.com/HawkMRS/pyAMARES/main/pyAMARES_logo.svg

The full documentation for pyAMARES can be found at pyAMARES Documentation.

What is pyAMARES?

The pyAMARES package provides the MRS community with an open-source, easy-to-use MRS fitting method in Python. It imports prior knowledge from Excel or CSV spreadsheets as initial values and constraints for fitting MRS data according to the AMARES model function.

Getting Started

Requirements

Python Version

Installation

pip install pyAMARES

See the Installation Guide for detailed information.

Run pyAMARES as standard-alone script

amaresFit -f ./pyAMARES/examples/fid.txt -p  ./pyAMARES/examples/example_human_brain_31P_7T.csv --MHz 120.0 --sw 10000 --deadtime 300e-6 --ifplot --xlim 10 -20 -o simple_example

Run pyAMARES in a Jupyter Notebook

Try Jupyter Notebook on Google Colab here

import pyAMARES
# Load FID from a 2-column ASCII file, and set the MR parameters
MHz = 120.0 # 31P nuclei at 7T
sw = 10000 # spectrum width in Hz
deadtime = 300e-6 # 300 us begin time for the FID signal acquisition

fid = pyAMARES.readmrs('./pyAMARES/examples/fid.txt')
# Load Prior Knowledge
FIDobj = pyAMARES.initialize_FID(fid=fid,
                                 priorknowledgefile='./pyAMARES/examples/example_human_brain_31P_7T.csv',
                                 MHz=MHz,
                                 sw=sw,
                                 deadtime=deadtime,
                                 preview=False,
                                 normalize_fid=False,
                                 xlim=(10, -20))# Region of Interest for visualization, -20 to 10 ppm

# Initialize the parameter using Levenberg-Marquard method
out1 = pyAMARES.fitAMARES(fid_parameters=FIDobj,
                           fitting_parameters=FIDobj.initialParams,
                           method='leastsq',
                           ifplot=False)

# Fitting the MRS data using the optimized parameter

out2 = pyAMARES.fitAMARES(fid_parameters=out1,
                          fitting_parameters=out1.fittedParams, # optimized parameter for last step
                          method='least_squares',
                          ifplot=False)

# Save the data
out2.styled_df.to_html('simple_example.html') # Save highlighted table to an HTML page
                                              # Python 3.6 does not support to_html.
out2.result_sum.to_csv('simple_example.csv') # Save table to CSV spreadsheet
out2.plotParameters.lb = 2.0 # Line Broadening factor for visualization
out2.plotParameters.ifphase = True # Phase the spectrum for visualization
pyAMARES.plotAMARES(fid_parameters=out1, filename='simple_example.svg') # Save plot to SVG

Fitting Result for Example 31P MRS data

https://raw.githubusercontent.com/HawkMRS/pyAMARES/main/pyAMARES/examples/simple_example.svg https://github.com/HawkMRS/pyAMARES/blob/4f9ca4431c0d72e1b41fb2b434f72e53feb1657f/pyAMARES/examples/simple_example_html.jpeg

How to cite

If you use pyAMARES in your research, please consider citing the following ISMRM proceeding:

Jia Xu, Rolf F. Schulte, Baolian Yang, Michael Vaeggemose, Christoffer Laustsen, and Vincent A. Magnotta, Proc. Intl. Soc. Mag. Reson. Med. 32 (2024) 2996.

This citation is based on the current conference proceedings and is tentative. A journal paper is expected to be published in the future, and users will be encouraged to cite the formal publication once it is available.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pyAMARES-0.3.16.tar.gz (918.6 kB view details)

Uploaded Source

Built Distribution

pyAMARES-0.3.16-py3-none-any.whl (253.5 kB view details)

Uploaded Python 3

File details

Details for the file pyAMARES-0.3.16.tar.gz.

File metadata

  • Download URL: pyAMARES-0.3.16.tar.gz
  • Upload date:
  • Size: 918.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.8.13

File hashes

Hashes for pyAMARES-0.3.16.tar.gz
Algorithm Hash digest
SHA256 8cde5722bf08d5fc7ded6385b57ab6a4098045229b4c4a999b461a6355d3e709
MD5 c7eb7fd530dc163644c0568b61164c5e
BLAKE2b-256 5e60934bedb5b0cfcb4f682754f539affe6b3aee04a5f4309310003f4d8040b3

See more details on using hashes here.

File details

Details for the file pyAMARES-0.3.16-py3-none-any.whl.

File metadata

  • Download URL: pyAMARES-0.3.16-py3-none-any.whl
  • Upload date:
  • Size: 253.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.8.13

File hashes

Hashes for pyAMARES-0.3.16-py3-none-any.whl
Algorithm Hash digest
SHA256 b89f35fb892b435eaff41450f8d92de0029fe9b06fe4f84f76d870fe118e31b1
MD5 5fa2f7180dd6259815abacf2247a9090
BLAKE2b-256 bb4d4f766772f9cbbd3a0d985c23aa18166307bf627194a848cb6f5edb00fe61

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page