Introduction to the BIDS Standard for Neuroimaging
Introduction
The Brain Imaging Data Structure (BIDS) is a simple and intuitive way to organize and describe your neuroimaging and behavioral data. In this guide, we will walk through the basics of converting a raw MRI dataset into a BIDS-compliant format suitable for machine learning pipelines.
Architecture Overview
graph LR
DICOM(Raw DICOMs) --> Heu(HeuDiConv / dcm2bids)
Heu --> NIfTI(NIfTI Volumes)
Heu --> JSON(JSON Sidecars)
NIfTI --> BIDS(BIDS Directory Tree)
JSON --> BIDS
BIDS --> Val(BIDS Validator)
Val --> ML(Deep Learning Pipeline)
Prerequisites
- Python 3.8+
- Raw DICOM neuroimaging files
dcm2niixanddcm2bidsinstalled
Step 1: Automated Conversion with dcm2bids
While you can manually convert DICOM to NIfTI using dcm2niix, it is far more efficient to automate the BIDS formatting using dcm2bids (or HeuDiConv). First, install the package:
pip install dcm2bids
Next, use dcm2bids_helper to extract the JSON metadata from one of your subjects to build a configuration file.
dcm2bids_helper -d ./raw_dicoms/sub-01/
Create a config.json file to map your specific DICOM series descriptions to BIDS standard naming conventions (e.g., mapping "T1w_MPRAGE" to the anat folder with the _T1w suffix).
{
"descriptions": [
{
"dataType": "anat",
"modalityLabel": "T1w",
"criteria": {
"SeriesDescription": "T1_MPRAGE_SAG"
}
},
{
"dataType": "func",
"modalityLabel": "bold",
"customLabels": "task-rest",
"criteria": {
"SeriesDescription": "RESTING_STATE_fMRI"
}
}
]
}
Finally, run the conversion for your subject:
dcm2bids -d ./raw_dicoms/sub-01/ -p 01 -c config.json -o ./my_bids_dataset/
Step 2: Understand the BIDS Directory Structure
A BIDS-compliant dataset follows a strict hierarchical folder structure. Notice how the JSON sidecars perfectly pair with the NIfTI volumes.
my_dataset/
├── dataset_description.json
├── participants.tsv
├── sub-01/
│ ├── anat/
│ │ ├── sub-01_T1w.nii.gz
│ │ └── sub-01_T1w.json
│ └── func/
│ ├── sub-01_task-rest_bold.nii.gz
│ └── sub-01_task-rest_bold.json
└── sub-02/
└── anat/
├── sub-02_T1w.nii.gz
└── sub-02_T1w.json
Step 3: Validate Your Dataset
Before publishing your dataset or feeding it into a pipeline like fMRIPrep or MONAI, you should always validate it using the BIDS Validator.
npm install -g bids-validator
bids-validator my_dataset/
Conclusion
Adopting the BIDS standard ensures that your medical imaging datasets are interoperable, reproducible, and ready to be consumed by the open-source machine learning community. Using automation tools like dcm2bids scales this process across thousands of patients.