This repository contains two scripts: tractography.sh
for processing diffusion MRI data to perform tractography and generate the connectivity matrix and count_streamlines.sh
for processing the tractogram and calculating the number of streamlines for each ROI of an atlas.
The scripts can require the following inputs:
- DWI: Diffusion-weighted image (in NIFTI format, multi-shell)
- BVEC: b-vector file
- BVAL: b-value file
- ANAT: Structural image (e.g., T1-weighted, in NIFTI format)
- ATLAS: Atlas file in standard space (in NIFTI format)
- WARP_STD2STRUCT: Warp of the transformation from standard space to structural space (in NIFTI format)
- TRACT_FILE: tract file (.tck)
- REMOVE_TEMP: Flag (0 or 1) for removing temporary files
First, make sure that the scripts have the right permisison to be run, by using chmod:
chmod 755 tractography.sh
chmod 755 count_streamlines.sh
./tractography.sh <DWI> <BVEC> <BVAL> <ANAT> <ATLAS> <WARP_STD2STRUCT> <REMOVE_TEMP>
Example:
./tractography.sh subject1_dwi.nii.gz subject1_dwi.bvec subject1_dwi.bval subject1_t1.nii.gz atlas.nii.gz subject1_std2struct_warp.nii.gz 1
./count_streamlines.sh <DWI> <ANAT> <WARP_STD2STRUCT> <ATLAS> <TRACKS_FILE> <REMOVE_TEMP>
Example:
./count_streamlines.sh subject1_dwi.nii.gz subject1_t1.nii.gz subject1_std2struct_warp.nii.gz atlas.nii.gz tracts.tck 1
- For multi-shell acquisitions, the script uses the "dhollander" method for response function estimation. Other methods might be suited depending on the acquisition. For single-shell acquisitions, it is recommended to change to the "tournier" method.
- For single-shell acquisitions, the
dwi2fod
function should use the "csd" methods instead of the "msmt_csd". - In the
5ttgen
function, it is imperative to use the-nocrop
flag so that the output image has the same size as the input image. Additionally, the-premasked
flag was used since the T1 image was already skull-stripped.
- Ensure all input files exist and are in the correct format.
- Check if FSL and MRtrix3 are correctly installed and available in your path. MRtrix3 can run into some issues with Python>=3.10, with failed imports being the main symptom. If that's the case, downgrade to, at most, python3.9.
- For coregistration, do a manual inspection of intermediate images.
- If you find some other problem, feel free to create an issue.
For questions or other business contact @anamatoso
If you use this code in your research, please cite this repository or this paper.