This repository contains a Python script designed to anonymise cardiac DTI data, and to convert DICOM data to NIFTI format.
This is going to be the standard procedure to share cardiac DTI data within the Cardiac Diffusion study group (SCMR).
This README describes the steps to install and run the Python script.
Cardiac DTI DICOM data should be converted to NIFTI format without any personal information. A Python script that internally calls the dcm2niix command tool is going to be used for this purpose. This tool exports:
- NIFTI files which contain the pixel values and minimal metadata information
- b-values
- diffusion directions
- Extra metadata in a JSON file.
- CSV file with adjusted b-values (STEAM sequences only)
Note
The diffusion direction files given by dcm2niix
are already rotated to the image plane.
Warning
At the moment we do not support enhanced multi-image DICOMs.
Install the dcm2niix
tool. More information on how to install it can be
found in this link.
We need a recent version of Python 3 installed. This script has been tested on Python 3.10 (macOS).
Check this link for Python installation instructions if you don't have Python 3 installed in your system.
Clone or download this repository, go to the repository folder and create a virtual environment and install the dependencies with the following terminal commands:
git clone https://github.com/ImperialCollegeLondon/cdti_data_export.git
cd cdti_data_export
python -m venv .venv
source .venv/bin/activate
pip install -U pip setuptools wheel pip-tools
pip install -r requirements.txt
We will need the full path for the input and output folders.
<input_folder>
is the path to the folder where the DICOM files are located.<output_folder>
is the path to the folder where the nii files will be created.
Warning
Make sure you are using the python virtual environment created in the repository folder. You can use the following commands to activate it:
cd <repository_folder>
source .venv/bin/activate
Then run the following command:
# for SE data
python cdti_data_export.py <input_folder> <output_folder>
# for STEAM data
python cdti_data_export.py <input_folder> <output_folder> steam
The <output_folder>
should contain one or multiple:
- NIFTI files:
*.nii
- b-values:
*.bval
- diffusion directions:
*.bvec
- Extra metadata:
*.json
- adjusted b-value tables
*.csv
(STEAM sequences only)
Please double check if no private data is present in the output files, including acquisition date and time.