Errors in using spec2nii trans MEGA-PRESS *.ima data

Hi All
I am a junior in MRS data analysis.
I have collected the MRS pilot data using the SIEMENS MAGNETOM Prisma 3.0T with the MEGA-PRESS sequence. The editing pulse frequency was setting off at 7.75ppm, and on at 1.9ppm. The water-unsuppressed data was collected with the same setting.

So, I got one folder of dynamic data mixed up with the ON /OFF editing data.
and a folder of (ON/OFF)average data. like the following:

https://drive.google.com/drive/folders/1CkA2W0nPYL8b7KeqRV08uUVFF8-h46h4?usp=drive_link

Several problems were raised.

  1. Do I need to transform the editing on and off data separately or transform the whole folder?
  2. When I use the spec2nii to transform the whole folder, the error report like this:

spec2nii dicom -f my_metab_RES_file -j EJA_SVS_MPRESS_RES_0011
mrs_tools info my_metab_RES_file.nii.gz

> Read file my_metab_RES_file_reordered.nii.gz (/home/rshuang/Amy/mrs_test/example_data).
> NIfTI-MRS version 0.5
> Data shape (1, 1, 1, 2048, 256)
> Dimension tags: ['DIM_COIL', None, None]
> Spectrometer Frequency: 123.254447 MHz
> Dwelltime (Bandwidth): 2.000E-04s (5000 Hz)
> Nucleus: 1H
> Field Strength: 2.89 T

I can’t illustrate the data use mrs_tools vis
mrs_tools vis my_metab_RES_file.nii.gz --display_dim DIM_COIL

> Traceback (most recent call last):
>   File "/home/packages/fsl/fslpython/bin/mrs_tools", line 10, in <module>
>     sys.exit(main())
>   File "/home/packages/fsl/fslpython/lib/python3.9/site-packages/mrs_tools/__init__.py", line 155, in main
>     args.func(args)
>   File "/home/packages/fsl/fslpython/lib/python3.9/site-packages/mrs_tools/__init__.py", line 280, in vis
>     vis_nifti_mrs(p)
>   File "/home/packages/fsl/fslpython/lib/python3.9/site-packages/mrs_tools/__init__.py", line 225, in vis_nifti_mrs
>     fig = plot_spectra(data.mrs(), ppmlim=args.ppmlim, plot_avg=args.no_mean)
>   File "/home/rshuang/.local/lib/python3.9/site-packages/fsl_mrs/utils/plotting.py", line 292, in plot_spectra
>     plt.grid(b=True, axis='x', which='major', color='k', linestyle='--', linewidth=.3)
>   File "/home/packages/fsl/fslpython/lib/python3.9/site-packages/matplotlib/pyplot.py", line 2616, in grid
>     return gca().grid(visible=visible, which=which, axis=axis, **kwargs)
>   File "/home/packages/fsl/fslpython/lib/python3.9/site-packages/matplotlib/axes/_base.py", line 3194, in grid
>     self.xaxis.grid(visible, which=which, **kwargs)
>   File "/home/packages/fsl/fslpython/lib/python3.9/site-packages/matplotlib/axis.py", line 1660, in grid
>     self.set_tick_params(which='major', **gridkw)
>   File "/home/packages/fsl/fslpython/lib/python3.9/site-packages/matplotlib/axis.py", line 932, in set_tick_params
>     kwtrans = self._translate_tick_params(kwargs)
>   File "/home/packages/fsl/fslpython/lib/python3.9/site-packages/matplotlib/axis.py", line 1076, in _translate_tick_params
>     raise ValueError(
> ValueError: keyword grid_b is not recognized; valid keywords are ['size', 'width', 'color', 'tickdir', 'pad', 'labelsize', 'labelcolor', 'zorder', 'gridOn', 'tick1On', 'tick2On', 'label1On', 'label2On', 'length', 'direction', 'left', 'bottom', 'right', 'top', 'labelleft', 'labelbottom', 'labelright', 'labeltop', 'labelrotation', 'grid_agg_filter', 'grid_alpha', 'grid_animated', 'grid_antialiased', 'grid_clip_box', 'grid_clip_on', 'grid_clip_path', 'grid_color', 'grid_dash_capstyle', 'grid_dash_joinstyle', 'grid_dashes', 'grid_data', 'grid_drawstyle', 'grid_figure', 'grid_fillstyle', 'grid_gapcolor', 'grid_gid', 'grid_in_layout', 'grid_label', 'grid_linestyle', 'grid_linewidth', 'grid_marker', 'grid_markeredgecolor', 'grid_markeredgewidth', 'grid_markerfacecolor', 'grid_markerfacecoloralt', 'grid_markersize', 'grid_markevery', 'grid_mouseover', 'grid_path_effects', 'grid_picker', 'grid_pickradius', 'grid_rasterized', 'grid_sketch_params', 'grid_snap', 'grid_solid_capstyle', 'grid_solid_joinstyle', 'grid_transform', 'grid_url', 'grid_visible', 'grid_xdata', 'grid_ydata', 'grid_zorder', 'grid_aa', 'grid_c', 'grid_ds', 'grid_ls', 'grid_lw', 'grid_mec', 'grid_mew', 'grid_mfc', 'grid_mfcalt', 'grid_ms']

When I run mrs_tools reorder --file my_metab_RES_file.nii.gz --dim_order DIM_COIL DIM_DYN
I seems like not work

mrs_tools info my_metab_RES_file_reordered.nii.gz

Read file my_metab_RES_file_reordered.nii.gz (/home/rshuang/Amy/mrs_test/example_data).
NIfTI-MRS version 0.5
Data shape (1, 1, 1, 2048, 256)
Dimension tags: ['DIM_COIL', None, None]
Spectrometer Frequency: 123.254447 MHz
Dwelltime (Bandwidth): 2.000E-04s (5000 Hz)
Nucleus: 1H
Field Strength: 2.89 T

Then mrs_tools reorder --file my_metab_RES_file.nii.gz --dim_order DIM_DYN

Traceback (most recent call last):
  File "/home/packages/fsl/fslpython/bin/mrs_tools", line 10, in <module>
    sys.exit(main())
  File "/home/packages/fsl/fslpython/lib/python3.9/site-packages/mrs_tools/__init__.py", line 155, in main
    args.func(args)
  File "/home/packages/fsl/fslpython/lib/python3.9/site-packages/mrs_tools/__init__.py", line 381, in reorder
    reordered = nmrs_tools.reorder(to_reorder, args.dim_order)
  File "/home/packages/fsl/fslpython/lib/python3.9/site-packages/nifti_mrs/tools/split_merge.py", line 327, in reorder
    raise NIfTI_MRSIncompatible(
nifti_mrs.tools.split_merge.NIfTI_MRSIncompatible: The existing tag (DIM_COIL) does not appear in the requested tag order (['DIM_DYN', None, None]).

It seems like lacking information in my data shape and Dimension tags will lead to the error report in my following preprocessing analysis. So I am asking for help with this data analysis. Thanks in advance.

Hi @Amy_YIN

The first error (ValueError: keyword grid_b...) is an issue that has been fixed in a recent update to FSL-MRS. Please follow the instructions conda update ... listed in the documentation to fix it. The second error arises because the conversion by spec2nii had guessed (incorrectly, and I should fix it) that the multiple DICOM files correspond to different coils, rather than different data transients (i.e. ON, OFF, ON, …etc). You can change this by running

spec2nii dicom -f my_metab_RES_file -j -t DIM_DYN EJA_SVS_MPRESS_RES_0011
mrs_tools info my_metab_RES_file.nii.gz

at which point you should see

> Dimension tags: ['DIM_DYN', None, None]

Let me know if that works.

Hi Clarke:
Thanks for your tips, it really works.

spec2nii dicom -f my_metab_RES_file -j -t DIM_DYN EJA_SVS_MPRESS_RES_0011
mrs_tools info my_metab_RES_file.nii.gz

But next, I need to do the coil-combine which needs the DIM_COIL information I think, right?
I tried to do next steps

mrs_tools reorder --file my_metab_RES_file.nii.gz --dim_order DIM_COIL DIM_DYN
mrs_tools reorder --file my_wref_metab_RES_file.nii.gz --dim_order DIM_COIL DIM_DYN

Changed the Dimension as

Read file my_metab_RES_file_reordered.nii.gz (/home/rshuang/Amy/mrs_test/example_data).
NIfTI-MRS version 0.7
Data shape (1, 1, 1, 2048, 1, 256)
Dimension tags: [‘DIM_COIL’, ‘DIM_DYN’, None]
Spectrometer Frequency: 123.254447 MHz
Dwelltime (Bandwidth): 2.000E-04s (5000 Hz)
Nucleus: 1H
Field Strength: 2.89 T

fsl_mrs_proc coilcombine --file my_metab_RES_file_reordered.nii.gz --reference my_wref_metab_RES_file_reordered.nii.gz --output combined -r

Traceback (most recent call last):
File “/home/packages/fsl/fslpython/envs/fslpython/bin/fsl_mrs_proc”, line 693, in
main()
File “/home/packages/fsl/fslpython/envs/fslpython/bin/fsl_mrs_proc”, line 351, in main
dataout = args.func(dataList, vars(args))
File “/home/packages/fsl/fslpython/envs/fslpython/bin/fsl_mrs_proc”, line 470, in coilcombine
combined = preproc.coilcombine(dataobj.data,
File “/home/packages/fsl/fslpython/envs/fslpython/lib/python3.8/site-packages/fsl_mrs/utils/preproc/nifti_mrs_proc.py”, line 84, in coilcombine
_, refWeights = preproc.combine_FIDs(
File “/home/packages/fsl/fslpython/envs/fslpython/lib/python3.8/site-packages/fsl_mrs/utils/preproc/combine.py”, line 148, in combine_FIDs
FIDlist, W, C = prewhiten(FIDlist)
File “/home/packages/fsl/fslpython/envs/fslpython/lib/python3.8/site-packages/fsl_mrs/utils/preproc/combine.py”, line 42, in prewhiten
C = np.cov(FIDs[start:, :], rowvar=False)
File “<array_function internals>”, line 180, in cov
File “/home/packages/fsl/fslpython/envs/fslpython/lib/python3.8/site-packages/numpy/lib/function_base.py”, line 2617, in cov
raise ValueError(“m has more than 2 dimensions”)
ValueError: m has more than 2 dimensions

Hi, In this DICOM data the coil combination has already been performed by the scanner’s own reconstruction pipeline. There is no need to repeat it.