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)
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$
## @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$
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
}
// -------------------------------------------------------------------------
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 )
// -------------------------------------------------------------------------
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;
seg->AddSeed( seed );
try
{
+ seg->DebugOn( );
seg->Update( );
+ seg->DebugOff( );
}
catch( std::exception& err )
{
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 );
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( )
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( );
}
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( );
<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>
#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>
/**
*/
typedef typename Superclass::TTraits TTraits;
fpaTraitsMacro( typename TTraits );
- typedef fpa::Common::IncrementalMeanAndVariance TMeanAndVar;
+ typedef ivq::ITK::IncrementalMeanAndVariance TMeanAndVar;
public:
itkNewMacro( Self );
SetOutsideLabel( const TLabel& v )
{
this->SetInitValue( v );
+ this->SetFillValue( v );
}
// -------------------------------------------------------------------------
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 );
_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
}
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(
_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 );
#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 >
// 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;
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 );
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(
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(
);
// 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
}
// -------------------------------------------------------------------------
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;
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( );
label->Update( );
out = label->GetOutputLabels( );
out->DisconnectPipeline( );
+
+ std::cout << label->GetLowerThreshold( ) << std::endl;
+ std::cout << label->GetUpperThreshold( ) << std::endl;
+
}
// -------------------------------------------------------------------------
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__
+++ /dev/null
-## =========================================================================
-## @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$
+++ /dev/null
-## =========================================================================
-## @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$
+++ /dev/null
-## =========================================================================
-## @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$
--- /dev/null
+## =========================================================================
+## @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$
--- /dev/null
+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
--- /dev/null
+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
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$
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$
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$
## -- 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}/*")
## -- 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$
+++ /dev/null
-// =========================================================================
-// @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$
+++ /dev/null
-// =========================================================================
-// @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$
+++ /dev/null
-// =========================================================================
-// @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$
+++ /dev/null
-// =========================================================================
-// @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$
#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
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;