project (PLM_Testing)

## -------------------------------------------------------------------------
## TODO: create targets like "make check plm-reg-bsp-a"
## http://stackoverflow.com/questions/733475/cmake-ctest-make-test-doesnt-build-tests
## -------------------------------------------------------------------------

## -------------------------------------------------------------------------
## Note on test dependencies.  Some versions of cmake (e.g. Windows cmake 
## version 2.8.2) have a bug where the dependency graph is created 
## incorrectly.  Specifically, if B depends on A, and C depends on 
## both A and B, the graph will be generated incorrectly.  
## -------------------------------------------------------------------------

## -------------------------------------------------------------------------
## Test and data download options
## -------------------------------------------------------------------------
option (PLM_REDUCED_TESTS 
  "Run fewer tests (used when debugging tests)" OFF)
option (PLM_DOWNLOAD_TEST_DATA
  "Additional testing data (download from internet)" OFF)

##-----------------------------------------------------------------------------
## Configure test input files
##-----------------------------------------------------------------------------
set (CONFIG_FILE_LIST
  "plm-bsp-mse-c.txt"
  "plm-bsp-mse-g.txt"
  "plm-bsp-mse-h.txt"
  "plm-bsp-mse-i.txt"
  "plm-bsp-mse-k.txt"
  "plm-bsp-mse-l.txt"
  "plm-bsp-mse-o.txt"
  "plm-bsp-mse-p.txt"
  "plm-bsp-mse-q.txt"
  "plm-bsp-mse-r.txt"
  "plm-bsp-mi-c.txt"
  "plm-bsp-mi-c-2.txt"
  "plm-bsp-mi-k.txt"
  "plm-bsp-gm-k.txt"
  "plm-bsp-dmap-k.txt"
  "plm-bsp-sm-multi-a.txt"
  "plm-bsp-cuda.txt"
  "plm-bsp-rect.txt"
  "plm-bsp-resume.txt"
  "plm-bsp-logfile.txt"
  "plm-bsp-dcos-a.txt"
  "plm-bsp-dcos-b.txt"
  "plm-bsp-dcos-c.txt"
  "plm-bsp-dcos-d.txt"
  "plm-bsp-dcos-e.txt"
  "plm-bsp-dcos-f.txt"
  "plm-bsp-landmark-a.txt"
  "plm-bsp-landmark-b.txt"
  "plm-bsp-landmark-c.txt"
  "plm-bsp-landmark-d.txt"
  "plm-bsp-landmark-e.txt"
  "plm-bsp-double.txt"
  "plm-bsp-regularize-none.txt"
  "plm-bsp-regularize-analytic.txt"
  "plm-bsp-regularize-numeric.txt"
  "plm-reg-align-center.txt"
  "plm-reg-itk-demons.txt"
  "plm-reg-itk-demons-diff.txt"
  "plm-reg-itk-demons-logd.txt"
  "plm-reg-itk-demons-sym-logd.txt"
  "plm-reg-itk-translation.txt"
  "plm-reg-roi-a.txt"
  "plm-reg-roi-b.txt"
  "plm-reg-roi-c.txt"
  "plm-reg-roi-d.txt"
  "plm-reg-roi-e.txt"
  "plm-reg-stiffness-a.txt"
  "plm-reg-multi-a.txt"
  "plm-reg-multi-b.txt"
  "plm-reg-dv-itk-translation.txt"
  "plm-reg-itk-rigid-a.txt"
  "plm-reg-itk-rigid-b.txt"
  "plm-reg-itk-similarity.txt"
  "plm-reg-itk-bspline.txt"
  "plm-reg-process-a.txt"
  "plm-reg-trans-a.txt"
  "plm-reg-trans-b.txt"
  "plm-reg-trans-mi-a.txt"
  "plm-reg-autores-a.txt"
  "plm-reg-autores-b.txt"
  "plm-reg-gw-a.txt"
  "plm-reg-point-dmap-a.txt"
  "proton-dose-1.txt"
  "proton-dose-2.txt"
  "proton-dose-4a.txt"
  "proton-dose-4d.txt"
  "proton-dose-5a.txt"
  "proton-dose-5d.txt"
  "proton-dose-6a.txt"
  "proton-dose-7a.txt"
  "proton-dose-8d.txt"
  "speedtest-a.txt"
  "wed-a.txt"
  "wed-b.txt"
  "wed-c.txt"
)
foreach (CONFIG_FILE ${CONFIG_FILE_LIST})
    string (REGEX REPLACE "\\.txt$" "" PLM_TEST_NAME ${CONFIG_FILE})
    configure_file ("${PLM_TESTING_DATA_DIR}/${CONFIG_FILE}"
	"${PLM_BUILD_TESTING_DIR}/${CONFIG_FILE}"
	@ONLY)
endforeach ()

## -------------------------------------------------------------------------
## Testing macros
## -------------------------------------------------------------------------
macro (plmtest_check_interval 
    test_name stdout_file regex_string lower_thresh upper_thresh)
  string (REPLACE "\\" "\\\\" regex_escaped "${regex_string}")
  add_test (${test_name}
    ${CMAKE_COMMAND} 
    "-DINFILE=${stdout_file}"
    "-DREGEX=${regex_escaped}"
    "-DLOWER_THRESH=${lower_thresh}"
    "-DUPPER_THRESH=${upper_thresh}"
    -P "${PLM_TESTING_SOURCE_DIR}/PlmCheckInterval.cmake"
    )
endmacro ()

macro (plmtest_check_string
    test_name stdout_file regex_string match_string)
  string (REPLACE "\\" "\\\\" regex_escaped "${regex_string}")
  add_test (${test_name}
    ${CMAKE_COMMAND} 
    "-DINFILE=${stdout_file}"
    "-DREGEX=${regex_escaped}"
    "-DMATCH_STRING=${match_string}"
    -P "${PLM_TESTING_SOURCE_DIR}/PlmCheckString.cmake"
    )
endmacro ()

macro (plmtest_debug test_name stdout_file stderr_file)
  add_test (${test_name}
    ${CMAKE_COMMAND} 
    "-DSTDOUT_FILE=${stdout_file}"
    "-DSTDERR_FILE=${stderr_file}"
    -P "${PLM_TESTING_SOURCE_DIR}/PlmTestDebug.cmake"
    )
endmacro ()

## -------------------------------------------------------------------------
## Download data sets
## -------------------------------------------------------------------------
macro (plm_download_and_extract DOWNLOAD_URL DOWNLOAD_FILENAME DOWNLOAD_DIR)
  if (NOT IS_DIRECTORY "${PLM_TESTING_DOWNLOAD_DATA_DIR}")
    file (MAKE_DIRECTORY "${PLM_TESTING_DOWNLOAD_DATA_DIR}")
  endif ()
  set (download_retries 3)
  while (NOT EXISTS ${DOWNLOAD_FILENAME} AND download_retries)
    message (STATUS "Downloading test data: ${DOWNLOAD_FILENAME}")
    file (DOWNLOAD "${DOWNLOAD_URL}" "${DOWNLOAD_FILENAME}"
      STATUS download_status)
    message (STATUS "Download status[${download_retries}]: ${download_status}")
    list (GET download_status 0 dl_status)
    if (dl_status)
      math (EXPR download_retries "${download_retries}-1")
    endif ()
  endwhile ()
  if (NOT EXISTS ${DOWNLOAD_DIR})
    message (STATUS "Untarring test data: ${DOWNLOAD_FILENAME}")
    execute_process (
      COMMAND 
      ${CMAKE_COMMAND} "-E" "tar" "xvzf" "${DOWNLOAD_FILENAME}"
      WORKING_DIRECTORY ${PLM_BUILD_TESTING_DIR}
      RESULT_VARIABLE untar_result
      OUTPUT_VARIABLE untar_output
      ERROR_VARIABLE untar_error)
    message (STATUS "Untar command returned: ${untar_result}\n${untar_output}\n${untar_error}")
  endif ()
endmacro ()

if (PLM_DOWNLOAD_TEST_DATA)

  plm_download_and_extract (
    "https://sourceforge.net/projects/plastimatch/files/Sample%20Data/dicomrt-33-structures.tar.gz/download"
    "${PLM_TESTING_DOWNLOAD_DATA_DIR}/dicomrt-33-structures.tar.gz"
    "${PLM_BUILD_TESTING_DIR}/dicomrt-33-structures")

  plm_download_and_extract (
    "https://sourceforge.net/projects/plastimatch/files/Sample%20Data/dicomrt-aw-4.4-foot.tar.gz/download"
    "${PLM_TESTING_DOWNLOAD_DATA_DIR}/dicomrt-aw-4.4-foot.tar.gz"
    "${PLM_BUILD_TESTING_DIR}/dicomrt-aw-4.4-foot")

  plm_download_and_extract (
    "https://sourceforge.net/projects/plastimatch/files/Sample%20Data/dicomrt-corvus-6.2.2.tar.gz/download"
    "${PLM_TESTING_DOWNLOAD_DATA_DIR}/dicomrt-corvus-6.2.2.tar.gz"
    "${PLM_BUILD_TESTING_DIR}/dicomrt-corvus-6.2.2")

  plm_download_and_extract (
    "https://sourceforge.net/projects/plastimatch/files/Sample%20Data/dicomrt-pinnacle3-8.2g-rando.tar.gz/download"
    "${PLM_TESTING_DOWNLOAD_DATA_DIR}/dicomrt-pinnacle3-8.2g-rando.tar.gz"
    "${PLM_BUILD_TESTING_DIR}/dicomrt-pinnacle3-8.2g-rando")

  plm_download_and_extract (
    "https://sourceforge.net/projects/plastimatch/files/Sample%20Data/dicomrt-xio-4.33.02-chest-phantom.tar.gz/download"
    "${PLM_TESTING_DOWNLOAD_DATA_DIR}/dicomrt-xio-4.33.02-chest-phantom.tar.gz"
    "${PLM_BUILD_TESTING_DIR}/dicomrt-xio-4.33.02-chest-phantom")

  plm_download_and_extract (
    "https://sourceforge.net/projects/plastimatch/files/Sample%20Data/dicomrt-xio-4.60-irregular-spacing.tar.gz/download"
    "${PLM_TESTING_DOWNLOAD_DATA_DIR}/dicomrt-xio-4.60-irregular-spacing.tar.gz"
    "${PLM_BUILD_TESTING_DIR}/dicomrt-xio-4.60-irregular-spacing")

  plm_download_and_extract (
    "https://sourceforge.net/projects/plastimatch/files/Sample%20Data/headphantom.tar.gz/download"
    "${PLM_TESTING_DOWNLOAD_DATA_DIR}/headphantom.tar.gz"
    "${PLM_BUILD_TESTING_DIR}/headphantom")

  plm_download_and_extract (
    "https://sourceforge.net/projects/plastimatch/files/Sample%20Data/rtog-corvus-6.2.2.tar.gz/download"
    "${PLM_TESTING_DOWNLOAD_DATA_DIR}/rtog-corvus-6.2.2.tar.gz"
    "${PLM_BUILD_TESTING_DIR}/rtog-corvus-6.2.2")

  plm_download_and_extract (
    "https://sourceforge.net/projects/plastimatch/files/Sample%20Data/varian-catphan-subset.tar.gz/download"
    "${PLM_TESTING_DOWNLOAD_DATA_DIR}/varian-catphan-subset.tar.gz"
    "${PLM_BUILD_TESTING_DIR}/varian-catphan-subset")

  plm_download_and_extract (
    "https://sourceforge.net/projects/plastimatch/files/Sample%20Data/xio-4.33.02-chest-phantom.tar.gz/download"
    "${PLM_TESTING_DOWNLOAD_DATA_DIR}/xio-4.33.02-chest-phantom.tar.gz"
    "${PLM_BUILD_TESTING_DIR}/xio-4.33.02-chest-phantom")

  plm_download_and_extract (
    "https://sourceforge.net/projects/plastimatch/files/Sample%20Data/xio-4.60-irregular-spacing.tar.gz/download"
    "${PLM_TESTING_DOWNLOAD_DATA_DIR}/xio-4.60-irregular-spacing.tar.gz"
    "${PLM_BUILD_TESTING_DIR}/xio-4.60-irregular-spacing")

endif ()

## -------------------------------------------------------------------------
## Custom test command
## -------------------------------------------------------------------------
add_custom_target (speedtest
  ${CMAKE_COMMAND} 
  -DPLM_PLASTIMATCH_PATH="${PLM_PLASTIMATCH_PATH}"
  -DPLM_BUILD_TESTING_DIR="${PLM_BUILD_TESTING_DIR}"
  -P "${PLM_TESTING_SOURCE_DIR}/PlmSpeedTest.cmake"
  )

## -------------------------------------------------------------------------
## Test cases
## -------------------------------------------------------------------------
## Create synthetic images
##   black-1           All black, slightly different geometry
##   cyl-1             UChar cylinder full height
##   cyl-mask-2        Mask for cyl-2
##   cyl-2             UChar cylinder masked to one z extent
##   cyl-mask-3        Mask for cyl-3
##   cyl-3             UChar cylinder masked to different z extent
##   donut-1           Centered donut
##   donut-2           Centered donut mask (0s and 1s)
##   gabor-xx          Fibonacci Gabor
##   gauss-1           Centered gauss
##   gauss-2           Off-center gauss
##   gauss-3           Inverted gauss
##   gauss-4           Gauss with inverted pixel spacing
##   gauss-5           Even more off-center gauss
##   gauss-6           Off-center gauss, in off-center world coordinates
##   gauss-7           Off-center gauss with wider sigma
##   gauss-ushort-1    Centered gauss, ushort
##   gauss-ushort-2    Off-center gauss, ushort
##   lung-1            Synthetic lung, tumor position 0
##   lung-2            Synthetic lung, tumor position -5
##   gw-lung-a         Synthetic lung, tumor position -5, in gw dir
##   gw-lung-b         Synthetic lung, tumor position 0, in gw dir
##   gw-lung-c         Synthetic lung, tumor position +5, in gw dir
##   pat-1             DICOM data with patient name and patient id
##   ptv-1             rect PTV target for dose calculation
##   ptv-2             rect PTV target for dose calculation, smaller geometry
##   rect-1            Inverted rect, centered
##   rect-2            Standard rect, off-center
##   rect-3            Standard rect, centered
##   rect-4            Uchar rect, centered
##   rect-5            Standard rect, centered, direction cosines alt-1
##   rect-6            Standard rect, centered, direction cosines alt-2
##   rect-7            Standard rect, centered, direction cosines alt-3
##   rect-8            Uchar rect, off-center
##   rect-9            Uchar rect, centered, higher resolution
##   rect-10-roi-1
##   rect-10-roi-2
##   rect-10
##   rect-11
##   rect-11-roi
##   rect-12           Small rect, bg=0, fg=10
##   rect-13           Small rect, bg=0, fg=11
##   rect-14           Small, off-center rect, bg=0, fg=10
##   rect-15           Standard rect, slicer direction cosines
##   rect-16           Off-center rect, slicer direction cosines
##   rect-17           Water phantom, resolution 5x5x5, for dose calculation
##   rect-18	       Water phantom, very low resolution 20x20, dose calc.
##   rect-19	       Standard, but larger rectangle
##   rect-20           Standard rect, rotated and translated
##   rectarr-01        Two rectangles, both centered
##   rectarr-02        Two rectangles, lower rect offset
##   rectarr-m-01      Upper mask for rectarr-01 and rectarr-02
##   rectarr-m-02      Lower mask for rectarr-01 and rectarr-02
##   rectarr-03        Two rectangles, both centered (for testing gamma)
##   rectarr-04        Two rectangles, lower rect offset (for testing gamma)
##   roi-1             left = 0, right = 1
##   rgc-1             rect range compensator for dose calculation
##   sphere-1          Uchar sphere, bg=0, fg=255
##   sphere-2          Standard sphere, centered
##   sphere-3          Standard, bg=0, fg=1
##   sphere-4          Standard, radius = 150
##   sphere-5          Uchar sphere, bg=0, fg=1, abutting image boundary
##   sphere-6          Standard uchar sphere, centered
##   sphere-7          Uchar sphere, bg=0, fg=1
##   xramp-1           X ramp
##   yramp-1           Y ramp
##   zramp-1           Z ramp
## -------------------------------------------------------------------------
set (SYNTH_MHA_SIZE 38)

plm_add_test (
  "black-1"
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "synth;--output;${PLM_BUILD_TESTING_DIR}/black-1.mha;--output-type;float;--pattern;rect;--origin;-25 -25 -25;--dim;40 40 40;--volume-size;50 50 50;--background;-1000;--foreground;-1000"
  )
plm_add_test (
  "cyl-1"
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "synth;--output;${PLM_BUILD_TESTING_DIR}/cyl-1.nrrd;--output-type;uchar;--pattern;cylinder;--origin;-19.5 -19.5 -49.5;--dim;40 40 100;--spacing;1 1 1;--background;0;--foreground;1;--radius;10"
  )
plm_add_test (
  "cyl-mask-2"
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "synth;--output;${PLM_BUILD_TESTING_DIR}/cyl-mask-2.nrrd;--output-type;uchar;--pattern;rect;--origin;-19.5 -19.5 -49.5;--dim;40 40 100;--spacing;1 1 1;--background;0;--foreground;1;--rect-size;-20 20 -20 20 -30 45"
  )
plm_add_test (
  "cyl-2"
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "mask;--input;${PLM_BUILD_TESTING_DIR}/cyl-1.nrrd;--mask;${PLM_BUILD_TESTING_DIR}/cyl-mask-2.nrrd;--output;${PLM_BUILD_TESTING_DIR}/cyl-2.nrrd"
  )
set_tests_properties (cyl-2 PROPERTIES DEPENDS "cyl-1;cyl-mask-2")
plm_add_test (
  "cyl-mask-3"
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "synth;--output;${PLM_BUILD_TESTING_DIR}/cyl-mask-3.nrrd;--output-type;uchar;--pattern;rect;--origin;-19.5 -19.5 -49.5;--dim;40 40 100;--spacing;1 1 1;--background;0;--foreground;1;--rect-size;-20 20 -20 20 -45 40"
  )
plm_add_test (
  "cyl-3"
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "mask;--input;${PLM_BUILD_TESTING_DIR}/cyl-1.nrrd;--mask;${PLM_BUILD_TESTING_DIR}/cyl-mask-3.nrrd;--output;${PLM_BUILD_TESTING_DIR}/cyl-3.nrrd"
  )
set_tests_properties (cyl-3 PROPERTIES DEPENDS "cyl-1;cyl-mask-3")
plm_add_test (
  "donut-1"
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "synth;--output;${PLM_BUILD_TESTING_DIR}/donut-1.mha;--output-ss-img;${PLM_BUILD_TESTING_DIR}/donut-1-ss.mha;--output-ss-list;${PLM_BUILD_TESTING_DIR}/donut-1-ss-list.txt;--output-type;float;--pattern;donut;--origin;-25 -25 -25;--dim;${SYNTH_MHA_SIZE} ${SYNTH_MHA_SIZE} ${SYNTH_MHA_SIZE};--volume-size;50 50 50;--donut-radius;10 10 10;--background;-1000;--foreground;0;--filenames-without-uids;--output-dicom;${PLM_BUILD_TESTING_DIR}/donut-1-dicom;--output-prefix;${PLM_BUILD_TESTING_DIR}/donut-1-prefix/"
  )
plm_add_test (
  "donut-2"
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "synth;--output;${PLM_BUILD_TESTING_DIR}/donut-2.mha;--output-type;uchar;--pattern;donut;--origin;-25 -25 -25;--dim;${SYNTH_MHA_SIZE} ${SYNTH_MHA_SIZE} ${SYNTH_MHA_SIZE};--volume-size;50 50 50;--donut-radius;10 10 10;--background;0;--foreground;1"
)
plm_add_test (
  "gabor-01"
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "synth;--output;${PLM_BUILD_TESTING_DIR}/gabor-01.mha;--pattern;gabor;--origin;-5 -5 -5;--dim;11 11 11;--spacing;1 1 1;--gabor-k-fib;0 1;--gauss-center;0 0 0;--gauss-std;3 3 3;--background;0;--foreground;1"
  )
plm_add_test (
  "gauss-1"
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "synth;--output;${PLM_BUILD_TESTING_DIR}/gauss-1.mha;--output-type;float;--pattern;gauss;--origin;-25 -25 -25;--dim;${SYNTH_MHA_SIZE} ${SYNTH_MHA_SIZE} ${SYNTH_MHA_SIZE};--volume-size;50 50 50;--background;-1000;--foreground;0;--gauss-center;0 0 0;--gauss-std;10 10 10"
  )
plm_add_test (
  "gauss-2"
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "synth;--output;${PLM_BUILD_TESTING_DIR}/gauss-2.mha;--output-type;float;--pattern;gauss;--origin;-25 -25 -25;--dim;${SYNTH_MHA_SIZE} ${SYNTH_MHA_SIZE} ${SYNTH_MHA_SIZE};--volume-size;50 50 50;--background;-1000;--foreground;0;--gauss-center;10 0 0;--gauss-std;10 10 10"
  )
plm_add_test (
  "gauss-3"
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "synth;--output;${PLM_BUILD_TESTING_DIR}/gauss-3.mha;--output-type;float;--pattern;gauss;--origin;-25 -25 -25;--dim;${SYNTH_MHA_SIZE} ${SYNTH_MHA_SIZE} ${SYNTH_MHA_SIZE};--volume-size;50 50 50;--background;0;--foreground;-1000;--gauss-center;10 0 0;--gauss-std;10 10 10"
  )
plm_add_test (
  "gauss-4"
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "synth;--output;${PLM_BUILD_TESTING_DIR}/gauss-4.mha;--output-type;float;--pattern;gauss;--origin;+25 +25 -25;--dim;${SYNTH_MHA_SIZE} ${SYNTH_MHA_SIZE} ${SYNTH_MHA_SIZE};--spacing;-1.31579 -1.31579 2;--background;-1000;--foreground;0;--gauss-center;0 0 0;--gauss-std;10 10 10"
  )
plm_add_test (
  "gauss-5"
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "synth;--output;${PLM_BUILD_TESTING_DIR}/gauss-5.mha;--output-type;float;--pattern;gauss;--origin;-25 -25 -25;--dim;${SYNTH_MHA_SIZE} ${SYNTH_MHA_SIZE} ${SYNTH_MHA_SIZE};--volume-size;50 50 50;--background;-1000;--foreground;0;--gauss-center;20 0 0;--gauss-std;10 10 10"
  )
plm_add_test (
  "gauss-6"
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "synth;--output;${PLM_BUILD_TESTING_DIR}/gauss-6.mha;--output-type;float;--pattern;gauss;--origin;-15 -25 -25;--dim;${SYNTH_MHA_SIZE} ${SYNTH_MHA_SIZE} ${SYNTH_MHA_SIZE};--volume-size;50 50 50;--background;-1000;--foreground;0;--gauss-center;10 0 0;--gauss-std;10 10 10"
  )
plm_add_test (
  "gauss-7"
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "synth;--output;${PLM_BUILD_TESTING_DIR}/gauss-7.mha;--output-type;float;--pattern;gauss;--origin;-25 -25 -25;--dim;${SYNTH_MHA_SIZE} ${SYNTH_MHA_SIZE} ${SYNTH_MHA_SIZE};--volume-size;50 50 50;--background;-1000;--foreground;0;--gauss-center;10 0 0;--gauss-std;20 20 20"
  )
plm_add_test (
  "gauss-double-1"
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "synth;--output;${PLM_BUILD_TESTING_DIR}/gauss-double-1.mha;--output-type;double;--pattern;gauss;--origin;-25 -25 -25;--dim;${SYNTH_MHA_SIZE} ${SYNTH_MHA_SIZE} ${SYNTH_MHA_SIZE};--volume-size;50 50 50;--background;0;--foreground;1000;--gauss-center;0 0 0;--gauss-std;10 10 10"
  )
plm_add_test (
  "gauss-double-2"
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "synth;--output;${PLM_BUILD_TESTING_DIR}/gauss-double-2.mha;--output-type;double;--pattern;gauss;--origin;-25 -25 -25;--dim;${SYNTH_MHA_SIZE} ${SYNTH_MHA_SIZE} ${SYNTH_MHA_SIZE};--volume-size;50 50 50;--background;0;--foreground;1000;--gauss-center;10 0 0;--gauss-std;10 10 10"
  )
plm_add_test (
  "gauss-ushort-1"
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "synth;--output;${PLM_BUILD_TESTING_DIR}/gauss-ushort-1.mha;--output-type;ushort;--pattern;gauss;--origin;-25 -25 -25;--dim;${SYNTH_MHA_SIZE} ${SYNTH_MHA_SIZE} ${SYNTH_MHA_SIZE};--volume-size;50 50 50;--background;0;--foreground;1000;--gauss-center;0 0 0;--gauss-std;10 10 10"
  )
plm_add_test (
  "gauss-ushort-2"
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "synth;--output;${PLM_BUILD_TESTING_DIR}/gauss-ushort-2.mha;--output-type;ushort;--pattern;gauss;--origin;-25 -25 -25;--dim;${SYNTH_MHA_SIZE} ${SYNTH_MHA_SIZE} ${SYNTH_MHA_SIZE};--volume-size;50 50 50;--background;0;--foreground;1000;--gauss-center;10 0 0;--gauss-std;10 10 10"
  )
plm_add_test (
  "lung-1"
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "synth;--filenames-without-uids;--output;${PLM_BUILD_TESTING_DIR}/lung-1.mha;--output-prefix;${PLM_BUILD_TESTING_DIR}/lung-1-prefix;--output-dicom;${PLM_BUILD_TESTING_DIR}/lung-1-dicom;--pattern;lung;--lung-tumor-pos;0"
  )
plm_add_test (
  "lung-2"
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "synth;--filenames-without-uids;--output;${PLM_BUILD_TESTING_DIR}/lung-2.mha;--output-dicom;${PLM_BUILD_TESTING_DIR}/lung-2-dicom;--pattern;lung;--lung-tumor-pos;-5"
  )
plm_add_test (
  "gw-lung-a"
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "synth;--output;${PLM_BUILD_TESTING_DIR}/gw/lung-a.mha;--pattern;lung;--lung-tumor-pos;-5"
  )
plm_add_test (
  "gw-lung-b"
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "synth;--output;${PLM_BUILD_TESTING_DIR}/gw/lung-b.mha;--pattern;lung;--lung-tumor-pos;0"
  )
plm_add_test (
  "gw-lung-c"
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "synth;--output;${PLM_BUILD_TESTING_DIR}/gw/lung-c.mha;--pattern;lung;--lung-tumor-pos;5"
  )
plm_add_test (
  "pat-1"
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "synth;--pattern;rect;--dim;30 30 30;--background;-1000;--foreground;0;--rect-size;20 20 20;--origin;-150 -150 -150;--spacing;10 10 10;--output-dicom;${PLM_BUILD_TESTING_DIR}/pat-1-dicom;--filenames-without-uids;--patient-id;PATIENT-ID;--patient-name;NAME^PATIENT;--series-description;Series Description Here"
  )
plm_add_test (
  "ptv-1"
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "synth;--output;${PLM_BUILD_TESTING_DIR}/ptv-1.mha;--pattern;rect;--dim;60 60 60;--background;0;--foreground;6;--rect-size;20 20 20;--origin;-150 -150 -150;--spacing;5 5 5"
  )
plm_add_test (
  "ptv-2"
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "synth;--output;${PLM_BUILD_TESTING_DIR}/ptv-2.mha;--pattern;rect;--dim;40 40 40;--background;0;--foreground;6;--rect-size;20 20 20;--origin;-100 -100 -100;--spacing;5 5 5"
  )
plm_add_test (
  "rect-1"
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "synth;--filenames-without-uids;--output;${PLM_BUILD_TESTING_DIR}/rect-1.mha;--output-type;float;--output-dose-img;${PLM_BUILD_TESTING_DIR}/rect-1-dose-img.mha;--output-ss-img;${PLM_BUILD_TESTING_DIR}/rect-1-ss.mha;--output-ss-list;${PLM_BUILD_TESTING_DIR}/rect-1-ss-list.txt;--output-dicom;${PLM_BUILD_TESTING_DIR}/rect-1-dicom;--pattern;rect;--dim;${SYNTH_MHA_SIZE} ${SYNTH_MHA_SIZE} ${SYNTH_MHA_SIZE};--background;0;--foreground;-1000"
  )
plm_add_test (
  "rect-2"
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "synth;--output;${PLM_BUILD_TESTING_DIR}/rect-2.mha;--output-type;float;--output-dicom;${PLM_BUILD_TESTING_DIR}/rect-2-dicom;--pattern;rect;--dim;${SYNTH_MHA_SIZE} ${SYNTH_MHA_SIZE} ${SYNTH_MHA_SIZE};--background;-1000;--foreground;0;--rect-size;-30 70 -50 50 -50 50;--patient-name;RECT^SYNTH;--patient-id;RECT-SYNTH;--series-description;rect-2;--filenames-without-uids"
  )

plm_add_test (
  "rect-2s"
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "synth;--pattern;rect;--dim;${SYNTH_MHA_SIZE} ${SYNTH_MHA_SIZE} ${SYNTH_MHA_SIZE};--background;-1000;--foreground;0;--spacing;13.158 13.158 13.158;--rect-size; 200 200 200;--output;${PLM_BUILD_TESTING_DIR}/rect-2s.mha"
  )

plm_add_test (
  "rect-3"
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "synth;--output;${PLM_BUILD_TESTING_DIR}/rect-3.mha;--output-type;float;--output-dicom;${PLM_BUILD_TESTING_DIR}/rect-3-dicom;--pattern;rect;--dim;${SYNTH_MHA_SIZE} ${SYNTH_MHA_SIZE} ${SYNTH_MHA_SIZE};--background;-1000;--foreground;0;--rect-size;-50 50 -50 50 -50 50;--patient-name;RECT^SYNTH;--patient-id;RECT-SYNTH;--series-description;rect-3;--filenames-without-uids"
  )
plm_add_test (
  "rect-4"
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "synth;--output;${PLM_BUILD_TESTING_DIR}/rect-4.mha;--output-type;uchar;--pattern;rect;--dim;${SYNTH_MHA_SIZE} ${SYNTH_MHA_SIZE} ${SYNTH_MHA_SIZE};--background;0;--foreground;1;--rect-size;-50 50 -50 50 -50 50"
  )
plm_add_test (
  "rect-5"
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "synth;--output;${PLM_BUILD_TESTING_DIR}/rect-5.mha;--output-type;float;--pattern;rect;--dim;${SYNTH_MHA_SIZE} ${SYNTH_MHA_SIZE} ${SYNTH_MHA_SIZE};--background;-1000;--foreground;0;--rect-size;-50 50 -50 50 -50 50;--origin;-300 -150 -250;--direction-cosines;rotated-1"
  )
plm_add_test (
  "rect-6"
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "synth;--output;${PLM_BUILD_TESTING_DIR}/rect-6.mha;--output-type;float;--pattern;rect;--dim;${SYNTH_MHA_SIZE} ${SYNTH_MHA_SIZE} ${SYNTH_MHA_SIZE};--background;-1000;--foreground;0;--rect-size;-50 50 -50 50 -50 50;--origin;0 -300 -200;--direction-cosines;rotated-2"
  )
plm_add_test (
  "rect-7"
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "synth;--output;${PLM_BUILD_TESTING_DIR}/rect-7.mha;--output-type;float;--pattern;rect;--dim;${SYNTH_MHA_SIZE} ${SYNTH_MHA_SIZE} ${SYNTH_MHA_SIZE};--background;-1000;--foreground;0;--rect-size;-50 50 -50 50 -50 50;--origin;100 300 -100;--direction-cosines;rotated-3"
  )
plm_add_test (
  "rect-8"
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "synth;--output;${PLM_BUILD_TESTING_DIR}/rect-8.mha;--output-type;uchar;--pattern;rect;--dim;${SYNTH_MHA_SIZE} ${SYNTH_MHA_SIZE} ${SYNTH_MHA_SIZE};--background;0;--foreground;1;--rect-size;-30 70 -50 50 -50 50"
  )
plm_add_test (
  "rect-9"
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "synth;--output;${PLM_BUILD_TESTING_DIR}/rect-9.mha;--output-type;uchar;--pattern;rect;--dim;47 47 47;--background;0;--foreground;1;--rect-size;-50 50 -50 50 -50 50"
  )
plm_add_test (
  "rect-10"
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "synth;--output;${PLM_BUILD_TESTING_DIR}/rect-10.mha;--output-type;float;--pattern;rect;--dim;${SYNTH_MHA_SIZE} ${SYNTH_MHA_SIZE} ${SYNTH_MHA_SIZE};--background;-1000;--foreground;0;--rect-size;-200 50 -50 50 -50 50"
  )
plm_add_test (
  "rect-10-roi-1"
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "synth;--output;${PLM_BUILD_TESTING_DIR}/rect-10-roi-1.mha;--output-type;uchar;--pattern;rect;--dim;${SYNTH_MHA_SIZE} ${SYNTH_MHA_SIZE} ${SYNTH_MHA_SIZE};--background;0;--foreground;1;--rect-size;-60 60 -60 60 -60 60"
  )
plm_add_test (
  "rect-10-roi-2"
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "synth;--output;${PLM_BUILD_TESTING_DIR}/rect-10-roi-2.mha;--output-type;uchar;--pattern;rect;--dim;${SYNTH_MHA_SIZE} ${SYNTH_MHA_SIZE} ${SYNTH_MHA_SIZE};--background;0;--foreground;1;--rect-size;-220 60 -60 60 -60 60"
  )
plm_add_test (
  "rect-11"
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "synth;--output;${PLM_BUILD_TESTING_DIR}/rect-11.mha;--output-type;float;--pattern;rect;--dim;${SYNTH_MHA_SIZE} ${SYNTH_MHA_SIZE} ${SYNTH_MHA_SIZE};--background;0;--foreground;-1000;--rect-size;-40 60 -40 60 -40 60"
  )
plm_add_test (
  "rect-11-roi"
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "synth;--output;${PLM_BUILD_TESTING_DIR}/rect-11-roi.mha;--output-type;uchar;--pattern;rect;--dim;${SYNTH_MHA_SIZE} ${SYNTH_MHA_SIZE} ${SYNTH_MHA_SIZE};--background;0;--foreground;1;--rect-size;-50 80 -50 80 -50 80"
  )
plm_add_test (
  "rect-12"
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "synth;--output;${PLM_BUILD_TESTING_DIR}/rect-12.mha;--output-type;float;--pattern;rect;--dim;20 20 20;--origin;-9.5 -9.5 -9.5;--spacing;1 1 1;--background;0;--foreground;10;--rect-size;-4.5 4.5 -4.5 4.5 -4.5 4.5"
  )
plm_add_test (
  "rect-13"
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "synth;--output;${PLM_BUILD_TESTING_DIR}/rect-13.mha;--output-type;float;--pattern;rect;--dim;20 20 20;--origin;-9.5 -9.5 -9.5;--spacing;1 1 1;--background;0;--foreground;11;--rect-size;-4.5 4.5 -4.5 4.5 -4.5 4.5"
  )
plm_add_test (
  "rect-14"
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "synth;--output;${PLM_BUILD_TESTING_DIR}/rect-14.mha;--output-type;float;--pattern;rect;--dim;20 20 20;--origin;-9.5 -9.5 -9.5;--spacing;1 1 1;--background;0;--foreground;10;--rect-size;-2.5 6.5 -4.5 4.5 -4.5 4.5"
  )
plm_add_test (
  "rect-15"
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "synth;--output;${PLM_BUILD_TESTING_DIR}/rect-15.mha;--output-type;float;--pattern;rect;--dim;${SYNTH_MHA_SIZE} ${SYNTH_MHA_SIZE} ${SYNTH_MHA_SIZE};--background;-1000;--foreground;0;--rect-size;-50 50 -50 50 -50 50;--origin;243.421 243.421 -243.421;--spacing;13.1579 13.1579 13.1579;--direction-cosines;-1 0 0 0 -1 0 0 0 1"
  )
plm_add_test (
  "rect-16"
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "synth;--output;${PLM_BUILD_TESTING_DIR}/rect-16.mha;--output-type;float;--pattern;rect;--dim;${SYNTH_MHA_SIZE} ${SYNTH_MHA_SIZE} ${SYNTH_MHA_SIZE};--background;-1000;--foreground;0;--rect-size;-30 70 -50 50 -50 50;--origin;243.421 243.421 -243.421;--spacing;13.1579 13.1579 13.1579;--direction-cosines;-1 0 0 0 -1 0 0 0 1"
  )
plm_add_test (
  "rect-17"
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "synth;--output;${PLM_BUILD_TESTING_DIR}/rect-17.mha;--pattern;rect;--dim;60 60 60;--background;-1000;--foreground;0;--rect-size;-100 100 -100 100 -100 100;--origin;-150 -150 -150;--spacing;5 5 5"
  )
plm_add_test (
  "rect-18"
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "synth;--output;${PLM_BUILD_TESTING_DIR}/rect-18.mha;--pattern;rect;--dim;15 15 15;--background;-1000;--foreground;0;--rect-size;-100 100 -100 100 -100 100;--origin;-150 -150 -150;--spacing;20 20 20"
  )
plm_add_test (
  "rect-19"
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "synth;--output;${PLM_BUILD_TESTING_DIR}/rect-19.mha;--output-type;float;--pattern;rect;--dim;${SYNTH_MHA_SIZE} ${SYNTH_MHA_SIZE} ${SYNTH_MHA_SIZE};--background;-1000;--foreground;0;--rect-size;-150 150 -150 150 -150 150"
  )
plm_add_test (
  "rectarr-01-a"
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "synth;--output;${PLM_BUILD_TESTING_DIR}/rectarr-01-a.mha;--output-type;float;--pattern;rect;--dim;30 50 30;--background;-1000;--foreground;0;--rect-size;-5 5 -15 -5 -5 5;--origin;-14.5 -24.5 -14.5;--spacing;1 1 1"
  )
plm_add_test (
  "rectarr-01"
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "synth;--input;${PLM_BUILD_TESTING_DIR}/rectarr-01-a.mha;--output;${PLM_BUILD_TESTING_DIR}/rectarr-01.mha;--output-type;float;--pattern;rect;--background;-1000;--foreground;0;--rect-size;-5 5 5 15 -5 5"
  )
plm_add_test (
  "rectarr-02"
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "synth;--input;${PLM_BUILD_TESTING_DIR}/rectarr-01-a.mha;--output;${PLM_BUILD_TESTING_DIR}/rectarr-02.mha;--output-type;float;--pattern;rect;--background;-1000;--foreground;0;--rect-size;-10 0 5 15 -5 5"
  )
set_property (TEST rectarr-01 APPEND PROPERTY DEPENDS rectarr-01-a)
set_property (TEST rectarr-02 APPEND PROPERTY DEPENDS rectarr-01-a)
plm_add_test (
  "rectarr-m-01"
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "synth;--fixed;rectarr-01-a.mha;--output;${PLM_BUILD_TESTING_DIR}/rectarr-m-01.mha;--output-type;uchar;--pattern;rect;--background;0;--foreground;1;--rect-size;-13 13 -20 0 -13 13"
  )
plm_add_test (
  "rectarr-m-02"
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "synth;--fixed;rectarr-01-a.mha;--output;${PLM_BUILD_TESTING_DIR}/rectarr-m-02.mha;--output-type;uchar;--pattern;rect;--background;0;--foreground;1;--rect-size;-13 13 0 20 -13 13"
  )
set_property (TEST rectarr-m-01 APPEND PROPERTY DEPENDS rectarr-01-a)
set_property (TEST rectarr-m-02 APPEND PROPERTY DEPENDS rectarr-01-a)
plm_add_test (
  "rectarr-03-a"
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "synth;--output;${PLM_BUILD_TESTING_DIR}/rectarr-03-a.mha;--output-type;float;--pattern;rect;--dim;30 50 30;--background;0;--foreground;70;--rect-size;-5 5 -15 -5 -5 5;--origin;-14.5 -24.5 -14.5;--spacing;1 1 1"
  )
plm_add_test (
  "rectarr-03"
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "synth;--input;${PLM_BUILD_TESTING_DIR}/rectarr-03-a.mha;--output;${PLM_BUILD_TESTING_DIR}/rectarr-03.mha;--output-type;float;--pattern;rect;--background;0;--foreground;50;--rect-size;-5 5 5 15 -5 5"
  )
plm_add_test (
  "rectarr-04"
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "synth;--input;${PLM_BUILD_TESTING_DIR}/rectarr-03-a.mha;--output;${PLM_BUILD_TESTING_DIR}/rectarr-04.mha;--output-type;float;--pattern;rect;--background;0;--foreground;50;--rect-size;-10 0 5 15 -5 5"
  )
set_property (TEST rectarr-03 APPEND PROPERTY DEPENDS rectarr-03-a)
set_property (TEST rectarr-04 APPEND PROPERTY DEPENDS rectarr-03-a)
plm_add_test (
  "rgc-1"
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "synth;--output;${PLM_BUILD_TESTING_DIR}/rgc-1.mha;--output-type;float;--pattern;rect;--dim;10 10 1;--background;0;--foreground;30;--rect-size;0 10 0 5 0 0;--origin;0 0 0;--spacing;1 1 1"
  )
plm_add_test (
    "roi-1"
    ${PLM_PLASTIMATCH_PATH}/plastimatch
    "synth;--output;${PLM_BUILD_TESTING_DIR}/roi-1.mha;--output-type;uchar;--pattern;rect;--dim;${SYNTH_MHA_SIZE} ${SYNTH_MHA_SIZE} ${SYNTH_MHA_SIZE};--background;0;--foreground;1;--rect-size;0 300 -300 300 -300 300"
    )
plm_add_test (
  "sphere-1"
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "synth;--output;${PLM_BUILD_TESTING_DIR}/sphere-1.mha;--output-type;uchar;--pattern;sphere;--origin;-25 -25 -25;--dim;${SYNTH_MHA_SIZE} ${SYNTH_MHA_SIZE} ${SYNTH_MHA_SIZE};--volume-size;50 50 50;--background;0;--foreground;255;--center;0 0 0;--radius;10 10 10"
  )
plm_add_test (
  "sphere-2"
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "synth;--output;${PLM_BUILD_TESTING_DIR}/sphere-2.mha;--output-type;float;--pattern;sphere;--dim;${SYNTH_MHA_SIZE} ${SYNTH_MHA_SIZE} ${SYNTH_MHA_SIZE};--background;-1000;--foreground;0;--center;0 0 0;--radius;50 50 50"
  )
plm_add_test (
  "sphere-3"
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "synth;--output;${PLM_BUILD_TESTING_DIR}/sphere-3.mha;--output-type;float;--pattern;sphere;--dim;${SYNTH_MHA_SIZE} ${SYNTH_MHA_SIZE} ${SYNTH_MHA_SIZE};--background;0;--foreground;1;--center;0 0 0;--radius;50 50 50"
  )
plm_add_test (
    "sphere-4"
    ${PLM_PLASTIMATCH_PATH}/plastimatch
    "synth;--output;${PLM_BUILD_TESTING_DIR}/sphere-4.mha;--output-type;float;--pattern;sphere;--dim;${SYNTH_MHA_SIZE} ${SYNTH_MHA_SIZE} ${SYNTH_MHA_SIZE};--background;-1000;--foreground;0;--center;0 0 0;--radius;150 150 150"
    )
plm_add_test (
  "sphere-5"
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "synth;--output;${PLM_BUILD_TESTING_DIR}/sphere-5.mha;--output-type;uchar;--pattern;sphere;--origin;-19 -19 -19;--dim;20 20 20;--spacing;2 2 2;--background;0;--foreground;1;--center;0 0 0;--radius;21"
  )
plm_add_test (
  "sphere-6"
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "synth;--output;${PLM_BUILD_TESTING_DIR}/sphere-6.mha;--output-type;uchar;--pattern;sphere;--dim;${SYNTH_MHA_SIZE} ${SYNTH_MHA_SIZE} ${SYNTH_MHA_SIZE};--background;0;--foreground;1;--center;0 0 0;--radius;50 50 50"
  )
plm_add_test (
  "sphere-7"
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "synth;--output;${PLM_BUILD_TESTING_DIR}/sphere-7.mha;--output-type;uchar;--pattern;sphere;--dim;${SYNTH_MHA_SIZE} ${SYNTH_MHA_SIZE} ${SYNTH_MHA_SIZE};--background;0;--foreground;1;--center;0 0 0;--radius;50 50 50"
  )
plm_add_test (
  "xramp-1"
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "synth;--output;${PLM_BUILD_TESTING_DIR}/xramp-1.mha;--output-type;float;--pattern;xramp;--dim;${SYNTH_MHA_SIZE} ${SYNTH_MHA_SIZE} ${SYNTH_MHA_SIZE}"
  )
plm_add_test (
  "yramp-1"
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "synth;--output;${PLM_BUILD_TESTING_DIR}/yramp-1.mha;--output-type;float;--pattern;yramp;--dim;${SYNTH_MHA_SIZE} ${SYNTH_MHA_SIZE} ${SYNTH_MHA_SIZE}"
  )
plm_add_test (
  "zramp-1"
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "synth;--output;${PLM_BUILD_TESTING_DIR}/zramp-1.mha;--output-type;float;--pattern;zramp;--dim;${SYNTH_MHA_SIZE} ${SYNTH_MHA_SIZE} ${SYNTH_MHA_SIZE}"
  )

## -------------------------------------------------------------------------
## Create synthetic vector fields
##   vf-zero         Zero vector field
##   vf-trans-1      Translation x direction, 1cm
##   vf-trans-2      Translation y direction, 1cm
##   vf-radial-1     Radial warp, 1cm
##   vf-gauss-1      Gaussian warp, 10cm std, 1cm x, 2cm y
## -------------------------------------------------------------------------
plm_add_test (
  "vf-zero"
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "synth-vf;--output;${PLM_BUILD_TESTING_DIR}/vf-zero.mha;--xf-zero;--dim;${SYNTH_MHA_SIZE} ${SYNTH_MHA_SIZE} ${SYNTH_MHA_SIZE}"
  )
plm_add_test (
  "vf-trans-1"
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "synth-vf;--output;${PLM_BUILD_TESTING_DIR}/vf-trans-1.mha;--xf-trans;10 0 0;--dim;${SYNTH_MHA_SIZE} ${SYNTH_MHA_SIZE} ${SYNTH_MHA_SIZE}"
  )
plm_add_test (
  "vf-trans-2"
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "synth-vf;--output;${PLM_BUILD_TESTING_DIR}/vf-trans-2.mha;--xf-trans;0 10 0;--dim;${SYNTH_MHA_SIZE} ${SYNTH_MHA_SIZE} ${SYNTH_MHA_SIZE}"
  )
plm_add_test (
  "vf-radial-1"
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "synth-vf;--output;${PLM_BUILD_TESTING_DIR}/vf-radial-1.mha;--xf-radial;--radial-center;0 0 0;--radial-mag;10;--dim;${SYNTH_MHA_SIZE} ${SYNTH_MHA_SIZE} ${SYNTH_MHA_SIZE}"
  )
plm_add_test (
  "vf-gaussian-1"
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "synth-vf;--output;${PLM_BUILD_TESTING_DIR}/vf-gaussian-1.mha;--xf-gauss;--gauss-center;0 0 0;--gauss-mag;10 20 0;--gauss-std;100 100 100;--dim;${SYNTH_MHA_SIZE} ${SYNTH_MHA_SIZE} ${SYNTH_MHA_SIZE}"
  )

## -------------------------------------------------------------------------
## Test synthetic vector fields
## -------------------------------------------------------------------------
plm_add_test (
  "vf-zero-stats"
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "stats;${PLM_BUILD_TESTING_DIR}/vf-zero.mha"
  )
plmtest_check_interval ("vf-zero-check"
  "${PLM_BUILD_TESTING_DIR}/vf-zero-stats.stdout.txt"
  "Mean abs: *([-0-9.]*)"
  "0.000"
  "0.000"
  )
set_property (TEST vf-zero-stats APPEND PROPERTY DEPENDS vf-zero)
set_property (TEST vf-zero-check APPEND PROPERTY DEPENDS vf-zero-stats)

plm_add_test (
  "vf-trans-1-stats"
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "stats;${PLM_BUILD_TESTING_DIR}/vf-trans-1.mha"
  )
plmtest_check_interval ("vf-trans-1-check"
  "${PLM_BUILD_TESTING_DIR}/vf-trans-1-stats.stdout.txt"
  "Mean: *([-0-9.]*)"
  "10.000"
  "10.000"
  )
set_property (TEST vf-trans-1-stats APPEND PROPERTY DEPENDS vf-trans-1)
set_property (TEST vf-trans-1-check APPEND PROPERTY DEPENDS vf-trans-1-stats)

plm_add_test (
  "vf-trans-2-stats"
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "stats;${PLM_BUILD_TESTING_DIR}/vf-trans-2.mha"
  )
plmtest_check_interval ("vf-trans-2-check"
  "${PLM_BUILD_TESTING_DIR}/vf-trans-2-stats.stdout.txt"
  "Mean: *[-0-9.]* *([-0-9.]*)"
  "10.000"
  "10.000"
  )
set_property (TEST vf-trans-2-stats APPEND PROPERTY DEPENDS vf-trans-2)
set_property (TEST vf-trans-2-check APPEND PROPERTY DEPENDS vf-trans-2-stats)

plm_add_test (
  "vf-radial-1-stats"
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "stats;${PLM_BUILD_TESTING_DIR}/vf-radial-1.mha"
  )
plmtest_check_interval ("vf-radial-1-check"
  "${PLM_BUILD_TESTING_DIR}/vf-radial-1-stats.stdout.txt"
  "Mean abs: *([-0-9.]*)"
  "5.15"
  "5.16"
  )
set_property (TEST vf-radial-1-stats APPEND PROPERTY DEPENDS vf-radial-1)
set_property (TEST vf-radial-1-check APPEND PROPERTY DEPENDS vf-radial-1-stats)


## -------------------------------------------------------------------------
## plm-compare-a    Compare two images
## plm-compare-b    Compare two vector fields
## plm-compare-c    Compare two vector fields with ROI
## plm-diff-a       Diff two images
## plm-diff-b       Diff two vector fields
## -------------------------------------------------------------------------
plm_add_test (
  "plm-compare-a"
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "compare;${PLM_BUILD_TESTING_DIR}/gauss-1.mha;${PLM_BUILD_TESTING_DIR}/gauss-2.mha"
  )
plmtest_check_interval ("plm-compare-a-check"
  "${PLM_BUILD_TESTING_DIR}/plm-compare-a.stdout.txt"
  "AVE *([-0-9.]*)"
  "7.76"
  "7.78"
  )
set_tests_properties (plm-compare-a PROPERTIES DEPENDS "gauss-1;gauss-2")
set_tests_properties (plm-compare-a-check PROPERTIES DEPENDS plm-compare-a)

plm_add_test (
  "plm-compare-b"
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "compare;${PLM_BUILD_TESTING_DIR}/vf-trans-1.mha;${PLM_BUILD_TESTING_DIR}/vf-trans-2.mha"
  )
plmtest_check_interval ("plm-compare-b-check"
  "${PLM_BUILD_TESTING_DIR}/plm-compare-b.stdout.txt"
  "Ave len: *([-0-9.]*)"
  "14.141"
  "14.143"
  )
set_tests_properties (plm-compare-b PROPERTIES DEPENDS "vf-trans-1;vf-trans-2")
set_tests_properties (plm-compare-b-check PROPERTIES DEPENDS plm-compare-b)

plm_add_test (
  "plm-compare-c"
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "compare;--mask;${PLM_BUILD_TESTING_DIR}/rect-1.mha;${PLM_BUILD_TESTING_DIR}/vf-trans-1.mha;${PLM_BUILD_TESTING_DIR}/vf-trans-2.mha"
  )
plmtest_check_interval ("plm-compare-c-check"
  "${PLM_BUILD_TESTING_DIR}/plm-compare-c.stdout.txt"
  "Ave len: *([-0-9.]*)"
  "14.141"
  "14.143"
  )
set_tests_properties (plm-compare-c PROPERTIES DEPENDS "rect-1;vf-trans-1;vf-trans-2")
set_tests_properties (plm-compare-c-check PROPERTIES DEPENDS plm-compare-c)

plm_add_test (
  "plm-diff-a"
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "diff;${PLM_BUILD_TESTING_DIR}/gauss-1.mha;${PLM_BUILD_TESTING_DIR}/gauss-2.mha;${PLM_BUILD_TESTING_DIR}/plm-diff-a-img.mha"
  )
plm_add_test ("plm-diff-a-stats"
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "stats;${PLM_BUILD_TESTING_DIR}/plm-diff-a-img.mha"
  )
plmtest_check_interval ("plm-diff-a-check"
  "${PLM_BUILD_TESTING_DIR}/plm-diff-a-stats.stdout.txt"
  "AVE *([-0-9.]*)"
  "7.76"
  "7.78"
  )
set_tests_properties (plm-diff-a PROPERTIES DEPENDS "gauss-1;gauss-2")
set_tests_properties (plm-diff-a-stats PROPERTIES DEPENDS plm-diff-a)
set_tests_properties (plm-diff-a-check PROPERTIES DEPENDS plm-diff-a-stats)

plm_add_test (
  "plm-diff-b"
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "diff;${PLM_BUILD_TESTING_DIR}/vf-trans-1.mha;${PLM_BUILD_TESTING_DIR}/vf-trans-2.mha;${PLM_BUILD_TESTING_DIR}/plm-diff-b-vf.mha"
  )
plm_add_test ("plm-diff-b-stats"
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "stats;${PLM_BUILD_TESTING_DIR}/plm-diff-b-vf.mha"
  )
plmtest_check_interval ("plm-diff-b-check"
  "${PLM_BUILD_TESTING_DIR}/plm-diff-b-stats.stdout.txt"
  "Ave len: *([-0-9.]*)"
  "14.141"
  "14.143"
  )
set_tests_properties (plm-diff-b PROPERTIES DEPENDS "vf-trans-1;vf-trans-2")
set_tests_properties (plm-diff-b-stats PROPERTIES DEPENDS plm-diff-b)
set_tests_properties (plm-diff-b-check PROPERTIES DEPENDS plm-diff-b-stats)


## -------------------------------------------------------------------------
## demons
##   demons-a          gauss-1.mha, gauss-2.mha
##   demons-cuda-a     gauss-1.mha, gauss-2.mha
## -------------------------------------------------------------------------
plm_add_test (
  "demons-a"
  ${PLM_PLASTIMATCH_PATH}/demons
  "-m;50;-s;3;-f;5 5 5;-O;${PLM_BUILD_TESTING_DIR}/demons-a.mha;${PLM_BUILD_TESTING_DIR}/gauss-1.mha;${PLM_BUILD_TESTING_DIR}/gauss-2.mha"
  )
plmtest_check_interval (demons-a-check
  "${PLM_BUILD_TESTING_DIR}/demons-a.stdout.txt"
  "^Mean: *([0-9.]*)"
  "3.4"
  "3.5"
  )
set_property (TEST demons-a APPEND PROPERTY DEPENDS gauss-1)
set_property (TEST demons-a APPEND PROPERTY DEPENDS gauss-2)
set_tests_properties (demons-a-check PROPERTIES DEPENDS demons-a)

plm_add_test (
  "demons-cuda-a"
  ${PLM_PLASTIMATCH_PATH}/demons
  "-A;cuda;-m;50;-s;3;-f;5 5 5;-O;${PLM_BUILD_TESTING_DIR}/demons-cuda-a.mha;${PLM_BUILD_TESTING_DIR}/gauss-1.mha;${PLM_BUILD_TESTING_DIR}/gauss-2.mha"
  )
plmtest_check_interval (demons-cuda-a-check
  "${PLM_BUILD_TESTING_DIR}/demons-cuda-a.stdout.txt"
  "^Mean: *([0-9.]*)"
  "3.3"
  "3.4"
  )
set_property (TEST demons-cuda-a APPEND PROPERTY DEPENDS gauss-1)
set_property (TEST demons-cuda-a APPEND PROPERTY DEPENDS gauss-2)
set_tests_properties (demons-cuda-a-check PROPERTIES DEPENDS demons-cuda-a)

## -------------------------------------------------------------------------
## drr
##   drr-a       gauss-1.mha (normal image), exact
##   drr-b       gauss-1.mha (normal image), uniform
##   drr-c       gauss-4.mha (negative spacing), exact
##   drr-d       gauss-4.mha (negative spacing), uniform
##   drr-cuda    gauss-1.mha, uniform
##   drr-opencl  gauss-1.mha, uniform
## -------------------------------------------------------------------------
plm_add_test (
  "drr-a"
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "drr;-a;20;-O;${PLM_BUILD_TESTING_DIR}/drr-a/out_;${PLM_BUILD_TESTING_DIR}/gauss-1.mha"
  )
plm_add_test (
  "drr-a-stats"
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "stats;${PLM_BUILD_TESTING_DIR}/drr-a/out_0010.pfm"
  )
plmtest_check_interval ("drr-a-check"
  "${PLM_BUILD_TESTING_DIR}/drr-a-stats.stdout.txt"
  "MAX *([-0-9.]*)"
  "0.045"
  "0.055"
  )
set_tests_properties (drr-a PROPERTIES DEPENDS gauss-1)
set_tests_properties (drr-a-stats PROPERTIES DEPENDS drr-a)
set_tests_properties (drr-a-check PROPERTIES DEPENDS drr-a-stats)

plm_add_test (
  "drr-b"
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "drr;-a;20;-O;${PLM_BUILD_TESTING_DIR}/drr-b/out_;-i;uniform;${PLM_BUILD_TESTING_DIR}/gauss-1.mha"
  )
plm_add_test (
  "drr-b-stats"
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "stats;drr-b/out_0010.pfm"
  )
plmtest_check_interval ("drr-b-check"
  "${PLM_BUILD_TESTING_DIR}/drr-b-stats.stdout.txt"
  "MAX *([-0-9.]*)"
  "0.045"
  "0.055"
  )
set_tests_properties (drr-b PROPERTIES DEPENDS gauss-1)
set_tests_properties (drr-b-stats PROPERTIES DEPENDS drr-b)
set_tests_properties (drr-b-check PROPERTIES DEPENDS drr-b-stats)

plm_add_test (
  "drr-c"
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "drr;-a;20;-O;${PLM_BUILD_TESTING_DIR}/drr-c/out_;${PLM_BUILD_TESTING_DIR}/gauss-4.mha"
  )
plm_add_test (
  "drr-c-stats"
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "stats;drr-c/out_0010.pfm"
  )
plmtest_check_interval ("drr-c-check"
  "${PLM_BUILD_TESTING_DIR}/drr-c-stats.stdout.txt"
  "MAX *([-0-9.]*)"
  "0.045"
  "0.055"
  )
set_tests_properties (drr-c PROPERTIES DEPENDS gauss-4)
set_tests_properties (drr-c-stats PROPERTIES DEPENDS drr-c)
set_tests_properties (drr-c-check PROPERTIES DEPENDS drr-c-stats)

plm_add_test (
  "drr-d"
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "drr;-a;20;-O;${PLM_BUILD_TESTING_DIR}/drr-d/out_;-i;uniform;${PLM_BUILD_TESTING_DIR}/gauss-4.mha"
  )
plm_add_test (
  "drr-d-stats"
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "stats;drr-d/out_0010.pfm"
  )
plmtest_check_interval ("drr-d-check"
  "${PLM_BUILD_TESTING_DIR}/drr-d-stats.stdout.txt"
  "MAX *([-0-9.]*)"
  "0.045"
  "0.055"
  )
set_tests_properties (drr-d PROPERTIES DEPENDS gauss-1)
set_tests_properties (drr-d-stats PROPERTIES DEPENDS drr-d)
set_tests_properties (drr-d-check PROPERTIES DEPENDS drr-d-stats)

plm_add_test (
  "drr-cuda"
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "drr;-A;cuda;-a;20;-O;${PLM_BUILD_TESTING_DIR}/drr-cuda/out_;${PLM_BUILD_TESTING_DIR}/gauss-1.mha"
  )
plm_add_test (
  "drr-cuda-stats"
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "stats;${PLM_BUILD_TESTING_DIR}/drr-cuda/out_0010.pfm"
  )
plmtest_check_interval ("drr-cuda-check"
  "${PLM_BUILD_TESTING_DIR}/drr-cuda-stats.stdout.txt"
  "MAX *([-0-9.]*)"
  "0.045"
  "0.055"
  )
set_tests_properties (drr-cuda PROPERTIES DEPENDS gauss-1)
set_tests_properties (drr-cuda-stats PROPERTIES DEPENDS drr-cuda)
set_tests_properties (drr-cuda-check PROPERTIES DEPENDS drr-cuda-stats)

plm_add_test (
  "drr-opencl"
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "drr;-A;opencl;-a;20;-O;${PLM_BUILD_TESTING_DIR}/drr-opencl/out_;${PLM_BUILD_TESTING_DIR}/gauss-1.mha"
  )
plm_add_test (
  "drr-opencl-stats"
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "stats;${PLM_BUILD_TESTING_DIR}/drr-opencl/out_0010.pfm"
  )
plmtest_check_interval ("drr-opencl-check"
  "${PLM_BUILD_TESTING_DIR}/drr-opencl-stats.stdout.txt"
  "MAX *([-0-9.]*)"
  "0.045"
  "0.055"
  )
set_tests_properties (drr-opencl PROPERTIES DEPENDS gauss-1)
set_tests_properties (drr-opencl-stats PROPERTIES DEPENDS drr-opencl)
set_tests_properties (drr-opencl-check PROPERTIES DEPENDS drr-opencl-stats)

## -------------------------------------------------------------------------
## fdk - all tests using fdk filtered backprojection
##   fdk-cpu-a     CPU reconstruction of synthetic data, flavor a
##   fdk-cpu-b     CPU reconstruction of Varian data, no filtering
##   fdk-cpu-c     CPU reconstruction of Varian data, fftw filtering
##   fdk-cpu-d     CPU reconstruction of synthetic data, flavor 0
##   fdk-cuda-a    GPU reconstruction of synthetic data using CUDA
##    [fdk-cuda-b  GPU reconstruction of Varian data using CUDA
##   fdk-opencl-a  GPU reconstruction of synthetic data using OpenCL
## -------------------------------------------------------------------------
plm_add_test (
  "fdk-cpu-a"
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "fdk;-I;${PLM_BUILD_TESTING_DIR}/drr-a;-f;none;-a;0 19;-O;${PLM_BUILD_TESTING_DIR}/fdk-cpu-a.mha"
  )
plm_add_test (
  "fdk-cpu-a-stats"
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "stats;${PLM_BUILD_TESTING_DIR}/fdk-cpu-a.mha"
  )
plmtest_check_interval ("fdk-cpu-a-check"
  "${PLM_BUILD_TESTING_DIR}/fdk-cpu-a-stats.stdout.txt"
  "MAX *([-0-9.]*)"
  "-987.5"
  "-986.5"
  )
set_tests_properties (fdk-cpu-a PROPERTIES DEPENDS drr-a)
set_tests_properties (fdk-cpu-a-stats PROPERTIES DEPENDS fdk-cpu-a)
set_tests_properties (fdk-cpu-a-check PROPERTIES DEPENDS fdk-cpu-a-stats)

plm_add_test (
  "fdk-cpu-b"
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "fdk;-I;${PLM_BUILD_TESTING_DIR}/varian-catphan-subset;-f;none;-a;0 20 670;-O;${PLM_BUILD_TESTING_DIR}/fdk-cpu-b.mha"
  )
plm_add_test (
  "fdk-cpu-b-stats"
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "stats;${PLM_BUILD_TESTING_DIR}/fdk-cpu-b.mha"
  )
plmtest_check_interval ("fdk-cpu-b-check"
  "${PLM_BUILD_TESTING_DIR}/fdk-cpu-b-stats.stdout.txt"
  "AVE *([-0-9.]*)"
  "-708.1"
  "-707.5"
  )
set_tests_properties (fdk-cpu-b-stats PROPERTIES DEPENDS fdk-cpu-b)
set_tests_properties (fdk-cpu-b-check PROPERTIES DEPENDS fdk-cpu-b-stats)

plm_add_test (
  "fdk-cpu-c"
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "fdk;-I;${PLM_BUILD_TESTING_DIR}/varian-catphan-subset;-f;ramp;-a;0 50 670;-O;${PLM_BUILD_TESTING_DIR}/fdk-cpu-c.mha"
  )
plm_add_test (
  "fdk-cpu-c-stats"
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "stats;${PLM_BUILD_TESTING_DIR}/fdk-cpu-c.mha"
  )
plmtest_check_interval ("fdk-cpu-c-check"
  "${PLM_BUILD_TESTING_DIR}/fdk-cpu-c-stats.stdout.txt"
  "AVE *([-0-9.]*)"
  "-982.3"
  "-981.5"
  )
set_tests_properties (fdk-cpu-c-stats PROPERTIES DEPENDS fdk-cpu-c)
set_tests_properties (fdk-cpu-c-check PROPERTIES DEPENDS fdk-cpu-c-stats)

plm_add_test (
  "fdk-cpu-d"
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "fdk;-I;${PLM_BUILD_TESTING_DIR}/drr-a;-X;0;-f;none;-a;0 19;-O;${PLM_BUILD_TESTING_DIR}/fdk-cpu-d.mha"
  )
plm_add_test (
  "fdk-cpu-d-stats"
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "stats;${PLM_BUILD_TESTING_DIR}/fdk-cpu-d.mha"
  )
plmtest_check_interval ("fdk-cpu-d-check"
  "${PLM_BUILD_TESTING_DIR}/fdk-cpu-d-stats.stdout.txt"
  "MAX *([-0-9.]*)"
  "-987.5"
  "-986.5"
  )
set_tests_properties (fdk-cpu-d PROPERTIES DEPENDS drr-a)
set_tests_properties (fdk-cpu-d-stats PROPERTIES DEPENDS fdk-cpu-d)
set_tests_properties (fdk-cpu-d-check PROPERTIES DEPENDS fdk-cpu-d-stats)

plm_add_test (
  "fdk-cuda-a"
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "fdk;-I;${PLM_BUILD_TESTING_DIR}/drr-a;-f;none;-A;cuda;-a;0 19;-O;${PLM_BUILD_TESTING_DIR}/fdk-cuda-a.mha"
  )
plm_add_test (
  "fdk-cuda-a-stats"
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "stats;${PLM_BUILD_TESTING_DIR}/fdk-cuda-a.mha"
  )
plmtest_check_interval ("fdk-cuda-a-check"
  "${PLM_BUILD_TESTING_DIR}/fdk-cuda-a-stats.stdout.txt"
  "MAX *([-0-9.]*)"
  "-987.5"
  "-986.5"
  )
set_tests_properties (fdk-cuda-a PROPERTIES DEPENDS drr-a)
set_tests_properties (fdk-cuda-a-stats PROPERTIES DEPENDS fdk-cuda-a)
set_tests_properties (fdk-cuda-a-check PROPERTIES DEPENDS fdk-cuda-a-stats)

plm_add_test (
  "fdk-opencl-a"
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "fdk;-I;${PLM_BUILD_TESTING_DIR}/drr-a;-f;none;-A;opencl;-a;0 19;-O;${PLM_BUILD_TESTING_DIR}/fdk-opencl-a.mha"
  )
plm_add_test (
  "fdk-opencl-a-stats"
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "stats;${PLM_BUILD_TESTING_DIR}/fdk-opencl-a.mha"
  )
plmtest_check_interval ("fdk-opencl-a-check"
  "${PLM_BUILD_TESTING_DIR}/fdk-opencl-a-stats.stdout.txt"
  "MAX *([-0-9.]*)"
  "-987.5"
  "-986.5"
  )
set_tests_properties (fdk-opencl-a PROPERTIES DEPENDS drr-a)
set_tests_properties (fdk-opencl-a-stats PROPERTIES DEPENDS fdk-opencl-a)
set_tests_properties (fdk-opencl-a-check PROPERTIES DEPENDS fdk-opencl-a-stats)

## -------------------------------------------------------------------------
## fdk_tutorial - run the fdk tutorial
## -------------------------------------------------------------------------
plm_add_test (
  "fdk-tutorial-a"
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "drr;-t;pfm;-a;60;-N;3;--sad;1000;--sid;1500;-r;100 100;-z;300 300;-I;${PLM_BUILD_TESTING_DIR}/headphantom/headphantom.mha;-O;${PLM_BUILD_TESTING_DIR}/fdk-tutorial-a/"
  )
plm_add_test (
  "fdk-tutorial-b"
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "fdk;-f;none;-r;100 100 100;-I;${PLM_BUILD_TESTING_DIR}/fdk-tutorial-a;-O;${PLM_BUILD_TESTING_DIR}/fdk-tutorial-b.mha"
  )
plm_add_test (
  "fdk-tutorial-b-stats-1"
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "stats;${PLM_BUILD_TESTING_DIR}/fdk-tutorial-b.mha"
  )
plmtest_check_interval ("fdk-tutorial-b-check-1"
  "${PLM_BUILD_TESTING_DIR}/fdk-tutorial-b-stats-1.stdout.txt"
  "AVE *([-0-9.]*)"
  "-955.8"
  "-954.8"
  )
plm_add_test (
  "fdk-tutorial-c"
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "fdk;-f;ramp;-r;100 100 100;-I;${PLM_BUILD_TESTING_DIR}/fdk-tutorial-a;-O;${PLM_BUILD_TESTING_DIR}/fdk-tutorial-c.mha"
  )
plm_add_test (
  "fdk-tutorial-c-stats-1"
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "stats;${PLM_BUILD_TESTING_DIR}/fdk-tutorial-c.mha"
  )
plmtest_check_interval ("fdk-tutorial-c-check-1"
  "${PLM_BUILD_TESTING_DIR}/fdk-tutorial-c-stats-1.stdout.txt"
  "AVE *([-0-9.]*)"
  "-999.0"
  "-998.0"
  )
set_tests_properties (fdk-tutorial-b PROPERTIES DEPENDS fdk-tutorial-a)
set_tests_properties (fdk-tutorial-b-stats-1 PROPERTIES DEPENDS fdk-tutorial-b)
set_tests_properties (fdk-tutorial-b-check-1 PROPERTIES 
  DEPENDS fdk-tutorial-b-stats-1)
set_tests_properties (fdk-tutorial-c PROPERTIES DEPENDS fdk-tutorial-a)
set_tests_properties (fdk-tutorial-c-stats-1 PROPERTIES DEPENDS fdk-tutorial-c)
set_tests_properties (fdk-tutorial-c-check-1 PROPERTIES 
  DEPENDS fdk-tutorial-c-stats-1)

## -------------------------------------------------------------------------
## landmark_warp a: itk tps, slicer fcsv
## landmark_warp b: wendland rbf, slicer fcsv
## landmark_warp c: gauss rbf, slicer fcsv
## landmark_warp d: itk tps, slicer fcsv, -L option
## -------------------------------------------------------------------------
plm_add_test (
  "landmark-warp-a" 
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "lm-warp;-a;tps;-f;${PLM_TESTING_DATA_DIR}/fiducials-rect-2.fcsv;-m;${PLM_TESTING_DATA_DIR}/fiducials-rect-3.fcsv;-I;${PLM_BUILD_TESTING_DIR}/rect-3.mha;-O;${PLM_BUILD_TESTING_DIR}/landmark-warp-a-img.mha;-V;${PLM_BUILD_TESTING_DIR}/landmark-warp-a-vf.mha"
  )
plm_add_test (
  "landmark-warp-a-stats-1"
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "stats;${PLM_BUILD_TESTING_DIR}/landmark-warp-a-img.mha"
  )
plmtest_check_interval ("landmark-warp-a-check-1"
  "${PLM_BUILD_TESTING_DIR}/landmark-warp-a-stats-1.stdout.txt"
  "AVE *([-0-9.]*)"
  "-992.0"
  "-991.5"
  )
plm_add_test (
  "landmark-warp-a-stats-2"
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "stats;${PLM_BUILD_TESTING_DIR}/landmark-warp-a-vf.mha"
  )
plmtest_check_interval ("landmark-warp-a-check-2"
  "${PLM_BUILD_TESTING_DIR}/landmark-warp-a-stats-2.stdout.txt"
  "Mean: *([-0-9.]*)"
  "-23.2"
  "-22.7"
  )
set_tests_properties (landmark-warp-a PROPERTIES DEPENDS rect-3)
set_tests_properties (landmark-warp-a-stats-1 PROPERTIES 
  DEPENDS landmark-warp-a)
set_tests_properties (landmark-warp-a-check-1 PROPERTIES 
  DEPENDS landmark-warp-a-stats-1)
set_tests_properties (landmark-warp-a-stats-2 PROPERTIES 
  DEPENDS landmark-warp-a)
set_tests_properties (landmark-warp-a-check-2 PROPERTIES 
  DEPENDS landmark-warp-a-stats-2)

plm_add_test (
  "landmark-warp-b" 
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "lm-warp;-a;wendland;-f;${PLM_TESTING_DATA_DIR}/fiducials-rect-2.fcsv;-m;${PLM_TESTING_DATA_DIR}/fiducials-rect-3.fcsv;-I;${PLM_BUILD_TESTING_DIR}/rect-3.mha;-O;${PLM_BUILD_TESTING_DIR}/landmark-warp-b-img.mha;-V;${PLM_BUILD_TESTING_DIR}/landmark-warp-b-vf.mha;-r;90;-d;0;-Y;0.0"
  )
plm_add_test (
  "landmark-warp-b-stats-1"
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "stats;${PLM_BUILD_TESTING_DIR}/landmark-warp-b-img.mha"
  )
plmtest_check_interval ("landmark-warp-b-check-1"
  "${PLM_BUILD_TESTING_DIR}/landmark-warp-b-stats-1.stdout.txt"
  "AVE *([-0-9.]*)"
  "-992.2"
  "-991.8"
  )
plm_add_test (
  "landmark-warp-b-stats-2"
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "stats;${PLM_BUILD_TESTING_DIR}/landmark-warp-b-vf.mha"
  )
plmtest_check_interval ("landmark-warp-b-check-2"
  "${PLM_BUILD_TESTING_DIR}/landmark-warp-b-stats-2.stdout.txt"
  "Mean: *([-0-9.]*)"
  "-1.55"
  "-1.4"
  )
set_tests_properties (landmark-warp-b PROPERTIES DEPENDS rect-3)
set_tests_properties (landmark-warp-b-stats-1 PROPERTIES 
  DEPENDS landmark-warp-b)
set_tests_properties (landmark-warp-b-check-1 PROPERTIES 
  DEPENDS landmark-warp-b-stats-1)
set_tests_properties (landmark-warp-b-stats-2 PROPERTIES 
  DEPENDS landmark-warp-b)
set_tests_properties (landmark-warp-b-check-2 PROPERTIES 
  DEPENDS landmark-warp-b-stats-2)

plm_add_test (
  "landmark-warp-c" 
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "lm-warp;-a;gauss;-f;${PLM_TESTING_DATA_DIR}/fiducials-rect-2.fcsv;-m;${PLM_TESTING_DATA_DIR}/fiducials-rect-3.fcsv;-I;${PLM_BUILD_TESTING_DIR}/rect-3.mha;-O;${PLM_BUILD_TESTING_DIR}/landmark-warp-c-img.mha;-V;${PLM_BUILD_TESTING_DIR}/landmark-warp-c-vf.mha;-r;74;-d;0;-Y;1.0"
  )
plm_add_test (
  "landmark-warp-c-stats-1"
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "stats;${PLM_BUILD_TESTING_DIR}/landmark-warp-c-img.mha"
  )
plmtest_check_interval ("landmark-warp-c-check-1"
  "${PLM_BUILD_TESTING_DIR}/landmark-warp-c-stats-1.stdout.txt"
  "AVE *([-0-9.]*)"
  "-992.0"
  "-991.5"
  )
plm_add_test (
  "landmark-warp-c-stats-2"
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "stats;${PLM_BUILD_TESTING_DIR}/landmark-warp-c-vf.mha"
  )
plmtest_check_interval ("landmark-warp-c-check-2"
  "${PLM_BUILD_TESTING_DIR}/landmark-warp-c-stats-2.stdout.txt"
  "Mean: *([-0-9.]*)"
  "-1.6"
  "-1.5"
  )
set_tests_properties (landmark-warp-c PROPERTIES DEPENDS rect-3)
set_tests_properties (landmark-warp-c-stats-1 PROPERTIES 
  DEPENDS landmark-warp-c)
set_tests_properties (landmark-warp-c-check-1 PROPERTIES 
  DEPENDS landmark-warp-c-stats-1)
set_tests_properties (landmark-warp-c-stats-2 PROPERTIES 
  DEPENDS landmark-warp-c)
set_tests_properties (landmark-warp-c-check-2 PROPERTIES 
  DEPENDS landmark-warp-c-stats-2)

plm_add_test (
  "landmark-warp-d" 
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "lm-warp;-a;tps;-f;${PLM_TESTING_DATA_DIR}/fiducials-rect-2.fcsv;-m;${PLM_TESTING_DATA_DIR}/fiducials-rect-3.fcsv;-I;${PLM_BUILD_TESTING_DIR}/rect-3.mha;-O;${PLM_BUILD_TESTING_DIR}/landmark-warp-d-img.mha;-V;${PLM_BUILD_TESTING_DIR}/landmark-warp-d-vf.mha;-L;${PLM_BUILD_TESTING_DIR}/landmark-warp-d.fcsv"
  )
set_tests_properties (landmark-warp-d PROPERTIES DEPENDS rect-3)

## -------------------------------------------------------------------------
## plastimatch add, plastimatch average
##  plm-add-a      Add two images
##  plm-add-b      Average two images
##  plm-add-vf-a   Add two vector fields
##  plm-add-vf-b   Average two vector fields
## -------------------------------------------------------------------------
plm_add_test (
  "plm-add-a"
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "add;--output;${PLM_BUILD_TESTING_DIR}/plm-add-a.nrrd;${PLM_BUILD_TESTING_DIR}/rect-1.mha;${PLM_BUILD_TESTING_DIR}/rect-3.mha"
  )
plm_add_test (
  "plm-add-a-stats"
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "stats;${PLM_BUILD_TESTING_DIR}/plm-add-a.nrrd"
  )
plmtest_check_interval ("plm-add-a-check"
  "${PLM_BUILD_TESTING_DIR}/plm-add-a-stats.stdout.txt"
  "AVE *([-0-9.]*)"
  "-1000.1"
  "-999.9"
  )
set_tests_properties (plm-add-a PROPERTIES DEPENDS "rect-1;rect-3")
set_tests_properties (plm-add-a-stats PROPERTIES DEPENDS plm-add-a)
set_tests_properties (plm-add-a-check PROPERTIES DEPENDS plm-add-a-stats)

plm_add_test (
  "plm-add-b"
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "average;--output;${PLM_BUILD_TESTING_DIR}/plm-add-b.nrrd;${PLM_BUILD_TESTING_DIR}/rect-1.mha;${PLM_BUILD_TESTING_DIR}/rect-3.mha"
  )
plm_add_test (
  "plm-add-b-stats"
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "stats;${PLM_BUILD_TESTING_DIR}/plm-add-b.nrrd"
  )
plmtest_check_interval ("plm-add-b-check"
  "${PLM_BUILD_TESTING_DIR}/plm-add-b-stats.stdout.txt"
  "AVE *([-0-9.]*)"
  "-500.1"
  "-499.9"
  )
set_tests_properties (plm-add-b PROPERTIES DEPENDS "rect-1;rect-3")
set_tests_properties (plm-add-b-stats PROPERTIES DEPENDS plm-add-b)
set_tests_properties (plm-add-b-check PROPERTIES DEPENDS plm-add-b-stats)


plm_add_test (
  "plm-add-vf-a"
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "add;--output;${PLM_BUILD_TESTING_DIR}/plm-add-vf-a.nrrd;${PLM_BUILD_TESTING_DIR}/vf-trans-1.mha;${PLM_BUILD_TESTING_DIR}/vf-trans-1.mha"
  )
plm_add_test (
  "plm-add-vf-a-stats"
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "stats;${PLM_BUILD_TESTING_DIR}/plm-add-vf-a.nrrd"
  )
plmtest_check_interval ("plm-add-vf-a-check"
  "${PLM_BUILD_TESTING_DIR}/plm-add-vf-a-stats.stdout.txt"
  "Mean: *([-0-9.]*)"
  "20.000"
  "20.000"
  )
set_tests_properties (plm-add-vf-a PROPERTIES DEPENDS vf-trans-1)
set_tests_properties (plm-add-vf-a-stats PROPERTIES DEPENDS plm-add-vf-a)
set_tests_properties (plm-add-vf-a-check PROPERTIES DEPENDS plm-add-vf-a-stats)

plm_add_test (
  "plm-add-vf-b"
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "average;--output;${PLM_BUILD_TESTING_DIR}/plm-add-vf-b.nrrd;${PLM_BUILD_TESTING_DIR}/vf-trans-1.mha;${PLM_BUILD_TESTING_DIR}/vf-trans-2.mha"
  )
plm_add_test (
  "plm-add-vf-b-stats"
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "stats;${PLM_BUILD_TESTING_DIR}/plm-add-vf-b.nrrd"
  )
plmtest_check_interval ("plm-add-vf-b-check"
  "${PLM_BUILD_TESTING_DIR}/plm-add-vf-b-stats.stdout.txt"
  "Mean: *([-0-9.]*)"
  "5.000"
  "5.000"
  )
set_tests_properties (plm-add-vf-b PROPERTIES DEPENDS "vf-trans-1;vf-trans-2")
set_tests_properties (plm-add-vf-b-stats PROPERTIES DEPENDS plm-add-vf-b)
set_tests_properties (plm-add-vf-b-check PROPERTIES DEPENDS plm-add-vf-b-stats)

## -------------------------------------------------------------------------
## plm-adjust-a     shift intensities by 100 with --pw-linear
## plm-adjust-b     shift intensities by 100 with --pw-linear and 
##                   explicit extrapolation
## plm-adjust-c     shift intensities by 100 with --linear
## plm-adjust-d     truncation of intensity values between -800 and -600
## plm-adjust-e     shift and scale (1000,2.5) intensities with --linear
## plm-adjust-f     histogram matching
## plm-adjust-g     linear-match
## plm-adjust-h     linear-match with masking
## plm-adjust-i     local-match
## plm-adjust-j     local-match, no blending
## -------------------------------------------------------------------------
plm_add_test (
  "plm-adjust-a"
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "adjust;--input;${PLM_BUILD_TESTING_DIR}/gauss-4.mha;--output;${PLM_BUILD_TESTING_DIR}/plm-adjust-a.nrrd;--pw-linear;0,100"
)
plm_add_test (
  "plm-adjust-a-stats"
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "stats;${PLM_BUILD_TESTING_DIR}/plm-adjust-a.nrrd"
)
plmtest_check_interval (
  "plm-adjust-a-check"
  "${PLM_BUILD_TESTING_DIR}/plm-adjust-a-stats.stdout.txt"
  "AVE *([-0-9.]*)"
  "-819.55"
  "-819.54"
)
set_tests_properties (plm-adjust-a PROPERTIES DEPENDS "gauss-4")
set_tests_properties (plm-adjust-a-stats PROPERTIES DEPENDS "plm-adjust-a")
set_tests_properties (plm-adjust-a-check PROPERTIES DEPENDS "plm-adjust-a-stats")

plm_add_test (
  "plm-adjust-b"
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "adjust;--input;${PLM_BUILD_TESTING_DIR}/gauss-4.mha;--output;${PLM_BUILD_TESTING_DIR}/plm-adjust-b.nrrd;--pw-linear;-inf,1,0,100,inf,1"
)
plm_add_test (
  "plm-adjust-b-stats"
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "stats;${PLM_BUILD_TESTING_DIR}/plm-adjust-b.nrrd"
)
plmtest_check_interval (
  "plm-adjust-b-check"
  "${PLM_BUILD_TESTING_DIR}/plm-adjust-b-stats.stdout.txt"
  "AVE *([-0-9.]*)"
  "-819.55"
  "-819.54"
)
set_tests_properties (plm-adjust-b PROPERTIES DEPENDS "gauss-4")
set_tests_properties (plm-adjust-b-stats PROPERTIES DEPENDS "plm-adjust-b")
set_tests_properties (plm-adjust-b-check PROPERTIES DEPENDS "plm-adjust-b-stats")

plm_add_test (
  "plm-adjust-c"
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "adjust;--input;${PLM_BUILD_TESTING_DIR}/gauss-4.mha;--output;${PLM_BUILD_TESTING_DIR}/plm-adjust-c.nrrd;--linear;100,1"
)
plm_add_test (
  "plm-adjust-c-stats"
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "stats;${PLM_BUILD_TESTING_DIR}/plm-adjust-c.nrrd"
)
plmtest_check_interval (
  "plm-adjust-c-check"
  "${PLM_BUILD_TESTING_DIR}/plm-adjust-c-stats.stdout.txt"
  "AVE *([-0-9.]*)"
  "-819.55"
  "-819.54"
)
set_tests_properties (plm-adjust-c PROPERTIES DEPENDS "gauss-4")
set_tests_properties (plm-adjust-c-stats PROPERTIES DEPENDS "plm-adjust-c")
set_tests_properties (plm-adjust-c-check PROPERTIES DEPENDS "plm-adjust-c-stats")

plm_add_test (
  "plm-adjust-d"
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "adjust;--input;${PLM_BUILD_TESTING_DIR}/gauss-4.mha;--output;${PLM_BUILD_TESTING_DIR}/plm-adjust-d.nrrd;--pw-linear;-inf,0,-800,-800,-600,-600,inf,0"
)
plm_add_test (
  "plm-adjust-d-stats"
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "stats;${PLM_BUILD_TESTING_DIR}/plm-adjust-d.nrrd"
)
plmtest_check_interval (
  "plm-adjust-d-check"
  "${PLM_BUILD_TESTING_DIR}/plm-adjust-d-stats.stdout.txt"
  "AVE *([-0-9.]*)"
  "-782.97"
  "-782.96"
)
set_tests_properties (plm-adjust-d PROPERTIES DEPENDS "gauss-4")
set_tests_properties (plm-adjust-d-stats PROPERTIES DEPENDS "plm-adjust-d")
set_tests_properties (plm-adjust-d-check PROPERTIES DEPENDS "plm-adjust-d-stats")

plm_add_test (
  "plm-adjust-e"
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "adjust;--input;${PLM_BUILD_TESTING_DIR}/gauss-4.mha;--output;${PLM_BUILD_TESTING_DIR}/plm-adjust-e.nrrd;--linear;1000,2.5"
)
plm_add_test (
  "plm-adjust-e-stats"
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "stats;${PLM_BUILD_TESTING_DIR}/plm-adjust-e.nrrd"
)
plmtest_check_interval (
  "plm-adjust-e-check"
  "${PLM_BUILD_TESTING_DIR}/plm-adjust-e-stats.stdout.txt"
  "AVE *([-0-9.]*)"
  "-1298.87"
  "-1298.86"
)
set_tests_properties (plm-adjust-e PROPERTIES DEPENDS "gauss-4")
set_tests_properties (plm-adjust-e-stats PROPERTIES DEPENDS "plm-adjust-e")
set_tests_properties (plm-adjust-e-check PROPERTIES DEPENDS "plm-adjust-e-stats")

plm_add_test (
  "plm-adjust-f"
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "adjust;--input;${PLM_BUILD_TESTING_DIR}/gauss-4.mha;--output;${PLM_BUILD_TESTING_DIR}/plm-adjust-f.nrrd;--hist-match;${PLM_BUILD_TESTING_DIR}/gabor-01.mha;--hist-levels;128;--hist-points;5"
)
plm_add_test (
  "plm-adjust-f-stats"
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "stats;${PLM_BUILD_TESTING_DIR}/plm-adjust-f.nrrd"
)
plmtest_check_interval (
  "plm-adjust-f-check"
  "${PLM_BUILD_TESTING_DIR}/plm-adjust-f-stats.stdout.txt"
  "AVE *([-0-9.]*)"
  "-0.0196"
  "-0.0195"
)
set_tests_properties (plm-adjust-f PROPERTIES DEPENDS "gauss-4;gabor-01")
set_tests_properties (plm-adjust-f-stats PROPERTIES DEPENDS "plm-adjust-f")
set_tests_properties (plm-adjust-f-check PROPERTIES DEPENDS "plm-adjust-f-stats")

plm_add_test (
  "plm-adjust-g"
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "adjust;--input;${PLM_BUILD_TESTING_DIR}/gauss-4.mha;--output;${PLM_BUILD_TESTING_DIR}/plm-adjust-g.nrrd;--linear-match;${PLM_BUILD_TESTING_DIR}/gabor-01.mha"
)
plm_add_test (
  "plm-adjust-g-stats"
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "stats;${PLM_BUILD_TESTING_DIR}/plm-adjust-g.nrrd"
)
plmtest_check_interval (
  "plm-adjust-g-check"
  "${PLM_BUILD_TESTING_DIR}/plm-adjust-g-stats.stdout.txt"
  "AVE *([-0-9.]*)"
  "-0.0001"
  "0.0001"
)
set_tests_properties (plm-adjust-g PROPERTIES DEPENDS "gauss-4;gabor-01")
set_tests_properties (plm-adjust-g-stats PROPERTIES DEPENDS "plm-adjust-g")
set_tests_properties (plm-adjust-g-check PROPERTIES DEPENDS "plm-adjust-g-stats")

plm_add_test (
  "plm-adjust-h"
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "adjust;--input;${PLM_BUILD_TESTING_DIR}/gauss-4.mha;--output;${PLM_BUILD_TESTING_DIR}/plm-adjust-h.nrrd;--linear-match;${PLM_BUILD_TESTING_DIR}/gabor-01.mha;--input-mask;donut-2.mha"
)
plm_add_test (
  "plm-adjust-h-stats"
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "stats;${PLM_BUILD_TESTING_DIR}/plm-adjust-h.nrrd"
)
plmtest_check_interval (
  "plm-adjust-h-check"
  "${PLM_BUILD_TESTING_DIR}/plm-adjust-h-stats.stdout.txt"
  "AVE *([-0-9.]*)"
  "-0.2481"
  "-0.248"
)
set_tests_properties (plm-adjust-h PROPERTIES DEPENDS "gauss-4;gabor-01;donut-2")
set_tests_properties (plm-adjust-h-stats PROPERTIES DEPENDS "plm-adjust-h")
set_tests_properties (plm-adjust-h-check PROPERTIES DEPENDS "plm-adjust-h-stats")

plm_add_test (
  "plm-adjust-i"
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "adjust;--input;${PLM_BUILD_TESTING_DIR}/gauss-4.mha;--output;${PLM_BUILD_TESTING_DIR}/plm-adjust-i.nrrd;--local-match;${PLM_BUILD_TESTING_DIR}/gauss-3.mha;--patch-size;3 3 3;--ref-mask;${PLM_BUILD_TESTING_DIR}/donut-2.mha;--local-scale-out;${PLM_BUILD_TESTING_DIR}/plm-adjust-i-scale.nrrd;--local-shift-out;${PLM_BUILD_TESTING_DIR}/plm-adjust-i-shift.nrrd"
)
plm_add_test (
  "plm-adjust-i-stats"
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "stats;${PLM_BUILD_TESTING_DIR}/plm-adjust-i.nrrd"
)
plmtest_check_interval (
  "plm-adjust-i-check"
  "${PLM_BUILD_TESTING_DIR}/plm-adjust-i-stats.stdout.txt"
  "AVE *([-0-9.]*)"
  "-921.5941"
  "-921.5940"
)
set_tests_properties (plm-adjust-i PROPERTIES DEPENDS "gauss-4;gauss-3;donut-2")
set_tests_properties (plm-adjust-i-stats PROPERTIES DEPENDS "plm-adjust-i")
set_tests_properties (plm-adjust-i-check PROPERTIES DEPENDS "plm-adjust-i-stats")

plm_add_test (
  "plm-adjust-j"
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "adjust;--input;${PLM_BUILD_TESTING_DIR}/gauss-4.mha;--output;${PLM_BUILD_TESTING_DIR}/plm-adjust-j.nrrd;--local-match;${PLM_BUILD_TESTING_DIR}/gauss-3.mha;--patch-size;3 3 3;--ref-mask;${PLM_BUILD_TESTING_DIR}/donut-2.mha;--local-scale-out;${PLM_BUILD_TESTING_DIR}/plm-adjust-j-scale.nrrd;--local-shift-out;${PLM_BUILD_TESTING_DIR}/plm-adjust-j-shift.nrrd;--local-blending-off"
)
plm_add_test (
  "plm-adjust-j-stats"
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "stats;${PLM_BUILD_TESTING_DIR}/plm-adjust-j.nrrd"
)
plmtest_check_interval (
  "plm-adjust-j-check"
  "${PLM_BUILD_TESTING_DIR}/plm-adjust-j-stats.stdout.txt"
  "AVE *([-0-9.]*)"
  "-921.6276"
  "-921.6274"
)
set_tests_properties (plm-adjust-j PROPERTIES DEPENDS "gauss-4;gauss-3;donut-2")
set_tests_properties (plm-adjust-j-stats PROPERTIES DEPENDS "plm-adjust-j")
set_tests_properties (plm-adjust-j-check PROPERTIES DEPENDS "plm-adjust-j-stats")

## -------------------------------------------------------------------------
## plastimatch boundary
##  plm-boundary-a: sphere against image boundary, edge type, adaptive pad
##  plm-boundary-b: sphere against image boundary, edge type, zero pad
##  plm-boundary-c: sphere against image boundary, edge type, edge pad
##  plm-boundary-d: sphere against image boundary, face type, adaptive pad
##  plm-boundary-e: sphere against image boundary, face type, edge pad
## -------------------------------------------------------------------------
plm_add_test (
  "plm-boundary-a"
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "boundary;--boundary-behavior;adaptive;--output;${PLM_BUILD_TESTING_DIR}/plm-boundary-a.nrrd;${PLM_BUILD_TESTING_DIR}/sphere-5.mha"
  )
plm_add_test (
  "plm-boundary-a-stats"
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "stats;${PLM_BUILD_TESTING_DIR}/plm-boundary-a.nrrd"
  )
plmtest_check_interval ("plm-boundary-a-check"
  "${PLM_BUILD_TESTING_DIR}/plm-boundary-a-stats.stdout.txt"
  "NONZERO *([-0-9.]*)"
  "1056"
  "1056"
  )
set_tests_properties (plm-boundary-a PROPERTIES DEPENDS sphere-5)
set_tests_properties (plm-boundary-a-stats PROPERTIES DEPENDS plm-boundary-a)
set_tests_properties (plm-boundary-a-check 
  PROPERTIES DEPENDS plm-boundary-a-stats)

plm_add_test (
  "plm-boundary-b"
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "boundary;--boundary-behavior;zero-pad;--output;${PLM_BUILD_TESTING_DIR}/plm-boundary-b.nrrd;${PLM_BUILD_TESTING_DIR}/sphere-5.mha"
  )
plm_add_test (
  "plm-boundary-b-stats"
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "stats;${PLM_BUILD_TESTING_DIR}/plm-boundary-b.nrrd"
  )
plmtest_check_interval ("plm-boundary-b-check"
  "${PLM_BUILD_TESTING_DIR}/plm-boundary-b-stats.stdout.txt"
  "NONZERO *([-0-9.]*)"
  "1056"
  "1056"
  )
set_tests_properties (plm-boundary-b PROPERTIES DEPENDS sphere-5)
set_tests_properties (plm-boundary-b-stats PROPERTIES DEPENDS plm-boundary-b)
set_tests_properties (plm-boundary-b-check 
  PROPERTIES DEPENDS plm-boundary-b-stats)

plm_add_test (
  "plm-boundary-c"
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "boundary;--boundary-behavior;edge-pad;--output;${PLM_BUILD_TESTING_DIR}/plm-boundary-c.nrrd;${PLM_BUILD_TESTING_DIR}/sphere-5.mha"
  )
plm_add_test (
  "plm-boundary-c-stats"
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "stats;${PLM_BUILD_TESTING_DIR}/plm-boundary-c.nrrd"
  )
plmtest_check_interval ("plm-boundary-c-check"
  "${PLM_BUILD_TESTING_DIR}/plm-boundary-c-stats.stdout.txt"
  "NONZERO *([-0-9.]*)"
  "840"
  "840"
  )
set_tests_properties (plm-boundary-c PROPERTIES DEPENDS sphere-5)
set_tests_properties (plm-boundary-c-stats PROPERTIES DEPENDS plm-boundary-c)
set_tests_properties (plm-boundary-c-check 
  PROPERTIES DEPENDS plm-boundary-c-stats)

plm_add_test (
  "plm-boundary-d"
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "boundary;--boundary-behavior;adaptive;--boundary-type;interior-face;--output;${PLM_BUILD_TESTING_DIR}/plm-boundary-d.nrrd;${PLM_BUILD_TESTING_DIR}/sphere-5.mha"
  )
plm_add_test (
  "plm-boundary-d-stats"
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "stats;${PLM_BUILD_TESTING_DIR}/plm-boundary-d.nrrd"
  )
plmtest_check_interval ("plm-boundary-d-check"
  "${PLM_BUILD_TESTING_DIR}/plm-boundary-d-stats.stdout.txt"
  "AVE *([-0-9.]*)"
  "2.614"
  "2.615"
  )
set_tests_properties (plm-boundary-d PROPERTIES DEPENDS sphere-5)
set_tests_properties (plm-boundary-d-stats PROPERTIES DEPENDS plm-boundary-d)
set_tests_properties (plm-boundary-d-check 
  PROPERTIES DEPENDS plm-boundary-d-stats)

plm_add_test (
  "plm-boundary-e"
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "boundary;--boundary-behavior;edge-pad;--boundary-type;interior-face;--output;${PLM_BUILD_TESTING_DIR}/plm-boundary-e.nrrd;${PLM_BUILD_TESTING_DIR}/sphere-5.mha"
  )
plm_add_test (
  "plm-boundary-e-stats"
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "stats;${PLM_BUILD_TESTING_DIR}/plm-boundary-e.nrrd"
  )
plmtest_check_interval ("plm-boundary-e-check"
  "${PLM_BUILD_TESTING_DIR}/plm-boundary-e-stats.stdout.txt"
  "AVE *([-0-9.]*)"
  "2.141"
  "2.143"
  )
set_tests_properties (plm-boundary-e PROPERTIES DEPENDS sphere-5)
set_tests_properties (plm-boundary-e-stats PROPERTIES DEPENDS plm-boundary-e)
set_tests_properties (plm-boundary-e-check 
  PROPERTIES DEPENDS plm-boundary-e-stats)


## -------------------------------------------------------------------------
## plastimatch convert dicom (and dicom rt)
##   plm convert dicom a: (rect) input rtss, no fixed image, no ct reference
##   plm convert dicom b: set metadata patient position to FFS
##   plm convert dicom c: make prefix images from lung-1
##   plm convert dicom d: error testing on non-existant directory
##   plm convert dicom e: error testing on directory without dicom files
##   plm convert dicom f: dicom rtss -> dicom rtss, with referenced ct
## -------------------------------------------------------------------------
plm_add_test (
  "plm-convert-dicom-a" 
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "convert;--input;${PLM_BUILD_TESTING_DIR}/rect-1-dicom/rtss.dcm;--output-ss-img;${PLM_BUILD_TESTING_DIR}/plm-convert-dicom-a-ss.mha;--output-ss-list;plm-convert-dicom-a-ss.txt;--output-cxt;${PLM_BUILD_TESTING_DIR}/plm-convert-dicom-a.cxt;--output-prefix;${PLM_BUILD_TESTING_DIR}/plm-convert-dicom-a-prefix"
  )
plm_add_test (
  "plm-convert-dicom-a-stats" 
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "stats;${PLM_BUILD_TESTING_DIR}/plm-convert-dicom-a-ss.mha"
  )
plmtest_check_interval (
  "plm-convert-dicom-a-check" 
  "${PLM_BUILD_TESTING_DIR}/plm-convert-dicom-a-stats.stdout.txt"
  " 0 *NVOX *([-0-9.]*)"
  "1648003"
  "1648003"
  )
set_tests_properties (plm-convert-dicom-a PROPERTIES DEPENDS rect-1)
set_tests_properties (plm-convert-dicom-a-stats PROPERTIES 
  DEPENDS plm-convert-dicom-a)
set_tests_properties (plm-convert-dicom-a-check PROPERTIES 
  DEPENDS plm-convert-dicom-a-stats)

plm_add_test (
  "plm-convert-dicom-b"
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "convert;--filenames-without-uids;--input;${PLM_BUILD_TESTING_DIR}/rect-1-dicom;--output-dicom;${PLM_BUILD_TESTING_DIR}/plm-convert-dicom-b-dicom;--metadata;0018,5100=FFS"
  )
plm_add_test (
  "plm-convert-dicom-b-stats" 
  ${PLM_PLASTIMATCH_PATH}/dicom_info
  "--input;${PLM_BUILD_TESTING_DIR}/plm-convert-dicom-b-dicom/image0000.dcm"
  )
plmtest_check_string ("plm-convert-dicom-b-check" 
  "${PLM_BUILD_TESTING_DIR}/plm-convert-dicom-b-stats.stdout.txt"
  "Patient Position . (.*[^ ]) *$"
  "FFS"
  )
set_tests_properties (plm-convert-dicom-b PROPERTIES DEPENDS rect-1)
set_tests_properties (plm-convert-dicom-b-stats PROPERTIES 
  DEPENDS plm-convert-dicom-b)
set_tests_properties (plm-convert-dicom-b-check PROPERTIES 
  DEPENDS plm-convert-dicom-b-stats)

plm_add_test (
  "plm-convert-dicom-c" 
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "convert;--input;${PLM_BUILD_TESTING_DIR}/lung-1-dicom/;--output-prefix;${PLM_BUILD_TESTING_DIR}/plm-convert-dicom-c-prefix"
  )
plm_add_test (
  "plm-convert-dicom-c-stats" 
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "stats;${PLM_BUILD_TESTING_DIR}/plm-convert-dicom-c-prefix/Tumor.mha"
  )
plmtest_check_interval (
  "plm-convert-dicom-c-check" 
  "${PLM_BUILD_TESTING_DIR}/plm-convert-dicom-c-stats.stdout.txt"
  "NONZERO *([-0-9.]*)"
  "280"
  "280"
  )
set_tests_properties (plm-convert-dicom-c PROPERTIES DEPENDS lung-1)
set_tests_properties (plm-convert-dicom-c-stats PROPERTIES 
  DEPENDS plm-convert-dicom-c)
set_tests_properties (plm-convert-dicom-c-check PROPERTIES 
  DEPENDS plm-convert-dicom-c-stats)

plm_add_test (
  "plm-convert-dicom-d" 
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "convert;--input;${PLM_BUILD_TESTING_DIR}/non-existant-directory/;--output-img;${PLM_BUILD_TESTING_DIR}/plm-convert-dicom-d.nrrd"
  "-DEXPECTED_ERRNO=1"
  )

plm_add_test (
  "plm-convert-dicom-e" 
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "convert;--input;${PLM_BUILD_TESTING_DIR}/tmp/;--output-img;${PLM_BUILD_TESTING_DIR}/plm-convert-dicom-e.nrrd"
  "-DEXPECTED_ERRNO=1"
  )

plm_add_test (
  "plm-convert-dicom-f" 
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "convert;--input;${PLM_BUILD_TESTING_DIR}/rect-1-dicom/rtss.dcm;--output-dicom;${PLM_BUILD_TESTING_DIR}/plm-convert-dicom-f-dicom;--referenced-ct;${PLM_BUILD_TESTING_DIR}/rect-2-dicom"
  )
## GCS FIX: Normally, I would want to probe the dicom data to see if they 
## match.  But dicom_info only works with images, not rtss.
set_tests_properties (plm-convert-dicom-f PROPERTIES DEPENDS "rect-1;rect2")

## -------------------------------------------------------------------------
## These tests are designed to check the handling of overlapping structures 
## in DICOM-RT format.  The tests assume that the original synthetic donut 
## DICOM-RT files are generated without keyholing.
##   plm-convert-dicom-donut-a   From DICOM to ss-img (or semantics)
##   plm-convert-dicom-donut-b   From DICOM to ss-img (xor semantics)
## -------------------------------------------------------------------------
plm_add_test (
  "plm-convert-dicom-donut-a"
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "convert;--input;${PLM_BUILD_TESTING_DIR}/donut-1-dicom;--output-ss-img;${PLM_BUILD_TESTING_DIR}/plm-convert-dicom-donut-a-ss.nrrd"
  )
plm_add_test (
  "plm-convert-dicom-donut-a-stats" 
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "stats;${PLM_BUILD_TESTING_DIR}/plm-convert-dicom-donut-a-ss.nrrd"
  )
plmtest_check_interval (
  "plm-convert-dicom-donut-a-check" 
  "${PLM_BUILD_TESTING_DIR}/plm-convert-dicom-donut-a-stats.stdout.txt"
  "S *0 *NVOX *([-0-9.]*)"
  "2623"
  "2623"
  )
plm_add_test (
  "plm-convert-dicom-donut-b"
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "convert;--input;${PLM_BUILD_TESTING_DIR}/donut-1-dicom;--output-ss-img;${PLM_BUILD_TESTING_DIR}/plm-convert-dicom-donut-b-ss.nrrd;--xor-contours"
  )
plm_add_test (
  "plm-convert-dicom-donut-b-stats" 
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "stats;${PLM_BUILD_TESTING_DIR}/plm-convert-dicom-donut-b-ss.nrrd"
  )
plmtest_check_interval (
  "plm-convert-dicom-donut-b-check" 
  "${PLM_BUILD_TESTING_DIR}/plm-convert-dicom-donut-b-stats.stdout.txt"
  "S *0 *NVOX *([-0-9.]*)"
  "1924"
  "1924"
  )
set_tests_properties (plm-convert-dicom-donut-a PROPERTIES DEPENDS donut-1)
set_tests_properties (plm-convert-dicom-donut-a-stats PROPERTIES 
  DEPENDS plm-convert-dicom-donut-a)
set_tests_properties (plm-convert-dicom-donut-a-check PROPERTIES 
  DEPENDS plm-convert-dicom-donut-a-stats)
set_tests_properties (plm-convert-dicom-donut-b PROPERTIES DEPENDS donut-1)
set_tests_properties (plm-convert-dicom-donut-b-stats PROPERTIES 
  DEPENDS plm-convert-dicom-donut-b)
set_tests_properties (plm-convert-dicom-donut-b-check PROPERTIES 
  DEPENDS plm-convert-dicom-donut-b-stats)

## -------------------------------------------------------------------------
## These tests are designed to check the handling of overlapping structures 
## in DICOM-RT format.  Converts donut topology structure into keyholized 
## rtstruct.
##   plm-convert-dicom-donut-c   From ss-img to DICOM
## -------------------------------------------------------------------------
plm_add_test (
  "plm-convert-dicom-donut-c"
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "convert;--input;${PLM_BUILD_TESTING_DIR}/donut-1.mha;--input-ss-img;${PLM_BUILD_TESTING_DIR}/donut-1-ss.mha;--input-ss-list;${PLM_BUILD_TESTING_DIR}/donut-1-ss-list.txt;--filenames-without-uids;--output-dicom;${PLM_BUILD_TESTING_DIR}/plm-convert-dicom-donut-c"
  )
set_tests_properties (plm-convert-dicom-donut-c PROPERTIES DEPENDS donut-1)

## -------------------------------------------------------------------------
## plastimatch convert rtog (corvus)
## -------------------------------------------------------------------------
plm_add_test (
  "plm-convert-rtog-corvus-a" 
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "convert;--input;${PLM_BUILD_TESTING_DIR}/rtog-corvus-6.2.2;--output-img;${PLM_BUILD_TESTING_DIR}/plm-convert-rtog-corvus-a.mha;--output-ss-img;${PLM_BUILD_TESTING_DIR}/plm-convert-rtog-corvus-a-ss.mha;--output-ss-list;${PLM_BUILD_TESTING_DIR}/plm-convert-rtog-corvus-a-ss.txt;--output-dose-img;${PLM_BUILD_TESTING_DIR}/plm-convert-rtog-corvus-a-dose.mha"
  )

## -------------------------------------------------------------------------
## plastimatch convert dicom-rt (aw)
## -------------------------------------------------------------------------
plm_add_test (
  "plm-convert-dicom-aw-a" 
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "convert;--filenames-without-uids;--input;${PLM_BUILD_TESTING_DIR}/dicomrt-aw-4.4-foot/20101202HFS;--output-img;${PLM_BUILD_TESTING_DIR}/plm-convert-dicom-aw-a.mha;--output-ss-img;${PLM_BUILD_TESTING_DIR}/plm-convert-dicom-aw-a-ss.mha;--output-ss-list;${PLM_BUILD_TESTING_DIR}/plm-convert-dicom-aw-a-ss.txt;--output-dose-img;${PLM_BUILD_TESTING_DIR}/plm-convert-dicom-aw-a-dose.mha;--output-dicom;${PLM_BUILD_TESTING_DIR}/plm-convert-dicom-aw-a-dicom"
  )
plm_add_test (
  "plm-convert-dicom-aw-a-stats" 
  ${PLM_PLASTIMATCH_PATH}/dicom_info
  "--input;${PLM_BUILD_TESTING_DIR}/plm-convert-dicom-aw-a-dicom/image0000.dcm"
  )
plmtest_check_string ("plm-convert-dicom-aw-a-check" 
  "${PLM_BUILD_TESTING_DIR}/plm-convert-dicom-aw-a-stats.stdout.txt"
  "^Patient's Name . (.*[^ ]) *$"
  "PHANTOM^HFS"
  )
plm_add_test (
  "plm-convert-dicom-aw-b" 
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "convert;--input;${PLM_BUILD_TESTING_DIR}/dicomrt-aw-4.4-foot/20101202FFS;--output-img;${PLM_BUILD_TESTING_DIR}/plm-convert-dicom-aw-b.mha;--output-ss-img;${PLM_BUILD_TESTING_DIR}/plm-convert-dicom-aw-b-ss.mha;--output-ss-list;${PLM_BUILD_TESTING_DIR}/plm-convert-dicom-aw-b-ss.txt;--output-dose-img;${PLM_BUILD_TESTING_DIR}/plm-convert-dicom-aw-b-dose.mha"
  )
set_tests_properties (plm-convert-dicom-aw-a-stats PROPERTIES 
  DEPENDS plm-convert-dicom-aw-a)
set_tests_properties (plm-convert-dicom-aw-a-check PROPERTIES 
  DEPENDS plm-convert-dicom-aw-a-stats)

## -------------------------------------------------------------------------
## plastimatch convert dicom-rt (cerr)
## -------------------------------------------------------------------------
# plm_add_test (
#   "plm-convert-dicom-cerr-a" 
#   ${PLM_PLASTIMATCH_PATH}/plastimatch
#   "convert;--input;${PLM_BUILD_TESTING_DIR}/chest-phantom-dicomrt-CERR4pt0beta2_25_Jan_2011;--output-img;${PLM_BUILD_TESTING_DIR}/plm-convert-dicom-cerr-a.mha;--output-ss-img;${PLM_BUILD_TESTING_DIR}/plm-convert-dicom-cerr-a-ss.mha;--output-ss-list;${PLM_BUILD_TESTING_DIR}/plm-convert-dicom-cerr-a-ss.txt;--output-dose-img;${PLM_BUILD_TESTING_DIR}/plm-convert-dicom-cerr-a-dose.mha"
#   )

## -------------------------------------------------------------------------
## plastimatch convert dicom-rt (corvus)
## -------------------------------------------------------------------------
plm_add_test (
  "plm-convert-dicom-corvus-a" 
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "convert;--input;${PLM_BUILD_TESTING_DIR}/dicomrt-corvus-6.2.2;--output-img;${PLM_BUILD_TESTING_DIR}/plm-convert-dicom-corvus-a.mha;--output-ss-img;${PLM_BUILD_TESTING_DIR}/plm-convert-dicom-corvus-a-ss.mha;--output-ss-list;${PLM_BUILD_TESTING_DIR}/plm-convert-dicom-corvus-a-ss.txt;--output-dose-img;${PLM_BUILD_TESTING_DIR}/plm-convert-dicom-corvus-a-dose.mha"
  )

## -------------------------------------------------------------------------
## plastimatch convert dicom-rt (pinnacle)
## -------------------------------------------------------------------------
plm_add_test (
  "plm-convert-dicom-pinnacle-a" 
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "convert;--input;${PLM_BUILD_TESTING_DIR}/dicomrt-pinnacle3-8.2g-rando;--output-img;${PLM_BUILD_TESTING_DIR}/plm-convert-dicom-pinnacle-a.mha;--output-ss-img;${PLM_BUILD_TESTING_DIR}/plm-convert-dicom-pinnacle-a-ss.mha;--output-ss-list;${PLM_BUILD_TESTING_DIR}/plm-convert-dicom-pinnacle-a-ss.txt;--output-dose-img;${PLM_BUILD_TESTING_DIR}/plm-convert-dicom-pinnacle-a-dose.mha"
  )

## -------------------------------------------------------------------------
## plastimatch-convert-dicom-xio (xio)
##   plm-convert-dicom-xio-a: ct only
##   plm-convert-dicom-xio-b: rtss -> ss_img, with referenced-ct
##   plm-convert-dicom-xio-c: rtss -> ss_img, with fixed image reference
##   plm-convert-dicom-xio-d: dose only, native sampling rate
##   plm-convert-dicom-xio-e: input xio dicom, output plm dicom
##   plm-convert-dicom-xio-f: input plm dicom, output plm dicom
##   plm-convert-dicom-xio-g: all inputs, image outputs
##   plm-warp-dicom-xio-a:    all inputs, bspline transform, all outputs
## -------------------------------------------------------------------------
plm_add_test (
  "plm-convert-dicom-xio-a"
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "convert;--input;${PLM_BUILD_TESTING_DIR}/dicomrt-xio-4.33.02-chest-phantom;--output-img;${PLM_BUILD_TESTING_DIR}/plm-convert-dicom-xio-a.mha"
  )
plm_add_test (
  "plm-convert-dicom-xio-a-stats"
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "stats;${PLM_BUILD_TESTING_DIR}/plm-convert-dicom-xio-a.mha"
  )
plmtest_check_interval ("plm-convert-dicom-xio-a-check"
  "${PLM_BUILD_TESTING_DIR}/plm-convert-dicom-xio-a-stats.stdout.txt"
  "AVE *([-0-9.]*)"
  "-667.5"
  "-666.6"
  )
set_tests_properties (plm-convert-dicom-xio-a-stats PROPERTIES 
  DEPENDS plm-convert-dicom-xio-a)
set_tests_properties (plm-convert-dicom-xio-a-check PROPERTIES 
  DEPENDS plm-convert-dicom-xio-a-stats)

plm_add_test (
  "plm-convert-dicom-xio-b"
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "convert;--input;${PLM_BUILD_TESTING_DIR}/dicomrt-xio-4.33.02-chest-phantom/SS.rtp1.12.20080627A.5.dcm;--output-ss-img;${PLM_BUILD_TESTING_DIR}/plm-convert-dicom-xio-b-ss.mha;--referenced-ct;${PLM_BUILD_TESTING_DIR}/dicomrt-xio-4.33.02-chest-phantom"
  )
plm_add_test (
  "plm-convert-dicom-xio-b-stats"
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "stats;${PLM_BUILD_TESTING_DIR}/plm-convert-dicom-xio-b-ss.mha"
  )
plmtest_check_interval ("plm-convert-dicom-xio-b-check"
  "${PLM_BUILD_TESTING_DIR}/plm-convert-dicom-xio-b-stats.stdout.txt"
  "S *1 *NVOX *([-0-9.]*)"
  "62767"
  "62767"
  )
set_tests_properties (plm-convert-dicom-xio-b-stats PROPERTIES 
  DEPENDS plm-convert-dicom-xio-b)
set_tests_properties (plm-convert-dicom-xio-b-check PROPERTIES 
  DEPENDS plm-convert-dicom-xio-b-stats)

plm_add_test (
  "plm-convert-dicom-xio-c"
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "convert;--input;${PLM_BUILD_TESTING_DIR}/dicomrt-xio-4.33.02-chest-phantom/SS.rtp1.12.20080627A.5.dcm;--output-ss-img;${PLM_BUILD_TESTING_DIR}/plm-convert-dicom-xio-c-ss.mha;--fixed;${PLM_BUILD_TESTING_DIR}/plm-convert-dicom-xio-a.mha;--output-cxt;${PLM_BUILD_TESTING_DIR}/plm-convert-dicom-xio-c.cxt"
  )
plm_add_test (
  "plm-convert-dicom-xio-c-stats"
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "stats;${PLM_BUILD_TESTING_DIR}/plm-convert-dicom-xio-c-ss.mha"
  )
# To be resolved.  Why do dicom-xio-b and dicom-xio-c give different answers?
plmtest_check_interval ("plm-convert-dicom-xio-c-check"
  "${PLM_BUILD_TESTING_DIR}/plm-convert-dicom-xio-c-stats.stdout.txt"
  "S *1 *NVOX *([-0-9.]*)"
  "62769"
  "62769"
  )
set_tests_properties (plm-convert-dicom-xio-c PROPERTIES 
  DEPENDS plm-convert-dicom-xio-a)
set_tests_properties (plm-convert-dicom-xio-c-stats PROPERTIES 
  DEPENDS plm-convert-dicom-xio-c)
set_tests_properties (plm-convert-dicom-xio-c-check PROPERTIES 
  DEPENDS plm-convert-dicom-xio-c-stats)

plm_add_test (
  "plm-convert-dicom-xio-d"
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "convert;--input;${PLM_BUILD_TESTING_DIR}/dicomrt-xio-4.33.02-chest-phantom/DOSE.20080627A.TRAINING4FLD.dcm;--output-dose-img;${PLM_BUILD_TESTING_DIR}/plm-convert-dicom-xio-d-dose-img.mha"
  )
plm_add_test (
  "plm-convert-dicom-xio-d-stats"
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "stats;${PLM_BUILD_TESTING_DIR}/plm-convert-dicom-xio-d-dose-img.mha"
  )
plmtest_check_interval ("plm-convert-dicom-xio-d-check"
  "${PLM_BUILD_TESTING_DIR}/plm-convert-dicom-xio-d-stats.stdout.txt"
  "MAX *([-0-9.]*)"
  "42.1"
  "42.2"
  )
set_tests_properties (plm-convert-dicom-xio-d-stats PROPERTIES 
  DEPENDS plm-convert-dicom-xio-d)
set_tests_properties (plm-convert-dicom-xio-d-check PROPERTIES 
  DEPENDS plm-convert-dicom-xio-d-stats)

plm_add_test (
  "plm-convert-dicom-xio-e" 
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "convert;--input;${PLM_BUILD_TESTING_DIR}/dicomrt-xio-4.33.02-chest-phantom;--output-dicom;${PLM_BUILD_TESTING_DIR}/plm-convert-dicom-xio-e-dicom;--output-dose-img;${PLM_BUILD_TESTING_DIR}/plm-convert-dicom-xio-e-dose-img.mha"
  )

plm_add_test (
  "plm-convert-dicom-xio-f" 
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "convert;--input;${PLM_BUILD_TESTING_DIR}/plm-convert-dicom-xio-e-dicom;--output-dicom;${PLM_BUILD_TESTING_DIR}/plm-convert-dicom-xio-f-dicom;--output-dose-img;${PLM_BUILD_TESTING_DIR}/plm-convert-dicom-xio-f-dose-img.mha"
  )
plm_add_test (
  "plm-convert-dicom-xio-f-stats" 
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "compare;${PLM_BUILD_TESTING_DIR}/plm-convert-dicom-xio-e-dose-img.mha;${PLM_BUILD_TESTING_DIR}/plm-convert-dicom-xio-f-dose-img.mha"
  )
plmtest_check_interval ("plm-convert-dicom-xio-f-check"
  "${PLM_BUILD_TESTING_DIR}/plm-convert-dicom-xio-f-stats.stdout.txt"
  "MAE *([-0-9.]*)"
  "0.000"
  "0.005"
  )
set_tests_properties (plm-convert-dicom-xio-f PROPERTIES 
  DEPENDS plm-convert-dicom-xio-e)
set_tests_properties (plm-convert-dicom-xio-f-stats PROPERTIES 
  DEPENDS plm-convert-dicom-xio-f)
set_tests_properties (plm-convert-dicom-xio-f-check PROPERTIES 
  DEPENDS plm-convert-dicom-xio-f-stats)

plm_add_test (
  "plm-convert-dicom-xio-g"
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "convert;--input;${PLM_BUILD_TESTING_DIR}/dicomrt-xio-4.33.02-chest-phantom;--output-img;${PLM_BUILD_TESTING_DIR}/plm-convert-dicom-xio-g.mha;--output-ss-img;${PLM_BUILD_TESTING_DIR}/plm-convert-dicom-xio-g-ss.mha;--output-ss-list;${PLM_BUILD_TESTING_DIR}/plm-convert-dicom-xio-g-ss.txt;--output-dose-img;${PLM_BUILD_TESTING_DIR}/plm-convert-dicom-xio-g-dose.mha"
  )

plm_add_test (
  "plm-warp-dicom-xio-a" 
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "warp;--xf;${PLM_TESTING_DATA_DIR}/xf-bspline-chest-phantom.txt;--input;${PLM_BUILD_TESTING_DIR}/dicomrt-xio-4.33.02-chest-phantom;--output-dicom;${PLM_BUILD_TESTING_DIR}/plm-warp-dicom-xio-a-dicom;--output-ss-img;${PLM_BUILD_TESTING_DIR}/plm-warp-dicom-xio-a-ss.nrrd;--output-ss-list;${PLM_BUILD_TESTING_DIR}/plm-warp-dicom-xio-a-ss.txt;--output-labelmap;${PLM_BUILD_TESTING_DIR}/plm-warp-dicom-xio-a-labelmap.nrrd;--output-img;${PLM_BUILD_TESTING_DIR}/plm-warp-dicom-xio-a-img.nrrd;--output-prefix;${PLM_BUILD_TESTING_DIR}/plm-warp-dicom-xio-a;--output-cxt;${PLM_BUILD_TESTING_DIR}/plm-warp-dicom-xio-a.cxt;--default-value;0"
  )
plm_add_test (
  "plm-warp-dicom-xio-a-stats-1"
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "stats;${PLM_BUILD_TESTING_DIR}/plm-warp-dicom-xio-a-img.nrrd"
  )
plmtest_check_interval ("plm-warp-dicom-xio-a-check-1"
  "${PLM_BUILD_TESTING_DIR}/plm-warp-dicom-xio-a-stats-1.stdout.txt"
  "AVE *([-0-9.]*)"
  "-661.9"
  "-661.4"
  )
plm_add_test (
  "plm-warp-dicom-xio-a-stats-2"
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "stats;${PLM_BUILD_TESTING_DIR}/plm-warp-dicom-xio-a-ss.nrrd"
  )
plmtest_check_interval ("plm-warp-dicom-xio-a-check-2"
  "${PLM_BUILD_TESTING_DIR}/plm-warp-dicom-xio-a-stats-2.stdout.txt"
  "S *1 *NVOX *([-0-9.]*)"
  "1971"
  "1971"
  )
set_tests_properties (plm-warp-dicom-xio-a-stats-1 
  PROPERTIES DEPENDS plm-warp-dicom-xio-a)
set_tests_properties (plm-warp-dicom-xio-a-check-1 
  PROPERTIES DEPENDS plm-warp-dicom-xio-a-stats-1)
set_tests_properties (plm-warp-dicom-xio-a-stats-2 
  PROPERTIES DEPENDS plm-warp-dicom-xio-a)
set_tests_properties (plm-warp-dicom-xio-a-check-2 
  PROPERTIES DEPENDS plm-warp-dicom-xio-a-stats-2)


## -------------------------------------------------------------------------
## plastimatch-convert-dicom-irregular (xio, irregular slice spacing)
## -------------------------------------------------------------------------
plm_add_test (
  "plm-convert-dicom-irregular-a"
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "convert;--input;${PLM_BUILD_TESTING_DIR}/xio-4.60-irregular-spacing;--output-img;${PLM_BUILD_TESTING_DIR}/plm-convert-dicom-irregular-a.mha;--output-ss-img;${PLM_BUILD_TESTING_DIR}/plm-convert-dicom-irregular-a-ss.mha;--output-ss-list;${PLM_BUILD_TESTING_DIR}/plm-convert-dicom-irregular-a-ss.txt;--output-dose-img;${PLM_BUILD_TESTING_DIR}/plm-convert-dicom-irregular-a-dose.mha"
  )

## -------------------------------------------------------------------------
## plm-convert-dicom-33 (mim, 33 structures)
##  plm-convert-dicom-33-a (native method, depends on configuration)
##  plm-convert-dicom-33-b (force unsigned long)
##  plm-convert-dicom-33-c (force uchar_vec)
## -------------------------------------------------------------------------
plm_add_test (
  "plm-convert-dicom-33-a" 
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "convert;--input;${PLM_BUILD_TESTING_DIR}/dicomrt-33-structures;--output-img;${PLM_BUILD_TESTING_DIR}/plm-convert-dicom-33-a.mha;--output-ss-img;${PLM_BUILD_TESTING_DIR}/plm-convert-dicom-33-a-ss.mha;--output-ss-list;${PLM_BUILD_TESTING_DIR}/plm-convert-dicom-33-a-ss.txt;--output-dicom;${PLM_BUILD_TESTING_DIR}/plm-convert-dicom-33-a-dicom"
  )
plm_add_test (
  "plm-convert-dicom-33-a-stats-1" 
  ${PLM_PLASTIMATCH_PATH}/plastimatch 
  "header;${PLM_BUILD_TESTING_DIR}/plm-convert-dicom-33-a-ss.mha"
  )
plm_add_test (
  "plm-convert-dicom-33-a-stats-2" 
  ${PLM_PLASTIMATCH_PATH}/plastimatch 
  "stats;${PLM_BUILD_TESTING_DIR}/plm-convert-dicom-33-a-ss.mha"
  )
plmtest_check_string ("plm-convert-dicom-33-a-check-1" 
  "${PLM_BUILD_TESTING_DIR}/plm-convert-dicom-33-a-stats-1.stdout.txt"
  "^Planes . (.*[^ ]) *$"
  "5"
  )
plmtest_check_interval ("plm-convert-dicom-33-a-check-2"
  "${PLM_BUILD_TESTING_DIR}/plm-convert-dicom-33-a-stats-2.stdout.txt"
  "S *28 *NVOX *([-0-9.]*)"
  "130"
  "130"
  )
set_tests_properties (plm-convert-dicom-33-a-stats-1 PROPERTIES 
  DEPENDS plm-convert-dicom-33-a)
set_tests_properties (plm-convert-dicom-33-a-stats-2 PROPERTIES 
  DEPENDS plm-convert-dicom-33-a)
set_tests_properties (plm-convert-dicom-33-a-check-1 PROPERTIES 
  DEPENDS plm-convert-dicom-33-a-stats-1)
set_tests_properties (plm-convert-dicom-33-a-check-2 PROPERTIES 
  DEPENDS plm-convert-dicom-33-a-stats-2)

## -------------------------------------------------------------------------
## plastimatch-convert-cxt
## -------------------------------------------------------------------------
plm_add_test (
  "plm-convert-cxt"
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "convert;--input;${PLM_BUILD_TESTING_DIR}/plm-convert-dicom-a.cxt;--output-ss-img;${PLM_BUILD_TESTING_DIR}/plm-convert-cxt.mha;--output-ss-list;${PLM_BUILD_TESTING_DIR}/plm-convert-cxt.txt"
  )
plm_add_test (
  "plm-convert-cxt-stats"
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "stats;${PLM_BUILD_TESTING_DIR}/plm-convert-cxt.mha"
  )
# There is a bug in the dicom converter, whereby the image in the 
# same directory is not parsed to find rasterization size.  This 
# test should be modified when that bug is fixed.
plmtest_check_interval ("plm-convert-cxt-check"
  "${PLM_BUILD_TESTING_DIR}/plm-convert-cxt-stats.stdout.txt"
  "S *0 *NVOX *([-0-9.]*)"
  "1648003"
  "1648003"
  )
set_tests_properties (plm-convert-cxt PROPERTIES DEPENDS plm-convert-dicom-a)
set_tests_properties (plm-convert-cxt-stats PROPERTIES DEPENDS plm-convert-cxt)
set_tests_properties (plm-convert-cxt-check PROPERTIES 
  DEPENDS plm-convert-cxt-stats)

## -------------------------------------------------------------------------
## plm-convert-xio
##  plm-convert-xio-a
##  plm-convert-xio-b
##    (2014-10-13) These used to convert to AVG between -667.5 to -666.6, 
##    but now the AVG is -665.638611.  Would be good to test with phantom
##    to make sure the conversion is good.
##  plm-warp-xio-a
##    (2014-10-13) Ditto. AVG was between -661.5 to -661.4, but now 
##    is -660.018921
## -------------------------------------------------------------------------
plm_add_test (
  "plm-convert-xio-a"
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "convert;--input;${PLM_BUILD_TESTING_DIR}/xio-4.33.02-chest-phantom;--output-img;${PLM_BUILD_TESTING_DIR}/plm-convert-xio-a.mha;--output-xio;${PLM_BUILD_TESTING_DIR}/plm-convert-xio-a-xio-output;--output-dicom;${PLM_BUILD_TESTING_DIR}/plm-convert-xio-a-dicom;--output-dose-img;${PLM_BUILD_TESTING_DIR}/plm-convert-xio-a-dose.mha"
  )
plm_add_test (
  "plm-convert-xio-a-stats"
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "stats;${PLM_BUILD_TESTING_DIR}/plm-convert-xio-a.mha"
  )
plmtest_check_interval ("plm-convert-xio-a-check"
  "${PLM_BUILD_TESTING_DIR}/plm-convert-xio-a-stats.stdout.txt"
  "AVE *([-0-9.]*)"
  "-667.5"
  "-665.2"
  )
set_tests_properties (plm-convert-xio-a-stats PROPERTIES 
  DEPENDS plm-convert-xio-a)
set_tests_properties (plm-convert-xio-a-check PROPERTIES 
  DEPENDS plm-convert-xio-a-stats)

plm_add_test (
  "plm-convert-xio-b"
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "convert;--input;${PLM_BUILD_TESTING_DIR}/xio-4.33.02-chest-phantom/20080627A/plan/TRAINING4FLD;--output-img;${PLM_BUILD_TESTING_DIR}/plm-convert-xio-b.mha;--output-xio;${PLM_BUILD_TESTING_DIR}/plm-convert-xio-b-xio-output;--output-dicom;${PLM_BUILD_TESTING_DIR}/plm-convert-xio-b-dicom"
  )
plm_add_test (
  "plm-convert-xio-b-stats"
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "stats;${PLM_BUILD_TESTING_DIR}/plm-convert-xio-b.mha"
  )
plmtest_check_interval ("plm-convert-xio-b-check"
  "${PLM_BUILD_TESTING_DIR}/plm-convert-xio-b-stats.stdout.txt"
  "AVE *([-0-9.]*)"
  "-667.5"
  "-665.2"
  )
set_tests_properties (plm-convert-xio-b-stats PROPERTIES 
  DEPENDS plm-convert-xio-b)
set_tests_properties (plm-convert-xio-b-check PROPERTIES 
  DEPENDS plm-convert-xio-b-stats)

plm_add_test (
  "plm-warp-xio-a" 
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "warp;--xf;${PLM_TESTING_DATA_DIR}/xf-bspline-chest-phantom.txt;--input;${PLM_BUILD_TESTING_DIR}/xio-4.33.02-chest-phantom;--output-xio;${PLM_BUILD_TESTING_DIR}/plm-warp-xio-a-xio;--output-ss-img;${PLM_BUILD_TESTING_DIR}/plm-warp-xio-a-ss.nrrd;--output-ss-list;${PLM_BUILD_TESTING_DIR}/plm-warp-xio-a-ss.txt;--output-labelmap;${PLM_BUILD_TESTING_DIR}/plm-warp-xio-a-labelmap.nrrd;--output-img;${PLM_BUILD_TESTING_DIR}/plm-warp-xio-a-img.nrrd;--output-prefix;${PLM_BUILD_TESTING_DIR}/plm-warp-xio-a;--output-cxt;${PLM_BUILD_TESTING_DIR}/plm-warp-xio-a.cxt;--output-colormap;${PLM_BUILD_TESTING_DIR}/plm-warp-xio-a.ctbl;--default-value;0"
  )
plm_add_test (
  "plm-warp-xio-a-stats-1"
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "stats;${PLM_BUILD_TESTING_DIR}/plm-warp-xio-a-img.nrrd"
  )
plmtest_check_interval ("plm-warp-xio-a-check-1"
  "${PLM_BUILD_TESTING_DIR}/plm-warp-xio-a-stats-1.stdout.txt"
  "AVE *([-0-9.]*)"
  "-661.5"
  "-659.9"
  )
plm_add_test (
  "plm-warp-xio-a-stats-2"
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "stats;${PLM_BUILD_TESTING_DIR}/plm-warp-xio-a/Patient.mha"
  )
plmtest_check_interval ("plm-warp-xio-a-check-2"
  "${PLM_BUILD_TESTING_DIR}/plm-warp-xio-a-stats-2.stdout.txt"
  "AVE *([-0-9.]*)"
  "0.385"
  "0.395"
  )
plm_add_test (
  "plm-warp-xio-a-stats-3"
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "stats;${PLM_BUILD_TESTING_DIR}/plm-warp-xio-a-labelmap.nrrd"
  )
plmtest_check_interval ("plm-warp-xio-a-check-3"
  "${PLM_BUILD_TESTING_DIR}/plm-warp-xio-a-stats-3.stdout.txt"
  "AVE *([-0-9.]*)"
  "0.67"
  "0.68"
  )
plm_add_test (
  "plm-warp-xio-a-stats-4"
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "stats;${PLM_BUILD_TESTING_DIR}/plm-warp-xio-a-ss.nrrd"
  )
plmtest_check_interval ("plm-warp-xio-a-check-4"
  "${PLM_BUILD_TESTING_DIR}/plm-warp-xio-a-stats-4.stdout.txt"
  "S *1 *NVOX *([-0-9.]*)"
  "1970"
  "1971"
  )
add_test ("plm-warp-xio-a-check-5" ${CMAKE_COMMAND} -E compare_files
  "${PLM_TESTING_DATA_DIR}/plm-warp-xio-a-ss.txt"
  "${PLM_BUILD_TESTING_DIR}/plm-warp-xio-a-ss.txt")
add_test ("plm-warp-xio-a-check-6" ${CMAKE_COMMAND} -E compare_files
  "${PLM_TESTING_DATA_DIR}/plm-warp-xio-a.ctbl"
  "${PLM_BUILD_TESTING_DIR}/plm-warp-xio-a.ctbl")
set_tests_properties (plm-warp-xio-a-stats-1 PROPERTIES DEPENDS plm-warp-xio-a)
set_tests_properties (plm-warp-xio-a-check-1 
  PROPERTIES DEPENDS plm-warp-xio-a-stats-1)
set_tests_properties (plm-warp-xio-a-stats-2 PROPERTIES DEPENDS plm-warp-xio-a)
set_tests_properties (plm-warp-xio-a-check-2 
  PROPERTIES DEPENDS plm-warp-xio-a-stats-2)
set_tests_properties (plm-warp-xio-a-stats-3 PROPERTIES DEPENDS plm-warp-xio-a)
set_tests_properties (plm-warp-xio-a-check-3 
  PROPERTIES DEPENDS plm-warp-xio-a-stats-3)
set_tests_properties (plm-warp-xio-a-stats-4 PROPERTIES DEPENDS plm-warp-xio-a)
set_tests_properties (plm-warp-xio-a-check-4 
  PROPERTIES DEPENDS plm-warp-xio-a-stats-4)
set_tests_properties (plm-warp-xio-a-check-5 PROPERTIES DEPENDS plm-warp-xio-a)
set_tests_properties (plm-warp-xio-a-check-6 PROPERTIES DEPENDS plm-warp-xio-a)

## -------------------------------------------------------------------------
## plastimatch-convert-prefix-fcsv
## -------------------------------------------------------------------------
file (WRITE "${PLM_BUILD_TESTING_DIR}/sphere-7-list.txt"
  "0|255 0 0|sphere-7")

plm_add_test (
  "plm-convert-prefix-fcsv"
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "convert;--input-ss-img;${PLM_BUILD_TESTING_DIR}/sphere-7.mha;--input-ss-list;${PLM_BUILD_TESTING_DIR}/sphere-7-list.txt;--output-prefix-fcsv;${PLM_BUILD_TESTING_DIR}/plm-convert-prefix-fcsv;--simplify-perc;0.5"
  )
set_tests_properties (plm-convert-prefix-fcsv PROPERTIES DEPENDS sphere-7)

## -------------------------------------------------------------------------
## plastimatch-convert-dose-scale
## -------------------------------------------------------------------------
plm_add_test (
  "plm-convert-dose-scale"
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "convert;--input-dose-img;${PLM_BUILD_TESTING_DIR}/sphere-3.mha;--output-dose-img;${PLM_BUILD_TESTING_DIR}/plm-convert-dose-scale.mha;--dose-scale;77.7"
  )
plm_add_test (
  "plm-convert-dose-scale-stats"
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "stats;${PLM_BUILD_TESTING_DIR}/plm-convert-dose-scale.mha"
  )
plmtest_check_interval ("plm-convert-dose-scale-check"
  "${PLM_BUILD_TESTING_DIR}/plm-convert-dose-scale-stats.stdout.txt"
  "MAX *([-0-9.]*)"
  "77.699"
  "77.7"
  )
set_tests_properties (plm-convert-dose-scale PROPERTIES 
  DEPENDS sphere-3)
set_tests_properties (plm-convert-dose-scale-stats PROPERTIES 
  DEPENDS plm-convert-dose-scale)
set_tests_properties (plm-convert-dose-scale-check PROPERTIES 
  DEPENDS plm-convert-dose-scale-stats)

## -------------------------------------------------------------------------
## plm-crop-a  crop, with voxel indices
## plm-crop-b  crop, with world coordinates
## plm-crop-c  crop to structure bounding box
## -------------------------------------------------------------------------
plm_add_test (
  "plm-crop-a"
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "crop;--input;${PLM_BUILD_TESTING_DIR}/gauss-1.mha;--output;${PLM_BUILD_TESTING_DIR}/plm-crop-a.mha;--voxels;5 15 3 18 7 9"
  )
plm_add_test (
  "plm-crop-a-stats"
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "header;plm-crop-a.mha"
  )
plmtest_check_string ("plm-crop-a-check-1"
  "${PLM_BUILD_TESTING_DIR}/plm-crop-a-stats.stdout.txt"
  "^Size = (.*)$"
  "11 16 3"
  )

plm_add_test (
  "plm-crop-b"
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "crop;--input;${PLM_BUILD_TESTING_DIR}/gauss-1.mha;--output;${PLM_BUILD_TESTING_DIR}/plm-crop-b.mha;--coordinates;-15 10 3 18 -12 -7"
  )
plm_add_test (
  "plm-crop-b-stats"
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "header;plm-crop-b.mha"
  )
plmtest_check_string ("plm-crop-b-check-1"
  "${PLM_BUILD_TESTING_DIR}/plm-crop-b-stats.stdout.txt"
  "^Size = (.*)$"
  "19 11 4"
  )

plm_add_test (
  "plm-crop-c"
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "crop;--input;${PLM_BUILD_TESTING_DIR}/gauss-1.mha;--output;${PLM_BUILD_TESTING_DIR}/plm-crop-c.mha;--structure;${PLM_BUILD_TESTING_DIR}/donut-2.mha"
  )
plm_add_test (
  "plm-crop-c-stats"
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "header;plm-crop-c.mha"
  )
plmtest_check_string ("plm-crop-c-check-1"
  "${PLM_BUILD_TESTING_DIR}/plm-crop-c-stats.stdout.txt"
  "^Size = (.*)$"
  "15 15 15"
  )

set_tests_properties (plm-crop-a PROPERTIES DEPENDS gauss-1)
set_tests_properties (plm-crop-a-stats PROPERTIES DEPENDS plm-crop-a)
set_tests_properties (plm-crop-a-check-1 PROPERTIES DEPENDS plm-crop-a-stats)
set_tests_properties (plm-crop-b PROPERTIES DEPENDS gauss-1)
set_tests_properties (plm-crop-b-stats PROPERTIES DEPENDS plm-crop-b)
set_tests_properties (plm-crop-b-check-1 PROPERTIES DEPENDS plm-crop-b-stats)
set_tests_properties (plm-crop-c PROPERTIES DEPENDS "gauss-1;donut-2")
set_tests_properties (plm-crop-c-stats PROPERTIES DEPENDS plm-crop-c)
set_tests_properties (plm-crop-c-check-1 PROPERTIES DEPENDS plm-crop-c-stats)

## -------------------------------------------------------------------------
## plm-dice-a  dice, centered and off-centered rect
## plm-dice-b  dice, centered rects of different resolution
## plm-dice-c  HD tests centered and off-centered rect
## plm-dice-d  HD tests centered sphere and off-centered rect
## plm-dice-e  dice, HD tests of cylinder with zcrop
## -------------------------------------------------------------------------
plm_add_test (
  "plm-dice-a"
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "dice;${PLM_BUILD_TESTING_DIR}/rect-4.mha;${PLM_BUILD_TESTING_DIR}/rect-8.mha"
  )
plmtest_check_interval ("plm-dice-a-check-1"
  "${PLM_BUILD_TESTING_DIR}/plm-dice-a.stdout.txt"
  "^DICE: *([-0-9.]*)"
  "0.799"
  "0.801"
  )
set_tests_properties (plm-dice-a PROPERTIES DEPENDS "rect-4;rect-8")
set_tests_properties (plm-dice-a-check-1 PROPERTIES DEPENDS "plm-dice-a")

plm_add_test (
  "plm-dice-b"
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "dice;${PLM_BUILD_TESTING_DIR}/rect-4.mha;${PLM_BUILD_TESTING_DIR}/rect-9.mha"
  )
plmtest_check_interval ("plm-dice-b-check-1"
  "${PLM_BUILD_TESTING_DIR}/plm-dice-b.stdout.txt"
  "^DICE: *([-0-9.]*)"
  "0.999"
  "1.000"
  )
set_tests_properties (plm-dice-b PROPERTIES DEPENDS "rect-4;rect-9")
set_tests_properties (plm-dice-b-check-1 PROPERTIES DEPENDS "plm-dice-b")

plm_add_test (
  "plm-dice-c"
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "dice;--hausdorff;${PLM_BUILD_TESTING_DIR}/rect-4.mha;${PLM_BUILD_TESTING_DIR}/rect-8.mha"
  )
plmtest_check_interval ("plm-dice-c-check-1"
  "${PLM_BUILD_TESTING_DIR}/plm-dice-c.stdout.txt"
  "^Hausdorff distance = *([-0-9.]*)"
  "26.31"
  "26.32"
  )
plmtest_check_interval ("plm-dice-c-check-2"
  "${PLM_BUILD_TESTING_DIR}/plm-dice-c.stdout.txt"
  "^Avg average Hausdorff distance = *([-0-9.]*)"
  "3.40"
  "3.41"
  )
plmtest_check_interval ("plm-dice-c-check-3"
  "${PLM_BUILD_TESTING_DIR}/plm-dice-c.stdout.txt"
  "^Avg average Hausdorff distance \\\\(boundary\\\\) = *([-0-9.]*)"
  "7.11"
  "7.12"
  )
plmtest_check_interval ("plm-dice-c-check-4"
  "${PLM_BUILD_TESTING_DIR}/plm-dice-c.stdout.txt"
  "^Max average Hausdorff distance \\\\(boundary\\\\) = *([-0-9.]*)"
  "8.53"
  "8.54"
  )
plmtest_check_interval ("plm-dice-c-check-5"
  "${PLM_BUILD_TESTING_DIR}/plm-dice-c.stdout.txt"
  "^Percent .* \\\\(boundary\\\\) = *([-0-9.]*)"
  "26.31"
  "26.32"
  )
set_tests_properties (plm-dice-c PROPERTIES DEPENDS "rect-4;rect-8")
set_tests_properties (plm-dice-c-check-1 PROPERTIES DEPENDS "plm-dice-c")
set_tests_properties (plm-dice-c-check-2 PROPERTIES DEPENDS "plm-dice-c")
set_tests_properties (plm-dice-c-check-3 PROPERTIES DEPENDS "plm-dice-c")
set_tests_properties (plm-dice-c-check-4 PROPERTIES DEPENDS "plm-dice-c")
set_tests_properties (plm-dice-c-check-5 PROPERTIES DEPENDS "plm-dice-c")

plm_add_test (
  "plm-dice-d"
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "dice;--hausdorff;${PLM_BUILD_TESTING_DIR}/sphere-6.mha;${PLM_BUILD_TESTING_DIR}/rect-8.mha"
  )
plmtest_check_interval ("plm-dice-d-check-1"
  "${PLM_BUILD_TESTING_DIR}/plm-dice-d.stdout.txt"
  "^Hausdorff distance = *([-0-9.]*)"
  "45.575"
  "45.585"
  )
plmtest_check_interval ("plm-dice-d-check-2"
  "${PLM_BUILD_TESTING_DIR}/plm-dice-d.stdout.txt"
  "^Avg average Hausdorff distance = *([-0-9.]*)"
  "7.07"
  "7.08"
  )
plmtest_check_interval ("plm-dice-d-check-3"
  "${PLM_BUILD_TESTING_DIR}/plm-dice-d.stdout.txt"
  "^Avg average Hausdorff distance \\\\(boundary\\\\) = *([-0-9.]*)"
  "14.89"
  "14.90"
  )
plmtest_check_interval ("plm-dice-d-check-4"
  "${PLM_BUILD_TESTING_DIR}/plm-dice-d.stdout.txt"
  "^Max average Hausdorff distance \\\\(boundary\\\\) = *([-0-9.]*)"
  "18.38"
  "18.39"
  )
plmtest_check_interval ("plm-dice-d-check-5"
  "${PLM_BUILD_TESTING_DIR}/plm-dice-d.stdout.txt"
  "^Percent .* \\\\(boundary\\\\) = *([-0-9.]*)"
  "32.89"
  "32.90"
  )
set_tests_properties (plm-dice-d PROPERTIES DEPENDS "sphere-6;rect-8")
set_tests_properties (plm-dice-d-check-1 PROPERTIES DEPENDS "plm-dice-d")
set_tests_properties (plm-dice-d-check-2 PROPERTIES DEPENDS "plm-dice-d")
set_tests_properties (plm-dice-d-check-3 PROPERTIES DEPENDS "plm-dice-d")
set_tests_properties (plm-dice-d-check-4 PROPERTIES DEPENDS "plm-dice-d")
set_tests_properties (plm-dice-d-check-5 PROPERTIES DEPENDS "plm-dice-d")

plm_add_test (
  "plm-dice-e"
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "dice;--all;--zcrop;0 0;${PLM_BUILD_TESTING_DIR}/cyl-2.nrrd;${PLM_BUILD_TESTING_DIR}/cyl-3.nrrd"
  )
plmtest_check_interval ("plm-dice-e-check-1"
  "${PLM_BUILD_TESTING_DIR}/plm-dice-e.stdout.txt"
  "^DICE: *([-0-9.]*)"
  "0.96550"
  "0.96554"
  )
plmtest_check_interval ("plm-dice-e-check-2"
  "${PLM_BUILD_TESTING_DIR}/plm-dice-e.stdout.txt"
  "^Hausdorff distance = *([-0-9.]*)"
  "5"
  "5"
  )

set_tests_properties (plm-dice-e PROPERTIES DEPENDS "cyl-2;cyl-3")
set_tests_properties (plm-dice-e-check-1 PROPERTIES DEPENDS plm-dice-e)
set_tests_properties (plm-dice-e-check-2 PROPERTIES DEPENDS plm-dice-e)

plm_add_test (
  "plm-dice-f"
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "dice;--all;--zcrop;10 10;${PLM_BUILD_TESTING_DIR}/cyl-2.nrrd;${PLM_BUILD_TESTING_DIR}/cyl-3.nrrd"
  )
plmtest_check_interval ("plm-dice-f-check-1"
  "${PLM_BUILD_TESTING_DIR}/plm-dice-f.stdout.txt"
  "^DICE: *([-0-9.]*)"
  "1"
  "1"
  )
plmtest_check_interval ("plm-dice-f-check-2"
  "${PLM_BUILD_TESTING_DIR}/plm-dice-f.stdout.txt"
  "^Hausdorff distance = *([-0-9.]*)"
  "0"
  "0"
  )

set_tests_properties (plm-dice-f PROPERTIES DEPENDS "cyl-2;cyl-3")
set_tests_properties (plm-dice-f-check-1 PROPERTIES DEPENDS plm-dice-f)
set_tests_properties (plm-dice-f-check-2 PROPERTIES DEPENDS plm-dice-f)

## -------------------------------------------------------------------------
## plm-dmap-a  distance map, itk maurer
## plm-dmap-b  distance map, native danielsson
## plm-dmap-c  distance map, song maurer
## -------------------------------------------------------------------------
plm_add_test (
  "plm-dmap-a"
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "dmap;--algorithm;maurer;--input;${PLM_BUILD_TESTING_DIR}/rect-4.mha;--output;${PLM_BUILD_TESTING_DIR}/plm-dmap-a.mha"
  )
set_tests_properties (plm-dmap-a PROPERTIES DEPENDS "rect-4")

plm_add_test (
  "plm-dmap-b"
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "dmap;--algorithm;danielsson;--input;${PLM_BUILD_TESTING_DIR}/rect-4.mha;--output;${PLM_BUILD_TESTING_DIR}/plm-dmap-b.mha;--absolute-distance"
  )
set_tests_properties (plm-dmap-b PROPERTIES DEPENDS "rect-4")

plm_add_test (
  "plm-dmap-c"
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "dmap;--algorithm;song_maurer;--input;${PLM_BUILD_TESTING_DIR}/rect-4.mha;--output;${PLM_BUILD_TESTING_DIR}/plm-dmap-c.mha"
  )
set_tests_properties (plm-dmap-c PROPERTIES DEPENDS "rect-4")


## -------------------------------------------------------------------------
## plm-dvh-a  ss-img, without ss-list
## plm-dvh-b  ss-img, with ss-list
## plm-dvh-c  DICOM input
## -------------------------------------------------------------------------
plm_add_test (
  "plm-dvh-a"
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "dvh;--input-ss-img;${PLM_BUILD_TESTING_DIR}/rect-1-ss.mha;--input-dose;${PLM_BUILD_TESTING_DIR}/rect-1-dose-img.mha;--output-csv;${PLM_BUILD_TESTING_DIR}/plm-dvh-a.csv"
  )
plmtest_check_interval ("plm-dvh-a-check-1"
  "${PLM_BUILD_TESTING_DIR}/plm-dvh-a.csv"
  "^15,([-0-9.]*),"
  "0.999"
  "1.0"
  )
plmtest_check_interval ("plm-dvh-a-check-2"
  "${PLM_BUILD_TESTING_DIR}/plm-dvh-a.csv"
  "^15.5,([-0-9.]*),"
  "0.0"
  "0.001"
  )
set_tests_properties (plm-dvh-a PROPERTIES DEPENDS "rect-1")
set_tests_properties (plm-dvh-a-check-1 PROPERTIES DEPENDS "plm-dvh-a")
set_tests_properties (plm-dvh-a-check-2 PROPERTIES DEPENDS "plm-dvh-a")

plm_add_test (
  "plm-dvh-b"
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "dvh;--input-ss-img;${PLM_BUILD_TESTING_DIR}/rect-1-ss.mha;--input-ss-list;${PLM_BUILD_TESTING_DIR}/rect-1-ss-list.txt;--input-dose;${PLM_BUILD_TESTING_DIR}/rect-1-dose-img.mha;--output-csv;${PLM_BUILD_TESTING_DIR}/plm-dvh-b.csv"
  )
plmtest_check_interval ("plm-dvh-b-check-1"
  "${PLM_BUILD_TESTING_DIR}/plm-dvh-b.csv"
  "^15,([-0-9.]*)"
  "0.999"
  "1.0"
  )
plmtest_check_interval ("plm-dvh-b-check-2"
  "${PLM_BUILD_TESTING_DIR}/plm-dvh-b.csv"
  "^15.5,([-0-9.]*)"
  "0.0"
  "0.001"
  )
set_tests_properties (plm-dvh-b PROPERTIES DEPENDS "rect-1")
set_tests_properties (plm-dvh-b-check-1 PROPERTIES DEPENDS "plm-dvh-b")
set_tests_properties (plm-dvh-b-check-2 PROPERTIES DEPENDS "plm-dvh-b")

plm_add_test (
  "plm-dvh-c"
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "dvh;--input;${PLM_BUILD_TESTING_DIR}/rect-1-dicom;--output-csv;${PLM_BUILD_TESTING_DIR}/plm-dvh-c.csv"
  )
plmtest_check_interval ("plm-dvh-c-check-1"
  "${PLM_BUILD_TESTING_DIR}/plm-dvh-c.csv"
  "^15,([-0-9.]*)"
  "0.780"
  "0.783"
  )
plmtest_check_interval ("plm-dvh-c-check-2"
  "${PLM_BUILD_TESTING_DIR}/plm-dvh-c.csv"
  "^15.5,([-0-9.]*)"
  "0.0"
  "0.001"
  )
set_tests_properties (plm-dvh-c PROPERTIES DEPENDS "rect-1")
set_tests_properties (plm-dvh-c-check-1 PROPERTIES DEPENDS "plm-dvh-c")
set_tests_properties (plm-dvh-c-check-2 PROPERTIES DEPENDS "plm-dvh-c")

## -------------------------------------------------------------------------
## plastimatch fill/mask
## -------------------------------------------------------------------------
plm_add_test (
  "plm-fill-a"
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "fill;--input;${PLM_BUILD_TESTING_DIR}/rect-1.mha;--output;${PLM_BUILD_TESTING_DIR}/plm-fill-a.mha;--mask;${PLM_BUILD_TESTING_DIR}/rect-4.mha"
  )
plm_add_test (
  "plm-fill-a-stats"
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "stats;${PLM_BUILD_TESTING_DIR}/plm-fill-a.mha"
  )
plmtest_check_interval ("plm-fill-a-check"
  "${PLM_BUILD_TESTING_DIR}/plm-fill-a-stats.stdout.txt"
  "AVE *([-0-9.]*)"
  "-0.1"
  "+0.1"
  )
set_tests_properties (plm-fill-a PROPERTIES DEPENDS "rect-1;rect-4")
set_tests_properties (plm-fill-a-stats PROPERTIES DEPENDS plm-fill-a)
set_tests_properties (plm-fill-a-check PROPERTIES DEPENDS plm-fill-a-stats)

plm_add_test (
  "plm-mask-a"
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "mask;--input;${PLM_BUILD_TESTING_DIR}/rect-1.mha;--output;${PLM_BUILD_TESTING_DIR}/plm-mask-a.mha;--mask;${PLM_BUILD_TESTING_DIR}/rect-4.mha;--mask-value;-1000"
  )
plm_add_test (
  "plm-mask-a-stats"
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "stats;${PLM_BUILD_TESTING_DIR}/plm-mask-a.mha"
  )
plmtest_check_interval ("plm-mask-a-check"
  "${PLM_BUILD_TESTING_DIR}/plm-mask-a-stats.stdout.txt"
  "AVE *([-0-9.]*)"
  "-1000.1"
  "-999.9"
  )
set_tests_properties (plm-mask-a PROPERTIES DEPENDS "rect-1;rect-4")
set_tests_properties (plm-mask-a-stats PROPERTIES DEPENDS plm-mask-a)
set_tests_properties (plm-mask-a-check PROPERTIES DEPENDS plm-mask-a-stats)

## -------------------------------------------------------------------------
## plm-gamma-a  centered and off-center rectangle, centered as reference
## plm-gamma-b  centered rectangles with different dosees
## plm-gamma-c  analysis using dose threshold on both images
## plm-gamma-d  analysis using dose threshold on ref only
## -------------------------------------------------------------------------
plm_add_test (
  "plm-gamma-a"
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "gamma;--compute-full-region;--output;${PLM_BUILD_TESTING_DIR}/plm-gamma-a.mha;${PLM_BUILD_TESTING_DIR}/rect-12.mha;${PLM_BUILD_TESTING_DIR}/rect-14.mha"
  )
plm_add_test (
  "plm-gamma-a-stats"
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "stats;${PLM_BUILD_TESTING_DIR}/plm-gamma-a.mha"
  )
plmtest_check_interval ("plm-gamma-a-check"
  "${PLM_BUILD_TESTING_DIR}/plm-gamma-a-stats.stdout.txt"
  "AVE *([-0-9.]*)"
  "0.023"
  "0.024"
  )
set_tests_properties (plm-gamma-a PROPERTIES DEPENDS "rect-12;rect-14")
set_tests_properties (plm-gamma-a-stats PROPERTIES DEPENDS plm-gamma-a)
set_tests_properties (plm-gamma-a-check PROPERTIES DEPENDS plm-gamma-a-stats)

plm_add_test (
  "plm-gamma-b"
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "gamma;--output;${PLM_BUILD_TESTING_DIR}/plm-gamma-b.mha;${PLM_BUILD_TESTING_DIR}/rect-12.mha;${PLM_BUILD_TESTING_DIR}/rect-13.mha"
  )
plm_add_test (
  "plm-gamma-b-stats"
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "stats;${PLM_BUILD_TESTING_DIR}/plm-gamma-b.mha"
  )
plmtest_check_interval ("plm-gamma-b-check"
  "${PLM_BUILD_TESTING_DIR}/plm-gamma-b-stats.stdout.txt"
  "AVE *([-0-9.]*)"
  "0.245"
  "0.255"
  )
set_tests_properties (plm-gamma-b PROPERTIES DEPENDS "rect-12;rect-13")
set_tests_properties (plm-gamma-b-stats PROPERTIES DEPENDS plm-gamma-b)
set_tests_properties (plm-gamma-b-check PROPERTIES DEPENDS plm-gamma-b-stats)

plm_add_test (
  "plm-gamma-c"
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "gamma;--output;${PLM_BUILD_TESTING_DIR}/plm-gamma-c.mha;${PLM_BUILD_TESTING_DIR}/rectarr-03.mha;${PLM_BUILD_TESTING_DIR}/rectarr-04.mha"
  )
plmtest_check_interval ("plm-gamma-c-check"
  "${PLM_BUILD_TESTING_DIR}/plm-gamma-c.stdout.txt"
  "Pass rate = *([-0-9.]*)"
  "90.6"
  "90.8"
  )
set_tests_properties (plm-gamma-c PROPERTIES DEPENDS "rectarr-03;rectarr-04")
set_tests_properties (plm-gamma-c-check PROPERTIES DEPENDS plm-gamma-c)

plm_add_test (
  "plm-gamma-d"
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "gamma;--output;${PLM_BUILD_TESTING_DIR}/plm-gamma-d.mha;--ref-only-threshold;${PLM_BUILD_TESTING_DIR}/rectarr-03.mha;${PLM_BUILD_TESTING_DIR}/rectarr-04.mha"
  )
plmtest_check_interval ("plm-gamma-d-check"
  "${PLM_BUILD_TESTING_DIR}/plm-gamma-d.stdout.txt"
  "Pass rate = *([-0-9.]*)"
  "89.9"
  "90.1"
  )
set_tests_properties (plm-gamma-d PROPERTIES DEPENDS "rectarr-03;rectarr-04")
set_tests_properties (plm-gamma-d-check PROPERTIES DEPENDS plm-gamma-d)

## -------------------------------------------------------------------------
## plastimatch maximum
##  plm-maximum       Set image containing maximum pixel values across list of images
## -------------------------------------------------------------------------
plm_add_test (
  "plm-maximum-a"
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "maximum;--output;${PLM_BUILD_TESTING_DIR}/plm-maximum-a.nrrd;${PLM_BUILD_TESTING_DIR}/rect-1.mha;${PLM_BUILD_TESTING_DIR}/rect-3.mha"
  )
plm_add_test (
  "plm-maximum-a-stats"
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "stats;${PLM_BUILD_TESTING_DIR}/plm-maximum-a.nrrd"
  )
plmtest_check_interval ("plm-maximum-a-check"
  "${PLM_BUILD_TESTING_DIR}/plm-maximum-a-stats.stdout.txt"
  "AVE *([-0-9.]*)"
  "0.0"
  "0.0"
  )
set_tests_properties (plm-maximum-a PROPERTIES DEPENDS "rect-1;rect-3")
set_tests_properties (plm-maximum-a-stats PROPERTIES DEPENDS plm-maximum-a)
set_tests_properties (plm-maximum-a-check PROPERTIES DEPENDS plm-maximum-a-stats)

## -------------------------------------------------------------------------
## plastimatch multiply
##  plm-multiply-a      Multiply two images
##  plm-multiply-vf-a   Multiply two vector fields
## -------------------------------------------------------------------------
plm_add_test (
  "plm-multiply-a"
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "multiply;--output;${PLM_BUILD_TESTING_DIR}/plm-multiply-a.nrrd;${PLM_BUILD_TESTING_DIR}/rect-1.mha;${PLM_BUILD_TESTING_DIR}/rect-3.mha"
  )
plm_add_test (
  "plm-multiply-a-stats"
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "stats;${PLM_BUILD_TESTING_DIR}/plm-multiply-a.nrrd"
  )
plmtest_check_interval ("plm-multiply-a-check"
  "${PLM_BUILD_TESTING_DIR}/plm-multiply-a-stats.stdout.txt"
  "AVE *([-0-9.]*)"
  "0.0"
  "0.0"
  )
set_tests_properties (plm-multiply-a PROPERTIES DEPENDS "rect-1;rect-3")
set_tests_properties (plm-multiply-a-stats PROPERTIES DEPENDS plm-multiply-a)
set_tests_properties (plm-multiply-a-check PROPERTIES DEPENDS plm-multiply-a-stats)


plm_add_test (
  "plm-multiply-vf-a"
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "multiply;--output;${PLM_BUILD_TESTING_DIR}/plm-multiply-vf-a.nrrd;${PLM_BUILD_TESTING_DIR}/vf-trans-1.mha;${PLM_BUILD_TESTING_DIR}/vf-trans-1.mha"
  )
plm_add_test (
  "plm-multiply-vf-a-stats"
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "stats;${PLM_BUILD_TESTING_DIR}/plm-multiply-vf-a.nrrd"
  )
plmtest_check_interval ("plm-multiply-vf-a-check"
  "${PLM_BUILD_TESTING_DIR}/plm-multiply-vf-a-stats.stdout.txt"
  "Mean: *([-0-9.]*)"
  "100.000"
  "100.000"
  )
set_tests_properties (plm-multiply-vf-a PROPERTIES DEPENDS vf-trans-1)
set_tests_properties (plm-multiply-vf-a-stats PROPERTIES DEPENDS plm-multiply-vf-a)
set_tests_properties (plm-multiply-vf-a-check PROPERTIES DEPENDS plm-multiply-vf-a-stats)

## -------------------------------------------------------------------------
## plastimatch usage
## -------------------------------------------------------------------------
plm_add_test (
  "plm-usage" 
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  ""
  )

## -------------------------------------------------------------------------
## plastimatch register (group 1) - basic functionality
##   plm-reg-align-center
##   plm-reg-itk-translation
##   plm-reg-itk-rigid-a
##   plm-reg-itk-rigid-b
##   plm-reg-itk-bspline
##   plm-reg-itk-demons
## -------------------------------------------------------------------------
# For Nocedal optimizer
set (PLM_BSPLINE_TEST_LOWER_THRESH "-746.0")
set (PLM_BSPLINE_TEST_UPPER_THRESH "-744.5")
# For Liblbfgs optimizer
#set (PLM_BSPLINE_TEST_LOWER_THRESH "-706.0")
#set (PLM_BSPLINE_TEST_UPPER_THRESH "-704.5")

# ITK changed its behavior the precision used when # exporting MHA files,
# which causes slight differences in registration results
if ("${ITK_VERSION}" VERSION_LESS "4.13")
  set (MSE_O_TEST_LOWER_THRESH "-741.6")
  set (MSE_O_TEST_UPPER_THRESH "-741.3")
  set (MSE_PQR_TEST_LOWER_THRESH "-741.6")
  set (MSE_PQR_TEST_UPPER_THRESH "-741.3")
else()
  set (MSE_O_TEST_LOWER_THRESH "-743.3")
  set (MSE_O_TEST_UPPER_THRESH "-743.0")
  set (MSE_PQR_TEST_LOWER_THRESH "-740.1")
  set (MSE_PQR_TEST_UPPER_THRESH "-739.8")
endif()

plm_add_test (
  "plm-reg-align-center"
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "${PLM_BUILD_TESTING_DIR}/plm-reg-align-center.txt"
  )
plm_add_test (
  "plm-reg-align-center-stats"
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "compare;${PLM_BUILD_TESTING_DIR}/gauss-1.mha;${PLM_BUILD_TESTING_DIR}/plm-reg-align-center-img.mha"
  )
plmtest_check_interval ("plm-reg-align-center-check"
  "${PLM_BUILD_TESTING_DIR}/plm-reg-align-center-stats.stdout.txt"
  "MAE *([-0-9.]*)"
  "-0.005"
  "0.005"
  )
set_property (TEST plm-reg-align-center APPEND PROPERTY DEPENDS gauss-1)
set_property (TEST plm-reg-align-center APPEND PROPERTY DEPENDS gauss-6)
set_tests_properties (plm-reg-align-center-stats PROPERTIES 
  DEPENDS plm-reg-align-center)
set_tests_properties (plm-reg-align-center-check PROPERTIES 
  DEPENDS plm-reg-align-center-stats)

plm_add_test (
  "plm-reg-itk-translation"
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "${PLM_BUILD_TESTING_DIR}/plm-reg-itk-translation.txt"
  )
plm_add_test (
  "plm-reg-itk-translation-stats"
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "stats;${PLM_BUILD_TESTING_DIR}/plm-reg-itk-translation-img.mha"
  )
plmtest_check_interval ("plm-reg-itk-translation-check"
  "${PLM_BUILD_TESTING_DIR}/plm-reg-itk-translation-stats.stdout.txt"
  "AVE *([-0-9.]*)"
  "-677.6"
  "-677.5"
  )
set_property (TEST plm-reg-itk-translation APPEND PROPERTY DEPENDS gauss-1)
set_property (TEST plm-reg-itk-translation APPEND PROPERTY DEPENDS gauss-2)
set_tests_properties (plm-reg-itk-translation-stats PROPERTIES 
  DEPENDS plm-reg-itk-translation)
set_tests_properties (plm-reg-itk-translation-check PROPERTIES 
  DEPENDS plm-reg-itk-translation-stats)

plm_add_test (
  "plm-reg-itk-rigid-a"
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "${PLM_BUILD_TESTING_DIR}/plm-reg-itk-rigid-a.txt"
  )
plm_add_test (
  "plm-reg-itk-rigid-a-stats-1"
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "stats;${PLM_BUILD_TESTING_DIR}/plm-reg-itk-rigid-a-intermediate-img.mha"
  )
plmtest_check_interval ("plm-reg-itk-rigid-a-check-1"
  "${PLM_BUILD_TESTING_DIR}/plm-reg-itk-rigid-a-stats-1.stdout.txt"
  "AVE *([-0-9.]*)"
  "-939.3"
  "-939.1"
  )
plm_add_test (
  "plm-reg-itk-rigid-a-stats-2"
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "stats;${PLM_BUILD_TESTING_DIR}/plm-reg-itk-rigid-a-img.mha"
  )
plmtest_check_interval ("plm-reg-itk-rigid-a-check-2"
  "${PLM_BUILD_TESTING_DIR}/plm-reg-itk-rigid-a-stats-2.stdout.txt"
  "AVE *([-0-9.]*)"
  "-939.3"
  "-939.1"
  )
set_tests_properties (plm-reg-itk-rigid-a PROPERTIES 
  DEPENDS "rect-2;rect-3")
set_tests_properties (plm-reg-itk-rigid-a-stats-1 PROPERTIES 
  DEPENDS plm-reg-itk-rigid-a)
set_tests_properties (plm-reg-itk-rigid-a-check-1 PROPERTIES 
  DEPENDS plm-reg-itk-rigid-a-stats-1)
set_tests_properties (plm-reg-itk-rigid-a-stats-2 PROPERTIES 
  DEPENDS plm-reg-itk-rigid-a)
set_tests_properties (plm-reg-itk-rigid-a-check-2 PROPERTIES 
  DEPENDS plm-reg-itk-rigid-a-stats-2)

plm_add_test (
  "plm-reg-itk-similarity"
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "${PLM_BUILD_TESTING_DIR}/plm-reg-itk-similarity.txt"
  )
plm_add_test (
  "plm-reg-itk-similarity-stats-1"
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "stats;${PLM_BUILD_TESTING_DIR}/plm-reg-itk-similarity-intermediate-img.mha"
  )
plmtest_check_interval ("plm-reg-itk-similarity-check-1"
  "${PLM_BUILD_TESTING_DIR}/plm-reg-itk-similarity-stats-1.stdout.txt"
  "AVE *([-0-9.]*)"
  "-981.3"
  "-981.1"
  )
plm_add_test (
  "plm-reg-itk-similarity-stats-2"
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "stats;${PLM_BUILD_TESTING_DIR}/plm-reg-itk-similarity-img.mha"
  )
plmtest_check_interval ("plm-reg-itk-similarity-check-2"
  "${PLM_BUILD_TESTING_DIR}/plm-reg-itk-similarity-stats-2.stdout.txt"
  "AVE *([-0-9.]*)"
  "-940.8"
  "-940.5"
  )

set_tests_properties (plm-reg-itk-similarity PROPERTIES
  DEPENDS "rect-2s;rect-2")
set_tests_properties (plm-reg-itk-similarity-stats-1 PROPERTIES
  DEPENDS plm-reg-itk-similarity)
set_tests_properties (plm-reg-itk-similarity-check-1 PROPERTIES
  DEPENDS plm-reg-itk-similarity-stats-1)
set_tests_properties (plm-reg-itk-similarity-stats-2 PROPERTIES
  DEPENDS plm-reg-itk-similarity)
set_tests_properties (plm-reg-itk-similarity-check-2 PROPERTIES
  DEPENDS plm-reg-itk-similarity-stats-2)

plm_add_test (
  "plm-reg-itk-rigid-b"
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "${PLM_BUILD_TESTING_DIR}/plm-reg-itk-rigid-b.txt"
  )
plm_add_test (
  "plm-reg-itk-rigid-b-stats-1"
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "stats;${PLM_BUILD_TESTING_DIR}/plm-reg-itk-rigid-b-intermediate-img.mha"
  )
plmtest_check_interval ("plm-reg-itk-rigid-b-check-1"
  "${PLM_BUILD_TESTING_DIR}/plm-reg-itk-rigid-b-stats-1.stdout.txt"
  "AVE *([-0-9.]*)"
  "-939.3"
  "-939.1"
  )
set_tests_properties (plm-reg-itk-rigid-b PROPERTIES 
  DEPENDS "rect-1;rect-2")
set_tests_properties (plm-reg-itk-rigid-b-stats-1 PROPERTIES 
  DEPENDS plm-reg-itk-rigid-b)
set_tests_properties (plm-reg-itk-rigid-b-check-1 PROPERTIES 
  DEPENDS plm-reg-itk-rigid-b-stats-1)

plm_add_test (
  "plm-reg-itk-bspline"
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "${PLM_BUILD_TESTING_DIR}/plm-reg-itk-bspline.txt"
  )
plm_add_test (
  "plm-reg-itk-bspline-stats-1"
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "stats;${PLM_BUILD_TESTING_DIR}/plm-reg-itk-bspline-img.mha"
  )
plmtest_check_interval ("plm-reg-itk-bspline-check-1"
  "${PLM_BUILD_TESTING_DIR}/plm-reg-itk-bspline-stats-1.stdout.txt"
  "AVE *([-0-9.]*)"
  "-764.0"
  "-763.6"
  )
set_property (TEST plm-reg-itk-bspline APPEND PROPERTY DEPENDS gauss-1)
set_property (TEST plm-reg-itk-bspline APPEND PROPERTY DEPENDS gauss-2)
set_tests_properties (plm-reg-itk-bspline-stats-1 PROPERTIES 
  DEPENDS plm-reg-itk-bspline)
set_tests_properties (plm-reg-itk-bspline-check-1 PROPERTIES 
  DEPENDS plm-reg-itk-bspline-stats-1)

plm_add_test (
  "plm-reg-itk-demons"
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "${PLM_BUILD_TESTING_DIR}/plm-reg-itk-demons.txt"
  )
plmtest_check_interval ("plm-reg-itk-demons-check-1"
  "${PLM_BUILD_TESTING_DIR}/plm-reg-itk-demons.stdout.txt"
  "VF_AVG +[^ ] +([-0-9.]*)"
  "31.85"
  "34.95"
  )
plm_add_test (
  "plm-reg-itk-demons-stats-2"
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "stats;${PLM_BUILD_TESTING_DIR}/plm-reg-itk-demons-img.mha"
  )
plmtest_check_interval ("plm-reg-itk-demons-check-2"
  "${PLM_BUILD_TESTING_DIR}/plm-reg-itk-demons-stats-2.stdout.txt"
  "AVE *([-0-9.]*)"
  "-755.3"
  "-754.6"
  )
set_property (TEST plm-reg-itk-demons PROPERTY DEPENDS "gauss-1;gauss-2")
set_tests_properties (plm-reg-itk-demons-check-1 
  PROPERTIES DEPENDS plm-reg-itk-demons)
set_tests_properties (plm-reg-itk-demons-stats-2 
  PROPERTIES DEPENDS plm-reg-itk-demons)
set_tests_properties (plm-reg-itk-demons-check-2 
  PROPERTIES DEPENDS plm-reg-itk-demons-stats-2)

plm_add_test (
  "plm-reg-itk-demons-diff"
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "${PLM_BUILD_TESTING_DIR}/plm-reg-itk-demons-diff.txt"
  )
plmtest_check_interval ("plm-reg-itk-demons-diff-check-1"
  "${PLM_BUILD_TESTING_DIR}/plm-reg-itk-demons-diff.stdout.txt"
  "VF_AVG +[^ ] +([-0-9.]*)"
  "31.2"
  "31.3"
  )
set_property (TEST plm-reg-itk-demons-diff 
  PROPERTY DEPENDS "gauss-1;gauss-2")
set_tests_properties (plm-reg-itk-demons-diff-check-1 
  PROPERTIES DEPENDS plm-reg-itk-demons-diff)

plm_add_test (
  "plm-reg-itk-demons-logd"
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "${PLM_BUILD_TESTING_DIR}/plm-reg-itk-demons-logd.txt"
  )
plmtest_check_interval ("plm-reg-itk-demons-logd-check-1"
  "${PLM_BUILD_TESTING_DIR}/plm-reg-itk-demons-logd.stdout.txt"
  "VF_AVG +[^ ] +([-0-9.]*)"
  "32.65"
  "32.75"
  )
set_property (TEST plm-reg-itk-demons-logd 
  PROPERTY DEPENDS "gauss-1;gauss-2")
set_tests_properties (plm-reg-itk-demons-logd-check-1 
  PROPERTIES DEPENDS plm-reg-itk-demons-logd)

plm_add_test (
  "plm-reg-itk-demons-sym-logd"
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "${PLM_BUILD_TESTING_DIR}/plm-reg-itk-demons-sym-logd.txt"
  )
plmtest_check_interval ("plm-reg-itk-demons-sym-logd-check-1"
  "${PLM_BUILD_TESTING_DIR}/plm-reg-itk-demons-sym-logd.stdout.txt"
  "VF_AVG +[^ ] +([-0-9.]*)"
  "31.85"
  "35.95"
  )
set_property (TEST plm-reg-itk-demons-sym-logd 
  PROPERTY DEPENDS "gauss-1;gauss-2")
set_tests_properties (plm-reg-itk-demons-sym-logd-check-1 
  PROPERTIES DEPENDS plm-reg-itk-demons-sym-logd)

## -------------------------------------------------------------------------
## plastimatch register (group 2)
##   plm-bsp-mse-c
##   plm-bsp-mse-g
##   plm-bsp-mse-h
##   plm-bsp-mse-i
##   plm-bsp-mse-k
##   plm-bsp-mse-l
##   plm-bsp-mse-o
##   plm-bsp-mes-p
##   plm-bsp-mse-q
##   plm-bsp-mse-r
##   plm-bsp-openmp
##   plm-bsp-cuda
##   plm-bsp-resume
##   plm-bsp-logfile
##   plm-bsp-ushort
##   plm-bsp-double
##   plm-bsp-itk-output
##   plm-bsp-char-output
## -------------------------------------------------------------------------
plm_add_test (
  "plm-bsp-mse-c" 
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "${PLM_BUILD_TESTING_DIR}/plm-bsp-mse-c.txt"
  )
plm_add_test (
  "plm-bsp-mse-c-stats"
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "stats;${PLM_BUILD_TESTING_DIR}/plm-bsp-mse-c-img.mha"
  )
plmtest_check_interval ("plm-bsp-mse-c-check"
  "${PLM_BUILD_TESTING_DIR}/plm-bsp-mse-c-stats.stdout.txt"
  "AVE *([-0-9.]*)"
  "${PLM_BSPLINE_TEST_LOWER_THRESH}"
  "${PLM_BSPLINE_TEST_UPPER_THRESH}"
  )
set_property (TEST plm-bsp-mse-c APPEND PROPERTY DEPENDS gauss-1)
set_property (TEST plm-bsp-mse-c APPEND PROPERTY DEPENDS gauss-2)
set_tests_properties (plm-bsp-mse-c-stats PROPERTIES 
  DEPENDS plm-bsp-mse-c)
set_tests_properties (plm-bsp-mse-c-check PROPERTIES 
  DEPENDS plm-bsp-mse-c-stats)

plm_add_test (
  "plm-bsp-mse-g" 
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "${PLM_BUILD_TESTING_DIR}/plm-bsp-mse-g.txt"
  )
plm_add_test (
  "plm-bsp-mse-g-stats"
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "stats;${PLM_BUILD_TESTING_DIR}/plm-bsp-mse-g-img.mha"
  )
plmtest_check_interval ("plm-bsp-mse-g-check"
  "${PLM_BUILD_TESTING_DIR}/plm-bsp-mse-g-stats.stdout.txt"
  "AVE *([-0-9.]*)"
  "${PLM_BSPLINE_TEST_LOWER_THRESH}"
  "${PLM_BSPLINE_TEST_UPPER_THRESH}"
  )
set_property (TEST plm-bsp-mse-g APPEND PROPERTY DEPENDS gauss-1)
set_property (TEST plm-bsp-mse-g APPEND PROPERTY DEPENDS gauss-2)
set_tests_properties (plm-bsp-mse-g-stats PROPERTIES 
  DEPENDS plm-bsp-mse-g)
set_tests_properties (plm-bsp-mse-g-check PROPERTIES 
  DEPENDS plm-bsp-mse-g-stats)


plm_add_test (
  "plm-bsp-mse-h" 
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "${PLM_BUILD_TESTING_DIR}/plm-bsp-mse-h.txt"
  )
plm_add_test (
  "plm-bsp-mse-h-stats"
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "stats;${PLM_BUILD_TESTING_DIR}/plm-bsp-mse-h-img.mha"
  )
plmtest_check_interval ("plm-bsp-mse-h-check"
  "${PLM_BUILD_TESTING_DIR}/plm-bsp-mse-h-stats.stdout.txt"
  "AVE *([-0-9.]*)"
  "${PLM_BSPLINE_TEST_LOWER_THRESH}"
  "${PLM_BSPLINE_TEST_UPPER_THRESH}"
  )
set_property (TEST plm-bsp-mse-h APPEND PROPERTY DEPENDS gauss-1)
set_property (TEST plm-bsp-mse-h APPEND PROPERTY DEPENDS gauss-2)
set_tests_properties (plm-bsp-mse-h-stats PROPERTIES 
  DEPENDS plm-bsp-mse-h)
set_tests_properties (plm-bsp-mse-h-check PROPERTIES 
  DEPENDS plm-bsp-mse-h-stats)

plm_add_test (
  "plm-bsp-mse-i" 
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "${PLM_BUILD_TESTING_DIR}/plm-bsp-mse-i.txt"
  )
plm_add_test (
  "plm-bsp-mse-i-stats"
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "stats;${PLM_BUILD_TESTING_DIR}/plm-bsp-mse-i-img.mha"
  )
plmtest_check_interval ("plm-bsp-mse-i-check"
  "${PLM_BUILD_TESTING_DIR}/plm-bsp-mse-i-stats.stdout.txt"
  "AVE *([-0-9.]*)"
  "${PLM_BSPLINE_TEST_LOWER_THRESH}"
  "${PLM_BSPLINE_TEST_UPPER_THRESH}"
  )
set_property (TEST plm-bsp-mse-i APPEND PROPERTY DEPENDS gauss-1)
set_property (TEST plm-bsp-mse-i APPEND PROPERTY DEPENDS gauss-2)
set_tests_properties (plm-bsp-mse-i-stats PROPERTIES 
  DEPENDS plm-bsp-mse-i)
set_tests_properties (plm-bsp-mse-i-check PROPERTIES 
  DEPENDS plm-bsp-mse-i-stats)

plm_add_test (
  "plm-bsp-mse-k" 
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "${PLM_BUILD_TESTING_DIR}/plm-bsp-mse-k.txt"
  )
plm_add_test (
  "plm-bsp-mse-k-stats"
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "stats;${PLM_BUILD_TESTING_DIR}/plm-bsp-mse-k-img.mha"
  )
plmtest_check_interval ("plm-bsp-mse-k-check"
  "${PLM_BUILD_TESTING_DIR}/plm-bsp-mse-k-stats.stdout.txt"
  "AVE *([-0-9.]*)"
  "${PLM_BSPLINE_TEST_LOWER_THRESH}"
  "${PLM_BSPLINE_TEST_UPPER_THRESH}"
  )
set_property (TEST plm-bsp-mse-k APPEND PROPERTY DEPENDS gauss-1)
set_property (TEST plm-bsp-mse-k APPEND PROPERTY DEPENDS gauss-2)
set_tests_properties (plm-bsp-mse-k-stats PROPERTIES 
  DEPENDS plm-bsp-mse-k)
set_tests_properties (plm-bsp-mse-k-check PROPERTIES 
  DEPENDS plm-bsp-mse-k-stats)

plm_add_test (
  "plm-bsp-mse-l" 
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "${PLM_BUILD_TESTING_DIR}/plm-bsp-mse-l.txt"
  )
plm_add_test (
  "plm-bsp-mse-l-stats"
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "stats;${PLM_BUILD_TESTING_DIR}/plm-bsp-mse-l-img.mha"
  )
plmtest_check_interval ("plm-bsp-mse-l-check"
  "${PLM_BUILD_TESTING_DIR}/plm-bsp-mse-l-stats.stdout.txt"
  "AVE *([-0-9.]*)"
  "${PLM_BSPLINE_TEST_LOWER_THRESH}"
  "${PLM_BSPLINE_TEST_UPPER_THRESH}"
  )
set_property (TEST plm-bsp-mse-l APPEND PROPERTY DEPENDS gauss-1)
set_property (TEST plm-bsp-mse-l APPEND PROPERTY DEPENDS gauss-2)
set_tests_properties (plm-bsp-mse-l-stats PROPERTIES 
  DEPENDS plm-bsp-mse-l)
set_tests_properties (plm-bsp-mse-l-check PROPERTIES 
  DEPENDS plm-bsp-mse-l-stats)

plm_add_test (
  "plm-bsp-mse-o" 
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "${PLM_BUILD_TESTING_DIR}/plm-bsp-mse-o.txt"
  )
plm_add_test (
  "plm-bsp-mse-o-stats"
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "stats;${PLM_BUILD_TESTING_DIR}/plm-bsp-mse-o-img.mha"
  )
# plmtest_check_interval ("plm-bsp-mse-o-check"
#   "${PLM_BUILD_TESTING_DIR}/plm-bsp-mse-o-stats.stdout.txt"
#   "AVE *([-0-9.]*)"
#   "${MSE_O_TEST_LOWER_THRESH}"
#   "${MSE_O_TEST_UPPER_THRESH}"
#   )
set_property (TEST plm-bsp-mse-o APPEND PROPERTY DEPENDS gauss-1)
set_property (TEST plm-bsp-mse-o APPEND PROPERTY DEPENDS gauss-2)
set_tests_properties (plm-bsp-mse-o-stats PROPERTIES 
  DEPENDS plm-bsp-mse-o)
# set_tests_properties (plm-bsp-mse-o-check PROPERTIES 
#   DEPENDS plm-bsp-mse-o-stats)

plm_add_test (
  "plm-bsp-mse-p" 
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "${PLM_BUILD_TESTING_DIR}/plm-bsp-mse-p.txt"
  )
plm_add_test (
  "plm-bsp-mse-p-stats"
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "stats;${PLM_BUILD_TESTING_DIR}/plm-bsp-mse-p-img.mha"
  )
# plmtest_check_interval ("plm-bsp-mse-p-check"
#   "${PLM_BUILD_TESTING_DIR}/plm-bsp-mse-p-stats.stdout.txt"
#   "AVE *([-0-9.]*)"
#   "${MSE_PQR_TEST_LOWER_THRESH}"
#   "${MSE_PQR_TEST_UPPER_THRESH}"
#   )
set_property (TEST plm-bsp-mse-p APPEND PROPERTY DEPENDS gauss-1)
set_property (TEST plm-bsp-mse-p APPEND PROPERTY DEPENDS gauss-2)
set_tests_properties (plm-bsp-mse-p-stats PROPERTIES 
  DEPENDS plm-bsp-mse-p)
# set_tests_properties (plm-bsp-mse-p-check PROPERTIES 
#   DEPENDS plm-bsp-mse-p-stats)

plm_add_test (
  "plm-bsp-mse-q" 
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "${PLM_BUILD_TESTING_DIR}/plm-bsp-mse-q.txt"
  )
plm_add_test (
  "plm-bsp-mse-q-stats"
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "stats;${PLM_BUILD_TESTING_DIR}/plm-bsp-mse-q-img.mha"
  )
# plmtest_check_interval ("plm-bsp-mse-q-check"
#   "${PLM_BUILD_TESTING_DIR}/plm-bsp-mse-q-stats.stdout.txt"
#   "AVE *([-0-9.]*)"
#   "${MSE_PQR_TEST_LOWER_THRESH}"
#   "${MSE_PQR_TEST_UPPER_THRESH}"
#   )
set_property (TEST plm-bsp-mse-q APPEND PROPERTY DEPENDS gauss-1)
set_property (TEST plm-bsp-mse-q APPEND PROPERTY DEPENDS gauss-2)
set_tests_properties (plm-bsp-mse-q-stats PROPERTIES 
  DEPENDS plm-bsp-mse-q)
# set_tests_properties (plm-bsp-mse-q-check PROPERTIES 
#   DEPENDS plm-bsp-mse-q-stats)

plm_add_test (
  "plm-bsp-mse-r" 
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "${PLM_BUILD_TESTING_DIR}/plm-bsp-mse-r.txt"
  )
plm_add_test (
  "plm-bsp-mse-r-stats"
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "stats;${PLM_BUILD_TESTING_DIR}/plm-bsp-mse-r-img.mha"
  )
# plmtest_check_interval ("plm-bsp-mse-r-check"
#   "${PLM_BUILD_TESTING_DIR}/plm-bsp-mse-r-stats.stdout.txt"
#   "AVE *([-0-9.]*)"
#   "${MSE_PQR_TEST_LOWER_THRESH}"
#   "${MSE_PQR_TEST_UPPER_THRESH}"
#   )
set_property (TEST plm-bsp-mse-r APPEND PROPERTY DEPENDS gauss-1)
set_property (TEST plm-bsp-mse-r APPEND PROPERTY DEPENDS gauss-2)
set_tests_properties (plm-bsp-mse-r-stats PROPERTIES 
  DEPENDS plm-bsp-mse-r)
# set_tests_properties (plm-bsp-mse-r-check PROPERTIES 
#   DEPENDS plm-bsp-mse-r-stats)


## This test (and bsp-mi-k) fails on windows with 2008 compiler.
plm_add_test (
  "plm-bsp-mi-c" 
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "${PLM_BUILD_TESTING_DIR}/plm-bsp-mi-c.txt"
  )
plm_add_test (
  "plm-bsp-mi-c-stats"
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "stats;${PLM_BUILD_TESTING_DIR}/plm-bsp-mi-c-img.mha"
  )
plmtest_check_interval ("plm-bsp-mi-c-check"
  "${PLM_BUILD_TESTING_DIR}/plm-bsp-mi-c-stats.stdout.txt"
  "AVE *([-0-9.]*)"
  "-114.0"
  "-113.0"
  )
set_property (TEST plm-bsp-mi-c APPEND PROPERTY DEPENDS gauss-1)
set_property (TEST plm-bsp-mi-c APPEND PROPERTY DEPENDS gauss-3)
set_tests_properties (plm-bsp-mi-c-stats PROPERTIES 
  DEPENDS plm-bsp-mi-c)
set_tests_properties (plm-bsp-mi-c-check PROPERTIES 
  DEPENDS plm-bsp-mi-c-stats)

plm_add_test (
  "plm-bsp-mi-c-2" 
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "${PLM_BUILD_TESTING_DIR}/plm-bsp-mi-c-2.txt"
  )
plm_add_test (
  "plm-bsp-mi-c-2-stats"
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "stats;${PLM_BUILD_TESTING_DIR}/plm-bsp-mi-c-2-img.mha"
  )
plmtest_check_interval ("plm-bsp-mi-c-2-check"
  "${PLM_BUILD_TESTING_DIR}/plm-bsp-mi-c-2-stats.stdout.txt"
  "AVE *([-0-9.]*)"
  "-129.5"
  "-128.5"
  )
set_property (TEST plm-bsp-mi-c-2 APPEND PROPERTY DEPENDS gauss-1)
set_property (TEST plm-bsp-mi-c-2 APPEND PROPERTY DEPENDS gauss-3)
set_tests_properties (plm-bsp-mi-c-2-stats PROPERTIES 
  DEPENDS plm-bsp-mi-c-2)
set_tests_properties (plm-bsp-mi-c-2-check PROPERTIES 
  DEPENDS plm-bsp-mi-c-2-stats)

plm_add_test (
  "plm-bsp-mi-k" 
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "${PLM_BUILD_TESTING_DIR}/plm-bsp-mi-k.txt"
  )
plm_add_test (
  "plm-bsp-mi-k-stats"
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "stats;${PLM_BUILD_TESTING_DIR}/plm-bsp-mi-k-img.mha"
  )
plmtest_check_interval ("plm-bsp-mi-k-check"
  "${PLM_BUILD_TESTING_DIR}/plm-bsp-mi-k-stats.stdout.txt"
  "AVE *([-0-9.]*)"
  "-114.0"
  "-113.0"
  )
set_property (TEST plm-bsp-mi-k APPEND PROPERTY DEPENDS gauss-1)
set_property (TEST plm-bsp-mi-k APPEND PROPERTY DEPENDS gauss-3)
set_tests_properties (plm-bsp-mi-k-stats PROPERTIES 
  DEPENDS plm-bsp-mi-k)
set_tests_properties (plm-bsp-mi-k-check PROPERTIES 
  DEPENDS plm-bsp-mi-k-stats)

plm_add_test (
  "plm-bsp-gm-k" 
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "${PLM_BUILD_TESTING_DIR}/plm-bsp-gm-k.txt"
  )
plm_add_test (
  "plm-bsp-gm-k-stats"
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "stats;${PLM_BUILD_TESTING_DIR}/plm-bsp-gm-k-img.mha"
  )
plmtest_check_interval ("plm-bsp-gm-k-check"
  "${PLM_BUILD_TESTING_DIR}/plm-bsp-gm-k-stats.stdout.txt"
  "AVE *([-0-9.]*)"
  "-122.5"
  "-121.5"
  )
set_property (TEST plm-bsp-gm-k APPEND PROPERTY DEPENDS gauss-1)
set_property (TEST plm-bsp-gm-k APPEND PROPERTY DEPENDS gauss-3)
set_tests_properties (plm-bsp-gm-k-stats PROPERTIES 
  DEPENDS plm-bsp-gm-k)
set_tests_properties (plm-bsp-gm-k-check PROPERTIES 
  DEPENDS plm-bsp-gm-k-stats)

# plm_add_test (
#   "plm-bsp-dmap-k" 
#   ${PLM_PLASTIMATCH_PATH}/plastimatch
#   "${PLM_BUILD_TESTING_DIR}/plm-bsp-dmap-k.txt"
#   )
# plm_add_test (
#   "plm-bsp-dmap-k-stats"
#   ${PLM_PLASTIMATCH_PATH}/plastimatch
#   "stats;${PLM_BUILD_TESTING_DIR}/plm-bsp-dmap-k-img.mha"
#   )
# plmtest_check_interval ("plm-bsp-dmap-k-check"
#   "${PLM_BUILD_TESTING_DIR}/plm-bsp-dmap-k-stats.stdout.txt"
#   "AVE *([-0-9.]*)"
#   "-122.5"
#   "-121.5"
#   )
# set_property (TEST plm-bsp-dmap-k APPEND PROPERTY DEPENDS rect-4)
# set_property (TEST plm-bsp-dmap-k APPEND PROPERTY DEPENDS rect-8)
# set_tests_properties (plm-bsp-dmap-k-stats PROPERTIES 
#   DEPENDS plm-bsp-dmap-k)
# set_tests_properties (plm-bsp-dmap-k-check PROPERTIES 
#   DEPENDS plm-bsp-dmap-k-stats)

plm_add_test (
  "plm-bsp-sm-multi-a" 
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "${PLM_BUILD_TESTING_DIR}/plm-bsp-sm-multi-a.txt"
  )
plm_add_test (
  "plm-bsp-sm-multi-a-stats"
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "stats;${PLM_BUILD_TESTING_DIR}/plm-bsp-sm-multi-a-img.mha"
  )
# plmtest_check_interval ("plm-bsp-sm-multi-a-check"
#   "${PLM_BUILD_TESTING_DIR}/plm-bsp-sm-multi-a-stats.stdout.txt"
#   "AVE *([-0-9.]*)"
#   "-122.5"
#   "-121.5"
#   )
set_property (TEST plm-bsp-sm-multi-a APPEND PROPERTY DEPENDS gauss-1)
set_property (TEST plm-bsp-sm-multi-a APPEND PROPERTY DEPENDS gauss-2)
set_tests_properties (plm-bsp-sm-multi-a-stats PROPERTIES 
  DEPENDS plm-bsp-sm-multi-a)
# set_tests_properties (plm-bsp-sm-multi-a-check PROPERTIES 
#   DEPENDS plm-bsp-sm-multi-a-stats)

plm_add_test (
  "plm-bsp-openmp" 
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "${PLM_TESTING_DATA_DIR}/plm-bsp-openmp.txt"
  )
plm_add_test (
  "plm-bsp-openmp-stats"
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "stats;${PLM_BUILD_TESTING_DIR}/plm-bsp-openmp-img.mha"
  )
plmtest_check_interval ("plm-bsp-openmp-check"
  "${PLM_BUILD_TESTING_DIR}/plm-bsp-openmp-stats.stdout.txt"
  "AVE *([-0-9.]*)"
  "${PLM_BSPLINE_TEST_LOWER_THRESH}"
  "${PLM_BSPLINE_TEST_UPPER_THRESH}"
  )
set_property (TEST plm-bsp-openmp APPEND PROPERTY DEPENDS gauss-1)
set_property (TEST plm-bsp-openmp APPEND PROPERTY DEPENDS gauss-2)
set_tests_properties (plm-bsp-openmp-stats PROPERTIES 
  DEPENDS plm-bsp-openmp)
set_tests_properties (plm-bsp-openmp-check PROPERTIES 
  DEPENDS plm-bsp-openmp-stats)

plm_add_test (
  "plm-bsp-cuda" 
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "${PLM_BUILD_TESTING_DIR}/plm-bsp-cuda.txt"
  )
plm_add_test (
  "plm-bsp-cuda-stats"
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "stats;${PLM_BUILD_TESTING_DIR}/plm-bsp-cuda-img.nrrd"
  )
plmtest_check_interval ("plm-bsp-cuda-check"
  "${PLM_BUILD_TESTING_DIR}/plm-bsp-cuda-stats.stdout.txt"
  "AVE *([-0-9.]*)"
  "${PLM_BSPLINE_TEST_LOWER_THRESH}"
  "${PLM_BSPLINE_TEST_UPPER_THRESH}"
  )
set_property (TEST plm-bsp-cuda APPEND PROPERTY DEPENDS gauss-1)
set_property (TEST plm-bsp-cuda APPEND PROPERTY DEPENDS gauss-2)
set_tests_properties (plm-bsp-cuda-stats PROPERTIES 
  DEPENDS plm-bsp-cuda)
set_tests_properties (plm-bsp-cuda-check PROPERTIES 
  DEPENDS plm-bsp-cuda-stats)

plm_add_test (
  "plm-bsp-resume" 
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "${PLM_BUILD_TESTING_DIR}/plm-bsp-resume.txt"
  )
plm_add_test (
  "plm-bsp-resume-stats"
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "stats;${PLM_BUILD_TESTING_DIR}/plm-bsp-resume-img.mha"
  )
# plmtest_check_interval ("plm-bsp-resume-check"
#   "${PLM_BUILD_TESTING_DIR}/plm-bsp-resume-stats.stdout.txt"
#   "AVE *([-0-9.]*)"
#   "${PLM_BSPLINE_TEST_LOWER_THRESH}"
#   "${PLM_BSPLINE_TEST_UPPER_THRESH}"
#   )
set_property (TEST plm-bsp-resume APPEND PROPERTY DEPENDS gauss-1)
set_property (TEST plm-bsp-resume APPEND PROPERTY DEPENDS gauss-2)
set_tests_properties (plm-bsp-resume-stats PROPERTIES 
  DEPENDS plm-bsp-resume)
# set_tests_properties (plm-bsp-resume-check PROPERTIES 
#   DEPENDS plm-bsp-resume-stats)

plm_add_test (
  "plm-bsp-logfile" 
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "${PLM_BUILD_TESTING_DIR}/plm-bsp-logfile.txt"
  )
plmtest_check_interval ("plm-bsp-logfile-check"
  "${PLM_BUILD_TESTING_DIR}/plm-bsp-logfile-logfile.txt"
  "\\\\[.*,  5] MSE *([-0-9.]*)"
  "281.5"
  "282.5"
  )
set_property (TEST plm-bsp-logfile APPEND PROPERTY DEPENDS gauss-1)
set_property (TEST plm-bsp-logfile APPEND PROPERTY DEPENDS gauss-2)
set_tests_properties (plm-bsp-logfile-check PROPERTIES 
  DEPENDS plm-bsp-logfile)

plm_add_test (
  "plm-bsp-ushort"
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "${PLM_TESTING_DATA_DIR}/plm-bsp-ushort.txt"
  )
plm_add_test (
  "plm-bsp-ushort-stats"
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "stats;${PLM_BUILD_TESTING_DIR}/plm-bsp-ushort-img.mha"
  )
plmtest_check_interval ("plm-bsp-ushort-check"
  "${PLM_BUILD_TESTING_DIR}/plm-bsp-ushort-stats.stdout.txt"
  "AVE *([-0-9.]*)"
  "106.6"
  "107.6"
  )
set_tests_properties (plm-bsp-ushort PROPERTIES 
  DEPENDS "gauss-ushort-1;gauss-ushort-2")
set_property (TEST plm-bsp-ushort 
  APPEND PROPERTY DEPENDS gauss-ushort-1)
set_property (TEST plm-bsp-ushort 
  APPEND PROPERTY DEPENDS gauss-ushort-2)
set_tests_properties (plm-bsp-ushort-stats PROPERTIES 
  DEPENDS plm-bsp-ushort)
set_tests_properties (plm-bsp-ushort-check PROPERTIES 
  DEPENDS plm-bsp-ushort-stats)

plm_add_test (
  "plm-bsp-double"
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "${PLM_BUILD_TESTING_DIR}/plm-bsp-double.txt"
  )
plm_add_test (
  "plm-bsp-double-stats"
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "stats;${PLM_BUILD_TESTING_DIR}/plm-bsp-double-img.mha"
  )
plmtest_check_interval ("plm-bsp-double-check"
  "${PLM_BUILD_TESTING_DIR}/plm-bsp-double-stats.stdout.txt"
  "AVE *([-0-9.]*)"
  "107.6"
  "108.6"
  )
set_tests_properties (plm-bsp-double PROPERTIES 
  DEPENDS "gauss-double-1;gauss-double-2")
set_tests_properties (plm-bsp-double-stats PROPERTIES 
  DEPENDS plm-bsp-double)
set_tests_properties (plm-bsp-double-check PROPERTIES 
  DEPENDS plm-bsp-double-stats)

plm_add_test (
  "plm-bsp-itk-output"
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "${PLM_TESTING_DATA_DIR}/plm-bsp-itk-output.txt"
  )
set_property (TEST plm-bsp-itk-output APPEND PROPERTY DEPENDS gauss-1)
set_property (TEST plm-bsp-itk-output APPEND PROPERTY DEPENDS gauss-2)

plm_add_test (
  "plm-bsp-char-output"
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "${PLM_TESTING_DATA_DIR}/plm-bsp-char-output.txt"
  )
plm_add_test (
  "plm-bsp-char-output-stats"
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "stats;${PLM_BUILD_TESTING_DIR}/plm-bsp-char-output.mha"
  )
plmtest_check_interval (
  "plm-bsp-char-output-check"
  "${PLM_BUILD_TESTING_DIR}/plm-bsp-char-output-stats.stdout.txt"
  "MIN *([-0-9.]*)"
  "-128.1"
  "-127.9"
  )
set_tests_properties (plm-bsp-char-output PROPERTIES 
  DEPENDS "rect-2;rect-3")
set_tests_properties (plm-bsp-char-output-stats PROPERTIES 
  DEPENDS plm-bsp-char-output)
set_tests_properties (plm-bsp-char-output-check PROPERTIES 
  DEPENDS plm-bsp-char-output-stats)

## -------------------------------------------------------------------------
## plastimatch register (group 3)
##   register-bsp-rect
##   register-bsp-regularize-none
##   register-bsp-regularize-analytic
##   register-bsp-regularize-numeric
## -------------------------------------------------------------------------
plm_add_test (
  "plm-bsp-rect"
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "${PLM_BUILD_TESTING_DIR}/plm-bsp-rect.txt"
  )
set_tests_properties (plm-bsp-rect PROPERTIES DEPENDS "rect-2;rect-3")

plm_add_test (
  "plm-bsp-regularize-none" 
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "${PLM_BUILD_TESTING_DIR}/plm-bsp-regularize-none.txt"
  )
plm_add_test (
  "plm-bsp-regularize-none-stats"
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "stats;${PLM_BUILD_TESTING_DIR}/plm-bsp-regularize-none-vf.mha"
  )
plmtest_check_interval (
  "plm-bsp-regularize-none-check"
  "${PLM_BUILD_TESTING_DIR}/plm-bsp-regularize-none-stats.stdout.txt"
  "MINJAC *([-0-9.]*)"
  "0.31"
  "0.32"
  )
set_tests_properties (plm-bsp-regularize-none PROPERTIES 
  DEPENDS "rect-3;sphere-2")
set_tests_properties (plm-bsp-regularize-none-stats PROPERTIES 
  DEPENDS plm-bsp-regularize-none)
set_tests_properties (plm-bsp-regularize-none-check PROPERTIES 
  DEPENDS plm-bsp-regularize-none-stats)

plm_add_test (
  "plm-bsp-regularize-analytic" 
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "${PLM_BUILD_TESTING_DIR}/plm-bsp-regularize-analytic.txt"
  )
plm_add_test (
  "plm-bsp-regularize-analytic-stats"
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "stats;${PLM_BUILD_TESTING_DIR}/plm-bsp-regularize-analytic-vf.mha"
  )
plmtest_check_interval (
  "plm-bsp-regularize-analytic-check"
  "${PLM_BUILD_TESTING_DIR}/plm-bsp-regularize-analytic-stats.stdout.txt"
  "MINJAC *([-0-9.]*)"
  "0.415"
  "0.425"
  )
set_tests_properties (plm-bsp-regularize-analytic PROPERTIES 
  DEPENDS "rect-3;sphere-2")
set_tests_properties (plm-bsp-regularize-analytic-stats PROPERTIES 
  DEPENDS plm-bsp-regularize-analytic)
set_tests_properties (plm-bsp-regularize-analytic-check PROPERTIES 
  DEPENDS plm-bsp-regularize-analytic-stats)

plm_add_test (
  "plm-bsp-regularize-numeric" 
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "${PLM_BUILD_TESTING_DIR}/plm-bsp-regularize-numeric.txt"
  )
plm_add_test (
  "plm-bsp-regularize-numeric-stats"
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "stats;${PLM_BUILD_TESTING_DIR}/plm-bsp-regularize-numeric-vf.mha"
  )
plmtest_check_interval (
  "plm-bsp-regularize-numeric-check"
  "${PLM_BUILD_TESTING_DIR}/plm-bsp-regularize-numeric-stats.stdout.txt"
  "MINJAC *([-0-9.]*)"
  "0.440"
  "0.445"
  )
set_tests_properties (plm-bsp-regularize-numeric PROPERTIES 
  DEPENDS "rect-3;sphere-2")
set_tests_properties (plm-bsp-regularize-numeric-stats PROPERTIES 
  DEPENDS plm-bsp-regularize-numeric)
set_tests_properties (plm-bsp-regularize-numeric-check PROPERTIES 
  DEPENDS plm-bsp-regularize-numeric-stats)

## -------------------------------------------------------------------------
## plastimatch register (group 4)
##   plm-bsp-landmark-a
##   plm-bsp-landmark-b
##   plm-bsp-landmark-c         Same as "b", but landmarks in stage
##   plm-bsp-landmark-d         Same as "b", but landmarks within file
##   plm-bsp-landmark-e         Same as "b", but txt instead of fcsv
## -------------------------------------------------------------------------
plm_add_test (
  "plm-bsp-landmark-a"
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "${PLM_BUILD_TESTING_DIR}/plm-bsp-landmark-a.txt"
  )
set_tests_properties (plm-bsp-landmark-a PROPERTIES DEPENDS "rect-2;sphere-2")

plm_add_test (
  "plm-bsp-landmark-b"
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "${PLM_BUILD_TESTING_DIR}/plm-bsp-landmark-b.txt"
  )
plm_add_test (
  "plm-bsp-landmark-b-stats"
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "stats;${PLM_BUILD_TESTING_DIR}/plm-bsp-landmark-b-img.mha"
  )
plmtest_check_interval (
  "plm-bsp-landmark-b-check"
  "${PLM_BUILD_TESTING_DIR}/plm-bsp-landmark-b-stats.stdout.txt"
  "AVE *([-0-9.]*)"
  "-991.5"
  "-991.0"
  )
set_tests_properties (plm-bsp-landmark-b PROPERTIES DEPENDS "rect-15;rect-16")
set_tests_properties (plm-bsp-landmark-b-stats PROPERTIES 
    DEPENDS plm-bsp-landmark-b)
set_tests_properties (plm-bsp-landmark-b-check PROPERTIES 
    DEPENDS plm-bsp-landmark-b-stats)

plm_add_test (
  "plm-bsp-landmark-c"
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "${PLM_BUILD_TESTING_DIR}/plm-bsp-landmark-c.txt"
  )
plm_add_test (
  "plm-bsp-landmark-c-stats"
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "stats;${PLM_BUILD_TESTING_DIR}/plm-bsp-landmark-c-img.mha"
  )
plmtest_check_interval (
  "plm-bsp-landmark-c-check"
  "${PLM_BUILD_TESTING_DIR}/plm-bsp-landmark-c-stats.stdout.txt"
  "AVE *([-0-9.]*)"
  "-991.5"
  "-991.0"
  )
set_tests_properties (plm-bsp-landmark-c PROPERTIES DEPENDS "rect-15;rect-16")
set_tests_properties (plm-bsp-landmark-c-stats PROPERTIES 
    DEPENDS plm-bsp-landmark-c)
set_tests_properties (plm-bsp-landmark-c-check PROPERTIES 
    DEPENDS plm-bsp-landmark-c-stats)

plm_add_test (
  "plm-bsp-landmark-d"
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "${PLM_BUILD_TESTING_DIR}/plm-bsp-landmark-d.txt"
  )
plm_add_test (
  "plm-bsp-landmark-d-stats"
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "stats;${PLM_BUILD_TESTING_DIR}/plm-bsp-landmark-d-img.mha"
  )
plmtest_check_interval (
  "plm-bsp-landmark-d-check"
  "${PLM_BUILD_TESTING_DIR}/plm-bsp-landmark-d-stats.stdout.txt"
  "AVE *([-0-9.]*)"
  "-991.5"
  "-991.0"
  )
set_tests_properties (plm-bsp-landmark-d PROPERTIES DEPENDS "rect-15;rect-16")
set_tests_properties (plm-bsp-landmark-d-stats PROPERTIES 
    DEPENDS plm-bsp-landmark-d)
set_tests_properties (plm-bsp-landmark-d-check PROPERTIES 
    DEPENDS plm-bsp-landmark-d-stats)

plm_add_test (
  "plm-bsp-landmark-e"
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "${PLM_BUILD_TESTING_DIR}/plm-bsp-landmark-e.txt"
  )
plm_add_test (
  "plm-bsp-landmark-e-stats"
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "stats;${PLM_BUILD_TESTING_DIR}/plm-bsp-landmark-e-img.mha"
  )
plmtest_check_interval (
  "plm-bsp-landmark-e-check"
  "${PLM_BUILD_TESTING_DIR}/plm-bsp-landmark-e-stats.stdout.txt"
  "AVE *([-0-9.]*)"
  "-991.5"
  "-991.0"
  )
set_tests_properties (plm-bsp-landmark-e PROPERTIES DEPENDS "rect-15;rect-16")
set_tests_properties (plm-bsp-landmark-e-stats PROPERTIES 
    DEPENDS plm-bsp-landmark-e)
set_tests_properties (plm-bsp-landmark-e-check PROPERTIES 
    DEPENDS plm-bsp-landmark-e-stats)

## -------------------------------------------------------------------------
## plastimatch register (group 5)
##   plm-bsp-dcos-a       fixed=standard moving=rotated, flavor=g
##   plm-bsp-dcos-b       fixed=rotated moving=standard, flavor=g
##   plm-bsp-dcos-c       fixed=standard moving=rotated, flavor=c
##   plm-bsp-dcos-d       fixed=rotated moving=standard, flavor=c
##   plm-bsp-dcos-e       fixed=standard moving=rotated, flavor=h
##   plm-bsp-dcos-f       fixed=rotated moving=standard, flavor=h
## -------------------------------------------------------------------------
plm_add_test (
  "plm-bsp-dcos-a"
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "${PLM_BUILD_TESTING_DIR}/plm-bsp-dcos-a.txt"
  )
plm_add_test (
  "plm-bsp-dcos-a-stats"
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "stats;${PLM_BUILD_TESTING_DIR}/plm-bsp-dcos-a-img.nrrd"
  )
plmtest_check_interval (
  "plm-bsp-dcos-a-check"
  "${PLM_BUILD_TESTING_DIR}/plm-bsp-dcos-a-stats.stdout.txt"
  "AVE *([-0-9.]*)"
  "-816"
  "-815"
  )
set_tests_properties (plm-bsp-dcos-a PROPERTIES 
  DEPENDS "rect-2;rect-5")
set_tests_properties (plm-bsp-dcos-a-stats PROPERTIES 
  DEPENDS plm-bsp-dcos-a)
set_tests_properties (plm-bsp-dcos-a-check PROPERTIES 
  DEPENDS plm-bsp-dcos-a-stats)

plm_add_test (
  "plm-bsp-dcos-b"
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "${PLM_BUILD_TESTING_DIR}/plm-bsp-dcos-b.txt"
  )
plm_add_test (
  "plm-bsp-dcos-b-stats"
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "stats;${PLM_BUILD_TESTING_DIR}/plm-bsp-dcos-b-img.nrrd"
  )
plmtest_check_interval (
  "plm-bsp-dcos-b-check"
  "${PLM_BUILD_TESTING_DIR}/plm-bsp-dcos-b-stats.stdout.txt"
  "AVE *([-0-9.]*)"
  "-796.8"
  "-795.8"
  )
set_tests_properties (plm-bsp-dcos-b PROPERTIES 
  DEPENDS "rect-2;rect-5")
set_tests_properties (plm-bsp-dcos-b-stats PROPERTIES 
  DEPENDS plm-bsp-dcos-b)
set_tests_properties (plm-bsp-dcos-b-check PROPERTIES 
  DEPENDS plm-bsp-dcos-b-stats)

plm_add_test (
  "plm-bsp-dcos-c"
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "${PLM_BUILD_TESTING_DIR}/plm-bsp-dcos-c.txt"
  )
plm_add_test (
  "plm-bsp-dcos-c-stats"
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "stats;${PLM_BUILD_TESTING_DIR}/plm-bsp-dcos-c-img.nrrd"
  )
plmtest_check_interval (
  "plm-bsp-dcos-c-check"
  "${PLM_BUILD_TESTING_DIR}/plm-bsp-dcos-c-stats.stdout.txt"
  "AVE *([-0-9.]*)"
  "-816"
  "-815"
  )
set_tests_properties (plm-bsp-dcos-c PROPERTIES 
  DEPENDS "rect-2;rect-5")
set_tests_properties (plm-bsp-dcos-c-stats PROPERTIES 
  DEPENDS plm-bsp-dcos-c)
set_tests_properties (plm-bsp-dcos-c-check PROPERTIES 
  DEPENDS plm-bsp-dcos-c-stats)

plm_add_test (
  "plm-bsp-dcos-d"
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "${PLM_BUILD_TESTING_DIR}/plm-bsp-dcos-d.txt"
  )
plm_add_test (
  "plm-bsp-dcos-d-stats"
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "stats;${PLM_BUILD_TESTING_DIR}/plm-bsp-dcos-d-img.nrrd"
  )
plmtest_check_interval (
  "plm-bsp-dcos-d-check"
  "${PLM_BUILD_TESTING_DIR}/plm-bsp-dcos-d-stats.stdout.txt"
  "AVE *([-0-9.]*)"
  "-796.8"
  "-795.8"
  )
set_tests_properties (plm-bsp-dcos-d PROPERTIES 
  DEPENDS "rect-2;rect-5")
set_tests_properties (plm-bsp-dcos-d-stats PROPERTIES 
  DEPENDS plm-bsp-dcos-d)
set_tests_properties (plm-bsp-dcos-d-check PROPERTIES 
  DEPENDS plm-bsp-dcos-d-stats)

plm_add_test (
  "plm-bsp-dcos-e"
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "${PLM_BUILD_TESTING_DIR}/plm-bsp-dcos-e.txt"
  )
plm_add_test (
  "plm-bsp-dcos-e-stats"
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "stats;${PLM_BUILD_TESTING_DIR}/plm-bsp-dcos-e-img.nrrd"
  )
plmtest_check_interval (
  "plm-bsp-dcos-e-check"
  "${PLM_BUILD_TESTING_DIR}/plm-bsp-dcos-e-stats.stdout.txt"
  "AVE *([-0-9.]*)"
  "-816"
  "-815"
  )
set_tests_properties (plm-bsp-dcos-e PROPERTIES 
  DEPENDS "rect-2;rect-5")
set_tests_properties (plm-bsp-dcos-e-stats PROPERTIES 
  DEPENDS plm-bsp-dcos-e)
set_tests_properties (plm-bsp-dcos-e-check PROPERTIES 
  DEPENDS plm-bsp-dcos-e-stats)

plm_add_test (
  "plm-bsp-dcos-f"
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "${PLM_BUILD_TESTING_DIR}/plm-bsp-dcos-f.txt"
  )
plm_add_test (
  "plm-bsp-dcos-f-stats"
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "stats;${PLM_BUILD_TESTING_DIR}/plm-bsp-dcos-f-img.nrrd"
  )
plmtest_check_interval (
  "plm-bsp-dcos-f-check"
  "${PLM_BUILD_TESTING_DIR}/plm-bsp-dcos-f-stats.stdout.txt"
  "AVE *([-0-9.]*)"
  "-796.8"
  "-795.8"
  )
set_tests_properties (plm-bsp-dcos-f PROPERTIES 
  DEPENDS "rect-2;rect-5")
set_tests_properties (plm-bsp-dcos-f-stats PROPERTIES 
  DEPENDS plm-bsp-dcos-f)
set_tests_properties (plm-bsp-dcos-f-check PROPERTIES 
  DEPENDS plm-bsp-dcos-f-stats)

## -------------------------------------------------------------------------
## plastimatch register (group 6)
##   plm-reg-multi-a      versor, then demons
##   plm-reg-multi-b      two b-spline stages
## -------------------------------------------------------------------------
plm_add_test (
  "plm-reg-multi-a"
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "${PLM_BUILD_TESTING_DIR}/plm-reg-multi-a.txt"
  )
plm_add_test (
  "plm-reg-multi-a-stats"
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "stats;${PLM_BUILD_TESTING_DIR}/plm-reg-multi-a-vf.nrrd"
  )
plmtest_check_interval (
  "plm-reg-multi-a-check"
  "${PLM_BUILD_TESTING_DIR}/plm-reg-multi-a-stats.stdout.txt"
  "Mean: *([-0-9.]*)"
  "-22"
  "-18"
  )
set_tests_properties (plm-reg-multi-a PROPERTIES 
  DEPENDS "rect-2;sphere-2")
set_tests_properties (plm-reg-multi-a-stats PROPERTIES 
  DEPENDS plm-reg-multi-a)
set_tests_properties (plm-reg-multi-a-check PROPERTIES 
  DEPENDS plm-reg-multi-a-stats)

plm_add_test (
  "plm-reg-multi-b"
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "${PLM_BUILD_TESTING_DIR}/plm-reg-multi-b.txt"
  )
plm_add_test (
  "plm-reg-multi-b-stats"
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "stats;${PLM_BUILD_TESTING_DIR}/plm-reg-multi-b-img.nrrd"
  )
plmtest_check_interval (
  "plm-reg-multi-b-check"
  "${PLM_BUILD_TESTING_DIR}/plm-reg-multi-b-stats.stdout.txt"
  "AVE *([-0-9.]*)"
  "-987"
  "-984"
  )
set_tests_properties (plm-reg-multi-b PROPERTIES 
  DEPENDS "rect-2;sphere-2")
set_tests_properties (plm-reg-multi-b-stats PROPERTIES 
  DEPENDS plm-reg-multi-b)
set_tests_properties (plm-reg-multi-b-check PROPERTIES 
  DEPENDS plm-reg-multi-b-stats)

## -------------------------------------------------------------------------
## plastimatch register (group 7) - check default value
##   plm-reg-dv-itk-translation
## -------------------------------------------------------------------------
plm_add_test (
  "plm-reg-dv-itk-translation"
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "${PLM_BUILD_TESTING_DIR}/plm-reg-dv-itk-translation.txt"
  )
plm_add_test (
  "plm-reg-dv-itk-translation-stats"
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "stats;${PLM_BUILD_TESTING_DIR}/plm-reg-dv-itk-translation-img.nrrd"
  )
plmtest_check_interval ("plm-reg-dv-itk-translation-check"
  "${PLM_BUILD_TESTING_DIR}/plm-reg-dv-itk-translation-stats.stdout.txt"
  "AVE *([-0-9.]*)"
  "-467.1"
  "-366.9"
  )
set_property (TEST plm-reg-dv-itk-translation APPEND PROPERTY DEPENDS gauss-1)
set_property (TEST plm-reg-dv-itk-translation APPEND PROPERTY DEPENDS gauss-2)
set_tests_properties (plm-reg-dv-itk-translation-stats PROPERTIES 
  DEPENDS plm-reg-dv-itk-translation)
set_tests_properties (plm-reg-dv-itk-translation-check PROPERTIES 
  DEPENDS plm-reg-dv-itk-translation-stats)

## -------------------------------------------------------------------------
## plastimatch register (group 8)
##   plm-reg-roi-a         bspline + mi
##   plm-reg-roi-b         itk 
##   plm-reg-roi-c         b-spline, upper rectangle
##   plm-reg-roi-d         b-spline, lower rectangle
##   plm-reg-roi-e         itk (no roi), b-spline (roi)
##   plm-reg-stiffness-a   b-spline, rect vs sphere
## -------------------------------------------------------------------------
plm_add_test (
  "plm-reg-roi-a"
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "${PLM_BUILD_TESTING_DIR}/plm-reg-roi-a.txt"
  )
set_tests_properties (plm-reg-roi-a PROPERTIES DEPENDS "rect-10;rect-10-mask-1;rect-11;rect-11-mask")

plm_add_test (
  "plm-reg-roi-b"
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "${PLM_BUILD_TESTING_DIR}/plm-reg-roi-b.txt"
  )
set_tests_properties (plm-reg-roi-b PROPERTIES DEPENDS "rectarr-01;rectarr-02;rectarr-m-01")

plm_add_test (
  "plm-reg-roi-c"
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "${PLM_BUILD_TESTING_DIR}/plm-reg-roi-c.txt"
  )
set_tests_properties (plm-reg-roi-c PROPERTIES DEPENDS "rectarr-01;rectarr-02;rectarr-m-01")

plm_add_test (
  "plm-reg-roi-d"
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "${PLM_BUILD_TESTING_DIR}/plm-reg-roi-d.txt"
  )
set_tests_properties (plm-reg-roi-d PROPERTIES DEPENDS "rectarr-01;rectarr-02;rectarr-m-02")

plm_add_test (
  "plm-reg-roi-e"
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "${PLM_BUILD_TESTING_DIR}/plm-reg-roi-e.txt"
  )
set_tests_properties (plm-reg-roi-e PROPERTIES DEPENDS "rectarr-01;rectarr-02;rectarr-m-02")

plm_add_test (
    "plm-reg-stiffness-a"
    ${PLM_PLASTIMATCH_PATH}/plastimatch
    "register;${PLM_BUILD_TESTING_DIR}/plm-reg-stiffness-a.txt"
    )
set_tests_properties (plm-reg-stiffness-a
    PROPERTIES DEPENDS "rect-19;roi-1;sphere-4")

## -------------------------------------------------------------------------
## plastimatch register (group 9)
##   plm-reg-process-a
## -------------------------------------------------------------------------
plm_add_test (
  "plm-reg-process-a"
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "${PLM_BUILD_TESTING_DIR}/plm-reg-process-a.txt"
  )
plm_add_test (
  "plm-reg-process-a-stats"
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "stats;${PLM_BUILD_TESTING_DIR}/plm-reg-process-a.mha"
  )
plmtest_check_interval ("plm-reg-process-a-check"
  "${PLM_BUILD_TESTING_DIR}/plm-reg-process-a-stats.stdout.txt"
  "AVE *([-0-9.]*)"
  "-491.0"
  "-490.0"
  )
set_property (TEST plm-reg-process-a APPEND PROPERTY DEPENDS gauss-1)
set_tests_properties (plm-reg-process-a-stats PROPERTIES 
  DEPENDS plm-reg-process-a)
set_tests_properties (plm-reg-process-a-check PROPERTIES 
  DEPENDS plm-reg-process-a-stats)

## -------------------------------------------------------------------------
## plastimatch register (group 10)
##   plm-reg-trans-a     Translation with grid search (mse, legacy form)
##   plm-reg-trans-b     Translation with grid search (mse, new form)
##   plm-reg-trans-mi-a  Translation with grid search (mutual information)
## -------------------------------------------------------------------------
plm_add_test (
  "plm-reg-trans-a"
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "${PLM_BUILD_TESTING_DIR}/plm-reg-trans-a.txt"
  )
plm_add_test (
  "plm-reg-trans-a-stats"
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "stats;${PLM_BUILD_TESTING_DIR}/plm-reg-trans-a.mha"
  )
plmtest_check_interval ("plm-reg-trans-a-check"
  "${PLM_BUILD_TESTING_DIR}/plm-reg-trans-a-stats.stdout.txt"
  "AVE *([-0-9.]*)"
  "-661.75"
  "-661.65"
  )
set_property (TEST plm-reg-trans-a APPEND PROPERTY DEPENDS gauss-1)
set_tests_properties (plm-reg-trans-a-stats PROPERTIES 
  DEPENDS plm-reg-trans-a)
set_tests_properties (plm-reg-trans-a-check PROPERTIES 
  DEPENDS plm-reg-trans-a-stats)

plm_add_test (
  "plm-reg-trans-b"
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "${PLM_BUILD_TESTING_DIR}/plm-reg-trans-b.txt"
  )
plm_add_test (
  "plm-reg-trans-b-stats"
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "stats;${PLM_BUILD_TESTING_DIR}/plm-reg-trans-b.mha"
  )
plmtest_check_interval ("plm-reg-trans-b-check"
  "${PLM_BUILD_TESTING_DIR}/plm-reg-trans-b-stats.stdout.txt"
  "AVE *([-0-9.]*)"
  "-661.75"
  "-661.65"
  )
set_property (TEST plm-reg-trans-b APPEND PROPERTY DEPENDS gauss-1)
set_tests_properties (plm-reg-trans-b-stats PROPERTIES 
  DEPENDS plm-reg-trans-b)
set_tests_properties (plm-reg-trans-b-check PROPERTIES 
  DEPENDS plm-reg-trans-b-stats)

plm_add_test (
  "plm-reg-trans-mi-a"
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "${PLM_BUILD_TESTING_DIR}/plm-reg-trans-mi-a.txt"
  )
plm_add_test (
  "plm-reg-trans-mi-a-stats"
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "stats;${PLM_BUILD_TESTING_DIR}/plm-reg-trans-mi-a.mha"
  )
plmtest_check_interval ("plm-reg-trans-mi-a-check"
  "${PLM_BUILD_TESTING_DIR}/plm-reg-trans-mi-a-stats.stdout.txt"
  "AVE *([-0-9.]*)"
  "-612.75"
  "-612.60"
  )
set_tests_properties (plm-reg-trans-mi-a PROPERTIES DEPENDS "gauss-1;gauss-2")
set_tests_properties (plm-reg-trans-mi-a-stats PROPERTIES 
  DEPENDS plm-reg-trans-mi-a)
set_tests_properties (plm-reg-trans-mi-a-check PROPERTIES 
  DEPENDS plm-reg-trans-mi-a-stats)

## -------------------------------------------------------------------------
## plastimatch register (group 11)
##   plm-reg-autores-a    Manually set sampling rate using mm
##   plm-reg-autores-b    Manually set sampling rate using pct
## -------------------------------------------------------------------------
plm_add_test (
  "plm-reg-autores-a"
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "${PLM_BUILD_TESTING_DIR}/plm-reg-autores-a.txt"
  )
plm_add_test (
  "plm-reg-autores-a-stats"
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "stats;${PLM_BUILD_TESTING_DIR}/plm-reg-autores-a.mha"
  )
plmtest_check_interval ("plm-reg-autores-a-check"
  "${PLM_BUILD_TESTING_DIR}/plm-reg-autores-a-stats.stdout.txt"
  "AVE *([-0-9.]*)"
  "-597.6"
  "-597.5"
  )
set_property (TEST plm-reg-autores-a APPEND PROPERTY DEPENDS gauss-1)
set_property (TEST plm-reg-autores-a APPEND PROPERTY DEPENDS gauss-2)
set_tests_properties (plm-reg-autores-a-stats PROPERTIES 
  DEPENDS plm-reg-autores-a)
set_tests_properties (plm-reg-autores-a-check PROPERTIES 
  DEPENDS plm-reg-autores-a-stats)

plm_add_test (
  "plm-reg-autores-b"
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "${PLM_BUILD_TESTING_DIR}/plm-reg-autores-b.txt"
  )
plm_add_test (
  "plm-reg-autores-b-stats"
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "stats;${PLM_BUILD_TESTING_DIR}/plm-reg-autores-b.mha"
  )
plmtest_check_interval ("plm-reg-autores-b-check"
  "${PLM_BUILD_TESTING_DIR}/plm-reg-autores-b-stats.stdout.txt"
  "AVE *([-0-9.]*)"
  "-597.5"
  "-597.4"
  )
set_property (TEST plm-reg-autores-b APPEND PROPERTY DEPENDS gauss-1)
set_property (TEST plm-reg-autores-b APPEND PROPERTY DEPENDS gauss-2)
set_tests_properties (plm-reg-autores-b-stats PROPERTIES 
  DEPENDS plm-reg-autores-b)
set_tests_properties (plm-reg-autores-b-check PROPERTIES 
  DEPENDS plm-reg-autores-b-stats)

## -------------------------------------------------------------------------
## plastimatch register (group 12)
##   plm-reg-gw-a         Groupwise registration
## -------------------------------------------------------------------------
# plm_add_test (
#   "plm-reg-gw-a"
#   ${PLM_PLASTIMATCH_PATH}/plastimatch
#   "${PLM_BUILD_TESTING_DIR}/plm-reg-gw-a.txt"
#   )

## -------------------------------------------------------------------------
## plastimatch register (group 13)
##   plm-reg-point-dmap-a    Map points to distance map
## -------------------------------------------------------------------------
plm_add_test (
  "plm-reg-point-dmap-a"
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "${PLM_BUILD_TESTING_DIR}/plm-reg-point-dmap-a.txt"
  )

set_tests_properties (plm-reg-point-dmap-a PROPERTIES
  DEPENDS "sphere-2;rect-3;plm-convert-prefix-fcsv;plm-dmap-b")

## -------------------------------------------------------------------------
## plastimatch compose
##   This test uses registers from gauss-1 to gauss-2 which are done above, 
##   and composes with results from an registration from gauss-2 to 
##   gauss-5.  The composed vf should be correctly align gauss-1 to gauss-5.
##   
##   plm-reg-compose    Make vf for testing composition
##   plm-compose-a           Compose translation and vector field
##   plm-compose-b           Compose vector field and vector field
##   plm-compose-c           Compose bspline and vector field
##   
##   Remark: these tests are correct, in the sense that they work as 
##   implemented.  Transformation vectors which are not defined are 
##   set to zero in plastimatch, and this causes artifacts in the composed 
##   vector field.
## -------------------------------------------------------------------------
plm_add_test (
  "plm-reg-compose" 
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "${PLM_TESTING_DATA_DIR}/plm-reg-compose.txt"
  )
set_tests_properties (plm-reg-compose PROPERTIES DEPENDS "gauss-2;gauss-5")

plm_add_test (
  "plm-compose-a" 
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "compose;${PLM_BUILD_TESTING_DIR}/plm-reg-itk-translation-xf.txt;${PLM_BUILD_TESTING_DIR}/plm-reg-compose-vf.mha;${PLM_BUILD_TESTING_DIR}/plm-compose-a-vf.mha"
  )
plm_add_test (
  "plm-compose-a-warp" 
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "warp;--input;${PLM_BUILD_TESTING_DIR}/gauss-5.mha;--xf;${PLM_BUILD_TESTING_DIR}/plm-compose-a-vf.mha;--output-img;${PLM_BUILD_TESTING_DIR}/plm-compose-a-warp.mha"
  )
plm_add_test (
  "plm-compose-a-stats"
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "stats;${PLM_BUILD_TESTING_DIR}/plm-compose-a-vf.mha"
  )
plmtest_check_interval ("plm-compose-a-check"
  "${PLM_BUILD_TESTING_DIR}/plm-compose-a-stats.stdout.txt"
  "Mean: *([-0-9.]*)"
  "13.75"
  "13.85"
  )
set_tests_properties (plm-compose-a PROPERTIES 
  DEPENDS "plm-reg-itk-translation;plm-reg-compose")
set_tests_properties (plm-compose-a-warp PROPERTIES DEPENDS plm-compose-a)
set_tests_properties (plm-compose-a-stats PROPERTIES DEPENDS plm-compose-a)
set_tests_properties (plm-compose-a-check PROPERTIES 
  DEPENDS plm-compose-a-stats)

plm_add_test (
  "plm-compose-b" 
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "compose;${PLM_BUILD_TESTING_DIR}/plm-reg-itk-translation-vf.mha;${PLM_BUILD_TESTING_DIR}/plm-reg-compose-vf.mha;${PLM_BUILD_TESTING_DIR}/plm-compose-b-vf.mha"
  )
plm_add_test (
  "plm-compose-b-warp" 
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "warp;--input;${PLM_BUILD_TESTING_DIR}/gauss-5.mha;--xf;${PLM_BUILD_TESTING_DIR}/plm-compose-b-vf.mha;--output-img;${PLM_BUILD_TESTING_DIR}/plm-compose-b-warp.mha"
  )
plm_add_test (
  "plm-compose-b-stats"
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "stats;${PLM_BUILD_TESTING_DIR}/plm-compose-b-vf.mha"
  )
plmtest_check_interval ("plm-compose-b-check"
  "${PLM_BUILD_TESTING_DIR}/plm-compose-b-stats.stdout.txt"
  "Mean: *([-0-9.]*)"
  "13.75"
  "13.85"
  )
set_tests_properties (plm-compose-b PROPERTIES 
  DEPENDS "plm-reg-itk-translation;plm-reg-compose")
set_tests_properties (plm-compose-b-warp PROPERTIES DEPENDS plm-compose-b)
set_tests_properties (plm-compose-b-stats PROPERTIES DEPENDS plm-compose-b)
set_tests_properties (plm-compose-b-check PROPERTIES 
  DEPENDS plm-compose-b-stats)

plm_add_test (
  "plm-compose-c" 
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "compose;${PLM_BUILD_TESTING_DIR}/plm-bsp-mse-h-xf.txt;${PLM_BUILD_TESTING_DIR}/plm-reg-compose-vf.mha;${PLM_BUILD_TESTING_DIR}/plm-compose-c-vf.mha"
  )
plm_add_test (
  "plm-compose-c-warp" 
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "warp;--input;${PLM_BUILD_TESTING_DIR}/gauss-5.mha;--xf;${PLM_BUILD_TESTING_DIR}/plm-compose-c-vf.mha;--output-img;${PLM_BUILD_TESTING_DIR}/plm-compose-c-warp.mha"
  )
plm_add_test (
  "plm-compose-c-stats"
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "stats;${PLM_BUILD_TESTING_DIR}/plm-compose-c-vf.mha"
  )
plmtest_check_interval ("plm-compose-c-check"
  "${PLM_BUILD_TESTING_DIR}/plm-compose-c-stats.stdout.txt"
  "Mean: *([-0-9.]*)"
  "12.5"
  "12.6"
  )
set_tests_properties (plm-compose-c PROPERTIES 
  DEPENDS "gauss-5;plm-bsp-mse-h;plm-reg-compose")
set_tests_properties (plm-compose-c-warp PROPERTIES DEPENDS plm-compose-c)
set_tests_properties (plm-compose-c-stats PROPERTIES DEPENDS plm-compose-c)
set_tests_properties (plm-compose-c-check PROPERTIES 
  DEPENDS plm-compose-c-stats)

## -------------------------------------------------------------------------
## plm-resample-a    Image, subsample
## plm-resample-b    Image, resample to fixed
## plm-resample-c    Vector field, resample to fixed
## -------------------------------------------------------------------------
plm_add_test (
  "plm-resample-a" 
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "resample;--input;${PLM_BUILD_TESTING_DIR}/gauss-1.mha;--output;${PLM_BUILD_TESTING_DIR}/plm-resample-a.mha;--output-type;float;--subsample;2 2 2"
  )
plm_add_test (
  "plm-resample-a-stats"
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "stats;${PLM_BUILD_TESTING_DIR}/plm-resample-a.mha"
  )
plmtest_check_interval ("plm-resample-a-check"
  "${PLM_BUILD_TESTING_DIR}/plm-resample-a-stats.stdout.txt"
  "AVE *([-0-9.]*)"
  "-879.0"
  "-878.0"
  )
set_tests_properties (plm-resample-a PROPERTIES DEPENDS gauss-1)
set_tests_properties (plm-resample-a-stats PROPERTIES DEPENDS plm-resample-a)
set_tests_properties (plm-resample-a-check PROPERTIES 
  DEPENDS plm-resample-a-stats)

plm_add_test (
  "plm-resample-b" 
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "resample;--input;${PLM_BUILD_TESTING_DIR}/gauss-1.mha;--output;${PLM_BUILD_TESTING_DIR}/plm-resample-b.mha;--output-type;float;--fixed;${PLM_BUILD_TESTING_DIR}/black-1.mha"
  )
plm_add_test (
  "plm-resample-b-stats"
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "stats;${PLM_BUILD_TESTING_DIR}/plm-resample-b.mha"
  )
plmtest_check_interval ("plm-resample-b-check"
  "${PLM_BUILD_TESTING_DIR}/plm-resample-b-stats.stdout.txt"
  "AVE *([-0-9.]*)"
  "-879.0"
  "-878.0"
  )
set_property (TEST plm-resample-b APPEND PROPERTY DEPENDS gauss-1)
set_property (TEST plm-resample-b APPEND PROPERTY DEPENDS black-1)
set_tests_properties (plm-resample-b-stats PROPERTIES DEPENDS plm-resample-b)
set_tests_properties (plm-resample-b-check PROPERTIES 
  DEPENDS plm-resample-b-stats)

plm_add_test (
  "plm-resample-c" 
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "resample;--input;${PLM_BUILD_TESTING_DIR}/plm-bsp-mi-c-2-vf.mha;--output;${PLM_BUILD_TESTING_DIR}/plm-resample-c-vf.mha;--fixed;${PLM_BUILD_TESTING_DIR}/black-1.mha"
  )
plm_add_test (
  "plm-resample-c-stats"
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "stats;${PLM_BUILD_TESTING_DIR}/plm-resample-c-vf.mha"
  )
plmtest_check_interval ("plm-resample-c-check"
  "${PLM_BUILD_TESTING_DIR}/plm-resample-c-stats.stdout.txt"
  "Mean: *([-0-9.]*)"
  "6.67"
  "6.74"
  )
set_tests_properties (plm-resample-c PROPERTIES 
  DEPENDS "plm-bsp-mi-c-2;black-1")
set_tests_properties (plm-resample-c-stats PROPERTIES DEPENDS plm-resample-c)
set_tests_properties (plm-resample-c-check PROPERTIES 
  DEPENDS plm-resample-c-stats)

## -------------------------------------------------------------------------
## plastimatch scale
##  plm-scale-a      Scale an image
##  plm-scale-vf-a   Scale a vector field
## -------------------------------------------------------------------------
plm_add_test (
  "plm-scale-a"
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "scale;--output;${PLM_BUILD_TESTING_DIR}/plm-scale-a.nrrd;--weight;0.4;${PLM_BUILD_TESTING_DIR}/rect-1.mha"
  )
plm_add_test (
  "plm-scale-a-stats"
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "stats;${PLM_BUILD_TESTING_DIR}/plm-scale-a.nrrd"
  )
plmtest_check_interval ("plm-scale-a-check"
  "${PLM_BUILD_TESTING_DIR}/plm-scale-a-stats.stdout.txt"
  "AVE *([-0-9.]*)"
  "-3.735"
  "-3.730"
  )
set_tests_properties (plm-scale-a PROPERTIES DEPENDS "rect-1")
set_tests_properties (plm-scale-a-stats PROPERTIES DEPENDS plm-scale-a)
set_tests_properties (plm-scale-a-check PROPERTIES DEPENDS plm-scale-a-stats)

plm_add_test (
  "plm-scale-vf-a"
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "scale;--output;${PLM_BUILD_TESTING_DIR}/plm-scale-vf-a.nrrd;--weight;0.4;${PLM_BUILD_TESTING_DIR}/vf-trans-1.mha"
  )
plm_add_test (
  "plm-scale-vf-a-stats"
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "stats;${PLM_BUILD_TESTING_DIR}/plm-scale-vf-a.nrrd"
  )
plmtest_check_interval ("plm-scale-vf-a-check"
  "${PLM_BUILD_TESTING_DIR}/plm-scale-vf-a-stats.stdout.txt"
  "Mean: *([-0-9.]*)"
  "4.000"
  "4.000"
  )
set_tests_properties (plm-scale-vf-a PROPERTIES DEPENDS vf-trans-1)
set_tests_properties (plm-scale-vf-a-stats PROPERTIES DEPENDS plm-scale-vf-a)
set_tests_properties (plm-scale-vf-a-check PROPERTIES DEPENDS plm-scale-vf-a-stats)

## -------------------------------------------------------------------------
## plastimatch sift
##  plm-sift-a       Run SIFT on rect
## -------------------------------------------------------------------------
plm_add_test (
  "plm-sift-a"
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "sift;--output-ps-1;${PLM_BUILD_TESTING_DIR}/plm-sift-a-ps-1.fcsv;--output-ps-2;${PLM_BUILD_TESTING_DIR}/plm-sift-a-ps-2.fcsv;--output-match-1;${PLM_BUILD_TESTING_DIR}/plm-sift-a-match-1.fcsv;--output-match-2;${PLM_BUILD_TESTING_DIR}/plm-sift-a-match-2.fcsv;${PLM_BUILD_TESTING_DIR}/lung-1.mha;${PLM_BUILD_TESTING_DIR}/lung-2.mha"
  )
plmtest_check_string ("plm-sift-a-check-1" 
  "${PLM_BUILD_TESTING_DIR}/plm-sift-a-match-1.fcsv"
  "^p1-1,(.*)"
  "-7.500,7.500,-17.500"
  )
plmtest_check_string ("plm-sift-a-check-2" 
  "${PLM_BUILD_TESTING_DIR}/plm-sift-a-match-2.fcsv"
  "^p1-1,(.*)"
  "-7.500,7.500,-22.500"
  )
set_tests_properties (plm-sift-a PROPERTIES DEPENDS "lung-1;lung-2")
set_tests_properties (plm-sift-a-check-1 PROPERTIES DEPENDS plm-sift-a)
set_tests_properties (plm-sift-a-check-2 PROPERTIES DEPENDS plm-sift-a)

## -------------------------------------------------------------------------
## plm-thumbnail-a: make png file of sphere
## plm-thumbnail-b: make png file of gauss
## plm-thumbnail-c: make png file of gauss (auto-adjust)
## -------------------------------------------------------------------------
plm_add_test (
  "plm-thumbnail-a" 
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "thumbnail;--input;${PLM_BUILD_TESTING_DIR}/sphere-1.mha;--output;${PLM_BUILD_TESTING_DIR}/plm-thumbnail-a.png;--spacing;2"
  )
plm_add_test (
  "plm-thumbnail-a-stats"
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "stats;${PLM_BUILD_TESTING_DIR}/plm-thumbnail-a.png"
  )
plmtest_check_interval ("plm-thumbnail-a-check"
  "${PLM_BUILD_TESTING_DIR}/plm-thumbnail-a-stats.stdout.txt"
  "AVE *([-0-9.]*)"
  "76.85"
  "76.95"
  )
set_tests_properties (plm-thumbnail-a PROPERTIES DEPENDS sphere-1)
set_tests_properties (plm-thumbnail-a-stats PROPERTIES DEPENDS plm-thumbnail-a)
set_tests_properties (plm-thumbnail-a-check PROPERTIES 
  DEPENDS plm-thumbnail-a-stats)

plm_add_test (
  "plm-thumbnail-b" 
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "thumbnail;--input;${PLM_BUILD_TESTING_DIR}/gauss-1.mha;--output;${PLM_BUILD_TESTING_DIR}/plm-thumbnail-b.png;--spacing;2"
  )
plm_add_test (
  "plm-thumbnail-b-stats"
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "stats;${PLM_BUILD_TESTING_DIR}/plm-thumbnail-b.png"
  )
plmtest_check_interval ("plm-thumbnail-b-check"
  "${PLM_BUILD_TESTING_DIR}/plm-thumbnail-b-stats.stdout.txt"
  "AVE *([-0-9.]*)"
  "0.0"
  "0.0"
  )
set_tests_properties (plm-thumbnail-b PROPERTIES DEPENDS gauss-1)
set_tests_properties (plm-thumbnail-b-stats PROPERTIES DEPENDS plm-thumbnail-b)
set_tests_properties (plm-thumbnail-b-check PROPERTIES 
  DEPENDS plm-thumbnail-b-stats)

plm_add_test (
  "plm-thumbnail-c" 
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "thumbnail;--input;${PLM_BUILD_TESTING_DIR}/gauss-1.mha;--output;${PLM_BUILD_TESTING_DIR}/plm-thumbnail-c.png;--spacing;2;--auto-adjust"
  )
plm_add_test (
  "plm-thumbnail-c-stats"
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "stats;${PLM_BUILD_TESTING_DIR}/plm-thumbnail-c.png"
  )
plmtest_check_interval ("plm-thumbnail-c-check"
  "${PLM_BUILD_TESTING_DIR}/plm-thumbnail-c-stats.stdout.txt"
  "AVE *([-0-9.]*)"
  "8.1"
  "8.3"
  )
set_tests_properties (plm-thumbnail-c PROPERTIES DEPENDS gauss-1)
set_tests_properties (plm-thumbnail-c-stats PROPERTIES DEPENDS plm-thumbnail-c)
set_tests_properties (plm-thumbnail-c-check PROPERTIES 
  DEPENDS plm-thumbnail-c-stats)

## -------------------------------------------------------------------------
## plm-intersect
## plm-union
## -------------------------------------------------------------------------
plm_add_test (
  "plm-intersect"
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "intersect;--output;${PLM_BUILD_TESTING_DIR}/plm-intersect.mha;${PLM_BUILD_TESTING_DIR}/rect-10-roi-1.mha;${PLM_BUILD_TESTING_DIR}/rect-11-roi.mha"
  )
plm_add_test (
  "plm-intersect-stats"
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "stats;${PLM_BUILD_TESTING_DIR}/plm-intersect.mha"
  )
plmtest_check_interval ("plm-intersect-check"
  "${PLM_BUILD_TESTING_DIR}/plm-intersect-stats.stdout.txt"
  "NONZERO *([-0-9.]*)"
  "729"
  "729"
  )

plm_add_test (
  "plm-union"
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "union;--output;${PLM_BUILD_TESTING_DIR}/plm-union.mha;${PLM_BUILD_TESTING_DIR}/rect-10-roi-1.mha;${PLM_BUILD_TESTING_DIR}/rect-11-roi.mha"
  )
plm_add_test (
  "plm-union-stats"
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "stats;${PLM_BUILD_TESTING_DIR}/plm-union.mha"
  )
plmtest_check_interval ("plm-union-check"
  "${PLM_BUILD_TESTING_DIR}/plm-union-stats.stdout.txt"
  "NONZERO *([-0-9.]*)"
  "1271"
  "1271"
  )

set_tests_properties (plm-intersect 
  PROPERTIES DEPENDS "rect-10-roi-1;rect-11-roi")
set_tests_properties (plm-intersect-stats PROPERTIES DEPENDS plm-intersect)
set_tests_properties (plm-intersect-check PROPERTIES DEPENDS plm-intersect-stats)

set_tests_properties (plm-union 
  PROPERTIES DEPENDS "rect-10-roi-1;rect-11-roi")
set_tests_properties (plm-union-stats PROPERTIES DEPENDS plm-union)
set_tests_properties (plm-union-check PROPERTIES DEPENDS plm-union-stats)

## -------------------------------------------------------------------------
## plm-threshold-a
## plm-threshold-b
## plm-threshold-c
## -------------------------------------------------------------------------
plm_add_test (
  "plm-threshold-a"
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "threshold;--input;${PLM_BUILD_TESTING_DIR}/gauss-1.mha;--output;${PLM_BUILD_TESTING_DIR}/plm-threshold-a.mha;--above;-888"
  )
plm_add_test (
  "plm-threshold-a-stats"
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "stats;${PLM_BUILD_TESTING_DIR}/plm-threshold-a.mha"
  )
plmtest_check_interval ("plm-threshold-a-check"
  "${PLM_BUILD_TESTING_DIR}/plm-threshold-a-stats.stdout.txt"
  "AVE *([-0-9.]*)"
  "0.306"
  "0.308"
  )
set_tests_properties (plm-threshold-a PROPERTIES DEPENDS "gauss-1")
set_tests_properties (plm-threshold-a-stats 
  PROPERTIES DEPENDS plm-threshold-a)
set_tests_properties (plm-threshold-a-check 
  PROPERTIES DEPENDS plm-threshold-a-stats)

plm_add_test (
  "plm-threshold-b"
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "threshold;--input;${PLM_BUILD_TESTING_DIR}/gauss-1.mha;--output;${PLM_BUILD_TESTING_DIR}/plm-threshold-b.mha;--below;-900"
  )
plm_add_test (
  "plm-threshold-b-stats"
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "stats;${PLM_BUILD_TESTING_DIR}/plm-threshold-b.mha"
  )
plmtest_check_interval ("plm-threshold-b-check"
  "${PLM_BUILD_TESTING_DIR}/plm-threshold-b-stats.stdout.txt"
  "AVE *([-0-9.]*)"
  "0.670"
  "0.672"
  )
set_tests_properties (plm-threshold-b PROPERTIES DEPENDS "gauss-1")
set_tests_properties (plm-threshold-b-stats 
  PROPERTIES DEPENDS plm-threshold-b)
set_tests_properties (plm-threshold-b-check 
  PROPERTIES DEPENDS plm-threshold-b-stats)

plm_add_test (
  "plm-threshold-c"
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "threshold;--input;${PLM_BUILD_TESTING_DIR}/gauss-1.mha;--output;${PLM_BUILD_TESTING_DIR}/plm-threshold-c.mha;--range;-900,-888"
  )
plm_add_test (
  "plm-threshold-c-stats"
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "stats;${PLM_BUILD_TESTING_DIR}/plm-threshold-c.mha"
  )
plmtest_check_interval ("plm-threshold-c-check"
  "${PLM_BUILD_TESTING_DIR}/plm-threshold-c-stats.stdout.txt"
  "NONZERO *([-0-9.]*)"
  "1206"
  "1206"
  )
set_tests_properties (plm-threshold-c PROPERTIES DEPENDS "gauss-1")
set_tests_properties (plm-threshold-c-stats 
  PROPERTIES DEPENDS plm-threshold-c)
set_tests_properties (plm-threshold-c-check 
  PROPERTIES DEPENDS plm-threshold-c-stats)

## -------------------------------------------------------------------------
## plastimatch warp pointset
##   plm-warp-pointset-a:  xf = bspline, output fcsv
##   plm-warp-pointset-b:  xf = bspline, output txt
##   plm-warp-pointset-c:  xf = vf, output fcsv
## -------------------------------------------------------------------------
plm_add_test (
  "plm-warp-pointset-a" 
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "warp;--xf;${PLM_BUILD_TESTING_DIR}/plm-bsp-rect-xf.txt;--input;${PLM_TESTING_DATA_DIR}/fiducials-rect-2.fcsv;--output-pointset;${PLM_BUILD_TESTING_DIR}/plm-warp-pointset-a.fcsv"
  )
plm_add_test (
  "plm-warp-pointset-b" 
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "warp;--xf;${PLM_BUILD_TESTING_DIR}/plm-bsp-rect-xf.txt;--input;${PLM_TESTING_DATA_DIR}/fiducials-rect-2.fcsv;--output-pointset;${PLM_BUILD_TESTING_DIR}/plm-warp-pointset-b.txt"
  )
plm_add_test (
  "plm-warp-pointset-c" 
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "warp;--xf;${PLM_BUILD_TESTING_DIR}/landmark-warp-c-vf.mha;--input;${PLM_TESTING_DATA_DIR}/fiducials-rect-2.fcsv;--output-pointset;${PLM_BUILD_TESTING_DIR}/plm-warp-landmark-c.fcsv"
  )
set_tests_properties (plm-warp-pointset-a PROPERTIES DEPENDS plm-bsp-rect)
set_tests_properties (plm-warp-pointset-b PROPERTIES DEPENDS plm-bsp-rect)
set_tests_properties (plm-warp-pointset-c PROPERTIES DEPENDS landmark-warp-c)

## -------------------------------------------------------------------------
## plastimatch warp
##   plm warp a: xf = bspline, algorithm = itk
##   plm warp b: xf = bspline, algorithm = native
##   plm warp c: xf = bspline, algorithm = itk, interp = nn
##   plm warp d: xf = bspline, algorithm = native, interp = nn
##   plm warp f: xf = itk-affine-a, harden transform
##   plm warp g: xf = itk-affine-b, force resample
##   plm warp h: xf = translation, force resample, ushort images
##   plm warp i: xf = translation, force resample, double images
## -------------------------------------------------------------------------
plm_add_test (
  "plm-warp-a" 
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "warp;--algorithm;itk;--xf;${PLM_TESTING_DATA_DIR}/xf-bspline-2.txt;--output-vf;${PLM_BUILD_TESTING_DIR}/plm-warp-a-vf.mha;--input;${PLM_BUILD_TESTING_DIR}/gauss-1.mha;--output-img;${PLM_BUILD_TESTING_DIR}/plm-warp-a.mha"
  )
plm_add_test (
  "plm-warp-a-stats"
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "stats;${PLM_BUILD_TESTING_DIR}/plm-warp-a-vf.mha"
  )
plmtest_check_interval ("plm-warp-a-check"
  "${PLM_BUILD_TESTING_DIR}/plm-warp-a-stats.stdout.txt"
  "Mean: *([-0-9.]*)"
  "5.77"
  "5.78"
  )
## Note: don't include dependency on gauss-1 as workaround for cmake bug.
set_property (TEST plm-warp-a APPEND PROPERTY DEPENDS bspline-c)
#set_property (TEST plm-warp-a APPEND PROPERTY DEPENDS gauss-1)
set_tests_properties (plm-warp-a-stats PROPERTIES DEPENDS plm-warp-a)
set_tests_properties (plm-warp-a-check PROPERTIES DEPENDS plm-warp-a-stats)

plm_add_test (
  "plm-warp-b" 
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "warp;--xf;${PLM_TESTING_DATA_DIR}/xf-bspline-2.txt;--output-vf;${PLM_BUILD_TESTING_DIR}/plm-warp-b-vf.mha;--input;${PLM_BUILD_TESTING_DIR}/gauss-1.mha;--output-img;${PLM_BUILD_TESTING_DIR}/plm-warp-b.mha;--default-value;0"
  )
plm_add_test (
  "plm-warp-b-stats-1"
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "stats;${PLM_BUILD_TESTING_DIR}/plm-warp-b-vf.mha"
  )
plmtest_check_interval ("plm-warp-b-check-1"
  "${PLM_BUILD_TESTING_DIR}/plm-warp-b-stats-1.stdout.txt"
  "Mean: *([-0-9.]*)"
  "5.77"
  "5.78"
  )
plm_add_test (
  "plm-warp-b-stats-2"
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "stats;${PLM_BUILD_TESTING_DIR}/plm-warp-b.mha"
  )
plmtest_check_interval ("plm-warp-b-check-2"
  "${PLM_BUILD_TESTING_DIR}/plm-warp-b-stats-2.stdout.txt"
  "AVE *([-0-9.]*)"
  "-775.7"
  "-775.6"
  )
## Note: don't include dependency on gauss-1 as workaround for cmake bug.
set_property (TEST plm-warp-b APPEND PROPERTY DEPENDS bspline-c)
#set_property (TEST plm-warp-b APPEND PROPERTY DEPENDS gauss-1)
set_tests_properties (plm-warp-b-stats-1 PROPERTIES DEPENDS plm-warp-b)
set_tests_properties (plm-warp-b-check-1 PROPERTIES DEPENDS plm-warp-b-stats-1)
set_tests_properties (plm-warp-b-stats-2 PROPERTIES DEPENDS plm-warp-b)
set_tests_properties (plm-warp-b-check-2 PROPERTIES DEPENDS plm-warp-b-stats-2)

plm_add_test (
  "plm-warp-c" 
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "warp;--algorithm;itk;--xf;${PLM_TESTING_DATA_DIR}/xf-bspline-2.txt;--output-vf;${PLM_BUILD_TESTING_DIR}/plm-warp-c-vf.mha;--input;${PLM_BUILD_TESTING_DIR}/sphere-1.mha;--output-img;${PLM_BUILD_TESTING_DIR}/plm-warp-c.mha;--interpolation;nn;--default-value;0"
  )
plm_add_test (
  "plm-warp-c-stats"
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "stats;${PLM_BUILD_TESTING_DIR}/plm-warp-c.mha"
  )
plmtest_check_interval ("plm-warp-c-check"
  "${PLM_BUILD_TESTING_DIR}/plm-warp-c-stats.stdout.txt"
  "AVE *([-0-9.]*)"
  "9.2"
  "9.3"
  )
set_tests_properties (plm-warp-c PROPERTIES DEPENDS "bspline-c;sphere-1")
set_tests_properties (plm-warp-c-stats PROPERTIES DEPENDS plm-warp-c)
set_tests_properties (plm-warp-c-check PROPERTIES DEPENDS plm-warp-c-stats)

plm_add_test (
  "plm-warp-d" 
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "warp;--xf;${PLM_TESTING_DATA_DIR}/xf-bspline-2.txt;--output-vf;${PLM_BUILD_TESTING_DIR}/plm-warp-d-vf.mha;--input;${PLM_BUILD_TESTING_DIR}/sphere-1.mha;--output-img;${PLM_BUILD_TESTING_DIR}/plm-warp-d.mha;--interpolation;nn;--default-value;0"
  )
plm_add_test (
  "plm-warp-d-stats"
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "stats;${PLM_BUILD_TESTING_DIR}/plm-warp-d.mha"
  )
plmtest_check_interval ("plm-warp-d-check"
  "${PLM_BUILD_TESTING_DIR}/plm-warp-d-stats.stdout.txt"
  "AVE *([-0-9.]*)"
  "9.2"
  "9.3"
  )
set_tests_properties (plm-warp-d PROPERTIES DEPENDS "bspline-c;sphere-1")
set_tests_properties (plm-warp-d-stats PROPERTIES DEPENDS plm-warp-d)
set_tests_properties (plm-warp-d-check PROPERTIES DEPENDS plm-warp-d-stats)

plm_add_test (
  "plm-warp-f" 
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "warp;--xf;${PLM_TESTING_DATA_DIR}/itk-affine-a.tfm;--input;${PLM_BUILD_TESTING_DIR}/rect-3.mha;--output-img;${PLM_BUILD_TESTING_DIR}/plm-warp-f-img.nrrd;--default-value;0;--harden-linear-xf"
  )
plm_add_test (
  "plm-warp-f-stats-1"
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "header;plm-warp-f-img.nrrd"
  )
plmtest_check_interval ("plm-warp-f-check-1"
  "${PLM_BUILD_TESTING_DIR}/plm-warp-f-stats-1.stdout.txt"
  "Direction = *[-0-9.]* *[-0-9.]* *([-0-9.]*)"
  "-0.379"
  "-0.378"
  )
set_tests_properties (plm-warp-f PROPERTIES DEPENDS rect-3)
set_tests_properties (plm-warp-f-stats-1 PROPERTIES DEPENDS plm-warp-f)
set_tests_properties (plm-warp-f-check-1 PROPERTIES DEPENDS plm-warp-f-stats-1)

plm_add_test (
  "plm-warp-g" 
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "warp;--xf;${PLM_TESTING_DATA_DIR}/itk-affine-a.tfm;--input;${PLM_BUILD_TESTING_DIR}/rect-3.mha;--output-img;${PLM_BUILD_TESTING_DIR}/plm-warp-g-img.nrrd;--default-value;0;--resample-linear-xf"
  )
plm_add_test (
  "plm-warp-g-stats-1"
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "stats;${PLM_BUILD_TESTING_DIR}/plm-warp-g-img.nrrd"
  )
plmtest_check_interval ("plm-warp-g-check-1"
  "${PLM_BUILD_TESTING_DIR}/plm-warp-g-stats-1.stdout.txt"
  "AVE *([-0-9.]*)"
  "-764.0"
  "-763.6"
  )
set_tests_properties (plm-warp-g PROPERTIES DEPENDS rect-3)
set_tests_properties (plm-warp-g-stats-1 PROPERTIES DEPENDS plm-warp-g)
set_tests_properties (plm-warp-g-check-1 PROPERTIES DEPENDS plm-warp-g-stats-1)

plm_add_test (
  "plm-warp-h" 
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "warp;--xf;${PLM_TESTING_DATA_DIR}/xf-translation-1.txt;--input;${PLM_BUILD_TESTING_DIR}/gauss-ushort-1.mha;--output-img;${PLM_BUILD_TESTING_DIR}/plm-warp-h-img.nrrd;--default-value;0;--resample-linear-xf"
  )
plm_add_test (
  "plm-warp-h-stats-1"
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "stats;plm-warp-h-img.nrrd"
  )
plmtest_check_interval ("plm-warp-h-check-1"
  "${PLM_BUILD_TESTING_DIR}/plm-warp-h-stats-1.stdout.txt"
  "AVE *([-0-9.]*)"
  "113.5"
  "114.0"
  )
set_tests_properties (plm-warp-h PROPERTIES DEPENDS gauss-ushort-1)
set_tests_properties (plm-warp-h-stats-1 PROPERTIES DEPENDS plm-warp-h)
set_tests_properties (plm-warp-h-check-1 PROPERTIES DEPENDS plm-warp-h-stats-1)

plm_add_test (
  "plm-warp-i" 
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "warp;--xf;${PLM_TESTING_DATA_DIR}/xf-translation-1.txt;--input;${PLM_BUILD_TESTING_DIR}/gauss-double-1.mha;--output-img;${PLM_BUILD_TESTING_DIR}/plm-warp-i-img.nrrd;--default-value;0;--resample-linear-xf"
  )
plm_add_test (
  "plm-warp-i-stats-1"
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "stats;plm-warp-i-img.nrrd"
  )
plmtest_check_interval ("plm-warp-i-check-1"
  "${PLM_BUILD_TESTING_DIR}/plm-warp-i-stats-1.stdout.txt"
  "AVE *([-0-9.]*)"
  "114.4"
  "114.7"
  )
set_tests_properties (plm-warp-i PROPERTIES DEPENDS gauss-double-1)
set_tests_properties (plm-warp-i-stats-1 PROPERTIES DEPENDS plm-warp-i)
set_tests_properties (plm-warp-i-check-1 PROPERTIES DEPENDS plm-warp-i-stats-1)

## -------------------------------------------------------------------------
## plm-xf-convert-a    plm bspline to vf
## plm-xf-convert-b    vf to plm bspline
## plm-xf-convert-c    plm bspline to vf
## plm-xf-convert-d    plm bspline to itk bspline
## plm-xf-convert-e    itk rigid to dicom rigid (referenced dicom images)
## plm-xf-convert-f    itk rigid to dicom rigid (exported dicom images)
## plm-xf-convert-g    vector field to dicom deformable (referenced dicom)
## plm-xf-convert-h    itk rigid to vector field (fixed reference)
## plm-xf-convert-i    plm bspline to vf (no 
## -------------------------------------------------------------------------
plm_add_test (
  "plm-xf-convert-a" 
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "xf-convert;--input;${PLM_TESTING_DATA_DIR}/xf-bspline-1.txt;--output;${PLM_BUILD_TESTING_DIR}/plm-xf-convert-a-vf.mha;--output-type;vf;--dim;4 4 4;--origin;-187.5 -187.5 -187.5;--spacing;125 125 125;"
  )

plm_add_test (
  "plm-xf-convert-b"
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "xf-convert;--input;${PLM_BUILD_TESTING_DIR}/plm-xf-convert-a-vf.mha;--output;${PLM_BUILD_TESTING_DIR}/plm-xf-convert-b.txt;--output-type;bspline;--dim;4 4 4;--origin;-187.5 -187.5 -187.5;--spacing;125 125 125;--grid-spacing;10 10 10"
  )
set_tests_properties (plm-xf-convert-b PROPERTIES DEPENDS plm-xf-convert-a)

plm_add_test (
  "plm-xf-convert-c"
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "xf-convert;--input;${PLM_BUILD_TESTING_DIR}/plm-xf-convert-b.txt;--output;${PLM_BUILD_TESTING_DIR}/plm-xf-convert-c-vf.mha;--output-type;vf;--dim;4 4 4;--origin;-187.5 -187.5 -187.5;--spacing;125 125 125"
  )
set_tests_properties (plm-xf-convert-c PROPERTIES DEPENDS plm-xf-convert-b)

plm_add_test (
  "plm-xf-convert-d" 
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "xf-convert;--input;${PLM_TESTING_DATA_DIR}/plm-xf-convert.txt;--output;${PLM_BUILD_TESTING_DIR}/plm-xf-convert-d-xf.tfm;--output-type;itk_bspline"
  )
plm_add_test (
  "plm-xf-convert-d-warp-1" 
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "warp;--input;${PLM_BUILD_TESTING_DIR}/gauss-2.mha;--xf;${PLM_TESTING_DATA_DIR}/plm-xf-convert.txt;--output-img;${PLM_BUILD_TESTING_DIR}/plm-xf-convert-d-warp-1.nrrd"
  )
plm_add_test (
  "plm-xf-convert-d-warp-1-stats"
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "stats;${PLM_BUILD_TESTING_DIR}/plm-xf-convert-d-warp-1.nrrd"
  )
plmtest_check_interval (
  "plm-xf-convert-d-warp-1-check"
  "${PLM_BUILD_TESTING_DIR}/plm-xf-convert-d-warp-1-stats.stdout.txt"
  "AVE *([-0-9.]*)"
  "-745.8"
  "-744.8"
  )
plm_add_test (
  "plm-xf-convert-d-warp-2" 
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "warp;--input;${PLM_BUILD_TESTING_DIR}/gauss-2.mha;--xf;${PLM_BUILD_TESTING_DIR}/plm-xf-convert-d-xf.tfm;--output-img;${PLM_BUILD_TESTING_DIR}/plm-xf-convert-d-warp-2.nrrd"
  )
plm_add_test (
  "plm-xf-convert-d-warp-2-stats"
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "stats;${PLM_BUILD_TESTING_DIR}/plm-xf-convert-d-warp-2.nrrd"
  )
plmtest_check_interval (
  "plm-xf-convert-d-warp-2-check"
  "${PLM_BUILD_TESTING_DIR}/plm-xf-convert-d-warp-2-stats.stdout.txt"
  "AVE *([-0-9.]*)"
  # GCS 2011-10-08.  The ITK B-spline resampling method is very poor, and 
  # gives different results on different platforms.  Probably we need 
  # to convert all ITK B-splines to native, and resample using the 
  # native method.
  "-751.0"
  #  "-745.8"
  "-744.8"
  )
set_tests_properties (plm-xf-convert-d-warp-1 PROPERTIES DEPENDS gauss-2)
set_tests_properties (plm-xf-convert-d-warp-1-stats PROPERTIES 
  DEPENDS plm-xf-convert-d-warp-1)
set_tests_properties (plm-xf-convert-d-warp-1-check PROPERTIES 
  DEPENDS plm-xf-convert-d-warp-1-stats)
set_tests_properties (plm-xf-convert-d-warp-2 PROPERTIES 
  DEPENDS "gauss-2;plm-xf-convert-d")
set_tests_properties (plm-xf-convert-d-warp-2-stats PROPERTIES 
  DEPENDS plm-xf-convert-d-warp-2)
set_tests_properties (plm-xf-convert-d-warp-2-check PROPERTIES 
  DEPENDS plm-xf-convert-d-warp-2-stats)

plm_add_test (
  "plm-xf-convert-e" 
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "xf-convert;--filenames-without-uids;--input;${PLM_TESTING_DATA_DIR}/itk-rigid-a.tfm;--output-dicom;${PLM_BUILD_TESTING_DIR}/plm-xf-convert-e;--fixed-rcs;${PLM_BUILD_TESTING_DIR}/rect-3-dicom;--moving-rcs;${PLM_BUILD_TESTING_DIR}/rect-2-dicom"
  )
set_tests_properties (plm-xf-convert-e PROPERTIES DEPENDS "rect-2;rect-3")

plm_add_test (
  "plm-xf-convert-f" 
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "xf-convert;--filenames-without-uids;--input;${PLM_TESTING_DATA_DIR}/itk-rigid-a.tfm;--output-dicom;${PLM_BUILD_TESTING_DIR}/plm-xf-convert-f;--fixed-image;${PLM_BUILD_TESTING_DIR}/rect-3.mha;--moving-image;${PLM_BUILD_TESTING_DIR}/rect-2.mha"
  )
set_tests_properties (plm-xf-convert-f PROPERTIES DEPENDS "rect-2;rect-3")

plm_add_test (
  "plm-xf-convert-g" 
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "xf-convert;--filenames-without-uids;--input;${PLM_BUILD_TESTING_DIR}/plm-bsp-rect-vf.nrrd;--output-dicom;${PLM_BUILD_TESTING_DIR}/plm-xf-convert-g;--fixed-rcs;${PLM_BUILD_TESTING_DIR}/rect-2-dicom;--moving-rcs;${PLM_BUILD_TESTING_DIR}/rect-3-dicom"
  )
set_tests_properties (plm-xf-convert-g PROPERTIES DEPENDS "rect-2;rect-3;plm-bsp-rect")

plm_add_test (
  "plm-xf-convert-h" 
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "xf-convert;--filenames-without-uids;--input;${PLM_TESTING_DATA_DIR}/itk-rigid-a.tfm;--output;${PLM_BUILD_TESTING_DIR}/plm-xf-convert-h.nrrd;--fixed;${PLM_BUILD_TESTING_DIR}/rect-3.mha;--output-type;vf"
  )
plm_add_test (
  "plm-xf-convert-h-stats"
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "stats;${PLM_BUILD_TESTING_DIR}/plm-xf-convert-h.nrrd"
  )
plmtest_check_interval (
  "plm-xf-convert-h-check"
  "${PLM_BUILD_TESTING_DIR}/plm-xf-convert-h-stats.stdout.txt"
  "Min: *([-0-9.]*)"
  "20"
  "20"
  )
set_tests_properties (plm-xf-convert-h PROPERTIES DEPENDS "rect-3")
set_tests_properties (plm-xf-convert-h-stats PROPERTIES DEPENDS "plm-xf-convert-h")
set_tests_properties (plm-xf-convert-h-check PROPERTIES DEPENDS "plm-xf-convert-h-stats")

plm_add_test (
  "plm-xf-convert-i" 
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "xf-convert;--input;${PLM_TESTING_DATA_DIR}/xf-bspline-1.txt;--output;${PLM_BUILD_TESTING_DIR}/plm-xf-convert-i-vf.nrrd;--output-type;vf"
  )
plm_add_test (
  "plm-xf-convert-i-stats"
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "stats;${PLM_BUILD_TESTING_DIR}/plm-xf-convert-i-vf.nrrd"
  )
plmtest_check_interval (
  "plm-xf-convert-i-check"
  "${PLM_BUILD_TESTING_DIR}/plm-xf-convert-i-stats.stdout.txt"
  "Min: *([-0-9.]*)"
  "7.155"
  "7.165"
  )
set_tests_properties (plm-xf-convert-i-stats PROPERTIES DEPENDS "plm-xf-convert-i")
set_tests_properties (plm-xf-convert-i-check PROPERTIES DEPENDS "plm-xf-convert-i-stats")

## -------------------------------------------------------------------------
## xf-invert
## -------------------------------------------------------------------------
## xf-invert-vf-zero-1    invert zero vector field
## xf-invert-vf-trans-1   invert translation x direction, 1cm
## xf-invert-vf-gauss-1   invert gaussian warp, 10cm std, 1cm x, 2cm y
##                             (missing)
## xf-invert-vrs-a        invert versor translation
## xf-invert-vrs-b        invert versor rotation
## -------------------------------------------------------------------------
plm_add_test (
  "xf-invert-vf-zero-1"
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "xf-invert;--input;${PLM_BUILD_TESTING_DIR}/vf-zero.mha;--fixed;${PLM_BUILD_TESTING_DIR}/vf-zero.mha;--output;${PLM_BUILD_TESTING_DIR}/xf-invert-vf-zero-1.mha"
  )
plm_add_test (
  "xf-invert-vf-zero-1-stats"
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "stats;${PLM_BUILD_TESTING_DIR}/xf-invert-vf-zero-1.mha"
  )
plmtest_check_interval ("xf-invert-vf-zero-1-check"
  "${PLM_BUILD_TESTING_DIR}/xf-invert-vf-zero-1-stats.stdout.txt"
  "Mean abs: *([-0-9.]*)"
  "0.000"
  "0.000"
  )
set_tests_properties (xf-invert-vf-zero-1 PROPERTIES DEPENDS vf-zero)
set_tests_properties (xf-invert-vf-zero-1-stats 
  PROPERTIES DEPENDS xf-invert-vf-zero-1)
set_tests_properties (xf-invert-vf-zero-1-check 
  PROPERTIES DEPENDS xf-invert-vf-zero-1-stats)

plm_add_test (
  "xf-invert-vf-trans-1"
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "xf-invert;--input;${PLM_BUILD_TESTING_DIR}/vf-trans-1.mha;--fixed;${PLM_BUILD_TESTING_DIR}/vf-trans-1.mha;--output;${PLM_BUILD_TESTING_DIR}/xf-invert-vf-trans-1.mha;--iterations;10"
  )
plm_add_test (
  "xf-invert-vf-trans-1-stats"
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "stats;${PLM_BUILD_TESTING_DIR}/xf-invert-vf-trans-1.mha"
  )
plmtest_check_interval ("xf-invert-vf-trans-1-check"
  "${PLM_BUILD_TESTING_DIR}/xf-invert-vf-trans-1-stats.stdout.txt"
  "Mean: *([-0-9.]*)"
  "-10.0"
  "-9.9"
  )
set_tests_properties (xf-invert-vf-trans-1 PROPERTIES DEPENDS vf-trans-1)
set_tests_properties (xf-invert-vf-trans-1-stats 
  PROPERTIES DEPENDS xf-invert-vf-trans-1)
set_tests_properties (xf-invert-vf-trans-1-check 
  PROPERTIES DEPENDS xf-invert-vf-trans-1-stats)

plm_add_test (
  "xf-invert-vrs-a"
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "xf-invert;--input;${PLM_TESTING_DATA_DIR}/itk-rigid-a.tfm;--output;${PLM_BUILD_TESTING_DIR}/xf-invert-vrs-a.tfm"
  )
plmtest_check_string (
  "xf-invert-vrs-a-check"
  "${PLM_BUILD_TESTING_DIR}/xf-invert-vrs-a.tfm"
  "^Parameters: *(.*)$"
  "0 0 0 -20 0 0"
  )
set_tests_properties (xf-invert-vrs-a-check
  PROPERTIES DEPENDS xf-invert-vrs-a)

plm_add_test (
  "xf-invert-vrs-b"
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "xf-invert;--input;${PLM_TESTING_DATA_DIR}/itk-rigid-b.tfm;--output;${PLM_BUILD_TESTING_DIR}/xf-invert-vrs-b.tfm"
  )
plmtest_check_interval (
  "xf-invert-vrs-b-check"
  "${PLM_BUILD_TESTING_DIR}/xf-invert-vrs-b.tfm"
  "^Parameters: *([-0-9.]*) *0 *0 *0 *0 *0 *$"
  "-0.52361"
  "-0.52359"
  )
set_tests_properties (xf-invert-vrs-b-check
  PROPERTIES DEPENDS xf-invert-vrs-b)

## -------------------------------------------------------------------------
## bragg-curve
## proton-dose-1    Flavor a, sobp
## proton-dose-4a   Flavor a, passive target with aperture and rgc
## proton-dose-4d   Flavor d, passive target with aperture and rgc
## proton-dose-5a   Flavor a, active target
## proton-dose-5d   Flavor d, active target
## proton-dose-6a   Flavor a, target geometry differs from CT geometry
## proton-dose-7a   Flavor a, spot map
## proton-dose-8d   Flavor d, mebs map
## -------------------------------------------------------------------------
plm_add_test (
  "bragg-curve"
  ${PLM_PLASTIMATCH_PATH}/bragg_curve
  "-O;${PLM_BUILD_TESTING_DIR}/bragg-curve.txt"
  )
add_test (bragg-curve-check ${CMAKE_COMMAND} -E compare_files
  "${PLM_TESTING_DATA_DIR}/bragg-curve.txt"
  "${PLM_BUILD_TESTING_DIR}/bragg-curve.txt")
set_tests_properties (bragg-curve-check PROPERTIES DEPENDS bragg-curve)

plm_add_test (
    "proton-dose-1"
    ${PLM_PLASTIMATCH_PATH}/plastimatch
    "dose;--command-file;${PLM_BUILD_TESTING_DIR}/proton-dose-1.txt"
    )
plm_add_test (
  "proton-dose-1-stats"
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "stats;${PLM_BUILD_TESTING_DIR}/proton-dose-1.mha"
  )
plmtest_check_interval ("proton-dose-1-check"
  "${PLM_BUILD_TESTING_DIR}/proton-dose-1-stats.stdout.txt"
  "AVE *([-0-9.]*)"
  "0.140"
  "0.145"
  )
set_tests_properties (proton-dose-1 PROPERTIES DEPENDS rect-17)
set_tests_properties (proton-dose-1-stats
    PROPERTIES DEPENDS proton-dose-1)
set_tests_properties (proton-dose-1-check
    PROPERTIES DEPENDS proton-dose-1-stats)

plm_add_test (
    "proton-dose-4a"
    ${PLM_PLASTIMATCH_PATH}/plastimatch
    "dose;--command-file;${PLM_BUILD_TESTING_DIR}/proton-dose-4a.txt"
    )
plm_add_test (
  "proton-dose-4a-stats"
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "stats;${PLM_BUILD_TESTING_DIR}/proton-dose-4a.mha"
  )
plmtest_check_interval ("proton-dose-4a-check"
  "${PLM_BUILD_TESTING_DIR}/proton-dose-4a-stats.stdout.txt"
  "AVE *([-0-9.]*)"
  "0.26"
  "0.27"
  )
set_tests_properties (proton-dose-4a PROPERTIES DEPENDS "rect-17;ptv-1")
set_tests_properties (proton-dose-4a-stats
    PROPERTIES DEPENDS proton-dose-4a)
set_tests_properties (proton-dose-4a-check
    PROPERTIES DEPENDS proton-dose-4a-stats)

plm_add_test (
    "proton-dose-4d"
    ${PLM_PLASTIMATCH_PATH}/plastimatch
    "dose;--command-file;${PLM_BUILD_TESTING_DIR}/proton-dose-4d.txt"
    )
plm_add_test (
  "proton-dose-4d-stats"
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "stats;${PLM_BUILD_TESTING_DIR}/proton-dose-4d.mha"
  )
plmtest_check_interval ("proton-dose-4d-check"
  "${PLM_BUILD_TESTING_DIR}/proton-dose-4d-stats.stdout.txt"
  "AVE *([-0-9.]*)"
  "0.38"
  "0.39"
  )
set_tests_properties (proton-dose-4d PROPERTIES DEPENDS "rect-17;ptv-1")
set_tests_properties (proton-dose-4d-stats
    PROPERTIES DEPENDS proton-dose-4d)
set_tests_properties (proton-dose-4d-check
    PROPERTIES DEPENDS proton-dose-4d-stats)

plm_add_test (
    "proton-dose-5a"
    ${PLM_PLASTIMATCH_PATH}/plastimatch
    "dose;--command-file;${PLM_BUILD_TESTING_DIR}/proton-dose-5a.txt"
    )
plm_add_test (
  "proton-dose-5a-stats"
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "stats;${PLM_BUILD_TESTING_DIR}/proton-dose-5a.mha"
  )
plmtest_check_interval ("proton-dose-5a-check"
  "${PLM_BUILD_TESTING_DIR}/proton-dose-5a-stats.stdout.txt"
  "AVE *([-0-9.]*)"
  "0.26"
  "0.27"
  )
set_tests_properties (proton-dose-5a PROPERTIES DEPENDS "rect-17;ptv-1")
set_tests_properties (proton-dose-5a-stats
    PROPERTIES DEPENDS proton-dose-5a)
set_tests_properties (proton-dose-5a-check
    PROPERTIES DEPENDS proton-dose-5a-stats)

plm_add_test (
    "proton-dose-5d"
    ${PLM_PLASTIMATCH_PATH}/plastimatch
    "dose;--command-file;${PLM_BUILD_TESTING_DIR}/proton-dose-5d.txt"
    )
plm_add_test (
  "proton-dose-5d-stats"
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "stats;${PLM_BUILD_TESTING_DIR}/proton-dose-5d.mha"
  )
plmtest_check_interval ("proton-dose-5d-check"
  "${PLM_BUILD_TESTING_DIR}/proton-dose-5d-stats.stdout.txt"
  "AVE *([-0-9.]*)"
  "0.38"
  "0.39"
  )
set_tests_properties (proton-dose-5d PROPERTIES DEPENDS "rect-17;ptv-1")
set_tests_properties (proton-dose-5d-stats
    PROPERTIES DEPENDS proton-dose-5d)
set_tests_properties (proton-dose-5d-check
    PROPERTIES DEPENDS proton-dose-5d-stats)

plm_add_test (
    "proton-dose-6a"
    ${PLM_PLASTIMATCH_PATH}/plastimatch
    "dose;--command-file;${PLM_BUILD_TESTING_DIR}/proton-dose-6a.txt"
    )
plm_add_test (
  "proton-dose-6a-stats"
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "stats;${PLM_BUILD_TESTING_DIR}/proton-dose-6a.mha"
  )
plmtest_check_interval ("proton-dose-6a-check"
  "${PLM_BUILD_TESTING_DIR}/proton-dose-6a-stats.stdout.txt"
  "AVE *([-0-9.]*)"
  "0.26"
  "0.27"
  )
set_tests_properties (proton-dose-6a PROPERTIES DEPENDS "rect-17;ptv-2")
set_tests_properties (proton-dose-6a-stats
    PROPERTIES DEPENDS proton-dose-6a)
set_tests_properties (proton-dose-6a-check
    PROPERTIES DEPENDS proton-dose-6a-stats)

plm_add_test (
    "proton-dose-7a"
    ${PLM_PLASTIMATCH_PATH}/plastimatch
    "dose;--command-file;${PLM_BUILD_TESTING_DIR}/proton-dose-7a.txt"
    )
set_tests_properties (proton-dose-7a PROPERTIES DEPENDS "rect-17")

plm_add_test (
    "proton-dose-8d"
    ${PLM_PLASTIMATCH_PATH}/plastimatch
    "dose;--command-file;${PLM_BUILD_TESTING_DIR}/proton-dose-8d.txt"
    )
plm_add_test (
  "proton-dose-8d-stats"
  ${PLM_PLASTIMATCH_PATH}/plastimatch
  "stats;${PLM_BUILD_TESTING_DIR}/proton-dose-8d.mha"
  )
plmtest_check_interval ("proton-dose-8d-check"
  "${PLM_BUILD_TESTING_DIR}/proton-dose-8d-stats.stdout.txt"
  "AVE *([-0-9.]*)"
  "0.38"
  "0.39"
  )
set_tests_properties (proton-dose-8d PROPERTIES DEPENDS "rect-17;proton-dose-5d")
set_tests_properties (proton-dose-8d-stats
    PROPERTIES DEPENDS proton-dose-8d)
set_tests_properties (proton-dose-8d-check
    PROPERTIES DEPENDS proton-dose-8d-stats)

## -------------------------------------------------------------------------
## wed-a           ct to proj-wed, proj-ct, and wed-ct
## wed-b           load saved proj-wed, compute proj-ct and wed-ct
## wed-c           proj-wed to dew-ct
## -------------------------------------------------------------------------
plm_add_test (
  "wed-a"
  ${PLM_PLASTIMATCH_PATH}/plastimatch 
  "wed;--command-file;${PLM_BUILD_TESTING_DIR}/wed-a.txt"
  )
set_tests_properties (wed-a PROPERTIES DEPENDS lung-1)

plm_add_test (
  "wed-b"
  ${PLM_PLASTIMATCH_PATH}/plastimatch 
  "wed;--command-file;${PLM_BUILD_TESTING_DIR}/wed-b.txt"
  )
set_tests_properties (wed-b PROPERTIES DEPENDS "lung-1;wed-a")

plm_add_test (
  "wed-c"
  ${PLM_PLASTIMATCH_PATH}/plastimatch 
  "wed;--command-file;${PLM_BUILD_TESTING_DIR}/wed-c.txt"
  )
set_tests_properties (wed-c PROPERTIES DEPENDS "lung-1;wed-a")

## -------------------------------------------------------------------------
## i hate myself
## -------------------------------------------------------------------------
if (${CMAKE_HOST_SYSTEM_PROCESSOR} MATCHES "^(ppc|powerpc)")
  plmtest_debug (debug-fdk-cpu-a
    "${PLM_BUILD_TESTING_DIR}/fdk-cpu-a.stdout.txt"
    "${PLM_BUILD_TESTING_DIR}/fdk-cpu-a.stderr.txt")
  plmtest_debug (debug-fdk-cpu-a-stats
    "${PLM_BUILD_TESTING_DIR}/fdk-cpu-a-stats.stdout.txt"
    "${PLM_BUILD_TESTING_DIR}/fdk-cpu-a-stats.stderr.txt")
  set_tests_properties (debug-fdk-cpu-a PROPERTIES 
    DEPENDS fdk-cpu-a)
  set_tests_properties (debug-fdk-cpu-a-stats PROPERTIES 
    DEPENDS fdk-cpu-a-stats)

  plmtest_debug (debug-landmark-warp-b
    "${PLM_BUILD_TESTING_DIR}/landmark-warp-b.stdout.txt"
    "${PLM_BUILD_TESTING_DIR}/landmark-warp-b.stderr.txt")
  plmtest_debug (debug-landmark-warp-b-stats
    "${PLM_BUILD_TESTING_DIR}/landmark-warp-b-stats.stdout.txt"
    "${PLM_BUILD_TESTING_DIR}/landmark-warp-b-stats.stderr.txt")
  set_tests_properties (debug-landmark-warp-b PROPERTIES 
    DEPENDS landmark-warp-b)
  set_tests_properties (debug-landmark-warp-b-stats PROPERTIES 
    DEPENDS landmark-warp-b-stats)

  plmtest_debug (debug-plm-bsp-char-output
    "${PLM_BUILD_TESTING_DIR}/plm-bsp-char-output.stdout.txt"
    "${PLM_BUILD_TESTING_DIR}/plm-bsp-char-output.stderr.txt")
  plmtest_debug (debug-plm-bsp-char-output-stats
    "${PLM_BUILD_TESTING_DIR}/plm-bsp-char-output-stats.stdout.txt"
    "${PLM_BUILD_TESTING_DIR}/plm-bsp-char-output-stats.stderr.txt")
  set_tests_properties (debug-plm-bsp-char-output PROPERTIES 
    DEPENDS plm-bsp-char-output)
  set_tests_properties (debug-plm-bsp-char-output-stats PROPERTIES 
    DEPENDS plm-bsp-char-output-stats)
endif ()
