Cannot convert .RAW files using fsl-mrs

Hello @wclarke

I am currently using FSL-MRS to quantify simulated spectra as part of my masters thesis. I used FID-A to simulate the basis spectra and the output consists of several .RAW files.

I am now trying to use basis_tools convert to convert the folder containing the .RAW files into the json format that FSL expects it to be in. I have however run into a problem, and was hoping you could give me some advice.

Here is the error message I am getting:

Traceback (most recent call last):
  File "/Users/miniconda3/envs/Master_Thesis_Experiment/bin/basis_tools", line 10, in <module>
    sys.exit(main())
  File "/Users/miniconda3/envs/Master_Thesis_Experiment/lib/python3.10/site-packages/fsl_mrs/scripts/basis_tools.py", line 224, in main
    args.func(args)
  File "/Users/miniconda3/envs/Master_Thesis_Experiment/lib/python3.10/site-packages/fsl_mrs/scripts/basis_tools.py", line 268, in convert
    basis_tools.convert_lcm_raw_basis(
  File "/Users/miniconda3/envs/Master_Thesis_Experiment/lib/python3.10/site-packages/fsl_mrs/utils/basis_tools.py", line 80, in convert_lcm_raw_basis
    basis = Basis(basis_array, names, [header, ] * len(names))
  File "/Users/miniconda3/envs/Master_Thesis_Experiment/lib/python3.10/site-packages/fsl_mrs/core/basis.py", line 74, in __init__
    self._dt = headers[0]['dwelltime']
IndexError: list index out of range

I assume that the list of dict [header, ] in convert_lcm_raw_basis is empty and thus trying to access the 0th element of this empty list ends up throwing the index out of range error. Any idea as how to how I could fix this? I will try digging a bit deeper using the debugger to see if I can figure out why this list is empty.

Thanks a lot, and I look forward to hearing from you.

Best,
Basab

Okay, I feel pretty naive. I just had to rename the files to *.raw instead of *.RAW as FID-A creates it. I just looked into the convert_lcm_raw_basis function and it ended up creating an empty list since it was only adding files with a “.raw” extension to the list it creates. It would be nice if this function also accepted the “.RAW” extension as well :blush:

1 Like

@b_gupta Well done on figuring it out, and thanks for the bug report. That should be in there for OS which make the distinction, I’ll make a change for the next version. Drop me a line if you need any additional help with basis sets, it isn’t the smoothest API at the moment.

1 Like