]> Creatis software - FrontAlgorithms.git/commitdiff
...
authorLeonardo Flórez-Valencia <florez-l@javeriana.edu.co>
Thu, 5 Oct 2017 21:22:00 +0000 (16:22 -0500)
committerLeonardo Flórez-Valencia <florez-l@javeriana.edu.co>
Thu, 5 Oct 2017 21:22:00 +0000 (16:22 -0500)
26 files changed:
CMakeLists.txt
appli/CTArteries/CMakeLists.txt
appli/CTArteries/CTArteries.cxx
appli/CTArteries/CTArteries.h
appli/CTArteries/Parameters.ui
appli/CTArteries/algorithms/DijkstraWithMeanAndVariance.h
appli/CTArteries/algorithms/RandomWalkLabelling.hxx
appli/CTArteries/algorithms/RandomWalkSegmentation.h
appli/CTArteries/algorithms/RandomWalkSegmentation.hxx
cmake/Definitions.cmake [deleted file]
cmake/Functions.cmake [deleted file]
cmake/InstallCommands.cmake [deleted file]
cmake_uninstall.cmake.in [new file with mode: 0644]
data/axial_CT_slice.mhd [new file with mode: 0644]
data/axial_CT_slice.raw [new file with mode: 0644]
data/axial_CT_slice_labels_00.mhd [new file with mode: 0644]
data/axial_CT_slice_labels_00.raw [new file with mode: 0644]
examples/image/Dijkstra/CMakeLists.txt
examples/image/RandomWalker/CMakeLists.txt
examples/image/RegionGrow/CMakeLists.txt
lib/fpa/CMakeLists.txt
lib/fpa/Common/IncrementalMeanAndVariance.cxx [deleted file]
lib/fpa/Common/IncrementalMeanAndVariance.h [deleted file]
lib/fpa/Common/PeakDetector.cxx [deleted file]
lib/fpa/Common/PeakDetector.h [deleted file]
lib/fpa/Filters/Mori.h

index 184f55699bd5281bfaac4490300eaff71b9e0526..6031b51951d96b8221cb1cb481dc81710eb23cf8 100644 (file)
@@ -21,17 +21,8 @@ foreach(_p ${_policies})
   endif(POLICY ${_p})
 endforeach(_p)
 
-## == Some general configuration
-include(cmake/Definitions.cmake)
-include(cmake/Functions.cmake)
-
 ## == Find cpPlugins
-find_package(cpPlugins CONFIG)
-if(NOT cpPlugins_FOUND)
-  ## == Find individual ITK (for a minimal build)
-  find_package(ITK CONFIG REQUIRED)
-  include(${ITK_USE_FILE})
-endif(NOT cpPlugins_FOUND)
+find_package(cpPlugins CONFIG REQUIRED)
 
 ## == Find eigen3 (http://eigen.tuxfamily.org)
 find_package(Eigen3 CONFIG)
@@ -40,10 +31,21 @@ if(Eigen3_FOUND)
 endif(Eigen3_FOUND)
 
 ## == Build packages
+set(fpa_BUILD 1)
 subdirs(lib examples appli)
 
 ## == Installation commands
-include(cmake/InstallCommands.cmake)
+include(${cpPlugins_INSTALL_FILE})
+
+## == Uninstall target
+configure_file(
+  "${CMAKE_CURRENT_SOURCE_DIR}/cmake_uninstall.cmake.in"
+  "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake"
+  IMMEDIATE @ONLY
+  )
+add_custom_target(
+  uninstall
+  COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake)
 
 ## eof - $RCSfile$
 
index 25a4109485467e94b4bb58945ce721a7508783c2..f968ebcc4c76e3265dfaeeb86a783afce4a18a6c 100644 (file)
@@ -2,9 +2,15 @@
 ## @author Leonardo Florez-Valencia (florez-l@javeriana.edu.co)
 ## =========================================================================
 
-if(cpPlugins_FOUND)
+if(cpPlugins_USE_VTK AND cpPlugins_USE_Qt5)
   find_package(Qt5 CONFIG REQUIRED COMPONENTS PrintSupport)
-  BuildApplication(CTArteries fpa cpPlugins::ivq Qt5::PrintSupport)
-endif(cpPlugins_FOUND)
+  BuildApplication(
+    CTArteries
+    SOURCE .
+    INSTALL
+    RECURRENT
+    LINKS fpa Qt5::PrintSupport
+    )
+endif(cpPlugins_USE_VTK AND cpPlugins_USE_Qt5)
 
 ## eof - $RCSfile$
index 345b94e556908fbba347da01832464232fd02982..8b8a3331e315ac69f8d702e8e994634d9c1debe1 100644 (file)
@@ -122,6 +122,16 @@ CTArteries( int argc, char* argv[], QWidget* parent )
   QT_ACTION_CONN( Open );
   QT_ACTION_CONN( Config );
   QT_ACTION_CONN( Process );
+
+  // Load log
+  if( argc == 3 )
+  {
+    std::string cmd( argv[ 1 ] );
+    std::string fname( argv[ 2 ] );
+    if( cmd == "-log" )
+      this->_ExecuteLog( fname );
+
+  } // fi
 }
 
 // -------------------------------------------------------------------------
@@ -138,6 +148,13 @@ template< class _TStrings >
 void CTArteries::
 _openImage( const _TStrings& fnames )
 {
+  // Save log
+  std::ofstream str_log( "CTArteries.log" );
+  str_log << fnames.size( ) << std::endl;
+  for( const std::string& s: fnames )
+    str_log << s << std::endl;
+  str_log.close( );
+
   // Create appropriate reader
   itk::ImageSource< TImage >::Pointer reader;
   if( fnames.size( ) == 1 )
@@ -221,36 +238,17 @@ _showInputImage( )
 
 // -------------------------------------------------------------------------
 void CTArteries::
-_process( )
+_process( const std::vector< TImage::PointType >& seeds )
 {
-  // Get seeds
-  typedef ivq::VTK::SeedWidgetOverImageActor::TSeeds _TSeeds;
-  if( this->m_Image.IsNull( ) || this->m_Seeds.GetPointer( ) == NULL )
-  {
-    QMessageBox::critical( this, "Error processing", "No valid input image." );
-    return;
-
-  } // fi
-  std::vector< TImage::PointType > seeds;
-  for( _TSeeds::value_type sValue: this->m_Seeds->GetSeeds( ) )
-  {
-    for( unsigned int i = 0; i < sValue.second.size( ); i += 3 )
-    {
-      TImage::PointType pnt;
-      pnt[ 0 ] = sValue.second[ i + 0 ];
-      pnt[ 1 ] = sValue.second[ i + 1 ];
-      pnt[ 2 ] = sValue.second[ i + 2 ];
-      seeds.push_back( pnt );
-
-    } // rof
-
-  } // rof
-  if( seeds.size( ) < 2 )
-  {
-    QMessageBox::critical( this, "Error processing", "Not enough seeds." );
-    return;
-
-  } // fi
+  // Save log
+  std::ofstream str_log( "CTArteries.log", std::ios_base::app );
+  str_log << this->m_UIParameters->Beta->value( ) << std::endl;
+  str_log << this->m_UIParameters->Sigma->value( ) << std::endl;
+  str_log << this->m_UIParameters->Radius->value( ) << std::endl;
+  str_log << seeds.size( ) << std::endl;
+  for( TImage::PointType seed: seeds )
+    str_log << seed << std::endl;
+  str_log.close( );
 
   // Create algorithm
   typedef RandomWalkSegmentation< TImage, TScalarImage > _TSegmentation;
@@ -265,7 +263,9 @@ _process( )
     seg->AddSeed( seed );
   try
   {
+    seg->DebugOn( );
     seg->Update( );
+    seg->DebugOff( );
   }
   catch( std::exception& err )
   {
@@ -370,12 +370,17 @@ _prepareQuantification( )
     while( lines->GetNextCell( npts, ids ) != 0 )
       mesh->AddEdge( ids[ 0 ], ids[ 1 ] );
     delete ids;
-    mesh->AddFace( mesh->GetEdge( ) );
     _TQEMesh::QEPrimal* edge = mesh->GetEdge( );
-    for( auto eIt = edge->BeginGeomLnext( ); eIt != edge->EndGeomLnext( ); ++eIt )
-      points.push_back( mesh->GetPoint( *eIt ) );
+    if( edge != NULL )
+    {
+      mesh->AddFace( edge );
+      edge = mesh->GetEdge( );
+      for( auto eIt = edge->BeginGeomLnext( ); eIt != edge->EndGeomLnext( ); ++eIt )
+        points.push_back( mesh->GetPoint( *eIt ) );
+
+    } // fi
 
-    TFourier f( points.begin( ), points.end( ), 3 );
+    TFourier f( points.begin( ), points.end( ), 6 );
     f.SetOrderingToCounterClockWise( );
     this->m_Fourier.push_back( f );
 
@@ -531,6 +536,18 @@ _showProcessResults( )
   this->_prepareQuantification( );
 }
 
+// -------------------------------------------------------------------------
+void CTArteries::
+_ExecuteLog( const std::string& fname )
+{
+  std::ifstream str_log( fname.c_str( ) );
+  if( str_log )
+  {
+    str_log.close( );
+
+  } // fi
+}
+
 // -------------------------------------------------------------------------
 void CTArteries::
 _sOpen( )
@@ -579,7 +596,35 @@ _sConfig( )
 void CTArteries::
 _sProcess( )
 {
-  this->_process( );
+  // Get seeds
+  typedef ivq::VTK::SeedWidgetOverImageActor::TSeeds _TSeeds;
+  if( this->m_Image.IsNull( ) || this->m_Seeds.GetPointer( ) == NULL )
+  {
+    QMessageBox::critical( this, "Error processing", "No valid input image." );
+    return;
+
+  } // fi
+  std::vector< TImage::PointType > seeds;
+  for( _TSeeds::value_type sValue: this->m_Seeds->GetSeeds( ) )
+  {
+    for( unsigned int i = 0; i < sValue.second.size( ); i += 3 )
+    {
+      TImage::PointType pnt;
+      pnt[ 0 ] = sValue.second[ i + 0 ];
+      pnt[ 1 ] = sValue.second[ i + 1 ];
+      pnt[ 2 ] = sValue.second[ i + 2 ];
+      seeds.push_back( pnt );
+
+    } // rof
+
+  } // rof
+  if( seeds.size( ) < 2 )
+  {
+    QMessageBox::critical( this, "Error processing", "Not enough seeds." );
+    return;
+
+  } // fi
+  this->_process( seeds );
   this->_showProcessResults( );
 }
 
index 487591727991386fc80719f847da06803db7f93f..b3e97c53e2225773045716aeb2f9fe212fcb1598 100644 (file)
@@ -72,10 +72,12 @@ protected:
   void _openDicom( const std::string& dirname );
   void _showInputImage( );
 
-  void _process( );
+  void _process( const std::vector< TImage::PointType >& seeds );
   void _prepareQuantification( );
   void _showProcessResults( );
 
+  void _ExecuteLog( const std::string& fname );
+
 protected slots:
   void _sOpen( );
   void _sConfig( );
index 2a40238799c3a17c23cc40d011c69f09ec80416b..566bf018dfdf9af4aa1cec0def6b75e0b3f3db84 100644 (file)
@@ -71,7 +71,7 @@
            <double>100000.000000000000000</double>
           </property>
           <property name="value">
-           <double>20.000000000000000</double>
+           <double>90.000000000000000</double>
           </property>
          </widget>
         </item>
            <double>100000.000000000000000</double>
           </property>
           <property name="value">
-           <double>5.000000000000000</double>
+           <double>7.000000000000000</double>
           </property>
          </widget>
         </item>
index a82c8aafe23a466c2c2b60ce6d30f5a32695662f..e5c327433f015d9825ffde9cc8e7e8b22a39ff3e 100644 (file)
@@ -4,9 +4,9 @@
 #ifndef __DijkstraWithMeanAndVariance__h__
 #define __DijkstraWithMeanAndVariance__h__
 
-#include <fpa/Common/IncrementalMeanAndVariance.h>
 #include <fpa/Filters/Image/Dijkstra.h>
 #include <fpa/Functors/Dijkstra/Image/Gaussian.h>
+#include <ivq/ITK/IncrementalMeanAndVariance.h>
 
 /**
  */
@@ -22,7 +22,7 @@ public:
 
   typedef typename Superclass::TTraits TTraits;
   fpaTraitsMacro( typename TTraits );
-  typedef fpa::Common::IncrementalMeanAndVariance TMeanAndVar;
+  typedef ivq::ITK::IncrementalMeanAndVariance TMeanAndVar;
 
 public:
   itkNewMacro( Self );
index 3cd2c6a5ca15c48ada64d41bc019a13c3a8c5249..de662f1e2f533a2c8f64d740391b2312a57696dc 100644 (file)
@@ -47,6 +47,7 @@ void RandomWalkLabelling< _TRawImage, _TCostsImage, _TLabelsImage >::
 SetOutsideLabel( const TLabel& v )
 {
   this->SetInitValue( v );
+  this->SetFillValue( v );
 }
 
 // -------------------------------------------------------------------------
@@ -111,9 +112,9 @@ _PostComputeOutputValue( TNode& n )
     if( costs->GetPixel( n.Vertex ) == this->m_MaxCost )
     {
       double v = double( raw->GetPixel( n.Vertex ) );
-      if( v <= this->m_LowerThreshold )
+      if( v < this->m_LowerThreshold )
         n.Value = this->GetLowerLabel( );
-      else if( v >= this->m_UpperThreshold )
+      else if( this->m_UpperThreshold < v )
         n.Value = this->GetUpperLabel( );
       else
         n.Value = TLabel( 0 );
@@ -135,17 +136,21 @@ void RandomWalkLabelling< _TRawImage, _TCostsImage, _TLabelsImage >::
 _Reinitialize( )
 {
   const TPath* path = this->GetInputPath( );
-  while(
-    this->_GetMark( path->GetVertex( this->m_CurrIdx ) ) > 0 &&
-    this->m_CurrIdx < path->GetSize( )
-    )
-    this->m_CurrIdx += 1;
   if( this->m_CurrIdx < path->GetSize( ) )
   {
-    TNode node;
-    node.Vertex = node.Parent = path->GetVertex( this->m_CurrIdx );
-    node.FrontId = 1;
-    this->_QueuePush( node );
+    while(
+      this->_GetMark( path->GetVertex( this->m_CurrIdx ) ) > 0 &&
+      this->m_CurrIdx < path->GetSize( )
+      )
+      this->m_CurrIdx += 1;
+    if( this->m_CurrIdx < path->GetSize( ) )
+    {
+      TNode node;
+      node.Vertex = node.Parent = path->GetVertex( this->m_CurrIdx );
+      node.FrontId = 1;
+      this->_QueuePush( node );
+
+    } // fi
 
   } // fi
 }
index 6644dba3eb251c6e59a3a01c50569d4afca50406..b7199decdaee3ce4fbe5f0c751c1fd884a2b0f54 100644 (file)
@@ -75,7 +75,7 @@ private:
   void _SynchSeed( const _TIn* in, _TSeed& seed );
 
   template< class _TIn, class _TOutPtr >
-  void _Smooth( const _TIn* in, _TOutPtr& out );
+  void _Smooth( const _TIn* in, _TOutPtr& out, double s );
 
   template< class _TIn, class _TOutPtr, class _TAxisPtr, class _TSeeds >
   typename _TIn::RegionType _RawSegmentation(
@@ -121,6 +121,9 @@ private:
     _TOutPtr& out_dist, _TAxisPtr& out_axis
     );
 
+  template< class _TInPtr >
+  void _Save( const _TInPtr& in, const std::string& fname );
+
 private:
   // Purposely not implemented
   RandomWalkSegmentation( const Self& other );
index 15fb9aff0135b4571635b700a0e1364f7f9843a9..30738e96e92ba2e6d75e0d6fa6aff3d9b4513031 100644 (file)
 #include "DijkstraWithMeanAndVariance.h"
 #include "RandomWalkLabelling.h"
 
-/* TODO
-   #include <itkImageRegionConstIterator.h>
-   #include <itkImageRegionIterator.h>
-
-
-   #include <fpa/Functors/Dijkstra/Image/Gaussian.h>
-
-   #include <itkImageFileWriter.h>
-*/
+#include <itkImageFileWriter.h>
 
 // -------------------------------------------------------------------------
 template< class _TInputImage, class _TOutputImage >
@@ -140,9 +132,12 @@ GenerateData( )
 
   // Smooth input
   typename TOutputImage::Pointer smooth_in;
-  this->_Smooth( this->GetInput( ), smooth_in );
+  std::cout << "smooth" << std::endl;
+  this->_Smooth( this->GetInput( ), smooth_in, 2 );
+  this->_Save( smooth_in, "smooth.mhd" );
 
   // Initial segmentation
+  std::cout << "raw" << std::endl;
   typename TOutputImage::Pointer init_seg;
   typename TPath::Pointer init_axis;
   _TScalar init_mean, init_std;
@@ -153,9 +148,12 @@ GenerateData( )
       this->m_Beta,
       init_seg, init_axis, init_mean, init_std
       );
+  std::cout << "Stat: " << init_mean << " +/- " << init_std << std::endl;
   init_std *= _TScalar( this->m_Sigma );
+  this->_Save( init_seg, "raw.mhd" );
 
   // Extract input ROIs
+  std::cout << "ROI" << std::endl;
   typename TOutputImage::Pointer smooth_in_roi, init_seg_roi;
   roi = this->_ROI( smooth_in.GetPointer( ), roi, 10, smooth_in_roi );
   this->_ROI( init_seg.GetPointer( ), roi, 0, init_seg_roi );
@@ -164,6 +162,7 @@ GenerateData( )
   this->_AxisROI( init_axis.GetPointer( ), roi, init_axis_roi );
 
   // Labelling
+  std::cout << "labelling" << std::endl;
   typename _TLabels::Pointer init_labels;
   _TScalar radius = _TScalar( this->m_Radius );
   this->_Label(
@@ -173,17 +172,20 @@ GenerateData( )
     init_mean, init_std, radius,
     init_labels
     );
+  this->_Save( init_labels, "init_labels.mhd" );
 
   // Random walker
+  std::cout << "random walker " << init_std << " " << this->m_Beta << std::endl;
   typename _TLabels::Pointer rw_seg;
   this->_RandomWalker(
     smooth_in_roi.GetPointer( ),
     init_labels.GetPointer( ),
-    init_std / _TScalar( 2 ),
+    this->m_Beta, // init_std / _TScalar( 2 ),
     rw_seg
     );
 
   // ROI outputs
+  std::cout << "axis" << std::endl;
   typename TOutputImage::Pointer out_dist;
   typename TPath::Pointer out_axis;
   this->_DistanceAndAxis(
@@ -193,37 +195,34 @@ GenerateData( )
     );
 
   // Put everything back to requested region
-  /* TODO
-     std::cout << "6" << std::endl;
-     { // begin
-     TOutputImage* output = this->GetOutput( );
-     output->SetBufferedRegion( output->GetRequestedRegion( ) );
-     output->Allocate( );
-     output->FillBuffer( -std::numeric_limits< _TScalar >::max( ) );
-
-     itk::ImageRegionConstIterator< TOutputImage > rIt(
-     output_roi, output_roi->GetRequestedRegion( )
-     );
-     itk::ImageRegionIterator< TOutputImage > oIt( output, roi );
-     rIt.GoToBegin( );
-     oIt.GoToBegin( );
-     for( ; !rIt.IsAtEnd( ); ++rIt, ++oIt )
-     oIt.Set( rIt.Get( ) );
-
-     TPath* output_axis = this->GetOutputAxis( );
-     output_axis->SetReferenceImage( output );
-     for( unsigned long i = 0; i < output_axis_roi->GetSize( ); ++i )
-     {
-     TIndex v = output_axis_roi->GetVertex( i );
-     for( unsigned int d = 0; d < TInputImage::ImageDimension; ++d )
-     v[ d ] += roi.GetIndex( )[ d ];
-     output_axis->AddVertex( v );
-
-     } // rof
-
-     } // end
-     std::cout << "7" << std::endl;
-  */
+  std::cout << "output" << std::endl;
+  { // begin
+    TOutputImage* output = this->GetOutput( );
+    output->SetBufferedRegion( output->GetRequestedRegion( ) );
+    output->Allocate( );
+    output->FillBuffer( -std::numeric_limits< _TScalar >::max( ) );
+
+    itk::ImageRegionConstIterator< TOutputImage > rIt(
+      out_dist, out_dist->GetRequestedRegion( )
+      );
+    itk::ImageRegionIterator< TOutputImage > oIt( output, roi );
+    rIt.GoToBegin( );
+    oIt.GoToBegin( );
+    for( ; !rIt.IsAtEnd( ); ++rIt, ++oIt )
+      oIt.Set( rIt.Get( ) );
+
+    TPath* output_axis = this->GetOutputAxis( );
+    output_axis->SetReferenceImage( output );
+    for( unsigned long i = 0; i < out_axis->GetSize( ); ++i )
+    {
+      TIndex v = out_axis->GetVertex( i );
+      for( unsigned int d = 0; d < TInputImage::ImageDimension; ++d )
+        v[ d ] += roi.GetIndex( )[ d ];
+      output_axis->AddVertex( v );
+
+    } // rof
+
+  } // end
 }
 
 // -------------------------------------------------------------------------
@@ -243,7 +242,7 @@ _SynchSeed( const _TIn* in, _TSeed& seed )
 template< class _TInputImage, class _TOutputImage >
 template< class _TIn, class _TOutPtr >
 void RandomWalkSegmentation< _TInputImage, _TOutputImage >::
-_Smooth( const _TIn* in, _TOutPtr& out )
+_Smooth( const _TIn* in, _TOutPtr& out, double s )
 {
   typedef typename _TOutPtr::ObjectType _TOut;
   typedef itk::SmoothingRecursiveGaussianImageFilter< _TIn, _TOut > _TSmooth;
@@ -251,7 +250,7 @@ _Smooth( const _TIn* in, _TOutPtr& out )
   typename _TSmooth::Pointer smooth = _TSmooth::New( );
   smooth->SetInput( in );
   smooth->SetNormalizeAcrossScale( true );
-  smooth->SetSigmaArray( in->GetSpacing( ) * double( 2 ) );
+  smooth->SetSigmaArray( in->GetSpacing( ) * s );
   smooth->Update( );
   out = smooth->GetOutput( );
   out->DisconnectPipeline( );
@@ -380,6 +379,10 @@ _Label(
   label->Update( );
   out = label->GetOutputLabels( );
   out->DisconnectPipeline( );
+
+  std::cout << label->GetLowerThreshold( ) << std::endl;
+  std::cout << label->GetUpperThreshold( ) << std::endl;
+
 }
 
 // -------------------------------------------------------------------------
@@ -447,7 +450,20 @@ _DistanceAndAxis(
   extract->Update( );
   out_axis = TPath::New( );
   out_axis->Graft( extract->GetOutput( ) );
-  this->_Smooth( extract->GetCenterness( )->GetOutput( ), out_dist );
+  this->_Smooth( extract->GetCenterness( )->GetOutput( ), out_dist, 1 );
+}
+
+// -------------------------------------------------------------------------
+template< class _TInputImage, class _TOutputImage >
+template< class _TInPtr >
+void RandomWalkSegmentation< _TInputImage, _TOutputImage >::
+_Save( const _TInPtr& in, const std::string& fname )
+{
+  typedef itk::ImageFileWriter< typename _TInPtr::ObjectType > _TWriter;
+  typename _TWriter::Pointer w = _TWriter::New( );
+  w->SetInput( in );
+  w->SetFileName( fname );
+  w->Update( );
 }
 
 #endif // __RandomWalkSegmentation__hxx__
diff --git a/cmake/Definitions.cmake b/cmake/Definitions.cmake
deleted file mode 100644 (file)
index 46fb5cf..0000000
+++ /dev/null
@@ -1,53 +0,0 @@
-## =========================================================================
-## @author Leonardo Florez-Valencia (florez-l@javeriana.edu.co)
-## =========================================================================
-
-## == If working on a MacOSX, activate the use of RPATH's
-## == Furthermore: prepare the type of executables
-set(EXECUTABLE_TYPE "" CACHE STRING "Executable linking." FORCE)
-if(APPLE)
-  set(EXECUTABLE_TYPE "MACOSX_BUNDLE" CACHE STRING "Executable linking." FORCE)
-  set(CMAKE_MACOSX_RPATH true CACHE BOOL "Use RPATH's on MacOSX." FORCE)
-  mark_as_advanced(CMAKE_MACOSX_RPATH)
-elseif(WIN32)
-  set(EXECUTABLE_TYPE "WIN32" CACHE STRING "Executable linking." FORCE)
-endif(APPLE)
-mark_as_advanced(EXECUTABLE_TYPE)
-
-## == Force c++11
-if(NOT MSVC)
-  include(CheckCXXCompilerFlag)
-  check_cxx_compiler_flag("-std=c++11" COMPILER_SUPPORTS_CXX11)
-  if(COMPILER_SUPPORTS_CXX11)
-    set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
-  else(COMPILER_SUPPORTS_CXX11)
-    check_cxx_compiler_flag("-std=c++0x" COMPILER_SUPPORTS_CXX0X)
-    if(COMPILER_SUPPORTS_CXX0X)
-      set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x")
-    else(COMPILER_SUPPORTS_CXX0X)
-      message(
-        FATAL_ERROR
-        "The compiler ${CMAKE_CXX_COMPILER} has no C++11 support."
-        )
-    endif(COMPILER_SUPPORTS_CXX0X)
-  endif(COMPILER_SUPPORTS_CXX11)
-endif(NOT MSVC)
-
-## == Prepare header generator to build shared libs
-include(GenerateExportHeader)
-
-## == Do not allow to build inside the source tree
-if(PROJECT_BINARY_DIR STREQUAL ${PROJECT_SOURCE_DIR})
-  message(FATAL_ERROR "Building in the source tree is not allowed.")
-endif(PROJECT_BINARY_DIR STREQUAL ${PROJECT_SOURCE_DIR})
-
-## == Where to put targets (executables and libs)
-set(EXECUTABLE_OUTPUT_PATH ${PROJECT_BINARY_DIR})
-set(LIBRARY_OUTPUT_PATH ${PROJECT_BINARY_DIR})
-mark_as_advanced(
-  CMAKE_BACKWARDS_COMPATIBILITY
-  EXECUTABLE_OUTPUT_PATH
-  LIBRARY_OUTPUT_PATH
-  )
-
-## eof - $RCSfile$
diff --git a/cmake/Functions.cmake b/cmake/Functions.cmake
deleted file mode 100644 (file)
index 1649a0b..0000000
+++ /dev/null
@@ -1,160 +0,0 @@
-## =========================================================================
-## @author Leonardo Florez-Valencia (florez-l@javeriana.edu.co)
-## =========================================================================
-
-## -------------------------------------------------------------------------
-function(BuildLibrary lib typ src maj min rel)
-
-## -- Get sources
-set(_files)
-foreach(_s ${src})
-
-  ## -- Canonicalize path
-  get_filename_component(_p "${_s}" ABSOLUTE)
-
-  ## -- Check type of input
-  if(IS_DIRECTORY ${_p})
-    file(GLOB _f "${_p}/*")
-    foreach(_x ${_f})
-      if(NOT IS_DIRECTORY ${_x})
-        list(APPEND _files ${_x})
-      endif(NOT IS_DIRECTORY ${_x})
-    endforeach(_x)
-  else(IS_DIRECTORY ${_p})
-    list(APPEND _files ${_p})
-  endif(IS_DIRECTORY ${_p})
-
-endforeach(_s)
-
-## -- Process sources
-set(_cpp)
-set(_hpp)
-set(_qui)
-foreach(_f ${_files})
-
-  ## -- Separate filename from extension
-  string(REGEX REPLACE "\\.[^.]*$" "" _name ${_f})
-  string(REPLACE ${_name} "" _ext ${_f})
-  set(_out_name ${_name})
-  set(_out_ext ${_ext})
-
-  ## -- Process .in files
-  string(COMPARE EQUAL "${_ext}" ".in" _in_cmp)
-  if(_in_cmp)
-    string(REPLACE ${PROJECT_SOURCE_DIR} ${PROJECT_BINARY_DIR} _out ${_name})
-    configure_file(${_f} ${_out} @ONLY)
-    string(REGEX REPLACE "\\.[^.]*$" "" _out_name ${_out})
-    string(REPLACE ${_out_name} "" _out_ext ${_out})
-  endif(_in_cmp)
-
-  ## -- Now, get real extension
-  string(SUBSTRING ${_out_ext} 0 2 _ext_cmp)
-
-  ## -- Process .c?? files
-  string(COMPARE EQUAL "${_ext_cmp}" ".c" _c_cmp)
-  if(_c_cmp)
-    list(APPEND _cpp ${_out_name}${_out_ext})
-  endif(_c_cmp)
-
-  ## -- Process .h?? files
-  string(COMPARE EQUAL "${_ext_cmp}" ".h" _h_cmp)
-  if(_h_cmp)
-    list(APPEND _hpp ${_out_name}${_out_ext})
-  endif(_h_cmp)
-
-  ## -- Process .ui files
-  string(COMPARE EQUAL "${_out_ext}" ".ui" _u_cmp)
-  if(_u_cmp)
-    list(APPEND _qui ${_out_name}${_out_ext})
-  endif(_u_cmp)
-
-endforeach(_f)
-
-## -- Process Qt ui files
-list(LENGTH _qui _qui_len)
-if(${_qui_len} GREATER 0)
-  qt5_wrap_ui(_qui_hpp ${_qui})
-endif(${_qui_len} GREATER 0)
-
-## -- Real build
-add_library(${lib} ${typ} ${_cpp} ${_hpp} ${_qui_hpp})
-
-## -- Header creation
-generate_export_header(${lib})
-set_property(TARGET ${lib} PROPERTY VERSION "${maj}.${min}.${rel}")
-set_property(TARGET ${lib} PROPERTY SOVERSION ${maj})
-set_property(TARGET ${lib} PROPERTY INTERFACE_${lib}_MAJOR_VERSION ${maj})
-set_property(TARGET ${lib} APPEND PROPERTY COMPATIBLE_INTERFACE_STRING ${maj})
-
-## -- Link library
-target_link_libraries(${lib} PUBLIC ${ARGN})
-
-## -- Installation rules
-option(${lib}_INSTALL_DEVEL "Install development files for ${lib}" OFF)
-string(COMPARE EQUAL "${type}" "SHARED" _cmp)
-if(_cmp OR ${lib}_INSTALL_DEVEL)
-  install(
-    TARGETS ${lib}
-    EXPORT "${targets_export_name}"
-    LIBRARY DESTINATION "lib"
-    ARCHIVE DESTINATION "lib"
-    RUNTIME DESTINATION "bin"
-    INCLUDES DESTINATION "${include_install_dir}"
-    )
-endif(_cmp OR ${lib}_INSTALL_DEVEL)
-if(${lib}_INSTALL_DEVEL)
-  string(TOLOWER ${lib} _lower_lib)
-  set(
-    _install_hdr
-    ${_hpp}
-    ${CMAKE_CURRENT_BINARY_DIR}/${_lower_lib}_export.h
-    )
-  set(_install_dirs)
-  foreach(_h ${_install_hdr})
-    string(REPLACE ${CMAKE_CURRENT_SOURCE_DIR} "" _h_name ${_h})
-    string(COMPARE EQUAL "${_h_name}" "${_h}" _h_cmp)
-    if(_h_cmp)
-      string(REPLACE ${CMAKE_CURRENT_BINARY_DIR} "" _h_name ${_h})
-    endif(_h_cmp)
-    set(_h_out ${include_install_dir}/${lib}${_h_name})
-    get_filename_component(_h_dir ${_h_out} DIRECTORY)
-    install(
-      FILES "${_h}"
-      DESTINATION "${_h_dir}"
-      )
-  endforeach(_h)
-endif(${lib}_INSTALL_DEVEL)
-
-endfunction()
-
-## -------------------------------------------------------------------------
-function(BuildLibraryRecursive lib typ dir maj min rel)
-
-## -- Globbing directory
-file(GLOB_RECURSE _files "${dir}/*")
-
-## -- Build library
-BuildLibrary(${lib} ${typ} "${_files}" ${maj} ${min} ${rel} ${ARGN})
-
-endfunction()
-
-## -------------------------------------------------------------------------
-function(BuildApplication app)
-option(BUILD_${app} "Build ${app}" OFF)
-if(BUILD_${app})
-  ## -- Use a static library
-  BuildLibraryRecursive(
-    _${app}_ STATIC ${CMAKE_CURRENT_SOURCE_DIR} 0 0 0 ${ARGN}
-    )
-
-  ## -- Create an empty application
-  set(_m ${CMAKE_CURRENT_BINARY_DIR}/__main__${app}.cxx)
-  file(WRITE ${_m} "// Automatically generated dummy file")
-  add_executable(${app} ${EXECUTABLE_TYPE} ${_m})
-
-  ## -- Link it against static library
-  target_link_libraries(${app} PUBLIC _${app}_)
-endif(BUILD_${app})
-endfunction()
-
-## eof - $RCSfile$
diff --git a/cmake/InstallCommands.cmake b/cmake/InstallCommands.cmake
deleted file mode 100644 (file)
index 97500ae..0000000
+++ /dev/null
@@ -1,40 +0,0 @@
-## =========================================================================
-## @author Leonardo Florez-Valencia (florez-l@javeriana.edu.co)
-## =========================================================================
-
-## =========================
-## == Installation values ==
-## =========================
-
-set(config_install_dir "lib/cmake/${PROJECT_NAME}")
-set(include_install_dir "include")
-set(generated_dir "${PROJECT_BINARY_DIR}/generated")
-set(version_config "${generated_dir}/${PROJECT_NAME}ConfigVersion.cmake")
-set(project_config "${generated_dir}/${PROJECT_NAME}Config.cmake")
-set(targets_export_name "${PROJECT_NAME}Targets")
-set(namespace "${PROJECT_NAME}::")
-
-## ===============================
-## == Global installation rules ==
-## ===============================
-
-include(CMakePackageConfigHelpers)
-write_basic_package_version_file(
-  "${version_config}" COMPATIBILITY SameMajorVersion
-  )
-configure_package_config_file(
-  "cmake/${PROJECT_NAME}Config.cmake.in"
-  "${project_config}"
-  INSTALL_DESTINATION "${config_install_dir}"
-  )
-install(
-  EXPORT "${targets_export_name}"
-  NAMESPACE "${namespace}"
-  DESTINATION "${config_install_dir}"
-  )
-install(
-  FILES "${project_config}"
-  DESTINATION "${config_install_dir}"
-  )
-
-## eof - $RCSfile$
diff --git a/cmake_uninstall.cmake.in b/cmake_uninstall.cmake.in
new file mode 100644 (file)
index 0000000..34c9330
--- /dev/null
@@ -0,0 +1,27 @@
+## =========================================================================
+## @author Leonardo Florez-Valencia (florez-l@javeriana.edu.co)
+## =========================================================================
+
+if(NOT EXISTS "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt")
+  message(FATAL_ERROR "Cannot find install manifest: @CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt")
+endif(NOT EXISTS "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt")
+
+file(READ "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt" files)
+string(REGEX REPLACE "\n" ";" files "${files}")
+foreach(file ${files})
+  message(STATUS "Uninstalling $ENV{DESTDIR}${file}")
+  if(IS_SYMLINK "$ENV{DESTDIR}${file}" OR EXISTS "$ENV{DESTDIR}${file}")
+    exec_program(
+      "@CMAKE_COMMAND@" ARGS "-E remove \"$ENV{DESTDIR}${file}\""
+      OUTPUT_VARIABLE rm_out
+      RETURN_VALUE rm_retval
+      )
+    if(NOT "${rm_retval}" STREQUAL 0)
+      message(FATAL_ERROR "Problem when removing $ENV{DESTDIR}${file}")
+    endif(NOT "${rm_retval}" STREQUAL 0)
+  else(IS_SYMLINK "$ENV{DESTDIR}${file}" OR EXISTS "$ENV{DESTDIR}${file}")
+    message(STATUS "File $ENV{DESTDIR}${file} does not exist.")
+  endif(IS_SYMLINK "$ENV{DESTDIR}${file}" OR EXISTS "$ENV{DESTDIR}${file}")
+endforeach(file)
+
+## eof - $RCSfile$
diff --git a/data/axial_CT_slice.mhd b/data/axial_CT_slice.mhd
new file mode 100644 (file)
index 0000000..ee256bf
--- /dev/null
@@ -0,0 +1,13 @@
+ObjectType = Image
+NDims = 2
+BinaryData = True
+BinaryDataByteOrderMSB = False
+CompressedData = False
+TransformMatrix = 1 0 0 1
+Offset = 0 0
+CenterOfRotation = 0 0
+ElementSpacing = 1 1
+DimSize = 256 256
+AnatomicalOrientation = ??
+ElementType = MET_UCHAR
+ElementDataFile = axial_CT_slice.raw
diff --git a/data/axial_CT_slice.raw b/data/axial_CT_slice.raw
new file mode 100644 (file)
index 0000000..ffce463
Binary files /dev/null and b/data/axial_CT_slice.raw differ
diff --git a/data/axial_CT_slice_labels_00.mhd b/data/axial_CT_slice_labels_00.mhd
new file mode 100644 (file)
index 0000000..47eca6b
--- /dev/null
@@ -0,0 +1,13 @@
+ObjectType = Image
+NDims = 2
+BinaryData = True
+BinaryDataByteOrderMSB = False
+CompressedData = False
+TransformMatrix = 1 0 0 1
+Offset = 0 0
+CenterOfRotation = 0 0
+ElementSpacing = 1 1
+DimSize = 256 256
+AnatomicalOrientation = ??
+ElementType = MET_UCHAR
+ElementDataFile = axial_CT_slice_labels_00.raw
diff --git a/data/axial_CT_slice_labels_00.raw b/data/axial_CT_slice_labels_00.raw
new file mode 100644 (file)
index 0000000..a1ce172
Binary files /dev/null and b/data/axial_CT_slice_labels_00.raw differ
index 3fa27a0a4fa73fc3880682cfd420418e466a5911..2d3704586b208fdb50a6888757e7899855066139 100644 (file)
@@ -14,8 +14,7 @@ set(
 include_directories(${PROJECT_SOURCE_DIR}/lib ${PROJECT_BINARY_DIR}/lib)
 
 foreach(_t ${_examples})
-  add_executable(${_pfx}${_t} ${_t}.cxx)
-  target_link_libraries(${_pfx}${_t} fpa)
+  BuildApplication(${_pfx}${_t} SOURCE ${_t}.cxx LINKS fpa)
 endforeach(_t)
 
 ## eof - $RCSfile$
index 90fd7f7e67476635ed7377cb4bdab50b5aacd6dc..1df8f013662c8b2cd5b9bbed43244279f836a306 100644 (file)
@@ -18,8 +18,7 @@ endif(Eigen3_FOUND)
 include_directories(${PROJECT_SOURCE_DIR}/lib ${PROJECT_BINARY_DIR}/lib)
 
 foreach(_t ${_examples})
-  add_executable(${_pfx}${_t} ${_t}.cxx)
-  target_link_libraries(${_pfx}${_t} fpa)
+  BuildApplication(${_pfx}${_t} SOURCE ${_t}.cxx LINKS fpa)
 endforeach(_t)
 
 ## eof - $RCSfile$
index f77acc5588114b10326ac53c19a6c07b73c0cca8..8305ecebbb8b1475de2ba37bcf74beaa2a1056d6 100644 (file)
@@ -12,8 +12,7 @@ set(
 include_directories(${PROJECT_SOURCE_DIR}/lib ${PROJECT_BINARY_DIR}/lib)
 
 foreach(_t ${_examples})
-  add_executable(${_pfx}${_t} ${_t}.cxx)
-  target_link_libraries(${_pfx}${_t} fpa)
+  BuildApplication(${_pfx}${_t} SOURCE ${_t}.cxx LINKS fpa)
 endforeach(_t)
 
 ## eof - $RCSfile$
index 7f9cb9f14248f45c1d7a1165b2e6c9ddea32d622..39cfbc4a82d3a8496ff83f39b42ca8acc850c915 100644 (file)
@@ -5,9 +5,9 @@
 
 ## -- Set directories
 set(_dirs . Common DataStructures Filters Functors)
-if(VTK_FOUND)
+if(cpPlugins_USE_VTK)
   list(APPEND _dirs VTK)
-endif(VTK_FOUND)
+endif(cpPlugins_USE_VTK)
 set(_src)
 foreach(_d ${_dirs})
   file(GLOB_RECURSE _s "${CMAKE_CURRENT_SOURCE_DIR}/${_d}/*")
@@ -16,9 +16,11 @@ endforeach(_d)
 
 ## -- Build
 BuildLibrary(
-  fpa SHARED "${_src}"
-  ${prj_MAJ} ${prj_MIN} ${prj_REL}
-  ${ITK_LIBRARIES} ${VTK_LIBRARIES}
+  fpa SHARED
+  INSTALL_ALL
+  SOURCE ${_src}
+  VERSION ${prj_MAJ} ${prj_MIN} ${prj_REL}
+  LINKS cpPlugins::ivq
   )
 
 ## eof - $RCSfile$
diff --git a/lib/fpa/Common/IncrementalMeanAndVariance.cxx b/lib/fpa/Common/IncrementalMeanAndVariance.cxx
deleted file mode 100644 (file)
index ea88f03..0000000
+++ /dev/null
@@ -1,74 +0,0 @@
-// =========================================================================
-// @author Leonardo Florez Valencia
-// @email florez-l@javeriana.edu.co
-// =========================================================================
-#include <fpa/Common/IncrementalMeanAndVariance.h>
-#include <cmath>
-
-// -------------------------------------------------------------------------
-fpa::Common::IncrementalMeanAndVariance::
-IncrementalMeanAndVariance( )
-{
-  this->Clear( );
-}
-
-// -------------------------------------------------------------------------
-fpa::Common::IncrementalMeanAndVariance::
-~IncrementalMeanAndVariance( )
-{
-}
-
-// -------------------------------------------------------------------------
-double fpa::Common::IncrementalMeanAndVariance::
-GetMean( ) const
-{
-  return( this->m_M );
-}
-
-// -------------------------------------------------------------------------
-double fpa::Common::IncrementalMeanAndVariance::
-GetVariance( ) const
-{
-  return( this->m_V );
-}
-
-// -------------------------------------------------------------------------
-double fpa::Common::IncrementalMeanAndVariance::
-GetDeviation( ) const
-{
-  return( std::sqrt( this->m_V ) );
-}
-
-// -------------------------------------------------------------------------
-unsigned long fpa::Common::IncrementalMeanAndVariance::
-GetNumberOfSamples( ) const
-{
-  return( ( unsigned long )( this->m_N ) );
-}
-
-// -------------------------------------------------------------------------
-void fpa::Common::IncrementalMeanAndVariance::
-Clear( )
-{
-  this->m_M = double( 0 );
-  this->m_V = double( 0 );
-  this->m_N = double( 0 );
-}
-
-// -------------------------------------------------------------------------
-void fpa::Common::IncrementalMeanAndVariance::
-AddValue( double v )
-{
-  this->m_N += double( 1 );
-  double d = v - this->m_M;
-  if( this->m_N > double( 1 ) )
-  {
-    double o = ( this->m_N - double( 2 ) ) / ( this->m_N - double( 1 ) );
-    this->m_V = ( o * this->m_V ) + ( ( d * d ) / this->m_N );
-  }
-  else
-    this->m_V = double( 0 );
-  this->m_M += d / this->m_N;
-}
-
-// eof - $RCSfile$
diff --git a/lib/fpa/Common/IncrementalMeanAndVariance.h b/lib/fpa/Common/IncrementalMeanAndVariance.h
deleted file mode 100644 (file)
index 83383c3..0000000
+++ /dev/null
@@ -1,44 +0,0 @@
-// =========================================================================
-// @author Leonardo Florez Valencia
-// @email florez-l@javeriana.edu.co
-// =========================================================================
-#ifndef __fpa__Common__IncrementalMeanAndVariance__h__
-#define __fpa__Common__IncrementalMeanAndVariance__h__
-
-#include <fpa/fpa_export.h>
-
-namespace fpa
-{
-  namespace Common
-  {
-    /**
-     */
-    class FPA_EXPORT IncrementalMeanAndVariance
-    {
-    public:
-      typedef IncrementalMeanAndVariance Self;
-
-    public:
-      IncrementalMeanAndVariance( );
-      virtual ~IncrementalMeanAndVariance( );
-
-      double GetMean( ) const;
-      double GetVariance( ) const;
-      double GetDeviation( ) const;
-      unsigned long GetNumberOfSamples( ) const;
-
-      void Clear( );
-      void AddValue( double v );
-
-    protected:
-      double m_M;
-      double m_V;
-      double m_N;
-    };
-
-  } // ecapseman
-
-} // ecapseman
-
-#endif // __fpa__Common__IncrementalMeanAndVariance__h__
-// eof - $RCSfile$
diff --git a/lib/fpa/Common/PeakDetector.cxx b/lib/fpa/Common/PeakDetector.cxx
deleted file mode 100644 (file)
index 0a53e1e..0000000
+++ /dev/null
@@ -1,187 +0,0 @@
-// =========================================================================
-// @author Leonardo Florez Valencia
-// @email florez-l@javeriana.edu.co
-// =========================================================================
-#include <fpa/Common/PeakDetector.h>
-#include <cmath>
-
-// -------------------------------------------------------------------------
-fpa::Common::PeakDetector::
-PeakDetector( )
-  : m_K( 3 ),
-    m_T( 3.5 ),
-    m_I( 0.5 )
-{
-}
-
-// -------------------------------------------------------------------------
-fpa::Common::PeakDetector::
-~PeakDetector( )
-{
-}
-
-// -------------------------------------------------------------------------
-unsigned long fpa::Common::PeakDetector::
-GetKernelSize( ) const
-{
-  return( this->m_K );
-}
-
-// -------------------------------------------------------------------------
-double fpa::Common::PeakDetector::
-GetThreshold( ) const
-{
-  return( this->m_T );
-}
-
-// -------------------------------------------------------------------------
-double fpa::Common::PeakDetector::
-GetInfluence( ) const
-{
-  return( this->m_I );
-}
-
-// -------------------------------------------------------------------------
-void fpa::Common::PeakDetector::
-SetKernelSize( unsigned long k )
-{
-  this->m_K = k;
-  this->Clear( );
-}
-
-// -------------------------------------------------------------------------
-void fpa::Common::PeakDetector::
-SetThreshold( double t )
-{
-  this->m_T = t;
-  this->Clear( );
-}
-
-// -------------------------------------------------------------------------
-void fpa::Common::PeakDetector::
-SetInfluence( double i )
-{
-  this->m_I = i;
-  this->Clear( );
-}
-
-// -------------------------------------------------------------------------
-void fpa::Common::PeakDetector::
-Clear( )
-{
-  this->m_X.clear( );
-  this->m_Y.clear( );
-  this->m_YF.clear( );
-  this->m_Avg.clear( );
-  this->m_STD.clear( );
-  this->m_Peaks.clear( );
-  this->m_MeanAndVar.Clear( );
-}
-
-// -------------------------------------------------------------------------
-const std::vector< double >& fpa::Common::PeakDetector::
-GetXValues( ) const
-{
-  return( this->m_X );
-}
-
-// -------------------------------------------------------------------------
-const std::vector< double >& fpa::Common::PeakDetector::
-GetYValues( ) const
-{
-  return( this->m_Y );
-}
-
-// -------------------------------------------------------------------------
-const std::vector< double >& fpa::Common::PeakDetector::
-GetFilteredYValues( ) const
-{
-  return( this->m_YF );
-}
-
-// -------------------------------------------------------------------------
-const std::vector< double >& fpa::Common::PeakDetector::
-GetAverages( ) const
-{
-  return( this->m_Avg );
-}
-
-// -------------------------------------------------------------------------
-const std::vector< double >& fpa::Common::PeakDetector::
-GetDeviations( ) const
-{
-  return( this->m_STD );
-}
-
-// -------------------------------------------------------------------------
-const std::vector< fpa::Common::PeakDetector::TPeak >& fpa::Common::
-PeakDetector::GetPeaks( ) const
-{
-  return( this->m_Peaks );
-}
-
-// -------------------------------------------------------------------------
-unsigned long fpa::Common::PeakDetector::
-GetNumberOfSamples( ) const
-{
-  return( this->m_X.size( ) );
-}
-
-// -------------------------------------------------------------------------
-fpa::Common::PeakDetector::
-TPeak fpa::Common::PeakDetector::
-AddValue( double x, double y )
-{
-  this->m_X.push_back( x );
-  this->m_Y.push_back( y );
-
-  if( this->m_YF.size( ) < this->m_K )
-  {
-    this->m_YF.push_back( y );
-    this->m_Avg.push_back( double( 0 ) );
-    this->m_STD.push_back( double( 0 ) );
-    this->m_Peaks.push_back( Self::NoPeak );
-
-    this->m_MeanAndVar.AddValue( y );
-    if( this->m_YF.size( ) == this->m_K )
-    {
-      this->m_Avg.push_back( this->m_MeanAndVar.GetMean( ) );
-      this->m_STD.push_back( this->m_MeanAndVar.GetDeviation( ) );
-
-    } // fi
-  }
-  else
-  {
-    unsigned long i = this->m_X.size( ) - 1;
-    if(
-      ( std::fabs( y - this->m_Avg[ i - 1 ] ) ) >
-      ( this->m_T * this->m_STD[ i - 1 ] )
-      )
-    {
-      this->m_Peaks.push_back(
-        ( y > this->m_Avg[ i - 1 ] )? Self::PosPeak: Self::NegPeak
-        );
-      this->m_YF.push_back(
-        ( this->m_I * y ) +
-        ( ( double( 1 ) - this->m_I ) * this->m_YF[ i - 1 ] )
-        );
-    }
-    else
-    {
-      this->m_Peaks.push_back( Self::NoPeak );
-      this->m_YF.push_back( y );
-
-    } // fi
-
-    this->m_MeanAndVar.Clear( );
-    unsigned long k = 0;
-    for( unsigned long j = i - this->m_K; j <= i; ++j, ++k )
-      this->m_MeanAndVar.AddValue( this->m_YF[ j ] );
-    this->m_Avg.push_back( this->m_MeanAndVar.GetMean( ) );
-    this->m_STD.push_back( this->m_MeanAndVar.GetDeviation( ) );
-
-  } // fi
-  return( this->m_Peaks.back( ) );
-}
-
-// eof - $RCSfile$
diff --git a/lib/fpa/Common/PeakDetector.h b/lib/fpa/Common/PeakDetector.h
deleted file mode 100644 (file)
index 8796cc3..0000000
+++ /dev/null
@@ -1,75 +0,0 @@
-// =========================================================================
-// @author Leonardo Florez Valencia
-// @email florez-l@javeriana.edu.co
-// =========================================================================
-#ifndef __fpa__Common__PeakDetector__h__
-#define __fpa__Common__PeakDetector__h__
-
-#include <vector>
-#include <fpa/fpa_export.h>
-#include <fpa/Common/IncrementalMeanAndVariance.h>
-
-namespace fpa
-{
-  namespace Common
-  {
-    /**
-     */
-    /**
-     * https://stackoverflow.com/questions/22583391/peak-signal-detection-in-realtime-timeseries-data
-     */
-    class FPA_EXPORT PeakDetector
-    {
-    public:
-      typedef PeakDetector Self;
-
-      enum TPeak
-      {
-        NoPeak = 0,
-        PosPeak,
-        NegPeak
-      };
-
-    public:
-      PeakDetector( );
-      virtual ~PeakDetector( );
-
-      unsigned long GetKernelSize( ) const;
-      double GetThreshold( ) const;
-      double GetInfluence( ) const;
-
-      void SetKernelSize( unsigned long k );
-      void SetThreshold( double t );
-      void SetInfluence( double i );
-
-      const std::vector< double >& GetXValues( ) const;
-      const std::vector< double >& GetYValues( ) const;
-      const std::vector< double >& GetFilteredYValues( ) const;
-      const std::vector< double >& GetAverages( ) const;
-      const std::vector< double >& GetDeviations( ) const;
-      const std::vector< TPeak >& GetPeaks( ) const;
-
-      void Clear( );
-      unsigned long GetNumberOfSamples( ) const;
-      TPeak AddValue( double x, double y );
-
-    protected:
-      unsigned long m_K;
-      double m_T;
-      double m_I;
-
-      std::vector< double > m_X;
-      std::vector< double > m_Y;
-      std::vector< double > m_YF;
-      std::vector< double > m_Avg;
-      std::vector< double > m_STD;
-      std::vector< TPeak >  m_Peaks;
-      fpa::Common::IncrementalMeanAndVariance m_MeanAndVar;
-    };
-
-  } // ecapseman
-
-} // ecapseman
-
-#endif // __fpa__Common__PeakDetector__h__
-// eof - $RCSfile$
index 14e8c539cefc3fb78ece97f763b17454d7acc3f8..df99fb78af2074362a476835b932cc759d6899b3 100644 (file)
@@ -6,10 +6,11 @@
 #define __fpa__Filters__Mori__h__
 
 #include <fpa/Config.h>
-#include <fpa/Common/PeakDetector.h>
 #include <fpa/Filters/QueueAlgorithm.h>
 #include <fpa/Functors/RegionGrow/BinaryThreshold.h>
 
+#include <ivq/ITK/PeakDetector.h>
+
 namespace fpa
 {
   namespace Filters
@@ -31,7 +32,7 @@ namespace fpa
       fpaTraitsMacro( typename TTraits );
 
       typedef std::set< TInputValue >   TThresholds;
-      typedef fpa::Common::PeakDetector TPeakDetector;
+      typedef ivq::ITK::PeakDetector    TPeakDetector;
       typedef TPeakDetector::TPeak      TPeak;
       typedef fpa::Functors::RegionGrow::BinaryThreshold< TInputValue > TPredicate;