I have both philips spar/sdat and data/list files acquired from a subject.
In the former dataset, nifti files were generated with both spec2nii and osprey gui. However, mrs_tool can get information from the nifti file from spec2nii, but not from osprey gui.
In the latter dataset of .data/.list, I saved it as nifti format with io_writeniimrs.m. The nifti file can be processed with osprey. Unfortunately, however, mrs_tool info also generated error messages like below.
main.py", line 91, in read_FID
return fsl_nmrs.NIFTI_MRS(filename, validate_on_creation=False)
âŚ
hdr_ext.py", line 106, in from_header_ext
raise ValueError(fâUser-defined key {key} must contain a âDescriptionâ field"')
ValueError: User-defined key ProcessingSoftwareVersion must contain a âDescriptionâ field"
in case of âwith io_writeniimrs.mâ
validator.py", line 166, in validate_hdr_ext
raise headerExtensionError(fâ{key} must be a {standard_defined[key][0]}. â
nifti_mrs.validator.headerExtensionError: RepetitionTime must be a <class âfloatâ>. RepetitionTime is a <class âintâ>, with value 2.
Thanks - this is really useful feedback. I think this means that weâll need to modify io_writeniimrs to comply a little more strictly with the requirements. Here, specifically, we stored TR as an integer rather than a float and didnât store a description of some additional header documentation. This should be easily fixable on our end.
@wclarke might also find this useful to edit his code to be a little more forgiving if the incoming NIfTI-MRS file is not perfectly compliant.
In the case of the nifti file generated with Osprey gui, spec2nii generate following errors:
File âfsl_mrs/lib/pypy3.9/site-packages/nifti_mrs/nifti_mrs.pyâ, line 125, in init
self._hdr_ext = Hdr_Ext.from_header_ext(
File âfsl_mrs/lib/pypy3.9/site-packages/nifti_mrs/hdr_ext.pyâ, line 106, in from_header_ext
raise ValueError(fâUser-defined key {key} must contain a âDescriptionâ field"')
ValueError: User-defined key ProcessingSoftwareVersion must contain a âDescriptionâ field"
Iâm 90% there with the validator, then onto fixing the Osprey outputs. It would be great if you could convert definitions.py into a JSON file that we both can use! Right now Iâve cloned the definitions with a couple rather clunky structs.
The validator worked perfectly on all test data in the nifti-mrs-tools test data repo, and also on a bunch of Osprey-processed NIfTI-MRS files that I just generated from our own example data.
@wclarke One tricky issue that might be out of reach for me to fix is forcing to write TR, TE and the transmitter offset as floats when they are in fact integer numbers. This is taken care of by a MATLAB JSON writer in the dcm2nii package we use. It looks like, in my example data, TR is still written out as 2. Upon reading in again, the MATLAB JSON reader still parses the 2 as double/float, so when my validator checks for float/double-ness, it thinks everything is correct. Do you think you can relax the requirements to include integers (which, technically, should be allowable for TR/TE/TxOffset)?
Also note that Osprey is only writing out the standard defined parameters that we currently parse, which doesnât, by default, include things like PatientWeight. If thatâs important to people, I can further work on the headers.
Great. Iâll a) translate the python definitions to a generic one and b) make the python interpretation match that of the standard which only specifies ânumberâ (so int/float are allowable where appropriate). I have a bit of time to start this tomorrow.
@Hanna Thanks for the data. I found the issue, and Iâll also fix that tomorrow in nifti-mrs-tools as a more immediate solution.