diff --git a/12_UnitTesting/code/CMakeLists.txt b/12_UnitTesting/code/CMakeLists.txt index 5a1988f..73edd9e 100644 --- a/12_UnitTesting/code/CMakeLists.txt +++ b/12_UnitTesting/code/CMakeLists.txt @@ -14,7 +14,7 @@ INCLUDE( ${ITK_USE_FILE} ) ADD_EXECUTABLE( ${EXE_NAME} ${PROJECT_SOURCE_DIR}/src/BasicApp.h - ${PROJECT_SOURCE_DIR}/src/cbicaITKWriteImage.h + ${PROJECT_SOURCE_DIR}/src/cbicaITKSafeImageIO.h ${PROJECT_SOURCE_DIR}/src/cbicaUtilities.h ${PROJECT_SOURCE_DIR}/src/cbicaUtilities.cpp ${PROJECT_SOURCE_DIR}/src/cbicaCmdParser.h diff --git a/12_UnitTesting/code/src/cbicaCmdParser.cpp b/12_UnitTesting/code/src/cbicaCmdParser.cpp index 2f6f578..df0fdb7 100644 --- a/12_UnitTesting/code/src/cbicaCmdParser.cpp +++ b/12_UnitTesting/code/src/cbicaCmdParser.cpp @@ -51,7 +51,7 @@ static const char cSeparator = '/'; #include #include #include "cbicaCmdParser.h" -#include "yaml-cpp/yaml.h" +//#include "yaml-cpp/yaml.h" #ifndef PROJECT_VERSION #define PROJECT_VERSION "0.0.1" diff --git a/12_UnitTesting/code/src/cbicaITKSafeImageIO.h b/12_UnitTesting/code/src/cbicaITKSafeImageIO.h index f95707e..31bdfd6 100644 --- a/12_UnitTesting/code/src/cbicaITKSafeImageIO.h +++ b/12_UnitTesting/code/src/cbicaITKSafeImageIO.h @@ -25,8 +25,8 @@ See COPYING file or https://www.cbica.upenn.edu/sbia/software/license.html #include "itkNiftiImageIO.h" #include "itkGDCMImageIO.h" #include "itkGDCMSeriesFileNames.h" -#include "itkDCMTKImageIO.h" -#include "itkDCMTKSeriesFileNames.h" +//#include "itkDCMTKImageIO.h" +//#include "itkDCMTKSeriesFileNames.h" #include "itkNumericSeriesFileNames.h" #include "itkOrientImageFilter.h" #include "itkChangeInformationImageFilter.h" @@ -39,8 +39,8 @@ See COPYING file or https://www.cbica.upenn.edu/sbia/software/license.html #endif #include "cbicaUtilities.h" -#include "cbicaITKImageInfo.h" -#include "cbicaITKUtilities.h" +//#include "cbicaITKImageInfo.h" +//#include "cbicaITKUtilities.h" using ImageTypeFloat3D = itk::Image< float, 3 >; using TImageType = ImageTypeFloat3D; @@ -160,90 +160,90 @@ namespace cbica return reader; } - /** - \brief Returns the unique series IDs in the specified directory - - The check is only done on the DICOM tag provided, so if there are series with the same UID information (but are indeed different images), - this function will not able to handle it. - - \param dirName The directory in question - \param tagToCheck The tag on the basis of which the test is done; defaults to "0x0020|0x00E" - \return Vector of Series UIDs and fileName collection pairs, with each fileName collection corresponding to a UID - */ - std::vector< std::pair< std::string , std::vector< std::string > > > GetDICOMSeriesAndFilesInDir(const std::string &dirName, - const std::string tagToCheck = "0x0020|0x00E") - { - std::vector< - std::pair< - std::string, // this is the series UID information - std::vector< std::string > > // these are the fileNames corresponding to each UID - > returnVector; - - auto dirName_wrap = cbica::normPath(dirName); - auto allFilesInDir = cbica::filesInDirectory(dirName_wrap); - - // initialize the returnVector with the first series UID and fileName - returnVector.push_back( - std::make_pair(cbica::GetDICOMTagValue(allFilesInDir[0], tagToCheck), // get the first series UID - std::vector< std::string >({ allFilesInDir[0] }) // construct a initial vector - )); - - std::vector< std::string > volumeSeries; - const std::string volumeSeriesTag = "0x0018|0x1030"; - volumeSeries.push_back(cbica::GetDICOMTagValue(allFilesInDir[0], volumeSeriesTag)); - - // looping through all the found files - for (size_t i = 1; i < allFilesInDir.size(); i++) - { - auto temp = cbica::GetDICOMTagValue(allFilesInDir[i], tagToCheck); - auto temp_volSeries = cbica::GetDICOMTagValue(allFilesInDir[i], volumeSeriesTag); - - bool newUIDFound = true; - for (size_t j = 0; j < returnVector.size(); j++) - { - if (returnVector[j].first == temp) - { - bool newVolSeriesFound = true; - for (size_t k = 0; k < volumeSeries.size(); k++) - { - if (volumeSeries[k] == temp_volSeries) - { - newVolSeriesFound = false; - } - } - if (!newVolSeriesFound) - { - returnVector[j].second.push_back(allFilesInDir[i]); - newUIDFound = false; - break; - } - else - { - volumeSeries.push_back(temp_volSeries); // the new volume has same series UID information so nothing changes there - } - } - } - if (newUIDFound) - { - // add a new seriesUID-fileNames pair - returnVector.push_back( - std::make_pair(temp, // this is the UID - std::vector< std::string >({ allFilesInDir[i] }) // first filename corresponding to the UID - )); - } - } - - return returnVector; - - //// this implementation takes a *lot* of time - //auto dicomIO = itk::DCMTKImageIO::New(); - //auto inputNames = itk::DCMTKSeriesFileNames::New(); - //inputNames->SetInputDirectory(dirName_wrap); - //inputNames->SetLoadPrivateTags(true); - //auto UIDs = inputNames->GetSeriesUIDs(); // this is the primary bottle-neck, I think because it does checks on multiple different things - - //return cbica::GetUniqueElements< std::string >(UIDs); - } + ///** + //\brief Returns the unique series IDs in the specified directory + + //The check is only done on the DICOM tag provided, so if there are series with the same UID information (but are indeed different images), + //this function will not able to handle it. + + //\param dirName The directory in question + //\param tagToCheck The tag on the basis of which the test is done; defaults to "0x0020|0x00E" + //\return Vector of Series UIDs and fileName collection pairs, with each fileName collection corresponding to a UID + //*/ + //std::vector< std::pair< std::string , std::vector< std::string > > > GetDICOMSeriesAndFilesInDir(const std::string &dirName, + // const std::string tagToCheck = "0x0020|0x00E") + //{ + // std::vector< + // std::pair< + // std::string, // this is the series UID information + // std::vector< std::string > > // these are the fileNames corresponding to each UID + // > returnVector; + + // auto dirName_wrap = cbica::normPath(dirName); + // auto allFilesInDir = cbica::filesInDirectory(dirName_wrap); + // + // // initialize the returnVector with the first series UID and fileName + // returnVector.push_back( + // std::make_pair(cbica::GetDICOMTagValue(allFilesInDir[0], tagToCheck), // get the first series UID + // std::vector< std::string >({ allFilesInDir[0] }) // construct a initial vector + // )); + + // std::vector< std::string > volumeSeries; + // const std::string volumeSeriesTag = "0x0018|0x1030"; + // volumeSeries.push_back(cbica::GetDICOMTagValue(allFilesInDir[0], volumeSeriesTag)); + + // // looping through all the found files + // for (size_t i = 1; i < allFilesInDir.size(); i++) + // { + // auto temp = cbica::GetDICOMTagValue(allFilesInDir[i], tagToCheck); + // auto temp_volSeries = cbica::GetDICOMTagValue(allFilesInDir[i], volumeSeriesTag); + + // bool newUIDFound = true; + // for (size_t j = 0; j < returnVector.size(); j++) + // { + // if (returnVector[j].first == temp) + // { + // bool newVolSeriesFound = true; + // for (size_t k = 0; k < volumeSeries.size(); k++) + // { + // if (volumeSeries[k] == temp_volSeries) + // { + // newVolSeriesFound = false; + // } + // } + // if (!newVolSeriesFound) + // { + // returnVector[j].second.push_back(allFilesInDir[i]); + // newUIDFound = false; + // break; + // } + // else + // { + // volumeSeries.push_back(temp_volSeries); // the new volume has same series UID information so nothing changes there + // } + // } + // } + // if (newUIDFound) + // { + // // add a new seriesUID-fileNames pair + // returnVector.push_back( + // std::make_pair(temp, // this is the UID + // std::vector< std::string >({ allFilesInDir[i] }) // first filename corresponding to the UID + // )); + // } + // } + + // return returnVector; + + // //// this implementation takes a *lot* of time + // //auto dicomIO = itk::DCMTKImageIO::New(); + // //auto inputNames = itk::DCMTKSeriesFileNames::New(); + // //inputNames->SetInputDirectory(dirName_wrap); + // //inputNames->SetLoadPrivateTags(true); + // //auto UIDs = inputNames->GetSeriesUIDs(); // this is the primary bottle-neck, I think because it does checks on multiple different things + + // //return cbica::GetUniqueElements< std::string >(UIDs); + //} /** \brief Get the Dicom image reader (not the image, the READER). This is useful for scenarios where reader meta information is needed for later writing step(s). diff --git a/12_UnitTesting/code/src/cbicaUtilities.cpp b/12_UnitTesting/code/src/cbicaUtilities.cpp index 98b4779..e4f0613 100644 --- a/12_UnitTesting/code/src/cbicaUtilities.cpp +++ b/12_UnitTesting/code/src/cbicaUtilities.cpp @@ -68,7 +68,7 @@ static const char cSeparator = '/'; #include #include "cbicaUtilities.h" -#include "yaml-cpp/yaml.h" +//#include "yaml-cpp/yaml.h" namespace cbica { @@ -518,30 +518,30 @@ namespace cbica */ } - bool IsCompatible(const std::string inputVersionFile) - { - auto config = YAML::LoadFile(inputVersionFile); + //bool IsCompatible(const std::string inputVersionFile) + //{ + // auto config = YAML::LoadFile(inputVersionFile); - auto currentCollectionVersion = std::stoi(cbica::replaceString(config["Version"].as< std::string >().c_str(), ".", "").c_str()); - auto minimumVersion = std::stoi(cbica::replaceString(config["Minimum"].as< std::string >().c_str(), ".", "").c_str()); - auto maximumVersion = std::stoi(cbica::replaceString(config["Maximum"].as< std::string >().c_str(), ".", "").c_str()); - auto currentPackageVersion = std::stoi(cbica::replaceString(std::string(PROJECT_VERSION), ".", "").c_str()); + // auto currentCollectionVersion = std::stoi(cbica::replaceString(config["Version"].as< std::string >().c_str(), ".", "").c_str()); + // auto minimumVersion = std::stoi(cbica::replaceString(config["Minimum"].as< std::string >().c_str(), ".", "").c_str()); + // auto maximumVersion = std::stoi(cbica::replaceString(config["Maximum"].as< std::string >().c_str(), ".", "").c_str()); + // auto currentPackageVersion = std::stoi(cbica::replaceString(std::string(PROJECT_VERSION), ".", "").c_str()); - if (currentPackageVersion == currentCollectionVersion) - { - return true; - } - if (currentPackageVersion < minimumVersion) - { - return false; - } - if (currentPackageVersion > maximumVersion) - { - return false; - } + // if (currentPackageVersion == currentCollectionVersion) + // { + // return true; + // } + // if (currentPackageVersion < minimumVersion) + // { + // return false; + // } + // if (currentPackageVersion > maximumVersion) + // { + // return false; + // } - return true; - } + // return true; + //} size_t getFolderSize(const std::string &rootFolder) { diff --git a/12_UnitTesting/code/src/cbicaUtilities.h b/12_UnitTesting/code/src/cbicaUtilities.h index 3d199c9..5774598 100644 --- a/12_UnitTesting/code/src/cbicaUtilities.h +++ b/12_UnitTesting/code/src/cbicaUtilities.h @@ -354,12 +354,12 @@ namespace cbica */ size_t getFileSize(const std::string &inputFile); - /* - \brief Checks for the compatibility with the current project + ///* + //\brief Checks for the compatibility with the current project - \param inputVersionFile The version file (in YAML) that contains the compatibility information - */ - bool IsCompatible(const std::string inputVersionFile); + //\param inputVersionFile The version file (in YAML) that contains the compatibility information + //*/ + //bool IsCompatible(const std::string inputVersionFile); /** \brief Get the size of the folder diff --git a/12_UnitTesting/code/testing/CMakeLists.txt b/12_UnitTesting/code/testing/CMakeLists.txt index 1111c31..d682327 100644 --- a/12_UnitTesting/code/testing/CMakeLists.txt +++ b/12_UnitTesting/code/testing/CMakeLists.txt @@ -13,7 +13,7 @@ ADD_EXECUTABLE( ${TEST_EXE_NAME} testExe.cxx ${PROJECT_SOURCE_DIR}/src/BasicApp.h - ${PROJECT_SOURCE_DIR}/src/cbicaITKWriteImage.h + ${PROJECT_SOURCE_DIR}/src/cbicaITKSafeImageIO.h ${PROJECT_SOURCE_DIR}/src/cbicaUtilities.h ${PROJECT_SOURCE_DIR}/src/cbicaUtilities.cpp ${PROJECT_SOURCE_DIR}/src/cbicaCmdParser.h diff --git a/12_UnitTesting/code/testing/testExe.cxx b/12_UnitTesting/code/testing/testExe.cxx index 573c8d5..22fc819 100644 --- a/12_UnitTesting/code/testing/testExe.cxx +++ b/12_UnitTesting/code/testing/testExe.cxx @@ -9,7 +9,7 @@ #include "cbicaCmdParser.h" #include "cbicaUtilities.h" -#include "cbicaITKWriteImage.h" +#include "cbicaITKSafeImageIO.h" #include "BasicApp.h"