A preprocessing and analysis pipeline for Dynamic Contrast-Enhanced (DCE) MRI data. Handles VFA-based T1 mapping, bias field correction, z-axis normalization, motion correction, AIF selection, and Ktrans parameter mapping, with automated QC reporting.
Barnes S, et al. Automated DCE-MRI processing with DCEPrep for Blood-Brain Barrier permeability in a multi-site aging study. Pending. 2026.
Clone the repository. The main branch is stable. Check out a specific tag for a pinned release.
git clone https://github.com/petmri/DCEPrep.gitThe easiest way to get started is with the included run_docker.sh script, which will automatically pull the Docker image and launch a container.
Important: Make sure the following are shared (mounted) with the Docker container:
- MATLAB license file
- FreeSurfer license file
- Your data directory
- Script preference folder (
docker/files/)/etc/Edit line 24 of
run_docker.shto set your data directory before running.
./run_docker.shTo pull the image manually:
docker pull lsaca05/dce:<MATLAB_release>-<branch>
# Example:
docker pull lsaca05/dce:R2022a-devSee Docker Hub tags for available releases.
Setup a Python virtual environment and install dependencies from venv_requirements.txt:
cd DCEPrep
python3 -m venv tf
source tf/bin/activate
pip install -r venv_requirements.txtconda is also supported — install packages from venv_requirements.txt into your conda environment.
If running without Docker, in addition to the Python packages in venv_requirements.txt, the following software must be installed and accessible in your system's PATH:
| Dependency | Version / Notes |
|---|---|
| FSL | 6.0 |
| ANTs | 2.6.2 |
| FreeSurfer | Linux-centos6_x86_64-stable-pub-v6.0.0-2beb96c (wm parcellation) |
| MATLAB | R2023a |
| Python | 3.8.10 or 3.10 |
| ROCKETSHIP + parametric_scripts | 1.2 |
All data is assumed to be BIDS compliant.
| File | Pattern |
|---|---|
| VFA images (any number of flip angles) | sub-##_ses-##_flip-##_VFA.nii.gz |
| DCE image | sub-##_ses-##_DCE.nii.gz |
| T1-weighted image | sub-##_ses-##_T1w.nii.gz |
| File |
|---|
dce/sub-##_ses-##_desc-bfcz_DCE.nii.gz |
anat/sub-##_ses-##_space-DCEref_T1map.nii |
anat/sub-##_ses-##_space-DCEref_VFA.nii.gz |
dce/sub-##_ses-##_desc-AIF_T1map.nii.gz |
anat/sub-##_ses-##_space-DCEref_desc-brain_mask.nii.gz |
| Flag | Description |
|---|---|
-d [rawdata_path] |
Required. Path to your BIDS raw data folder. |
-a [suffix] |
AIF suffix (default: desc-AIF_mask). .nii.gz is appended automatically. |
-A [mode] |
Enable AutoAIF: A (fully automatic), M (manual if available), or T (manual + training if available). Requires the vascular_function repo and weights. |
-b |
Enable first round of bias field correction. |
-B |
Enable second round of bias field correction (post-Z-norm, if enabled). |
-c |
Clean the case's derivative folder before processing. Ensures fresh runs but disables skips. |
-C [name] |
Enable comparison mode. Outputs all files to a named directory within each timepoint. Useful for comparing runs (e.g., no corrections vs. corrections). |
-m |
Enable motion correction. |
-s |
Skip preprocessing if DCE input file already exists. |
-t |
Only run up to T1 mapping. |
-T [dir_path] |
Target specific subject(s)/session(s) (default: sub-*/ses-*/). |
-w [path] |
Path to AutoAIF weights file. |
-Z |
Enable z-slice normalization. |
./preprocess_all.sh -d /path/to/data/bids_data -b -c -Z -A -C noMC- Brain Extraction of T1w MPRAGE using
HD-BETwith default weights (does not brain mask VFAs). -
DCE Motion Correction — FSL
mcflirt, targeting 2nd frame with mutual info cost functionmcflirt -in $source_dir/dce/${PREFIX}_DCE.nii.gz -refvol 1 -cost mutualinfo -report -plots -o dce/${PREFIX}_desc-hmc_DCE.nii -
MPRAGE → DCE Registration — ANTs
antsRegistrationantsRegistration --verbose 0 --dimensionality 3 --float 0 --collapse-output-transforms 1 --output [ anat/${PREFIX}_${REF_SPACE}_T1w,anat/${PREFIX}_${REF_SPACE}_T1w.nii.gz ] --interpolation Linear --use-histogram-matching 0 --winsorize-image-intensities [ 0.005,0.995 ] --transform Rigid[ 0.1 ] --metric MI[ $DCE_REF_VOL,${source_dir}/anat/${PREFIX}_T1w.nii.gz,1,32,Regular,0.25 ] --convergence [ 1000x500x250x100,1e-6,10 ] --shrink-factors 12x8x4x2 --smoothing-sigmas 4x3x2x1vox -
VFA → DCE Registration — ANTs
antsRegistrationantsRegistration --verbose 0 --dimensionality 3 --float 0 --collapse-output-transforms 1 --output [ anat/${PREFIX}_flip-${VFA}_${REF_SPACE},anat/${PREFIX}_flip-${VFA}_${REF_SPACE}_VFA.nii.gz ] --interpolation Linear --use-histogram-matching 0 --winsorize-image-intensities [ 0.005,0.995 ] --transform Rigid[ 0.1 ] --metric MI[ $DCE_REF_VOL,$source_dir/anat/${PREFIX}_flip-${VFA}_VFA.nii.gz,1,32,Regular,0.25 ] --convergence [ 1000x500x250x100,1e-6,10 ] --shrink-factors 12x8x4x2 --smoothing-sigmas 4x3x2x1vox -
MPRAGE White Matter Segmentation — FSL
fastfast -t 1 -n 3 -H 0.1 -I 4 -l 20.0 -b --nopve -g -o anat/${PREFIX}_label- anat/${PREFIX}_desc-brain_T1w.nii.gz - Apply MPRAGE → DCE transform to WM mask — ANTs
antsApplyTransforms -
VFA Bias Field Correction — FSL
fastfast -t 1 -n 3 -H 0.1 -I 4 -l 20.0 -B --nopve -o anat/${PREFIX}_${VFA}_${REF_SPACE}_desc-brain_VFA.nii.gz - VFA Z-axis Normalization — double Gaussian fitting (
VFA_norm.py) - Second VFA Bias Field Correction — FSL
fast - T1 Map Generation — ROCKETSHIP
- Apply MPRAGE → DCE transform to brain mask — ANTs
antsApplyTransforms - AIF Drawing via Neural Network — ensures AIF is included within the brain mask
-
DCE Bias Field Correction — averages bias fields from the 1st + 8 evenly spaced temporal samples via FSL
fastfast -t 1 -n 3 -H 0.1 -I 4 -l 20.0 -b --nopve -o rep_$((rep_interval*i-1)).nii - DCE Z-axis Normalization — double Gaussian fitting (
DCE_norm.py)
| File |
|---|
dce/sub-##_ses-##_desc-bfcz_DCE.nii.gz |
anat/sub-##_ses-##_space-DCEref_T1map.nii |
anat/sub-##_ses-##_space-DCEref_VFA.nii.gz |
dce/sub-##_ses-##_desc-AIF_T1map.nii.gz |
anat/sub-##_ses-##_space-DCEref_desc-brain_mask.nii.gz |
| File |
|---|
sub-##_ses-##_Ktrans.nii |
sub-##_ses-##_vp.nii |
case_report.html |
population_report.html |
| Flag | Description |
|---|---|
-d [path] |
Required. Path to raw BIDS data directory. |
-C [name] |
Enable comparison mode. Copies essential files from a standard run if a preprocessed run of the same name does not exist. |
-f |
Enable FreeSurfer WM parcellation for subregion analysis. |
-s |
Skip cases already processed. |
-S |
Enable smoothing of DCE input. |
-T [dir_path] |
Target specific subject(s)/session(s) (default: sub-*/ses-*/). |
./DCE_all.sh -d /path/to/data/bids_data -s -C noMC- Ktrans Mapping — ROCKETSHIP
- Gray Matter & CSF Masking — create, align, and apply masks with
antsApplyTransformsandfslmaths - QC Analysis — run
ktrans_analysis.pyandktrans_report.py - Case Report — generate
case_report.htmlfor each case viacase_report.py - Population Report — after all cases finish, generate
population_report.htmlviapopulation_report.py
