Skip to content
master
Switch branches/tags
Code

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 
bin
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Data2Bids

Data2Bids is a python3 package that converts fmri files from extension supported by nibabel 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. It also does not handle properly the headers of the images (we rely entirely on nibabel). Finally, do not use this tool for too complicated raw data structures, in this case you should use a GUI converter like bidscoin.

Input

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.

Output

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

Example

A directory MyDataset with the following files :

MyDataset/
|
└── adhd_41278_FU12_T1_001.nii
|
└── adhd_41278_FU24_T1_001.nii
|
└── adhd_41578_BL00_RSFMRI_001.nii
|
└── adhd_41578_BL00_RSFMRI_002.nii

Will be transformed as :

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

Heuristic

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 : https://github.com/SIMEXP/Data2Bids/blob/master/example/config.json

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).

(*) Do not forget to use an escape character to match for example a "."

Dependencies

Install

with pip

pip3 install data2bids

with container

Docker and singularity comming soon

Usage

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

cd myFmriData
data2bids

The resulting bids directory will be myFmriData/myFmriData_BIDS.

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.

About

Reorganize fmri files to make them BIDS compliant.

Resources

License

Releases

No releases published

Packages

No packages published