-
Notifications
You must be signed in to change notification settings - Fork 1
Converting DICOMs to BIDS NIfTIs
- Python 3 (Anaconda)
- VS Code
sudo snap install code --classic
- YAML support for VS Code
code --install-extension redhat.vscode-yaml, code --install-extension docsmsft.docs-yaml
- dcm2niix (rordenlab)
-
Create a conda virtual environment
conda create --name bidscoin python=3.8
-
Activate the virtual environment:
conda activate bidscoin
-
Install BIDScoin
pip install bidscoin
- dicomsort.py Sorts and/or renames DICOMs in my_dicomsfolder into sub-directories my_dicomsfolder/SeriesNumber-SeriesDescription
- bidsmapper.py Creates a bidsmap.yaml YAML file in my_bidsfolder/code/bidscoin
- bidseditor.py Launches a GUI for looking at and small manual tweaking of the bidsmap.yaml
- bidscoiner.py Converts bidsmap into BIDS NIfTIs
- 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
- Activate conda environment
conda activate bidscoin
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)
- 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) - Save the bidsmap.yaml and close the GUI.
- The other fields can be modified in the bidsmap.yaml file using VScode.
- The naming scheme can be modified for each sequence a.k.a. provenance.
- Modify the labels under bids: such as acq: , mod: etc. or removing labels and replacing them with empty quotes (" ").
- 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.
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..
Find them here: BIDScoin Github