Skip to content

proc_dicom2bids

rcruces edited this page Aug 31, 2023 · 1 revision

From DICOMS to BIDS: mic2bids

For further information about how to generate a BIDS conform dataset check our resources in micapipe ReadTheDocs: mica2bids

the information below this line is DEPRECATED...

dicoms to BIDS

This wiki shows you step by step how to convert your fMRI data (dicoms) into the right format (BIDS specification) for anatomical, functional and diffusion analyzes.

How the script works

mica_dicomToNifti = This function converts the DICOMS to nifti format and stores the nifti files in the folder specified by the user.

mica_bidsStructure = This function first creates the BIDS folders ('anat', 'func', 'dwi' and 'fmap') and subsequently moves the corresponding nifti files into the correct folder.

Preparation to run the script

First of all, you need to complete some preparation steps :

  1. Download the mic2bids script (or use the clone version), that you can find in this directory : /micasoft/pipelines/09_bids_micaProcessing
  2. Download dcm2niix
  3. Create a BIDS directory in your folder
  4. Specify the directory of micasoft in your bash_profile export MICASOFT_DIR="<DIRECTORY OF YOUR MICASOFT FOLDER>"

Change the regular expression

In the mic2bids script, you will have to modify the regular expressions, in order to register the names of folders that contain your dicoms files (your original folders). You need to change the regular expressions to put the name of your original folders (dicoms) for anatomical and functional data (orig=) and for DWI data (origDWI=).

Examples of regular expressions : orig=("*_ORIG" "*_T1_Images" "*rsfmri-3mm-bold_AP" "*rsfmri-3mm_se_AP" "*rsfmri-3mm_se_PA")

origDWI=("*dwi_b700_40" "*dwi_b300_10" "*dwi_b0_5PA" "*_dwi_b2000*")

Change the BIDS-naming

After, you must create the names of your new files, in BIDS format, for anatomical, functional and diffusion data. Each of your dicoms files must have a new name in BIDS format. It's very important to follow the specifications surrounding the BIDS format for the names of your files so that your database is valid. You will find the BIDS specifications here. Like with regular expressions, you need to change the BIDS-naming for anatomical and functional data (bids=) and for DWI data (bidsDWI=).

Examples of BIDS-naming : bids=(T1w T1map task-rest_acq-AP_bold task-rest_acq-APse_bold task-rest_acq-PAse_bold)

bidsDWI=(acq-b700_dir-NUM_dwi acq-b300_dir-NUM_dwi acq-PA_dir-NUM_dwi acq-b2000_dir-NUM_dwi)

Run the mic2bids script

When all this steps are done, you can run the script in your terminal. You will need to specify these elements:

  1. Identification of your subject < SUBJ_ID >
  2. Path of your dicoms data folder, with specification for your subject < DICOMS PATH OF YOUR SUBJ >
  3. Path of your BIDS data folder < BIDS PATH >

bash mic2bids -id <SUBJ_ID> -in <DICOMS PATH OF YOUR SUBJ> -bids <BIDS PATH>

Example : bash mic2bids -id Subj17 -in /Users/name.of.my.computer/Documents/My_Data/sourcedata/Subj17 -bids /Users/name.of.my.computer/Documents/My_Data/BIDS_Data

Output of this script

With this script, each participants will have there one folder, that will contains :

  1. Anatomical folder (.json .nii)
  2. DWI folder (.bval .bvec .json .nii)
  3. Functional folder (.json .nii)
  4. (Optional) Fieldmap folder (.json .nii)

A file (participants.tsv) will be created in your BIDS path by the script. This file will show you the name of your BIDS subject folders and the number of nifti files that have been create with the script.

As you can see, there are others files in the BIDS folder. These are files that you must create.

  1. participants.tsv : this file is automatically create with the script, but you need to modify it. You can add all the datas you want to include in your analyzes (e.g. age, sex, group, etc.). This file have to be in tsv (Tabulation-separated value) format.
  2. participants.json : You must then create a .json file in order to define each variable that you included in the previous file.
  3. dataset_description.json ; README ; CHANGES : Files you need to create to define your dataset.
  4. task-rest_bold.json : A file you need to create to define some specifications of your experimental task.

To learn more about this different files and the specifications to respect for the BIDS format, consult this page

Validation of your dataset

You can now validate your BIDS directory here. You will be able to see if your dataset corresponds to the BIDS format. To comply with the BIDS format, we must be very specific with filenames and follow the specifications required to harmonize the data sets. The BIDS validator will tell you if you have errors and how to fix them to fully match your dataset to the BIDS format.

Clone this wiki locally