FSL-MRS spec2nii Siemens dicom conversion issue

Hi,

I’m new to fsl-mrs and am trying to load DICOM images from an MRSI sequence acquired on a Siemens Prisma 3T system using spec2nii. The MRSI sequence I ran is described here: https://doi.org/10.1016/j.neuroimage.2014.09.032

When I run spec2nii dicom ~/pathtodicomfolder I get the following error message:

'/Users/simin/fsl/lib/python3.11/site-packages/spec2nii/Siemens/dicomfunctions.py:10: UserWarning: The DICOM readers are highly experimental, unstable, and only work for Siemens time-series at the moment',
 'Please use with caution.  We would be grateful for your help in improving them',
 '  import nibabel.nicom.dicomwrappers',
 'Found 3 files.',
 'Traceback (most recent call last):',
 '  File "/Users/simin/fsl/bin/spec2nii", line 10, in <module>',
 '    sys.exit(main())',
 '             ^^^^^^',
 '  File "/Users/simin/fsl/lib/python3.11/site-packages/spec2nii/spec2nii.py", line 666, in main',
 '    spec2nii(*args)',
 '  File "/Users/simin/fsl/lib/python3.11/site-packages/spec2nii/spec2nii.py", line 283, in __init__',
 '    args.func(args)',
 '  File "/Users/simin/fsl/lib/python3.11/site-packages/spec2nii/spec2nii.py", line 512, in dicom',
 '    self.imageOut, self.fileoutNames = multi_file_dicom(files_in, args.fileout, args.tag, args.verbose)',
 '                                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^',
 '  File "/Users/simin/fsl/lib/python3.11/site-packages/spec2nii/Siemens/dicomfunctions.py", line 118, in multi_file_dicom',
 '    specDataCmplx, orientation, dwelltime, meta_obj = process_siemens_csi(img, verbose=verbose)',
 '                                                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^',
 '  File "/Users/simin/fsl/lib/python3.11/site-packages/spec2nii/Siemens/dicomfunctions.py", line 308, in process_siemens_csi',
 '    return process_siemens_csi_xa(img, verbose)',
 '           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^',
 '  File "/Users/simin/fsl/lib/python3.11/site-packages/spec2nii/Siemens/dicomfunctions.py", line 314, in process_siemens_csi_xa',
 "    raise NotImplementedError('Method process_siemens_csi_xa not implemented, example data needed!')",
 'NotImplementedError: Method process_siemens_csi_xa not implemented, example data needed!'

The software version on the scanner is VE11C. Is this version supported?

Thanks for any suggestions / ideas,

Simon

Hi @simin ,

Ah this must be an enhanced DICOM coming from a VE11c scanner then, I have heard of this but hadn’t yet encountered it (at first enhanced DICOM were only seemingly coming from the XA line scanners, hence the error).

I haven’t yet included MRSI/CSI handling in this pathway (SVS is), because I haven’t got any example data. If you had some, that I can host as part of the public dataset, I’d be very happy to add it. This just needs to be a small (low resolution) scan on a phantom.

BW

Will

Hi @wclarke,

thank you very much for the quick reply. I could record some phantom data with the sequence next week. Alternatively, I could get permission to upload the in-vivo data from one of the control subjects and remove personal data from the dicom header. Where can I upload the data?

Best wishes,

Simon

Hi @simin ,

There are so many issues with hosting human data that I would greatly prefer phantom. It should be pretty small int erms of data size, so you could just send it to the email listed here: William Clarke — Wellcome Centre for Integrative Neuroimaging

Will

Hi @wclarke,

Thanks a lot. I will record some low resolution data next week and will email it to you.

Best wishes,

Simon

Hi @wclarke,

I’ve just sent you an email with some phantom data at a reduced resolution. Hope the attachment size was okay and it reached your inbox.

All the best,

Simon

1 Like

Thanks for providing the data @simin , Roland was also in touch about this with more data. As such it’s now in the codebase and will be in version 0.7.1 (out in the next few days). If you want it now you can clone from github and do a local installation (pip install .).

Will

1 Like

Hi @wclarke,

That’s great. Thanks for the quick implementation! I’ll try to run spec2nii with the GitHub version tomorrow.

Best wishes,

Simon

Hi all,

I hope it’s okay to reopen this discussion here; I’m facing a very similar error on Siemens syngo MR E11 (ID Manufacturer Model Name → Prisma_fit)

I’m new to MRS and I’m trying to convert some DICOM files to NIfTI using spec2nii and I’m facing similar issues.

Before explaining my issues, let me share some information:

· Python version: 3.11.9
· OS: Linux
· spec2nii version: 0.8.7

· The data were acquired on a SIEMENS scanner. See below some DICOM tags:
→ Tag 0018 1020 ACQ Software Version//syngo MR E11

Some of my DICOM files have:
→ Tag 0008 0016 ID SOP Class UID//1.2.840.10008.5.1.4.1.1.4
→ Tag 0008 0008 ID Image Type//DERIVED\PRIMARY\SPECTROSCOPY\REFERENCEIMAGE

And one DICOM file in the same folder has:
→ Tag 0008 0016 ID SOP Class UID//1.2.840.10008.5.1.4.1.1.7 (only one DICOM)
→ Tag 0008 0008 ID Image Type//DERIVED\PRIMARY\SPECTROSCOPY\SPECTRUM

MY ISSUE:

When I try to convert my DICOM using spec2nii dicom -f . PATIENT123/dicom_file I get this:

/home/apps/packages/Anaconda/Anaconda3-2024.02-1/lib/python3.11/site-packages/spec2nii/Siemens/dicomfunctions.py:10: UserWarning: The DICOM readers are highly experimental, unstable, and only work for Siemens time-series at the moment
Please use with caution. We would be grateful for your help in improving them
import nibabel.nicom.dicomwrappers
Single file conversion.
Traceback (most recent call last):
File “/home/apps/packages/Anaconda/Anaconda3-2024.02-1/bin/spec2nii”, line 10, in
sys.exit(main())
^^^^^^
File “/home/apps/packages/Anaconda/Anaconda3-2024.02-1/lib/python3.11/site-packages/spec2nii/spec2nii.py”, line 701, in main
spec2nii(*args)
File “/home/apps/packages/Anaconda/Anaconda3-2024.02-1/lib/python3.11/site-packages/spec2nii/spec2nii.py”, line 297, in init
args.func(args)
File “/home/apps/packages/Anaconda/Anaconda3-2024.02-1/lib/python3.11/site-packages/spec2nii/spec2nii.py”, line 547, in dicom
self.imageOut, self.fileoutNames = multi_file_dicom(files_in, args.fileout, args.tag, args.verbose)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “/home/apps/packages/Anaconda/Anaconda3-2024.02-1/lib/python3.11/site-packages/spec2nii/Siemens/dicomfunctions.py”, line 105, in multi_file_dicom
raise exc
File “/home/apps/packages/Anaconda/Anaconda3-2024.02-1/lib/python3.11/site-packages/spec2nii/Siemens/dicomfunctions.py”, line 102, in multi_file_dicom
mrs_type = svs_or_CSI(img)
^^^^^^^^^^^^^^^
File “/home/apps/packages/Anaconda/Anaconda3-2024.02-1/lib/python3.11/site-packages/spec2nii/Siemens/dicomfunctions.py”, line 65, in svs_or_CSI
if xa_or_vx(img) == ‘vx’:
^^^^^^^^^^^^^
File “/home/apps/packages/Anaconda/Anaconda3-2024.02-1/lib/python3.11/site-packages/spec2nii/Siemens/dicomfunctions.py”, line 49, in xa_or_vx
raise IncompatibleSOPClassUID(
spec2nii.Siemens.dicomfunctions.IncompatibleSOPClassUID: spec2nii detected SOPClassUID 1.2.840.10008.5.1.4.1.1.4. This normally contains MR imaging (not spectroscopy) data. This data was collected on a syngo MR E11 baseline scanner. spec2nii is tested on VA-VE, XA20, and XA30 DICOM files.

What I guess is that the root cause is related with the incompatibility with the SOPClassUID. Is it possible that the main issue is because of the following function in dicomfunctions.py?:

def xa_or_vx(img):
“”"Determine siemens DICOM type

:param img: DICOM image object
:type img: nibabel.nicom.dicomwrappers.SiemensWrapper
:raises IncompatibleSOPClassUID: Raised if not a Siemens Syngo Non Image Storage or MRSpectroscopyStorage dicom file
:return: String either 'xa' or 'vx'
:rtype: str
"""
if img.dcm_data.SOPClassUID == '1.3.12.2.1107.5.9.1':
    return 'vx'
elif img.dcm_data.SOPClassUID == '1.2.840.10008.5.1.4.1.1.4.2':
    return 'xa'
else:
    if img.dcm_data.SOPClassUID == '1.2.840.10008.5.1.4.1.1.4':
        raise IncompatibleSOPClassUID(
            f'spec2nii detected SOPClassUID {img.dcm_data.SOPClassUID}.'
            ' This normally contains MR imaging (not spectroscopy) data.'
            ' This data was collected on a'
            f' {img.dcm_data.SoftwareVersions} baseline scanner.'
            ' spec2nii is tested on VA-VE, XA20, and XA30 DICOM files.')
    else:
        raise IncompatibleSOPClassUID(
            'spec2nii does not recognise this SOPClassUID '
            f'{img.dcm_data.SOPClassUID} as MRS data. This data was collected on a'
            f' {img.dcm_data.SoftwareVersions} baseline scanner.'
            ' spec2nii is tested on VA-VE, XA20, and XA30 DICOM files.')

Is this behaviour expected for Siemens syngo MR E11 data where spectroscopy information is stored with SOP Class UIDs 1.2.840.10008.5.1.4.1.1.4 and 1.2.840.10008.5.1.4.1.1.7?

How can this issue be resolved effectively?

Thank you in advance. If required I could provide additional (anonymised) information if that helps.

Sofia.

Hi Sofia,

Based on those DICOM tags you posted, along with the error message from spec2nii, it looks like the ones with “REFERENCEIMAGE” in the ImageType field are likely the anatomical scans used for spectroscopy voxel placement (or a reconstructed/resliced version), and the actual spectroscopy data is in the other DICOMs. You may not need the REFERENCEIMAGE DICOMs at all (you most likely have separate T1 DICOMs), but you could try converting those with dcm2niix and see what happens.

Just my guesses - others can correct if I’m wrong!

Best,
Elizabeth

@sofiasp96

I think @elizabethlorenc is right. Are you sure these dicom actually contain Mrs data? I’ve seen this issue arise when they either contain some sort of reference image or they are an image of the spectrum (useless for actual analysis). Can you match up the data to the series on the scanner or inspect everything in e.g. Horos?