]> Creatis software - clitk.git/commitdiff
Merge branch 'master' of /home/dsarrut/clitk3.server
authorDavid Sarrut <david.sarrut@creatis.insa-lyon.fr>
Wed, 28 Sep 2011 05:47:18 +0000 (07:47 +0200)
committerDavid Sarrut <david.sarrut@creatis.insa-lyon.fr>
Wed, 28 Sep 2011 05:47:18 +0000 (07:47 +0200)
common/clitkCommon.cxx
common/clitkDD.h
scripts/create_mhd_4D.sh
tests/tools/CMakeLists.txt
tests/tools/toolTestRunner.cxx
vv/qt_ui/vvOverlayPanel.ui

index 785b0fd2c021ad087dd500a68ba0d03a60481b65..10f608e6ce8b7ba7c92d6085f4d1b1588a047e3d 100644 (file)
@@ -243,7 +243,7 @@ double clitk::ComputeEuclideanDistanceFromPointToPlane(const itk::ContinuousInde
 // 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 : <" 
index f43db9d005d9ef9d98f4b6ca4dc66bb5713b8b66..c21bb815acbc080e97f3adfd9b844c934209292e 100644 (file)
@@ -29,6 +29,7 @@
     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();
index bc51da445d06389ab8a1347495d680b566d4c892..5b602446bd3b038081cf91834c663c4d0eaf6b74 100755 (executable)
@@ -35,80 +35,81 @@ then
   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
+
index 5e1165b1900180ad44c1e481758cdfdcf2fe1ae8..c87899ac5c953156697dbc2513454e28cffa16df 100644 (file)
@@ -41,8 +41,8 @@ ADD_TEST(clitkGetDirection_4d ${exe} clitkGetDirection -i ${p}Deformation4D.mhd
 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)
@@ -73,11 +73,10 @@ ADD_TEST(clitkMorphoMath2_4d ${exe} clitkMorphoMath -i ${p}Deformation4D.mhd -o
 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)
 
 
 
index a4795ee8781fc1e6d4e73fb4b71bf55024a1019e..753aa37bcef992c0bccf53ff922ae6c3724aab86 100644 (file)
@@ -57,6 +57,39 @@ void assertFalse(int fail, const std::string &message=""){
     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){
@@ -124,10 +157,10 @@ int main(int argc, char** argv){
        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);
index ef00277a607422d80eada75b340040ef3b86c5ed..1a6e5b81398e9671e854aaa1c33367027c48c0c0 100644 (file)
@@ -422,7 +422,7 @@ p, li { white-space: pre-wrap; }
         </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">
@@ -435,14 +435,14 @@ p, li { white-space: pre-wrap; }
         </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">
@@ -455,7 +455,7 @@ p, li { white-space: pre-wrap; }
         </property>
        </widget>
       </item>
-      <item row="1" column="6">
+      <item row="1" column="5">
        <widget class="QDoubleSpinBox" name="fusionOpacitySpin">
         <property name="decimals">
          <number>2</number>
@@ -490,7 +490,7 @@ p, li { white-space: pre-wrap; }
         </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">
@@ -503,7 +503,7 @@ p, li { white-space: pre-wrap; }
         </property>
        </widget>
       </item>
-      <item row="2" column="6">
+      <item row="2" column="5">
        <widget class="QDoubleSpinBox" name="fusionThresSpin">
         <property name="decimals">
          <number>2</number>
@@ -567,14 +567,14 @@ p, li { white-space: pre-wrap; }
         </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>
@@ -593,14 +593,14 @@ p, li { white-space: pre-wrap; }
         </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>