]> Creatis software - clitk.git/commitdiff
Merge branch 'master' of /home/dsarrut/clitk3.server
authorDavid Sarrut <david.sarrut@gmail.com>
Mon, 24 Oct 2011 05:25:11 +0000 (07:25 +0200)
committerDavid Sarrut <david.sarrut@gmail.com>
Mon, 24 Oct 2011 05:25:11 +0000 (07:25 +0200)
24 files changed:
itk/clitkAddRelativePositionConstraintToLabelImageFilter.h
itk/clitkAddRelativePositionConstraintToLabelImageFilter.txx
itk/clitkBooleanOperatorLabelImageFilter.txx
itk/clitkBoundingBoxUtils.h [new file with mode: 0644]
itk/clitkBoundingBoxUtils.txx [new file with mode: 0644]
itk/clitkCropLikeImageFilter.h
itk/clitkCropLikeImageFilter.txx
itk/clitkRelativePositionAnalyzerFilter.h [new file with mode: 0644]
itk/clitkRelativePositionAnalyzerFilter.txx [new file with mode: 0644]
itk/clitkSegmentationUtils.h
itk/clitkSegmentationUtils.txx
segmentation/clitkExtractLymphStation_3A.txx
segmentation/clitkExtractLymphStation_Supports.txx
segmentation/clitkExtractLymphStationsFilter.old.h [deleted file]
segmentation/clitkExtractLymphStationsFilter.old.txx [deleted file]
segmentation/clitkExtractLymphStationsFilter.txx
segmentation/clitkExtractLymphStationsFilter.txx.save [deleted file]
tools/CMakeLists.txt
tools/clitkRelativePositionAnalyzer.cxx [new file with mode: 0644]
tools/clitkRelativePositionAnalyzer.ggo [new file with mode: 0644]
tools/clitkRelativePositionAnalyzerGenericFilter.h [new file with mode: 0644]
tools/clitkRelativePositionAnalyzerGenericFilter.txx [new file with mode: 0644]
tools/clitkRelativePositionGenericFilter.h
tools/clitkRelativePositionGenericFilter.txx

index fa5e95b1c39eb3bc90bc8488ca1feaad320c689a..4d60a9da4e2936a3b3529e61e187d84735a970a1 100644 (file)
@@ -21,6 +21,7 @@
 
 // clitk
 #include "clitkFilterBase.h"
+#include "clitkCropLikeImageFilter.h"
 
 // itk
 #include <itkPasteImageFilter.h>
@@ -128,6 +129,12 @@ namespace clitk {
     itkSetMacro(CombineWithOrFlag, bool);
     itkBooleanMacro(CombineWithOrFlag);
 
+    itkGetConstMacro(FuzzyMapOnlyFlag, bool);
+    itkSetMacro(FuzzyMapOnlyFlag, bool);
+    itkBooleanMacro(FuzzyMapOnlyFlag);
+
+    typename FloatImageType::Pointer GetFuzzyMap() { return m_FuzzyMap; }
+
     // I dont want to verify inputs information
     virtual void VerifyInputInformation() { }
     
@@ -151,6 +158,7 @@ namespace clitk {
     bool m_InverseOrientationFlag;
     bool m_RemoveObjectFlag;
     bool m_CombineWithOrFlag;
+    bool m_FuzzyMapOnlyFlag;
 
     virtual void GenerateOutputInformation();
     virtual void GenerateInputRequestedRegion();
@@ -160,6 +168,7 @@ namespace clitk {
     typename ImageType::Pointer working_image;
     typename ImageType::Pointer object_resampled;
     typename FloatImageType::Pointer relPos;
+    typename FloatImageType::Pointer m_FuzzyMap;
     ImagePointer input;
     ImagePointer object;
 
index 694910c6490434280661bbbba1d51dfbc96a3bbc..b73368f84324cb92dc60d5ed6530ded8791e86fc 100644 (file)
@@ -22,6 +22,7 @@
 #include "clitkAutoCropFilter.h"
 #include "clitkResampleImageWithOptionsFilter.h"
 #include "clitkBooleanOperatorLabelImageFilter.h"
+#include "clitkCropLikeImageFilter.h"
 
 // itk
 #include <deque>
@@ -61,6 +62,7 @@ AddRelativePositionConstraintToLabelImageFilter():
   CombineWithOrFlagOff();
   VerboseStepFlagOff();
   WriteStepFlagOff();
+  FuzzyMapOnlyFlagOff();
 }
 //--------------------------------------------------------------------
 
@@ -361,7 +363,6 @@ GenerateData()
   typedef itk::RelativePositionPropImageFilter<ImageType, FloatImageType> RelPosFilterType;
   typename RelPosFilterType::Pointer relPosFilter;
 
-  typename FloatImageType::Pointer m_FuzzyMap;
   for(int i=0; i<GetNumberOfAngles(); i++) {
     // Compute fuzzy map
     relPosFilter = RelPosFilterType::New();
index 86b464538d176e3c579084e89bda2c2c072eb2ea..ff0f5748063503d5b7c5656c714943740020c18c 100644 (file)
@@ -21,7 +21,7 @@
 
 #include "clitkCommon.h"
 #include "clitkBooleanOperatorLabelImageFilter.h"
-#include "clitkSegmentationUtils.h"
+#include "clitkBoundingBoxUtils.h"
 
 namespace clitk {
 
diff --git a/itk/clitkBoundingBoxUtils.h b/itk/clitkBoundingBoxUtils.h
new file mode 100644 (file)
index 0000000..2138d63
--- /dev/null
@@ -0,0 +1,53 @@
+/*=========================================================================
+  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://oncora1.lyon.fnclcc.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 CLITKBOUNDINGBOXUTILS_H
+#define CLITKBOUNDINGBOXUTILS_H
+
+// clitk
+#include "clitkCommon.h"
+
+// itk
+#include <itkBoundingBox.h>
+
+namespace clitk {
+
+  //--------------------------------------------------------------------
+  template<class ImageType>
+  void ComputeBBFromImageRegion(const ImageType * image, 
+                                typename ImageType::RegionType region,
+                                typename itk::BoundingBox<unsigned long, 
+                                                          ImageType::ImageDimension>::Pointer bb);
+  
+  //--------------------------------------------------------------------
+  template<int Dimension>
+  void ComputeBBIntersection(typename itk::BoundingBox<unsigned long, Dimension>::Pointer bbo, 
+                             typename itk::BoundingBox<unsigned long, Dimension>::Pointer bbi1, 
+                             typename itk::BoundingBox<unsigned long, Dimension>::Pointer bbi2);
+
+  //--------------------------------------------------------------------
+  template<class ImageType>
+  void ComputeRegionFromBB(const ImageType * image, 
+                           const typename itk::BoundingBox<unsigned long, 
+                                                           ImageType::ImageDimension>::Pointer bb, 
+                           typename ImageType::RegionType & region);
+} // end clitk namespace
+
+#include "clitkBoundingBoxUtils.txx"
+
+#endif
diff --git a/itk/clitkBoundingBoxUtils.txx b/itk/clitkBoundingBoxUtils.txx
new file mode 100644 (file)
index 0000000..26f38b2
--- /dev/null
@@ -0,0 +1,106 @@
+/*=========================================================================
+  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
+  ======================================================================-====*/
+
+namespace clitk {
+
+  //--------------------------------------------------------------------
+  template<class ImageType>
+  void ComputeBBFromImageRegion(const ImageType * image, 
+                                typename ImageType::RegionType region,
+                                typename itk::BoundingBox<unsigned long, 
+                                ImageType::ImageDimension>::Pointer bb) {
+    typedef typename ImageType::IndexType IndexType;
+    IndexType firstIndex;
+    IndexType lastIndex;
+    for(unsigned int i=0; i<image->GetImageDimension(); i++) {
+      firstIndex[i] = region.GetIndex()[i];
+      lastIndex[i] = firstIndex[i]+region.GetSize()[i];
+    }
+
+    typedef itk::BoundingBox<unsigned long, 
+                             ImageType::ImageDimension> BBType;
+    typedef typename BBType::PointType PointType;
+    PointType lastPoint;
+    PointType firstPoint;
+    image->TransformIndexToPhysicalPoint(firstIndex, firstPoint);
+    image->TransformIndexToPhysicalPoint(lastIndex, lastPoint);
+
+    bb->SetMaximum(lastPoint);
+    bb->SetMinimum(firstPoint);
+  }
+  //--------------------------------------------------------------------
+
+
+  //--------------------------------------------------------------------
+  template<int Dimension>
+  void ComputeBBIntersection(typename itk::BoundingBox<unsigned long, Dimension>::Pointer bbo, 
+                             typename itk::BoundingBox<unsigned long, Dimension>::Pointer bbi1, 
+                             typename itk::BoundingBox<unsigned long, Dimension>::Pointer bbi2) {
+
+    typedef itk::BoundingBox<unsigned long, Dimension> BBType;
+    typedef typename BBType::PointType PointType;
+    PointType lastPoint;
+    PointType firstPoint;
+
+    for(unsigned int i=0; i<Dimension; i++) {
+      firstPoint[i] = std::max(bbi1->GetMinimum()[i], 
+                               bbi2->GetMinimum()[i]);
+      lastPoint[i] = std::min(bbi1->GetMaximum()[i], 
+                              bbi2->GetMaximum()[i]);
+    }
+
+    bbo->SetMaximum(lastPoint);
+    bbo->SetMinimum(firstPoint);
+  }
+  //--------------------------------------------------------------------
+
+
+  //--------------------------------------------------------------------
+  template<class ImageType>
+  void ComputeRegionFromBB(const ImageType * image, 
+                           const typename itk::BoundingBox<unsigned long, 
+                                                           ImageType::ImageDimension>::Pointer bb, 
+                           typename ImageType::RegionType & region) {
+    // Types
+    typedef typename ImageType::IndexType  IndexType;
+    typedef typename ImageType::PointType  PointType;
+    typedef typename ImageType::RegionType RegionType;
+    typedef typename ImageType::SizeType   SizeType;
+
+    // Region starting point
+    IndexType regionStart;
+    PointType start = bb->GetMinimum();
+    image->TransformPhysicalPointToIndex(start, regionStart);
+    
+    // Region size
+    SizeType regionSize;
+    PointType maxs = bb->GetMaximum();
+    PointType mins = bb->GetMinimum();
+    for(unsigned int i=0; i<ImageType::ImageDimension; i++) {
+      regionSize[i] = lrint((maxs[i] - mins[i])/image->GetSpacing()[i]);
+    }
+   
+    // Create region
+    region.SetIndex(regionStart);
+    region.SetSize(regionSize);
+  }
+  //--------------------------------------------------------------------
+
+
+} // end of namespace
+
index 9281fcad71fc7ec7ce2c7cd5a049a76078670861..9c12d784dfd0543436bf30c6604b8d5b94cc0c4c 100644 (file)
@@ -100,6 +100,15 @@ namespace clitk {
   }; // end class
   //--------------------------------------------------------------------
 
+
+  //--------------------------------------------------------------------
+  // Convenient function 
+  template<class ImageType>
+  typename ImageType::Pointer
+  ResizeImageLike(const ImageType * input,
+                  const itk::ImageBase<ImageType::ImageDimension> * like, 
+                  typename ImageType::PixelType BG);
+
 } // end namespace clitk
 //--------------------------------------------------------------------
 
index 73dd7a7d1532f0f885d1a35f71296145b9691f9f..5a9696e8b935434ed969194e89c1e7dd4236c09d 100644 (file)
@@ -23,9 +23,6 @@
 #include "clitkCommon.h"
 #include "clitkPasteImageFilter.h"
 
-// itk
-//#include "itkPasteImageFilter.h"
-
 //--------------------------------------------------------------------
 template <class ImageType>
 clitk::CropLikeImageFilter<ImageType>::
@@ -244,5 +241,23 @@ GenerateData() {
 }
 //--------------------------------------------------------------------
    
+
+//--------------------------------------------------------------------
+template<class ImageType>
+typename ImageType::Pointer
+clitk::ResizeImageLike(const ImageType * input,                       
+                       const itk::ImageBase<ImageType::ImageDimension> * like, 
+                       typename ImageType::PixelType backgroundValue) 
+{
+  typedef clitk::CropLikeImageFilter<ImageType> CropFilterType;
+  typename CropFilterType::Pointer cropFilter = CropFilterType::New();
+  cropFilter->SetInput(input);
+  cropFilter->SetCropLikeImage(like);
+  cropFilter->SetBackgroundValue(backgroundValue);
+  cropFilter->Update();
+  return cropFilter->GetOutput();  
+}
+//--------------------------------------------------------------------
+
  
-#endif //#define CLITKAUTOCROPFILTER
+#endif //#define CLITKCROPLIKEIMAGEFILTER_TXX
diff --git a/itk/clitkRelativePositionAnalyzerFilter.h b/itk/clitkRelativePositionAnalyzerFilter.h
new file mode 100644 (file)
index 0000000..2933958
--- /dev/null
@@ -0,0 +1,114 @@
+/*=========================================================================
+  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 CLITKRELATIVEPOSITIONANALYZERFILTER_H
+#define CLITKRELATIVEPOSITIONANALYZERFILTER_H
+
+// clitk
+#include "clitkCommon.h"
+
+// itk
+#include <itkImageToImageFilter.h>
+
+namespace clitk {
+  
+  //--------------------------------------------------------------------
+  /*
+    TODO
+  */
+  //--------------------------------------------------------------------
+  
+  template <class ImageType>
+  class ITK_EXPORT RelativePositionAnalyzerFilter:
+    public itk::ImageToImageFilter<ImageType, ImageType> 
+  {
+
+  public:
+    /** Standard class typedefs. */
+    typedef itk::ImageToImageFilter<ImageType, ImageType>      Superclass;
+    typedef RelativePositionAnalyzerFilter                     Self;
+    typedef itk::SmartPointer<Self>                            Pointer;
+    typedef itk::SmartPointer<const Self>                      ConstPointer;
+       
+    /** Method for creation through the object factory. */
+    itkNewMacro(Self);
+    
+    /** Run-time type information (and related methods). */
+    itkTypeMacro(RelativePositionAnalyzerFilter, ImageToImageFilter);
+
+    /** Some convenient typedefs. */
+    typedef typename ImageType::ConstPointer ImageConstPointer;
+    typedef typename ImageType::Pointer      ImagePointer;
+    typedef typename ImageType::RegionType   RegionType; 
+    typedef typename ImageType::PixelType    PixelType;
+    typedef typename ImageType::SpacingType  SpacingType;
+    typedef typename ImageType::SizeType     SizeType;
+    typedef typename ImageType::IndexType    IndexType;
+    typedef typename ImageType::PointType    PointType;
+    
+    /** ImageDimension constants */
+    itkStaticConstMacro(ImageDimension, unsigned int, ImageType::ImageDimension);
+    typedef itk::Image<float, ImageDimension> FloatImageType;
+
+     /** Input : initial image and object */
+    void SetInputSupport(const ImageType * image);
+    void SetInputObject(const ImageType * image);
+    void SetInputTarget(const ImageType * image);
+    
+    // Options
+    itkSetMacro(VerboseFlag, bool);
+    itkGetConstMacro(VerboseFlag, bool);
+    itkBooleanMacro(VerboseFlag);
+
+    itkGetConstMacro(BackgroundValue, PixelType);
+    itkSetMacro(BackgroundValue, PixelType);
+
+    itkGetConstMacro(ForegroundValue, PixelType);
+    itkSetMacro(ForegroundValue, PixelType);
+
+    // For debug
+    void PrintOptions();
+
+  protected:
+    RelativePositionAnalyzerFilter();
+    virtual ~RelativePositionAnalyzerFilter() {}
+    
+    bool m_VerboseFlag;
+    PixelType m_BackgroundValue;
+    PixelType m_ForegroundValue;
+    ImagePointer m_Support;
+    ImagePointer m_Object;
+    ImagePointer m_Target;
+
+    virtual void GenerateData();
+
+  private:
+    RelativePositionAnalyzerFilter(const Self&); //purposely not implemented
+    void operator=(const Self&); //purposely not implemented
+    
+  }; // end class
+  //--------------------------------------------------------------------
+
+} // end namespace clitk
+//--------------------------------------------------------------------
+
+#ifndef ITK_MANUAL_INSTANTIATION
+#include "clitkRelativePositionAnalyzerFilter.txx"
+#endif
+
+#endif
diff --git a/itk/clitkRelativePositionAnalyzerFilter.txx b/itk/clitkRelativePositionAnalyzerFilter.txx
new file mode 100644 (file)
index 0000000..a732aab
--- /dev/null
@@ -0,0 +1,135 @@
+/*=========================================================================
+  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
+  ===========================================================================**/
+
+//--------------------------------------------------------------------
+template <class ImageType>
+clitk::RelativePositionAnalyzerFilter<ImageType>::
+RelativePositionAnalyzerFilter():
+itk::ImageToImageFilter<ImageType, ImageType>()
+{
+  this->SetNumberOfRequiredInputs(3); // support, object, target
+  VerboseFlagOff();
+}
+//--------------------------------------------------------------------
+
+
+//--------------------------------------------------------------------
+template <class ImageType>
+void 
+clitk::RelativePositionAnalyzerFilter<ImageType>::
+SetInputSupport(const ImageType * image) 
+{
+  // Process object is not const-correct so the const casting is required.
+  this->SetNthInput(0, const_cast<ImageType *>(image));
+}
+//--------------------------------------------------------------------
+  
+
+//--------------------------------------------------------------------
+template <class ImageType>
+void 
+clitk::RelativePositionAnalyzerFilter<ImageType>::
+SetInputObject(const ImageType * image) 
+{
+  // Process object is not const-correct so the const casting is required.
+  this->SetNthInput(1, const_cast<ImageType *>(image));
+}
+//--------------------------------------------------------------------
+  
+
+//--------------------------------------------------------------------
+template <class ImageType>
+void 
+clitk::RelativePositionAnalyzerFilter<ImageType>::
+SetInputTarget(const ImageType * image) 
+{
+  // Process object is not const-correct so the const casting is required.
+  this->SetNthInput(1, const_cast<ImageType *>(image));
+}
+//--------------------------------------------------------------------
+  
+
+//--------------------------------------------------------------------
+template <class ImageType>
+void 
+clitk::RelativePositionAnalyzerFilter<ImageType>::
+PrintOptions() 
+{
+  DD("TODO");
+}
+//--------------------------------------------------------------------
+
+
+//--------------------------------------------------------------------
+template <class ImageType>
+void 
+clitk::RelativePositionAnalyzerFilter<ImageType>::
+GenerateData() 
+{
+  DD("Update");
+  // Get input pointer
+  m_Support = dynamic_cast<ImageType*>(itk::ProcessObject::GetInput(0));
+  m_Object = dynamic_cast<ImageType*>(itk::ProcessObject::GetInput(1));
+  m_Target = dynamic_cast<ImageType*>(itk::ProcessObject::GetInput(2));
+  static const unsigned int dim = ImageType::ImageDimension;
+
+  /*
+    Prerequisite:
+    - target fully inside support ? 
+  */
+  
+  //for(int i=0; i<m_ListOfOrientation.size(); i++) {
+  //DD(i);
+    
+    // Compute Fuzzy map
+
+    // Get minimal value in the target area
+
+    // Or -> analyze floating point values inside the target area (histo ?)
+
+    // Set threshold and compute new support
+    
+    // Compute ratio of area before/after
+    // http://www.itk.org/Doxygen/html/classitk_1_1LabelStatisticsImageFilter.html#details
+    /*
+    typedef itk::LabelStatisticsImageFilter<ImageType, ImageType> StatisticsImageFilterType;
+    typename StatisticsImageFilterType::Pointer statisticsFilter = StatisticsImageFilterType::New();
+    statisticsFilter->SetInput(m_Input);
+    statisticsFilter->SetLabelInput(m_Input);
+    statisticsFilter->Update();
+    int n = labelStatisticsImageFilter->GetCount(GetForegroundValue());
+    DD(n);
+    statisticsFilter = StatisticsImageFilterType::New();
+    statisticsFilter->SetInput(m_Output);
+    statisticsFilter->SetLabelInput(m_Output);
+    statisticsFilter->Update();
+    int m = labelStatisticsImageFilter->GetCount(GetForegroundValue());
+    DD(m);
+    */
+    
+    // Print results
+    
+  //}
+
+  
+  // Final Step -> set output TODO
+  // this->SetNthOutput(0, working_image);
+  //  this->GraftOutput(working_image);
+}
+//--------------------------------------------------------------------
+
index 70388fe6cdb7380511bbda45373abd7f71a1200a..cd1612aa8f513ba371ced207fbd270d6f9f38b92 100644 (file)
 namespace clitk {
 
   //--------------------------------------------------------------------
-  template<class ImageType>
-  void ComputeBBFromImageRegion(const ImageType * image, 
-                                typename ImageType::RegionType region,
-                                typename itk::BoundingBox<unsigned long, 
-                                                          ImageType::ImageDimension>::Pointer bb);
-  
-  //--------------------------------------------------------------------
-  template<int Dimension>
-  void ComputeBBIntersection(typename itk::BoundingBox<unsigned long, Dimension>::Pointer bbo, 
-                             typename itk::BoundingBox<unsigned long, Dimension>::Pointer bbi1, 
-                             typename itk::BoundingBox<unsigned long, Dimension>::Pointer bbi2);
-
-  //--------------------------------------------------------------------
-  template<class ImageType>
-  void ComputeRegionFromBB(const ImageType * image, 
-                           const typename itk::BoundingBox<unsigned long, 
-                                                           ImageType::ImageDimension>::Pointer bb, 
-                           typename ImageType::RegionType & region);
-  //--------------------------------------------------------------------
   template<class TInternalImageType, class TMaskInternalImageType>
   typename TInternalImageType::Pointer
   SetBackground(const TInternalImageType * input,
@@ -136,13 +117,6 @@ namespace clitk {
                           int minimalComponentSize,
                           LabelizeParameters<typename TImageType::PixelType> * param);
 
-  //--------------------------------------------------------------------
-  template<class ImageType>
-  typename ImageType::Pointer
-  ResizeImageLike(const ImageType * input,
-                  const itk::ImageBase<ImageType::ImageDimension> * like, 
-                  typename ImageType::PixelType BG);
-
 
   //--------------------------------------------------------------------
   template<class MaskImageType>
index 2f0d935a7cbbc88d038000768d6bed04bfd2451f..3022ad25f7a9844f07102dd06bfb59e5916659b0 100644 (file)
 
 namespace clitk {
 
-  //--------------------------------------------------------------------
-  template<class ImageType>
-  void ComputeBBFromImageRegion(const ImageType * image, 
-                                typename ImageType::RegionType region,
-                                typename itk::BoundingBox<unsigned long, 
-                                ImageType::ImageDimension>::Pointer bb) {
-    typedef typename ImageType::IndexType IndexType;
-    IndexType firstIndex;
-    IndexType lastIndex;
-    for(unsigned int i=0; i<image->GetImageDimension(); i++) {
-      firstIndex[i] = region.GetIndex()[i];
-      lastIndex[i] = firstIndex[i]+region.GetSize()[i];
-    }
-
-    typedef itk::BoundingBox<unsigned long, 
-                             ImageType::ImageDimension> BBType;
-    typedef typename BBType::PointType PointType;
-    PointType lastPoint;
-    PointType firstPoint;
-    image->TransformIndexToPhysicalPoint(firstIndex, firstPoint);
-    image->TransformIndexToPhysicalPoint(lastIndex, lastPoint);
-
-    bb->SetMaximum(lastPoint);
-    bb->SetMinimum(firstPoint);
-  }
-  //--------------------------------------------------------------------
-
-
-  //--------------------------------------------------------------------
-  template<int Dimension>
-  void ComputeBBIntersection(typename itk::BoundingBox<unsigned long, Dimension>::Pointer bbo, 
-                             typename itk::BoundingBox<unsigned long, Dimension>::Pointer bbi1, 
-                             typename itk::BoundingBox<unsigned long, Dimension>::Pointer bbi2) {
-
-    typedef itk::BoundingBox<unsigned long, Dimension> BBType;
-    typedef typename BBType::PointType PointType;
-    PointType lastPoint;
-    PointType firstPoint;
-
-    for(unsigned int i=0; i<Dimension; i++) {
-      firstPoint[i] = std::max(bbi1->GetMinimum()[i], 
-                               bbi2->GetMinimum()[i]);
-      lastPoint[i] = std::min(bbi1->GetMaximum()[i], 
-                              bbi2->GetMaximum()[i]);
-    }
-
-    bbo->SetMaximum(lastPoint);
-    bbo->SetMinimum(firstPoint);
-  }
-  //--------------------------------------------------------------------
-
-
-  //--------------------------------------------------------------------
-  template<class ImageType>
-  void ComputeRegionFromBB(const ImageType * image, 
-                           const typename itk::BoundingBox<unsigned long, 
-                                                           ImageType::ImageDimension>::Pointer bb, 
-                           typename ImageType::RegionType & region) {
-    // Types
-    typedef typename ImageType::IndexType  IndexType;
-    typedef typename ImageType::PointType  PointType;
-    typedef typename ImageType::RegionType RegionType;
-    typedef typename ImageType::SizeType   SizeType;
-
-    // Region starting point
-    IndexType regionStart;
-    PointType start = bb->GetMinimum();
-    image->TransformPhysicalPointToIndex(start, regionStart);
-    
-    // Region size
-    SizeType regionSize;
-    PointType maxs = bb->GetMaximum();
-    PointType mins = bb->GetMinimum();
-    for(unsigned int i=0; i<ImageType::ImageDimension; i++) {
-      regionSize[i] = lrint((maxs[i] - mins[i])/image->GetSpacing()[i]);
-    }
-   
-    // Create region
-    region.SetIndex(regionStart);
-    region.SetSize(regionSize);
-  }
-  //--------------------------------------------------------------------
-
   //--------------------------------------------------------------------
   template<class ImageType, class TMaskImageType>
   typename ImageType::Pointer
@@ -312,24 +229,6 @@ namespace clitk {
   //--------------------------------------------------------------------
 
 
-  //--------------------------------------------------------------------
-  template<class ImageType>
-  typename ImageType::Pointer
-  ResizeImageLike(const ImageType * input,                       
-                  const itk::ImageBase<ImageType::ImageDimension> * like, 
-                  typename ImageType::PixelType backgroundValue) 
-  {
-    typedef CropLikeImageFilter<ImageType> CropFilterType;
-    typename CropFilterType::Pointer cropFilter = CropFilterType::New();
-    cropFilter->SetInput(input);
-    cropFilter->SetCropLikeImage(like);
-    cropFilter->SetBackgroundValue(backgroundValue);
-    cropFilter->Update();
-    return cropFilter->GetOutput();  
-  }
-  //--------------------------------------------------------------------
-
-
   //--------------------------------------------------------------------
   template<class MaskImageType>
   typename MaskImageType::Pointer
@@ -343,7 +242,7 @@ namespace clitk {
                                bool autocropFlag, 
                                bool singleObjectCCL) 
   {
-    typedef SliceBySliceRelativePositionFilter<MaskImageType> SliceRelPosFilterType;
+    typedef clitk::SliceBySliceRelativePositionFilter<MaskImageType> SliceRelPosFilterType;
     typename SliceRelPosFilterType::Pointer sliceRelPosFilter = SliceRelPosFilterType::New();
     sliceRelPosFilter->VerboseStepFlagOff();
     sliceRelPosFilter->WriteStepFlagOff();
index e973ed02d07655caac505bbbf2c78a24403320dd..50e394852123e6fec950275934f2de39978a84ec 100644 (file)
@@ -148,19 +148,10 @@ ExtractStation_3A_Post_Limits_With_Dilated_Aorta_S6_Support()
   Aorta = clitk::Dilate<MaskImageType>(Aorta, radius, GetBackgroundValue(), GetForegroundValue(), false);
   
   // Now, insert this image in the AFDB (but do not store on disk)
-  GetAFDB()->template SetImage<MaskImageType>("Aorta_Dilated_Anteriorly", "bidon", 
-                                              Aorta, false);
-  /*
-  // Not Post to
-  m_Working_Support = 
-    clitk::SliceBySliceRelativePosition<MaskImageType>(m_Working_Support, Aorta, 2, 
-                                                       GetFuzzyThreshold("3A", "Aorta"), 
-                                                       "NotPostTo", true, 
-                                                       Aorta->GetSpacing()[0], false, false);
-
-  */
+  GetAFDB()->template SetImage<MaskImageType>("Aorta_Dilated_Anteriorly", "seg/Aorta_Dilated_Anteriorly.mha", Aorta, false);
+  writeImage<MaskImageType>(Aorta, "seg/Aorta_Dilated_Anteriorly.mha");
+  GetAFDB()->Write();
 
-  
   StopCurrentStep<MaskImageType>(m_Working_Support);
   m_ListOfStations["3A"] = m_Working_Support;
 }
index 2cde97dd98b7465ae1addea1e6bcfc11965a4281..79abe6a6652b60f20cf5aa2eaf293a12855345fa 100644 (file)
@@ -123,6 +123,8 @@ Support_SupInf_S1RL()
   MaskImagePointType p;
   p[0] = p[1] = p[2] =  0.0; // to avoid warning
   clitk::FindExtremaPointInAGivenDirection<MaskImageType>(Sternum, GetBackgroundValue(), 2, false, p);
+  //  DD(p);
+  p[2] += Sternum->GetSpacing()[2]; // add one slice:  start just superiorly
   MaskImagePointer S1RL = 
     clitk::CropImageRemoveLowerThan<MaskImageType>(m_Working_Support, 2, 
                                                    p[2], true, GetBackgroundValue());
diff --git a/segmentation/clitkExtractLymphStationsFilter.old.h b/segmentation/clitkExtractLymphStationsFilter.old.h
deleted file mode 100644 (file)
index 6be4764..0000000
+++ /dev/null
@@ -1,124 +0,0 @@
-/*=========================================================================
-  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://oncora1.lyon.fnclcc.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 CLITKEXTRACTLYMPHSTATIONSFILTER_H
-#define CLITKEXTRACTLYMPHSTATIONSFILTER_H
-
-// clitk
-#include "clitkFilterBase.h"
-#include "clitkFilterWithAnatomicalFeatureDatabaseManagement.h"
-
-namespace clitk {
-  
-  //--------------------------------------------------------------------
-  /*
-    Try to extract the LymphStations part of a thorax CT.
-    Inputs : 
-    - Patient label image
-    - Lungs label image
-    - Bones label image
-  */
-  //--------------------------------------------------------------------
-  
-  template <class TImageType>
-  class ITK_EXPORT ExtractLymphStationsFilter: 
-    public virtual clitk::FilterBase, 
-    public clitk::FilterWithAnatomicalFeatureDatabaseManagement,
-    public itk::ImageToImageFilter<TImageType, itk::Image<uchar, 3> >
-  {
-
-  public:
-    /** Standard class typedefs. */
-    typedef itk::ImageToImageFilter<TImageType, itk::Image<uchar, 3> > Superclass;
-    typedef ExtractLymphStationsFilter          Self;
-    typedef itk::SmartPointer<Self>             Pointer;
-    typedef itk::SmartPointer<const Self>       ConstPointer;
-    
-    /** Method for creation through the object factory. */
-    itkNewMacro(Self);
-    
-    /** Run-time type information (and related methods). */
-    itkTypeMacro(ExtractLymphStationsFilter, InPlaceImageFilter);
-
-    /** Some convenient typedefs. */
-    typedef TImageType                       ImageType;
-    typedef typename ImageType::ConstPointer ImageConstPointer;
-    typedef typename ImageType::Pointer      ImagePointer;
-    typedef typename ImageType::RegionType   ImageRegionType; 
-    typedef typename ImageType::PixelType    ImagePixelType; 
-    typedef typename ImageType::SizeType     ImageSizeType; 
-    typedef typename ImageType::IndexType    ImageIndexType; 
-    typedef typename ImageType::PointType    ImagePointType; 
-        
-    typedef uchar MaskImagePixelType;
-    typedef itk::Image<MaskImagePixelType, 3> MaskImageType;  
-    typedef typename MaskImageType::Pointer   MaskImagePointer;
-
-    /** Connect inputs */
-    //    void SetInput(const TImageType * image);
-  
-    /** ImageDimension constants */
-    itkStaticConstMacro(ImageDimension, unsigned int, TImageType::ImageDimension);
-    FILTERBASE_INIT;
-   
-    itkGetConstMacro(BackgroundValue, ImagePixelType);
-    itkGetConstMacro(ForegroundValue, ImagePixelType);
-    itkSetMacro(BackgroundValue, ImagePixelType);
-    itkSetMacro(ForegroundValue, ImagePixelType);
-    
-    itkSetMacro(FuzzyThreshold, double);
-    itkGetConstMacro(FuzzyThreshold, double);
-
-  protected:
-    ExtractLymphStationsFilter();
-    virtual ~ExtractLymphStationsFilter() {}
-    
-    virtual void GenerateOutputInformation();
-    virtual void GenerateInputRequestedRegion();
-    virtual void GenerateData();
-       
-    MaskImagePointer m_mediastinum;
-    MaskImagePointer m_trachea;
-    MaskImagePointer m_working_mediastinum;
-    MaskImagePointer m_working_trachea;  
-    MaskImagePointer m_output;  
-    
-    ImagePixelType m_BackgroundValue;
-    ImagePixelType m_ForegroundValue;
-    double m_CarinaZPositionInMM;
-    bool   m_CarinaZPositionInMMIsSet;
-    double m_MiddleLobeBronchusZPositionInMM; 
-
-    double m_IntermediateSpacing;
-    double m_FuzzyThreshold;
-    
-  private:
-    ExtractLymphStationsFilter(const Self&); //purposely not implemented
-    void operator=(const Self&); //purposely not implemented
-    
-  }; // end class
-  //--------------------------------------------------------------------
-
-} // end namespace clitk
-//--------------------------------------------------------------------
-
-#ifndef ITK_MANUAL_INSTANTIATION
-#include "clitkExtractLymphStationsFilter.txx"
-#endif
-
-#endif
diff --git a/segmentation/clitkExtractLymphStationsFilter.old.txx b/segmentation/clitkExtractLymphStationsFilter.old.txx
deleted file mode 100644 (file)
index c95be39..0000000
+++ /dev/null
@@ -1,395 +0,0 @@
-/*=========================================================================
-  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://oncora1.lyon.fnclcc.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 CLITKEXTRACTLYMPHSTATIONSFILTER_TXX
-#define CLITKEXTRACTLYMPHSTATIONSFILTER_TXX
-
-// clitk
-#include "clitkCommon.h"
-#include "clitkExtractLymphStationsFilter.h"
-#include "clitkAddRelativePositionConstraintToLabelImageFilter.h"
-#include "clitkSegmentationUtils.h"
-#include "clitkAutoCropFilter.h"
-#include "clitkSegmentationUtils.h"
-#include "clitkSliceBySliceRelativePositionFilter.h"
-
-// itk
-#include <itkStatisticsLabelMapFilter.h>
-#include <itkLabelImageToStatisticsLabelMapFilter.h>
-#include <itkRegionOfInterestImageFilter.h>
-#include <itkBinaryThresholdImageFilter.h>
-#include <itkImageSliceConstIteratorWithIndex.h>
-#include <itkImageSliceIteratorWithIndex.h>
-#include <itkBinaryThinningImageFilter.h>
-
-// itk ENST
-#include "RelativePositionPropImageFilter.h"
-
-//--------------------------------------------------------------------
-template <class TImageType>
-clitk::ExtractLymphStationsFilter<TImageType>::
-ExtractLymphStationsFilter():
-  clitk::FilterBase(),
-  clitk::FilterWithAnatomicalFeatureDatabaseManagement(),
-  itk::ImageToImageFilter<TImageType, MaskImageType>()
-{
-  this->SetNumberOfRequiredInputs(1);
-  SetBackgroundValue(0);
-  SetForegroundValue(1);
-  SetFuzzyThreshold(0.5);
-}
-//--------------------------------------------------------------------
-
-
-//--------------------------------------------------------------------
-template <class TImageType>
-void 
-clitk::ExtractLymphStationsFilter<TImageType>::
-GenerateOutputInformation() { 
-  //  Superclass::GenerateOutputInformation();
-  
-  // Get input
-  LoadAFDB();
-  m_mediastinum = GetAFDB()->template GetImage <MaskImageType>("mediastinum");  
-  m_trachea = GetAFDB()->template GetImage <MaskImageType>("trachea");  
-  ImagePointType carina;
-  GetAFDB()->GetPoint3D("carina", carina);
-  m_CarinaZPositionInMM = carina[2];
-  DD(m_CarinaZPositionInMM);
-  ImagePointType mlb;
-  GetAFDB()->GetPoint3D("middleLobeBronchus", mlb);
-  m_MiddleLobeBronchusZPositionInMM = mlb[2];
-  DD(m_MiddleLobeBronchusZPositionInMM);
-
-  // ----------------------------------------------------------------
-  // ----------------------------------------------------------------
-  // Superior limit = carina
-  // Inferior limit = origin right middle lobe bronchus
-  StartNewStep("Inf/Sup mediastinum limits with carina/bronchus");
-  m_working_mediastinum = 
-    clitk::CropImageAlongOneAxis<MaskImageType>(m_mediastinum, 2, 
-                                                m_MiddleLobeBronchusZPositionInMM, 
-                                                m_CarinaZPositionInMM, true,
-                                                GetBackgroundValue());
-  StopCurrentStep<MaskImageType>(m_working_mediastinum);
-  m_output = m_working_mediastinum;
-
-  // ----------------------------------------------------------------
-  // ----------------------------------------------------------------
-  // Superior limit = carina
-  // Inferior limit = origin right middle lobe bronchus
-  StartNewStep("Inf/Sup trachea limits with carina/bronchus");
-  m_working_trachea = 
-    clitk::CropImageAlongOneAxis<MaskImageType>(m_trachea, 2, 
-                                                m_MiddleLobeBronchusZPositionInMM, 
-                                                m_CarinaZPositionInMM, true,
-                                                GetBackgroundValue());
-  StopCurrentStep<MaskImageType>(m_working_trachea);
-
-  // ----------------------------------------------------------------
-  // ----------------------------------------------------------------
-  // Separate trachea in two CCL
-  StartNewStep("Separate trachea under carina");
-
-  // Labelize and consider two main labels
-  m_working_trachea = Labelize<MaskImageType>(m_working_trachea, 0, true, 1);
-
-  // Carina position must at the first slice that separate the two main bronchus (not superiorly) 
-  // Check that upper slice is composed of at least two labels
-  typedef itk::ImageSliceIteratorWithIndex<MaskImageType> SliceIteratorType;
-  SliceIteratorType iter(m_working_trachea, m_working_trachea->GetLargestPossibleRegion());
-  iter.SetFirstDirection(0);
-  iter.SetSecondDirection(1);
-  iter.GoToReverseBegin(); // Start from the end (because image is IS not SI)
-  int maxLabel=0;
-  while (!iter.IsAtReverseEndOfSlice()) {
-    while (!iter.IsAtReverseEndOfLine()) {    
-      //  DD(iter.GetIndex());
-      if (iter.Get() > maxLabel) maxLabel = iter.Get();
-      --iter;
-    }
-    iter.PreviousLine();
-  }
-  if (maxLabel < 2) {
-    clitkExceptionMacro("First slice form Carina does not seems to seperate the two main bronchus. Abort");
-  }
-
-  // Compute centroid of both parts to identify the left from the right bronchus
-  typedef long LabelType;
-  static const unsigned int Dim = ImageType::ImageDimension;
-  typedef itk::ShapeLabelObject< LabelType, Dim > LabelObjectType;
-  typedef itk::LabelMap< LabelObjectType > LabelMapType;
-  typedef itk::LabelImageToLabelMapFilter<MaskImageType, LabelMapType> ImageToMapFilterType;
-  typename ImageToMapFilterType::Pointer imageToLabelFilter = ImageToMapFilterType::New(); 
-  typedef itk::ShapeLabelMapFilter<LabelMapType, MaskImageType> ShapeFilterType; 
-  typename ShapeFilterType::Pointer statFilter = ShapeFilterType::New();
-  imageToLabelFilter->SetBackgroundValue(GetBackgroundValue());
-  imageToLabelFilter->SetInput(m_working_trachea);
-  statFilter->SetInput(imageToLabelFilter->GetOutput());
-  statFilter->Update();
-  typename LabelMapType::Pointer labelMap = statFilter->GetOutput();
-
-  ImagePointType C1 = labelMap->GetLabelObject(1)->GetCentroid();
-  ImagePointType C2 = labelMap->GetLabelObject(2)->GetCentroid();
-
-  ImagePixelType leftLabel;
-  ImagePixelType rightLabel;  
-  if (C1[0] < C2[0]) { leftLabel = 1; rightLabel = 2; }
-  else { leftLabel = 2; rightLabel = 1; }
-  DD(leftLabel);
-  DD(rightLabel);
-
-  StopCurrentStep<MaskImageType>(m_working_trachea);
-
-  //-----------------------------------------------------
-  StartNewStep("Left limits with bronchus (slice by slice)");  
-  // Select LeftLabel (set one label to Backgroundvalue)
-  MaskImagePointer leftBronchus = 
-    SetBackground<MaskImageType, MaskImageType>(m_working_trachea, m_working_trachea, 
-                                                rightLabel, GetBackgroundValue());
-  MaskImagePointer rightBronchus  = 
-    SetBackground<MaskImageType, MaskImageType>(m_working_trachea, m_working_trachea, 
-                                                leftLabel, GetBackgroundValue());
-  writeImage<MaskImageType>(leftBronchus, "left.mhd");
-  writeImage<MaskImageType>(rightBronchus, "right.mhd");
-
-  m_working_mediastinum = 
-    clitk::SliceBySliceRelativePosition<MaskImageType>(m_working_mediastinum, 
-                                                      leftBronchus, 2, 
-                                                       GetFuzzyThreshold(), "RightTo", 
-                                                       true, 4);
-  m_working_mediastinum = 
-    clitk::SliceBySliceRelativePosition<MaskImageType>(m_working_mediastinum, 
-                                                      rightBronchus, 
-                                                      2, GetFuzzyThreshold(), "LeftTo", 
-                                                       true, 4);
-  m_working_mediastinum = 
-    clitk::SliceBySliceRelativePosition<MaskImageType>(m_working_mediastinum, 
-                                                      leftBronchus, 
-                                                      2, GetFuzzyThreshold(), "AntTo", 
-                                                       true, 4, true); // NOT
-  m_working_mediastinum = 
-    clitk::SliceBySliceRelativePosition<MaskImageType>(m_working_mediastinum, 
-                                                      rightBronchus, 
-                                                      2, GetFuzzyThreshold(), "AntTo", 
-                                                       true, 4, true);
-  m_working_mediastinum = 
-    clitk::SliceBySliceRelativePosition<MaskImageType>(m_working_mediastinum, 
-                                                      leftBronchus, 
-                                                      2, GetFuzzyThreshold(), "PostTo", 
-                                                       true, 4, true);
-  m_working_mediastinum = 
-    clitk::SliceBySliceRelativePosition<MaskImageType>(m_working_mediastinum, 
-                                                      rightBronchus, 
-                                                      2, GetFuzzyThreshold(), "PostTo", 
-                                                       true, 4, true);
-  m_output = m_working_mediastinum;
-  StopCurrentStep<MaskImageType>(m_output);
-
-  //-----------------------------------------------------
-  //-----------------------------------------------------
-  StartNewStep("Posterior limits");  
-
-  // Left Bronchus slices
-  typedef clitk::ExtractSliceFilter<MaskImageType> ExtractSliceFilterType;
-  typedef typename ExtractSliceFilterType::SliceType SliceType;
-  typename ExtractSliceFilterType::Pointer 
-    extractSliceFilter = ExtractSliceFilterType::New();
-  extractSliceFilter->SetInput(leftBronchus);
-  extractSliceFilter->SetDirection(2);
-  extractSliceFilter->Update();
-  std::vector<typename SliceType::Pointer> leftBronchusSlices;
-  extractSliceFilter->GetOutputSlices(leftBronchusSlices);
-  
-  // Right Bronchus slices
-  extractSliceFilter = ExtractSliceFilterType::New();
-  extractSliceFilter->SetInput(rightBronchus);
-  extractSliceFilter->SetDirection(2);
-  extractSliceFilter->Update();
-  std::vector<typename SliceType::Pointer> rightBronchusSlices ;
-  extractSliceFilter->GetOutputSlices(rightBronchusSlices);
-  
-  assert(leftBronchusSlices.size() == rightBronchusSlices.size());
-  
-  std::vector<MaskImageType::PointType> leftPoints;
-  std::vector<MaskImageType::PointType> rightPoints;
-  for(uint i=0; i<leftBronchusSlices.size(); i++) {
-    // Keep main CCL
-    leftBronchusSlices[i] = Labelize<SliceType>(leftBronchusSlices[i], 0, true, 10);
-    leftBronchusSlices[i] = KeepLabels<SliceType>(leftBronchusSlices[i], 
-                                                  GetBackgroundValue(), 
-                                                  GetForegroundValue(), 1, 1, true);
-    rightBronchusSlices[i] = Labelize<SliceType>(rightBronchusSlices[i], 0, true, 10);
-    rightBronchusSlices[i] = KeepLabels<SliceType>(rightBronchusSlices[i], 
-                                                   GetBackgroundValue(), 
-                                                   GetForegroundValue(), 1, 1, true);
-    double distance_max_from_center_point = 15;
-
-    // ------- Find point in left Bronchus ------- 
-    // find right most point in left  = rightMost
-    SliceType::PointType a;
-    SliceType::PointType rightMost = 
-      clitk::FindExtremaPointInAGivenDirection<SliceType>(leftBronchusSlices[i], 
-                                                          GetBackgroundValue(), 
-                                                          0, false, a, 0);
-    // find post most point in left, not far away from rightMost
-    SliceType::PointType p = 
-      clitk::FindExtremaPointInAGivenDirection<SliceType>(leftBronchusSlices[i], 
-                                                          GetBackgroundValue(), 
-                                                          1, false, rightMost, 
-                                                          distance_max_from_center_point);
-    MaskImageType::PointType pp;
-    pp[0] = p[0]; pp[1] = p[1];
-    pp[2] = i*leftBronchus->GetSpacing()[2] + leftBronchus->GetOrigin()[2];
-    leftPoints.push_back(pp);
-
-    // ------- Find point in right Bronchus ------- 
-    // find left most point in right  = leftMost
-    SliceType::PointType leftMost = 
-      clitk::FindExtremaPointInAGivenDirection<SliceType>(rightBronchusSlices[i], 
-                                                          GetBackgroundValue(), 
-                                                          0, true, a, 0);
-    // find post most point in left, not far away from leftMost
-    p = clitk::FindExtremaPointInAGivenDirection<SliceType>(rightBronchusSlices[i], 
-                                                            GetBackgroundValue(), 
-                                                            1, false, leftMost, 
-                                                            distance_max_from_center_point);
-    pp[0] = p[0]; pp[1] = p[1];
-    pp[2] = i*rightBronchus->GetSpacing()[2] + rightBronchus->GetOrigin()[2];
-    rightPoints.push_back(pp);
-  }
-
-  // DEBUG
-  std::ofstream osl;
-  openFileForWriting(osl, "left.txt");
-  osl << "LANDMARKS1" << std::endl;
-  std::ofstream osr;
-  openFileForWriting(osr, "right.txt");
-  osr << "LANDMARKS1" << std::endl;
-  for(uint i=0; i<leftBronchusSlices.size(); i++) {
-    osl << i << " " << leftPoints[i][0] << " " << leftPoints[i][1] 
-        << " " << leftPoints[i][2] << " 0 0 " << std::endl;
-    osr << i << " " << rightPoints[i][0] << " " << rightPoints[i][1] 
-        << " " << rightPoints[i][2] << " 0 0 " << std::endl;
-  }
-  osl.close();
-  osr.close();
-
-  // Now uses these points to limit, slice by slice 
-  // http://www.gamedev.net/community/forums/topic.asp?topic_id=542870
-  /*
-    Assuming the points are (Ax,Ay) (Bx,By) and (Cx,Cy), you need to compute:
-    (Bx - Ax) * (Cy - Ay) - (By - Ay) * (Cx - Ax)
-    This will equal zero if the point C is on the line formed by points A and B, and will have a different sign depending on the side. Which side this is depends on the orientation of your (x,y) coordinates, but you can plug test values for A,B and C into this formula to determine whether negative values are to the left or to the right.
-
-    => to accelerate, start with formula, when change sign -> stop and fill
-  */
-  //  typedef itk::ImageSliceIteratorWithIndex<MaskImageType> SliceIteratorType;
-  iter = SliceIteratorType(m_working_mediastinum, m_working_mediastinum->GetLargestPossibleRegion());
-  iter.SetFirstDirection(0);
-  iter.SetSecondDirection(1);
-  iter.GoToBegin();
-  int i=0;
-  MaskImageType::PointType A;
-  MaskImageType::PointType B;
-  MaskImageType::PointType C;
-  while (!iter.IsAtEnd()) {
-    A = leftPoints[i];
-    B = rightPoints[i];
-    C = A;
-    C[1] -= 10; // I know I must keep this point
-    double s = (B[0] - A[0]) * (C[1] - A[1]) - (B[1] - A[1]) * (C[0] - A[0]);
-    bool isPositive = s<0;
-    while (!iter.IsAtEndOfSlice()) {
-      while (!iter.IsAtEndOfLine()) {
-        // Very slow, I know ... but image should be very small
-        m_working_mediastinum->TransformIndexToPhysicalPoint(iter.GetIndex(), C);
-        double s = (B[0] - A[0]) * (C[1] - A[1]) - (B[1] - A[1]) * (C[0] - A[0]);
-        if (s == 0) iter.Set(2);
-        if (isPositive) {
-          if (s > 0) iter.Set(GetBackgroundValue());
-        }
-        else {
-          if (s < 0) iter.Set(GetBackgroundValue());
-        }
-        ++iter;
-      }
-      iter.NextLine();
-    }
-    iter.NextSlice();
-    ++i;
-  }
-
-  //-----------------------------------------------------
-  //-----------------------------------------------------
-  // StartNewStep("Anterior limits");  
-
-  // MISSING FROM NOW 
-  
-  // Station 4R, Station 4L, the right pulmonary artery, and/or the
-  // left superior pulmonary vein
-
-
-  //-----------------------------------------------------
-  //-----------------------------------------------------
-  // ALSO SUBSTRACT ARTERY/VEIN (initially in the support)
-
-  
-  // Set output image information (required)
-  MaskImagePointer outputImage = this->GetOutput(0);
-  outputImage->SetRegions(m_working_mediastinum->GetLargestPossibleRegion());
-  outputImage->SetOrigin(m_working_mediastinum->GetOrigin());
-  outputImage->SetRequestedRegion(m_working_mediastinum->GetLargestPossibleRegion());
-
-}
-//--------------------------------------------------------------------
-
-
-//--------------------------------------------------------------------
-template <class TImageType>
-void 
-clitk::ExtractLymphStationsFilter<TImageType>::
-GenerateInputRequestedRegion() {
-  DD("GenerateInputRequestedRegion");
-  // Call default
-  //  Superclass::GenerateInputRequestedRegion();
-  // Following needed because output region can be greater than input (trachea)
-  //ImagePointer mediastinum = dynamic_cast<TImageType*>(itk::ProcessObject::GetInput(0));
-  //ImagePointer trachea = dynamic_cast<TImageType*>(itk::ProcessObject::GetInput(1));
-  DD("set reg");
-  m_mediastinum->SetRequestedRegion(m_mediastinum->GetLargestPossibleRegion());
-  m_trachea->SetRequestedRegion(m_trachea->GetLargestPossibleRegion());
-  DD("end");
-}
-//--------------------------------------------------------------------
-
-
-//--------------------------------------------------------------------
-template <class TImageType>
-void 
-clitk::ExtractLymphStationsFilter<TImageType>::
-GenerateData() {
-  DD("GenerateData");
-  // Final Step -> graft output (if SetNthOutput => redo)
-  this->GraftOutput(m_output);
-}
-//--------------------------------------------------------------------
-  
-
-#endif //#define CLITKBOOLEANOPERATORLABELIMAGEFILTER_TXX
index ec93c098b3421ea3d8a9105f5677c1212771ed45..6686923948dc086cbd368c54684457e12837d66a 100644 (file)
@@ -438,7 +438,7 @@ FindCarina()
     z = this->GetAFDB()->GetDouble("CarinaZ");
   }
   catch(clitk::ExceptionObject e) {
-    DD("FindCarinaSlicePosition");
+    //DD("FindCarinaSlicePosition");
     // Get Carina
     MaskImagePointer Carina = this->GetAFDB()->template GetImage<MaskImageType>("Carina");
     
@@ -471,7 +471,7 @@ FindApexOfTheChest()
     z = this->GetAFDB()->GetDouble("ApexOfTheChestZ");
   }
   catch(clitk::ExceptionObject e) {
-    DD("FindApexOfTheChestPosition");
+    //DD("FindApexOfTheChestPosition");
     MaskImagePointer Lungs = this->GetAFDB()->template GetImage<MaskImageType>("Lungs");
     MaskImagePointType p;
     p[0] = p[1] = p[2] =  0.0; // to avoid warning
@@ -596,7 +596,7 @@ FindSuperiorBorderOfAorticArch()
     z = this->GetAFDB()->GetDouble("SuperiorBorderOfAorticArchZ");
   }
   catch(clitk::ExceptionObject e) {
-    DD("FindSuperiorBorderOfAorticArch");
+    //    DD("FindSuperiorBorderOfAorticArch");
     MaskImagePointer Aorta = this->GetAFDB()->template GetImage<MaskImageType>("Aorta");
     MaskImagePointType p;
     p[0] = p[1] = p[2] =  0.0; // to avoid warning
@@ -628,7 +628,7 @@ FindInferiorBorderOfAorticArch()
     z = this->GetAFDB()->GetDouble("InferiorBorderOfAorticArchZ");
   }
   catch(clitk::ExceptionObject e) {
-    DD("FindInferiorBorderOfAorticArch");
+    //DD("FindInferiorBorderOfAorticArch");
     MaskImagePointer Aorta = this->GetAFDB()->template GetImage<MaskImageType>("Aorta");
     std::vector<MaskSlicePointer> slices;
     clitk::ExtractSlices<MaskImageType>(Aorta, 2, slices);
diff --git a/segmentation/clitkExtractLymphStationsFilter.txx.save b/segmentation/clitkExtractLymphStationsFilter.txx.save
deleted file mode 100644 (file)
index a7b3244..0000000
+++ /dev/null
@@ -1,289 +0,0 @@
-/*=========================================================================
-  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://oncora1.lyon.fnclcc.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 CLITKEXTRACTLYMPHSTATIONSFILTER_TXX
-#define CLITKEXTRACTLYMPHSTATIONSFILTER_TXX
-
-// clitk
-#include "clitkCommon.h"
-#include "clitkExtractLymphStationsFilter.h"
-#include "clitkAddRelativePositionConstraintToLabelImageFilter.h"
-#include "clitkSegmentationUtils.h"
-#include "clitkAutoCropFilter.h"
-#include "clitkSegmentationUtils.h"
-#include "clitkSliceBySliceRelativePositionFilter.h"
-
-// itk
-#include <itkStatisticsLabelMapFilter.h>
-#include <itkLabelImageToStatisticsLabelMapFilter.h>
-#include <itkRegionOfInterestImageFilter.h>
-#include <itkBinaryThresholdImageFilter.h>
-#include <itkImageSliceConstIteratorWithIndex.h>
-#include <itkBinaryThinningImageFilter.h>
-
-// itk ENST
-#include "RelativePositionPropImageFilter.h"
-
-//--------------------------------------------------------------------
-template <class TImageType>
-clitk::ExtractLymphStationsFilter<TImageType>::
-ExtractLymphStationsFilter():
-  clitk::FilterBase(),
-  clitk::FilterWithAnatomicalFeatureDatabaseManagement(),
-  itk::ImageToImageFilter<TImageType, MaskImageType>()
-{
-  this->SetNumberOfRequiredInputs(1);
-  SetBackgroundValue(0);
-  SetForegroundValue(1);
-}
-//--------------------------------------------------------------------
-
-
-//--------------------------------------------------------------------
-template <class TImageType>
-void 
-clitk::ExtractLymphStationsFilter<TImageType>::
-GenerateOutputInformation() { 
-  //  Superclass::GenerateOutputInformation();
-  
-  // Get input
-  LoadAFDB();
-  m_mediastinum = GetAFDB()->template GetImage <MaskImageType>("mediastinum");  
-  m_trachea = GetAFDB()->template GetImage <MaskImageType>("trachea");  
-  ImagePointType carina;
-  GetAFDB()->GetPoint3D("carina", carina);
-  DD(carina);
-  m_CarinaZPositionInMM = carina[2];
-  DD(m_CarinaZPositionInMM);
-  ImagePointType mlb;
-  GetAFDB()->GetPoint3D("middleLobeBronchus", mlb);
-  m_MiddleLobeBronchusZPositionInMM = mlb[2];
-  DD(m_MiddleLobeBronchusZPositionInMM);
-
-  // ----------------------------------------------------------------
-  // ----------------------------------------------------------------
-  // Superior limit = carina
-  // Inferior limit = origin right middle lobe bronchus
-  StartNewStep("Inf/Sup mediastinum limits with carina/bronchus");
-  ImageRegionType region = m_mediastinum->GetLargestPossibleRegion(); DD(region);
-  ImageSizeType size = region.GetSize();
-  ImageIndexType index = region.GetIndex();
-  DD(m_CarinaZPositionInMM);
-  DD(m_MiddleLobeBronchusZPositionInMM);
-  index[2] = floor((m_MiddleLobeBronchusZPositionInMM - m_mediastinum->GetOrigin()[2]) / m_mediastinum->GetSpacing()[2]);
-  size[2] = 1+ceil((m_CarinaZPositionInMM-m_MiddleLobeBronchusZPositionInMM) / m_mediastinum->GetSpacing()[2]); // +1 to 
-  region.SetSize(size);
-  region.SetIndex(index);
-  DD(region);
-  typedef itk::RegionOfInterestImageFilter<MaskImageType, MaskImageType> CropFilterType;
-  typename CropFilterType::Pointer cropFilter = CropFilterType::New();
-  cropFilter->SetInput(m_mediastinum);
-  cropFilter->SetRegionOfInterest(region);
-  cropFilter->Update();
-  m_working_image = cropFilter->GetOutput();
-  // Auto Crop (because following rel pos is faster)
-  m_working_image = clitk::AutoCrop<MaskImageType>(m_working_image, 0); 
-  StopCurrentStep<MaskImageType>(m_working_image);
-  m_output = m_working_image;
-
-  // ----------------------------------------------------------------
-  // ----------------------------------------------------------------
-  // Separate trachea in two CCL
-  StartNewStep("Separate trachea under carina");
-  // DD(region);
-  ImageRegionType trachea_region = m_trachea->GetLargestPossibleRegion();
-  for(int i=0; i<3; i++) {
-    index[i] = floor(((index[i]*m_mediastinum->GetSpacing()[i])+m_mediastinum->GetOrigin()[i]
-                      -m_trachea->GetOrigin()[i])/m_trachea->GetSpacing()[i]);
-    // DD(index[i]);
-    size[i] = ceil((size[i]*m_mediastinum->GetSpacing()[i])/m_trachea->GetSpacing()[i]);
-    //  DD(size[i]);
-    if (index[i] < 0) { 
-      size[i] += index[i];
-      index[i] = 0;       
-    }
-    if (size[i]+index[i] > (trachea_region.GetSize()[i] + trachea_region.GetIndex()[i])) {
-      size[i] = trachea_region.GetSize()[i] + trachea_region.GetIndex()[i] - index[i];
-    }
-  }
-  // DD(index);
-  //   DD(size);
-  region.SetIndex(index);
-  region.SetSize(size);  
-  //  typedef itk::RegionOfInterestImageFilter<MaskImageType, MaskImageType> CropFilterType;
-  //  typename CropFilterType::Pointer 
-  cropFilter = CropFilterType::New();
- //  m_trachea.Print(std::cout);
-  cropFilter->SetInput(m_trachea);
-  cropFilter->SetRegionOfInterest(region);
-  cropFilter->Update();
-  m_working_trachea = cropFilter->GetOutput();
-
-  // Labelize and consider two main labels
-  m_working_trachea = Labelize<MaskImageType>(m_working_trachea, 0, true, 1);
-
-  // Detect wich label is at Left
-  typedef itk::ImageSliceConstIteratorWithIndex<MaskImageType> SliceIteratorType;
-  SliceIteratorType iter(m_working_trachea, m_working_trachea->GetLargestPossibleRegion());
-  iter.SetFirstDirection(0);
-  iter.SetSecondDirection(1);
-  iter.GoToBegin();
-  bool stop = false;
-  ImagePixelType leftLabel;
-  ImagePixelType rightLabel;
-  while (!stop) {
-    if (iter.Get() != GetBackgroundValue()) {
-      //     DD(iter.GetIndex());
-      //       DD((int)iter.Get());
-      leftLabel = iter.Get();
-      stop = true;
-    }
-    ++iter;
-  }
-  if (leftLabel == 1) rightLabel = 2;
-  else rightLabel = 1;
-  DD((int)leftLabel);
-  DD((int)rightLabel);  
-
-  // End step
-  StopCurrentStep<MaskImageType>(m_working_trachea);
-  
-  //-----------------------------------------------------
-  /*  DD("TEST Skeleton");
-  typedef itk::BinaryThinningImageFilter<MaskImageType, MaskImageType> SkeletonFilterType;
-  typename SkeletonFilterType::Pointer skeletonFilter = SkeletonFilterType::New();
-  skeletonFilter->SetInput(m_working_trachea);
-  skeletonFilter->Update();
-  writeImage<MaskImageType>(skeletonFilter->GetOutput(), "skel.mhd");
-  writeImage<MaskImageType>(skeletonFilter->GetThinning(), "skel2.mhd");  
-  */
-
-  //-----------------------------------------------------
-  StartNewStep("Left limits with bronchus (slice by slice)");  
-  // Select LeftLabel (set right label to 0)
-  MaskImagePointer temp = SetBackground<MaskImageType, MaskImageType>(m_working_trachea, m_working_trachea, rightLabel, 0);
-  writeImage<MaskImageType>(temp, "temp1.mhd");
-
-  m_working_image = 
-    clitk::SliceBySliceRelativePosition<MaskImageType>(m_working_image, 
-                                                      temp, 
-                                                      2, GetFuzzyThreshold(), "RightTo");
-  /*
-  typedef clitk::SliceBySliceRelativePositionFilter<MaskImageType> SliceRelPosFilterType;
-  typename SliceRelPosFilterType::Pointer sliceRelPosFilter = SliceRelPosFilterType::New();
-  sliceRelPosFilter->SetCurrentStepBaseId(this->GetCurrentStepId());
-  sliceRelPosFilter->VerboseStepOn();
-  sliceRelPosFilter->WriteStepOn();
-  sliceRelPosFilter->SetInput(m_working_image);
-  sliceRelPosFilter->SetInputObject(temp);
-  sliceRelPosFilter->SetDirection(2);
-  sliceRelPosFilter->SetFuzzyThreshold(GetFuzzyThreshold());
-  sliceRelPosFilter->SetOrientationTypeString("RightTo");
-  sliceRelPosFilter->Update();
-  m_working_image = sliceRelPosFilter->GetOutput();*/
-  writeImage<MaskImageType>(m_working_image, "afterslicebyslice.mhd");
-
-
-  typedef clitk::SliceBySliceRelativePositionFilter<MaskImageType> SliceRelPosFilterType;
-  typename SliceRelPosFilterType::Pointer sliceRelPosFilter = SliceRelPosFilterType::New();
-
-
-  //-----------------------------------------------------
-  StartNewStep("Right limits with bronchus (slice by slice)");
-  // Select LeftLabel (set right label to 0)
-  temp = SetBackground<MaskImageType, MaskImageType>(m_working_trachea, m_working_trachea, leftLabel, 0);
-  writeImage<MaskImageType>(temp, "temp2.mhd");
-
-  sliceRelPosFilter = SliceRelPosFilterType::New();
-  sliceRelPosFilter->SetCurrentStepBaseId(this->GetCurrentStepId());
-  sliceRelPosFilter->VerboseStepOff();
-  sliceRelPosFilter->WriteStepOff();
-  sliceRelPosFilter->SetInput(m_working_image);
-  sliceRelPosFilter->SetInputObject(temp);
-  sliceRelPosFilter->SetDirection(2);
-  sliceRelPosFilter->SetFuzzyThreshold(GetFuzzyThreshold());
-  sliceRelPosFilter->SetOrientationTypeString("LeftTo");
-  sliceRelPosFilter->Update();
-  m_working_image = sliceRelPosFilter->GetOutput();
-  writeImage<MaskImageType>(m_working_image, "afterslicebyslice.mhd");
-  DD("end");
-  m_output = m_working_image;
-  StopCurrentStep<MaskImageType>(m_output);
-
-  //-----------------------------------------------------
-  StartNewStep("Trial Post position according to trachea");
-  // Post: do not extend past the post wall of the 2 main bronchi
-  sliceRelPosFilter = SliceRelPosFilterType::New();
-  sliceRelPosFilter->SetCurrentStepBaseId(this->GetCurrentStepId());
-  sliceRelPosFilter->VerboseStepOn();
-  sliceRelPosFilter->WriteStepOn();
-  sliceRelPosFilter->SetInput(m_output);
-  sliceRelPosFilter->SetInputObject(m_trachea);
-  sliceRelPosFilter->SetDirection(2);
-  sliceRelPosFilter->SetFuzzyThreshold(GetFuzzyThreshold());
-  // It means "not PostTo" (different from AntTo)
-  sliceRelPosFilter->NotFlagOn();
-  //sliceRelPosFilter->SetOrientationType(SliceRelPosFilterType::RelPosFilterType::PostTo);
-  sliceRelPosFilter->SetOrientationTypeString("PostTo");
-  sliceRelPosFilter->Update();
-  m_output = sliceRelPosFilter->GetOutput();
-  writeImage<MaskImageType>(m_output, "postrelpos.mhd");
-
-
-  // Set output image information (required)
-  MaskImagePointer outputImage = this->GetOutput(0);
-  outputImage->SetRegions(m_working_image->GetLargestPossibleRegion());
-  outputImage->SetOrigin(m_working_image->GetOrigin());
-  outputImage->SetRequestedRegion(m_working_image->GetLargestPossibleRegion());
-  DD("end2");
-}
-//--------------------------------------------------------------------
-
-
-//--------------------------------------------------------------------
-template <class TImageType>
-void 
-clitk::ExtractLymphStationsFilter<TImageType>::
-GenerateInputRequestedRegion() {
-  DD("GenerateInputRequestedRegion");
-  // Call default
-  //  Superclass::GenerateInputRequestedRegion();
-  // Following needed because output region can be greater than input (trachea)
-  //ImagePointer mediastinum = dynamic_cast<TImageType*>(itk::ProcessObject::GetInput(0));
-  //ImagePointer trachea = dynamic_cast<TImageType*>(itk::ProcessObject::GetInput(1));
-  DD("set reg");
-  m_mediastinum->SetRequestedRegion(m_mediastinum->GetLargestPossibleRegion());
-  m_trachea->SetRequestedRegion(m_trachea->GetLargestPossibleRegion());
-  DD("end");
-}
-//--------------------------------------------------------------------
-
-
-//--------------------------------------------------------------------
-template <class TImageType>
-void 
-clitk::ExtractLymphStationsFilter<TImageType>::
-GenerateData() {
-  DD("GenerateData");
-  // Final Step -> graft output (if SetNthOutput => redo)
-  this->GraftOutput(m_output);
-}
-//--------------------------------------------------------------------
-  
-
-#endif //#define CLITKBOOLEANOPERATORLABELIMAGEFILTER_TXX
index 1f2b07a377579d4ff54986a46f3069515107f2fb..be453b1cb99d2d3fa52ca71baef8de92bd7aeef3 100644 (file)
@@ -315,6 +315,16 @@ IF (CLITK_BUILD_TOOLS)
   TARGET_LINK_LIBRARIES(clitkRelativePosition clitkCommon ${ITK_LIBRARIES})
   SET(TOOLS_INSTALL ${TOOLS_INSTALL} clitkRelativePosition)
 
+  WRAP_GGO(clitkLabelImageOverlapMeasure_GGO_C clitkLabelImageOverlapMeasure.ggo)
+  ADD_EXECUTABLE(clitkLabelImageOverlapMeasure clitkLabelImageOverlapMeasure.cxx ${clitkLabelImageOverlapMeasure_GGO_C})
+  TARGET_LINK_LIBRARIES(clitkLabelImageOverlapMeasure clitkSegmentationGgoLib clitkCommon ${ITK_LIBRARIES} )
+  SET(TOOLS_INSTALL ${TOOLS_INSTALL} clitkLabelImageOverlapMeasure)
+
+  WRAP_GGO(clitkRelativePositionAnalyzer_GGO_C clitkRelativePositionAnalyzer.ggo)
+  ADD_EXECUTABLE(clitkRelativePositionAnalyzer clitkRelativePositionAnalyzer.cxx ${clitkRelativePositionAnalyzer_GGO_C})
+  TARGET_LINK_LIBRARIES(clitkRelativePositionAnalyzer clitkSegmentationGgoLib clitkCommon ${ITK_LIBRARIES})
+  SET(TOOLS_INSTALL ${TOOLS_INSTALL} clitkRelativePositionAnalyzer)
+
   WRAP_GGO(clitkTransformLandmarks_GGO_C clitkTransformLandmarks.ggo)
   ADD_EXECUTABLE(clitkTransformLandmarks clitkTransformLandmarks.cxx ${clitkTransformLandmarks_GGO_C})
   TARGET_LINK_LIBRARIES(clitkTransformLandmarks clitkCommon ${ITK_LIBRARIES})
diff --git a/tools/clitkRelativePositionAnalyzer.cxx b/tools/clitkRelativePositionAnalyzer.cxx
new file mode 100644 (file)
index 0000000..9b16e51
--- /dev/null
@@ -0,0 +1,45 @@
+/*=========================================================================
+  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
+===========================================================================**/
+
+// clitk
+#include "clitkRelativePositionAnalyzer_ggo.h"
+#include "clitkRelativePositionAnalyzerGenericFilter.h"
+
+//--------------------------------------------------------------------
+int main(int argc, char * argv[]) {
+
+  // Init command line
+  GGO(clitkRelativePositionAnalyzer, args_info);
+  CLITK_INIT;
+
+  // Filter
+  typedef clitk::RelativePositionAnalyzerGenericFilter<args_info_clitkRelativePositionAnalyzer> FilterType;
+  FilterType::Pointer filter = FilterType::New();
+  
+  filter->SetArgsInfo(args_info);
+  
+  try {
+    filter->Update();
+  } catch(std::runtime_error e) {
+    std::cout << e.what() << std::endl;
+    return EXIT_FAILURE;
+  }
+
+  return EXIT_SUCCESS;
+} // This is the end, my friend
+//--------------------------------------------------------------------
diff --git a/tools/clitkRelativePositionAnalyzer.ggo b/tools/clitkRelativePositionAnalyzer.ggo
new file mode 100644 (file)
index 0000000..982792c
--- /dev/null
@@ -0,0 +1,16 @@
+#File clitkRelativePositionAnalyzer.ggo
+package "clitkRelativePositionAnalyzer"
+version "1.0"
+purpose "Analyze relative position of a target according to structures"
+
+section "General options"
+option "config"                -       "Config file"                     string        no
+option "verbose"       v       "Verbose"                         flag          off
+option "imagetypes"     -       "Display allowed image types"     flag          off
+
+section "Input/Output"
+option "support"       i       "Input mask support"      string        yes
+option "object"                j       "Input mask object"       string        yes
+option "target"                t       "Input mask target"       string        yes
+option "output"        o       "Output image "           string        yes
+
diff --git a/tools/clitkRelativePositionAnalyzerGenericFilter.h b/tools/clitkRelativePositionAnalyzerGenericFilter.h
new file mode 100644 (file)
index 0000000..fb5648a
--- /dev/null
@@ -0,0 +1,75 @@
+/*=========================================================================
+  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 CLITKRELATIVEPOSITIONANALYZERGENERICFILTER_H
+#define CLITKRELATIVEPOSITIONANALYZERGENERICFILTER_H
+
+// clitk 
+#include "clitkIO.h"
+#include "clitkImageToImageGenericFilter.h"
+#include "clitkRelativePositionAnalyzerFilter.h"
+
+//--------------------------------------------------------------------
+namespace clitk 
+{
+
+  template<class ArgsInfoType>
+  class ITK_EXPORT RelativePositionAnalyzerGenericFilter:
+    public ImageToImageGenericFilter<RelativePositionAnalyzerGenericFilter<ArgsInfoType> >
+  {
+  public:
+    //--------------------------------------------------------------------
+    RelativePositionAnalyzerGenericFilter();
+  
+    //--------------------------------------------------------------------
+    typedef ImageToImageGenericFilter<RelativePositionAnalyzerGenericFilter<ArgsInfoType> > Superclass;
+    typedef RelativePositionAnalyzerGenericFilter Self;
+    typedef itk::SmartPointer<Self>       Pointer;
+    typedef itk::SmartPointer<const Self> ConstPointer;
+   
+    //--------------------------------------------------------------------
+    itkNewMacro(Self);  
+    itkTypeMacro(RelativePositionAnalyzerGenericFilter, LightObject);
+
+    //--------------------------------------------------------------------
+    void SetArgsInfo(const ArgsInfoType & a);
+    template<class FilterType> 
+      void SetOptionsFromArgsInfoToFilter(FilterType * f) ;
+
+    //--------------------------------------------------------------------
+    // Main function called each time the filter is updated
+    template<class ImageType>  
+    void UpdateWithInputImageType();
+
+  protected:
+    template<unsigned int Dim> void InitializeImageType();
+      ArgsInfoType mArgsInfo;
+
+  private:
+    RelativePositionAnalyzerGenericFilter(const Self&); //purposely not implemented
+    void operator=(const Self&); //purposely not implemented
+    
+  };// end class
+  //--------------------------------------------------------------------
+} // end namespace clitk
+
+#ifndef ITK_MANUAL_INSTANTIATION
+#include "clitkRelativePositionAnalyzerGenericFilter.txx"
+#endif
+
+#endif // #define CLITKRELATIVEPOSITIONANALYZERGENERICFILTER_H
diff --git a/tools/clitkRelativePositionAnalyzerGenericFilter.txx b/tools/clitkRelativePositionAnalyzerGenericFilter.txx
new file mode 100644 (file)
index 0000000..4225c43
--- /dev/null
@@ -0,0 +1,103 @@
+/*=========================================================================
+  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
+  ===========================================================================**/
+
+//--------------------------------------------------------------------
+template<class ArgsInfoType>
+clitk::RelativePositionAnalyzerGenericFilter<ArgsInfoType>::
+RelativePositionAnalyzerGenericFilter():
+  ImageToImageGenericFilter<Self>("RelativePositionAnalyzer")
+{
+  // Default values
+  cmdline_parser_clitkRelativePositionAnalyzer_init(&mArgsInfo);
+  InitializeImageType<3>();
+}
+//--------------------------------------------------------------------
+
+
+//--------------------------------------------------------------------
+template<class ArgsInfoType>
+template<unsigned int Dim>
+void clitk::RelativePositionAnalyzerGenericFilter<ArgsInfoType>::
+InitializeImageType() 
+{  
+  ADD_IMAGE_TYPE(Dim, uchar);
+}
+//--------------------------------------------------------------------
+  
+
+//--------------------------------------------------------------------
+template<class ArgsInfoType>
+void clitk::RelativePositionAnalyzerGenericFilter<ArgsInfoType>::
+SetArgsInfo(const ArgsInfoType & a) 
+{
+  mArgsInfo=a;
+  SetIOVerbose(mArgsInfo.verbose_flag);
+  if (mArgsInfo.imagetypes_flag) this->PrintAvailableImageTypes();
+  if (mArgsInfo.support_given) AddInputFilename(mArgsInfo.support_arg);
+  if (mArgsInfo.object_given) AddInputFilename(mArgsInfo.object_arg);
+  if (mArgsInfo.target_given) AddInputFilename(mArgsInfo.target_arg);
+  if (mArgsInfo.output_given) AddOutputFilename(mArgsInfo.output_arg);
+}
+//--------------------------------------------------------------------
+
+
+//--------------------------------------------------------------------
+// Update with the number of dimensions and the pixeltype
+//--------------------------------------------------------------------
+template<class ArgsInfoType>
+template<class FilterType>
+void clitk::RelativePositionAnalyzerGenericFilter<ArgsInfoType>::
+SetOptionsFromArgsInfoToFilter(FilterType * f) 
+{
+  
+}
+
+//--------------------------------------------------------------------
+// Update with the number of dimensions and the pixeltype
+//--------------------------------------------------------------------
+template<class ArgsInfoType>
+template<class ImageType>
+void clitk::RelativePositionAnalyzerGenericFilter<ArgsInfoType>::
+UpdateWithInputImageType() 
+{ 
+  // Reading input
+  typename ImageType::Pointer support = this->template GetInput<ImageType>(0);
+  typename ImageType::Pointer object = this->template GetInput<ImageType>(1);
+  typename ImageType::Pointer target = this->template GetInput<ImageType>(2);
+
+  // Create filter
+  typedef clitk::RelativePositionAnalyzerFilter<ImageType> FilterType;
+  typename FilterType::Pointer filter = FilterType::New();
+  
+  // Set global Options 
+  filter->SetInputSupport(support);
+  filter->SetInputObject(object);
+  filter->SetInputTarget(target);
+  SetOptionsFromArgsInfoToFilter<FilterType>(filter);
+
+  // Go !
+  filter->Update();
+  
+  // Write/Save results
+  //  typename ImageType::Pointer output = filter->GetOutput();
+  //this->template SetNextOutput<ImageType>(output); 
+
+}
+//--------------------------------------------------------------------
+
+
index 84ac3e01cb034fcbe8d4a3389b091212c54b3444..bb9ec6faa8336c13317829c2396324730dacf011 100644 (file)
@@ -16,8 +16,8 @@
   - CeCILL-B   http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
 ===========================================================================**/
 
-#ifndef CLITKEXTRACTPATIENTGENERICFILTER_H
-#define CLITKEXTRACTPATIENTGENERICFILTER_H
+#ifndef CLITKRELATIVEPOSITIONGENERICFILTER_H
+#define CLITKRELATIVEPOSITIONGENERICFILTER_H
 
 // clitk 
 #include "clitkIO.h"
@@ -73,4 +73,4 @@ namespace clitk
 #include "clitkRelativePositionGenericFilter.txx"
 #endif
 
-#endif // #define CLITKEXTRACTPATIENTGENERICFILTER_H
+#endif // #define CLITKRELATIVEPOSITIONGENERICFILTER_H
index 66c4be47cfa9c80e9e5b687675e30ecf6f6e1061..4114e55cfc1b8d1f238dfb42659ee7e47f2a8901 100644 (file)
@@ -69,6 +69,9 @@ SetOptionsFromArgsInfoToFilter(FilterType * f)
   f->SetVerboseStepFlag(mArgsInfo.verboseStep_flag);
   f->SetWriteStepFlag(mArgsInfo.writeStep_flag);
 
+  // Must be set before AddOrientationTypeString
+  f->SetInverseOrientationFlag(mArgsInfo.inverse_flag);
+  
   for(uint i=0; i<mArgsInfo.orientation_given; i++) {
     f->AddOrientationTypeString(mArgsInfo.orientation_arg[i]);
   }
@@ -85,8 +88,6 @@ SetOptionsFromArgsInfoToFilter(FilterType * f)
   f->SetRemoveObjectFlag(!mArgsInfo.doNotRemoveObject_flag);
   f->SetAutoCropFlag(!mArgsInfo.noAutoCrop_flag);
   f->SetCombineWithOrFlag(mArgsInfo.combineWithOr_flag);
-  f->SetInverseOrientationFlag(mArgsInfo.inverse_flag);
-  
 }
 
 //--------------------------------------------------------------------