FSL-MRS: examplePRESS.json

Hello,
I would like to use FSL-MRS to create a basis set, but I have no idea what to use for the examplePRESS.json

I am working on a 3T GE Discovery
TE=35ms

I’m not sure what else to include…

But FSLMRS wants an examplePRESS.json and I wouldn’t know the first thing about where to find that or write one myself.

Cheers,

Alex W.

Hi Alex,

We’ve got some online resources that can help with the understanding of what’s in a basis set, and how to create one. See these videos and the last bit of the online practical.

As an alternative you can use a preexisting basis set without regenerating it via simulation. For example by following the same route in this thread FSL-MRS spec2nii philips dicom dimension issue - #5 by VerenaD, using the published sets from Chris Juchem’s lab.

Hi Will

I’m trying to follow that thread but something seems amiss.

I’ve downloaded the data from Juchem’s lab (RawBasis_for_PRESSGE_TE_35_BW_4000_NPts_2048)

I then run: basis_tools convert ../RawBasis_for_PRESSGE_TE_35_BW_4000_NPts_2048 --bandwidth 4000 --fieldstrength 3.0 fsl_basis

However, when I go to run the analysis:

fsl_mrs --data processed/metab.nii.gz --h2o processed/wref.nii.gz --basis ../fsl_basis_reduced --output results

I get this error:

Traceback (most recent call last):
  File "/usr/local/fsl/fslpython/envs/fslpython/lib/python3.8/site-packages/fsl_mrs/core/basis.py", line 302, in _resampled_basis
    basis = misc.ts_to_ts(self._raw_fids,
  File "/usr/local/fsl/fslpython/envs/fslpython/lib/python3.8/site-packages/fsl_mrs/utils/misc.py", line 210, in ts_to_ts
    raise InsufficentTimeCoverageError('Input data covers less time than is requested by interpolation.'
fsl_mrs.utils.misc.InsufficentTimeCoverageError: Input data covers less time than is requested by interpolation. Change interpolation points or dwell time.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/fsl/fslpython/envs/fslpython/bin/fsl_mrs", line 426, in <module>
    main()
  File "/usr/local/fsl/fslpython/envs/fslpython/bin/fsl_mrs", line 229, in main
    conjugated = mrs.check_Basis(repair=True)
  File "/usr/local/fsl/fslpython/envs/fslpython/lib/python3.8/site-packages/fsl_mrs/core/mrs.py", line 588, in check_Basis
    basis = self.basis
  File "/usr/local/fsl/fslpython/envs/fslpython/lib/python3.8/site-packages/fsl_mrs/core/mrs.py", line 231, in basis
    return self._basis.get_formatted_basis(
  File "/usr/local/fsl/fslpython/envs/fslpython/lib/python3.8/site-packages/fsl_mrs/core/basis.py", line 224, in get_formatted_basis
    formatted_basis = self._resampled_basis(1 / bandwidth, points)
  File "/usr/local/fsl/fslpython/envs/fslpython/lib/python3.8/site-packages/fsl_mrs/core/basis.py", line 307, in _resampled_basis
    raise BasisHasInsufficentCoverage('The basis spectra covers too little time. '
fsl_mrs.core.basis.BasisHasInsufficentCoverage: The basis spectra covers too little time. Please reduce the dwelltime, number of points or pad this basis.

In that thread, the person had a similar error, but it was fixed by using the same bandwidth as the one they downloaded. I am doing that… so I’m not sure what I’ve done wrong.

Any help would be appreciated

Cheers,

Alex W.

Hi @weberam2,

What bandwidth (dwelltime) and how many points does your data have? If the product of dwelltime * points of your data is greater than dwelltime * points of the basis then you will get this error.

Will

Hi Will,

Thanks for responding so fast.

When I type

mrs_tools info P38400.nii.gz

I get:

Read file P38400.nii.gz (/home/weberam2/Dropbox/AssistantProf_BCCHRI/Projects/sLASER/FSL-MRSAnalysis/PRESS35).
NIfTI-MRS version 0.5
Data shape (1, 1, 1, 4096, 32, 16)
Dimension tags: ['DIM_COIL', 'DIM_DYN', None]
Spectrometer Frequency: 127.773775 MHz
Dwelltime (Bandwidth): 2.000E-04s (5000 Hz)
Nucleus: 1H
Field Strength: 3.00 T

Which I think means my dwell time (0.0002) x num of points (4096) = ~0.8

Whereas from Jurech the max option is around 0.5

Is there a workaround?

I COULD use MRSCloud which works, but when I try to add MM

basis_tools add_set --add_MM basis_without_mm/ basis_with_default_mm/

I get a very strange basis set…

Thanks for all your help!

Cheers

Alex W.

Hi Alex,

What ends up weird? Is it that the MM are at the wrong frequency? If so try using basis_tools conj before adding the MM. Or is it that the MM are very narrow? If so you can specify Lorentzian and Gaussian broadening in the call to add default MM

% basis_tools add_set --help
usage: basis_tools add_set [-h] (--add_MM | --add_MM_MEGA | --add_water) [--gamma GAMMA] [--sigma SIGMA] file output

positional arguments:
  file           Basis file
  output         Output location, can overwrite.

optional arguments:
  -h, --help     show this help message and exit
  --add_MM       include default macromolecule peaks
  --add_MM_MEGA  include default MEGA-PRESS macromolecule peaks. This option is experimental!
  --add_water    include water peak.
  --gamma GAMMA  Peak widths (lorentzian) in Hz.
  --sigma SIGMA  Peak widths (gaussian) in Hz.

Hi Will,

Yes, I believe the conjugation was the issue.

However, now when I look at my report, my baseline is above my model… is this normal?

This is what the fit summary looks like

Cheers,

Alex W.

In a word, no.

What does the final basis look like? One issue is that you might need to run basis_tools conj again. Sorting out the basis set conventions is on the to-do list, pending a new standard that various people ware working on.

Will

Hi Will,

This is what the basis set looks like that I used:

Is it also possible I have preprocessed my P file wrong?

Basically:

spec2nii ge P38400.7
fsl_mrs_preproc --output processed --data P38400.nii.gz --reference P38400_ref.nii.gz --report
svs_segment -t anat/T1w.nii.gz processed/metab.nii.gz
fsl_mrs  --data processed/metab.nii.gz --basis basis_sets/MRSCloud_35TE_conj_wMM/ --output results_svs  --h2o processed/wref.nii.gz --tissue_frac segmentation.json --report

spec2nii is version 0.4.6
fsl_mrs is version 1.1.8

Is there anyone who is familiar with FSL_MRS who would be willing to process my Pfile to confirm that it isn’t hte file itself that is the issue?

https://share.bcchr.ca/?u=vx7MWaf9MAF7&p=4BtyyJ3UXWm3

One issue is that you might need to run basis_tools conj again.

Does this mean I run basis_tools conj MRSCloud_35TE_conj_wMM MRSCloud_35TE_conj_wMM_conjagain ?

If so, I think it gives me a funky basis set

Thanks for all your help Will

Is there any way I can help in any way as a GE user?

I also noticed spec2nii ge doesn’t recognize semi-LASER sequences. I have some semi-LASER GE Pfiles if you want to play with them

Cheers

Alex W.

Hi Alex,

There appears to be a couple of things going on here with the basis.

  1. The MM appear to have been applied when the basis set is conjugated. Precisely what commands did you run to get the first figure in the previous post?

  2. That basis set comes with many metabolites, I would suggest trimming it down. To precisely what remains a debated question, but perhaps remove Tyros, Thr, Ser, Phenyl, PE, EtOH, EA, Cit and Asc to start.

Those commands look right, but you are on quite an old version of FSL-MRS now. You have the version that comes with the ‘current’ (> year old) version of FSL. However, as a newer tool in the FSL stable development has kept going. Could you update using the instructions here? Installation Instructions — FSL-MRS 2.0.7 documentation

Re the spec2nii. You are not the only one. It’s relatively near the top of my things to do list. I think @mmikkel has a solution.

Hi Will,

Thanks for staying with me on this. I was having issues with the FSL install and various Python installations (miniconda3 and the native one, I think)

  1. The first image I got by running the following:
basis_tools conj MRSCloud_35TE/LCModel_GE_UnEdited_PRESS_GABA35_.BASIS MRSCloud_35TE_conj

That’s all

  1. Ok will do

Thanks for bringing this to my attention. It seems this is the version that is installed with the most recent version of FSL? (I even re-installed to see if it updated, but it stays the same)
The best solution for me was to create a conda environment and then install using conda.
The reason I have to create a conda environment is that, if I install with the base environment, it still defaults to /usr/local/fsl/bin/fsl_mrs instead of the conda updated version

now when I type

fsl_mrs --version

I get 2.0.8 :smile:

Hi Will,

How do I trim down a .BASIS file?

When I run basis_tools conj LCModel_GE_UnEdited_PRESS_GABA35_.BASIS MRSCloud_35TE_conj I get a folder that I can then remove json files from…

But not sure how to edit the .BASIS file itself if in fact I don’t want to conjugate it

Hi Will,

Ok, everything is up to date (removed all traces of what FSL default installs w.r.t. fsl_mrs and created an virt environment and installed in that using conda)
fsl_mrs -v gives 2.0.8
spec2nii -v gives 0.4.9

I have processed my data according to the tutorial (FSL-MRS Practical)

Here is my basis set

image

Here is my fit summary

Which looks good. This is without MM however…

with MM:

mrs_tools vis MRSCloud_fromFSLLec_conj_wMM/

fsl_mrs --data fsl_mrs_proc/metab.nii.gz --basis MRSCloud_fromFSLLec_conj_wMM/ --output results_conj_wMM --h2o fsl_mrs_proc/wref.nii.gz --tissue_frac ../PRESS35/segmentation.json --report --metab_groups MM09 MM12 MM14 MM17 MM21

Which I’m guessing means I’ve added too many MM to my basis set?

What do you think is happening at .8ppm and 1.6ppm?

I feel like we are close? I definitely feel like I’ve learned a lot

Yes, right the MM have been added with the wrong handedness convention. This is unfortunately a bit of a mess currently in FSL. All this is hopefully going to get sorted soon when @Helge establishes a new standard for basis sets :).

For now take the first basis set you have just shown me (without MM), run the conjugation step, then the add MM, then the conjugation step again on the basis with MM added. You should then see the (broad MM) peaks in the right positions roughly 1-2 ppm. Something like this:

Hi Will,

I think that did the trick:

Cheers!

Alex W.

Hi Alex,

That looks quite a bit better now, but that fit isn’t great. Is there a substantial amount of water residual left in the data?

Hi Will,

Sorry, how do I check something like that?

You can either look at the interactive fitting report (html format) and expand the ppm limits in the first figure.

Or use mrs_tools vis --ppmlim 0 6 my_data.nii.gz