Converting to BIDS in MATLAB

Hi everyone,

I want to convert my ASL data to BIDS format in MATLAB, I tried exploreASL but didn’t work properly? Can someone introduce me a toolbox to do it? I really appreciate it!

cc @jan-petr for ExploreASL and @Remi-Gau for BIDSMatlab ( :slight_smile:


I know exploreASL uses bids-matlab under the hood. But happy to help troubleshoot issues you might have though I am sure @jan-petr will know more than me for the ASL details.

1 Like

I would suggest dicm2nii which has an option for BIDS output. Depending on the manufacturer of your MRI system, you may need to add a lot of details to your JSON sidecars. In many cases the DICOMs do not provide the details required for thorough analyses.

 dicm2nii('/path/to/dicoms', '/path/for/output', 'bids')

dcm2nii is indeed the most robust option although you might need to fill in the BIDS fields that are missing in the DICOMs.

ExploreASL uses dcm2nii under the hood and can make the process of filling the missing BIDS fields easier, especially if you have more datasets. It might indeed be tricky to configure, but it should work in general. I’d be happy to help you solve the issues you’re having with it.


Just to clarify, dcm2niix (and its predecessor dcm2nii) are standalone executables. While dcm2niix creates BIDS-compatible sidecars, it does not create the file and folder naming structure for BIDS. There are several wrappers in various languages that provide this functionality. ExploreASL uses dcm2niix.

In contrast, dicm2nii is a Matlab script written by Xiangui Li. It is completely independent of dcm2niix. It is able to convert DICOM data directly to BIDS.

Therefore, dicm2nii and dcm2niix are completely independent tools. The disadvantage of dicm2nii is that it depends on either the proprietary Matlab or the free Octave. The advantage of dicm2nii is that it is written in a higher level language that is easier to script and modify. Since you mentioned you were looking for a Matlab solution, I would recommend dicm2nii.

While both dicm2nii and dcm2niix fill the same niche, they are independent code.

ASL is a tricky case, the BIDS BEP005 is very new, and many of the required fields are not available in the source DICOM. You may want to try both dcm2niix and dicm2nii and see which does a better job with your data. You should also make sure you have the latest version of each tool. The recent release of dcm2niix (v1.0.20211006 does include a much richer BIDS sidecar for ASL, in particular for data from a Siemens scanner. In general, Philips DICOM images provide very little ASL meta data, so you will have to add a lot of details manually. For General Electric scanners, the product ASL sequences are clever in that they do a lot of computations in K-space, but that means the raw images are not available for ExploreASL. If you use a GE scanner, and want to use FSL’s BASL or ExploreASL, you will need to get a research sequence installed.


Thank you so much for your reply! I’m trying to run it on my dataset. This the way I tried it,
I ran this command first:

[x] = ExploreASL(‘drive/…/datasetRoot’, [1 0 0 0], 0, 0, 1, 1);
The datasetroot contains studyPar.json, sourceStructure.json, and a folder named source data containing all DICOM files for only one participant. (dual echo ASL).
But the final temp folder is empty! I do not know where is the problem!

Thanks Chris!
My problem is that I don’t know where and what kind of information I need to add!

Thanks Remi, I do need help with ExploreASL! Have you worked with it? to convert data?

Actually I have not. Not yet.

I am sort of planning to check several BIDS converters in general to get a better idea of their pros and cons but I have not yet had the time.

This sounds like that the folder structure doesn’t match its description in sourceStructure.json. Can you contact me at j.petr(at), or paste the screenshots of these files/directory tree here?