MriBids - MRC CBU Imaging Wiki

Revision 19 as of 2023-12-12 18:23:33

Clear message
location: MriBids

Table of contents:

Converting MRI DICOM data to BIDS format

To start working with your MRI data, you need to convert the raw DICOM format data to NIfTI format and organise them according to the BIDS standard.

Where is your raw data

The raw data that come from the MRI scanner are stored at /mridata/cbu/[your project code]. You can see all your participant scan directories with a command like this (replace 'MR09029' with your project code):

ls -d /mridata/cbu/*_MR09029/*

/mridata/cbu/CBU210700_MR21002/20211208_143530/
/mridata/cbu/CBU210711_MR21002/20211213_103712/
/mridata/cbu/CBU220006_MR21002/20220106_115411/
/mridata/cbu/CBU220011_MR21002/20220107_125238/
...

The first part of the folder name which follows the project code, is the acquisition date. E.g., the data of the first subject in the example above was acquired on 08/12/2021 ('20211208'). Each subject's folder contains data like this:

ls /mridata/cbu/CBU210700_MR21002/20211208_143530

Series001_64_Channel_Localizer/
Series002_CBU_MPRAGE_64chn/
Series003_bold_mbep2d_3mm_MB2_AP_2_SBRef/
Series004_bold_mbep2d_3mm_MB2_AP_2/
Series005_bold_mbep2d_3mm_MB2_AP_2_SBRef/
Series006_bold_mbep2d_3mm_MB2_AP_2/
Series007_bold_mbep2d_3mm_MB2_AP_2_SBRef/
Series008_bold_mbep2d_3mm_MB2_AP_2/
Series009_bold_mbep2d_3mm_MB2_AP_2_SBRef/
Series010_bold_mbep2d_3mm_MB2_AP_2/
Series011_bold_mbep2d_3mm_MB2_PA_2_SBRef/
Series012_bold_mbep2d_3mm_MB2_PA_2/
Series013_fieldmap_gre_3mm_mb/
Series014_fieldmap_gre_3mm_mb/

Each Series### folder contains DICOM files of the particular scan. The name of the folder is the same as what a radiographer named the scan in the MRI console. Usually, the name is very indicative of what type of scan it is. Ideally, you'd also know yourself what type of scans were acquired for your project. In the example above, we acquired a T1w anatomical/structural scan (MPRAGE), five multi-band functional scans with single-band reference scans for each of them, and two field maps.

.. need to convert .. Several conversion tools exist (see a full list here). We recommend using HeuDiConv.

DICOM to BIDS using HeuDiConv

HeuDiConv is available on our computing system as an Apptainer image

/imaging/local/software/singularity_images/heudiconv/heudiconv_latest.sif

Converting DICOM data to BIDS using HeuDiConv involves 3 main steps:

  1. Discovering what type of scans there are in your data
  2. Creating a heuristics file specifying how to translate the scans into BIDS format
  3. Converting the data

Step 1: Discovering your scans

...

# Your project's root directory
PROJECT_PATH='/imaging/correia/da05/wiki/BIDS_conversion/MRI'
# Location of the raw data
RAW_PATH='/mridata/cbu/CBU210700_MR21002/20211208_143530'
# Location of the output data
OUTPUT_PATH=$PROJECT_PATH/data/work/dicom_discovery/

# Subject ID
subject="01"

# Define the path to DICOM files under the project directory
DICOM_PATH=$PROJECT_PATH/data/dicom

# Define the path where to save  the output data
OUTPUT_PATH=$PROJECT_PATH/data/work/dicom_discovery/

# Which subject to process
sid="01"

# Load the apptainer module
module load apptainer

# Run the container
apptainer run --cleanenv -B "${PROJECT_PATH},${RAW_PATH}" \
    /imaging/local/software/singularity_images/heudiconv/heudiconv_latest.sif \
    --files "${RAW_PATH}"/*/*.dcm \
    --outdir "$OUTPUT_PATH" \
    --heuristic convertall \
    --subjects "${subject}" \
    --converter none \
    --bids \
    --overwrite

# ============================================================
# HeudiConv parameters:
# --files: Files or directories containing files to process
# --outdir: Output directory
# --heuristic: Name of a known heuristic or path to the Python script containing heuristic
# --subjects: Subject ID
# --converter : dicom to nii converter (dcm2niix or none)
# --bids: Flag for output into BIDS structure
# --overwrite: Flag to overwrite existing files
# ============================================================

# Unload the apptainer module
module unload apptainer

Step 2: Creating heuristics file

...

Example 1

...

Example 2

...

Step 3: Converting the data

...

[da05@login-j05 MRI]$ squeue -u da05
             JOBID PARTITION     NAME     USER ST       TIME  NODES NODELIST(REASON)
         3246338_0      Main heudicon     da05  R       0:06      1 node-k08
         3246338_1      Main heudicon     da05  R       0:06      1 node-k08
         3246338_2      Main heudicon     da05  R       0:06      1 node-k08
         3246338_3      Main heudicon     da05  R       0:06      1 node-k08

More examples

...

Functional scans with `sbref`

...

ls /mridata/cbu/CBU210700_MR21002/20211208_143530

Series001_64_Channel_Localizer/
Series002_CBU_MPRAGE_64chn/
Series003_bold_mbep2d_3mm_MB2_AP_2_SBRef/
Series004_bold_mbep2d_3mm_MB2_AP_2/
Series005_bold_mbep2d_3mm_MB2_AP_2_SBRef/
Series006_bold_mbep2d_3mm_MB2_AP_2/
Series007_bold_mbep2d_3mm_MB2_AP_2_SBRef/
Series008_bold_mbep2d_3mm_MB2_AP_2/
Series009_bold_mbep2d_3mm_MB2_AP_2_SBRef/
Series010_bold_mbep2d_3mm_MB2_AP_2/
Series011_bold_mbep2d_3mm_MB2_PA_2_SBRef/
Series012_bold_mbep2d_3mm_MB2_PA_2/
Series013_fieldmap_gre_3mm_mb/
Series014_fieldmap_gre_3mm_mb/

In this example, researchers acquired a T1w anatomical/structural scan (MPRAGE), five multi-band functional scans with single-band reference scans for each of them, two field maps, and ...

Multiple sessions per subject

...

Code examples

code_examples on GitHub