Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

MR Spectroscopy with Osprey

Run this notebook

Analyzing MR Spectra from the Human Brain using Single Voxel Spectroscopy (SVS)

Date: 24 Sep 2025

License:

MIT License

Note: If this notebook uses neuroimaging tools from Neurocontainers, those tools retain their original licenses. Please see Neurodesk citation guidelines for details.

This notebook was prepared for an audience of clinicians at the 2025 PACTALS (Pan-Asian consortium of Treatment and Research in ALS) conference in Melbourne (link)

📘 How to Use This Notebook

This notebook is an interactive document. It mixes short explanations (like this box) with computer code that runs automatically.

⚡ The basics

  • 👆 Click on a cell (the boxes with text or code)

  • ▶️ Run it by pressing Command + Enter (Mac) or Control + Enter (Windows/Linux)

  • ⏭️ Or use the play button in the toolbar above

  • ⬇️ Move to the next cell and repeat

🧩 What happens when you run a cell?

The computer will either:

  • ✏️ Show you some text or figures

  • 🖥️ Run an analysis step in the background

  • 📂 Save results into a folder

MR Spectroscopy (MRS)

  • Quantification of concentration of various metabolites (chemical compounds)

  • Each metabolite has a distinct spectral (frequency-domain) signature based on its chemical structure

MRS spectrum overview

Introduction

This example demonstrates the processing of MR spectra acquired from the human motor cortex using Osprey, a standalone tool for processing and quantification of magnetic resonance spectroscopy (MRS) data.

Citation and Resources:

Tools included in this workflow

Osprey:

  • Oeltzschner, G., Zöllner, H. J., Hui, S. C. N., Mikkelsen, M., Saleh, M. G., Tapper, S., & Edden, R. A. E. (2020). Osprey: Open-source processing, reconstruction & estimation of magnetic resonance spectroscopy data. Journal of Neuroscience Methods, 343, 108827. Oeltzschner et al. (2020)

  • Osprey documentation

Python:

Dataset

  • Collected at UQ as part of the BeLong study

  • Data: Shaw, T. & Toth, M. PACTALS-data. OSF 3a2ws, mirrored at neurodeskorg/pactals-osprey-example. Provided for educational use in the Neurodesk example notebooks only; see the terms of use.

  • T1 weighted MP2RAGE at 3T (healthy control)

  • SEMI-LASER MRS at 3T (healthy control)

    • Oz, G., & Tkáč, I. (2011). Short-echo, single-shot, full-intensity proton magnetic resonance spectroscopy for neurochemical profiling at 4 T: validation in the cerebellum and brainstem. Magn Reson Med, 65(4), 901-910. Öz & Tkáč (2010)

    • Deelchand, D. K., Berrington, A., Noeske, R., Joers, J. M., Arani, A., Gillen, J., Schär, M., Nielsen, J. F., Peltier, S., Seraji-Bozorgzad, N., Landheer, K., Juchem, C., Soher, B. J., Noll, D. C., Kantarci, K., Ratai, E. M., Mareci, T. H., Barker, P. B., & Öz, G. (2021). Across-vendor standardization of semi-LASER for single-voxel MRS at 3T. NMR Biomed, 34(5), e4218. Deelchand et al. (2019)

    • The basis file used in this example is a placeholder, the SLaser basis set used in the acquisition (Eftekhari, Z., Shaw, T., Deelchand, D., Marjańska, M., Bogner, W., & Barth, M. (2025). Reliability and Reproducibility of Metabolite Quantification Using 1H MRS in the Human Brain at 3 T and 7 T. NMR in biomedicine, 38, e70087. Eftekhari et al. (2025)) is not shareable at the moment.

Osprey input

DescriptionFilename
Raw metabolite datamrs/...svs_slaser_dkd_ul.dat
Water reference datamrs/...svs_slaser_dkd_ul_wref.dat
T1-weighted anatomical imageanat/...acq-MP2RAGE_T1w.nii
JSON file configuring the pipeline. See Osprey’s documentation for more detailsosprey-job.json
A BASIS file containing simulated model spectra for known metabolites. Used by LCModel to fit data.set.BASIS

Osprey output

DescriptionFilename
MRS voxel aligned with the anatomyosprey-output/VoxelMasks/...svs_slaser_dkd_ul_space-scanner_mask.nii
MRS voxel segmentation masks (GM, WM, CSF)osprey-output/SegMaps/...svs_slaser_dkd_ul_space-scanner_Voxel-1_label-CSF.nii
Results of spectral fitting (from LCmodel)osprey-output/LCMOutput/
Summary of results from different steps of the pipeline. It includes some QC metricsosprey-output/Reports/sub-002-report.html
Tables with concentration values for metabolites using different referencesosprey-output/QuantifyResults/

Load software tools and import python libraries

['osprey/2.9.0']

Set up Osprey Job configuration

  1. Download and prepare data

  2. Set up paths to the relevant MRS/MRI files

  3. Set up the configuration JSON file

  4. Check that all specified paths exist

NOTE: For a more detailed explanation of all the configuration options see Osprey’s documentation

Data archive already exists, skipping download
Extracting data
✅  '/home/jovyan/workspace/books/examples/spectroscopy/data_osprey'
✅  '/home/jovyan/workspace/books/examples/spectroscopy/osprey-output'
✅  '/home/jovyan/workspace/books/examples/spectroscopy/data_osprey/basis_siemens_slaser30.mat'
✅  '/home/jovyan/workspace/books/examples/spectroscopy/osprey-job.json'
✅  '/home/jovyan/workspace/books/examples/spectroscopy/data_osprey/sub-002/ses-01/mrs/meas_MID00103_FID130220_svs_slaser_dkd_ul.dat'
✅  '/home/jovyan/workspace/books/examples/spectroscopy/data_osprey/sub-002/ses-01/mrs/meas_MID00104_FID130221_svs_slaser_dkd_ul_wref.dat'
✅  '/home/jovyan/workspace/books/examples/spectroscopy/data_osprey/sub-002/ses-01/anat/sub-002_ses-01_acq-MP2RAGE_desc-defaced_T1w.nii'

Run Osprey processing

The following command runs the Oprey CLI software with specifications from the job file defined above.

------------------------------------------
Setting up environment variables
---
LD_LIBRARY_PATH is .:/opt/MCR/R2023a//runtime/glnxa64:/opt/MCR/R2023a//bin/glnxa64:/opt/MCR/R2023a//sys/os/glnxa64:/opt/MCR/R2023a//sys/opengl/lib/glnxa64
Spectral fitting parameters will not be saved (default). Please indicate otherwise in the csv-file or the GUI 
Continue with loading new job, overwriting existing job.
/home/jovyan/workspace/books/examples/spectroscopy/osprey-job.json
Timestamp October 07, 2026 22:22:51 Osprey 2.9.0
Timestamp October 07, 2026 22:22:51 Osprey 2.9.0  OspreyLoad
Loading raw data from dataset   1 out of   1 total datasets...
Software version: VD (!?)
Reader version: 1496740353 (UTC: 06-Jun-2017 09:12:33)
Scan 1/2, read all mdhs:
    35.3 MB read in    0 s
Scan 2/2, read all mdhs:
    83.9 MB read in    0 s

ans =

     0

multi RAID file detected.
Software version: VD (!?)
Reader version: 1496740353 (UTC: 06-Jun-2017 09:12:33)
Scan 1/2, read all mdhs:
    35.3 MB read in    0 s
Scan 2/2, read all mdhs:
    19.0 MB read in    0 s

ans =

     0

multi RAID file detected.

... done.
 Elapsed time 9.669890 seconds
Timestamp October 07, 2026 22:23:01 Osprey 2.9.0  OspreyProcess
Processing data from dataset   1 out of   1 total datasets...

... done.
 Elapsed time 32.932902 seconds
Writing table to file = /home/jovyan/workspace/books/examples/spectroscopy/osprey-output/QM_processed_spectra.tsv
Writing table to file = /home/jovyan/workspace/books/examples/spectroscopy/osprey-output/QM_processed_spectra.json
Timestamp October 07, 2026 22:23:35 Osprey 2.9.0  OspreyFit
Fitting metabolite spectra from dataset   1 out of   1 total datasets...

... done.
 Elapsed time 3.882328 seconds

... done.
 Elapsed time 3.882328 seconds
Writing table to file = /home/jovyan/workspace/books/examples/spectroscopy/osprey-output/QM_processed_spectra.tsv
Writing table to file = /home/jovyan/workspace/books/examples/spectroscopy/osprey-output/QM_processed_spectra.json
Timestamp October 07, 2026 22:23:45 Osprey 2.9.0  OspreyCoreg
Coregistering voxel from dataset   1 out of   1 total datasets...

... done.
 Elapsed time 2.473600 seconds
Timestamp October 07, 2026 22:23:47 Osprey 2.9.0  OspreySeg

Segmenting structural image from dataset   1 out of   1 total datasets...


------------------------------------------------------------------------
07-Oct-2026 22:23:58 - Running job #1
------------------------------------------------------------------------
07-Oct-2026 22:23:59 - Running 'Image Calculator'

SPM12: spm_imcalc (v6961)                          22:23:59 - 07/10/2026
========================================================================
ImCalc Image: /home/jovyan/workspace/books/examples/spectroscopy/osprey-output/VoxelMasks/MID00103_FID130220_svs_slaser_dkd_ul_space-spm152_mask_VoxelOverlap.nii
07-Oct-2026 22:23:59 - Done    'Image Calculator'
07-Oct-2026 22:23:59 - Done


... done.
 Elapsed time 6.572647 seconds
Writing table to file = /home/jovyan/workspace/books/examples/spectroscopy/osprey-output/SegMaps/TissueFractions_Voxel_1.tsv
Writing table to file = /home/jovyan/workspace/books/examples/spectroscopy/osprey-output/SegMaps/TissueFractions_Voxel_1.json
Timestamp October 07, 2026 22:24:00 Osprey 2.9.0  OspreyQuantify

Quantifying dataset   1 out of   1 total datasets...

... done.
 Elapsed time 0.042244 seconds
Writing table to file = /home/jovyan/workspace/books/examples/spectroscopy/osprey-output/QuantifyResults/A_amplMets_Voxel_1_Basis_1.tsv
Writing table to file = /home/jovyan/workspace/books/examples/spectroscopy/osprey-output/QuantifyResults/A_amplMets_Voxel_1_Basis_1.json
Writing table to file = /home/jovyan/workspace/books/examples/spectroscopy/osprey-output/QuantifyResults/A_tCr_Voxel_1_Basis_1.tsv
Writing table to file = /home/jovyan/workspace/books/examples/spectroscopy/osprey-output/QuantifyResults/A_tCr_Voxel_1_Basis_1.json
Writing table to file = /home/jovyan/workspace/books/examples/spectroscopy/osprey-output/QuantifyResults/A_rawWaterScaled_Voxel_1_Basis_1.tsv
Writing table to file = /home/jovyan/workspace/books/examples/spectroscopy/osprey-output/QuantifyResults/A_rawWaterScaled_Voxel_1_Basis_1.json
Writing table to file = /home/jovyan/workspace/books/examples/spectroscopy/osprey-output/QuantifyResults/A_CSFWaterScaled_Voxel_1_Basis_1.tsv
Writing table to file = /home/jovyan/workspace/books/examples/spectroscopy/osprey-output/QuantifyResults/A_CSFWaterScaled_Voxel_1_Basis_1.json
Writing table to file = /home/jovyan/workspace/books/examples/spectroscopy/osprey-output/QuantifyResults/A_TissCorrWaterScaled_Voxel_1_Basis_1.tsv
Writing table to file = /home/jovyan/workspace/books/examples/spectroscopy/osprey-output/QuantifyResults/A_TissCorrWaterScaled_Voxel_1_Basis_1.json
Writing table to file = /home/jovyan/workspace/books/examples/spectroscopy/osprey-output/QuantifyResults/A_AlphaCorrWaterScaled_Voxel_1_Basis_1.tsv
Writing table to file = /home/jovyan/workspace/books/examples/spectroscopy/osprey-output/QuantifyResults/A_AlphaCorrWaterScaled_Voxel_1_Basis_1.json
Writing table to file = /home/jovyan/workspace/books/examples/spectroscopy/osprey-output/QuantifyResults/A_AlphaCorrWaterScaledGroupNormed_Voxel_1_Basis_1.tsv
Writing table to file = /home/jovyan/workspace/books/examples/spectroscopy/osprey-output/QuantifyResults/A_AlphaCorrWaterScaledGroupNormed_Voxel_1_Basis_1.json
Writing table to file = /home/jovyan/workspace/books/examples/spectroscopy/osprey-output/QuantifyResults/A_CRLB_Voxel_1_Basis_1.tsv
Writing table to file = /home/jovyan/workspace/books/examples/spectroscopy/osprey-output/QuantifyResults/A_CRLB_Voxel_1_Basis_1.json
Writing table to file = /home/jovyan/workspace/books/examples/spectroscopy/osprey-output/QuantifyResults/A_h2oarea_Voxel_1_Basis_1.tsv
Writing table to file = /home/jovyan/workspace/books/examples/spectroscopy/osprey-output/QuantifyResults/A_h2oarea_Voxel_1_Basis_1.json
Timestamp October 07, 2026 22:24:01 Osprey 2.9.0  OspreyOverview

Gathering spectra from subspectrum 1 out of 2 total subspectra..Gathering spectra from subspectrum 1 out of 2 total subspectra..Gathering spectra from subspectrum 2 out of 2 total subspectra...
... done.
Gathering fit models from fit 1 out of 1 total fits.Gathering fit models from fit 1 out of 1 total fits...
... done.
Interpolating fit models from fit 1 out of 1 total fits.Interpolating fit models from fit 1 out of 1 total fits...
... done.

Scaling data from dataset 1 out of 1 total datasets.Scaling data from dataset 1 out of 1 total datasets.Scaling data from dataset 1 out of 1 total datasets...
... done.
Writing table to file = /home/jovyan/workspace/books/examples/spectroscopy/osprey-output/subject_names_and_excluded.tsv
Writing table to file = /home/jovyan/workspace/books/examples/spectroscopy/osprey-output/subject_names_and_excluded.json
... done.
 Elapsed time 0.088403 seconds
Runtime Breakdown................
OspreyLoad runtime: 9.669890 seconds
OspreyProcess runtime: 32.932902 seconds
OspreyFit runtime: 3.882328 seconds
	OspreyFit metab runtime: 3.882328 seconds
OspreyCoreg runtime: 2.473600 seconds
OspreySeg runtime: 6.572647 seconds
OspreyOverview runtime: 0.088403 seconds
Full Osprey runtime: 55.662014 seconds

Results

T1s with the MRS voxel aligned

  • Osprey performs alignment with T1

  • Osprey also performs segmentation to determine the proportion of tissue types within the voxel (for WM and CSF correction)

[HF-patcher] meas: path → url
[HF-patcher] meas: path → url
[HF-patcher] meas: path → url
Loading...
<IPython.core.display.Image object>

Spectral modelling

  • Osprey runs LCModel for spectral fitting

<PIL.JpegImagePlugin.JpegImageFile image mode=RGB size=1181x886>
Loading...
<IPython.core.display.Image object>

Metabolite concetrations

  • Osprey calculates metabolite concentrations relative to different references

<Figure size 2000x500 with 1 Axes>
<Figure size 2000x500 with 1 Axes>

Dependencies in Jupyter/Python

  • Using the package watermark to document system environment and software versions used in this notebook, alongside the Neurodesktop version extracted from the JUPYTER_IMAGE or NEURODESKTOP_VERSION environment variables.

Last updated: 2026-10-07T22:24:12.871443+00:00

Python implementation: CPython
Python version       : 3.13.15
IPython version      : 9.17.1

Compiler    : GCC 15.3.0
OS          : Linux
Release     : 6.8.0-111-generic
Machine     : x86_64
Processor   : x86_64
CPU cores   : 16
Architecture: 64bit

IPython   : 9.17.1
PIL       : 12.3.0
ipyniivue : 2.4.4
ipywidgets: 8.1.9
json      : 2.0.9
matplotlib: 3.11.2
nibabel   : 5.4.2
numpy     : 2.5.3
pandas    : 3.0.6

Neurodesktop version: 2026-10-05
References
  1. Oeltzschner, G., Zöllner, H. J., Hui, S. C. N., Mikkelsen, M., Saleh, M. G., Tapper, S., & Edden, R. A. E. (2020). Osprey: Open-source processing, reconstruction & estimation of magnetic resonance spectroscopy data. Journal of Neuroscience Methods, 343, 108827. 10.1016/j.jneumeth.2020.108827
  2. Öz, G., & Tkáč, I. (2010). Short‐echo, single‐shot, full‐intensity proton magnetic resonance spectroscopy for neurochemical profiling at 4 T: Validation in the cerebellum and brainstem. Magnetic Resonance in Medicine, 65(4), 901–910. 10.1002/mrm.22708
  3. Deelchand, D. K., Berrington, A., Noeske, R., Joers, J. M., Arani, A., Gillen, J., Schär, M., Nielsen, J., Peltier, S., Seraji‐Bozorgzad, N., Landheer, K., Juchem, C., Soher, B. J., Noll, D. C., Kantarci, K., Ratai, E. M., Mareci, T. H., Barker, P. B., & Öz, G. (2019). Across‐vendor standardization of semi‐LASER for single‐voxel MRS at 3T. NMR in Biomedicine, 34(5). 10.1002/nbm.4218
  4. Eftekhari, Z., Shaw, T. B., Deelchand, D. K., Marjańska, M., Bogner, W., & Barth, M. (2025). Reliability and Reproducibility of Metabolite Quantification Using                    1                    H MRS in the Human Brain at 3 T and 7 T. NMR in Biomedicine, 38(8). 10.1002/nbm.70087