// Open a file for reading
void clitk::openFileForReading(std::ifstream & is, const std::string & filename)
{
- is.open(filename.c_str(), std::ios::in);
+ is.open(filename.c_str(), std::ios::in | std::ios::binary);
if ( is.fail() ) {
clitkExceptionMacro("Could not open file for reading: "
<< filename << ". Error is : <"
std::ostringstream ossDD; \
ossDD << #a " = [ " << a << " ]" << std::endl; \
OutputDebugString(ossDD.str().c_str()); \
+ std::cout << ossDD.str() << std::endl; \
}
#else
# define DD(a) std::cout << #a " = [ " << a << " ]" << std::endl;std::cout.flush();
exit 1
fi
-########## CT #########
-list_pattern=""
+list_prefix=""
list_phase_file=`find $1 -maxdepth 1 -iname "*[0-9]*.mhd"`
for phase_file in $list_phase_file
do
phase_file_name=`basename $phase_file`
- if [[ ! -z `echo "$phase_file_name" | grep ","` ]]
+ if [[ ! -z `echo "$phase_file_name" | grep "__[0-9]"` ]]
then
- prefix=`echo $phase_file_name | sed "s/,_.*/,_/"`
+ prefix=`echo $phase_file_name | sed "s/__[0-9].*/__/"`
else
- prefix="NONE"
+ if [[ ! -z `echo "$phase_file_name" | grep "[0-9]-.*\]"` ]]
+ then
+ if [[ ! -z `echo "$phase_file_name" | grep "[0-9][0-9]-.*\]"` ]]
+ then
+ prefix=`echo $phase_file_name | sed "s/[0-9][0-9]-.*//"`
+ else
+ prefix=`echo $phase_file_name | sed "s/[0-9]-.*//"`
+ fi
+ else
+ prefix="NONE"
+ fi
fi
- if [[ -z `echo "$list_pattern" | grep "$prefix"` ]]
- then
- list_pattern="$list_pattern $prefix"
- fi
-done
-
-for pattern in $list_pattern
-do
-
- if [ "$pattern" = "NONE" ]
+ if [[ -z `echo "$list_prefix" | grep "$prefix"` ]]
then
- pattern=""
+ list_prefix="$list_prefix $prefix"
fi
-
- nbph=`find $1 -maxdepth 1 -iname "${pattern}*[0-9]*.mhd" | wc -l`
- orig=`find $1 -maxdepth 1 -iname "${pattern}*[0-9]*.mhd" | sort | head -n 1`
- listph=`find $1 -maxdepth 1 -iname "${pattern}*[0-9]*.raw" | sort`
-
- file_name_4D="${pattern}_4D.mhd"
- echo $file_name_4D
-
- write_mhd_4D $1
-
done
-############ PET ###########
-
-list_pattern=""
-list_phase_file=`find $1 -maxdepth 1 -iname "*[0-9]*\]*.mhd"`
-for phase_file in $list_phase_file
+for prefix in $list_prefix
do
- phase_file_name=`basename $phase_file`
- if [[ ! -z `echo "$phase_file_name" | grep "[0-9]-.*\]"` ]]
- then
- prefix=`echo $phase_file_name | sed "s/.*[0-9]-/-/;s/\]_.*//"`
- else
- prefix="NONE"
- fi
- if [[ -z `echo "$list_pattern" | grep -- "$prefix"` ]]
+ if [ "$prefix" = "NONE" ]
then
- list_pattern="$list_pattern $prefix"
+ prefix=""
fi
-done
-
-for pattern in $list_pattern
-do
-
- if [ "$pattern" = "NONE" ]
- then
- pattern=""
- fi
+ list_suffix=""
+ list_phase_file_prefix=`find $1 -maxdepth 1 -iname "${prefix}[0-9]*.mhd"`
+ for phase_file_prefix in $list_phase_file_prefix
+ do
+ phase_file_prefix_name=`basename $phase_file_prefix`
+ if [[ ! -z `echo "$phase_file_prefix_name" | grep "__[0-9]"` ]]
+ then
+ suffix="NONE"
+ else
+ if [[ ! -z `echo "$phase_file_prefix_name" | grep "[0-9]-.*\]"` ]]
+ then
+ suffix=`echo $phase_file_prefix_name | sed "s/.*[0-9]-//;s/_\.mhd//;s/\.mhd//"`
+ else
+ suffix="NONE"
+ fi
+ fi
+
+ if [[ -z `echo "$list_suffix" | grep "$suffix"` ]]
+ then
+ list_suffix="$list_suffix $suffix"
+ fi
+ done
- nbph=`find $1 -maxdepth 1 -iname "*[0-9]${pattern}\]*.mhd" | wc -l`
- orig=`find $1 -maxdepth 1 -iname "*[0-9]${pattern}\]*.mhd" | sort | head -n 1`
- listph=`find $1 -maxdepth 1 -iname "*[0-9]${pattern}\]*.raw" | sort`
-
- file_name_4D=`basename "$orig" | sed "s/[0-9]${pattern}\]/${pattern}\]/;s/_.mhd/_4D.mhd/"`
+ for suffix in $list_suffix
+ do
+ if [ "$suffix" = "NONE" ]
+ then
+ suffix=""
+ fi
+ nbph=`find $1 -maxdepth 1 -iname "*${prefix}*[0-9]*${suffix}*.mhd" | wc -l`
+ orig=`find $1 -maxdepth 1 -iname "*${prefix}*[0-9]*${suffix}*.mhd" | sort | head -n 1`
+ listph=`find $1 -maxdepth 1 -iname "*${prefix}*[0-9]*${suffix}*.raw" | sort`
+
+ file_name_4D="${prefix}4D${suffix}.mhd"
+
+ write_mhd_4D $1
- write_mhd_4D $1
+ done
done
+
ADD_TEST(clitkGetDirection_3d ${exe} clitkGetDirection -i ${p}Lung3D.mhd ${p}Lung3D_ref.direction)
#=========================================================
# clitkBinarize
-ADD_TEST(clitkBinarizeBGl0.1356_4d ${exe} clitkBinarizeImage -i ${p}Deformation4D.mhd --mode BG -l 0.1356 -o Deformation4D_ref.binarizeBGl0.1356.mhd ${p}Deformation4D_ref.binarizeBGl0.1356)
-ADD_TEST(clitkBinarizeFGl0.1556_3d ${exe} clitkBinarizeImage -i ${p}Lung3D.mhd --mode FG -l 0.1556 -o Lung3D_ref.binarizeFGl0.1556.mhd ${p}Lung3D_ref.binarizeFGl0.1556)
+ADD_TEST(clitkBinarizeBGl0.1356_4d ${exe} clitkBinarizeImage -i ${p}Deformation4D.mhd --mode BG -l 0.1356 -o Deformation4D_ref.binarizeBGl0.1356.mhd ${p}Deformation4D_ref.binarizeBGl0.1356.mhd)
+ADD_TEST(clitkBinarizeFGl0.1556_3d ${exe} clitkBinarizeImage -i ${p}Lung3D.mhd --mode FG -l 0.1556 -o Lung3D_ref.binarizeFGl0.1556.mhd ${p}Lung3D_ref.binarizeFGl0.1556.mhd)
#=========================================================
# clitkImageArithm
ADD_TEST(clitkImageArithm0_3d ${exe} clitkImageArithm -i ${p}Lung3D.mhd -j ${p}Lung3D.mhd -t 0 -o Lung3D_ref.arithm0.mhd ${p}Lung3D_ref.arithm0.mhd)
ADD_TEST(clitkMorphoMath3_4d ${exe} clitkMorphoMath -i ${p}Deformation4D.mhd -o Deformation4D_ref.morphoMath.t3.mhd ${p}Deformation4D_ref.morphoMath.t3.mhd)
ADD_TEST(clitkMorphoMath4_4d ${exe} clitkMorphoMath -i ${p}Deformation4D.mhd -o Deformation4D_ref.morphoMath.t4.mhd ${p}Deformation4D_ref.morphoMath.t4.mhd)
ADD_TEST(clitkMorphoMath5_4d ${exe} clitkMorphoMath -i ${p}Deformation4D.mhd -o Deformation4D_ref.morphoMath.t5.mhd ${p}Deformation4D_ref.morphoMath.t5.mhd)
-
-
#=========================================================
-
-
+#clitkSetBackground
+ADD_TEST(clitkSetBackground_4d ${exe} clitkSetBackground -i ${p}Deformation4D.mhd -o Deformation4D_ref.setBackground.mhd ${p}Deformation4D_ref.setBackground.mhd)
+ADD_TEST(clitkSetBackground_3d ${exe} clitkSetBackground -i ${p}Lung3D.mhd -o Lung3D_ref.setBackground.mhd ${p}Lung3D_ref.setBackground.mhd)
exit(1);
}
}
+bool isLineToIgnore(const std::string line){
+ if(std::string::npos == line.find_first_of("ITK_InputFilterName")){
+ return true;
+ }
+ return false;
+}
+bool mhdCmp(const std::string &file, const std::string &refFile){
+ bool sameFiles = true;
+ std::ifstream in(file.c_str());
+ std::ifstream ref(file.c_str());
+ std::string line;
+ std::string refLine;
+ while ( in.good() && ref.good()){
+ getline (in,line);
+ //does the line begins by an attribute to ignore
+ if(isLineToIgnore(line)){
+ continue;
+ }
+
+ getline(ref,refLine);
+ while(isLineToIgnore(refLine)){
+ getline(ref,refLine);
+ }
+ if(line!=refLine){
+ sameFiles = false;
+ break;
+ }
+ }
+ in.close();
+ ref.close();
+ //check files same length
+ return sameFiles;
+}
#ifdef _WIN32
void dosToUnixFile(std::string dosFile, std::string unixedFile){
std::string unixedOutFile= getTmpFileName();
//replace \r\n
dosToUnixFile(outFile, unixedOutFile);
- assertFalse((itksys::SystemTools::FilesDiffer(unixedOutFile.c_str(), refFile)), "Generated mhd file != ref File");
+ assertFalse(!mhdCmp(unixedOutFile, refFile), "Generated mhd file != ref File");
remove(unixedOutFile.c_str());
#else
- assertFalse((itksys::SystemTools::FilesDiffer(outFile.c_str(), refFile)), "Generated mhd file != ref File");
+ assertFalse(!mhdCmp(outFile.c_str(), refFile), "Generated mhd file != ref File");
#endif
std::string refRawFile = mhdToRawName(strRefFile);
</property>
</widget>
</item>
- <item row="0" column="1">
+ <item row="0" column="1" colspan="5">
<widget class="QLabel" name="dataFusionnedLabel">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
</property>
</widget>
</item>
- <item row="1" column="0" colspan="2">
+ <item row="1" column="0" colspan="3">
<widget class="QLabel" name="opacityLabel">
<property name="text">
<string>Global Opacity :</string>
</property>
</widget>
</item>
- <item row="1" column="3" colspan="3">
+ <item row="1" column="3" colspan="2">
<widget class="QSlider" name="opacityHorizontalSlider">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
</property>
</widget>
</item>
- <item row="1" column="6">
+ <item row="1" column="5">
<widget class="QDoubleSpinBox" name="fusionOpacitySpin">
<property name="decimals">
<number>2</number>
</property>
</widget>
</item>
- <item row="2" column="3" colspan="3">
+ <item row="2" column="3" colspan="2">
<widget class="QSlider" name="thresOpacityHorizontalSlider">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
</property>
</widget>
</item>
- <item row="2" column="6">
+ <item row="2" column="5">
<widget class="QDoubleSpinBox" name="fusionThresSpin">
<property name="decimals">
<number>2</number>
</item>
</widget>
</item>
- <item row="4" column="0" colspan="2">
+ <item row="4" column="0">
<widget class="QLabel" name="label_7">
<property name="text">
<string>Window :</string>
</property>
</widget>
</item>
- <item row="4" column="2" colspan="2">
+ <item row="4" column="1" colspan="2">
<widget class="QDoubleSpinBox" name="fusionWindowSpinBox">
<property name="decimals">
<number>4</number>
</property>
</widget>
</item>
- <item row="4" column="4">
+ <item row="4" column="3">
<widget class="QLabel" name="label_8">
<property name="text">
<string>Level :</string>
</property>
</widget>
</item>
- <item row="4" column="5" colspan="2">
+ <item row="4" column="4" colspan="2">
<widget class="QDoubleSpinBox" name="fusionLevelSpinBox">
<property name="decimals">
<number>4</number>