Commit e48578ac authored by Saad Jbabdi's avatar Saad Jbabdi
Browse files

updated usage

parent bd32b739
......@@ -34,6 +34,14 @@ NeuroImage, 76(1), 400-411. DOI: 10.1016/j.neuroimage.2013.03.015
## Usage:
```
__ _______ ____ _ ____ _____
\ \/ /_ _| _ \ / \ / ___|_ _|
\ / | | | |_) | / _ \| | | |
/ \ | | | _ < / ___ \ |___ | |
/_/\_\ |_| |_| \_\/_/ \_\____| |_|
Usage:
xtract -bpx <bedpostX_dir> -out <outputDir> -str <structuresFile> -p <protocolsFolder> [options]
xtract -bpx <bedpostX_dir> -out <outputDir> -species HUMAN [options]
xtract -bpx <bedpostX_dir> -out <outputDir> -species MACAQUE [options]
......@@ -56,6 +64,7 @@ NeuroImage, 76(1), 400-411. DOI: 10.1016/j.neuroimage.2013.03.015
-gpu Use GPU version
-native Run tractography in native (diffusion) space
-res <mm> Output resolution (Default=same as in protocol folders unless '-native' used)
```
---------------------------------------------------------------------
......@@ -129,3 +138,35 @@ Then create the following NIFTI files (with this exact naming) and copy them int
All the masks above should be in standard space (e.g. MNI152 or F99) if you want to run the same tracking for a collection of subjects.
---------------------------------------------------------------------
## Visualising results with FSLEYES
The output of XTRACT is a folder that contrains tracts in separate folders. We provide a convenient script that can load these tracts (or a subset of the tracts) into FSLEYES using different colours for the different tracts but matching the left/right colours
```
__ _______ ____ _ ____ _____ _
\ \/ /_ _| _ \ / \ / ___|_ _| __ _(_) _____ _____ _ __
\ / | | | |_) | / _ \| | | | \ \ / / |/ _ \ \ /\ / / _ \ '__|
/ \ | | | _ < / ___ \ |___ | | \ V /| | __/\ V V / __/ |
/_/\_\ |_| |_| \_\/_/ \_\____| |_| \_/ |_|\___| \_/\_/ \___|_|
Usage:
xtract_viewer -dir <xtractDir> [options]
Compulsory arguments:
-dir FOLDER Path to XTRACT output folder
Optional arguments:
-str STRUCTURE ,STRUCTURE,... Structures (comma separated (default = display all that is found in input folder)
-thr NUMBER NUMBER The lower and upper thresholds applied to the tracts for viewing
Default = 0.001 0.1
-brain The brain image to use for the background overlay - must be in the same space as tracts.
Default is the FSL_HCP065_FA map
```
......@@ -52,15 +52,12 @@ Splash (){
cat <<EOF
***************************************************
__ __ _____ ____ _ ____ _____
\ \/ /|_ _|| _ \ / \ / ___||_ _|
\ / | | | |_) | / _ \ | | | |
/ \ | | | _ < / ___ \ | |___ | |
/_/\_\ |_| |_| \_\/_/ \_\ \____| |_|
***************************************************
__ _______ ____ _ ____ _____
\ \/ /_ _| _ \ / \ / ___|_ _|
\ / | | | |_) | / _ \| | | |
/ \ | | | _ < / ___ \ |___ | |
/_/\_\ |_| |_| \_\/_/ \_\____| |_|
EOF
}
......
#!/bin/bash
# Copyright (C) 2019 University of Oxford
......@@ -6,32 +8,24 @@
# Script to view output of XTRACT in fsleyes
# Written by Shaun Warrington 07/2019
# Modified by Saad Jbabdi 08/2019
# (Slightly modified by Saad Jbabdi 08/2019)
Usage() {
cat << EOF
Usage:
xtract_viewer -dir <xtractDir> -str <structuresFile> [options]
xtract_viewer -dir <xtractDir> [options]
Compulsory arguments:
-dir <folder> Path to Xtract folder
e.g. for subject, /data/subID/Xtract
for atlas, /data/tract_atlases
-str <file> Structures file (can be same as xtract input structures list)
-dir FOLDER Path to XTRACT output folder
Optional arguments:
-sub Use this flag to view a single subject's data
(look's for densityNorm.nii.gz under <dir>/tracts/)
Default is to view a tract atlas (looks for <structure>.nii.gz under <dir>)
-mip Use this flag to view tracts as mips, window of 5 slices, spline interpolation
-str STRUCTURE ,STRUCTURE,... Structures (comma separated (default = display all that is found in input folder)
-thr <number> <number> The lower and upper thresholds applied to the tracts for viewing
Default for subject = 0.001 0.1, default for atlas = 0.3 1.0
-thr NUMBER NUMBER The lower and upper thresholds applied to the tracts for viewing
Default = 0.001 0.1
-brain The brain image to use for the background overlay - must be in the same space as tracts.
Default is the FSL_HCP065_FA map
......@@ -39,61 +33,45 @@ EOF
exit 1
}
echo "---"
echo "----"
echo "-----"
echo "------"
echo "-------"
echo "------- Xtract Viewer"
echo "-------"
echo "------"
echo "-----"
echo "----"
echo "---"
Splash (){
[ "$1" = "" ] && Usage
cat <<EOF
# Set defaults
sub=0
mip=0
thr=""
brain=""
__ _______ ____ _ ____ _____ _
\ \/ /_ _| _ \ / \ / ___|_ _| __ _(_) _____ _____ _ __
\ / | | | |_) | / _ \| | | | \ \ / / |/ _ \ \ /\ / / _ \ '__|
/ \ | | | _ < / ___ \ |___ | | \ V /| | __/\ V V / __/ |
/_/\_\ |_| |_| \_\/_/ \_\____| |_| \_/ |_|\___| \_/\_/ \___|_|
EOF
}
Splash
[ "$1" = "" ] && Usage
# the colourmap options
cmaps=(blue red green blue-lightblue pink red-yellow cool yellow copper \
hot hsv coolwarm spring summer winter Oranges)
cmaps=(blue red green blue-lightblue pink red-yellow cool yellow copper hot hsv coolwarm spring summer winter Oranges)
cL="${#cmaps[@]}" # length of array for colourmap loop control
# Parse command-line arguments
# Set defaults
thr=0.001
uthr=0.1
brain=${FSLDIR}/data/standard/FSL_HCP1065_FA_1mm.nii.gz
str=ALL
while [ ! -z "$1" ];do
case "$1" in
-dir) dir=$2;shift;;
-str) str=$2;shift;;
-sub) sub=1;;
-str) IFS=', ' read -r -a str <<< "$2";shift;;
-thr) thr=$2;uthr=$3;shift;shift;;
-mip) mip=1;;
-brain) brain=$2;shift;;
*) echo "Unknown option '$1'";exit 1;;
esac
shift
done
# Default threshold values and mip opts
if [ "$thr" == "" ];then
if [ "$sub" == "1" ]; then
thr=0.001
uthr=0.1
elif [ "$sub" == "0" ]; then
thr=0.3
uthr=1.0
fi
fi
if [ "$brain" == "" ];then
# the FA atlas
brain=${FSLDIR}/data/standard/FSL_HCP1065_FA_1mm.nii.gz
fi
# Check compulsory arguments
errflag=0
if [ "$dir" == "" ];then
......@@ -103,18 +81,11 @@ elif [ ! -d $dir ];then
echo "Xtract folder $dir not found"
errflag=1
fi
if [ "$str" == "" ];then
echo "Must set compulsory argument '-str'"
errflag=1
elif [ ! -f $str ];then
echo "Structure file $str not found"
errflag=1
fi
if [ "$uthr" == "" ];then
echo "You have set a lower threshold but not an upper threshold. Must set '-thr' using <number> <number>"
errflag=1
fi
if [ ! -f $brain ];then
if [ `$FSLDIR/bin/imtest $brain` -eq 0 ];then
echo "Brain overlay file $brain not found"
errflag=1
fi
......@@ -126,42 +97,30 @@ fi
# build struct array - removing any empty/comment lines
# and check for and remove any file extentions
strlist=()
while read structstring; do
struct=`echo $structstring | awk '{print $1}'`
# skip empty lines and lines that start with '#'
if [ "${struct:0:1}" == "#" ];then
foo=0 #do nothing
elif [ ! "$struct" == "" ];then
ss=`echo $struct | sed s/.nii.gz//`
strlist+=("$ss")
fi
done < $str
if [ $str == ALL ];then
str=(`ls $dir/tracts`)
#str=`IFS=' ' read -r -a str <<< "$strlist"`
fi
echo Structures to be displayed
for index in "${!str[@]}"
do
echo "$index ${str[index]}"
done
# start the fsleyes command with basic options
cmd="${FSLDIR}/bin/fsleyes $brain -dr 0 `fslstats $brain -r | awk '{print $2}'`"
opts="-dr $thr $uthr"
# Using mip?
if [ "$mip" == "1" ];then
opts="$opts --overlayType mip --interpolation spline --window 5.0"
fi
# subject or atlas data structure?
if [ "$sub" == "1" ];then
preT="/tracts"
postT="/densityNorm.nii.gz"
else
preT=""
postT=".nii.gz"
fi
# Useful bits
preT="tracts"
postT="/densityNorm.nii.gz"
# Now loop and check for left/right tracts to colour the same
# checks for _l and matches any _r
# if no _?, then just move on to next line
i=0
for tract in "${strlist[@]}"
do
for tract in "${str[@]}";do
if [ $i -gt $((cL - 1)) ]; then i=0; fi # control colourmap loop
# check tract exists
if [ ! -f "${dir}/${preT}/${tract}${postT}" ]; then
......@@ -171,27 +130,26 @@ do
else
# if you find a left tract, then find the corresponding right tract
# and colour in the same way
if [[ $tract == *"_l"* ]];then
tt=`echo ${tract} | sed s/_l/_r/`
if [ "`grep ${tt} $str`" != "" ];then
# append _l and _r to fsleyes command with viewing options
cmd="$cmd ${dir}/${preT}/${tract}${postT} $opts -cm ${cmaps[i]} -n ${tract} ${dir}/${preT}/${tt}${postT} $opts -cm ${cmaps[i]} -n ${tt}"
else
# else, just add the current tract
cmd="$cmd ${dir}/${preT}/${tract}${postT} $opts -cm ${cmaps[i]} -n ${tract}"
fi
elif [[ $tract == *"_r"* ]] && [[ ! $cmd == *"$tract"* ]] && [[ ! ${strlist[@]} == *"`echo ${tract} | sed s/_r/_l/`"* ]];then
if [[ $tract == *"_l"* ]];then
tt=`echo ${tract} | sed s/_l/_r/`
if [[ "${str[@]}" =~ "$tt" ]];then
# append _l and _r to fsleyes command with viewing options
cmd="$cmd ${dir}/${preT}/${tract}${postT} $opts -cm ${cmaps[i]} -n ${tract} ${dir}/${preT}/${tt}${postT} $opts -cm ${cmaps[i]} -n ${tt}"
else
# else, just add the current tract
cmd="$cmd ${dir}/${preT}/${tract}${postT} $opts -cm ${cmaps[i]} -n ${tract}"
fi
elif [[ $tract == *"_r"* ]] && [[ ! $cmd == *"$tract"* ]] && [[ ! ${str[@]} == *"`echo ${tract} | sed s/_r/_l/`"* ]];then
# if tract name has _r and hasn't been found already
cmd="$cmd ${dir}/${preT}/${tract}${postT} $opts -cm ${cmaps[i]} -n ${tract}"
elif [[ $tract != *"_r"* && $tract != *"_l"* ]];then
cmd="$cmd ${dir}/${preT}/${tract}${postT} $opts -cm ${cmaps[i]} -n ${tract}"
elif [[ $tract != *"_r"* && $tract != *"_l"* ]];then
# if tract name doesn't have _l or _r
cmd="$cmd ${dir}/${preT}/${tract}${postT} $opts -cm ${cmaps[i]} -n ${tract}"
fi
((i++))
cmd="$cmd ${dir}/${preT}/${tract}${postT} $opts -cm ${cmaps[i]} -n ${tract}"
fi
((i++))
fi
done
echo $cmd
echo "Launching FSLeyes..."
bash $cmd &
#echo $cmd
eval $cmd &
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment