]> Creatis software - clitk.git/commitdiff
Add first version of RelativePositionAnalyzer
authorDavid Sarrut <david.sarrut@gmail.com>
Wed, 19 Oct 2011 11:03:44 +0000 (13:03 +0200)
committerDavid Sarrut <david.sarrut@gmail.com>
Wed, 19 Oct 2011 11:03:44 +0000 (13:03 +0200)
itk/clitkRelativePositionAnalyzerFilter.h [new file with mode: 0644]
itk/clitkRelativePositionAnalyzerFilter.txx [new file with mode: 0644]
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]

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 8bf0cbc26cf5ebf2a0a443040fac459a03bc1f1e..4ce6ac79a09b122a0649786ad601f51222870f2f 100644 (file)
@@ -315,6 +315,11 @@ IF (CLITK_BUILD_TOOLS)
   TARGET_LINK_LIBRARIES(clitkRelativePosition clitkCommon ${ITK_LIBRARIES})
   SET(TOOLS_INSTALL ${TOOLS_INSTALL} clitkRelativePosition)
 
+  WRAP_GGO(clitkRelativePositionAnalyzer_GGO_C clitkRelativePositionAnalyzer.ggo)
+  ADD_EXECUTABLE(clitkRelativePositionAnalyzer  clitkRelativePositionAnalyzer.cxx ${clitkRelativePositionAnalyzer_GGO_C})
+  TARGET_LINK_LIBRARIES(clitkRelativePositionAnalyzer 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); 
+
+}
+//--------------------------------------------------------------------
+
+