Read in Philips .SDAT/.SPAR files in python

Hi, I’m new to MRS Hub I was wondering if there is a way to read in .SDAT/.SPAR files in python? I have tried using the suspect module but that doesn’t seem to work, does anyone have any suggestions?

Hi Daniel, Wellcome to MRSHub!

I’m not aware of a specific SDAT/SPAR reader for python but I can offer two routes.

  1. Use GitHub - wexeee/spec2nii: Multi-format in vivo MR spectroscopy conversion to NIFTI to convert your data to the new NIfTI-MRS format and then read that into python using the minimal loading example found at GitHub - wexeee/nifti_mrs_python_example: Minimal example of loading NIfTI MRS using python.. spec2nii can be installed using pypi or conda. I’ve taken some time to validate the orientation code for Philips so the voxel location should be accurate w.r.t. structural images converted using dcm2niix.

  2. Use some of the code that is around to roll your own reader e.g. from spec2nii/ at master · wexeee/spec2nii · GitHub or the VESPA source code.


I’ve just tried running ‘spec2nii ge SDAT_FILE SPAR_FILE’ in the anaconda prompt window whilst I’m in the directory of my two .sdat and .spar files and I’m getting the error ‘spec2nii: error: unrecognized arguments: DBIEX_5_1_raw_act.SPAR’ (name of my .spar file). I’m not sure what I’m doing wrong? Thank you.

Hi @daniel
Sorry a bad typo from me when writing the instructions.
It should read

spec2nii philips SDAT_FILE SPAR_FILE

I’ve corrected this on my local copy which I’ll publish over the weekend (it should still work with the current version if you replace ge with philips in the call).

Thank you, I have just implemented the above this morning and received the error 'KeyError: ‘lr_angulation’ '. Do you know why this might be?

I’m not sure what is happening just from this description. Are you able to send me a copy of the data it failed on and a description of what it should be (e.g. svs, MRSI, voxel size etc.)?

Sure thing, if you send me your email I can get that over to you. my email is