Matlab version of spec2nii?

is there a Matlab version of spec2nii? Or is there a header format file for NII-MRS, with it one can read or write nii-MRS data.

1 Like

dicm2nii can load NIfTI-MRS data.

Basic load code is:

nii = nii_tool('load', 'nii_filename.nii');

% Extract the header and header extensions
hdr = nii.hdr;
hdr_ext = jsondecode(nii.ext.edata_decoded);

% Extract the raw time-domain data
fids = double(nii.img);

Mark

To add to that, we also have read and write functions in Osprey. They are not perfect at this point and haven’t been updated in a while, but they should do most of the job.

@zdnyc I imagine that the recommendations by @admin and @mmikkel will be best, though there is also a minimal example of how to load a NIfTI-MRS file in Matlab here: GitHub - schorschinho/nifti-mrs-matlab: A minimal example demonstrating the import of NIfTI MRS data into MATLAB.

Spec2nii doesn’t handle loading data, only the conversion. There is no MATLAB equivalent, as it’s a command line interface the language it uses isn’t that relevant.

The standard for the file format can be found at mrs_nifti_standard/specification.MD at master · wtclarke/mrs_nifti_standard · GitHub. The only MRS-specific section in the file is the JSON header extension.

1 Like