diff --git a/testing/apps/VoxelizerTool/VoxelizerToolDifferentCommandsTest.cpp b/testing/apps/VoxelizerTool/VoxelizerToolDifferentCommandsTest.cpp index 363bfeb..c328469 100644 --- a/testing/apps/VoxelizerTool/VoxelizerToolDifferentCommandsTest.cpp +++ b/testing/apps/VoxelizerTool/VoxelizerToolDifferentCommandsTest.cpp @@ -1,130 +1,121 @@ // ----------------------------------------------------------------------- // RTToolbox - DKFZ radiotherapy quantitative evaluation library // // Copyright (c) German Cancer Research Center (DKFZ), // Software development for Integrated Diagnostics and Therapy (SIDT). // ALL RIGHTS RESERVED. // See rttbCopyright.txt or // http://www.dkfz.de/en/sidt/projects/rttb/copyright.html // // This software is distributed WITHOUT ANY WARRANTY; without even // the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // PURPOSE. See the above copyright notices for more information. // //------------------------------------------------------------------------ #include "litCheckMacros.h" #include #include #include "itkImage.h" #include "itkImageFileReader.h" #include /*! @brief VoxelizerToolTest3. Test the output, multipleStructs and the booleanVoxelization parameter. */ namespace rttb { namespace testing { //path to the current running directory. VoxelizerTool is in the same directory (Debug/Release) extern const char* _callingAppPath; int VoxelizerToolDifferentCommandsTest(int argc, char* argv[]) { PREPARE_DEFAULT_TEST_REPORTING; typedef itk::Image< double, 3 > ImageType; typedef itk::ImageFileReader ReaderType; std::string voxelizerToolExe; std::string tempDirectory; std::string structFile; std::string referenceFile; if (argc > 4) { voxelizerToolExe = argv[1]; tempDirectory = argv[2]; structFile = argv[3]; referenceFile = argv[4]; } std::vector commands; commands.push_back("\"Niere.*\" -m -o Test.nrrd"); - commands.push_back("\"Rueckenmark\" -o BooleanNRRD -z"); + commands.push_back("\"Rueckenmark\" -o Boolean.nrrd -z"); std::vector filenames; filenames.push_back("Test_Niere li"); filenames.push_back("Test_Niere re"); filenames.push_back("Boolean"); std::vector > voxelsToTestInside; std::vector > voxelsToTestOutside; voxelsToTestInside.push_back(std::make_pair(ImageType::IndexType{ 48, 31, 18 }, 1.0)); //Niere li inside voxelsToTestOutside.push_back(std::make_pair(ImageType::IndexType{ 19, 31, 18 }, 0.0)); //Niere li outside voxelsToTestInside.push_back(std::make_pair(ImageType::IndexType{ 19, 31, 18 }, 1.0)); //Niere re inside voxelsToTestOutside.push_back(std::make_pair(ImageType::IndexType{ 48, 31, 18 }, 0.0)); //Niere re outside voxelsToTestInside.push_back(std::make_pair(ImageType::IndexType{ 35, 32, 30 }, 1.0)); //Rueckenmark inside voxelsToTestOutside.push_back(std::make_pair(ImageType::IndexType{ 35, 30, 23 }, 0.0)); //Rueckenmark outside boost::filesystem::path callingPath(_callingAppPath); std::string voxelizerToolExeWithPath = callingPath.parent_path().string() + "/" + voxelizerToolExe; std::string baseCommand = voxelizerToolExeWithPath; baseCommand += " -s \"" + structFile + "\""; baseCommand += " -r \"" + referenceFile + "\""; baseCommand += " -e "; for (size_t i = 0; i < commands.size(); i++) { std::string command = baseCommand + commands.at(i); int returnValue = system(command.c_str()); std::cout << "Command line call: " + command << std::endl; CHECK_EQUAL(returnValue, 0); } for (size_t i = 0; i < filenames.size(); i++) { const std::string NRRDfileName = tempDirectory + "/" + filenames.at(i) + ".nrrd"; boost::filesystem::path NRRDFile(NRRDfileName); - const std::string IMGfileName = tempDirectory + "/" + filenames.at(i) + ".img"; - boost::filesystem::path IMGFile(IMGfileName); - CHECK_EQUAL(boost::filesystem::exists(NRRDFile), true); - CHECK_EQUAL(boost::filesystem::exists(IMGFile), true); - - //check voxel values - if (boost::filesystem::exists(NRRDFile)) - { - ReaderType::Pointer reader = ReaderType::New(); - reader->SetFileName(NRRDfileName); - reader->Update(); - ReaderType::OutputImageType::ConstPointer image = reader->GetOutput(); + //check voxel values + if (boost::filesystem::exists(NRRDFile)) + { + ReaderType::Pointer reader = ReaderType::New(); + reader->SetFileName(NRRDfileName); + reader->Update(); - ImageType::PixelType voxelValueInside = image->GetPixel(voxelsToTestInside.at(i).first); - ImageType::PixelType expectedVoxelValueInside = voxelsToTestInside.at(i).second; - CHECK_EQUAL(voxelValueInside, expectedVoxelValueInside); + ReaderType::OutputImageType::ConstPointer image = reader->GetOutput(); - ImageType::PixelType voxelValueOutside = image->GetPixel(voxelsToTestOutside.at(i).first); - ImageType::PixelType expectedVoxelValueOutside = voxelsToTestOutside.at(i).second; - CHECK_EQUAL(voxelValueOutside, expectedVoxelValueOutside); - } + ImageType::PixelType voxelValueInside = image->GetPixel(voxelsToTestInside.at(i).first); + ImageType::PixelType expectedVoxelValueInside = voxelsToTestInside.at(i).second; + CHECK_EQUAL(voxelValueInside, expectedVoxelValueInside); - if (boost::filesystem::exists(IMGFile)) - { - boost::filesystem::remove(IMGFile); + ImageType::PixelType voxelValueOutside = image->GetPixel(voxelsToTestOutside.at(i).first); + ImageType::PixelType expectedVoxelValueOutside = voxelsToTestOutside.at(i).second; + CHECK_EQUAL(voxelValueOutside, expectedVoxelValueOutside); } if (boost::filesystem::exists(NRRDFile)) { boost::filesystem::remove(NRRDFile); } } RETURN_AND_REPORT_TEST_SUCCESS; } } } diff --git a/testing/apps/VoxelizerTool/VoxelizerToolVoxelValueTest.cpp b/testing/apps/VoxelizerTool/VoxelizerToolVoxelValueTest.cpp index eb09188..9aa7d19 100644 --- a/testing/apps/VoxelizerTool/VoxelizerToolVoxelValueTest.cpp +++ b/testing/apps/VoxelizerTool/VoxelizerToolVoxelValueTest.cpp @@ -1,127 +1,120 @@ // ----------------------------------------------------------------------- // RTToolbox - DKFZ radiotherapy quantitative evaluation library // // Copyright (c) German Cancer Research Center (DKFZ), // Software development for Integrated Diagnostics and Therapy (SIDT). // ALL RIGHTS RESERVED. // See rttbCopyright.txt or // http://www.dkfz.de/en/sidt/projects/rttb/copyright.html // // This software is distributed WITHOUT ANY WARRANTY; without even // the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // PURPOSE. See the above copyright notices for more information. // //------------------------------------------------------------------------ #include "litCheckMacros.h" #include #include "itkImage.h" #include "itkImageFileReader.h" #include #include /*! @brief VoxelizerToolTest5. Search the coordinate at the Image and return the Voxel(Pixel) value. */ namespace rttb { namespace testing { //path to the current running directory. VoxelizerTool is in the same directory (Debug/Release) extern const char* _callingAppPath; int VoxelizerToolVoxelValue(int argc, char* argv[]) { PREPARE_DEFAULT_TEST_REPORTING; typedef itk::Image< double, 3 > ImageType; typedef itk::ImageFileReader ReaderType; std::string voxelizerToolExe; std::string tempDirectory; std::string structFile; std::string referenceFile; std::string structName; if (argc > 5) { voxelizerToolExe = argv[1]; tempDirectory = argv[2]; structFile = argv[3]; referenceFile = argv[4]; structName = argv[5]; } boost::filesystem::path callingPath(_callingAppPath); std::string voxelizerToolExeWithPath = callingPath.parent_path().string() + "/" + voxelizerToolExe; std::string command = voxelizerToolExeWithPath; command += " -s \"" + structFile + "\""; command += " -r \"" + referenceFile + "\""; command += " -e " + structName; command += " -o testOutputVoxelValue.nrrd"; int returnValue = system(command.c_str()); CHECK_EQUAL(returnValue, 0); //image values taken in Mevislab //Index inside ImageType::IndexType voxelInside1 = {{20, 30, 30}}; ImageType::IndexType voxelInside2 = {{30, 10, 40}}; //Outside index ImageType::IndexType voxelOutside1 = {{40, 30, 30}}; ImageType::IndexType voxelOutside2 = {{10, 40, 30}}; //Border index ImageType::IndexType voxelBorder1 = {{12, 23, 27}}; ImageType::IndexType voxelBorder2 = {{34, 21, 31}}; std::vector voxelIndices = boost::assign::list_of(voxelInside1)(voxelInside2)( voxelOutside1)( voxelOutside2)(voxelBorder1)(voxelBorder2); std::vector expectedVoxelValues = boost::assign::list_of(1.0)(1.0)(0.0)(0.0)( 0.265865)(0.819613); std::string filenameNRRDWithVoxelization = tempDirectory + "/testOutputVoxelValue.nrrd"; - std::string filenameIMGWithVoxelization = tempDirectory + "/testOutputVoxelValue.img"; CHECK(boost::filesystem::exists(filenameNRRDWithVoxelization)); - CHECK(boost::filesystem::exists(filenameIMGWithVoxelization)); if (boost::filesystem::exists(filenameNRRDWithVoxelization)) { ReaderType::Pointer reader = ReaderType::New(); reader->SetFileName(filenameNRRDWithVoxelization); reader->Update(); ReaderType::OutputImageType::ConstPointer image = reader->GetOutput(); for (size_t i = 0; i < voxelIndices.size(); i++) { ImageType::PixelType voxelValue = image->GetPixel(voxelIndices.at(i)); ImageType::PixelType expectedVoxelValue = expectedVoxelValues.at(i); if (expectedVoxelValue == 0.0 || expectedVoxelValue == 1.0) { CHECK_EQUAL(voxelValue, expectedVoxelValue); } else { CHECK_CLOSE(voxelValue, expectedVoxelValue, 1e-4); } } boost::filesystem::remove(filenameNRRDWithVoxelization); - - if (boost::filesystem::exists(filenameIMGWithVoxelization)) - { - boost::filesystem::remove(filenameIMGWithVoxelization); - } } RETURN_AND_REPORT_TEST_SUCCESS; } } } diff --git a/testing/apps/VoxelizerTool/VoxelizerToolVoxelizerAllStructsTest.cpp b/testing/apps/VoxelizerTool/VoxelizerToolVoxelizerAllStructsTest.cpp index 69e887b..43c8f22 100644 --- a/testing/apps/VoxelizerTool/VoxelizerToolVoxelizerAllStructsTest.cpp +++ b/testing/apps/VoxelizerTool/VoxelizerToolVoxelizerAllStructsTest.cpp @@ -1,98 +1,86 @@ // ----------------------------------------------------------------------- // RTToolbox - DKFZ radiotherapy quantitative evaluation library // // Copyright (c) German Cancer Research Center (DKFZ), // Software development for Integrated Diagnostics and Therapy (SIDT). // ALL RIGHTS RESERVED. // See rttbCopyright.txt or // http://www.dkfz.de/en/sidt/projects/rttb/copyright.html // // This software is distributed WITHOUT ANY WARRANTY; without even // the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // PURPOSE. See the above copyright notices for more information. // //------------------------------------------------------------------------ #include #include "litCheckMacros.h" #include #include /*! @brief VoxelizerToolTest. Tests a selection of structs. */ namespace rttb { namespace testing { //path to the current running directory. VoxelizerTool is in the same directory (Debug/Release) extern const char* _callingAppPath; int VoxelizerToolVoxelizerAllStructsTest(int argc, char* argv[]) { PREPARE_DEFAULT_TEST_REPORTING; std::string voxelizerToolExe; std::string tempDirectory; std::string structFile; std::string referenceFile; if (argc > 4) { voxelizerToolExe = argv[1]; tempDirectory = argv[2]; structFile = argv[3]; referenceFile = argv[4]; } boost::filesystem::path callingPath(_callingAppPath); std::string voxelizerToolExeWithPath = callingPath.parent_path().string() + "/" + voxelizerToolExe; std::vector structNames; structNames.push_back("Niere.*"); structNames.push_back("Magen/DD"); structNames.push_back("PTV"); std::string baseCommand = voxelizerToolExeWithPath; baseCommand += " -s \"" + structFile + "\""; baseCommand += " -r \"" + referenceFile + "\""; baseCommand += " -o outputAllStructs.nrrd"; baseCommand += " -e \""; for (size_t i = 0; i < structNames.size(); i++) { std::string command = baseCommand + structNames.at(i) + "\""; std::cout << "Command line call: " + command << std::endl; int returnValue = system(command.c_str()); CHECK_EQUAL(returnValue, 0); boost::filesystem::path NRRDFile(tempDirectory); NRRDFile /= "outputAllStructs.nrrd"; - boost::filesystem::path IMGFile(tempDirectory); - IMGFile /= "outputAllStructs.img"; - CHECK_EQUAL( boost::filesystem::exists(NRRDFile), true); - CHECK_EQUAL( - boost::filesystem::exists(IMGFile), - true); - - - if (boost::filesystem::exists(IMGFile)) - { - boost::filesystem::remove(IMGFile); - } if (boost::filesystem::exists(NRRDFile)) { boost::filesystem::remove(NRRDFile); } } RETURN_AND_REPORT_TEST_SUCCESS; } } } diff --git a/testing/apps/VoxelizerTool/VoxelizerToolVoxelizerStructTest.cpp b/testing/apps/VoxelizerTool/VoxelizerToolVoxelizerStructTest.cpp index 686f4fe..6b787b7 100644 --- a/testing/apps/VoxelizerTool/VoxelizerToolVoxelizerStructTest.cpp +++ b/testing/apps/VoxelizerTool/VoxelizerToolVoxelizerStructTest.cpp @@ -1,98 +1,88 @@ // ----------------------------------------------------------------------- // RTToolbox - DKFZ radiotherapy quantitative evaluation library // // Copyright (c) German Cancer Research Center (DKFZ), // Software development for Integrated Diagnostics and Therapy (SIDT). // ALL RIGHTS RESERVED. // See rttbCopyright.txt or // http://www.dkfz.de/en/sidt/projects/rttb/copyright.html // // This software is distributed WITHOUT ANY WARRANTY; without even // the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // PURPOSE. See the above copyright notices for more information. // //------------------------------------------------------------------------ #include #include "litCheckMacros.h" #include /*! @brief VoxelizerToolTest. Tests a struct with multiple files and a single file */ namespace rttb { namespace testing { //path to the current running directory. VoxelizerTool is in the same directory (Debug/Release) extern const char* _callingAppPath; int VoxelizerToolVoxelizerStructTest(int argc, char* argv[]) { PREPARE_DEFAULT_TEST_REPORTING; std::string voxelizerToolExe; std::string tempDirectory; std::string structFile; std::string referenceFile; boost::filesystem::path NRRDFile(tempDirectory); NRRDFile /= "outputSingleStruct.nrrd"; - boost::filesystem::path IMGFile(tempDirectory); - IMGFile /= "outputSingleStruct.img"; - if (argc > 4) { voxelizerToolExe = argv[1]; tempDirectory = argv[2]; structFile = argv[3]; referenceFile = argv[4]; } boost::filesystem::path callingPath(_callingAppPath); std::string voxelizerToolExeWithPath = callingPath.parent_path().string() + "/" + voxelizerToolExe; std::string structName = "Heart"; std::string baseCommand = voxelizerToolExeWithPath; baseCommand += " -s \"" + structFile + "\""; baseCommand += " -r \"" + referenceFile + "\""; baseCommand += " -o outputSingleStruct.nrrd"; baseCommand += " -y itkDicom"; baseCommand += " -e \""; std::string command = baseCommand + structName + "\""; std::cout << "Command line call: " + command << std::endl; int returnValue = system(command.c_str()); CHECK_EQUAL(returnValue, 0); CHECK_EQUAL(boost::filesystem::exists(NRRDFile), true); - CHECK_EQUAL(boost::filesystem::exists(IMGFile), true); - - baseCommand = voxelizerToolExeWithPath; baseCommand += " -s \"" + structFile + "\""; baseCommand += " -r \"" + NRRDFile.string() + "\""; baseCommand += " -o outputSingleStruct.nrrd"; baseCommand += " -y itk"; baseCommand += " -e \""; command = baseCommand + structName + "\""; std::cout << "Command line call: " + command << std::endl; returnValue = system(command.c_str()); CHECK_EQUAL(returnValue, 0); - if (boost::filesystem::exists(IMGFile)) { - boost::filesystem::remove(IMGFile); - } - if (boost::filesystem::exists(NRRDFile)) { boost::filesystem::remove(NRRDFile); } RETURN_AND_REPORT_TEST_SUCCESS; } } }