Issue with outputting bad averages for fMRS data using FSL-MRS


I’m currently analysing my fMRS data using FSL-MRS. For the analysis, I would like to create an output of the bad averages using fsl_mrs_proc unlike, which I can subsequently use to create a subject-specific design matrix (similar to fMRI analysis). However, when trying to run the following command (removed the overall folder structure to increase readability):

fsl_mrs_proc unlike --file ~/fMRS_metab.nii.gz --outputbad --output ~/derivatives/badaverages --generateReport --verbose

I receive this error:
Traceback (most recent call last):
File “/home/deboucherie/.conda/envs/fsl_mrs/bin/fsl_mrs_proc”, line 10, in
File “/home/deboucherie/.conda/envs/fsl_mrs/lib/python3.8/site-packages/fsl_mrs/scripts/”, line 428, in main
dataout = args.func(dataList, vars(args))
File “/home/deboucherie/.conda/envs/fsl_mrs/lib/python3.8/site-packages/fsl_mrs/scripts/”, line 746, in unlike
good, bad = preproc.shift_to_reference(,
TypeError: shift_to_reference() got an unexpected keyword argument ‘ppmlim’

Looking at the FSL-MRS documentation, it should be optional to provide a ppmlim for fsl_mrs_proc unlike, so I’m not sure how this error arises and how to work around it. I have also tried to provide a ppm window, but this also yields errors. Does anyone have experience with this error and/or ways to solve it?
Thanks in advance!


Hi @dboucherie,

On a quick inspection that looks like a bad bug from me, also lacking a test case to catch it. I’ll try to get a fix out today. For now you could make a small python script and call the function directly (using the API defined in the code. Something like:

from fsl_mrs.utils import mrs_io
from fsl_mrs.utils.preproc import nifti_mrs_proc as nproc
data = mrs_io.read_FID('/path/to/file.nii.gz')

good_avg, bad_avg = nproc.remove_unlike(data, ppmlim=None, sdlimit=1.96, niter=2, figure=False, report=None)'/path/to/good.nii.gz')'/path/to/bad.nii.gz')

@dboucherie This should now be fixed in 2.1.11

Amazing! Thank you @wclarke, will give it another go today

@wclarke No luck unfortunately - it seems the output folder specified is not identified for --outputbad maybe?

Ugh, that’s my fault for not writing a code test exploring all the command line options. I’ll make a fix for it tomorrow. Sorry

1 Like

@dboucherie V2.1.12 is now live and I hope is a final fix

@wclarke it works now, thank you! Do you maybe know if there is a way to additionally output the FID numbers of the bad averages?

There isn’t at the moment. Let me think of the best way to do that.


@dboucherie 2.1.13 now inserts the indices kept/removed as a NIfTI-MRS header key in the respective outputs.