and mystery 64 multi measurements files


Trying to convert Siemens DICOM MRS files with suspect. This works for most files, but the ones created by a Siemens WIP for navigator gated spectroscopy fail. Somehow the script tries to get the data in a shape with a dimension of 64. It is a single FID of 1024 points, but created with a protocol with multiple measurements. Not 64, but 2.
Other spectra translate just fine.
I looked at the .py and I see it correctly pulls the data dimension from that wonderful obsure carefully hidden Siemens CSA header. I cannot see where the number 64 comes from. How can I fix this?

ValueError Traceback (most recent call last)
----> 1 arr_data =“XX_svs_se_ubp_WSRFoffTR2TE25.0-2ave.IMA”)

/opt/conda/lib/python3.7/site-packages/suspect/io/ in load_siemens_dicom(filename)
149 complex_data = complex_array_from_iter(iter(data_floats),
150 length=len(data_floats) // 2,
–> 151 shape=data_shape)
153 in_plane_rot = csa_header[“VoiInPlaneRotation”]

/opt/conda/lib/python3.7/site-packages/suspect/io/ in complex_array_from_iter(data_iter, length, shape, chirality)
26 complex_array = np.fromiter(complex_iter, “complex64”, length)
27 if shape is not None:
—> 28 complex_array = np.reshape(complex_array, shape).squeeze()
29 return complex_array

<array_function internals> in reshape(*args, **kwargs)

/opt/conda/lib/python3.7/site-packages/numpy/core/ in reshape(a, newshape, order)
299 [5, 6]])
300 “”"
–> 301 return _wrapfunc(a, ‘reshape’, newshape, order=order)

/opt/conda/lib/python3.7/site-packages/numpy/core/ in _wrapfunc(obj, method, *args, **kwds)
60 try:
—> 61 return bound(*args, **kwds)
62 except TypeError:
63 # A TypeError occurs if the object does have such a method in its

ValueError: cannot reshape array of size 1024 into shape (64,1,1,1024)

Hi @ouwerkerkr,

Thanks for joining the MRSHub. I can’t speak for Suspect directly, but I’ll tag @bennyrowland so he sees this thread. Ben, would you be able to help Ronald?

Best wishes,

Hi @ouwerkerkr,

Sorry for the slow reply, it has been a busy week with ISMRM. I haven’t done a lot of work with Siemens Dicom as I prefer to use Twix where possible, so it is possible there are some errors or incompleteness in the code handling them. It is also possible that the Siemens WIP is doing something different with one of the CSA header parameters that is being misinterpreted. A quick review of the code shows that the 64 seems to come from the CSA parameter “SpectroscopyAcquisitionOut-of-planePhaseSteps” which normally contains the number of slices in 3D MRSI, so I don’t know what is going on in this case.

Can you share the file? If so I will have a dig through the header and see if I can figure out what is going on and sort out a fix.


Hi Ben,

Thanks for your reply.
I would share the file, but I have to find a reliable way to anonymize thing e DICOM file without changing anything else. I can no longer go back to the Siemens because it is being replaced (magnet was hauled out yesterday). There is a workstation with backups that I have to revive first.
For now I can say that the value of this variable is indeed 64 csa.SpectroscopyAcquisitionOutofplanePhaseSteps = [64 0 0 0 0 0]
and in single vulume DICOM spectra that did convert properly it is
data: [1 0 0 0 0 0]
So, I think you hit the nail on the head. I just don’t know how to fix this yet, but searching for this CSA parameter in the code should help. I will post it if I find a fix.
I have the source of the pulse sequence, but it is an old VB17 WIP and we are no longer going to use it. I seek a solution for the old data only. Any suggestions are welcome.


Hi @ouwerkerkr,
I have just pushed a new version of Suspect (v0.4.2) to PyPI so you can upgrade with pip. The new version changes the way that .IMA files are loaded so that if there is a mismatch between the shape of the data as calculated by Suspect and the size of data available then it reverts to a 1D array of whatever size is in the data. Hopefully this will solve your problem at least.
Please bear in mind that I don’t have your data to test on, so this may not be a correct solution to the problem, please let me know if you have any further problems and I will try and fix them.

Hi Ben,

Thank you for the fix. This works. I had temporarily fixed it with a hack: hardcoding the number of phase steps to 1, but this is a more elegant solution to a problem that is really caused by sloppy pulse programming (the recorded size parameters should match the data).
I get : “Warning: The calculated data shape for this file {} does not match the size of data contained in the file {}. Therefore the returned data shape from this function will simply be ({},), any reshaping must be done by the user. If you need help with this or believe this has occured in error, please raise an issue at”

After that the data look just fine:
And the data plots and FFT’s just fine

Thank you,


Thanks, @ouwerkerkr, I see that I forgot to put the values into the format string - will sort that out now. The warning is there in case someone has a similar problem where the data is not supposed to be 1D, just to let them know they have to take responsibility for reshaping it. Glad to hear it is working for you now.