Hi everyone! I am trying to register and quantify Siemens CSI (TE=97ms, 3T) data in FSL-MRS and repeatedly hit the same issues:
Major errors:
Fslread: DT 1792 not supported – every FSL tool (FLIRT, fslmaths, etc.) crashes on the CSI NIfTIs that spec2nii writes because they are stored as complex128 (datatype 1792).
fslcomplex usage – I initially used fslcomplex -abs (invalid flag), then the correct -realabs, which produced magnitude files but kept them 4D.
FLIRT singular-matrix / COG = 0 warnings – when I ran FLIRT on those 4D magnitudes, it truncated to time-point 0 (all zeros), printed “inv(): matrix is singular” and no transform was generated.
Any advice, updated tools, or clearer instructions would be greatly appreciated!
Ilyas
This is a frustrating limitation of the original FSL tools.
You can take the approach that I use in the MRSI tissue segmentation tool mrsi_segment. In this I use the super useful fslpy package (already installed with fsl-mrs / fsl), to make a dummy image that matches the CSI exactly, but is just zeros. You can then use that to register to / from T1s etc.
# Make dummy nifti as nothing works with complex data
mrsi_in = Image(args.mrsi)
tmp_img = np.zeros(mrsi_in.shape[0:3])
tmp_img = Image(tmp_img, xform=mrsi_in.voxToWorldMat)
# Register the pvseg to the MRSI data using flirt
def applywarp_func(i, o):
applywarp(str_resolve_path(i),
tmp_img,
str_resolve_path(o),
usesqform=True,
super=True,
superlevel='a')
# T1_fast_pve_0, T1_fast_pve_1, T1_fast_pve_2
# partial volume segmentations (CSF, GM, WM respectively)
csf_output = args.output / (args.filename + '_csf.nii.gz')
gm_output = args.output / (args.filename + '_gm.nii.gz')
wm_output = args.output / (args.filename + '_wm.nii.gz')
applywarp_func(anat / 'T1_fast_pve_0.nii.gz',
csf_output)
applywarp_func(anat / 'T1_fast_pve_1.nii.gz',
gm_output)
applywarp_func(anat / 'T1_fast_pve_2.nii.gz',
wm_output)
Note that you want to do all processing/fitting in the native MRSI space and then warp the output metabolite maps (which are just normal, real, NIfTI images) to another space.
Hi!
Thanks for the prompt feedback. I followed the recommended pipeline but the fit stops ~60 % through with: “RuntimeWarning: divide by zero encountered in scalar divide
Exception (Water reference has zero integral. Please check water reference data.)
occurred in voxel index (22, 24, 0)
fsl_mrs.utils.results.FitRes.QuantificationError”
Below is exactly what I did. Please note that my data was already pre-processed.
I ran the data conversion using spec2nii and got “csi_se_30_fast.nii.gz” (metabolite CSI) and “csi_se_30_fast_w.nii.gz” (water ref).
I performed tissue segmentation using FAST on my T1 and got “T1_fast_pve_0.nii.gz”(CSF),
“T1_fast_pve_1.nii.gz”(GM), and “T1_fast_pve_2.nii.gz”(WM)
I used the script you gave me and got “csi_se_30_fast_csf.nii.gz”, “csi_se_30_fast_gm.nii.gz”, “csi_se_30_fast_wm.nii.gz” and “csi_se_30_fast_dummy.nii.gz”. 3. All are (32 × 32 × 1) with non-zero values (checked with fslstats -R -M).
I generated the brain mask (GM + WM > 0.5).
I performed the fitting, then the job aborted at voxel (22, 24, 0) because that voxel’s water spectrum is zero.
What is the best practice for handling voxels with empty water references?
• remove them from the mask,
• replace the water file with a dummy (all ones), or
• another FSL-MRS option I’ve missed?
Have a look at the data in fsleyes fsleyes -smrs csi_se_30_fast_w.nii.gz. Does the water peak look like it has zero value there and or does it appear otherwise correct? I.e. upright and at the expected frequency (4.65 ppm).