From 55fe275f6d59c42c2eeb0aed298f5114954eeed6 Mon Sep 17 00:00:00 2001 From: Paul McCarthy <pauldmccarthy@gmail.com> Date: Wed, 24 Nov 2021 11:08:09 +0000 Subject: [PATCH] RF: Major re-arrangement of eddy tests so that job submission / monitoring code is shared across all tests in a common "runEddy" script. Also test both $FSLDIR/bin/eddy_openmp and $FSLDIR/bin/eddy_cpu if either exist. --- eddy/{EddyTest => }/EddyFeeds.py | 0 .../{EddyHigh_b_Test => }/EddyHigh_b_Feeds.py | 0 eddy/EddyHigh_b_Test/feedsInputs | 1 - eddy/EddyHigh_b_Test/feedsRun | 148 ---------------- eddy/{EddyLSRTest => }/EddyLSRFeeds.py | 0 eddy/EddyLSRTest/LaunchEddy.sh | 25 --- eddy/EddyLSRTest/feedsInputs | 1 - eddy/EddyLSRTest/feedsRun | 146 ---------------- eddy/EddyMBSTest/feedsInputs | 1 - eddy/EddyMBSTest/feedsRun | 151 ----------------- eddy/EddyS2VTest/feedsInputs | 1 - eddy/EddyS2VTest/feedsRun | 158 ------------------ eddy/EddyS2VTest/rubbestad.txt | 12 -- eddy/EddyTest/feedsInputs | 1 - eddy/EddyTest/feedsRun | 151 ----------------- eddy/{EddyMBSTest => }/MoveBySuscFeeds.py | 0 eddy/{EddyS2VTest => }/S2VFeeds.py | 0 eddy/feedsRun.EddyHigh_b_Test | 74 ++++++++ eddy/feedsRun.EddyLSRTest | 71 ++++++++ eddy/feedsRun.EddyMBSTest | 77 +++++++++ eddy/feedsRun.EddyS2VTest | 81 +++++++++ eddy/feedsRun.EddyTest | 71 ++++++++ 22 files changed, 374 insertions(+), 796 deletions(-) rename eddy/{EddyTest => }/EddyFeeds.py (100%) rename eddy/{EddyHigh_b_Test => }/EddyHigh_b_Feeds.py (100%) delete mode 100755 eddy/EddyHigh_b_Test/feedsInputs delete mode 100755 eddy/EddyHigh_b_Test/feedsRun rename eddy/{EddyLSRTest => }/EddyLSRFeeds.py (100%) delete mode 100644 eddy/EddyLSRTest/LaunchEddy.sh delete mode 100755 eddy/EddyLSRTest/feedsInputs delete mode 100755 eddy/EddyLSRTest/feedsRun delete mode 100755 eddy/EddyMBSTest/feedsInputs delete mode 100755 eddy/EddyMBSTest/feedsRun delete mode 100755 eddy/EddyS2VTest/feedsInputs delete mode 100755 eddy/EddyS2VTest/feedsRun delete mode 100644 eddy/EddyS2VTest/rubbestad.txt delete mode 100755 eddy/EddyTest/feedsInputs delete mode 100755 eddy/EddyTest/feedsRun rename eddy/{EddyMBSTest => }/MoveBySuscFeeds.py (100%) rename eddy/{EddyS2VTest => }/S2VFeeds.py (100%) create mode 100755 eddy/feedsRun.EddyHigh_b_Test create mode 100755 eddy/feedsRun.EddyLSRTest create mode 100755 eddy/feedsRun.EddyMBSTest create mode 100755 eddy/feedsRun.EddyS2VTest create mode 100755 eddy/feedsRun.EddyTest diff --git a/eddy/EddyTest/EddyFeeds.py b/eddy/EddyFeeds.py similarity index 100% rename from eddy/EddyTest/EddyFeeds.py rename to eddy/EddyFeeds.py diff --git a/eddy/EddyHigh_b_Test/EddyHigh_b_Feeds.py b/eddy/EddyHigh_b_Feeds.py similarity index 100% rename from eddy/EddyHigh_b_Test/EddyHigh_b_Feeds.py rename to eddy/EddyHigh_b_Feeds.py diff --git a/eddy/EddyHigh_b_Test/feedsInputs b/eddy/EddyHigh_b_Test/feedsInputs deleted file mode 100755 index 16e9916..0000000 --- a/eddy/EddyHigh_b_Test/feedsInputs +++ /dev/null @@ -1 +0,0 @@ -EddyHigh_b_TestData/eddyData diff --git a/eddy/EddyHigh_b_Test/feedsRun b/eddy/EddyHigh_b_Test/feedsRun deleted file mode 100755 index 83cb34f..0000000 --- a/eddy/EddyHigh_b_Test/feedsRun +++ /dev/null @@ -1,148 +0,0 @@ -#! /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="" -cpu_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_cpu executable -if [ -x "${exedir}/eddy_openmp" ]; then - cpu_exe="${exedir}/eddy_openmp" -fi - -if [ "${cuda_exes}" == "" ] && [ "${cpu_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 - -if [ "${cpu_exe}" != "" ]; then - cpu_jid=`fsl_sub -l ${odir} -q long.q -s openmp,6 ${cpu_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}/eddyCpuOutput --very_verbose` -fi - -# 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 - if [ "${cpu_exe}" != "" ]; then - qalter ${cpu_jid} -R y - fi - 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 [ "${cpu_exe}" != "" ]; then - if [ $tmp -eq 0 ]; then - tmp=`qstat -j ${cpu_jid} | wc` - tmp=`echo $tmp | awk '{print $1}'` - if [ $tmp -eq 0 ]; then - break - fi - 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 [ "${cpu_exe}" != "" ]; then - if [ ! -f ${odir}/eddyCpuOutput.nii* ]; then - echo "eddyCpuOutput missing" - exit 1 - fi -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 - -cpu_exit_status=0 -if [ "${cpu_exe}" != "" ]; then - ./EddyHigh_b_Feeds.py ${odir} Cpu `imglob -extension ${indir}/EddyHigh_b_TestData/eddyData/testMask` `imglob -extension ${odir}/eddyCpuOutput` `imglob -extension ${indir}/EddyHigh_b_TestData/eddyData/Precomputed/eddy_openmp_output` $max_mean_ima_diff $max_max_ima_diff - cpu_exit_status=$? -fi - -if [ $cuda_exit_status -gt 0 ] || [ $cpu_exit_status -gt 0 ]; then - echo "Test failed" - exit 1 -else - echo "Test passed" - exit 0 -fi diff --git a/eddy/EddyLSRTest/EddyLSRFeeds.py b/eddy/EddyLSRFeeds.py similarity index 100% rename from eddy/EddyLSRTest/EddyLSRFeeds.py rename to eddy/EddyLSRFeeds.py diff --git a/eddy/EddyLSRTest/LaunchEddy.sh b/eddy/EddyLSRTest/LaunchEddy.sh deleted file mode 100644 index 3bbd752..0000000 --- a/eddy/EddyLSRTest/LaunchEddy.sh +++ /dev/null @@ -1,25 +0,0 @@ -#! /bin/bash - -export exedir="/home/fs0/jesper/fsl/src/BuildingEddy_5_0_11_for_PreRelease/eddy/" -export indir="/vols/Data/fsldev/dataSets/EddyLSRTestData/eddyData" -export odir="/vols/Data/fsldev/dataSets/EddyLSRTestData/eddyData/Precomputed" - -fsl_sub -q long.q -s openmp,6 ${exedir}/eddy_openmp --imain=${indir}/testData --mask=${indir}/testMask --bvals=${indir}/testBvals --bvecs=${indir}/testBvecs --index=${indir}/testIndex --acqp=${indir}/testAcqparams --topup=${indir}/testTopup --out=${odir}/eddy_openmp_output --resamp=lsr --fep --nvoxhp=5000 --dont_sep_offs_move --very_verbose - -fsl_sub -q cuda.q ${exedir}/eddy_cuda7.5 --imain=${indir}/testData --mask=${indir}/testMask --bvals=${indir}/testBvals --bvecs=${indir}/testBvecs --index=${indir}/testIndex --acqp=${indir}/testAcqparams --topup=${indir}/testTopup --out=${odir}/eddy_cuda_output --resamp=lsr --fep --nvoxhp=5000 --dont_sep_offs_move --very_verbose - -# -# Run new eddy as well, as a kind of pre-test -# - -export exedir="/home/fs0/jesper/DebugEddyNewNewimage/eddy_new/eddy" -export indir="/vols/Data/fsldev/dataSets/EddyLSRTestData/eddyData" -export odir="/vols/Scratch/HCP/Diffusion/jesper/EddyLSRFeedsTest20190129" - -fsl_sub -q long.q -s openmp,6 ${exedir}/eddy_openmp --imain=${indir}/testData --mask=${indir}/testMask --bvals=${indir}/testBvals --bvecs=${indir}/testBvecs --index=${indir}/testIndex --acqp=${indir}/testAcqparams --topup=${indir}/testTopup --out=${odir}/eddy_openmp_output --resamp=lsr --fep --nvoxhp=5000 --dont_sep_offs_move --very_verbose - -fsl_sub -q cuda.q ${exedir}/eddy_cuda --imain=${indir}/testData --mask=${indir}/testMask --bvals=${indir}/testBvals --bvecs=${indir}/testBvecs --index=${indir}/testIndex --acqp=${indir}/testAcqparams --topup=${indir}/testTopup --out=${odir}/eddy_cuda_output --resamp=lsr --fep --nvoxhp=5000 --dont_sep_offs_move --very_verbose - - - - diff --git a/eddy/EddyLSRTest/feedsInputs b/eddy/EddyLSRTest/feedsInputs deleted file mode 100755 index d2c80fb..0000000 --- a/eddy/EddyLSRTest/feedsInputs +++ /dev/null @@ -1 +0,0 @@ -EddyLSRTestData/eddyData diff --git a/eddy/EddyLSRTest/feedsRun b/eddy/EddyLSRTest/feedsRun deleted file mode 100755 index 4a5dad8..0000000 --- a/eddy/EddyLSRTest/feedsRun +++ /dev/null @@ -1,146 +0,0 @@ -#! /bin/sh -# -# This script runs eddy followed by some -# tests on the output. -# It uses some data from the pilot phase -# of the HCP where each diffusion direction was -# scanned twice with opposing PE-directions. -# The "ground truth" is simply the output from eddy -# prior to Armadillo and NewNewimage. -# - -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="" -cpu_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_cpu executable -if [ -x "${exedir}/eddy_openmp" ]; then - cpu_exe="${exedir}/eddy_openmp" -fi - -if [ "${cuda_exes}" == "" ] && [ "${cpu_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}/EddyLSRTestData/eddyData/testData --mask=${indir}/EddyLSRTestData/eddyData/testMask --bvals=${indir}/EddyLSRTestData/eddyData/testBvals --bvecs=${indir}/EddyLSRTestData/eddyData/testBvecs --index=${indir}/EddyLSRTestData/eddyData/testIndex --acqp=${indir}/EddyLSRTestData/eddyData/testAcqparams --topup=${indir}/EddyLSRTestData/eddyData/testTopup --out=${odir}/eddyCudaOutput${version} --resamp=lsr --fep --nvoxhp=5000 --repol --fwhm=10,0,0,0,0 --dont_peas --very_verbose`" -done - -if [ "${cpu_exe}" != "" ]; then - cpu_jid=`fsl_sub -l ${odir} -q long.q -s openmp,6 ${cpu_exe} --imain=${indir}/EddyLSRTestData/eddyData/testData --mask=${indir}/EddyLSRTestData/eddyData/testMask --bvals=${indir}/EddyLSRTestData/eddyData/testBvals --bvecs=${indir}/EddyLSRTestData/eddyData/testBvecs --index=${indir}/EddyLSRTestData/eddyData/testIndex --acqp=${indir}/EddyLSRTestData/eddyData/testAcqparams --topup=${indir}/EddyLSRTestData/eddyData/testTopup --out=${odir}/eddyCpuOutput --resamp=lsr --fep --nvoxhp=5000 --repol --fwhm=10,0,0,0,0 --dont_peas --very_verbose` -fi - -# 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 - if [ "${cpu_exe}" != "" ]; then - qalter ${cpu_jid} -R y - fi - - 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 [ "${cpu_exe}" != "" ]; then - if [ $tmp -eq 0 ]; then - tmp=`qstat -j ${cpu_jid} | wc` - tmp=`echo $tmp | awk '{print $1}'` - if [ $tmp -eq 0 ]; then - break - fi - 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 [ "${cpu_exe}" != "" ]; then - if [ ! -f ${odir}/eddyCpuOutput.nii* ]; then - echo "eddyCpuOutput missing" - exit 1 - fi -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//'` - ./EddyLSRFeeds.py ${odir} Cuda${version} `imglob -extension ${indir}/EddyLSRTestData/eddyData/testMask` `imglob -extension ${odir}/eddyCudaOutput${version}` `imglob -extension ${indir}/EddyLSRTestData/eddyData/Precomputed/eddy_cuda_output` $max_mean_ima_diff $max_max_ima_diff - cuda_exit_status=$(($cuda_exit_status + $?)) -done - -cpu_exit_status=0 -if [ "${cpu_exe}" != "" ]; then - ./EddyLSRFeeds.py ${odir} Cpu `imglob -extension ${indir}/EddyLSRTestData/eddyData/testMask` `imglob -extension ${odir}/eddyCpuOutput` `imglob -extension ${indir}/EddyLSRTestData/eddyData/Precomputed/eddy_openmp_output` $max_mean_ima_diff $max_max_ima_diff - cpu_exit_status=$? -fi - -if [ $cuda_exit_status -gt 0 ] || [ $cpu_exit_status -gt 0 ]; then - echo "Test failed" - exit 1 -else - echo "Test passed" - exit 0 -fi diff --git a/eddy/EddyMBSTest/feedsInputs b/eddy/EddyMBSTest/feedsInputs deleted file mode 100755 index 0d13a25..0000000 --- a/eddy/EddyMBSTest/feedsInputs +++ /dev/null @@ -1 +0,0 @@ -EddyMBSTestData/eddyData diff --git a/eddy/EddyMBSTest/feedsRun b/eddy/EddyMBSTest/feedsRun deleted file mode 100755 index 9be5681..0000000 --- a/eddy/EddyMBSTest/feedsRun +++ /dev/null @@ -1,151 +0,0 @@ -#! /bin/sh -# -# This script runs eddy for testing the -# movement-by-susceptibility functionality -# followed by some tests on the output. -# It uses simulated data supplied by Mark -# Graham, UCL. -# The data is a subset of that used for -# the MBS paper. We don't have an "actual" -# ground truth so instead we compare against -# the results from the paper (calculated with -# the Cuda version). -# The actual data used for the test is -# .../SecondSetOfSimulations/ap/ec-volumetric-3x/images_SNR40_1 -# - -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="" -cpu_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_cpu executable -if [ -x "${exedir}/eddy_openmp" ]; then - cpu_exe="${exedir}/eddy_openmp" -fi - -if [ "${cuda_exes}" == "" ] && [ "${cpu_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 - -# Define some constants - -max_mean_dfield_diff=0.03 -max_max_dfield_diff=0.06 -max_mean_ima_diff=0.3 -max_max_ima_diff=0.6 - -# 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}/EddyMBSTestData/eddyData/testData --acqp=${indir}/EddyMBSTestData/eddyData/testAcqparams --mask=${indir}/EddyMBSTestData/eddyData/testMask --index=${indir}/EddyMBSTestData/eddyData/testIndex --bvecs=${indir}/EddyMBSTestData/eddyData/testBvecs --bvals=${indir}/EddyMBSTestData/eddyData/testBvals --topup=${indir}/EddyMBSTestData/eddyData/testTopup --fwhm=10,5,2,0,0,0,0,0 --niter=8 --nvoxhp=2000 --flm=quadratic --dont_peas --estimate_move_by_susceptibility --mbs_niter=20 --mbs_lambda=10 --mbs_ksp=10 --out=${odir}/eddyCudaOutput${version} --very_verbose`" -done - -if [ "${cpu_exe}" != "" ]; then - cpu_jid=`fsl_sub -l ${odir} -q long.q -s openmp,6 ${cpu_exe} --imain=${indir}/EddyMBSTestData/eddyData/testData --acqp=${indir}/EddyMBSTestData/eddyData/testAcqparams --mask=${indir}/EddyMBSTestData/eddyData/testMask --index=${indir}/EddyMBSTestData/eddyData/testIndex --bvecs=${indir}/EddyMBSTestData/eddyData/testBvecs --bvals=${indir}/EddyMBSTestData/eddyData/testBvals --topup=${indir}/EddyMBSTestData/eddyData/testTopup --fwhm=10,5,2,0,0,0,0,0 --niter=8 --nvoxhp=2000 --flm=quadratic --dont_peas --estimate_move_by_susceptibility --mbs_niter=20 --mbs_lambda=10 --mbs_ksp=10 --out=${odir}/eddyCpuOutput --very_verbose` -fi - -# 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 - if [ "${cpu_exe}" != "" ]; then - qalter ${cpu_jid} -R y - fi - 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 [ "${cpu_exe}" != "" ]; then - if [ $tmp -eq 0 ]; then - tmp=`qstat -j ${cpu_jid} | wc` - tmp=`echo $tmp | awk '{print $1}'` - if [ $tmp -eq 0 ]; then - break - fi - 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 [ "${cpu_exe}" != "" ]; then - if [ ! -f ${odir}/eddyCpuOutput.nii* ]; then - exit 1 - fi -fi - -# Check the results against precomputed results - -cuda_exit_status=0 -for cuda_exe in ${cuda_exes}; -do - tmp=`basename $cuda_exe` - version=`echo $tmp | sed 's/eddy_cuda//'` - ./MoveBySuscFeeds.py ${odir} Cuda${version} `imglob -extension ${indir}/EddyMBSTestData/eddyData/Precomputed/BrainMaskForComparison` `imglob -extension ${odir}/eddyCudaOutput${version}` `imglob -extension ${indir}/EddyMBSTestData/eddyData/Precomputed/PrecomputedResults` `imglob -extension ${odir}/eddyCudaOutput${version}.eddy_mbs_first_order_fields` `imglob -extension ${indir}/EddyMBSTestData/eddyData/Precomputed/PrecomputedResults.eddy_mbs_first_order_fields` ${max_mean_ima_diff} ${max_max_ima_diff} ${max_mean_dfield_diff} ${max_max_dfield_diff} - cuda_exit_status=$(($cuda_exit_status + $?)) -done - -cpu_exit_status=0 -if [ "${cpu_exe}" != "" ]; then - ./MoveBySuscFeeds.py ${odir} Cpu `imglob -extension ${indir}/EddyMBSTestData/eddyData/Precomputed/BrainMaskForComparison` `imglob -extension ${odir}/eddyCpuOutput` `imglob -extension ${indir}/EddyMBSTestData/eddyData/Precomputed/PrecomputedResults` `imglob -extension ${odir}/eddyCpuOutput.eddy_mbs_first_order_fields` `imglob -extension ${indir}/EddyMBSTestData/eddyData/Precomputed/PrecomputedResults.eddy_mbs_first_order_fields` ${max_mean_ima_diff} ${max_max_ima_diff} ${max_mean_dfield_diff} ${max_max_dfield_diff} - cpu_exit_status=$? -fi - -if [ $cuda_exit_status -gt 0 ] || [ $cpu_exit_status -gt 0 ]; then - echo "Test failed" - exit 1 -else - echo "Test passed" - exit 0 -fi diff --git a/eddy/EddyS2VTest/feedsInputs b/eddy/EddyS2VTest/feedsInputs deleted file mode 100755 index b6aff52..0000000 --- a/eddy/EddyS2VTest/feedsInputs +++ /dev/null @@ -1 +0,0 @@ -EddyS2VTestData/eddyData diff --git a/eddy/EddyS2VTest/feedsRun b/eddy/EddyS2VTest/feedsRun deleted file mode 100755 index 37f6a1e..0000000 --- a/eddy/EddyS2VTest/feedsRun +++ /dev/null @@ -1,158 +0,0 @@ -#! /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. -# - -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 - -# Find all eddy_cuda* executables -cuda_exes="" -cpu_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_cpu executable -if [ -x "${exedir}/eddy_openmp" ]; then - cpu_exe="${exedir}/eddy_openmp" -fi - -if [ "${cuda_exes}" == "" ] && [ "${cpu_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 ${odir} 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}/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 --out=${odir}/eddyCudaOutput${version} --nvoxhp=5000 --mporder=16 --s2v_niter=10 --s2v_interp=trilinear --s2v_lambda=1 --slspec=${indir}/EddyS2VTestData/eddyData/testSlspec --very_verbose`" -done - -if [ "${cpu_exe}" != "" ]; then - cpu_jid=`fsl_sub -l ${odir} -q long.q -s openmp,6 ${cpu_exe} --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 --niter=8 --fwhm=10,6,4,2,0,0,0,0 --out=${odir}/eddyCpuOutput --nvoxhp=5000 --mporder=16 --s2v_niter=10 --s2v_interp=trilinear --s2v_lambda=1 --slspec=${indir}/EddyS2VTestData/eddyData/testSlspec --very_verbose` -fi - -# 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 - if [ "${cpu_exe}" != "" ]; then - qalter ${cpu_jid} -R y - fi - 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 [ "${cpu_exe}" != "" ]; then - if [ $tmp -eq 0 ]; then - tmp=`qstat -j ${cpu_jid} | wc` - tmp=`echo $tmp | awk '{print $1}'` - if [ $tmp -eq 0 ]; then - break - fi - 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 - echo "Cuda output eddyCudaOutput${version} missing" - exit 1 - fi -done -if [ "${cpu_exe}" != "" ]; then - if [ ! -f ${odir}/eddyCpuOutput.nii* ]; then - echo "eddyCpuOutput missing" - exit 1 - fi -fi - -# 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 - -cuda_exit_status=0 -for cuda_exe in ${cuda_exes}; -do - tmp=`basename $cuda_exe` - version=`echo $tmp | sed 's/eddy_cuda//'` - echo "./S2VFeeds.py ${odir} Cuda${version} `imglob -extension ${indir}/EddyS2VTestData/eddyData/testMask` ${indir}/EddyS2VTestData/eddyData/testBvals `imglob -extension ${odir}/eddyCudaOutput${version}` `imglob -extension $\ -{indir}/EddyS2VTestData/eddyData/GroundTruth/ground_truth` ${odir}/eddyCudaOutput${version}.eddy_movement_over_time ${indir}/EddyS2VTestData/eddyData/MovementTruth/ground_truth.eddy_movement_over_time ${odir}/eddyCudaO\ -utput${version}.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}" - ./S2VFeeds.py ${odir} Cuda${version} `imglob -extension ${indir}/EddyS2VTestData/eddyData/testMask` ${indir}/EddyS2VTestData/eddyData/testBvals `imglob -extension ${odir}/eddyCudaOutput${version}` `imglob -extension ${indir}/EddyS2VTestData/eddyData/GroundTruth/ground_truth` ${odir}/eddyCudaOutput${version}.eddy_movement_over_time ${indir}/EddyS2VTestData/eddyData/MovementTruth/ground_truth.eddy_movement_over_time ${odir}/eddyCudaOutput${version}.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} - cuda_exit_status=$(($cuda_exit_status + $?)) -done - -cpu_exit_status=0 - -if [ "${cpu_exe}" != "" ]; then - ./S2VFeeds.py ${odir} Cpu `imglob -extension ${indir}/EddyS2VTestData/eddyData/testMask` ${indir}/EddyS2VTestData/eddyData/testBvals `imglob -extension ${odir}/eddyCpuOutput` `imglob -extension ${indir}/EddyS2VTestData/eddyData/GroundTruth/ground_truth` ${odir}/eddyCpuOutput.eddy_movement_over_time ${indir}/EddyS2VTestData/eddyData/MovementTruth/ground_truth.eddy_movement_over_time ${odir}/eddyCpuOutput.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} - cpu_exit_status=$? -fi - - -if [ $cuda_exit_status -gt 0 ] || [ $cpu_exit_status -gt 0 ]; then - echo "Test failed" - exit 1 -else - echo "Test passed" - exit 0 -fi diff --git a/eddy/EddyS2VTest/rubbestad.txt b/eddy/EddyS2VTest/rubbestad.txt deleted file mode 100644 index 3d7a911..0000000 --- a/eddy/EddyS2VTest/rubbestad.txt +++ /dev/null @@ -1,12 +0,0 @@ -export indir=/vols/Data/fsldev/dataSets -export odir=/vols/Scratch/HCP/Diffusion/jesper/EddyS2VFeedsTest20190129 -exedir=/home/fs0/jesper/DebugEddyNewNewimage/eddy_new/eddy - -${exedir}/eddy_cuda --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 --niter=8 --fwhm=10,6,4,2,0,0,0,0 --out=${odir}/NewEddyCudaOutput --nvoxhp=5000 --mporder=16 --s2v_niter=10 --s2v_interp=trilinear --s2v_lambda=1 --slspec=${indir}/EddyS2VTestData/eddyData/testSlspec --very_verbose - - -export indir=/vols/Data/fsldev/dataSets -export odir=/vols/Scratch/HCP/Diffusion/jesper/EddyS2VFeedsTest20190129 -exedir=/home/fs0/jesper/fsl/src/BuildingEddyForHCP_2017_09_29/eddy - -${exedir}/eddy_cuda8.0 --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 --niter=8 --fwhm=10,6,4,2,0,0,0,0 --out=${odir}/OldEddyCudaOutput --nvoxhp=5000 --mporder=16 --s2v_niter=10 --s2v_interp=trilinear --s2v_lambda=1 --slspec=${indir}/EddyS2VTestData/eddyData/testSlspec --very_verbose diff --git a/eddy/EddyTest/feedsInputs b/eddy/EddyTest/feedsInputs deleted file mode 100755 index dcfa4da..0000000 --- a/eddy/EddyTest/feedsInputs +++ /dev/null @@ -1 +0,0 @@ -EddyTestData/eddyData diff --git a/eddy/EddyTest/feedsRun b/eddy/EddyTest/feedsRun deleted file mode 100755 index cf3f1ac..0000000 --- a/eddy/EddyTest/feedsRun +++ /dev/null @@ -1,151 +0,0 @@ -#!/bin/sh -# -# This script runs eddy 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 outlier paper. -# - -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="" -cpu_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_cpu executable -if [ -x "${exedir}/eddy_openmp" ]; then - cpu_exe="${exedir}/eddy_openmp" -fi - -if [ "${cuda_exes}" == "" ] && [ "${cpu_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 - -# Define some constants - -max_mean_dfield_diff=0.5 -max_max_dfield_diff=1.0 -max_mean_ima_diff=1.5 -max_max_ima_diff=3.0 -allowed_false_positives=1 -allowed_false_negatives=1 - -# 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}/EddyTestData/eddyData/testData --mask=${indir}/EddyTestData/eddyData/testMask --bvals=${indir}/EddyTestData/eddyData/testBvals --bvecs=${indir}/EddyTestData/eddyData/testBvecs --index=${indir}/EddyTestData/eddyData/testIndex --acqp=${indir}/EddyTestData/eddyData/testAcqparams --repol --fwhm=10,0,0,0,0 --out=${odir}/eddyCudaOutput${version} --dfields -v`" -done - -if [ "${cpu_exe}" != "" ]; then - cpu_jid=`fsl_sub -l ${odir} -q long.q -s openmp,6 ${cpu_exe} --imain=${indir}/EddyTestData/eddyData/testData --mask=${indir}/EddyTestData/eddyData/testMask --bvals=${indir}/EddyTestData/eddyData/testBvals --bvecs=${indir}/EddyTestData/eddyData/testBvecs --index=${indir}/EddyTestData/eddyData/testIndex --acqp=${indir}/EddyTestData/eddyData/testAcqparams --repol --fwhm=10,0,0,0,0 --out=${odir}/eddyCpuOutput --dfields -v` -fi - -# 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 - if [ "${cpu_exe}" != "" ]; then - qalter ${cpu_jid} -R y - fi - - 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 [ "${cpu_exe}" != "" ]; then - if [ $tmp -eq 0 ]; then - tmp=`qstat -j ${cpu_jid} | wc` - tmp=`echo $tmp | awk '{print $1}'` - if [ $tmp -eq 0 ]; then - break - fi - 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 [ "${cpu_exe}" != "" ]; then - if [ ! -f ${odir}/eddyCpuOutput.nii* ]; then - echo "eddyCpuOutput missing" - exit 1 - fi -fi - -# 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//'` - ./EddyFeeds.py ${odir} Cuda${version} `imglob -extension ${indir}/EddyTestData/eddyData/testMask` `imglob -extension ${odir}/eddyCudaOutput${version}` `imglob -extension ${indir}/EddyTestData/eddyData/GroundTruth/ground_truth` ${odir}/eddyCudaOutput${version}.eddy_displacement_fields ${indir}/EddyTestData/eddyData/DisplacementFields/DisplacementField ${odir}/eddyCudaOutput${version}.eddy_outlier_map ${indir}/EddyTestData/eddyData/OutlierTruth/dropoutLog_1.txt ${max_mean_ima_diff} ${max_max_ima_diff} ${max_mean_dfield_diff} ${max_max_dfield_diff} ${allowed_false_positives} ${allowed_false_negatives} - cuda_exit_status=$(($cuda_exit_status + $?)) -done - -cpu_exit_status=0 - -if [ "${cpu_exe}" != "" ]; then - ./EddyFeeds.py ${odir} Cpu `imglob -extension ${indir}/EddyTestData/eddyData/testMask` `imglob -extension ${odir}/eddyCpuOutput` `imglob -extension ${indir}/EddyTestData/eddyData/GroundTruth/ground_truth` ${odir}/eddyCpuOutput.eddy_displacement_fields ${indir}/EddyTestData/eddyData/DisplacementFields/DisplacementField ${odir}/eddyCpuOutput.eddy_outlier_map ${indir}/EddyTestData/eddyData/OutlierTruth/dropoutLog_1.txt ${max_mean_ima_diff} ${max_max_ima_diff} ${max_mean_dfield_diff} ${max_max_dfield_diff} ${allowed_false_positives} ${allowed_false_negatives} - cpu_exit_status=$? -fi - -if [ $cuda_exit_status -gt 0 ] || [ $cpu_exit_status -gt 0 ]; then - echo "Test failed" - exit 1 -else - echo "Test passed" - exit 0 -fi diff --git a/eddy/EddyMBSTest/MoveBySuscFeeds.py b/eddy/MoveBySuscFeeds.py similarity index 100% rename from eddy/EddyMBSTest/MoveBySuscFeeds.py rename to eddy/MoveBySuscFeeds.py diff --git a/eddy/EddyS2VTest/S2VFeeds.py b/eddy/S2VFeeds.py similarity index 100% rename from eddy/EddyS2VTest/S2VFeeds.py rename to eddy/S2VFeeds.py diff --git a/eddy/feedsRun.EddyHigh_b_Test b/eddy/feedsRun.EddyHigh_b_Test new file mode 100755 index 0000000..7b238aa --- /dev/null +++ b/eddy/feedsRun.EddyHigh_b_Test @@ -0,0 +1,74 @@ +#! /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. +# + +set -e + +thisdir=$(cd $(dirname $0) && pwd) +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 + +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 + +# Prepare arguments to pass to eddy +eddy_args="--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 --very_verbose" + +# run eddy +output_prefixes=$(${thisdir}/runEddy ${exedir} ${odir} ${eddy_args} | tail -n1) + +# Define some constants +max_mean_ima_diff=15.0 +max_max_ima_diff=20.0 + +# Check the results against ground truth +for prefix in ${output_prefixes}; do + + if [[ "${prefix}" = *cuda* ]]; then + precomputed="${indir}/EddyHigh_b_TestData/eddyData/Precomputed/eddy_cuda_output" + else + precomputed="${indir}/EddyHigh_b_TestData/eddyData/Precomputed/eddy_openmp_output" + fi + + ${thisdir}/EddyHigh_b_Feeds.py ${odir} `basename ${prefix}` \ + `imglob -extension ${indir}/EddyHigh_b_TestData/eddyData/testMask` \ + `imglob -extension ${prefix}` \ + `imglob -extension ${precomputed}` \ + $max_mean_ima_diff $max_max_ima_diff +done diff --git a/eddy/feedsRun.EddyLSRTest b/eddy/feedsRun.EddyLSRTest new file mode 100755 index 0000000..d965a57 --- /dev/null +++ b/eddy/feedsRun.EddyLSRTest @@ -0,0 +1,71 @@ +#! /bin/sh +# +# This script runs eddy followed by some +# tests on the output. +# It uses some data from the pilot phase +# of the HCP where each diffusion direction was +# scanned twice with opposing PE-directions. +# The "ground truth" is simply the output from eddy +# prior to Armadillo and NewNewimage. +# + +set -e + +thisdir=$(cd $(dirname $0) && pwd) +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 + +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 + +# Prepare arguments to pass to eddy +eddy_args="--imain=${indir}/EddyLSRTestData/eddyData/testData " \ + "--mask=${indir}/EddyLSRTestData/eddyData/testMask " \ + "--bvals=${indir}/EddyLSRTestData/eddyData/testBvals " \ + "--bvecs=${indir}/EddyLSRTestData/eddyData/testBvecs " \ + "--index=${indir}/EddyLSRTestData/eddyData/testIndex " \ + "--acqp=${indir}/EddyLSRTestData/eddyData/testAcqparams " \ + "--topup=${indir}/EddyLSRTestData/eddyData/testTopup " \ + "--resamp=lsr --fep --nvoxhp=5000 --repol --fwhm=10,0,0,0,0 " \ + "--dont_peas --very_verbose" + +# run eddy +output_prefixes=$(${thisdir}/runEddy ${exedir} ${odir} ${eddy_args} | tail -n1) + +# Define some constants +max_mean_ima_diff=15.0 +max_max_ima_diff=20.0 + +# Check the results against ground truth +for prefix in ${output_prefixes}; do + if [[ "${prefix}" = *cuda* ]]; then + precomputed="${indir}/EddyLSRTestData/eddyData/Precomputed/eddy_cuda_output" + else + precomputed="${indir}/EddyLSRTestData/eddyData/Precomputed/eddy_openmp_output" + fi + + ${thisdir}/EddyLSRFeeds.py ${odir} `basename ${prefix}` \ + `imglob -extension ${indir}/EddyLSRTestData/eddyData/testMask` \ + `imglob -extension ${prefix}` \ + `imglob -extension ${precomputed}` \ + $max_mean_ima_diff $max_max_ima_diff +done diff --git a/eddy/feedsRun.EddyMBSTest b/eddy/feedsRun.EddyMBSTest new file mode 100755 index 0000000..babc78e --- /dev/null +++ b/eddy/feedsRun.EddyMBSTest @@ -0,0 +1,77 @@ +#! /bin/sh +# +# This script runs eddy for testing the +# movement-by-susceptibility functionality +# followed by some tests on the output. +# It uses simulated data supplied by Mark +# Graham, UCL. +# The data is a subset of that used for +# the MBS paper. We don't have an "actual" +# ground truth so instead we compare against +# the results from the paper (calculated with +# the Cuda version). +# The actual data used for the test is +# .../SecondSetOfSimulations/ap/ec-volumetric-3x/images_SNR40_1 +# + +set -e + +thisdir=$(cd $(dirname $0) && pwd) +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 + +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 + +# Prepare arguments to pass to eddy +eddy_args="--imain=${indir}/EddyMBSTestData/eddyData/testData " \ + "--acqp=${indir}/EddyMBSTestData/eddyData/testAcqparams " \ + "--mask=${indir}/EddyMBSTestData/eddyData/testMask " \ + "--index=${indir}/EddyMBSTestData/eddyData/testIndex " \ + "--bvecs=${indir}/EddyMBSTestData/eddyData/testBvecs " \ + "--bvals=${indir}/EddyMBSTestData/eddyData/testBvals " \ + "--topup=${indir}/EddyMBSTestData/eddyData/testTopup " \ + "--fwhm=10,5,2,0,0,0,0,0 --niter=8 --nvoxhp=2000 " \ + "--flm=quadratic --dont_peas --estimate_move_by_susceptibility " \ + "--mbs_niter=20 --mbs_lambda=10 --mbs_ksp=10 --very_verbose" + +# run eddy +output_prefixes=$(${thisdir}/runEddy ${exedir} ${odir} ${eddy_args} | tail -n1) + +# Define some constants +max_mean_dfield_diff=0.03 +max_max_dfield_diff=0.06 +max_mean_ima_diff=0.3 +max_max_ima_diff=0.6 + + +# Check the results against precomputed results + +for prefix in ${output_prefixes}; do + ${thisdir}/MoveBySuscFeeds.py ${odir} `basename ${prefix}` \ + `imglob -extension ${indir}/EddyMBSTestData/eddyData/Precomputed/BrainMaskForComparison` \ + `imglob -extension ${prefix}` \ + `imglob -extension ${indir}/EddyMBSTestData/eddyData/Precomputed/PrecomputedResults` \ + `imglob -extension ${prefix}.eddy_mbs_first_order_fields` \ + `imglob -extension ${indir}/EddyMBSTestData/eddyData/Precomputed/PrecomputedResults.eddy_mbs_first_order_fields` \ + ${max_mean_ima_diff} ${max_max_ima_diff} ${max_mean_dfield_diff} ${max_max_dfield_diff} +done diff --git a/eddy/feedsRun.EddyS2VTest b/eddy/feedsRun.EddyS2VTest new file mode 100755 index 0000000..a511d5d --- /dev/null +++ b/eddy/feedsRun.EddyS2VTest @@ -0,0 +1,81 @@ +#! /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 diff --git a/eddy/feedsRun.EddyTest b/eddy/feedsRun.EddyTest new file mode 100755 index 0000000..c50ac5e --- /dev/null +++ b/eddy/feedsRun.EddyTest @@ -0,0 +1,71 @@ +#!/bin/sh +# +# This script runs eddy 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 outlier paper. +# + +set -e + +thisdir=$(cd $(dirname $0) && pwd) +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 + +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 + +# Prepare arguments to pass to eddy +eddy_args="--imain=${indir}/EddyTestData/eddyData/testData " \ + "--mask=${indir}/EddyTestData/eddyData/testMask " \ + "--bvals=${indir}/EddyTestData/eddyData/testBvals " \ + "--bvecs=${indir}/EddyTestData/eddyData/testBvecs " \ + "--index=${indir}/EddyTestData/eddyData/testIndex " \ + "--acqp=${indir}/EddyTestData/eddyData/testAcqparams " \ + "--repol --fwhm=10,0,0,0,0 --dfields -v" + +# run eddy +output_prefixes=$(${thisdir}/runEddy ${exedir} ${odir} ${eddy_args} | tail -n1) + +# Define some constants +max_mean_dfield_diff=0.5 +max_max_dfield_diff=1.0 +max_mean_ima_diff=1.5 +max_max_ima_diff=3.0 +allowed_false_positives=1 +allowed_false_negatives=1 + +# Check the results against ground truth +for prefix in ${output_prefixes}; do + ${thisdir}/EddyFeeds.py ${odir} `basename ${prefix}` \ + `imglob -extension ${indir}/EddyTestData/eddyData/testMask` \ + `imglob -extension ${prefix}` \ + `imglob -extension ${indir}/EddyTestData/eddyData/GroundTruth/ground_truth` \ + ${prefix}.eddy_displacement_fields \ + ${indir}/EddyTestData/eddyData/DisplacementFields/DisplacementField \ + ${prefix}.eddy_outlier_map \ + ${indir}/EddyTestData/eddyData/OutlierTruth/dropoutLog_1.txt \ + ${max_mean_ima_diff} ${max_max_ima_diff} ${max_mean_dfield_diff} \ + ${max_max_dfield_diff} ${allowed_false_positives} ${allowed_false_negatives} +done -- GitLab