Dcm2bids is an open-source tool that converts DICOM imaging data to NIfTI format with dcm2niix and organizes the results according to the Brain Imaging Data Structure (BIDS). It is designed to simplify routine DICOM-to-BIDS conversion while remaining flexible for different datasets.
Allocate an interactive session and run the program. Sample session:
[user@biowulf]$ sinteractive
salloc.exe: Pending job allocation 46116226
salloc.exe: job 46116226 queued and waiting for resources
salloc.exe: job 46116226 has been allocated resources
salloc.exe: Granted job allocation 46116226
salloc.exe: Waiting for resource configuration
salloc.exe: Nodes cn3144 are ready for job
[user@cn3144 ~]$ cd /data/$USER
[user@cn3144 ~]$ module load dcm2bids
[+] Loading dcm2bids 3.1.0 on cn0070
[+] Loading singularity 4.3.7 on cn0070
[user@cn3144 ~]$ dcm2bids --help
usage: dcm2bids [-h] -d DICOM_DIR [DICOM_DIR ...] -p PARTICIPANT [-s SESSION] -c CONFIG [-o OUTPUT_DIR]
[--auto_extract_entities] [--bids_validate] [--force_dcm2bids] [--skip_dcm2niix] [--clobber]
[-l {DEBUG,INFO,WARNING,ERROR,CRITICAL}] [-v]
Reorganising NIfTI files from dcm2niix into the Brain Imaging Data Structure
options:
-h, --help show this help message and exit
-d DICOM_DIR [DICOM_DIR ...], --dicom_dir DICOM_DIR [DICOM_DIR ...]
DICOM directory(ies) or archive(s) (tar, tar.bz2, tar.gz or zip).
-p PARTICIPANT, --participant PARTICIPANT
Participant ID.
-s SESSION, --session SESSION
Session ID. []
-c CONFIG, --config CONFIG
JSON configuration file (see example/config.json).
-o OUTPUT_DIR, --output_dir OUTPUT_DIR
Output BIDS directory. [/vf/users/ulloapereza/DCM2BIDS_TEST]
--auto_extract_entities
If set, it will automatically try to extract entityinformation [task, dir, echo] based on the suffix and datatype. [False]
--bids_validate If set, once your conversion is done it will check if your output folder is BIDS valid. [False]
bids-validator needs to be installed check: https://github.com/bids-standard/bids-validator#quickstart
--force_dcm2bids Overwrite previous temporary dcm2bids output if it exists.
--skip_dcm2niix Skip dcm2niix conversion. Option -d should contains NIFTI and json files.
--clobber Overwrite output if it exists.
-l {DEBUG,INFO,WARNING,ERROR,CRITICAL}, --log_level {DEBUG,INFO,WARNING,ERROR,CRITICAL}
Set logging level to the console. [INFO]
-v, --version Report dcm2bids version and the BIDS version.
Documentation at https://unfmontreal.github.io/Dcm2Bids/
[user@cn3144 ~]$ wget -O dcm_qa_nih.zip https://github.com/neurolabusc/dcm_qa_nih/archive/refs/heads/master.zip
--2026-08-18 12:00:40-- https://github.com/neurolabusc/dcm_qa_nih/archive/refs/heads/master.zip
Resolving
Connecting ... connected.
Proxy request sent, awaiting response... 302 Found
Location: https://codeload.github.com/neurolabusc/dcm_qa_nih/zip/refs/heads/master [following]
--2026-08-18 12:00:40-- https://codeload.github.com/neurolabusc/dcm_qa_nih/zip/refs/heads/master
Connecting ... connected.
Proxy request sent, awaiting response... 200 OK
Length: unspecified [application/zip]
Saving to: ‘dcm_qa_nih.zip’
dcm_qa_nih.zip [ <=> ] 9.78M 9.64MB/s in 1.0s
2026-08-18 12:00:41 (9.64 MB/s) - ‘dcm_qa_nih.zip’ saved [10260084]
[user@cn3144 ~]$ unzip dcm_qa_nih.zip
Archive: dcm_qa_nih.zip
6a11dc671ac6a0631585d59c840e7ff364494943
creating: dcm_qa_nih-master/
extracting: dcm_qa_nih-master/.gitignore
creating: dcm_qa_nih-master/In/
creating: dcm_qa_nih-master/In/20180918GE/
inflating: dcm_qa_nih-master/In/20180918GE/README-Study.txt
creating: dcm_qa_nih-master/In/20180918GE/mr_0004/
[...]
inflating: dcm_qa_nih-master/Ref/EPI_PE=AP_3.json
inflating: dcm_qa_nih-master/Ref/EPI_PE=AP_3.nii
inflating: dcm_qa_nih-master/Ref/EPI_PE=LR_6.json
inflating: dcm_qa_nih-master/Ref/EPI_PE=LR_6.nii
inflating: dcm_qa_nih-master/Ref/EPI_PE=PA_4.json
inflating: dcm_qa_nih-master/Ref/EPI_PE=PA_4.nii
inflating: dcm_qa_nih-master/Ref/EPI_PE=RL_5.json
inflating: dcm_qa_nih-master/Ref/EPI_PE=RL_5.nii
inflating: dcm_qa_nih-master/batch.sh
[user@cn3144 ~]$ cat >>config.json< {
> "descriptions": [
> {
> "datatype": "func",
> "suffix": "bold",
> "custom_entities": "task-rest",
> "criteria": {
> "SeriesDescription": "Axial EPI-FMRI (Interleaved I to S)"
> },
> "sidecar_changes": {
> "TaskName": "rest"
> }
> }
> ]
> }
> EOF
[user@cn3144 ~]$ dcm2bids -d dcm_qa_nih-master/In/20180918GE/mr_0004 -p 01 -c config.json -o bids
INFO | --- dcm2bids start ---
INFO | Running the following command: dcm2bids -d dcm_qa_nih-master/In/20180918GE/mr_0004 -p 01 -c config.json -o bids
INFO | OS version: Linux-4.18.0-425.19.3b.el8.x86_64-x86_64-with-glibc2.35
INFO | Python version: 3.10.12 (main, Jun 11 2023, 05:26:28) [GCC 11.4.0]
INFO | dcm2bids version: 3.1.0
INFO | dcm2niix version: v1.0.20230411
INFO | Checking for software update
WARNING | A newer version exists for dcm2bids: 3.2.0
WARNING | You should update it -> https://github.com/UNFmontreal/Dcm2Bids.
WARNING | A newer version exists for dcm2niix: v1.0.20260724
WARNING | You should update it -> https://github.com/rordenlab/dcm2niix.
INFO | participant: sub-01
INFO | config: config.json
INFO | BIDS directory: bids
INFO | Auto extract entities: False
INFO | Validate BIDS: False
INFO | Running: dcm2niix -b y -ba y -z y -f %3s_%f_%p_%t -o bids/tmp_dcm2bids/sub-01 dcm_qa_nih-master/In/20180918GE/mr_0004
INFO | Check log file for dcm2niix output
INFO | SIDECAR PAIRING
INFO | sub-01_task-rest_bold <- 004_mr_0004_DCM2NIIX_regression_test_20180918114023
INFO | Moving acquisitions into BIDS folder "bids/sub-01".
INFO | Logs saved in bids/tmp_dcm2bids/log/sub-01_20260818-120924.log
INFO | --- dcm2bids end ---
[user@cn3144 ~]$ exit
salloc.exe: Relinquishing job allocation 46116226
[user@biowulf ~]$
Create a batch input file (e.g. dcm2bids.sh). For example:
#!/bin/bash module load dcm2bids cd /data/$USER dcm2bids -d dcm_qa_nih-master/In/20180918GE/mr_0004 -p 01 -c config.json -o bids
Submit this job using the Slurm sbatch command.
sbatch [--cpus-per-task=#] [--mem=#] dcm2bids.sh
Create a swarmfile (e.g. dcm2bids.swarm). For example:
dcm2bids -d /data/$USER/dcm2bids-test/dcm_qa_nih-master/In/20180918GE/mr_0004 \ -p 01 -c /data/$USER/dcm2bids-test/config.json -o /data/$USER/dcm2bids-test/bids dcm2bids -d /data/$USER/dcm2bids-test/dcm_qa_nih-master/In/20180918GE/mr_0004 \ -p 02 -c /data/$USER/dcm2bids-test/config.json -o /data/$USER/dcm2bids-test/bids dcm2bids -d /data/$USER/dcm2bids-test/dcm_qa_nih-master/In/20180918GE/mr_0004 \ -p 03 -c /data/$USER/dcm2bids-test/config.json -o /data/$USER/dcm2bids-test/bids
Submit this job using the swarm command.
swarm [-g #] [-t #] --module dcm2bids dcm2bids.swarmwhere
| -g # | Number of Gigabytes of memory required for each process (1 line in the swarm command file) |
| -t # | Number of threads/CPUs required for each process (1 line in the swarm command file). |
| --module dcm2bids | Loads the dcm2bids module for each subjob in the swarm |