Skip to content

Commit

Permalink
compiling properly now
Browse files Browse the repository at this point in the history
  • Loading branch information
sarthakpati committed Aug 22, 2018
1 parent 31bf2ee commit 93a7385
Show file tree
Hide file tree
Showing 7 changed files with 119 additions and 119 deletions.
2 changes: 1 addition & 1 deletion 12_UnitTesting/code/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion 12_UnitTesting/code/src/cbicaCmdParser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ static const char cSeparator = '/';
#include <algorithm>
#include <string>
#include "cbicaCmdParser.h"
#include "yaml-cpp/yaml.h"
//#include "yaml-cpp/yaml.h"

#ifndef PROJECT_VERSION
#define PROJECT_VERSION "0.0.1"
Expand Down
176 changes: 88 additions & 88 deletions 12_UnitTesting/code/src/cbicaITKSafeImageIO.h
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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;
Expand Down Expand Up @@ -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).
Expand Down
44 changes: 22 additions & 22 deletions 12_UnitTesting/code/src/cbicaUtilities.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ static const char cSeparator = '/';
#include <thread>

#include "cbicaUtilities.h"
#include "yaml-cpp/yaml.h"
//#include "yaml-cpp/yaml.h"

namespace cbica
{
Expand Down Expand Up @@ -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)
{
Expand Down
10 changes: 5 additions & 5 deletions 12_UnitTesting/code/src/cbicaUtilities.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion 12_UnitTesting/code/testing/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion 12_UnitTesting/code/testing/testExe.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

#include "cbicaCmdParser.h"
#include "cbicaUtilities.h"
#include "cbicaITKWriteImage.h"
#include "cbicaITKSafeImageIO.h"

#include "BasicApp.h"

Expand Down

0 comments on commit 93a7385

Please sign in to comment.