#! /bin/sh # # This script runs eddy followed by some # tests on the output. # It uses some b=7000 data from the pilot phase # of the HCP. The "ground truth" is simply the # output from eddy at a time when it seemed to # do a good job. The tolerance is quite high. That # reflects both that the data has a quite high # scale (b=0 values ~2000) and also that the # run-to-run variability of eddy is quite high # on these data. # odir=$1 indir=$2 # # Inputs 1--3 are the once 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 # Find all eddy_cuda* executables cuda_exes="" openmp_exe="" for cuda_exe in ${exedir}/eddy_cuda*; do if [ -x "${cuda_exe}" ]; then cuda_exes="${cuda_exes} ${cuda_exe}" fi done # Find the eddy_openmp executable if [ -x "${exedir}/eddy_openmp" ]; then openmp_exe="${exedir}/eddy_openmp" fi if [ "${cuda_exes}" == "" ] && [ "${openmp_exe}" == "" ]; then echo "Cannot find any eddy executables in ${exedir}!" exit 1 fi if [ ! -d "$odir" ]; then echo "Output directory ${odir} does not exist" exit 1; fi if [ ! -d "$indir" ]; then echo "Input directory ${indir} does not exist" exit 1; fi # Launch both GPU and CPU versions cuda_jid="" for cuda_exe in ${cuda_exes}; do tmp=`basename $cuda_exe` version=`echo $tmp | sed 's/eddy_cuda//'` cuda_jid="$cuda_jid `fsl_sub -l ${odir} -q cuda.q ${cuda_exe} --imain=${indir}/EddyHigh_b_TestData/eddyData/testData --mask=${indir}/EddyHigh_b_TestData/eddyData/testMask --bvals=${indir}/EddyHigh_b_TestData/eddyData/testBvals --bvecs=${indir}/EddyHigh_b_TestData/eddyData/testBvecs --index=${indir}/EddyHigh_b_TestData/eddyData/testIndex --acqp=${indir}/EddyHigh_b_TestData/eddyData/testAcqparams --topup=${indir}/EddyHigh_b_TestData/eddyData/testTopup --nvoxhp=5000 --repol --fwhm=10,0,0,0,0 --dont_peas --out=${odir}/eddyCudaOutput${version} --very_verbose`" done omp_jid=`fsl_sub -l ${odir} -q long.q -s openmp,6 ${exedir}/eddy_openmp --imain=${indir}/EddyHigh_b_TestData/eddyData/testData --mask=${indir}/EddyHigh_b_TestData/eddyData/testMask --bvals=${indir}/EddyHigh_b_TestData/eddyData/testBvals --bvecs=${indir}/EddyHigh_b_TestData/eddyData/testBvecs --index=${indir}/EddyHigh_b_TestData/eddyData/testIndex --acqp=${indir}/EddyHigh_b_TestData/eddyData/testAcqparams --topup=${indir}/EddyHigh_b_TestData/eddyData/testTopup --nvoxhp=5000 --repol --fwhm=10,0,0,0,0 --dont_peas --out=${odir}/eddyOmpOutput --very_verbose` # If running on a cluster, ensure that # slots are being reserved on the queue, # and wait until all jobs have finished if [ ! -z "${SGE_ROOT}" ]; then qalter ${omp_jid} -R y while [ : ]; do for jid in ${cuda_jid}; do tmp=`qstat -j ${jid} | wc` tmp=`echo $tmp | awk '{print $1}'` if [ $tmp -ne 0 ]; then break fi done if [ $tmp -eq 0 ]; then tmp=`qstat -j ${omp_jid} | wc` tmp=`echo $tmp | awk '{print $1}'` if [ $tmp -eq 0 ]; then break fi fi sleep 5m done fi # Check that eddy output exists for cuda_exe in ${cuda_exes}; do tmp=`basename $cuda_exe` version=`echo $tmp | sed 's/eddy_cuda//'` if [ ! -f ${odir}/eddyCudaOutput${version}.nii* ]; then exit 1 fi done if [ ! -f ${odir}/eddyOmpOutput.nii* ]; then exit 1 fi # Define some constants max_mean_ima_diff=15.0 max_max_ima_diff=20.0 # Check the results against ground truth cuda_exit_status=0 for cuda_exe in ${cuda_exes}; do tmp=`basename $cuda_exe` version=`echo $tmp | sed 's/eddy_cuda//'` ./EddyHigh_b_Feeds.py ${odir} Cuda${version} `imglob -extension ${indir}/EddyHigh_b_TestData/eddyData/testMask` `imglob -extension ${odir}/eddyCudaOutput${version}` `imglob -extension ${indir}/EddyHigh_b_TestData/eddyData/Precomputed/eddy_cuda_output` $max_mean_ima_diff $max_max_ima_diff cuda_exit_status=$(($cuda_exit_status + $?)) done ./EddyHigh_b_Feeds.py ${odir} Omp `imglob -extension ${indir}/EddyHigh_b_TestData/eddyData/testMask` `imglob -extension ${odir}/eddyOmpOutput` `imglob -extension ${indir}/EddyHigh_b_TestData/eddyData/Precomputed/eddy_openmp_output` $max_mean_ima_diff $max_max_ima_diff omp_exit_status=$? if [ $cuda_exit_status -gt 0 ] || [ $omp_exit_status -gt 0 ]; then echo "Test failed" exit 1 else echo "Test passed" exit 0 fi