PyAMARES, an Open-Source Python Library for Fitting Magnetic Resonance Spectroscopy Data
<p>Flowchart of pyAMARES. The workflow starts with importing prior knowledge from spreadsheets (1a) and loading the FID signal (1b) to establish initial values and constraints for fitting (3). If the initial parameters are far from the actual values, users can optionally employ Hankel singular value decomposition (HSVD) or Levenberg–Marquardt (LM) initializers to optimize these starting values (2a). The FID signal can be processed directly or optionally filtered using MPFIR to focus on specific spectral regions (2b). The non-linear least-squares minimization (4) using either trust region reflective (TRR) or LM, with either default or user-defined objective functions (1c). The fitting process can be iterative—the output can be fine-tuned and used as initial parameters for subsequent iterations (7). The Cramér–Rao lower bound (CRLB) estimation (5) integrates information from both the fitting results and the linear relationships between parameters (2b). These relationships include constraints like fixed amplitude ratios or chemical shift differences between multiplet peaks. The final output (6) includes fitted parameters, their uncertainties (CRLB), and signal-to-noise ratios. Solid arrows indicate the main workflow, while dashed arrows and boxes represent optional processing steps.</p> "> Figure 2
<p>PyAMARES plotting outputs. The default output figure from the <span class="html-italic">plotAMARES</span> function shows the fit of (<b>A</b>) an in vivo brain <sup>31</sup>P MRS spectrum acquired at 7T [<a href="#B34-diagnostics-14-02668" class="html-bibr">34</a>], (<b>B</b>) a voxel of hyperpolarized <sup>129</sup>Xe MRSI acquired from healthy porcine lungs at 3T, and (<b>D</b>) a voxel of in vivo brain <sup>2</sup>H 3D MRSI spectra acquired at 3T. In (<b>A</b>,<b>B</b>,<b>D</b>), the top panels display the original spectrum (gray), the fitted spectrum (red), and the residual (green dash), with individual fitted components shown in the bottom panels. Panel (<b>A</b>) is shown with phase correction applied (<span class="html-italic">ifphase = True</span> for the <span class="html-italic">plotAMARES</span> function) for display purposes, while (<b>B</b>,<b>D</b>) are not phased. The prior knowledge for the fitting (<b>A</b>) is in <a href="#diagnostics-14-02668-t001" class="html-table">Table 1</a>. The fitting results for <sup>31</sup>P MRS (<b>A</b>), including metabolite concentrations and their respective Cramér–Rao lower bounds (CRLBs), are presented in (<b>C</b>), where green grows indicate reliable fits with CRLB < 20% and red rows indicate less reliable fits. The fitting results of (<b>B</b>,<b>D</b>) are shown in <a href="#app1-diagnostics-14-02668" class="html-app">Figure S2</a>. Abbreviations: RBC, red blood cells; DHO, deuterated water; Glx, combined signals of glutamate and glutamine; PCr: phosphocreatine; PE: phosphoethenolamine; GPE: glycerophosphoethanolamine; GPC: glycerophosphocholine; Pi: inorganic phosphate; NAD, nicotinamide adenine dinucleotide; UDPG, uridine diphosphoglucose.</p> "> Figure 3
<p>Comparison of Monte Carlo simulated single-peak spectra fitting using OXSA and pyAMARES. (<b>A</b>) Ground truth for spectra simulation with fixed (red) and 3000 perturbed (various colors) parameters. Gaussian noise is omitted for clarity. (<b>B</b>) Relative bias of fitted amplitude compared to ground truth at different SNR levels. (<b>C</b>) Bias of fitted chemical shift compared to ground truth at different SNRs. (<b>D</b>) CRLB of fitted amplitude at each SNR, with the 20% threshold indicated by a green dashed line. In (<b>B</b>–<b>D</b>), blue and red represent pyAMARES and OXSA fitted results, respectively; solid patterns indicate results from spectra simulated with perturbed parameters, while hatched patterns show results from spectra simulated with fixed parameters.</p> "> Figure 4
<p>Comparison of Monte Carlo simulated in vivo human brain <sup>31</sup>P MRS spectra fitting at 7T using OXSA and different algorithms implemented in pyAMARES. (<b>A</b>) Ground truth for spectra simulation with slightly perturbed parameters. Gaussian noise is omitted for clarity. (<b>B</b>) Relative bias of peak amplitude quantification compared to ground truth. (<b>C</b>) CRLB of fitted amplitude for each peak, with the 20% threshold indicated by a green dashed line. (<b>D</b>) Pearson’s correlation coefficient (R) between OXSA and pyAMARES quantified amplitudes. Abbreviations: LM: Levenberg–Marquardt algorithm; TRR: trust region reflective algorithm; Init: Initializer using LM; PCr: phosphocreatine; PE: phosphoethenolamine; GPE: glycerophosphoethanolamine; GPC: glycerophosphocholine; Pi: inorganic phosphate; NAD, nicotinamide adenine dinucleotide; UDPG, uridine diphosphoglucose.</p> "> Figure 5
<p>Multiprocessing fitting of dynamic unlocalized <sup>31</sup>P MRS spectra of the tibialis anterior muscle at 3T using pyAMARES and comparison to OXSA. (<b>A</b>). Representative fitting results from pyAMARES (blue solid line) and OXSA (red dash line), with the differences between them shown as green dashed line. The metabolites of interest (PCr and Pi) are labeled. (<b>B</b>). Linear correlations between fitted amplitudes (a.u.), linewidths (Hz), and CRLBs obtained by pyAMARES and OXSA. Pearson’s R and the <span class="html-italic">p</span>-value for each dataset are shown in the plots. (<b>C</b>,<b>D</b>) Time courses of PCr (blue) and Pi (orange) amplitudes fitted by pyAMARES (<b>C</b>) and OXSA (<b>D</b>). The time points at which exercise and recovery start are indicated by dotted and dashed vertical lines, respectively. (<b>E</b>,<b>F</b>) Mono-exponential fitting of the PCr recovery kinetics using pyAMARES (<b>E</b>) and OXSA (<b>F</b>). The fitted equations are PC<sub>recover</sub> = 0.435 − 0.173 × e<sup>−time/44.171</sup>, R<sup>2</sup> = 0.914 for pyAMARES, and PC<sub>recover</sub> = 0.435 − 0.165 × e<sup>−time/42.523</sup>, R<sup>2</sup> = 0.928 for OXSA.</p> "> Figure 6
<p>Using AMARES for post-processing: Removal of metabolite residuals from a short echo time (TE) <sup>1</sup>H MR spectrum at 9.4T. (<b>A</b>) Upper panel: Fitting of residual metabolites (red) and the resulting macromolecule (MM) spectrum after subtraction of residual metabolite signals from the original spectrum (green). Lower panel: AMARES modeling of residual metabolite signals. (<b>B</b>) Comparison of metabolite-free MM spectra obtained by jMRUI (red) and pyAMARES (blue), showing identical results as confirmed by the flat difference spectrum (black).</p> ">
Abstract
:1. Introduction
2. Materials and Methods
2.1. Software Design
2.1.1. Workflow
2.1.2. Prior Knowledge Spreadsheet
- Prior knowledge Dataset Format
- Setting J-coupling Splitting for Multiplets
- Spreadsheets for Fitting Results
2.2. Validation and Testing
2.3. X-Nuclei MRS Acquisition
2.3.1. Deuterium Metabolic Imaging
2.3.2. Xenon Imaging
2.3.3. Dynamic 31P MRS
3. Results
3.1. Examples of In Vivo X-Nuclei (31P, 129Xe, and 2H) MRS Fitting
3.2. Validation of pyAMARES Using Monte-Carlo Simulation
3.3. Multiprocessing Fitting of Dynamic 31P MRS Spectra of Muscle at 3T
3.4. Versatile MRS Quantification with pyAMARES
4. Discussion
4.1. Validation and Benchmark of pyAMARES
4.2. A Flexible, User-Friendly, and Versatile MRS Fitting Tool
4.3. Enhancing Reproducibility in MR Spectroscopy Research
4.4. Limitations
5. Conclusions
Supplementary Materials
Author Contributions
Funding
Institutional Review Board Statement
Informed Consent Statement
Data Availability Statement
Acknowledgments
Conflicts of Interest
References
- Poullet, J.B.; Sima, D.M.; Van Huffel, S. MRS signal quantitation: A review of time- and frequency-domain methods. J. Magn. Reson. 2008, 195, 134–144. [Google Scholar] [CrossRef] [PubMed]
- Near, J.; Harris, A.D.; Juchem, C.; Kreis, R.; Marjanska, M.; Oz, G.; Slotboom, J.; Wilson, M.; Gasparovic, C. Preprocessing, analysis and quantification in single-voxel magnetic resonance spectroscopy: Experts’ consensus recommendations. NMR Biomed. 2021, 34, e4257. [Google Scholar] [CrossRef]
- Chen, X.; Li, J.; Chen, D.; Zhou, Y.; Tu, Z.; Lin, M.; Kang, T.; Lin, J.; Gong, T.; Zhu, L.; et al. CloudBrain-MRS: An intelligent cloud computing platform for in vivo magnetic resonance spectroscopy preprocessing, quantification, and analysis. J. Magn. Reson. 2024, 358, 107601. [Google Scholar] [CrossRef]
- Vanhamme, L.; van den Boogaart, A.; Van Huffel, S. Improved method for accurate and efficient quantification of MRS data with use of prior knowledge. J. Magn. Reson. 1997, 129, 35–43. [Google Scholar] [CrossRef] [PubMed]
- Purvis, L.A.B.; Clarke, W.T.; Biasiolli, L.; Valkovic, L.; Robson, M.D.; Rodgers, C.T. OXSA: An open-source magnetic resonance spectroscopy analysis toolbox in MATLAB. PLoS ONE 2017, 12, e0185356. [Google Scholar] [CrossRef]
- Vanhamme, L.; Sundin, T.; Van Hecke, P.; Van Huffel, S.; Pintelon, R. Frequency-selective quantification of biomedical magnetic resonance spectroscopy data. J. Magn. Reson. 2000, 143, 1–16. [Google Scholar] [CrossRef] [PubMed]
- Provencher, S.W. Automatic quantitation of localized in vivo 1H spectra with LCModel. NMR Biomed. 2001, 14, 260–264. [Google Scholar] [CrossRef]
- Kanowski, M.; Kaufmann, J.; Braun, J.; Bernarding, J.; Tempelmann, C. Quantitation of simulated short echo time 1H human brain spectra by LCModel and AMARES. Magn. Reson. Med. 2004, 51, 904–912. [Google Scholar] [CrossRef]
- Weis, J.; Johansson, L.; Ortiz-Nieto, F.; Ahlstrom, H. Assessment of lipids in skeletal muscle by LCModel and AMARES. J. Magn. Reson. Imaging 2009, 30, 1124–1129. [Google Scholar] [CrossRef]
- Janich, M.A.; Menzel, M.I.; Wiesinger, F.; Weidl, E.; Khegai, O.; Ardenkjaer-Larsen, J.H.; Glaser, S.J.; Haase, A.; Schulte, R.F.; Schwaiger, M. Effects of pyruvate dose on in vivo metabolism and quantification of hyperpolarized (1)(3)C spectra. NMR Biomed. 2012, 25, 142–151. [Google Scholar] [CrossRef]
- Lanz, B.; Duarte, J.M.; Kunz, N.; Mlynarik, V.; Gruetter, R.; Cudalbu, C. Which prior knowledge? Quantification of in vivo brain 13C MR spectra following 13C glucose infusion using AMARES. Magn. Reson. Med. 2013, 69, 1512–1522. [Google Scholar] [CrossRef] [PubMed]
- Mosconi, E.; Sima, D.M.; Osorio Garcia, M.I.; Fontanella, M.; Fiorini, S.; Van Huffel, S.; Marzola, P. Different quantification algorithms may lead to different results: A comparison using proton MRS lipid signals. NMR Biomed. 2014, 27, 431–443. [Google Scholar] [CrossRef] [PubMed]
- Deelchand, D.K.; Nguyen, T.M.; Zhu, X.H.; Mochel, F.; Henry, P.G. Quantification of in vivo (3)(1)P NMR brain spectra using LCModel. NMR Biomed. 2015, 28, 633–641. [Google Scholar] [CrossRef] [PubMed]
- Craven, A.R.; Bhattacharyya, P.K.; Clarke, W.T.; Dydak, U.; Edden, R.A.E.; Ersland, L.; Mandal, P.K.; Mikkelsen, M.; Murdoch, J.B.; Near, J.; et al. Comparison of seven modelling algorithms for gamma-aminobutyric acid-edited proton magnetic resonance spectroscopy. NMR Biomed. 2022, 35, e4702. [Google Scholar] [CrossRef]
- Christensen, N.V.; Vaeggemose, M.; Bogh, N.; Hansen, E.S.S.; Olesen, J.L.; Kim, Y.; Vigneron, D.B.; Gordon, J.W.; Jespersen, S.N.; Laustsen, C. A user independent denoising method for x-nuclei MRI and MRS. Magn. Reson. Med. 2023, 90, 2539–2556. [Google Scholar] [CrossRef]
- Vaeggemose, M.; Schulte, R.F.; Laustsen, C. Comprehensive Literature Review of Hyperpolarized Carbon-13 MRI: The Road to Clinical Application. Metabolites 2021, 11, 219. [Google Scholar] [CrossRef]
- Simicic, D.; Rackayova, V.; Xin, L.; Tkac, I.; Borbath, T.; Starcuk, Z., Jr.; Starcukova, J.; Lanz, B.; Cudalbu, C. In vivo macromolecule signals in rat brain (1) H-MR spectra at 9.4T: Parametrization, spline baseline estimation, and T(2) relaxation times. Magn. Reson. Med. 2021, 86, 2384–2401. [Google Scholar] [CrossRef]
- Povazan, M.; Strasser, B.; Hangel, G.; Heckova, E.; Gruber, S.; Trattnig, S.; Bogner, W. Simultaneous mapping of metabolites and individual macromolecular components via ultra-short acquisition delay (1) H MRSI in the brain at 7T. Magn. Reson. Med. 2018, 79, 1231–1240. [Google Scholar] [CrossRef]
- Cudalbu, C.; Behar, K.L.; Bhattacharyya, P.K.; Bogner, W.; Borbath, T.; de Graaf, R.A.; Gruetter, R.; Henning, A.; Juchem, C.; Kreis, R.; et al. Contribution of macromolecules to brain (1) H MR spectra: Experts’ consensus recommendations. NMR Biomed. 2021, 34, e4393. [Google Scholar] [CrossRef]
- Zhan, H.; Chen, Y.; Cui, Y.; Zeng, Y.; Feng, X.; Tan, C.; Huang, C.; Lin, E.; Huang, Y.; Chen, Z. Pure-Shift-Based Proton Magnetic Resonance Spectroscopy for High-Resolution Studies of Biological Samples. Int. J. Mol. Sci. 2024, 25, 4698. [Google Scholar] [CrossRef]
- Stefan, D.; Di Cesare, F.; Andrasescu, A.; Popa, E.; Lazariev, A.; Vescovo, E.; Strbak, O.; Williams, S.; Starcuk, Z.; Cabanas, M.; et al. Quantitation of magnetic resonance spectroscopy signals: The jMRUI software package. Meas. Sci. Technol. 2009, 20, 104035. [Google Scholar] [CrossRef]
- Poullet, J.B. Quantification and Classification of Magnetic Resonance Spectroscopic Data for Brain Tumor Diagnosis. Ph.D. Thesis, Katholic University of Leuven, Leuven, Belgium, 2008. [Google Scholar]
- Clarke, W.T.; Stagg, C.J.; Jbabdi, S. FSL-MRS: An end-to-end spectroscopy analysis package. Magn. Reson. Med. 2021, 85, 2950–2964. [Google Scholar] [CrossRef] [PubMed]
- Soher, B.J.; Semanchuk, P.; Todd, D.; Ji, X.; Deelchand, D.; Joers, J.; Oz, G.; Young, K. Vespa: Integrated applications for RF pulse design, spectral simulation and MRS data analysis. Magn. Reson. Med. 2023, 90, 823–838. [Google Scholar] [CrossRef]
- Rowland, B. SUSPECT. Available online: https://github.com/openmrslab/suspect (accessed on 6 October 2024).
- Helmus, J.J.; Jaroniec, C.P. Nmrglue: An open source Python package for the analysis of multidimensional NMR data. J. Biomol. NMR 2013, 55, 355–367. [Google Scholar] [CrossRef]
- Cavassila, S.; Deval, S.; Huegen, C.; van Ormondt, D.; Graveron-Demilly, D. Cramer-Rao bounds: An evaluation tool for quantitation. NMR Biomed. 2001, 14, 278–283. [Google Scholar] [CrossRef] [PubMed]
- Ren, J.; Sherry, A.D.; Malloy, C.R. (31)P-MRS of healthy human brain: ATP synthesis, metabolite concentrations, pH, and T1 relaxation times. NMR Biomed. 2015, 28, 1455–1462. [Google Scholar] [CrossRef]
- Kreis, R.; Boer, V.; Choi, I.Y.; Cudalbu, C.; de Graaf, R.A.; Gasparovic, C.; Heerschap, A.; Krssak, M.; Lanz, B.; Maudsley, A.A.; et al. Terminology and concepts for the characterization of in vivo MR spectroscopy methods and MR spectra: Background and experts’ consensus recommendations. NMR Biomed. 2020, 34, e4347. [Google Scholar] [CrossRef]
- Bogh, N.; Vaeggemose, M.; Schulte, R.F.; Hansen, E.S.S.; Laustsen, C. Repeatability of deuterium metabolic imaging of healthy volunteers at 3 T. Eur. Radiol. Exp. 2024, 8, 44. [Google Scholar] [CrossRef]
- Collier, G.J.; Schulte, R.F.; Rao, M.; Norquay, G.; Ball, J.; Wild, J.M. Imaging gas-exchange lung function and brain tissue uptake of hyperpolarized (129) Xe using sampling density-weighted MRSI. Magn. Reson. Med. 2023, 89, 2217–2226. [Google Scholar] [CrossRef]
- McKinney, W. Data Structures for Statistical Computing in Python. In Proceedings of the 9th Python in Science Conference, Austin, TX, USA, 28 June–3 July 2010; pp. 56–61. [Google Scholar]
- Bier, E.A.; Robertson, S.H.; Schrank, G.M.; Rackley, C.; Mammarappallil, J.G.; Rajagopal, S.; McAdams, H.P.; Driehuys, B. A protocol for quantifying cardiogenic oscillations in dynamic (129) Xe gas exchange spectroscopy: The effects of idiopathic pulmonary fibrosis. NMR Biomed. 2019, 32, e4029. [Google Scholar] [CrossRef]
- Schultz, J.L.; Brinker, A.N.; Xu, J.; Ernst, S.E.; Tayyari, F.; Rauckhorst, A.J.; Liu, L.; Uc, E.Y.; Taylor, E.B.; Simmering, J.E.; et al. A pilot to assess target engagement of terazosin in Parkinson’s disease. Parkinsonism Relat. Disord. 2022, 94, 79–83. [Google Scholar] [CrossRef]
- Newville, M.; Stensitzki, T.; Allen, D.B.; Rawlik, M.; Ingargiola, A.; Nelson, A. Lmfit: Non-Linear Least-Square Minimization and Curve-Fitting for Python; Astrophysics Source Code Library: Houghton, MI, USA, 2016; p. ascl:1606.1014. [Google Scholar]
- Mascalchi, M.; Brugnoli, R.; Guerrini, L.; Belli, G.; Nistri, M.; Politi, L.S.; Gavazzi, C.; Lolli, F.; Argenti, G.; Villari, N. Single-voxel long TE 1H-MR spectroscopy of the normal brainstem and cerebellum. J. Magn. Reson. Imaging 2002, 16, 532–537. [Google Scholar] [CrossRef] [PubMed]
- Simpson, R.; Devenyi, G.A.; Jezzard, P.; Hennessy, T.J.; Near, J. Advanced processing and simulation of MRS data using the FID appliance (FID-A)-An open source, MATLAB-based toolkit. Magn. Reson. Med. 2017, 77, 23–33. [Google Scholar] [CrossRef] [PubMed]
- Deelchand, D. MRspa: Magnetic Resonance Signal Processing and Analysis. Available online: https://www.cmrr.umn.edu/downloads/mrspa/ (accessed on 6 October 2024).
- Oeltzschner, G.; Zollner, H.J.; Hui, S.C.N.; Mikkelsen, M.; Saleh, M.G.; Tapper, S.; Edden, R.A.E. Osprey: Open-source processing, reconstruction & estimation of magnetic resonance spectroscopy data. J. Neurosci. Methods 2020, 343, 108827. [Google Scholar] [CrossRef]
- Reynolds, G.; Wilson, M.; Peet, A.; Arvanitis, T.N. An algorithm for the automated quantitation of metabolites in in vitro NMR signals. Magn. Reson. Med. 2006, 56, 1211–1219. [Google Scholar] [CrossRef] [PubMed]
A | B | C | D | E | F | |
---|---|---|---|---|---|---|
1 | # Ren et al. [28] | |||||
2 | Index | BATP | BATP2 | BATP3 | AATP | AATP2 |
3 | Initial Values | |||||
4 | amplitude | 1.41 | BATP/2 | BATP/2 | 1.545 | AATP |
5 | chemicalshift | −16.15 | BATP-15Hz | BATP+15Hz | −7.49 | AATP-16Hz |
6 | linewidth | 58.12 | BATP | BATP | 32.28 | AATP |
7 | phase | 0 | BATP | BATP | BATP | BATP |
8 | g | 0 | 0 | 0 | 0 | 0 |
9 | Bounds | |||||
10 | amplitude | (0, | (0, | (0, | (0, | (0, |
11 | chemicalshift | (−16.30, −16.00) | (−16.30, −16.00) | (−16.30, −16.00) | (−7.72, −7.42) | (−7.72, −7.42) |
12 | linewidth | (54.335, 61.911) | (54.335, 61.911) | (54.335, 61.911) | (31.226, 33.327) | (31.226, 33.327) |
13 | phase | (−180, 180) | (−180, 180) | (−180, 180) | (−180, 180) | (−180, 180) |
14 | g | (0, 1) | (0, 1) | (0, 1) | (0, 1) | (0, 1) |
15 | # Use the same phase for all peaks |
Disclaimer/Publisher’s Note: The statements, opinions and data contained in all publications are solely those of the individual author(s) and contributor(s) and not of MDPI and/or the editor(s). MDPI and/or the editor(s) disclaim responsibility for any injury to people or property resulting from any ideas, methods, instructions or products referred to in the content. |
© 2024 by the authors. Licensee MDPI, Basel, Switzerland. This article is an open access article distributed under the terms and conditions of the Creative Commons Attribution (CC BY) license (https://creativecommons.org/licenses/by/4.0/).
Share and Cite
Xu, J.; Vaeggemose, M.; Schulte, R.F.; Yang, B.; Lee, C.-Y.; Laustsen, C.; Magnotta, V.A. PyAMARES, an Open-Source Python Library for Fitting Magnetic Resonance Spectroscopy Data. Diagnostics 2024, 14, 2668. https://doi.org/10.3390/diagnostics14232668
Xu J, Vaeggemose M, Schulte RF, Yang B, Lee C-Y, Laustsen C, Magnotta VA. PyAMARES, an Open-Source Python Library for Fitting Magnetic Resonance Spectroscopy Data. Diagnostics. 2024; 14(23):2668. https://doi.org/10.3390/diagnostics14232668
Chicago/Turabian StyleXu, Jia, Michael Vaeggemose, Rolf F. Schulte, Baolian Yang, Chu-Yu Lee, Christoffer Laustsen, and Vincent A. Magnotta. 2024. "PyAMARES, an Open-Source Python Library for Fitting Magnetic Resonance Spectroscopy Data" Diagnostics 14, no. 23: 2668. https://doi.org/10.3390/diagnostics14232668
APA StyleXu, J., Vaeggemose, M., Schulte, R. F., Yang, B., Lee, C. -Y., Laustsen, C., & Magnotta, V. A. (2024). PyAMARES, an Open-Source Python Library for Fitting Magnetic Resonance Spectroscopy Data. Diagnostics, 14(23), 2668. https://doi.org/10.3390/diagnostics14232668