Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/build-test-package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ on:

jobs:
cxx-build-workflow-itk5:
uses: InsightSoftwareConsortium/ITKRemoteModuleBuildTestPackageAction/.github/workflows/build-test-cxx.yml@v5.4.6
uses: InsightSoftwareConsortium/ITKRemoteModuleBuildTestPackageAction/.github/workflows/build-test-cxx.yml@v5.4.7

cxx-build-workflow-itk6:
uses: InsightSoftwareConsortium/ITKRemoteModuleBuildTestPackageAction/.github/workflows/build-test-cxx.yml@v6.0b02
Expand All @@ -21,7 +21,7 @@ jobs:
itk-git-tag: '5d31af3cfdf2071d14dfc331d169111487b80597'

python-build-workflow-itk5:
uses: InsightSoftwareConsortium/ITKRemoteModuleBuildTestPackageAction/.github/workflows/build-test-package-python.yml@v5.4.6
uses: InsightSoftwareConsortium/ITKRemoteModuleBuildTestPackageAction/.github/workflows/build-test-package-python.yml@v5.4.7
with:
test-notebooks: false

Expand Down
87 changes: 30 additions & 57 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,64 +11,37 @@ endif()

option(LSTK_USE_VTK "Build visualization helper tools." OFF)
if(LSTK_USE_VTK)
if(NOT COMMAND vtk_module_config)
macro(vtk_module_config ns)
foreach(arg ${ARGN})
if(${arg} MATCHES "^[Vv][Tt][Kk]")
string(REGEX REPLACE "^[Vv][Tt][Kk]" "" _arg ${arg})
else()
set(_arg ${arg})
endif()
set(${ns}_LIBRARIES ${${ns}_LIBRARIES} VTK::${_arg})
endforeach()
endmacro()

if(NOT VTK_RENDERING_BACKEND)
set(VTK_RENDERING_BACKEND OpenGL2)
endif()
endif()

if(NOT VTK_RENDERING_BACKEND)
if(NOT COMMAND vtk_module_config)
set(VTK_RENDERING_BACKEND OpenGL2)
else()
set(VTK_RENDERING_BACKEND OpenGL)
endif()
endif()

set(_target_freetypeopengl)
if(TARGET ${_target_prefix}RenderingFreeType${VTK_RENDERING_BACKEND})
set(_target_freetypeopengl ${_target_prefix}RenderingFreeType${VTK_RENDERING_BACKEND})
find_package(
VTK 9.0 REQUIRED
COMPONENTS
CommonCore
FiltersCore
FiltersGeneral
FiltersSources
ImagingCore
InteractionImage
InteractionStyle
InteractionWidgets
IOGeometry
IOImage
IOLegacy
RenderingCore
RenderingFreeType
RenderingOpenGL2
RenderingVolume
RenderingVolumeOpenGL2
vtksys
)
# ITK 6 exports one interface library per module; ITK 5.4 provides only the list variable.
if(TARGET ITK::LesionSizingToolkitModule)
set(_lstk_libraries ITK::LesionSizingToolkitModule)
elseif(TARGET LesionSizingToolkitModule)
set(_lstk_libraries LesionSizingToolkitModule)
else()
set(_lstk_libraries ${LesionSizingToolkit_LIBRARIES})
endif()

set(_required_vtk_libraries
${_target_prefix}RenderingVolume
#${_target_prefix}Rendering${VTK_RENDERING_BACKEND}
${_target_prefix}IOGeometry
${_target_prefix}IOLegacy
${_target_prefix}IOImage
${_target_prefix}InteractionWidgets
${_target_prefix}InteractionImage
)

vtk_module_config(ITK_VTK_LSTK
${_required_vtk_libraries}
)

set(ITK_VTK_LSTK_LIBRARIES ${LesionSizingToolkit_LIBRARIES} ${_required_vtk_libraries})

# The VTK DICOMParser and vtkmetaio includes conflict with the ITK
# versions. Here we remove them from the include directories.
#
string(REGEX REPLACE "[^;]*MetaIO;"
"" ITK_VTK_LSTK_INCLUDE_DIRS "${ITK_VTK_LSTK_INCLUDE_DIRS}")
string(REGEX REPLACE "[^;]*vtkmetaio;"
"" ITK_VTK_LSTK_INCLUDE_DIRS "${ITK_VTK_LSTK_INCLUDE_DIRS}")
string(REGEX REPLACE "[^;]*DICOMParser;"
"" ITK_VTK_LSTK_INCLUDE_DIRS "${ITK_VTK_LSTK_INCLUDE_DIRS}")

# Add preprocessor definitions needed to use VTK.
set_property(DIRECTORY APPEND PROPERTY COMPILE_DEFINITIONS ${ITK_VTK_LSTK_VTK_DEFINITIONS})
set(ITK_VTK_LSTK_LIBRARIES ${_lstk_libraries} ${ITK_LIBRARIES} ${VTK_LIBRARIES})
include_directories("${LesionSizingToolkit_SOURCE_DIR}/include")

add_subdirectory(Examples)
add_subdirectory(Utilities)
Expand Down
1 change: 1 addition & 0 deletions Examples/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,5 @@ add_executable( LesionSegmentation
LesionSegmentation.cxx
itkLesionSegmentationCommandLineProgressReporter.cxx )
target_link_libraries( LesionSegmentation ${ITK_VTK_LSTK_LIBRARIES} )
vtk_module_autoinit( TARGETS LesionSegmentation MODULES ${VTK_LIBRARIES} )

6 changes: 3 additions & 3 deletions Examples/LesionSegmentation.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ GetImage(std::string dir, bool ignoreDirection)
catch (itk::ExceptionObject & ex)
{
std::cout << ex << std::endl;
return NULL;
return nullptr;
}


Expand All @@ -172,10 +172,10 @@ GetImage(std::string dir, bool ignoreDirection)
catch (itk::ExceptionObject & ex)
{
std::cout << ex << std::endl;
return NULL;
return nullptr;
}

return NULL;
return nullptr;
}

// --------------------------------------------------------------------------
Expand Down
6 changes: 3 additions & 3 deletions Examples/LesionSegmentationCLI.h
Original file line number Diff line number Diff line change
Expand Up @@ -125,8 +125,8 @@ class LesionSegmentationCLI : public MetaCommand
seeds[0];
for (int i = 0; i < 3; i++)
{
this->ROI[2 * i] = seeds[0].GetPosition()[i] - this->GetValueAsFloat("MaximumRadius");
this->ROI[2 * i + 1] = seeds[0].GetPosition()[i] + this->GetValueAsFloat("MaximumRadius");
this->ROI[2 * i] = seeds[0].GetPositionInObjectSpace()[i] - this->GetValueAsFloat("MaximumRadius");
this->ROI[2 * i + 1] = seeds[0].GetPositionInObjectSpace()[i] + this->GetValueAsFloat("MaximumRadius");
}
}
return this->ROI;
Expand Down Expand Up @@ -252,7 +252,7 @@ class LesionSegmentationCLI : public MetaCommand
exit(-1);
}

seeds[i].SetPosition(sx, sy, sz);
seeds[i].SetPositionInObjectSpace(sx, sy, sz);
}
return seeds;
}
Expand Down
16 changes: 8 additions & 8 deletions Examples/itkLesionSegmentationCommandLineProgressReporter.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@
*=========================================================================*/

#ifndef itkLesionSegmentationCommandLineProgressReporter_h
# define itkLesionSegmentatioCommandLineProgressReporter_h
#define itkLesionSegmentationCommandLineProgressReporter_h

# include "itkLesionSegmentationImageFilter8.h"
# include "itkCommand.h"
# include <string>
#include "itkLesionSegmentationImageFilter8.h"
#include "itkCommand.h"
#include <string>

namespace itk
{
Expand All @@ -45,10 +45,10 @@ class ITKCommon_EXPORT LesionSegmentationCommandLineProgressReporter : public Co
// the instance invoking the event; eid is the event id (see
// vtkCommand.h); and calldata is information sent when the callback
// was invoked (e.g., progress value in the vtkCommand::ProgressEvent).
virtual void
Execute(const Object * caller, const EventObject & event);
virtual void
Execute(Object * caller, const EventObject & event);
void
Execute(const Object * caller, const EventObject & event) override;
void
Execute(Object * caller, const EventObject & event) override;

void
SetReportProgress(int i)
Expand Down
4 changes: 4 additions & 0 deletions Utilities/Visualization/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,20 @@ include_directories(${Visualization_SOURCE_DIR})

add_executable(ViewImageAndSegmentationSurface ViewImageAndSegmentationSurface.cxx )
target_link_libraries(ViewImageAndSegmentationSurface ${ITK_VTK_LSTK_LIBRARIES})
vtk_module_autoinit(TARGETS ViewImageAndSegmentationSurface MODULES ${VTK_LIBRARIES})

add_executable(ViewImageSlicesAndSegmentationContours
ViewImageSlicesAndSegmentationContours.cxx
vtkContourVisualizationModule.cxx
)
target_link_libraries(ViewImageSlicesAndSegmentationContours ${ITK_VTK_LSTK_LIBRARIES})
vtk_module_autoinit(TARGETS ViewImageSlicesAndSegmentationContours MODULES ${VTK_LIBRARIES})

add_executable(LesionSurfaceExtraction LesionSurfaceExtraction.cxx )
target_link_libraries(LesionSurfaceExtraction ${ITK_VTK_LSTK_LIBRARIES})
vtk_module_autoinit(TARGETS LesionSurfaceExtraction MODULES ${VTK_LIBRARIES})

add_executable(IsoSurfaceVolumeEstimation IsoSurfaceVolumeEstimation.cxx )
target_link_libraries(IsoSurfaceVolumeEstimation ${ITK_VTK_LSTK_LIBRARIES})
vtk_module_autoinit(TARGETS IsoSurfaceVolumeEstimation MODULES ${VTK_LIBRARIES})

2 changes: 2 additions & 0 deletions Utilities/Visualization/LesionSurfaceExtraction.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@
#include "vtksys/SystemTools.hxx"
#include "vtkVersion.h"

#include <iostream>


#define VTK_CREATE(type, name) vtkSmartPointer<type> name = vtkSmartPointer<type>::New()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,11 +88,11 @@ main(int argc, char * argv[])
return EXIT_FAILURE;
}

std::cout << "Number of objects in the group:" << group->GetNumberOfObjects(1) << std::endl;
std::cout << "Number of objects in the group:" << group->GetNumberOfChildren(1) << std::endl;

using ObjectListType = SpatialObjectReaderType::GroupType::ObjectListType;
using ObjectListType = SpatialObjectReaderType::GroupType::ChildrenListType;

ObjectListType * groupChildren = group->GetObjects(999999);
ObjectListType * groupChildren = group->GetChildren(999999);

ObjectListType::const_iterator spatialObjectItr = groupChildren->begin();

Expand All @@ -119,7 +119,7 @@ main(int argc, char * argv[])
const LandmarkPointListType & points = landmarkSpatialObject->GetPoints();

// Grab the first point in the list of seed points
PointType point = points[0].GetPosition();
PointType point = points[0].GetPositionInObjectSpace();

std::cout << "Seed point = " << point << std::endl;

Expand Down
2 changes: 0 additions & 2 deletions include/itkFeatureAggregator.h
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,6 @@ class ITK_TEMPLATE_EXPORT FeatureAggregator : public FeatureGenerator<NDimension
const InputFeatureType *
GetInputFeature(unsigned int featureId) const;

ProgressAccumulator::Pointer m_ProgressAccumulator;

private:
using FeatureGeneratorPointer = typename FeatureGeneratorType::Pointer;
using FeatureGeneratorArrayType = std::vector<FeatureGeneratorPointer>;
Expand Down
8 changes: 4 additions & 4 deletions include/itkFeatureAggregator.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,6 @@ FeatureAggregator<NDimension>::FeatureAggregator()
typename OutputImageSpatialObjectType::Pointer outputObject = OutputImageSpatialObjectType::New();

this->ProcessObject::SetNthOutput(0, outputObject.GetPointer());

this->m_ProgressAccumulator = ProgressAccumulator::New();
this->m_ProgressAccumulator->SetMiniPipelineFilter(this);
}


Expand Down Expand Up @@ -143,14 +140,17 @@ template <unsigned int NDimension>
void
FeatureAggregator<NDimension>::UpdateAllFeatureGenerators()
{
ProgressAccumulator::Pointer progress = ProgressAccumulator::New();
progress->SetMiniPipelineFilter(this);

auto gitr = this->m_FeatureGenerators.begin();
auto gend = this->m_FeatureGenerators.end();

while (gitr != gend)
{
// Assuming that most of the time is spent in generating the features and
// hardly negligible time is spent in consolidating the features
this->m_ProgressAccumulator->RegisterInternalFilter(*gitr, 1.0 / this->m_FeatureGenerators.size());
progress->RegisterInternalFilter(*gitr, 1.0 / this->m_FeatureGenerators.size());

(*gitr)->Update();
++gitr;
Expand Down
6 changes: 2 additions & 4 deletions include/itkLesionSegmentationMethod.h
Original file line number Diff line number Diff line change
Expand Up @@ -125,12 +125,10 @@ class ITK_TEMPLATE_EXPORT LesionSegmentationMethod : public ProcessObject

SegmentationModulePointer m_SegmentationModule;

ProgressAccumulator::Pointer m_ProgressAccumulator;


/** This method calls the Update() method of each one of the feature generators */
void
UpdateAllFeatureGenerators();
UpdateAllFeatureGenerators(ProgressAccumulator * progress);

/** This method compares the number of available features against the number
* of expected features, and it will throw an exception if they do not match.
Expand All @@ -143,7 +141,7 @@ class ITK_TEMPLATE_EXPORT LesionSegmentationMethod : public ProcessObject
ConnectFeaturesToSegmentationModule();

void
ExecuteSegmentationModule();
ExecuteSegmentationModule(ProgressAccumulator * progress);
};

} // end namespace itk
Expand Down
18 changes: 9 additions & 9 deletions include/itkLesionSegmentationMethod.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,6 @@ LesionSegmentationMethod<NDimension>::LesionSegmentationMethod()
typename OutputSpatialObjectType::Pointer outputObject = OutputSpatialObjectType::New();

this->ProcessObject::SetNthOutput(0, outputObject.GetPointer());

this->m_ProgressAccumulator = ProgressAccumulator::New();
this->m_ProgressAccumulator->SetMiniPipelineFilter(this);
}


Expand Down Expand Up @@ -105,13 +102,16 @@ LesionSegmentationMethod<NDimension>::GenerateData()
itkExceptionMacro("Segmentation Module has not been connected");
}

this->UpdateAllFeatureGenerators();
ProgressAccumulator::Pointer progress = ProgressAccumulator::New();
progress->SetMiniPipelineFilter(this);

this->UpdateAllFeatureGenerators(progress);

this->VerifyNumberOfAvailableFeaturesMatchedExpectations();

this->ConnectFeaturesToSegmentationModule();

this->ExecuteSegmentationModule();
this->ExecuteSegmentationModule(progress);
}


Expand All @@ -120,14 +120,14 @@ LesionSegmentationMethod<NDimension>::GenerateData()
*/
template <unsigned int NDimension>
void
LesionSegmentationMethod<NDimension>::UpdateAllFeatureGenerators()
LesionSegmentationMethod<NDimension>::UpdateAllFeatureGenerators(ProgressAccumulator * progress)
{
auto gitr = this->m_FeatureGenerators.begin();
auto gend = this->m_FeatureGenerators.end();

while (gitr != gend)
{
this->m_ProgressAccumulator->RegisterInternalFilter(*gitr, 0.5 / this->m_FeatureGenerators.size());
progress->RegisterInternalFilter(*gitr, 0.5 / this->m_FeatureGenerators.size());
(*gitr)->Update();
++gitr;
}
Expand Down Expand Up @@ -164,9 +164,9 @@ LesionSegmentationMethod<NDimension>::ConnectFeaturesToSegmentationModule()

template <unsigned int NDimension>
void
LesionSegmentationMethod<NDimension>::ExecuteSegmentationModule()
LesionSegmentationMethod<NDimension>::ExecuteSegmentationModule(ProgressAccumulator * progress)
{
this->m_ProgressAccumulator->RegisterInternalFilter(this->m_SegmentationModule, 0.5);
progress->RegisterInternalFilter(this->m_SegmentationModule, 0.5);
this->m_SegmentationModule->SetInput(this->m_InitialSegmentation);
this->m_SegmentationModule->Update();
}
Expand Down
Loading