Skip to content

Converting DICOMs to BIDS NIfTIs

Sriranga Kashyap edited this page Nov 15, 2022 · 2 revisions

Prerequisites

  1. Python 3 (Anaconda)
  2. VS Code sudo snap install code --classic
  3. YAML support for VS Code code --install-extension redhat.vscode-yaml, code --install-extension docsmsft.docs-yaml
  4. dcm2niix (rordenlab)

Install using Pip

  1. Create a conda virtual environment conda create --name bidscoin python=3.8

  2. Activate the virtual environment: conda activate bidscoin

  3. Install BIDScoin pip install bidscoin

User Guide

The fantastic four

  1. dicomsort.py Sorts and/or renames DICOMs in my_dicomsfolder into sub-directories my_dicomsfolder/SeriesNumber-SeriesDescription
  2. bidsmapper.py Creates a bidsmap.yaml YAML file in my_bidsfolder/code/bidscoin
  3. bidseditor.py Launches a GUI for looking at and small manual tweaking of the bidsmap.yaml
  4. bidscoiner.py Converts bidsmap into BIDS NIfTIs

Steps

Prepare

  1. DICOMs from the study are to be in folders, e.g. sub-01 , …. If not, do so. These sub-0* folders are in the parent (study-level) directory, e.g. my_dicomsfolder
  2. Activate conda environment conda activate bidscoin

BIDScoin workflow

Step-1: Sort DICOMs

Run dicomsort.py my_dicomsfolder/sub-01

Sorts DICOMs into sub-directories with SeriesNumber-SeriesDescription created: my_dicomsfolder/sub-01/001- , my_dicomsfolder/sub-01/002- , etc..

Step-2: Make a BIDSmap

Run bidsmapper.py ./my_dicomsfolder ./my_bidsfolder

Makes a BIDsmap and launches the bidseditor.py GUI that shows recognised (green) and unrecognised (red) data-modalities.
A bidsmap.yaml file is created in my_bidsfolder/code/bidscoin/.

N.B. for (thus far) BIDS incompatible sequences (MP2RAGE , ASL , VASO , even 3D-EPI)

  1. Manually assign the scan category in the bidseditor.py GUI as anat, func, fmap, etc..

    Click EDIT to manually assign the modality category (adapted from bidseditor_main.png)

    Select the required modality classification from the dropdown menu and click OK (adapted from bidseditor_edit.png)
  2. Save the bidsmap.yaml and close the GUI.
  3. The other fields can be modified in the bidsmap.yaml file using VScode.
  4. The naming scheme can be modified for each sequence a.k.a. provenance.
  5. Modify the labels under bids: such as acq: , mod: etc. or removing labels and replacing them with empty quotes (" ").
  6. Open BIDSeditor and check the changes bidseditor.py ./my_bidsfolder

Tip from Alex
"Make sure to select the suffix that best describes the data from the dropdown menu or in the YAML file. Important if one plans to use fMRIPrep down the line."

Check the my_bidsfolder/code/bidscoin/bidsmap.yaml file for the following and change if necessary:

This needs to be changed to the output of whereis dcm2niix


Example


Change ''-b' to ''-ba' for BIDS sidecar with anonymisation

Step-3: BIDScoin-ing

Run bidscoiner.py ./my_dicomsfolder/ ./my_bidsfolder/

Step-4: BIDS validation

After successful coinage, validate using bids-validator online or locally.

BIDS (in)compatibility

Exact specs for (thus far) BIDS incompatible sequences are still unclear, however, some extension proposals are available.

See here for : MP2RAGE , ASL , SWI , pre-processing derivatives (anatomy) , pre-processing derivatives (functional) , pre-processing derivatives (resting-state) etc..

Full Credit to BIDScoin team at the Donders Insitute

Find them here: BIDScoin Github