gbarisano / alps

Bash script to compute DTI-ALPS
31 stars 6 forks source link

alps.sh

This is a bash script that automatically computes the diffusion along perivascular spaces (ALPS) metric from diffusion-weighted images (dwi).
The ALPS index has been described by Taoka et al. (Japanese Journal of Radiology, 2017)
As of 2024-02-03, there is a new option (-f) to specify whether the transformation of the tensors to the template space should be performed with FSL flirt/applywarp (default option) or with the FSL function vecreg, as suggested in PMIDs 36472803 and 37162692. The default option remains flirt/applywarp, because according to my data, the ALPS index seems to be more robust this way.

If you use this script, please cite our work AND report the link to this repository:

If you have any question, please contact me: barisano [at] stanford [dot] edu.

Table of contents

Required libraries

This script assumes that FSL and MRtrix3 are in your $PATH.

Required inputs

You must define these elements (except when -s 1, read Optional arguments):

Optional inputs

A second dwi dataset with opposite phase encoding (PE) direction to correct for susceptibility-induced distortions. To correct for susceptibility-induced distortions, the user must define the following 4 additional inputs:

Optional arguments

If the user does not specify these options, the script will use the default argument for each of them (see below)

Outputs

IMPORTANT: If Eddy current correction outputs are not present in the output folder, it means that the DTI fitting has been performed EITHER on preprocessed (denoised and/or unringed) input(s) OR on raw dwi input(s) if preprocessed data are not present in the output folder. If TOPUP correction outputs are not present in the output folder, it means that NO TOPUP correction has been applied (see the log for understanding the reason why).

Examples of usage

1. ALPS analysis with 1 dwi input.

alps.sh -a my_4D_dwi.nii.gz -b my_bval_file -c my_bvec_file -m my_bids_file.json

This command will preprocess my_4D_dwi.nii.gz (denoising and unringing, i.e. default option -d), perform eddy current correction on the preprocessed data, and compute the ALPS index using the provided default ROIs on FSL template JHU-ICBM-FA-1mm.nii.gz. The output folder will be called with the default name "alps" and will be located in the same folder as the input.

2. ALPS analysis with 2 dwi inputs with opposite PE direction and B0 image as first volume in both inputs.

alps.sh -a dwi_PA.nii.gz -b id_PA.bval -c id_PA.bvec -m id_PA.json -i dwi_AP.nii.gz -j id_AP.bval -k id_AP.bvec -n id_AP.json

This command will preprocess both dwi_PA.nii.gz and dwi_AP.nii.gz (denoising and unringing, i.e. default option -d), perform TOPUP and eddy current correction on the preprocessed data, and compute the ALPS index using the provided default ROIs on FSL template JHU-ICBM-FA-1mm.nii.gz. The output folder will be called with the default name "alps" and will be located in the same folder as the FIRST input.

3. ALPS analysis with 1 dwi input, in native space (-t 0), and customized output folder (-o my_output_folder).

alps.sh -a my_4D_dwi.nii.gz -b my_bval_file -c my_bvec_file -m my_bids_file.json -t 0 -r proj_L.nii.gz,proj_R.nii.gz,assoc_L.nii.gz,assoc_R.nii.gz -o my_output_folder

This command will preprocess my_4D_dwi.nii.gz (denoising and unringing, i.e. default option -d), perform eddy current correction on the preprocessed data, and compute the ALPS index in native space (-t 0) using the ROI files defined by the user, which MUST be in native space. The output folder will be "my_output_folder".

4. ALPS analysis with 1 dwi input in native space (-t 0) after drawing ROIs on the output dti_FA.nii.gz.

This is a 3-step process:

  1. alps.sh -a my_4D_dwi.nii.gz -b my_bval_file -c my_bvec_file -m my_bids_file.json -r0 -o my_output_folder
    This command will preprocess my_4D_dwi.nii.gz (denoising and unringing, i.e. default option -d), perform eddy current correction on the preprocessed data, and output only the DTI fitting files in "my_output_folder".
  2. Draw the ROIs in the generated FA map (native space): myroi1_native.nii.gz, myroi2_native.nii.gz, myroi3_native.nii.gz, myroi4_native.nii.gz
  3. alps.sh -a my_4D_dwi.nii.gz -t 0 -s 1 -o my_output_folder -r myroi1_native.nii.gz,myroi2_native.nii.gz,myroi3_native.nii.gz,myroi4_native.nii.gz This command will skip all preprocessing steps and the DTI fitting step (-s 1) and will use the DTI fitting output files previously generated in "my_output_folder" to compute the ALPS index in native space (-t 0) using the user-defined ROIs (-r myroi1_native.nii.gz,myroi2_native.nii.gz,myroi3_native.nii.gz,myroi4_native.nii.gz).
    The option -a my_4D_dwi.nii.gz is not required in this latest command, but is only needed to add the ID in the final CSV output file with the ALPS index.

5. ALPS analysis without denoising and unringing (e.g., in case MRtrix3 is not available).

alps.sh -a my_4D_dwi.nii.gz -b my_bval_file -c my_bvec_file -m my_bids_file.json -d 0 -r 1 -t 1

This command will perform ONLY eddy current correction on the RAW dwi input data (not denoised nor unringed), and compute the ALPS index using the provided default ROIs on FSL template JHU-ICBM-FA-1mm.nii.gz. The output folder will be called with the default name "alps" and will be located in the same folder as the input.

6. Minimal number of inputs (not recommended if used without the eddy current correction -e 3 option).

alps.sh -a my_4D_dwi.nii.gz -b my_bval_file -c my_bvec_file

This command will preprocess my_4D_dwi.nii.gz (denoising and unringing, i.e. default option -d) and compute the ALPS index using the provided default ROIs on FSL template JHU-ICBM-FA-1mm.nii.gz. Eddy current correction will be applied only if the user specifies the option -e 3 (i.e., using ${FSLDIR}/bin/eddy_correct). If -e 3 is not specified, no eddy current correction will be performed, which is not recommended.