Reorganize fmri files to make them BIDS compliant.
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.


Data2Bids is a python3 package that converts fmri files from any extension into NIfTI and then make them Brain Imaging Data Structure compliant. The user specify how the files should be read into a directory. Then the tool scan all the files and move them into the right directories.

Disclaimer: This tool is intended to convert data other than DICOM. If you have DICOM data, please use more recognized tools as heudiconv or Dcm2Bids


A directory containing some files in any extension, with names containing at minimum the information of modality and patient number. A .JSON configuration file explaining how the filenames should be read.


A directory as specified by the BIDS standard. BIDS validator is used to check the conformity of the output.


A directory MyDataset with the following files :

└── adhd_41278_FU12_T1_001.mnc
└── adhd_41278_FU24_T1_001.mnc
└── adhd_41578_BL00_RSFMRI_001.mnc
└── adhd_41578_BL00_RSFMRI_002.mnc

Will be transformed as :

└── sub-41278/
|   |
|   └── anat/
|       |
|       └── adhd_41278_FU12_T1_001.nii
|       |
|       └── adhd_41278_FU24_T1_001.nii
└── sub-41578/
    └── func/
        └── adhd_41578_BL00_RSFMRI_001.nii
        └── adhd_41578_BL00_RSFMRI_002.nii


The package is using heuristics on the filenames to see how files should be reorganized. You will first probably need to write your own configuration file. Please take example from this file :

The first mandatory field is dataFormat which specify what is the extension of the images in your input folder. Data2Bids accept all file formats available in nibabel.

If you have NIfTI files, you can choose to whether compress the data or not. If the files are not NIfTI, then the compression in .nii.gz is done automatically.

repetitionTimeInSec and delayTimeInSec are two mandatory fields needed by bids, because of some issues with nibabel, this field is asked to the user.

The remainind fields correspond to bids structure. For each of them you need to specify what content match for what type, with the left and right delimiter with perl regexp format.

For example with adhd_41578_NAPBL00_RSFMRI_001.mnc if you want to match:

  • the fmri field, you need to specify the left and right delimiter _ and the content RSFMRI.
  • the run number, the left delimiter is _ but the right is . with content [0-9]{3} which means match exactly 3 integers.
  • the session BL00, you can use left delimiter _.*? (match a _ and everything after), right delimiter _ with content BL00.

Everything shoud be in a list. For structural mri anat, functionnal mri func and tasks func.task, we use a sub-list to indentify the image sub-type (to differentiate T1w and T2w for example).



with pip

pip3 install data2bids

with container

Docker and singularity comming soon


If you have your configuration file config.json in the directory myFmriData where your data is just do:

cd myFmriData

The resulting bids directory will be myFmriData/myFmriData_BIDS.

If no configuration file is given, it will load You can also use -c to provide a path to the configuration.

To change the input directory use -d, you can also change the output bids directory with -o.