Skip to content
Snippets Groups Projects
feedsRun.EddyS2VTest 3.03 KiB
#! /bin/sh
#
# This script runs eddy on data with intra-volume movement,
# followed by some tests on the output.
# It uses simulated data supplied by Mark
# Graham, UCL, which allows us to have a ground
# truth. The data is a subset of that used
# for the s2v paper.
# The script was updated in May 2021 to test also the openmp
# version.
#

set -e

thisdir=$(cd $(dirname $0) && pwd)
odir=$1
indir=$2

#
# Inputs 1--3 are the ones neccessary for feeds to work
# Additional inputs are optional and intended for testing
# outside of the feeds context.
#
# Input 4 is alternative location of executable
#
if [ "$#" -gt 3 ]; then
    exedir=$4
   echo "Directory for eddy executables set to ${exedir}"
else
   exedir="${FSLDIR}/bin"
fi

if [ ! -d "$odir" ]; then
   echo "Output directory ${odir} does not exist"
   exit 1;
fi
if [ ! -d "$indir" ]; then
   echo "Input directory ${odir} does not exist"
   exit 1;
fi

# Prepare arguments to pass to eddy
eddy_args="--imain=${indir}/EddyS2VTestData/eddyData/testData     " \
          "--mask=${indir}/EddyS2VTestData/eddyData/testMask      " \
          "--bvals=${indir}/EddyS2VTestData/eddyData/testBvals    " \
          "--bvecs=${indir}/EddyS2VTestData/eddyData/testBvecs    " \
          "--index=${indir}/EddyS2VTestData/eddyData/testIndex    " \
          "--acqp=${indir}/EddyS2VTestData/eddyData/testAcqparams " \
          "--repol --ol_type=slice --ol_nstd=6 --ol_nvox=500      " \
          "--niter=8 --fwhm=10,6,4,2,0,0,0,0 --nvoxhp=5000        " \
          "--mporder=16 --s2v_niter=10 --s2v_interp=trilinear     " \
          "--s2v_lambda=1 --very_verbose                          " \
          "--slspec=${indir}/EddyS2VTestData/eddyData/testSlspec  "

# run eddy
output_prefixes=$(${thisdir}/runEddy ${exedir} ${odir} ${eddy_args} | tail -n1)

# Define some constants
# These are for the comparison of output images divided on b=0, b=700 and b=2000
max_ima_diff="2.0 2.5 0.6 0.7 0.5 0.6"
# Translations
max_trans_diff="0.2 1.0"
# Rotations
max_rot_diff="0.2 2.0"
# Outliers
max_false_pos=10
max_false_neg=10

# Check the results against ground truth
for prefix in ${output_prefixes}; do
    ${thisdir}/S2VFeeds.py ${odir} `basename ${prefix}`                                      \
        `imglob -extension ${indir}/EddyS2VTestData/eddyData/testMask`                       \
        ${indir}/EddyS2VTestData/eddyData/testBvals                                          \
        `imglob -extension ${prefix}`                                                        \
        `imglob -extension ${indir}/EddyS2VTestData/eddyData/GroundTruth/ground_truth`       \
        ${prefix}.eddy_movement_over_time                                                    \
        ${indir}/EddyS2VTestData/eddyData/MovementTruth/ground_truth.eddy_movement_over_time \
        ${prefix}.eddy_outlier_map                                                           \
        ${indir}/EddyS2VTestData/eddyData/OutlierTruth/dropoutLog_1.txt                      \
        ${max_ima_diff} ${max_false_pos} ${max_false_neg} ${max_trans_diff} ${max_rot_diff}
done