diff --git a/Modules/DiffusionImaging/DiffusionCore/Testing/files.cmake b/Modules/DiffusionImaging/DiffusionCore/Testing/files.cmake index 2b1323b4e3..e0dffd884b 100644 --- a/Modules/DiffusionImaging/DiffusionCore/Testing/files.cmake +++ b/Modules/DiffusionImaging/DiffusionCore/Testing/files.cmake @@ -1,9 +1,10 @@ set(MODULE_TESTS mitkFactoryRegistrationTest.cpp ) set(MODULE_CUSTOM_TESTS mitkPyramidImageRegistrationMethodTest.cpp mitkDWHeadMotionCorrectionTest.cpp + mitkConvertDWITypeTest.cpp ) diff --git a/Modules/DiffusionImaging/DiffusionCore/Testing/mitkConvertDWITypeTest.cpp b/Modules/DiffusionImaging/DiffusionCore/Testing/mitkConvertDWITypeTest.cpp new file mode 100644 index 0000000000..fab2cf599b --- /dev/null +++ b/Modules/DiffusionImaging/DiffusionCore/Testing/mitkConvertDWITypeTest.cpp @@ -0,0 +1,63 @@ +/*=================================================================== + +The Medical Imaging Interaction Toolkit (MITK) + +Copyright (c) German Cancer Research Center, +Division of Medical and Biological Informatics. +All rights reserved. + +This software is distributed WITHOUT ANY WARRANTY; without +even the implied warranty of MERCHANTABILITY or FITNESS FOR +A PARTICULAR PURPOSE. + +See LICENSE.txt or http://www.mitk.org for details. + +===================================================================*/ + +#include "mitkTestingMacros.h" +#include "mitkIOUtil.h" + +#include "mitkDiffusionCoreObjectFactory.h" + +#include "mitkDWIHeadMotionCorrectionFilter.h" +#include "mitkNrrdDiffusionImageWriter.h" + +typedef short DiffusionPixelType; +typedef mitk::DiffusionImage< DiffusionPixelType > DiffusionImageType; + +/** + * @brief Custom test to provide CMD-line access to the mitk::DWIHeadMotionCorrectionFilter + * + * @param argv : Input and Output image full path + */ +int mitkConvertDWITypeTest( int argc, char* argv[] ) +{ + MITK_TEST_BEGIN("mitkConvertDWITypeTest"); + + MITK_TEST_CONDITION_REQUIRED( argc > 2, "Specify input and output."); + + RegisterDiffusionCoreObjectFactory(); + + mitk::Image::Pointer inputImage = mitk::IOUtil::LoadImage( argv[1] ); + DiffusionImageType* dwimage = + static_cast( inputImage.GetPointer() ); + + + mitk::NrrdDiffusionImageWriter< DiffusionPixelType >::Pointer dwiwriter = + mitk::NrrdDiffusionImageWriter< DiffusionPixelType >::New(); + + dwiwriter->SetInput( dwimage ); + dwiwriter->SetFileName( argv[2] ); + + try + { + dwiwriter->Update(); + } + catch( const itk::ExceptionObject& e) + { + MITK_ERROR << "Catched exception: " << e.what(); + mitkThrow() << "Failed with exception from subprocess!"; + } + + MITK_TEST_END(); +}