Skip to content

Instantly share code, notes, and snippets.

@pipitone
Last active August 29, 2015 14:18
Show Gist options
  • Save pipitone/f520d1a8ba68db9c94a4 to your computer and use it in GitHub Desktop.
Save pipitone/f520d1a8ba68db9c94a4 to your computer and use it in GitHub Desktop.
UKFTractography script
#!/bin/bash
source /etc/profile.d/modules.sh
source /etc/profile.d/quarantine.sh
module load slicer/4.4.0
module load FSL/5.0.7
module load DTIPrep/1.2.4
module load UKFTractography/2015-02-05
if [ -z "$4" ]; then
cat <<EOF
Runs DTIPrep and UKFTractography on a DWI image
Usage:
$0 <dwi> <DTIPrep-protocol.xml> <outputdir> <seeds>
EOF
exit 1
fi
inputimage=$1 # input NRRD DWI image
dtiprep_protocol=$2 # xml spec for DTIPrep
outputfolder=$3 # output folder for all outputs
seeds=$4 # number of seeds in the tractography step
stem=$(basename $inputimage .nrrd)
threads=8
# Run image through DTIPrep to clean up the image
if [ ! -e $outputfolder/${stem}_QCed.nrrd ]; then
DTIPrep \
--DWINrrdFile $inputimage \
--xmlProtocol $dtiprep_protocol \
--outputFolder $outputfolder \
--numberOfThreads $threads \
--check
fi
if [ ! -e $outputfolder/${stem}_DTI.nrrd ]; then
DWIToDTIEstimation \
--enumeration WLS \
--shiftNeg \
$outputfolder/${stem}_QCed.nrrd \
$outputfolder/${stem}_DTI.nrrd \
$outputfolder/${stem}_SCALAR.nrrd
fi
if [ ! -e $outputfolder/${stem}_MASK.nrrd ]; then
DiffusionWeightedVolumeMasking \
--otsuomegathreshold 0.7 \
--removeislands \
${outputfolder}/${stem}_QCed.nrrd \
${outputfolder}/${stem}_SCALAR.nrrd \
${outputfolder}/${stem}_MASK.nrrd
fi
if [ ! -e $outputfolder/${stem}_TRACTS.vtk ]; then
UKFTractography \
--labels 1 \
--recordFA \
--recordState \
--numTensor 2 \
--freeWater \
--seedsPerVoxel ${seeds} \
--numThreads $threads \
--dwiFile ${outputfolder}/${stem}_QCed.nrrd \
--maskFile ${outputfolder}/${stem}_MASK.nrrd \
--tracts ${outputfolder}/${stem}_TRACTS.vtk
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment