[pubgit-commits-list] Clitk branch master updated. v1.2.0-625-g82029e7

root root at tux.creatis.insa-lyon.fr
Tue Jan 24 14:53:18 CET 2012


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "Clitk".

The branch, master has been updated
       via  82029e7928db0cb8c17273c6da1c95314b1593c6 (commit)
       via  5be83a695bafa815cca85e180c0070e30020fa4c (commit)
      from  75d074a4caf86e1c036bc7879557a1600ad0ceac (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
http://git.creatis.insa-lyon.fr/pubgit/?p=clitk.git;a=commitdiff;h=82029e7928db0cb8c17273c6da1c95314b1593c6

commit 82029e7928db0cb8c17273c6da1c95314b1593c6
Author: Romulo Pinho <romulo.pinho at lyon.unicancer.fr>
Date:   Tue Jan 24 14:50:43 2012 +0100

    more robust clitkExtractLung
    
    - quits with exception when no seed is found for trachea

diff --git a/segmentation/clitkExtractLungFilter.txx b/segmentation/clitkExtractLungFilter.txx
index 41e7967..8dcdb5b 100644
--- a/segmentation/clitkExtractLungFilter.txx
+++ b/segmentation/clitkExtractLungFilter.txx
@@ -259,6 +259,9 @@ GenerateOutputInformation()
   StartNewStep("Search for the trachea");
   SearchForTrachea();
   PrintMemory(GetVerboseMemoryFlag(), "After SearchForTrachea");
+  if (m_Seeds.empty()) {
+    clitkExceptionMacro("No seeds for trachea... Aborting.");
+  }
 
   //--------------------------------------------------------------------
   //--------------------------------------------------------------------
@@ -766,6 +769,11 @@ SearchForTracheaSeed2(int numberOfSlices)
         
         prev_e_centre= max_e_centre;
       }
+      else {
+        if (GetVerboseRegionGrowingFlag()) {
+          cout << "No shapes found at slice " << index[2] << std::endl;
+        }
+      }
     }
     
     size_t longest = 0;
@@ -778,9 +786,11 @@ SearchForTracheaSeed2(int numberOfSlices)
       }
     }
     
-    if (GetVerboseRegionGrowingFlag()) 
-      std::cout << "seed at: " << trachea_centre << std::endl;
-    m_Seeds.push_back(trachea_centre);
+    if (longest > 0) {
+      if (GetVerboseRegionGrowingFlag()) 
+        std::cout << "seed at: " << trachea_centre << std::endl;
+      m_Seeds.push_back(trachea_centre);
+    }
   }
   
   return (m_Seeds.size() != 0);
@@ -892,16 +902,17 @@ SearchForTrachea()
             std::cout << "\t Found trachea with volume " << volume << " cc." << std::endl;
           }
         }
-        else {
-          if (GetVerboseStepFlag()) {
-            std::cout << "\t The volume of the trachea (" << volume 
-                      << " cc) seems not correct. I skip some slices (" << skip << ") and restart to find seeds." 
-                      << std::endl;
-          }
-          skip += 5;
-          stop = false;
-          // empty the list of seed
-          m_Seeds.clear();
+        else 
+          if (GetTracheaSeedAlgorithm() == 0) {
+            if (GetVerboseStepFlag()) {
+              std::cout << "\t The volume of the trachea (" << volume 
+                        << " cc) seems not correct. I skip some slices (" << skip << ") and restart to find seeds." 
+                        << std::endl;
+            }
+            skip += 5;
+            stop = false;
+            // empty the list of seed
+            m_Seeds.clear();
         }
         if (skip > 0.5 * working_input->GetLargestPossibleRegion().GetSize()[2]) {
           // we want to skip more than a half of the image, it is probably a bug

http://git.creatis.insa-lyon.fr/pubgit/?p=clitk.git;a=commitdiff;h=5be83a695bafa815cca85e180c0070e30020fa4c

commit 5be83a695bafa815cca85e180c0070e30020fa4c
Author: Romulo Pinho <romulo.pinho at lyon.unicancer.fr>
Date:   Thu Jan 19 17:51:00 2012 +0100

    refactoring...
    
    - Put coeff to dvf function in separate file, as a global function
    - Changed affected files/classes

diff --git a/common/clitkCoeffsToDVF.h b/common/clitkCoeffsToDVF.h
new file mode 100644
index 0000000..0fe30bb
--- /dev/null
+++ b/common/clitkCoeffsToDVF.h
@@ -0,0 +1,86 @@
+/*=========================================================================
+  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
+===========================================================================**/
+#ifndef clitkCoeffsToDVF_h
+#define clitkCoeffsToDVF_h
+
+#include "clitkBSplineDeformableTransform.h"
+#if ITK_VERSION_MAJOR >= 4
+#include "itkTransformToDisplacementFieldSource.h"
+#else
+#include "itkTransformToDeformationFieldSource.h"
+#endif
+
+//-------------------------------------------------------------------
+// Convert Coefficient image to DVF
+//-------------------------------------------------------------------
+template<class DisplacementFieldType>
+typename DisplacementFieldType::Pointer
+CoeffsToDVF(std::string fileName, std::string likeFileName, bool verbose = false)
+{
+  typedef clitk::BSplineDeformableTransform<double, DisplacementFieldType::ImageDimension, DisplacementFieldType::ImageDimension> TransformType;
+  typedef typename TransformType::CoefficientImageType CoefficientImageType;
+
+  typedef itk::ImageFileReader<CoefficientImageType> CoeffReaderType;
+  typename CoeffReaderType::Pointer reader = CoeffReaderType::New();
+  reader->SetFileName(fileName);
+  reader->Update();
+
+  typename TransformType::Pointer transform = TransformType::New();
+  transform->SetCoefficientImage(reader->GetOutput());
+  
+#if ITK_VERSION_MAJOR >= 4
+      typedef itk::TransformToDisplacementFieldSource<DisplacementFieldType, double> ConvertorType;
+#else
+      typedef itk::TransformToDeformationFieldSource<DisplacementFieldType, double> ConvertorType;
+#endif
+
+  typedef itk::ImageIOBase ImageIOType;
+  typename ImageIOType::Pointer imageIO = itk::ImageIOFactory::CreateImageIO(likeFileName.c_str(), itk::ImageIOFactory::ReadMode);
+  imageIO->SetFileName(likeFileName);
+  imageIO->ReadImageInformation();
+
+  typename ConvertorType::Pointer convertor= ConvertorType::New();
+  typename ConvertorType::SizeType output_size;
+  typename ConvertorType::SpacingType output_spacing;
+  typename ConvertorType::OriginType output_origin;
+  typename ConvertorType::DirectionType output_direction;
+  for (unsigned int i = 0; i < DisplacementFieldType::ImageDimension; i++) {
+    output_size[i] = imageIO->GetDimensions(i);
+    output_spacing[i] = imageIO->GetSpacing(i);
+    output_origin[i] = imageIO->GetOrigin(i);
+    for (unsigned int j = 0; j < DisplacementFieldType::ImageDimension; j++)
+      output_direction[i][j] = imageIO->GetDirection(i)[j];
+  }
+  
+  if (verbose) {
+    std::cout << "Interpolating coefficients with grid:" << std::endl;
+    std::cout << output_size << output_spacing << std::endl;
+  }
+  
+  convertor->SetNumberOfThreads(1);
+  convertor->SetTransform(transform);
+  convertor->SetOutputOrigin(output_origin);
+  convertor->SetOutputSpacing(output_spacing);
+  convertor->SetOutputSize(output_size);
+  convertor->SetOutputDirection(output_direction);
+  convertor->Update();
+
+  return convertor->GetOutput();
+}
+
+#endif
diff --git a/tools/clitkComposeVFGenericFilter.h b/tools/clitkComposeVFGenericFilter.h
index b86f22b..4d9d9f5 100644
--- a/tools/clitkComposeVFGenericFilter.h
+++ b/tools/clitkComposeVFGenericFilter.h
@@ -67,7 +67,6 @@ namespace clitk
     //Templated members
     template<unsigned int Dimension> void UpdateWithDim(std::string PixelType);
     template<unsigned int Dimension, class PixelType> void UpdateWithDimAndPixelType(); 
-    template<class DisplacementFieldType> typename DisplacementFieldType::Pointer CoeffsToDVF(std::string fileName, std::string likeFileName);
     
     std::string m_InputName1;
     std::string m_InputName2;
diff --git a/tools/clitkComposeVFGenericFilter.txx b/tools/clitkComposeVFGenericFilter.txx
index 07df988..8b0ecdf 100644
--- a/tools/clitkComposeVFGenericFilter.txx
+++ b/tools/clitkComposeVFGenericFilter.txx
@@ -19,13 +19,7 @@
 #define __clitkComposeVFGenericFilter_txx
 #include "clitkComposeVFGenericFilter.h"
 
-#include "clitkBSplineDeformableTransform.h"
-#include "clitkBSplineDeformableTransformInitializer.h"
-#if ITK_VERSION_MAJOR >= 4
-#include "itkTransformToDisplacementFieldSource.h"
-#else
-#include "itkTransformToDeformationFieldSource.h"
-#endif
+#include "clitkCoeffsToDVF.h"
 
 namespace clitk
 {
@@ -43,59 +37,6 @@ namespace clitk
       }
   }
 
-  template<class DisplacementFieldType>
-  typename DisplacementFieldType::Pointer ComposeVFGenericFilter::CoeffsToDVF(std::string fileName, std::string likeFileName)
-  {
-    typedef clitk::BSplineDeformableTransform<double, DisplacementFieldType::ImageDimension, DisplacementFieldType::ImageDimension> TransformType;
-    typedef typename TransformType::CoefficientImageType CoefficientImageType;
-
-    typedef itk::ImageFileReader<CoefficientImageType> CoeffReaderType;
-    typename CoeffReaderType::Pointer reader = CoeffReaderType::New();
-    reader->SetFileName(fileName);
-    reader->Update();
-
-    typename TransformType::Pointer transform = TransformType::New();
-    transform->SetCoefficientImage(reader->GetOutput());
-    
-#if ITK_VERSION_MAJOR >= 4
-        typedef itk::TransformToDisplacementFieldSource<DisplacementFieldType, double> ConvertorType;
-#else
-        typedef itk::TransformToDeformationFieldSource<DisplacementFieldType, double> ConvertorType;
-#endif
-
-    typedef itk::ImageIOBase ImageIOType;
-    typename ImageIOType::Pointer imageIO = itk::ImageIOFactory::CreateImageIO(likeFileName.c_str(), itk::ImageIOFactory::ReadMode);
-    imageIO->SetFileName(likeFileName);
-    imageIO->ReadImageInformation();
-
-    typename ConvertorType::Pointer convertor= ConvertorType::New();
-    typename ConvertorType::SizeType output_size;
-    typename ConvertorType::SpacingType output_spacing;
-    typename ConvertorType::OriginType output_origin;
-    typename ConvertorType::DirectionType output_direction;
-    for (unsigned int i = 0; i < DisplacementFieldType::ImageDimension; i++) {
-      output_size[i] = imageIO->GetDimensions(i);
-      output_spacing[i] = imageIO->GetSpacing(i);
-      output_origin[i] = imageIO->GetOrigin(i);
-      for (unsigned int j = 0; j < DisplacementFieldType::ImageDimension; j++)
-        output_direction[i][j] = imageIO->GetDirection(i)[j];
-    }
-    
-    if (m_Verbose) {
-      std::cout << "Interpolating coefficients with grid:" << std::endl;
-      std::cout << output_size << output_spacing << std::endl;
-    }
-    
-    convertor->SetNumberOfThreads(1);
-    convertor->SetTransform(transform);
-    convertor->SetOutputOrigin(output_origin);
-    convertor->SetOutputSpacing(output_spacing);
-    convertor->SetOutputSize(output_size);
-    convertor->SetOutputDirection(output_direction);
-    convertor->Update();
-
-    return convertor->GetOutput();
-  }
   
   template<unsigned int Dimension, class PixelType>
   void ComposeVFGenericFilter::UpdateWithDimAndPixelType()
@@ -106,8 +47,8 @@ namespace clitk
 
     //Define the image type
     if (m_Type == 1) {
-      input1 = this->CoeffsToDVF<ImageType>(m_InputName1, m_LikeImage);
-      input2 = this->CoeffsToDVF<ImageType>(m_InputName2, m_LikeImage);
+      input1 = CoeffsToDVF<ImageType>(m_InputName1, m_LikeImage, m_Verbose);
+      input2 = CoeffsToDVF<ImageType>(m_InputName2, m_LikeImage, m_Verbose);
     }
     else {
       //Read the input1
diff --git a/tools/clitkInvertVFGenericFilter.h b/tools/clitkInvertVFGenericFilter.h
index cdaf86f..012524c 100644
--- a/tools/clitkInvertVFGenericFilter.h
+++ b/tools/clitkInvertVFGenericFilter.h
@@ -99,7 +99,6 @@ namespace clitk
     //----------------------------------------  
     template <unsigned int Dimension>  void UpdateWithDim(std::string PixelType);
     template <unsigned int Dimension, class PixelType>  void UpdateWithDimAndPixelType();
-    template<class DisplacementFieldType> typename DisplacementFieldType::Pointer CoeffsToDVF(std::string fileName, std::string likeFileName);
 
 
     //----------------------------------------  
diff --git a/tools/clitkInvertVFGenericFilter.txx b/tools/clitkInvertVFGenericFilter.txx
index 5cd12c4..e4b590e 100644
--- a/tools/clitkInvertVFGenericFilter.txx
+++ b/tools/clitkInvertVFGenericFilter.txx
@@ -19,12 +19,7 @@
 #define clitkInvertVFGenericFilter_txx
 
 #include "itkVectorResampleImageFilter.h"
-#include "clitkBSplineDeformableTransform.h"
-#if ITK_VERSION_MAJOR >= 4
-#include "itkTransformToDisplacementFieldSource.h"
-#else
-#include "itkTransformToDeformationFieldSource.h"
-#endif
+#include "clitkCoeffsToDVF.h"
 
 /* =================================================
  * @file   clitkInvertVFGenericFilter.txx
@@ -106,65 +101,6 @@ InvertVFGenericFilter<args_info_type>::UpdateWithDim(std::string PixelType)
   // }
 }
 
-//-------------------------------------------------------------------
-// Convert Coefficient image to DVF
-//-------------------------------------------------------------------
-template<class args_info_type>
-template<class DisplacementFieldType>
-typename DisplacementFieldType::Pointer
-InvertVFGenericFilter<args_info_type>::CoeffsToDVF(std::string fileName, std::string likeFileName)
-{
-  typedef clitk::BSplineDeformableTransform<double, DisplacementFieldType::ImageDimension, DisplacementFieldType::ImageDimension> TransformType;
-  typedef typename TransformType::CoefficientImageType CoefficientImageType;
-
-  typedef itk::ImageFileReader<CoefficientImageType> CoeffReaderType;
-  typename CoeffReaderType::Pointer reader = CoeffReaderType::New();
-  reader->SetFileName(fileName);
-  reader->Update();
-
-  typename TransformType::Pointer transform = TransformType::New();
-  transform->SetCoefficientImage(reader->GetOutput());
-  
-#if ITK_VERSION_MAJOR >= 4
-      typedef itk::TransformToDisplacementFieldSource<DisplacementFieldType, double> ConvertorType;
-#else
-      typedef itk::TransformToDeformationFieldSource<DisplacementFieldType, double> ConvertorType;
-#endif
-
-  typedef itk::ImageIOBase ImageIOType;
-  typename ImageIOType::Pointer imageIO = itk::ImageIOFactory::CreateImageIO(likeFileName.c_str(), itk::ImageIOFactory::ReadMode);
-  imageIO->SetFileName(likeFileName);
-  imageIO->ReadImageInformation();
-
-  typename ConvertorType::Pointer convertor= ConvertorType::New();
-  typename ConvertorType::SizeType output_size;
-  typename ConvertorType::SpacingType output_spacing;
-  typename ConvertorType::OriginType output_origin;
-  typename ConvertorType::DirectionType output_direction;
-  for (unsigned int i = 0; i < DisplacementFieldType::ImageDimension; i++) {
-    output_size[i] = imageIO->GetDimensions(i);
-    output_spacing[i] = imageIO->GetSpacing(i);
-    output_origin[i] = imageIO->GetOrigin(i);
-    for (unsigned int j = 0; j < DisplacementFieldType::ImageDimension; j++)
-      output_direction[i][j] = imageIO->GetDirection(i)[j];
-  }
-  
-  if (m_Verbose) {
-    std::cout << "Interpolating coefficients with grid:" << std::endl;
-    std::cout << output_size << output_spacing << std::endl;
-  }
-  
-  convertor->SetNumberOfThreads(1);
-  convertor->SetTransform(transform);
-  convertor->SetOutputOrigin(output_origin);
-  convertor->SetOutputSpacing(output_spacing);
-  convertor->SetOutputSize(output_size);
-  convertor->SetOutputDirection(output_direction);
-  convertor->Update();
-
-  return convertor->GetOutput();
-}
-
 
 //-------------------------------------------------------------------
 // Update with the number of dimensions and the pixeltype
diff --git a/tools/clitkWarpImageGenericFilter.h b/tools/clitkWarpImageGenericFilter.h
index 9394d8d..0ce874d 100644
--- a/tools/clitkWarpImageGenericFilter.h
+++ b/tools/clitkWarpImageGenericFilter.h
@@ -98,7 +98,6 @@ namespace clitk
     //----------------------------------------  
     template <unsigned int Dimension>  void UpdateWithDim(std::string PixelType);
     template <unsigned int Dimension, class PixelType>  void UpdateWithDimAndPixelType();
-    template<class DisplacementFieldType> typename DisplacementFieldType::Pointer CoeffsToDVF(std::string fileName, std::string likeFileName);
 
     //----------------------------------------  
     // Data members
diff --git a/tools/clitkWarpImageGenericFilter.txx b/tools/clitkWarpImageGenericFilter.txx
index ce979aa..c64080e 100644
--- a/tools/clitkWarpImageGenericFilter.txx
+++ b/tools/clitkWarpImageGenericFilter.txx
@@ -28,12 +28,7 @@
  ===================================================*/
 
 #include "itkVectorResampleImageFilter.h"
-#include "clitkBSplineDeformableTransform.h"
-#if ITK_VERSION_MAJOR >= 4
-#include "itkTransformToDisplacementFieldSource.h"
-#else
-#include "itkTransformToDeformationFieldSource.h"
-#endif
+#include "clitkCoeffsToDVF.h"
 
 namespace clitk
 {
@@ -71,63 +66,6 @@ WarpImageGenericFilter::UpdateWithDim(std::string PixelType)
   }
 }
 
-//-------------------------------------------------------------------
-// Convert Coefficient image to DVF
-//-------------------------------------------------------------------
-template<class DisplacementFieldType>
-typename DisplacementFieldType::Pointer
-WarpImageGenericFilter::CoeffsToDVF(std::string fileName, std::string likeFileName)
-{
-  typedef clitk::BSplineDeformableTransform<double, DisplacementFieldType::ImageDimension, DisplacementFieldType::ImageDimension> TransformType;
-  typedef typename TransformType::CoefficientImageType CoefficientImageType;
-
-  typedef itk::ImageFileReader<CoefficientImageType> CoeffReaderType;
-  typename CoeffReaderType::Pointer reader = CoeffReaderType::New();
-  reader->SetFileName(fileName);
-  reader->Update();
-
-  typename TransformType::Pointer transform = TransformType::New();
-  transform->SetCoefficientImage(reader->GetOutput());
-  
-#if ITK_VERSION_MAJOR >= 4
-      typedef itk::TransformToDisplacementFieldSource<DisplacementFieldType, double> ConvertorType;
-#else
-      typedef itk::TransformToDeformationFieldSource<DisplacementFieldType, double> ConvertorType;
-#endif
-
-  typedef itk::ImageIOBase ImageIOType;
-  typename ImageIOType::Pointer imageIO = itk::ImageIOFactory::CreateImageIO(likeFileName.c_str(), itk::ImageIOFactory::ReadMode);
-  imageIO->SetFileName(likeFileName);
-  imageIO->ReadImageInformation();
-
-  typename ConvertorType::Pointer convertor= ConvertorType::New();
-  typename ConvertorType::SizeType output_size;
-  typename ConvertorType::SpacingType output_spacing;
-  typename ConvertorType::OriginType output_origin;
-  typename ConvertorType::DirectionType output_direction;
-  for (unsigned int i = 0; i < DisplacementFieldType::ImageDimension; i++) {
-    output_size[i] = imageIO->GetDimensions(i);
-    output_spacing[i] = imageIO->GetSpacing(i);
-    output_origin[i] = imageIO->GetOrigin(i);
-    for (unsigned int j = 0; j < DisplacementFieldType::ImageDimension; j++)
-      output_direction[i][j] = imageIO->GetDirection(i)[j];
-  }
-  
-  if (m_Verbose) {
-    std::cout << "Interpolating coefficients with grid:" << std::endl;
-    std::cout << output_size << output_spacing << std::endl;
-  }
-  
-  convertor->SetNumberOfThreads(1);
-  convertor->SetTransform(transform);
-  convertor->SetOutputOrigin(output_origin);
-  convertor->SetOutputSpacing(output_spacing);
-  convertor->SetOutputSize(output_size);
-  convertor->SetOutputDirection(output_direction);
-  convertor->Update();
-
-  return convertor->GetOutput();
-}
 
 //-------------------------------------------------------------------
 // Update with the number of dimensions and the pixeltype
@@ -152,7 +90,7 @@ WarpImageGenericFilter::UpdateWithDimAndPixelType()
   
   typename DeformationFieldType::Pointer deformationField;
   if (m_ArgsInfo.coeff_given) {
-    deformationField = CoeffsToDVF<DeformationFieldType>(m_ArgsInfo.coeff_arg, m_InputFileName);
+    deformationField = CoeffsToDVF<DeformationFieldType>(m_ArgsInfo.coeff_arg, m_InputFileName, m_Verbose);
   }
   else {
     //Read the deformation field

-----------------------------------------------------------------------

Summary of changes:
 common/clitkCoeffsToDVF.h               |   86 +++++++++++++++++++++++++++++++
 segmentation/clitkExtractLungFilter.txx |   37 +++++++++-----
 tools/clitkComposeVFGenericFilter.h     |    1 -
 tools/clitkComposeVFGenericFilter.txx   |   65 +----------------------
 tools/clitkInvertVFGenericFilter.h      |    1 -
 tools/clitkInvertVFGenericFilter.txx    |   66 +-----------------------
 tools/clitkWarpImageGenericFilter.h     |    1 -
 tools/clitkWarpImageGenericFilter.txx   |   66 +-----------------------
 8 files changed, 116 insertions(+), 207 deletions(-)
 create mode 100644 common/clitkCoeffsToDVF.h


hooks/post-receive
-- 
Clitk


More information about the Pubgit-commits-list mailing list