diff --git a/code/CMakeLists.txt b/code/CMakeLists.txt index c1b92f0..402f644 100644 --- a/code/CMakeLists.txt +++ b/code/CMakeLists.txt @@ -1,26 +1,25 @@ MESSAGE(STATUS "processing RTToolbox code") ADD_SUBDIRECTORY(core) ADD_SUBDIRECTORY(algorithms) + +OPTION(BUILD_Interpolation "Determine if the dose interpolation classes will be generated." OFF) +IF(BUILD_All_Modules OR BUILD_Interpolation) + ADD_SUBDIRECTORY(interpolation) + SET(BUILD_Interpolation ON CACHE BOOL ON FORCE) +ENDIF() + ADD_SUBDIRECTORY(indices) OPTION(BUILD_Models "Determine if the model classes will be generated." OFF) IF(BUILD_All_Modules OR BUILD_Models) ADD_SUBDIRECTORY(models) SET(BUILD_Models ON CACHE BOOL ON FORCE) ENDIF() OPTION(BUILD_Masks "Determine if the mask classes will be generated." ON) IF(BUILD_All_Modules OR BUILD_Masks) ADD_SUBDIRECTORY(masks) SET(BUILD_Masks ON CACHE BOOL ON FORCE) ENDIF() -ADD_SUBDIRECTORY(io) - -OPTION(BUILD_Interpolation "Determine if the dose interpolation classes will be generated." OFF) -IF(BUILD_All_Modules OR BUILD_Interpolation) - ADD_SUBDIRECTORY(interpolation) - SET(BUILD_Interpolation ON CACHE BOOL ON FORCE) -ENDIF() - - +ADD_SUBDIRECTORY(io) \ No newline at end of file diff --git a/code/indices/CMakeLists.txt b/code/indices/CMakeLists.txt index bdb24cc..a14e257 100644 --- a/code/indices/CMakeLists.txt +++ b/code/indices/CMakeLists.txt @@ -1 +1 @@ -RTTB_CREATE_MODULE(RTTBIndices DEPENDS RTTBCore PACKAGE_DEPENDS Boost) \ No newline at end of file +RTTB_CREATE_MODULE(RTTBIndices DEPENDS RTTBCore RTTBInterpolation PACKAGE_DEPENDS Boost) \ No newline at end of file diff --git a/code/indices/files.cmake b/code/indices/files.cmake index 6f42e98..4b96429 100644 --- a/code/indices/files.cmake +++ b/code/indices/files.cmake @@ -1,19 +1,23 @@ SET(CPP_FILES rttbConformalIndex.cpp rttbConformationNumber.cpp rttbConformityIndex.cpp rttbCoverageIndex.cpp rttbDoseIndex.cpp rttbDvhBasedDoseIndex.cpp rttbHomogeneityIndex.cpp + rttbSpatialDoseIndex.cpp + rttbGammaIndex.cpp ) SET(H_FILES rttbConformalIndex.h rttbConformationNumber.h rttbConformityIndex.h rttbCoverageIndex.h rttbDoseIndex.h rttbDvhBasedDoseIndex.h rttbHomogeneityIndex.h + rttbSpatialDoseIndex.h + rttbGammaIndex.h ) diff --git a/code/indices/rttbGammaIndex.cpp b/code/indices/rttbGammaIndex.cpp new file mode 100644 index 0000000..632fad0 --- /dev/null +++ b/code/indices/rttbGammaIndex.cpp @@ -0,0 +1,75 @@ +// ----------------------------------------------------------------------- +// RTToolbox - DKFZ radiotherapy quantitative evaluation library +// +// Copyright (c) German Cancer Research Center (DKFZ), +// Software development for Integrated Diagnostics and Therapy (SIDT). +// ALL RIGHTS RESERVED. +// See rttbCopyright.txt or +// http://www.dkfz.de/en/sidt/projects/rttb/copyright.html +// +// This software is distributed WITHOUT ANY WARRANTY; without even +// the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +// PURPOSE. See the above copyright notices for more information. +// +//------------------------------------------------------------------------ + +#include "rttbGammaIndex.h" +#include "rttbException.h" +#include "rttbInvalidParameterException.h" + +namespace rttb +{ + namespace indices + { + + //SpatialDoseIndex::SpatialDoseIndex(DoseTypeGy aDoseReference) + // : _doseReference(aDoseReference), _initSuccess(false) {} + + // SpatialDoseIndex::~SpatialDoseIndex()= default; + + //bool SpatialDoseIndex::init() + //{ + // if (!(this->checkInputs())) + // { + // throw core::InvalidParameterException("Check inputs failed: invalid parameters! "); + // } + + // if (this->calcIndex()) + // { + // _initSuccess = true; + // } + // else + // { + // throw core::InvalidParameterException("Index calculation failed! "); + // } + + // return _initSuccess; + //} + + //void SpatialDoseIndex::setDoseReference(DoseTypeGy aDoseReference) + //{ + // _doseReference = aDoseReference; + // _initSuccess = false; + // init(); + //} + + //DoseTypeGy SpatialDoseIndex::getDoseReference() const + //{ + // return _doseReference; + //} + + //IndexValueType SpatialDoseIndex::getValue() const + //{ + // if (_initSuccess) + // { + // return _value; + // } + // else + // { + // throw core::Exception("SpatialDoseIndex init error: init() must be called first!"); + // } + //} + } +} + + diff --git a/code/indices/rttbGammaIndex.h b/code/indices/rttbGammaIndex.h new file mode 100644 index 0000000..7583777 --- /dev/null +++ b/code/indices/rttbGammaIndex.h @@ -0,0 +1,86 @@ +// ----------------------------------------------------------------------- +// RTToolbox - DKFZ radiotherapy quantitative evaluation library +// +// Copyright (c) German Cancer Research Center (DKFZ), +// Software development for Integrated Diagnostics and Therapy (SIDT). +// ALL RIGHTS RESERVED. +// See rttbCopyright.txt or +// http://www.dkfz.de/en/sidt/projects/rttb/copyright.html +// +// This software is distributed WITHOUT ANY WARRANTY; without even +// the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +// PURPOSE. See the above copyright notices for more information. +// +//------------------------------------------------------------------------ + +#ifndef __GAMMA_INDEX_H +#define __GAMMA_INDEX_H + +#include "rttbSpatialDoseIndex.h" + +#include "rttbInterpolationBase.h" + +#include "RTTBIndicesExports.h" + +namespace rttb +{ + namespace indices + { + /*! @class SpatialDoseIndex + @brief This is the base class for indicies that are computed on spatialy resolved + dose distributions (e.g. gamma index). + In contrast to other "normal" DVH based indices that are not spatialy resolved (like + e.g. ConformityIndex), these type of indices are computed on a spatialy resolved dose + distribution for specifeid points in space. Thus this index type itself has a geometry + info and is spatialy distributed. + @ingroup indices + */ + class RTTBIndices_EXPORT GammaIndex : SpatialDoseIndex + { + public: + rttbClassMacro(GammaIndex, SpatialDoseIndex); + + /*! @brief Constructor with the referece dose*/ + GammaIndex(core::DoseAccessorInterface::ConstPointer computedDose, + core::DoseAccessorInterface::ConstPointer referenceDose); + + GammaIndex(core::DoseAccessorInterface::ConstPointer dose, + core::DoseAccessorInterface::ConstPointer referenceDose, + double distaneToAgreementThreshold, double doseDifferenceThreshold); + virtual ~GammaIndex(); + + GenericValueType getValueAt(const VoxelGridID aID) const override; + + GenericValueType getValueAt(const VoxelGridIndex3D& aIndex) const override; + + const IDType getUID() const override; + + protected: + + /** Reference dose used to compare the computed dose with.*/ + core::DoseAccessorInterface::ConstPointer _referenceDose; + + interpolation::InterpolationBase::Pointer _doseInterpolator; + interpolation::InterpolationBase::Pointer _referenceDoseInterpolator; + + /** Distance to aggreement (DTA) threshold for the gamma index comutation. Specified in mm.*/ + double _dtaThreshold = 3.; + + /** To calculate the gamma index one has to sample the reference dose within the DTA. This + variable controls how dense the sampling is within the Dit is sampled a Distance to aggreement (DTA) threshold for the gamma index comutation. Specified in mm.*/ + unsigned int _spatialResolution = 10; + + /** in %*/ + double _doseDifferenceThreshold = 3.; + + /** */ + bool _useLocalDose = false; + + DoseTypeGy _globalDose = 0.; + + }; + } +} + + +#endif diff --git a/code/indices/rttbSpatialDoseIndex.cpp b/code/indices/rttbSpatialDoseIndex.cpp new file mode 100644 index 0000000..2bf8c09 --- /dev/null +++ b/code/indices/rttbSpatialDoseIndex.cpp @@ -0,0 +1,75 @@ +// ----------------------------------------------------------------------- +// RTToolbox - DKFZ radiotherapy quantitative evaluation library +// +// Copyright (c) German Cancer Research Center (DKFZ), +// Software development for Integrated Diagnostics and Therapy (SIDT). +// ALL RIGHTS RESERVED. +// See rttbCopyright.txt or +// http://www.dkfz.de/en/sidt/projects/rttb/copyright.html +// +// This software is distributed WITHOUT ANY WARRANTY; without even +// the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +// PURPOSE. See the above copyright notices for more information. +// +//------------------------------------------------------------------------ + +#include "rttbSpatialDoseIndex.h" +#include "rttbException.h" +#include "rttbInvalidParameterException.h" + +namespace rttb +{ + namespace indices + { + + //SpatialDoseIndex::SpatialDoseIndex(DoseTypeGy aDoseReference) + // : _doseReference(aDoseReference), _initSuccess(false) {} + + // SpatialDoseIndex::~SpatialDoseIndex()= default; + + //bool SpatialDoseIndex::init() + //{ + // if (!(this->checkInputs())) + // { + // throw core::InvalidParameterException("Check inputs failed: invalid parameters! "); + // } + + // if (this->calcIndex()) + // { + // _initSuccess = true; + // } + // else + // { + // throw core::InvalidParameterException("Index calculation failed! "); + // } + + // return _initSuccess; + //} + + //void SpatialDoseIndex::setDoseReference(DoseTypeGy aDoseReference) + //{ + // _doseReference = aDoseReference; + // _initSuccess = false; + // init(); + //} + + //DoseTypeGy SpatialDoseIndex::getDoseReference() const + //{ + // return _doseReference; + //} + + //IndexValueType SpatialDoseIndex::getValue() const + //{ + // if (_initSuccess) + // { + // return _value; + // } + // else + // { + // throw core::Exception("SpatialDoseIndex init error: init() must be called first!"); + // } + //} + } +} + + diff --git a/code/indices/rttbSpatialDoseIndex.h b/code/indices/rttbSpatialDoseIndex.h new file mode 100644 index 0000000..58c814b --- /dev/null +++ b/code/indices/rttbSpatialDoseIndex.h @@ -0,0 +1,55 @@ +// ----------------------------------------------------------------------- +// RTToolbox - DKFZ radiotherapy quantitative evaluation library +// +// Copyright (c) German Cancer Research Center (DKFZ), +// Software development for Integrated Diagnostics and Therapy (SIDT). +// ALL RIGHTS RESERVED. +// See rttbCopyright.txt or +// http://www.dkfz.de/en/sidt/projects/rttb/copyright.html +// +// This software is distributed WITHOUT ANY WARRANTY; without even +// the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +// PURPOSE. See the above copyright notices for more information. +// +//------------------------------------------------------------------------ + +#ifndef __SPATIAL_DOSE_INDEX_H +#define __SPATIAL_DOSE_INDEX_H + +#include "rttbDoseAccessorInterface.h" + +#include "RTTBIndicesExports.h" + +namespace rttb +{ + namespace indices + { + /*! @class SpatialDoseIndex + @brief This is the base class for indicies that are computed on spatialy resolved + dose distributions (e.g. gamma index). + In contrast to other "normal" DVH based indices that are not spatialy resolved (like + e.g. ConformityIndex), these type of indices are computed on a spatialy resolved dose + distribution for specifeid points in space. Thus this index type itself has a geometry + info and is spatialy distributed. + @ingroup indices + */ + class RTTBIndices_EXPORT SpatialDoseIndex : core::AccessorInterface + { + public: + rttbClassMacro(SpatialDoseIndex, AccessorInterface); + + const core::GeometricInfo& getGeometricInfo() const override; + + protected: + + /*! @brief Constructor with the referece dose*/ + SpatialDoseIndex(core::DoseAccessorInterface::ConstPointer aDose); + virtual ~SpatialDoseIndex(); + + core::DoseAccessorInterface::ConstPointer _dose; + }; + } +} + + +#endif