-set(CTEST_PROJECT_NAME "vv_itk4")
-set(CTEST_NIGHTLY_START_TIME "1:00:00 UTC")
+MACRO(SET_IF_NOT_SET var val)
+ IF(NOT DEFINED "${var}")
+ SET("${var}" "${val}")
+ ENDIF(NOT DEFINED "${var}")
+ENDMACRO(SET_IF_NOT_SET)
+# Set them in a dart file when using ctest to submit on an other dashboard
+# Those are set for running a classical make Experimental
+SET_IF_NOT_SET(CTEST_DROP_METHOD "http")
+SET_IF_NOT_SET(CTEST_DROP_SITE "my.cdash.org")
+SET_IF_NOT_SET(CTEST_DROP_LOCATION "/submit.php?project=VV")
+SET_IF_NOT_SET(CTEST_DROP_SITE_CDASH TRUE)
+SET_IF_NOT_SET(CTEST_PROJECT_NAME "vv_itk4")
+SET_IF_NOT_SET(CTEST_NIGHTLY_START_TIME "1:00:00 UTC")
-set(CTEST_DROP_METHOD "http")
-set(CTEST_DROP_SITE "www.cdash.org")
-set(CTEST_DROP_LOCATION "/CDash/submit.php?project=Insight")
-set(CTEST_DROP_SITE_CDASH TRUE)
+#=========================================================
+SET(CLITK_TEST_DATA_PATH ${PROJECT_BINARY_DIR}/tests/data/ CACHE INTERNAL DOCSTRING)
\ No newline at end of file
+++ /dev/null
-# This file is configured by CMake automatically as DartConfiguration.tcl
-# If you choose not to use CMake, this file may be hand configured, by
-# filling in the required variables.
-
-
-# Configuration directories and files
-SourceDirectory: /home/mpech/workspace/vvSource
-BuildDirectory: /home/mpech/workspace/vvSource
-
-# Where to place the cost data store
-CostDataFile:
-
-# Site is something like machine.domain, i.e. pragmatic.crd
-Site: russule
-
-# Build name is osname-revision-compiler, i.e. Linux-2.4.2-2smp-c++
-BuildName: Linux-c++
-
-# Submission information
-IsCDash: TRUE
-CDashVersion:
-QueryCDashVersion:
-DropSite: localhost
-DropLocation: /cdash/submit.php?project=vv
-DropSiteUser:
-DropSitePassword:
-DropSiteMode:
-DropMethod: http
-TriggerSite:
-ScpCommand: /usr/bin/scp
-
-# Dashboard start time
-NightlyStartTime: 00:00:00 EST
-
-# Commands for the build/test/submit cycle
-ConfigureCommand: "/usr/bin/cmake" "/home/mpech/workspace/vvSource"
-MakeCommand: /usr/bin/gmake -i
-DefaultCTestConfigurationType: Release
-
-# CVS options
-# Default is "-d -P -A"
-CVSCommand: /usr/bin/cvs
-CVSUpdateOptions: -d -A -P
-
-# Subversion options
-SVNCommand: /usr/bin/svn
-SVNUpdateOptions:
-
-# Git options
-GITCommand: /usr/bin/git
-GITUpdateOptions:
-GITUpdateCustom:
-
-# Generic update command
-UpdateCommand: /usr/bin/git
-UpdateOptions:
-UpdateType: git
-
-# Compiler info
-Compiler: /usr/bin/c++
-
-# Dynamic analysis and coverage
-PurifyCommand:
-ValgrindCommand:
-ValgrindCommandOptions:
-MemoryCheckCommand: MEMORYCHECK_COMMAND-NOTFOUND
-MemoryCheckCommandOptions:
-MemoryCheckSuppressionFile:
-CoverageCommand: /usr/bin/gcov
-
-# Cluster commands
-SlurmBatchCommand: SLURM_SBATCH_COMMAND-NOTFOUND
-SlurmRunCommand: SLURM_SRUN_COMMAND-NOTFOUND
-
-# Testing options
-# TimeOut is the amount of time in seconds to wait for processes
-# to complete during testing. After TimeOut seconds, the
-# process will be summarily terminated.
-# Currently set to 25 minutes
-TimeOut: 1500
-
-UseLaunchers:
-CurlOptions:
-# warning, if you add new options here that have to do with submit,
-# you have to update cmCTestSubmitCommand.cxx
-
-# For CTest submissions that timeout, these options
-# specify behavior for retrying the submission
-CTestSubmitRetryDelay: 5
-CTestSubmitRetryCount: 3
option "lower" - "Initial lower threshold" double no
option "upper" - "Initial upper threshold" double no default="-300"
+option "openingRadius" - "Radius for opening after threshold" int no default="0"
section "First Label Image (air=1)"
itkSetMacro(LowerThreshold, InputImagePixelType);
itkGetMacro(LowerThreshold, InputImagePixelType);
- itkSetMacro(UseLowerThreshold, bool);
+ itkSetMacro(UseLowerThreshold, bool);
+ itkGetMacro(PrimaryOpeningRadius, unsigned int);
+ itkSetMacro(PrimaryOpeningRadius, unsigned int);
itkGetConstMacro(UseLowerThreshold, bool);
itkBooleanMacro(UseLowerThreshold);
bool m_DecomposeAndReconstructDuringFirstStep;
bool m_DecomposeAndReconstructDuringSecondStep;
bool m_FinalOpenClose;
+ unsigned m_PrimaryOpeningRadius;
InternalImageSizeType m_Radius1;
InternalImageSizeType m_Radius2;
int m_MaximumNumberOfLabels1;
this->SetNumberOfRequiredInputs(1);
SetBackgroundValue(0); // Must be zero
SetForegroundValue(1);
+ SetPrimaryOpeningRadius(0);
// Step 1: Threshold + CC + sort (Find low density areas)
SetUpperThreshold(-300);
binarizeFilter->SetUpperThreshold(GetUpperThreshold());
binarizeFilter ->SetInsideValue(this->GetForegroundValue());
binarizeFilter ->SetOutsideValue(this->GetBackgroundValue());
+ working_image = binarizeFilter->GetOutput();
+ typedef itk::BinaryBallStructuringElement<InternalPixelType,Dim> KernelType;
+ unsigned int radius = this->GetPrimaryOpeningRadius();
+ if (radius > 0)
+ {
+ if (this->GetVerboseOptionFlag()) std::cout << ("Opening after threshold; R = ") << radius << std::endl;
+ KernelType kernel;
+ kernel.SetRadius(radius);
+
+ typedef itk::BinaryMorphologicalOpeningImageFilter<InternalImageType, InternalImageType , KernelType> OpenFilterType2;
+ typename OpenFilterType2::Pointer openFilter2 = OpenFilterType2::New();
+ openFilter2->SetInput(working_image);
+ openFilter2->SetBackgroundValue(0);
+ openFilter2->SetForegroundValue(1);
+ openFilter2->SetKernel(kernel);
+ openFilter2->Update();
+ working_image = openFilter2->GetOutput();
+ }
+
+ if (this->GetVerboseOptionFlag()) std::cout << ("Labelling") << std::endl;
// Connected component labeling
typedef itk::ConnectedComponentImageFilter<InternalImageType, InternalImageType> ConnectFilterType;
typename ConnectFilterType::Pointer connectFilter=ConnectFilterType::New();
- connectFilter->SetInput(binarizeFilter->GetOutput());
+ connectFilter->SetInput(working_image);
connectFilter->SetBackgroundValue(this->GetBackgroundValue());
connectFilter->SetFullyConnected(false);
+ connectFilter->Update();
+ if (this->GetVerboseOptionFlag()) std::cout << ("RelabelComponentImageFilter") << std::endl;
// Sort labels according to size
typedef itk::RelabelComponentImageFilter<InternalImageType, InternalImageType> RelabelFilterType;
typename RelabelFilterType::Pointer relabelFilter=RelabelFilterType::New();
//--------------------------------------------------------------------
//--------------------------------------------------------------------
+ if (this->GetVerboseOptionFlag()) std::cout << ("Remove the air (largest area)") << std::endl;
StartNewStep("Remove the air (largest area)");
typedef itk::BinaryThresholdImageFilter<InternalImageType, InternalImageType> iBinarizeFilterType;
typename iBinarizeFilterType::Pointer binarizeFilter2 = iBinarizeFilterType::New();
if (GetFinalOpenClose()) {
StartNewStep("Final OpenClose");
// Open
- typedef itk::BinaryBallStructuringElement<InternalPixelType,Dim> KernelType;
KernelType structuringElement;
structuringElement.SetRadius(1);
structuringElement.CreateStructuringElement();
f->SetUpperThreshold(mArgsInfo.upper_arg);
f->SetLowerThreshold(mArgsInfo.lower_arg);
+ f->SetPrimaryOpeningRadius(mArgsInfo.openingRadius_arg);
f->SetDecomposeAndReconstructDuringFirstStep(mArgsInfo.erode1_flag);
cmake_policy(SET CMP0005 NEW)
#=========================================================
+
+#=========================================================
+# Data tests path
+ADD_DEFINITIONS(-DCLITK_TEST_DATA_PATH=\"${CLITK_TEST_DATA_PATH}/\")
+#=========================================================
+#=========================================================
# Google test macro
macro(ADD_GOOGLE_TESTS executable)
-message(exe : ${executable})
foreach ( source ${ARGN} )
file(READ "${source}" contents)
string(REGEX MATCHALL "TEST_?F?\\(([A-Za-z_0-9 ,]+)\\)" found_tests ${contents})
SET(BUILDNAME ${CMAKE_SYSTEM_NAME}${CMAKE_OSX_ARCHITECTURES} CACHE INTERNAL DOCSTRING)
#=========================================================
#=========================================================
-# Data tests path
-FIND_PATH(CLITK_DATA_PATH data)
-ADD_DEFINITIONS(-DCLITK_DATA_PATH=\"${CLITK_DATA_PATH}\")
-#=========================================================
-#=========================================================
# GoogleTest framemwork
FIND_PATH(GTEST_DIR gtest)
INCLUDE_DIRECTORIES(${GTEST_DIR}/include/)
--- /dev/null
+# take in arguments the folder to pull in
+# get repo's name
+# run git pull
--- /dev/null
+#!/bin/sh
+#
+# arg[1] is TESTING_BINARY_DIR
+# This script has been edited from itk/Modules/ThirdParty/NIFTI/src/nifti/Testing/nifti_regress_test/cmake_testscripts/fetch_data_test.sh
+if cd $1
+then
+ git pull
+else
+ git clone $2 $1
+fi
+exit 0
+
${GTEST_DIR}/include
)
-FILE(GLOB srcs *.cxx)
-ADD_EXECUTABLE(toolsTest ${srcs})
-ADD_DEFINITIONS(-DTOOLS_PATH=\"${PROJECT_BINARY_DIR}/bin/\")
-target_link_libraries(toolsTest vvLib ${vvExternalLibs} gtest)
+SET (CUSTOM_TEST_SRC
+ clitkImageInfoTest.cxx
+ vvMainTest.cxx
+)
+ADD_EXECUTABLE(toolsTest ${CUSTOM_TEST_SRC})
+ADD_DEFINITIONS(-DCLITK_TEST_TOOLS_PATH=\"${PROJECT_BINARY_DIR}/bin/\")
+TARGET_LINK_LIBRARIES(toolsTest vvLib ${vvExternalLibs} gtest)
# Add all tests found in the source code, calling the executable to run them
add_google_tests ( ${EXECUTABLE_OUTPUT_PATH}/toolsTest ${srcs})
-SET(BUILDNAME ${BUILDNAME}_tools CACHE INTERNAL DOCSTRING)
\ No newline at end of file
+SET(BUILDNAME ${BUILDNAME}_tools CACHE INTERNAL DOCSTRING)
+
+SET (srcs
+ toolTestRunner.cxx
+)
+ADD_EXECUTABLE(toolTestRunner ${srcs})
+TARGET_LINK_LIBRARIES(toolTestRunner vvLib ${vvExternalLibs})
+SET(exe ${EXECUTABLE_OUTPUT_PATH}/toolTestRunner)
+SET(p ${CLITK_TEST_DATA_PATH})
+#=========================================================
+# clitkImageInfo
+ADD_TEST(clitkImageInfo_1 ${exe} clitkImageInfo ${p}Deformation4D.mhd ${p}Deformation4D_ref.info)
+ADD_TEST(clitkImageInfo_2 ${exe} clitkImageInfo ${p}Lung3D.mhd ${p}Lung3D_ref.info)
+#=========================================================
+# clitkGetSpacing
+ADD_TEST(clitkGetSpacing_1 ${exe} clitkGetSpacing ${p}Deformation4D.mhd ${p}Deformation4D_ref.spacing)
+ADD_TEST(clitkGetSpacing_2 ${exe} clitkGetSpacing ${p}Lung3D.mhd ${p}Deformation4D_ref.spacing)
+UNSET(exe)
+UNSET(p)
\ No newline at end of file
#include <itksys/SystemTools.hxx>
static inline void compare(std::string mhd, std::string refMhd, std::string refRaw){
std::ostringstream cmd_line;
+
+ //Ensure the description file exists
ASSERT_TRUE(itksys::SystemTools::FileExists(mhd.c_str(), true));
+
+ //Ensure the description reference file exists
ASSERT_TRUE(itksys::SystemTools::FileExists(refMhd.c_str(), true));
+
+ //Ensure our reference raw exists
ASSERT_TRUE(itksys::SystemTools::FileExists(refRaw.c_str(), true));
+//todo : test this on windows
+ //Generate the new mhd and the new raw
cmd_line << TOOLS_PATH<<"clitkAffineTransform -i " << mhd << " -o "<<"out.mhd >/dev/null";
system(cmd_line.str().c_str());
+
+ //Check the new file has been created
EXPECT_TRUE(itksys::SystemTools::FileExists("out.mhd", true));
+
+ //Check the mhd and the produced mhd are still equal
EXPECT_FALSE( itksys::SystemTools::FilesDiffer("out.mhd", refMhd.c_str()) );
- EXPECT_FALSE( itksys::SystemTools::FilesDiffer("out.raw", refRaw.c_str()) );
+
+ //Check the raw and the produced raw are different
+ EXPECT_TRUE( itksys::SystemTools::FilesDiffer("out.raw", refRaw.c_str()) );
+
+ //clean the produced junk
remove("out.mhd");
remove("out.raw");
}
-TEST(clitkAffineTransformTest, main){
- std::string mhd1=std::string(CLITK_DATA_PATH)+"Deformation4D.mhd";
- std::string refMhd1=std::string(CLITK_DATA_PATH)+"Deformation4DRef.mhd";
- std::string refRaw1=std::string(CLITK_DATA_PATH)+"Deformation4DRef.raw";
+TEST(identity, clitkAffineTransformTest){
+ std::string mhd1=std::string(CLITK_TEST_DATA_PATH)+"Deformation4D.mhd";
+ std::string refMhd1=std::string(CLITK_TEST_DATA_PATH)+"Deformation4DRef.mhd";
+ std::string refRaw1=std::string(CLITK_TEST_DATA_PATH)+"Deformation4DRef.raw";
compare(mhd1, refMhd1, refRaw1);
}
\ No newline at end of file
remove("clitkImageInfoTest.out");
}
TEST(clitkImageInfoTest, main){
- std::string mhd1=std::string(CLITK_DATA_PATH)+"Deformation4D.mhd";
+ std::string mhd1=std::string(CLITK_TEST_DATA_PATH)+"Deformation4D.mhd";
ASSERT_TRUE(itksys::SystemTools::FileExists(mhd1.c_str(), true));
- std::string mhd2=std::string(CLITK_DATA_PATH)+"Lung3D.mhd";
+ std::string mhd2=std::string(CLITK_TEST_DATA_PATH)+"Lung3D.mhd";
ASSERT_TRUE(itksys::SystemTools::FileExists(mhd2.c_str(), true));
mhd1+=" "+mhd2;
- std::string ref1=std::string(CLITK_DATA_PATH)+"clitkImageInfoTestRef.out";
+ std::string ref1=std::string(CLITK_TEST_DATA_PATH)+"clitkImageInfoTestRef.out";
ASSERT_TRUE(itksys::SystemTools::FileExists(ref1.c_str(), true));
compare(mhd1, ref1);
}
\ No newline at end of file
--- /dev/null
+/*=========================================================================
+ Program: vv http://www.creatis.insa-lyon.fr/rio/vv
+
+ Authors belong to:
+ - University of LYON http://www.universite-lyon.fr/
+ - Léon Bérard cancer center http://www.centreleonberard.fr
+ - CREATIS CNRS laboratory http://www.creatis.insa-lyon.fr
+
+ This software is distributed WITHOUT ANY WARRANTY; without even
+ the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+ PURPOSE. See the copyright notices for more information.
+
+ It is distributed under dual licence
+
+ - BSD See included LICENSE.txt file
+ - CeCILL-B http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
+===========================================================================*/
+#include <iostream>
+#include <sstream>
+#include <string>
+#include <fstream>
+#include <stdio.h>
+#include <stdlib.h>
+#include <itksys/SystemTools.hxx>
+int main(int argc, char** argv){
+ int fail = 1;
+ std::string mhd = std::string(CLITK_TEST_DATA_PATH);
+ std::string ref = std::string(CLITK_TEST_DATA_PATH);
+
+ //We select which image we use to test clitkImageInfo
+ int idImg = atoi(argv[1]);
+ switch(idImg){
+ case '0':
+ mhd += "Deformation4D.mhd";
+ ref += "clitkImageInfoTestRef";
+ break;
+ case '1':
+ mhd += "Lung3D.mhd";
+ ref += "clitkImageInfoTestRef";
+ break;
+ default:
+ return fail;
+ }
+ //end of selection
+
+ //ensure mhd do exist
+ if(!itksys::SystemTools::FileExists(mhd.c_str(), true)){
+ return fail;
+ }
+ //ensure ref do exist
+ if(!itksys::SystemTools::FileExists(ref.c_str(), true)){
+ return fail;
+ }
+
+ std::ostringstream cmd_line;
+ cmd_line << TOOLS_PATH <<"clitkImageInfo " << mhd << " > clitkImageInfoTest.out";
+ system(cmd_line.str().c_str());
+
+ //files should be equal, so if this is the case return success=0
+ fail = (itksys::SystemTools::FilesDiffer("clitkImageInfoTest.out", ref.c_str()))?0:1;
+ remove("clitkImageInfoTest.out");
+ return fail;
+}
#include <itksys/SystemTools.hxx>
TEST(clitkWriteDicomSeriesTest, main){
- std::string fIn=std::string(CLITK_DATA_PATH)+"/3d/mhd/00.mhd";
- std::string fOut=std::string(CLITK_DATA_PATH)+"/3d/dcm/1.2.840.113704.1.111.536.1248695032.26";
+ std::string fIn=std::string(CLITK_TEST_DATA_PATH)+"/3d/mhd/00.mhd";
+ std::string fOut=std::string(CLITK_TEST_DATA_PATH)+"/3d/dcm/1.2.840.113704.1.111.536.1248695032.26";
ASSERT_TRUE(itksys::SystemTools::FileExists(fIn.c_str(), true));
std::ostringstream cmd_line;
cmd_line << TOOLS_PATH <<"clitkWriteDicomSeries -i " << fIn << " -d " << fOut << " -o dcm --verbose";
--- /dev/null
+/*=========================================================================
+ Program: vv http://www.creatis.insa-lyon.fr/rio/vv
+
+ Authors belong to:
+ - University of LYON http://www.universite-lyon.fr/
+ - Léon Bérard cancer center http://www.centreleonberard.fr
+ - CREATIS CNRS laboratory http://www.creatis.insa-lyon.fr
+
+ This software is distributed WITHOUT ANY WARRANTY; without even
+ the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+ PURPOSE. See the copyright notices for more information.
+
+ It is distributed under dual licence
+
+ - BSD See included LICENSE.txt file
+ - CeCILL-B http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
+===========================================================================*/
+#include <iostream>
+#include <sstream>
+#include <string>
+#include <fstream>
+#include <stdio.h>
+#include <stdlib.h>
+#include <itksys/SystemTools.hxx>
+const int NO_OUTPUT_OPTION=-1;
+int getOutputOptionIndex(int argc, char** argv){
+ for(int i=1; i<argc; i++){
+ std::string s = argv[i];
+ if(s=="-o"){
+ return i+1;
+ }
+ }
+ return NO_OUTPUT_OPTION;
+}
+inline char* getTmpFileName(){
+ char buffer [L_tmpnam];
+ char* back = tmpnam (buffer);
+ if(back==NULL){
+ exit(1);
+ }
+ return back;
+}
+/**
+ * argv
+ * [1] executable
+ * [2] random options
+ * [2.x] -o
+ * [2.x+1] outFileName
+ * [3] reference file
+ *
+ * [2.x] and [2.x+1] are optional
+ */
+int main(int argc, char** argv){
+ //reference file must exist or we fail
+ char* refFile = argv[argc-1];
+ if(!(itksys::SystemTools::FileExists(refFile, true))){
+ std::cout<<"refFile "<<refFile<<" doesn't exist"<<std::endl;
+ return 1;
+ }
+
+ std::ostringstream cmd_line;
+ cmd_line<<CLITK_TEST_TOOLS_PATH;
+ for(int i=1; i<argc-1; i++){
+ //we should ensure the file exists, find an -i index or a long file name maybe?
+ cmd_line<<argv[i]<<" ";
+ }
+
+ //look for the need of generating an output file
+ int outputOptionIndex = getOutputOptionIndex(argc, argv);
+ char* outFile;
+ if(NO_OUTPUT_OPTION==outputOptionIndex){
+ outFile = getTmpFileName();
+ cmd_line<<" > "<<outFile;
+ }else{
+ //todo test this else branch
+ std::string s = std::string(CLITK_TEST_DATA_PATH);
+ s+=argv[outputOptionIndex];
+ //DO NOT MODIFY outFile
+ outFile = (char*)s.c_str();
+ }
+
+ //run the command line
+ system(cmd_line.str().c_str());
+
+ //files should be equal, so if this is the case return success=0
+ int fail = (itksys::SystemTools::FilesDiffer(outFile, refFile))?1:0;
+ remove(outFile);
+ return fail;
+}
#include "vvConfiguration.h"
#include <stdio.h>
#include <fstream>
-const std::string data_path = CLITK_DATA_PATH;
+const std::string data_path = CLITK_TEST_DATA_PATH;
TEST(vvRegisterForm, canPush){
QUrl url;
//the file exists with some old lines