QSM pipeline: raw/matlab 2 bids

Hello Everyone!

I was wondering what is the best path to take from Siemens’ raw data (.dat files) or Matlab files (.mat) to generate a BIDS file format. Is there a toolbox for this? or what would be your suggestions in this regard?
I’m doing prospective undersampling to ME-GRE images @ 7T and then I reconstruct the missing information using Matlab codes. Anyway, I think that it would be ideal for me and my research to grab the data from both formats, convert them to bids and run the QSM pipeline to check results.
Thanks for your time!
Gabriel

Off the top of my head, no, I haven’t seen any BIDS conversion tool that starts with either proprietary raw data or matlab files. Half of BIDS is just the filename and file structure, so you should be able to recreate that easily enough if you can get your files into nifti format. The other half of BIDS, though, is reliant on the scan parameter information usually contained within the DICOM header.

I might try asking around at CFMM to see if they have Siemens .dat to DICOM converter code, or if they know who potentially to ask if such code exists.

Otherwise, Matlab has pretty decent support for reading in and writing out DICOMs (https://www.mathworks.com/matlabcentral/answers/321634-converting-mat-file-to-dicom-file).

1 Like

Skipping dicom altogether would probably be the preferred route, e.g. write your code to read in .dat/.mat files and write out nifti and json.

Matlab has built-in nifti (niftiwrite) and json support (jsonencode), so should be pretty easy to adapt your code to spit out a nifti/json pairs.

As for how to structure the filenames and json data, the quantitative MRI extension to bids is now part of the main standard – I haven’t actually used it myself yet, but some details are here:
https://bids-specification.readthedocs.io/en/stable/99-appendices/10-file-collections.html

I’m happy to help out along the way, also cc-ing @tristankk too

Just to echo what’s been said, most automatic BIDS conversion software I’m aware of works from DICOMs with reconstructed data, but it shouldn’t be too much work to convert your reconstructed images to NIfTIs. Accurately filling out complete JSON metadata and structuring the files will probably be a bit more labour intensive but also straightforward.

The BIDS Starter kit has a couple of example scripts for generating the JSON metadata here.

In any case, I’d be happy to take a more active role in helping you write a script for this if necessary. Let me know!

As others have said, BIDS is designed to organize raw image data. Since the Siemens raw data in the .dat file is unreconstructioned raw signal it needs to be reconstructed into images which can then be stored in BIDS format. The output of your reconstruction is what needs to be in the BIDS format so it can be used as input to processing pipelines that want BIDS format data, and previous responses outline tools for accomplishing this.

However, If you want an open standard for storing the raw data, e.g. you want to write a generic reconstruction tool that does not depend on proprietary raw data formats, you might want to try https://github.com/ismrmrd/ismrmrd. It was suggests as a possible format for extending BIDS to handle raw data (https://github.com/bids-standard/bids-2-devel/issues/32) and a Siemens to ISMRMD converter is available (https://github.com/ismrmrd/siemens_to_ismrmrd).

Interesting! Thank you all for the comments! I’ll try to investigate in this regard using your posts :smiley: .

Just to add some clarity as to what purpose the JSON files serve in BIDS and why it is difficult to create them from just the nifti data, this forum post from neurostars.org gives a clear explanation:

Basically, the information in the JSON sidecar files contains header information from the DICOM files that is not included in the nifti file header. The advice is when converting directly from nifti to BIDS, you either need access to the original DICOM files or access to the full scanning parameters in order to create the JSON sidecar files.

1 Like