In fsl_mrs, how export the spectrum in ppm?

Hi MRS experts,

I am learning to use FSL_MRS now. We are fitting the spectrum of a phantom consisting of PVP molecules. The preprocessing works well so far and we got a well-shaped water reference peak and some PVP peaks. How could export the spectrum for manual Lorentzian fitting? Thanks.


Hi @ruifengd,

Sorry, I’m not 100% certain what you mean. Do you want to load the data from the processed NIfTI-MRS file?

In python you can use FSL’s methods

from fsl_mrs.utils import mrs_io
data = mrsi_io.read_FID('path/to/processed.nii.gz')

Then you can access the data using data[:]. For other languages see our minimal examples.


After loading, data[:] gives the time-domain signals. I want to export the spectrum with x-axis in units of ppm.

You can take the FFT. There are two ways you could go about this in FSL

from fsl_mrs.utils.misc import FIDToSpec
spectra = FIDToSpec(data[:], axis=3)
mrs_list = data.mrs()
first_spectrum = mrs_list[0].get_spectrum()
ppm_axis = mrs_list[0].getAxes()

Thank you so much for sharing this. I’m new to FSL-MRS and I like drawing my own plots. This piece of information was exactly what I was looking for :smiling_face:

@wclarke, this might a very small ask but would it be possible to add “How to access data in Nifti-MRS object into FSL-MRS documentation”? Thanks again! Have a lovely day!

Hande Halilibrahimoglu