diff --git a/code/core/rttbDVHSet.cpp b/code/core/rttbDVHSet.cpp index 67ea484..dec2cfc 100644 --- a/code/core/rttbDVHSet.cpp +++ b/code/core/rttbDVHSet.cpp @@ -1,175 +1,175 @@ // ----------------------------------------------------------------------- // 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. // //------------------------------------------------------------------------ /*! // @file // @version $Revision$ (last changed revision) // @date $Date$ (last change date) // @author $Author$ (last changed by) */ #include "rttbDVHSet.h" #include "rttbInvalidParameterException.h" namespace rttb{ namespace core{ DVHSet::DVHSet(IDType aStructureSetID, IDType aDoseID){ this->_structureSetID=aStructureSetID; this->_doseID=aDoseID; } DVHSet::DVHSet(DVHSetType aDVHTVSet, DVHSetType aDVHHTSet, IDType aStructureSetID, IDType aDoseID){ _dvhHTSet=aDVHHTSet; _dvhTVSet=aDVHTVSet; this->_structureSetID=aStructureSetID; this->_doseID=aDoseID; } DVHSet::DVHSet(DVHSetType aDVHTVSet, DVHSetType aDVHHTSet, DVHSetType aDVHWVSet, IDType aStructureSetID, IDType aDoseID){ _dvhHTSet=aDVHHTSet; _dvhTVSet=aDVHTVSet; _dvhWVSet=aDVHWVSet; this->_structureSetID=aStructureSetID; this->_doseID=aDoseID; } std::size_t DVHSet::size() const{ return _dvhHTSet.size()+_dvhTVSet.size()+_dvhWVSet.size(); } void DVHSet::setStrSetID(IDType aStrSetID){_structureSetID=aStrSetID;} void DVHSet::setDoseID(IDType aDoseID){_doseID=aDoseID;} IDType DVHSet::getStrSetID() const{return _structureSetID;} IDType DVHSet::getDoseID() const{return _doseID;} DVH* DVHSet::getDVH(IDType structureID){ DVHSetType::iterator itTV = _dvhTVSet.begin(); for(;itTV!=_dvhTVSet.end();itTV++){ if((*(itTV)).getStructureID()==structureID) { return &(*itTV); } } DVHSetType::iterator itHT = _dvhHTSet.begin(); for(;itHT!=_dvhHTSet.end();itHT++){ if((*(itHT)).getStructureID()==structureID) { return &(*itHT); } } DVHSetType::iterator itWV = _dvhWVSet.begin(); for(;itWV!=_dvhWVSet.end();itWV++){ if((*(itWV)).getStructureID()==structureID) { return &(*itWV); } } std::cout << "No DVH with the structure id: "<getHTVolume(aDoseAbsolute)+this->getTVVolume(aDoseAbsolute); + VolumeType volume=this->getHealthyTissueVolume(aDoseAbsolute)+this->getTargetVolume(aDoseAbsolute); return volume; } - VolumeType DVHSet::getHTVolume(DoseTypeGy aDoseAbsolute) const{ + VolumeType DVHSet::getHealthyTissueVolume(DoseTypeGy aDoseAbsolute) const{ DVHSetType::const_iterator itHT = _dvhHTSet.begin(); VolumeType volume=0; VolumeType testVol=0; while(itHT!=_dvhHTSet.end()){ DVH dvh=*(itHT); testVol = dvh.getVx(aDoseAbsolute); if (testVol>=0) { volume+=testVol; } itHT++; } return volume; } - VolumeType DVHSet::getTVVolume(DoseTypeGy aDoseAbsolute) const{ + VolumeType DVHSet::getTargetVolume(DoseTypeGy aDoseAbsolute) const{ DVHSetType::const_iterator itTV = _dvhTVSet.begin(); VolumeType volume=0; VolumeType testVol=0; while(itTV!=_dvhTVSet.end()){ DVH dvh=*(itTV); testVol = dvh.getVx(aDoseAbsolute); if (testVol>=0) { volume+=testVol; } itTV++; } return volume; } bool operator==(const DVHSet &aDVHSet, const DVHSet &otherDVHSet){ if (aDVHSet.getStrSetID() != otherDVHSet.getStrSetID()) { return false; } if (aDVHSet.getDoseID() != otherDVHSet.getDoseID()) { return false; } if (aDVHSet.size() != otherDVHSet.size()) { return false; } return true; } std::ostream& operator<<(std::ostream& s, const DVHSet &aDVHSet){ s << "[ " << aDVHSet.getStrSetID() << ", " << aDVHSet.getDoseID() << " ]"; return s; } std::ostream& operator<<(std::ostream& s, const DVHSet::DVHSetType &aDVHSet){ s << "[ "; for( int i = 0; i < aDVHSet.size();i++){ s << aDVHSet.at(i); } s << " ]"; return s; } } } diff --git a/code/core/rttbDVHSet.h b/code/core/rttbDVHSet.h index 95a6d58..9ca3b05 100644 --- a/code/core/rttbDVHSet.h +++ b/code/core/rttbDVHSet.h @@ -1,125 +1,126 @@ // ----------------------------------------------------------------------- // 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. // //------------------------------------------------------------------------ /*! // @file // @version $Revision$ (last changed revision) // @date $Date$ (last change date) // @author $Author$ (last changed by) */ #ifndef __DVH_SET_H #define __DVH_SET_H #include #include #include #include "rttbBaseType.h" #include "rttbDVH.h" namespace rttb{ namespace core{ /*! @class DVHSet @brief This is a class representing a RT DVHSet including Target Volume and Organ at Risk A DVHSet consists of three subsets: one for the target volume (_dvhTVSet), one for healthy tissue (_dvhHTSet), and one for the whole volume (_dvhWVSet). */ class DVHSet { public: typedef std::vector DVHSetType; + typedef DVHSetType::size_type IndexType; private: IDType _structureSetID; IDType _doseID; DVHSetType _dvhTVSet; DVHSetType _dvhHTSet; DVHSetType _dvhWVSet; public: DVHSet(IDType aStructureSetID="", IDType aDoseID=""); DVHSet(DVHSetType aDVHTVSet, DVHSetType aDVHHTSet, IDType aStructureSetID="", IDType aDoseID=""); DVHSet(DVHSetType aDVHTVSet, DVHSetType aDVHHTSet, DVHSetType aDVHWVSet, IDType aStructureSetID="", IDType aDoseID=""); /*! @brief Get the size of the DVHSet, that is the sum of the numbers of DVHs in all sub-sets. */ std::size_t size() const; void setStrSetID(IDType aStrSetID); void setDoseID(IDType aDoseID); IDType getStrSetID() const; IDType getDoseID() const; /*! @brief Get the DVH according to the structure ID @return Return NULL if not found */ DVH* getDVH(IDType aStructureID); /*! @brief Insert a DVH object. @brief param aDVHType "TV" for target volume or "HT" for healthy tissue or "WV" for whole volume @exception InvalidParameterException Thrown if no valid DVHRole was given. */ void insert(DVH& aDvh, DVHRole aDVHRole); /*! @brief Get DVH subset for target volume */ - const DVHSetType& getDVHTVSet() const{return _dvhTVSet;}; + const DVHSetType& getTargetVolumeSet() const{return _dvhTVSet;}; /*! @brief Get DVH subset for healthy tissue */ - const DVHSetType& getDVHHTSet() const{return _dvhHTSet;}; + const DVHSetType& getHealthyTissueSet() const{return _dvhHTSet;}; /*! @brief Get DVH subset for whole volume */ - const DVHSetType& getDVHWVSet() const{return _dvhWVSet;}; + const DVHSetType& getWholeVolumeSet() const{return _dvhWVSet;}; /*! @brief Get the whole volume irradiated to >= aDoseAbsolute */ VolumeType getWholeVolume(DoseTypeGy aDoseAbsolute) const; /*! @brief Get the healthy tissue volume irradiated to >= aDoseAbsolute @return Return -1 if DVH of _dvhHTSet init() failed */ - VolumeType getHTVolume(DoseTypeGy aDoseAbsolute) const; + VolumeType getHealthyTissueVolume(DoseTypeGy aDoseAbsolute) const; /*! @brief Get the target volume irradiated to >= aDoseAbsolute @return Return -1 if DVH of _dvhTVSet init() failed */ - VolumeType getTVVolume(DoseTypeGy aDoseAbsolute) const; + VolumeType getTargetVolume(DoseTypeGy aDoseAbsolute) const; /*! DVHSets are considered equal if they have the same structureSet, dose and voxelization ID and the number of DVHs are equal. */ bool friend operator==(const DVHSet &aDVHSet, const DVHSet &otherDVHSet); friend std::ostream& operator<<(std::ostream& s, const DVHSet &aDVHSet); friend std::ostream& operator<<(std::ostream& s, const DVHSetType &aDVHSet); }; bool operator==(const DVHSet &aDVHSet, const DVHSet &otherDVHSet); std::ostream& operator<<(std::ostream& s, const DVHSet &aDVHSet); std::ostream& operator<<(std::ostream& s, const DVHSet::DVHSetType &aDVHSet); } - } +} #endif diff --git a/code/indices/files.cmake b/code/indices/files.cmake index f08aa12..6f42e98 100644 --- a/code/indices/files.cmake +++ b/code/indices/files.cmake @@ -1,17 +1,19 @@ SET(CPP_FILES rttbConformalIndex.cpp rttbConformationNumber.cpp rttbConformityIndex.cpp rttbCoverageIndex.cpp rttbDoseIndex.cpp + rttbDvhBasedDoseIndex.cpp rttbHomogeneityIndex.cpp ) SET(H_FILES rttbConformalIndex.h rttbConformationNumber.h rttbConformityIndex.h rttbCoverageIndex.h rttbDoseIndex.h + rttbDvhBasedDoseIndex.h rttbHomogeneityIndex.h ) diff --git a/code/indices/rttbConformalIndex.cpp b/code/indices/rttbConformalIndex.cpp index d6794d7..06ba900 100644 --- a/code/indices/rttbConformalIndex.cpp +++ b/code/indices/rttbConformalIndex.cpp @@ -1,115 +1,101 @@ // ----------------------------------------------------------------------- // 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. // //------------------------------------------------------------------------ /*! // @file // @version $Revision$ (last changed revision) // @date $Date$ (last change date) // @author $Author$ (last changed by) */ #include "rttbConformalIndex.h" #include "rttbNullPointerException.h" #include "rttbInvalidParameterException.h" #include "rttbExceptionMacros.h" namespace rttb{ namespace indices{ - ConformalIndex::ConformalIndex(core::DVHSet* dvhSet, DoseTypeGy aDoseReference) + ConformalIndex::ConformalIndex(ConformalIndex::DVHSetPtr dvhSet, DoseTypeGy aDoseReference) + :DvhBasedDoseIndex(dvhSet, aDoseReference) { - _dvhSet=dvhSet; - _doseReference=aDoseReference; - initSuccess=false; - } - - bool ConformalIndex::init() - { - if(!_dvhSet){ - throw core::NullPointerException("DVHSet must not be NULL! "); - } - if(this->calcIndex()){ - initSuccess=true; - return true; - } - else - return false; + init(); } bool ConformalIndex::calcIndex() { - VolumeType TV=_dvhSet->getTVVolume(0); + VolumeType TV=_dvhSet->getTargetVolume(0); VolumeType Vref=_dvhSet->getWholeVolume(_doseReference); if(TV!=0 && Vref!=0){ - _value=(_dvhSet->getTVVolume(_doseReference)/TV)* - (_dvhSet->getTVVolume(_doseReference)/Vref); + _value=(_dvhSet->getTargetVolume(_doseReference)/TV)* + (_dvhSet->getTargetVolume(_doseReference)/Vref); - std::vector dvhHTSet=this->_dvhSet->getDVHHTSet(); + std::vector dvhHTSet=this->_dvhSet->getHealthyTissueSet(); std::vector::iterator it; for(it=dvhHTSet.begin(); it!=dvhHTSet.end();++it) { core::DVH dvh=*(it); VolumeType HT=dvh.getVx(0); if(HT!=0) _value*=(1-dvh.getVx(this->_doseReference)/HT); } } else if(TV==0){ throw core::InvalidParameterException("DVH Set invalid: Target volume should not be 0!"); } else{ rttbExceptionMacro(core::InvalidParameterException, << "Reference dose "<getDoseReference()<<" invalid: Volume of reference dose should not be 0!"); } return true; } - IndexValueType ConformalIndex::getDoseIndexAt(GridIndexType tvIndex){ - std::vector dvhTVSet=this->_dvhSet->getDVHTVSet(); + IndexValueType ConformalIndex::getValueAt(core::DVHSet::IndexType tvIndex){ + std::vector dvhTVSet=this->_dvhSet->getTargetVolumeSet(); VolumeType Vref=_dvhSet->getWholeVolume(_doseReference); if(tvIndex>=dvhTVSet.size()){ rttbExceptionMacro(core::InvalidParameterException, <<"tvIndex invalid: it should be <"<getDoseReference()<<" invalid: Volume of reference dose should not be 0!"); } double value=dvh.getVx(_doseReference)/TV;//the irradiation factor of i-th target volume value=value*dvh.getVx(_doseReference)/Vref;//conformation number - std::vector dvhHTSet=this->_dvhSet->getDVHHTSet(); + std::vector dvhHTSet=this->_dvhSet->getHealthyTissueSet(); std::vector::iterator it; for(it=dvhHTSet.begin(); it!=dvhHTSet.end();++it) { dvh=*(it); VolumeType HT=dvh.getVx(0); if(HT!=0){ value*=(1-dvh.getVx(this->_doseReference)/HT); } } return value; } } }//end namespace indices }//end namespace rttb diff --git a/code/indices/rttbConformalIndex.h b/code/indices/rttbConformalIndex.h index 0d0d454..cdc9f45 100644 --- a/code/indices/rttbConformalIndex.h +++ b/code/indices/rttbConformalIndex.h @@ -1,69 +1,65 @@ // ----------------------------------------------------------------------- // 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. // //------------------------------------------------------------------------ /*! // @file // @version $Revision$ (last changed revision) // @date $Date$ (last change date) // @author $Author$ (last changed by) */ #ifndef __CONFORMAL_INDEX_H #define __CONFORMAL_INDEX_H -#include "rttbDoseIndex.h" +#include "rttbDvhBasedDoseIndex.h" #include "rttbBaseType.h" namespace rttb{ namespace indices{ /*! @class ConformalIndex @brief This class representing a ConformalIndex Object. Conformal Index (COIN)= Conformation Number(CN)* (1-Vref,0/Vnt,0)*(1-Vref,1/Vnt,1)... i: i-th critiacal organ Conformation Number (CN)= (TVref/TV) * (TVref/Vref) @ingroup indices */ - class ConformalIndex: public DoseIndex + class ConformalIndex: public DvhBasedDoseIndex { protected: /*! @brief Calculate conformal index @exception InvalidParameterException Thrown if dvhSet or aDoseReference invalid */ bool calcIndex(); - + public: /*! @brief Constructor */ - ConformalIndex(core::DVHSet* dvhSet, DoseTypeGy aDoseReference); - - /*! @return Return true if calcIndex() finished - @exception NullPointerException thrown if dvhSet is NULL - */ - bool init(); + ConformalIndex(DVHSetPtr dvhSet, DoseTypeGy aDoseReference); /*! @brief Dose index calculation for tvIndex-th treated volume @param tvIndex index in the DVH in the current set of tv-DVHs @return Return index value @exception InvalidParameterException Thrown if tvIndex or aDoseReference invalid */ - IndexValueType getDoseIndexAt(const GridIndexType tvIndex); + IndexValueType getValueAt(const core::DVHSet::IndexType tvIndex); + }; } } #endif diff --git a/code/indices/rttbConformationNumber.cpp b/code/indices/rttbConformationNumber.cpp index 21dce8f..1b58119 100644 --- a/code/indices/rttbConformationNumber.cpp +++ b/code/indices/rttbConformationNumber.cpp @@ -1,90 +1,77 @@ // ----------------------------------------------------------------------- // 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. // //------------------------------------------------------------------------ /*! // @file // @version $Revision$ (last changed revision) // @date $Date$ (last change date) // @author $Author$ (last changed by) */ #include "rttbConformationNumber.h" #include "rttbNullPointerException.h" #include "rttbInvalidParameterException.h" #include "rttbExceptionMacros.h" namespace rttb{ namespace indices{ - ConformationNumber::ConformationNumber(core::DVHSet* dvhSet, DoseTypeGy aDoseReference) + ConformationNumber::ConformationNumber(DVHSetPtr dvhSet, DoseTypeGy aDoseReference) + :DvhBasedDoseIndex(dvhSet, aDoseReference) { - _dvhSet=dvhSet; - _doseReference=aDoseReference; - initSuccess=false; - } - - bool ConformationNumber::init() - { - if(!_dvhSet){ - throw core::NullPointerException("DVHSet must not be NULL! "); - } - if( this->calcIndex()){ - initSuccess=true; - return true; - } - return false; + init(); } bool ConformationNumber::calcIndex() { - VolumeType TV=_dvhSet->getTVVolume(0); + VolumeType TV=_dvhSet->getTargetVolume(0); VolumeType Vref=_dvhSet->getWholeVolume(_doseReference); if(TV!=0 && Vref!=0){ - _value=(_dvhSet->getTVVolume(_doseReference)/TV)* - (_dvhSet->getTVVolume(_doseReference)/Vref); + _value=(_dvhSet->getTargetVolume(_doseReference)/TV)* + (_dvhSet->getTargetVolume(_doseReference)/Vref); } else if(TV==0){ throw core::InvalidParameterException("DVH Set invalid: Target volume should not be 0!"); } else{ rttbExceptionMacro(core::InvalidParameterException, << "Reference dose "<getDoseReference()<<" invalid: Volume of reference dose should not be 0!"); } return true; } - IndexValueType ConformationNumber::getDoseIndexAt(GridIndexType tvIndex){ - std::vector dvhTVSet=this->_dvhSet->getDVHTVSet(); + IndexValueType ConformationNumber::getValueAt(core::DVHSet::IndexType tvIndex){ + std::vector dvhTVSet=this->_dvhSet->getTargetVolumeSet(); VolumeType Vref=_dvhSet->getWholeVolume(_doseReference); if(tvIndex>=dvhTVSet.size()){ rttbExceptionMacro(core::InvalidParameterException, <<"tvIndex invalid: it should be <"<getDoseReference()<<" invalid: Volume of reference dose should not be 0!"); } IndexValueType value=dvh.getVx(_doseReference)/TV;//the irradiation factor of i-th target volume value=value*dvh.getVx(_doseReference)/Vref; return value; } } }//end namespace indices - }//end namespace rttb \ No newline at end of file +}//end namespace rttb \ No newline at end of file diff --git a/code/indices/rttbConformationNumber.h b/code/indices/rttbConformationNumber.h index 3c9e92d..c636160 100644 --- a/code/indices/rttbConformationNumber.h +++ b/code/indices/rttbConformationNumber.h @@ -1,69 +1,67 @@ // ----------------------------------------------------------------------- // 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. // //------------------------------------------------------------------------ /*! // @file // @version $Revision$ (last changed revision) // @date $Date$ (last change date) // @author $Author$ (last changed by) */ #ifndef __CONFORMATION_NUMBER_H #define __CONFORMATION_NUMBER_H -#include "rttbDoseIndex.h" +#include "rttbDvhBasedDoseIndex.h" #include "rttbBaseType.h" namespace rttb{ namespace indices{ /*! @class ConformationNumber @brief This class representing a ConformationNumber Object. Conformation Number (CN)= (TVref/TV) * (TVref/Vref) @ingroup indices */ - class ConformationNumber: public DoseIndex + class ConformationNumber: public DvhBasedDoseIndex { protected: /*! @brief Calculate conformation number @exception InvalidParameterException Thrown if dvhSet or aDoseReference invalid */ bool calcIndex(); - + public: /*! @brief Constructor */ - ConformationNumber(core::DVHSet* dvhSet, DoseTypeGy aDoseReference); - - /*! @return Return true if calcIndex() finished sucessfully - @exception NullPointerException thrown if dvhSet is NULL - */ - bool init(); + ConformationNumber(DVHSetPtr dvhSet, DoseTypeGy aDoseReference); + /*! @brief Dose index calculation for tvIndex-th treated volume @param tvIndex index in the DVH in the current set of tv-DVHs @return Return index value @exception InvalidParameterException Thrown if tvIndex or aDoseReference invalid */ - IndexValueType getDoseIndexAt(const GridIndexType tvIndex); + IndexValueType getValueAt(const core::DVHSet::IndexType tvIndex); + + }; } } #endif diff --git a/code/indices/rttbConformityIndex.cpp b/code/indices/rttbConformityIndex.cpp index b4f2c7a..f1ed34a 100644 --- a/code/indices/rttbConformityIndex.cpp +++ b/code/indices/rttbConformityIndex.cpp @@ -1,90 +1,76 @@ // ----------------------------------------------------------------------- // 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. // //------------------------------------------------------------------------ /*! // @file // @version $Revision$ (last changed revision) // @date $Date$ (last change date) // @author $Author$ (last changed by) */ #include "rttbConformityIndex.h" #include "rttbNullPointerException.h" #include "rttbInvalidParameterException.h" #include "rttbExceptionMacros.h" namespace rttb{ namespace indices{ - ConformityIndex::ConformityIndex(core::DVHSet* dvhSet, DoseTypeGy aDoseReference) + ConformityIndex::ConformityIndex(DVHSetPtr dvhSet, DoseTypeGy aDoseReference) + :DvhBasedDoseIndex(dvhSet, aDoseReference) { - _dvhSet=dvhSet; - _doseReference=aDoseReference; - initSuccess=false; - } - - bool ConformityIndex::init() - { - if(!_dvhSet){ - throw core::NullPointerException("DVHSet must not be NULL! "); - } - if( this->calcIndex()){ - initSuccess=true; - return true; - } - else - return false; + init(); } bool ConformityIndex::calcIndex() { - VolumeType TV=_dvhSet->getTVVolume(0); + VolumeType TV=_dvhSet->getTargetVolume(0); VolumeType Vref=_dvhSet->getWholeVolume(_doseReference); if(TV!=0 && Vref!=0){ - _value=(_dvhSet->getTVVolume(this->_doseReference)/TV)*(1-_dvhSet->getHTVolume(_doseReference)/Vref); + _value=(_dvhSet->getTargetVolume(this->_doseReference)/TV)*(1-_dvhSet->getHealthyTissueVolume(_doseReference)/Vref); } else if(TV==0){ throw core::InvalidParameterException("DVH Set invalid: Target volume should not be 0!"); } else{ rttbExceptionMacro(core::InvalidParameterException, << "Reference dose "<getDoseReference()<<" invalid: Volume of reference dose should not be 0!"); } return true; } - IndexValueType ConformityIndex::getDoseIndexAt(GridIndexType tvIndex){ - std::vector dvhTVSet=this->_dvhSet->getDVHTVSet(); + IndexValueType ConformityIndex::getValueAt(core::DVHSet::IndexType tvIndex){ + std::vector dvhTVSet=this->_dvhSet->getTargetVolumeSet(); VolumeType Vref=_dvhSet->getWholeVolume(_doseReference); if(tvIndex>=dvhTVSet.size()){ rttbExceptionMacro(core::InvalidParameterException, <<"tvIndex invalid: it should be <"<getDoseReference()<<" invalid: Volume of reference dose should not be 0!"); } double value=dvh.getVx(_doseReference)/TV;//the irradiation factor of i-th treated volume - value=value*(1-_dvhSet->getHTVolume(_doseReference)/Vref); + value=value*(1-_dvhSet->getHealthyTissueVolume(_doseReference)/Vref); return value; } } }//end namespace indices - }//end namespace rttb +}//end namespace rttb diff --git a/code/indices/rttbConformityIndex.h b/code/indices/rttbConformityIndex.h index adb18a1..c4f086c 100644 --- a/code/indices/rttbConformityIndex.h +++ b/code/indices/rttbConformityIndex.h @@ -1,69 +1,64 @@ // ----------------------------------------------------------------------- // 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. // //------------------------------------------------------------------------ /*! // @file // @version $Revision$ (last changed revision) // @date $Date$ (last change date) // @author $Author$ (last changed by) */ #ifndef __CONFORMITY_INDEX_H #define __CONFORMITY_INDEX_H -#include "rttbDoseIndex.h" +#include "rttbDvhBasedDoseIndex.h" #include "rttbBaseType.h" namespace rttb{ namespace indices{ /*! @class ConformityIndex @brief This class representing a ConformityIndex Object. Conformity Index (CI): CI(D)=IFtv(D)*(1-IFht(D)), D:reference dose, IFtv(D): the irradiation factor of the PTV, defined as the fraction of the PTV receiving a dose higher than D IFht(D): the irradiation factor of healthy tissue, defined as the radio of the volume of tissue outside the PTV receiving a dose greater than D to the volume of isodose D @ingroup indices */ - class ConformityIndex: public DoseIndex + class ConformityIndex: public DvhBasedDoseIndex { protected: /*! @brief Calculate Conformity index @exception InvalidParameterException Thrown if dvhSet or aDoseReference invalid */ bool calcIndex(); public: /*! @brief Constructor */ - ConformityIndex(core::DVHSet* dvhSet, DoseTypeGy aDoseReference); - - /*! @return Return true if calcIndex() finished sucessfully - @exception NullPointerException thrown if dvhSet is NULL - */ - bool init(); + ConformityIndex(DVHSetPtr dvhSet, DoseTypeGy aDoseReference); /*! @brief Dose index calculation for tvIndex-th treated volume @param tvIndex index in the DVH in the current set of tv-DVHs @return Return index value @exception InvalidParameterException Thrown if tvIndex or aDoseReference invalid */ - IndexValueType getDoseIndexAt(const GridIndexType tvIndex); + IndexValueType getValueAt(const core::DVHSet::IndexType tvIndex); }; } } #endif diff --git a/code/indices/rttbCoverageIndex.cpp b/code/indices/rttbCoverageIndex.cpp index 546807d..b4c8652 100644 --- a/code/indices/rttbCoverageIndex.cpp +++ b/code/indices/rttbCoverageIndex.cpp @@ -1,78 +1,64 @@ // ----------------------------------------------------------------------- // 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. // //------------------------------------------------------------------------ /*! // @file // @version $Revision$ (last changed revision) // @date $Date$ (last change date) // @author $Author$ (last changed by) */ #include "rttbCoverageIndex.h" #include "rttbNullPointerException.h" #include "rttbInvalidParameterException.h" #include "rttbExceptionMacros.h" namespace rttb{ namespace indices{ - CoverageIndex::CoverageIndex(core::DVHSet* dvhSet, DoseTypeGy aDoseReference) - { - _dvhSet=dvhSet; - _doseReference=aDoseReference; - initSuccess=false; - } - - bool CoverageIndex::init() - { - if(!_dvhSet){ - throw core::NullPointerException("DVHSet must not be NULL! "); - } - if( this->calcIndex()){ - initSuccess=true; - return true; - } - else - return false; + CoverageIndex::CoverageIndex(DVHSetPtr dvhSet, DoseTypeGy aDoseReference) + :DvhBasedDoseIndex(dvhSet, aDoseReference) + { + init(); } bool CoverageIndex::calcIndex() { - VolumeType TV=_dvhSet->getTVVolume(0); + VolumeType TV=_dvhSet->getTargetVolume(0); if(TV!=0) - _value=_dvhSet->getTVVolume(this->_doseReference)/TV; + _value=_dvhSet->getTargetVolume(this->_doseReference)/TV; else{ throw core::InvalidParameterException("DVH Set invalid: Target volume should not be 0!"); } return true; } - IndexValueType CoverageIndex::getDoseIndexAt(GridIndexType tvIndex){ - std::vector dvhTVSet=this->_dvhSet->getDVHTVSet(); + IndexValueType CoverageIndex::getValueAt(core::DVHSet::IndexType tvIndex){ + std::vector dvhTVSet=this->_dvhSet->getTargetVolumeSet(); VolumeType Vref=_dvhSet->getWholeVolume(_doseReference); if(tvIndex>=dvhTVSet.size()){ rttbExceptionMacro(core::InvalidParameterException, <<"tvIndex invalid: it should be <"< #include -#include "rttbDoseIndex.h" +#include "rttbDvhBasedDoseIndex.h" #include "rttbBaseType.h" #include "rttbDVHSet.h" namespace rttb{ namespace indices{ /*! @class CoverageIndex @brief This class representing a CoverageIndex Object. Coverage Index fraction of the target volume receiving a dose >= the reference dose @ingroup indices */ - class CoverageIndex: public DoseIndex + class CoverageIndex: public DvhBasedDoseIndex { protected: /*! @brief Calculate conformation number @exception InvalidParameterException Thrown if dvhSet invalid */ bool calcIndex(); - + public: /*! @brief Constructor */ - CoverageIndex(core::DVHSet* dvhSet, DoseTypeGy aDoseReference); - - /*! @return Return true if calcIndex() finished sucessfully - @exception NullPointerException thrown if dvhSet is NULL - @see calcIndex - */ - bool init(); + CoverageIndex(DVHSetPtr dvhSet, DoseTypeGy aDoseReference); + /*! @brief Dose index calculation for tvIndex-th treated volume * @param tvIndex: index in the vector of DVH TV * @return Return index value @exception InvalidParameterException Thrown if tvIndex invalid */ - IndexValueType getDoseIndexAt(const GridIndexType tvIndex); + IndexValueType getValueAt(const core::DVHSet::IndexType tvIndex); }; } } #endif diff --git a/code/indices/rttbDoseIndex.cpp b/code/indices/rttbDoseIndex.cpp index bb187c7..9787cd9 100644 --- a/code/indices/rttbDoseIndex.cpp +++ b/code/indices/rttbDoseIndex.cpp @@ -1,50 +1,70 @@ // ----------------------------------------------------------------------- // 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. // //------------------------------------------------------------------------ /*! // @file // @version $Revision$ (last changed revision) // @date $Date$ (last change date) // @author $Author$ (last changed by) */ #include "rttbDoseIndex.h" #include "rttbException.h" +#include "rttbInvalidParameterException.h" namespace rttb{ namespace indices{ + + DoseIndex::DoseIndex(DoseTypeGy aDoseReference) + :_doseReference(aDoseReference),_initSuccess(false){} + + bool DoseIndex::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 DoseIndex::setDoseReference(DoseTypeGy aDoseReference) { _doseReference=aDoseReference; - initSuccess=false; + _initSuccess=false; + init(); } DoseTypeGy DoseIndex::getDoseReference() const { return _doseReference; } IndexValueType DoseIndex::getValue() const { - if(initSuccess){ + if(_initSuccess){ return _value; } else{ throw core::Exception("DoseIndex init error: init() must be called first!"); } } } - } +} diff --git a/code/indices/rttbDoseIndex.h b/code/indices/rttbDoseIndex.h index 6897a36..e0e0830 100644 --- a/code/indices/rttbDoseIndex.h +++ b/code/indices/rttbDoseIndex.h @@ -1,85 +1,87 @@ // ----------------------------------------------------------------------- // 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. // //------------------------------------------------------------------------ /*! // @file // @version $Revision$ (last changed revision) // @date $Date$ (last change date) // @author $Author$ (last changed by) */ #ifndef __DOSE_INDEX_H #define __DOSE_INDEX_H #include "rttbBaseType.h" #include "rttbDVHSet.h" namespace rttb{ namespace indices{ /*! @class DoseIndex @brief This is the interface for dose/plan comparison indices. @ingroup indices */ class DoseIndex { protected: - /*! @todo Use Shared Pointers for _dvhSet*/ - core::DVHSet* _dvhSet; - IndexValueType _value; DoseTypeGy _doseReference; /*! @brief If init() successful*/ - bool initSuccess; + bool _initSuccess; + + /*! @brief Initialize the calculation. It should be called in constructor or if any parameter of the calcualtion is changed. + @return Return true if successfully + @exception InvalidParameterException thrown if any input is invalid or index calculation failed + */ + bool init(); /*! @brief Dose index calculation */ virtual bool calcIndex()=0; + /*! @brief Check all inputs for the index calculation*/ + virtual bool checkInputs()=0; public: - /*! @brief Initialize the calculation - @return Return true if successfully - */ - virtual bool init()=0; + /*! @brief Constructor with the referece dose*/ + DoseIndex(DoseTypeGy aDoseReference); + /*! @brief Set the reference dose */ void setDoseReference(DoseTypeGy aDoseReference); /*! @brief Get the reference dose */ DoseTypeGy getDoseReference() const; /*! @brief Get the value of dose/plan comparison index @return Return the value of this index @exception Exception Thrown if the class was not initialized previously. */ IndexValueType getValue() const; - /*! @brief Dose/plan comparison index calculation for tvIndex-th treated volume - (tv = target volume; th = healthy tissue) - @param tvIndex index in the DVH in the current set of tv-DVHs - @todo is this name good? getIndexAt() instead? + /*! @brief Get the value of dose/plan comparison index for a treated volume with the index in the DVH treated volume set + @param tvIndex index in the DVH in the current set of DVH subset for target volume: use DVHSet.getTargetVolumeSet() */ - virtual IndexValueType getDoseIndexAt(const GridIndexType tvIndex)=0; + virtual IndexValueType getValueAt(const core::DVHSet::IndexType tvIndex)=0; }; } } #endif diff --git a/code/indices/rttbDoseIndex.cpp b/code/indices/rttbDvhBasedDoseIndex.cpp similarity index 54% copy from code/indices/rttbDoseIndex.cpp copy to code/indices/rttbDvhBasedDoseIndex.cpp index bb187c7..f250b48 100644 --- a/code/indices/rttbDoseIndex.cpp +++ b/code/indices/rttbDvhBasedDoseIndex.cpp @@ -1,50 +1,44 @@ // ----------------------------------------------------------------------- // 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. // //------------------------------------------------------------------------ /*! // @file -// @version $Revision$ (last changed revision) -// @date $Date$ (last change date) -// @author $Author$ (last changed by) +// @version $Revision: 707 $ (last changed revision) +// @date $Date: 2014-09-04 16:37:24 +0200 (Do, 04 Sep 2014) $ (last change date) +// @author $Author: floca $ (last changed by) */ -#include "rttbDoseIndex.h" -#include "rttbException.h" +#include "rttbDvhBasedDoseIndex.h" + namespace rttb{ namespace indices{ - void DoseIndex::setDoseReference(DoseTypeGy aDoseReference) - { - _doseReference=aDoseReference; - initSuccess=false; - } - DoseTypeGy DoseIndex::getDoseReference() const - { - return _doseReference; - } + DvhBasedDoseIndex::DvhBasedDoseIndex(DvhBasedDoseIndex::DVHSetPtr aDVHSet, DoseTypeGy aDoseReference) + :DoseIndex(aDoseReference),_dvhSet(aDVHSet) + { + } - IndexValueType DoseIndex::getValue() const - { - if(initSuccess){ - return _value; - } + bool DvhBasedDoseIndex::checkInputs(){ + if(!_dvhSet){ + return false; + } else{ - throw core::Exception("DoseIndex init error: init() must be called first!"); - } + return true; } } } +} diff --git a/code/indices/rttbDvhBasedDoseIndex.h b/code/indices/rttbDvhBasedDoseIndex.h new file mode 100644 index 0000000..cd4f51f --- /dev/null +++ b/code/indices/rttbDvhBasedDoseIndex.h @@ -0,0 +1,65 @@ +// ----------------------------------------------------------------------- +// 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. +// +//------------------------------------------------------------------------ +/*! +// @file +// @version $Revision: 707 $ (last changed revision) +// @date $Date: 2014-09-04 16:37:24 +0200 (Do, 04 Sep 2014) $ (last change date) +// @author $Author: floca $ (last changed by) +*/ +#ifndef __DVH_BASED_DOSE_INDEX_H +#define __DVH_BASED_DOSE_INDEX_H + + +#include "rttbBaseType.h" +#include "rttbDVHSet.h" +#include "rttbDoseIndex.h" + +namespace rttb{ + + + namespace indices{ + /*! @class DvhBasedDoseIndex + @brief This is the interface for dose/plan comparison indices calculated by DVh set of the dose. + */ + class DvhBasedDoseIndex: public DoseIndex + { + public: + typedef boost::shared_ptr DVHSetPtr; + + protected: + + DVHSetPtr _dvhSet; + + /*! @brief Dose index calculation */ + virtual bool calcIndex()=0; + + /*! @brief Check inputs*/ + bool checkInputs(); + + public: + /*! @brief Constructor*/ + DvhBasedDoseIndex(DVHSetPtr aDVHSet, DoseTypeGy aDoseReference); + + /*! @brief Dose/plan comparison index calculation for tvIndex-th treated volume + (tv = target volume; th = healthy tissue) + @param tvIndex index in the DVH in the current set of tv-DVHs + */ + virtual IndexValueType getValueAt(const core::DVHSet::IndexType tvIndex)=0; + }; + } +} + + +#endif diff --git a/code/indices/rttbHomogeneityIndex.cpp b/code/indices/rttbHomogeneityIndex.cpp index 6d74d0a..b56bce0 100644 --- a/code/indices/rttbHomogeneityIndex.cpp +++ b/code/indices/rttbHomogeneityIndex.cpp @@ -1,90 +1,76 @@ // ----------------------------------------------------------------------- // 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. // //------------------------------------------------------------------------ /*! // @file // @version $Revision$ (last changed revision) // @date $Date$ (last change date) // @author $Author$ (last changed by) */ #include "rttbHomogeneityIndex.h" -#include "rttbNullPointerException.h" #include "rttbInvalidParameterException.h" #include "rttbExceptionMacros.h" namespace rttb{ namespace indices{ - HomogeneityIndex::HomogeneityIndex(core::DVHSet* dvhSet, DoseTypeGy aDoseReference) + HomogeneityIndex::HomogeneityIndex(DVHSetPtr dvhSet, DoseTypeGy aDoseReference) + :DvhBasedDoseIndex(dvhSet, aDoseReference) { - _dvhSet=dvhSet; - _doseReference=aDoseReference; - initSuccess=false; - } - - bool HomogeneityIndex::init() - { - if(!_dvhSet){ - throw core::NullPointerException("DVHSet must not be NULL! "); - } - if(this->calcIndex()){ - initSuccess=true; - return true; - } - return false; + init(); } bool HomogeneityIndex::calcIndex() { double max=0; double min; - std::vector dvhTVSet=this->_dvhSet->getDVHTVSet(); + std::vector dvhTVSet=this->_dvhSet->getTargetVolumeSet(); std::vector::iterator it; - - for(it=dvhTVSet.begin(); it!=dvhTVSet.end();it++) + + for(it=dvhTVSet.begin(); it!=dvhTVSet.end();++it) { core::DVH dvh=*(it); if(it==dvhTVSet.begin()) min=dvh.getMinimum(); if(dvh.getMaximum()>max) max=dvh.getMaximum(); if(dvh.getMinimum()getDoseReference()!=0){ _value=(max-min)/this->getDoseReference(); } else{ rttbExceptionMacro(core::InvalidParameterException, << "Reference dose "<getDoseReference()<<" invalid: Volume of reference dose should not be 0!"); } return true; - + } - IndexValueType HomogeneityIndex::getDoseIndexAt(GridIndexType tvIndex){ - std::vector dvhTVSet=this->_dvhSet->getDVHTVSet(); + IndexValueType HomogeneityIndex::getValueAt(core::DVHSet::IndexType tvIndex){ + std::vector dvhTVSet=this->_dvhSet->getTargetVolumeSet(); if(tvIndex>=dvhTVSet.size()){ rttbExceptionMacro(core::InvalidParameterException, <<"tvIndex invalid: it should be <"<getDoseReference()<=0){ rttbExceptionMacro(core::InvalidParameterException, << "Reference dose "<getDoseReference()<<" invalid: Volume of reference dose should not be 0!"); } return (dvh.getMaximum()-dvh.getMinimum())/this->getDoseReference(); } }//end namespace indices }//end namespace rttb \ No newline at end of file diff --git a/code/indices/rttbHomogeneityIndex.h b/code/indices/rttbHomogeneityIndex.h index 53a8a73..4ed663b 100644 --- a/code/indices/rttbHomogeneityIndex.h +++ b/code/indices/rttbHomogeneityIndex.h @@ -1,69 +1,63 @@ // ----------------------------------------------------------------------- // 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. // //------------------------------------------------------------------------ /*! // @file // @version $Revision$ (last changed revision) // @date $Date$ (last change date) // @author $Author$ (last changed by) */ #ifndef __HOMOGENEITY_INDEX_H #define __HOMOGENEITY_INDEX_H #include #include -#include "rttbDoseIndex.h" +#include "rttbDvhBasedDoseIndex.h" #include "rttbBaseType.h" namespace rttb{ namespace indices{ /*! @class HomogeneityIndex @brief This class representing a HomogeneityIndex Object. Homogeneity Index (HI) = (Dmax(PTV)-Dmin(PTV))/Dref @ingroup indices */ - class HomogeneityIndex: public DoseIndex + class HomogeneityIndex: public DvhBasedDoseIndex { protected: /*! @brief Calculate Conformity index @exception InvalidParameterException Thrown if aDoseReference invalid */ bool calcIndex(); - public: /*! @brief Constructor */ - HomogeneityIndex(core::DVHSet* dvhSet, DoseTypeGy aDoseReference); - - /*! @return Return true if calcIndex() finished sucessfully - @exception NullPointerException thrown if dvhSet is NULL - */ - bool init(); + HomogeneityIndex(DVHSetPtr dvhSet, DoseTypeGy aDoseReference); /*! @brief Dose index calculation for tvIndex-th treated volume @param tvIndex index in the DVH in the current set of tv-DVHs @return Return index value @exception InvalidParameterException Thrown if tvIndex or aDoseReference invalid */ - IndexValueType getDoseIndexAt(const GridIndexType tvIndex); + IndexValueType getValueAt(const core::DVHSet::IndexType tvIndex); }; } } #endif diff --git a/testing/core/DVHSetTest.cpp b/testing/core/DVHSetTest.cpp index beda9de..731b0d1 100644 --- a/testing/core/DVHSetTest.cpp +++ b/testing/core/DVHSetTest.cpp @@ -1,168 +1,168 @@ // ----------------------------------------------------------------------- // 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. // //------------------------------------------------------------------------ /*! // @file // @version $Revision$ (last changed revision) // @date $Date$ (last change date) // @author $Author$ (last changed by) */ #include #include #include #include #include "litCheckMacros.h" #include "rttbBaseType.h" #include "rttbDVH.h" #include "rttbDVHSet.h" #include "rttbNullPointerException.h" #include "rttbInvalidParameterException.h" #include "DummyDVHGenerator.h" namespace rttb{ namespace testing{ typedef core::DVHSet::DVHSetType DVHSetType; /*! @brief DVHTest - test the API of DVH 1) test constructors (values as expected?) 2) test size 3) test set/getIDs 4) test insert/retrieve individual DVHs 5) test getDVHSet 6) test getVolume */ int DVHSetTest(int argc, char* argv[] ) { PREPARE_DEFAULT_TEST_REPORTING; const IDType structureSetID = "myStructureSet"; const IDType structureIDPrefix = "myStructure"; const IDType doseID = "myDose"; const IDType voxelizationID = "myVoxelization"; DummyDVHGenerator dvhGenerator; DVHSetType tvSet; IDType structureID = structureIDPrefix+"_TV_"; for(int i = 0; i < 3; i++){ tvSet.push_back(dvhGenerator.generateDVH(structureID+ boost::lexical_cast(i),doseID)); } DVHSetType htSet; structureID = structureIDPrefix+"_HT_"; for(int i = 0; i < 5; i++){ htSet.push_back(dvhGenerator.generateDVH(structureID+ boost::lexical_cast(i),doseID)); } DVHSetType wvSet; structureID = structureIDPrefix+"_WV_"; for(int i = 0; i < 1; i++){ wvSet.push_back(dvhGenerator.generateDVH(structureID+ boost::lexical_cast(i),doseID)); } //1) test constructors (values as expected?) CHECK_NO_THROW(core::DVHSet(structureSetID, doseID)); CHECK_NO_THROW(core::DVHSet(tvSet, htSet, structureSetID, doseID)); CHECK_NO_THROW(core::DVHSet(tvSet, htSet, wvSet, structureSetID, doseID)); //2) test size core::DVHSet myDvhSet1(structureSetID, doseID); CHECK_EQUAL(myDvhSet1.size(),0); core::DVHSet myDvhSet2(tvSet, htSet, structureSetID, doseID); CHECK_EQUAL(myDvhSet2.size(),tvSet.size()+htSet.size()); core::DVHSet myDvhSet3(tvSet, htSet, wvSet, structureSetID, doseID); CHECK_EQUAL(myDvhSet3.size(),tvSet.size()+htSet.size()+wvSet.size()); //3) test set/getIDs const IDType newStructureSetID = "myNewStructureSet"; const IDType newDoseID = "myNewDose"; CHECK_EQUAL(myDvhSet1.getStrSetID(),structureSetID); CHECK_EQUAL(myDvhSet1.getDoseID(),doseID); CHECK_NO_THROW(myDvhSet1.setStrSetID(newStructureSetID)); CHECK_NO_THROW(myDvhSet1.setDoseID(newDoseID)); CHECK_EQUAL(myDvhSet1.getStrSetID(),newStructureSetID); CHECK_EQUAL(myDvhSet1.getDoseID(),newDoseID); CHECK_EQUAL(myDvhSet3.getStrSetID(),structureSetID); CHECK_EQUAL(myDvhSet3.getDoseID(),doseID); CHECK_NO_THROW(myDvhSet3.setStrSetID(newStructureSetID)); CHECK_NO_THROW(myDvhSet3.setDoseID(newDoseID)); CHECK_EQUAL(myDvhSet3.getStrSetID(),newStructureSetID); CHECK_EQUAL(myDvhSet3.getDoseID(),newDoseID); //4) test insert/retrieve individual DVHs DVHRole roleTV = {DVHRole::TargetVolume}; structureID = structureIDPrefix+"_TV_"; core::DVH tv = dvhGenerator.generateDVH(structureID+ boost::lexical_cast(tvSet.size()),doseID); CHECK_EQUAL(myDvhSet1.size(),0); CHECK_NO_THROW(myDvhSet1.insert(tv, roleTV)); CHECK_EQUAL(myDvhSet1.size(),1); std::size_t currentSize = myDvhSet2.size(); CHECK_NO_THROW(myDvhSet2.insert(tv, roleTV)); CHECK_EQUAL(myDvhSet2.size(),currentSize+1); DVHRole roleHT = {DVHRole::HealthyTissue}; structureID = structureIDPrefix+"_HT_"; core::DVH ht = dvhGenerator.generateDVH(structureID+ boost::lexical_cast(htSet.size()),doseID); CHECK_EQUAL(myDvhSet1.size(),1); CHECK_NO_THROW(myDvhSet1.insert(ht, roleHT)); CHECK_EQUAL(myDvhSet1.size(),2); currentSize = myDvhSet2.size(); CHECK_NO_THROW(myDvhSet2.insert(ht, roleHT)); CHECK_EQUAL(myDvhSet2.size(),currentSize+1); DVHRole roleWV = {DVHRole::WholeVolume}; structureID = structureIDPrefix+"_wv_"; IDType testID = structureID+ boost::lexical_cast(wvSet.size()); core::DVH wv = dvhGenerator.generateDVH(structureID+ boost::lexical_cast(wvSet.size()),doseID); CHECK_EQUAL(myDvhSet1.size(),2); CHECK_NO_THROW(myDvhSet1.insert(wv, roleWV)); CHECK_EQUAL(myDvhSet1.size(),3); currentSize = myDvhSet2.size(); CHECK_NO_THROW(myDvhSet2.insert(wv, roleWV)); CHECK_EQUAL(myDvhSet2.size(),currentSize+1); //5) test getDVHSet core::DVH* dvhPtr = myDvhSet1.getDVH(testID); CHECK_EQUAL(*dvhPtr,wv); dvhPtr = myDvhSet3.getDVH(structureIDPrefix+"_TV_0"); CHECK_EQUAL(*dvhPtr,tvSet.at(0)); dvhPtr = myDvhSet3.getDVH(structureIDPrefix+"_TV_2"); CHECK_EQUAL(*dvhPtr,tvSet.at(2)); - DVHSetType tvTest = myDvhSet3.getDVHTVSet(); + DVHSetType tvTest = myDvhSet3.getTargetVolumeSet(); CHECK_EQUAL(tvTest,tvSet); - DVHSetType htTest = myDvhSet3.getDVHHTSet(); + DVHSetType htTest = myDvhSet3.getHealthyTissueSet(); CHECK_EQUAL(htTest,htSet); - DVHSetType wvTest = myDvhSet3.getDVHWVSet(); + DVHSetType wvTest = myDvhSet3.getWholeVolumeSet(); CHECK_EQUAL(wvTest,wvSet); //6) test getVolume DoseTypeGy aDoseAbsolute = 10; - CHECK_EQUAL(0,myDvhSet3.getHTVolume(aDoseAbsolute)); - CHECK_EQUAL(0,myDvhSet3.getTVVolume(aDoseAbsolute)); + CHECK_EQUAL(0,myDvhSet3.getHealthyTissueVolume(aDoseAbsolute)); + CHECK_EQUAL(0,myDvhSet3.getTargetVolume(aDoseAbsolute)); CHECK_EQUAL(0,myDvhSet3.getWholeVolume(aDoseAbsolute)); RETURN_AND_REPORT_TEST_SUCCESS; } }//end namespace testing }//end namespace rttb diff --git a/testing/examples/RTDoseIndexTest.cpp b/testing/examples/RTDoseIndexTest.cpp index c8164c9..34ceeb3 100644 --- a/testing/examples/RTDoseIndexTest.cpp +++ b/testing/examples/RTDoseIndexTest.cpp @@ -1,247 +1,206 @@ // ----------------------------------------------------------------------- // 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. // //------------------------------------------------------------------------ /*! // @file // @version $Revision$ (last changed revision) // @date $Date$ (last change date) // @author $Author$ (last changed by) */ // this file defines the rttbCoreTests for the test driver // and all it expects is that you have a function called RegisterTests #include "litCheckMacros.h" #include "rttbDoseIndex.h" #include "rttbDVHSet.h" #include "rttbDVHTxtFileReader.h" #include "rttbBaseType.h" #include "rttbNullPointerException.h" #include "rttbConformalIndex.h" #include "rttbConformationNumber.h" #include "rttbConformityIndex.h" #include "rttbCoverageIndex.h" #include "rttbHomogeneityIndex.h" #include "rttbException.h" #include "rttbInvalidParameterException.h" #include +#include +#include + namespace rttb { namespace testing { /*! @brief DoseIndexTest. ConformationNumber ConformalIndex ConformityIndex CoverageIndex HomogeneityIndex are tested. test dvh: deltaV 0.125, deltaD 0.5 1. dvh TV: number of voxels 2900, maximum dose bin 133, dose bin 127~133 2. dvh HT1: number of voxels 5410, maximum dose bin 40, dose bin 0~2,40 3. dvh HT2: number of voxels 10210, maximum dose bin 50, dose bin 0~2,50 4. dvh HT3: number of voxels 1210, maximum dose bin 70, dose bin 0~2,70 Test if calculation in new architecture returns similar results to the original implementation. WARNING: The values for comparison need to be adjusted if the input files are changed! */ int RTDoseIndexTest(int argc, char* argv[]) { PREPARE_DEFAULT_TEST_REPORTING; //ARGUMENTS: 1: ptv dvh file name // 2: normal tissue 1 dvh file name // 3: normal tissue 2 dvh file name // 4: normal tissue 3 dvh file name std::string DVH_FILENAME_PTV; std::string DVH_FILENAME_NT1; std::string DVH_FILENAME_NT2; std::string DVH_FILENAME_NT3; if (argc > 1) { DVH_FILENAME_PTV = argv[1]; } if (argc > 2) { DVH_FILENAME_NT1 = argv[2]; } if (argc > 3) { DVH_FILENAME_NT2 = argv[3]; } if (argc > 4) { DVH_FILENAME_NT3 = argv[4]; } /*test dvh: deltaV 0.125, deltaD 0.5*/ /*dvh TV: number of voxels 2900, maximum dose bin 133, dose bin 127~133*/ rttb::io::other::DVHTxtFileReader dvhReader = rttb::io::other::DVHTxtFileReader(DVH_FILENAME_PTV); rttb::core::DVH dvhPTV = *(dvhReader.generateDVH()); /*dvh HT1: number of voxels 5410, maximum dose bin 40, dose bin 0~2,40*/ rttb::io::other::DVHTxtFileReader dvhReader1 = rttb::io::other::DVHTxtFileReader(DVH_FILENAME_NT1); core::DVH dvhNT1 = *(dvhReader1.generateDVH()); /*dvh HT2: number of voxels 10210, maximum dose bin 50, dose bin 0~2,50*/ rttb::io::other::DVHTxtFileReader dvhReader2 = rttb::io::other::DVHTxtFileReader(DVH_FILENAME_NT2); core::DVH dvhNT2 = *(dvhReader2.generateDVH()); /*dvh HT3: number of voxels 1210, maximum dose bin 70, dose bin 0~2,70*/ rttb::io::other::DVHTxtFileReader dvhReader3 = rttb::io::other::DVHTxtFileReader(DVH_FILENAME_NT3); core::DVH dvhNT3 = *(dvhReader3.generateDVH()); std::vector dvhTVSet; std::vector dvhHTSet; dvhTVSet.push_back(dvhPTV); dvhHTSet.push_back(dvhNT1); dvhHTSet.push_back(dvhNT2); dvhHTSet.push_back(dvhNT3); - core::DVHSet dvhSet = core::DVHSet(dvhTVSet, dvhHTSet, "testStrSet", dvhPTV.getDoseID()); - + boost::shared_ptr dvhSetPtr = boost::make_shared(dvhTVSet, dvhHTSet, "testStrSet", dvhPTV.getDoseID()); + /*test exception*/ - indices::ConformalIndex test1 = indices::ConformalIndex(NULL, 0); - indices::ConformationNumber test2 = indices::ConformationNumber(NULL, 0); - indices::ConformityIndex test3 = indices::ConformityIndex(NULL, 0); - indices::CoverageIndex test4 = indices::CoverageIndex(NULL, 0); - indices::HomogeneityIndex test5 = indices::HomogeneityIndex(NULL, 0); - - CHECK_THROW_EXPLICIT(test1.init(), core::NullPointerException); - CHECK_THROW_EXPLICIT(test2.init(), core::NullPointerException); - CHECK_THROW_EXPLICIT(test3.init(), core::NullPointerException); - CHECK_THROW_EXPLICIT(test4.init(), core::NullPointerException); - CHECK_THROW_EXPLICIT(test5.init(), core::NullPointerException); - + CHECK_THROW_EXPLICIT(indices::ConformalIndex(NULL, 0), core::InvalidParameterException); + CHECK_THROW_EXPLICIT(indices::ConformationNumber(NULL, 0), core::InvalidParameterException); + CHECK_THROW_EXPLICIT(indices::ConformityIndex(NULL, 0), core::InvalidParameterException); + CHECK_THROW_EXPLICIT(indices::CoverageIndex(NULL, 0), core::InvalidParameterException); + CHECK_THROW_EXPLICIT(indices::HomogeneityIndex(NULL, 0), core::InvalidParameterException); /*test exception for invalid reference dose*/ - test1 = indices::ConformalIndex(&dvhSet, 100); - test2 = indices::ConformationNumber(&dvhSet, 100); - test3 = indices::ConformityIndex(&dvhSet, 100); - test5 = indices::HomogeneityIndex(&dvhSet, 0); - - CHECK_THROW_EXPLICIT(test1.init(), core::InvalidParameterException); - CHECK_THROW_EXPLICIT(test2.init(), core::InvalidParameterException); - CHECK_THROW_EXPLICIT(test3.init(), core::InvalidParameterException); - CHECK_THROW_EXPLICIT(test5.init(), core::InvalidParameterException); + CHECK_THROW_EXPLICIT(indices::ConformalIndex(dvhSetPtr, 100), core::InvalidParameterException); + CHECK_THROW_EXPLICIT(indices::ConformationNumber(dvhSetPtr, 100), core::InvalidParameterException); + CHECK_THROW_EXPLICIT(indices::ConformityIndex(dvhSetPtr, 100), core::InvalidParameterException); + CHECK_THROW_EXPLICIT(indices::HomogeneityIndex(dvhSetPtr, 0), core::InvalidParameterException); /*test index calculation*/ /*RTConformationNumber */ //PTV covered by reference dose 30 = the whole PTV =362.5; Volume of the referece 30=362.5+1.25 - indices::ConformationNumber cn = indices::ConformationNumber(&dvhSet, 30); - cn.init(); + indices::ConformationNumber cn = indices::ConformationNumber(dvhSetPtr, 30); //check if values are close. Equality is only achieved with double precission. CHECK_CLOSE(362.5 / 363.75, cn.getValue(), errorConstant); //cn==1*TV0/V0=362.5/2466.25 cn.setDoseReference(0); - //if not init, throw Exception - CHECK_THROW_EXPLICIT(cn.getValue(), core::Exception); - cn.init(); CHECK_CLOSE(362.5 / 2466.25, cn.getValue(), errorConstant); cn.setDoseReference(65); - //if not init, throw Exception - CHECK_THROW_EXPLICIT(cn.getValue(), core::Exception); - cn.init(); CHECK_CLOSE(2300 / 2900.0, cn.getValue(), errorConstant); //ref dose: 65 -> TVref=Vref -> cn=TVref/TV=2300/2900 - CHECK_EQUAL(cn.getValue(), cn.getDoseIndexAt(0)); - CHECK_THROW_EXPLICIT(cn.getDoseIndexAt(1), core::InvalidParameterException); + CHECK_EQUAL(cn.getValue(), cn.getValueAt(0)); + CHECK_THROW_EXPLICIT(cn.getValueAt(1), core::InvalidParameterException); /*ConformalIndex */ //HT 1 covered by ref=HT2 covered by ref=0, HT3 covered by ref=1.25 - indices::ConformalIndex coin = indices::ConformalIndex(&dvhSet, 30); - coin.init(); + indices::ConformalIndex coin = indices::ConformalIndex(dvhSetPtr, 30); CHECK_CLOSE((362.5 / 363.75) * (1 - 1.25 / 151.25), coin.getValue(), errorConstant); coin.setDoseReference(0); - //if not init, throw Exception - CHECK_THROW_EXPLICIT(coin.getValue(), core::Exception); - coin.init(); CHECK_EQUAL(0, coin.getValue()); coin.setDoseReference(65); - //if not init, throw Exception - CHECK_THROW_EXPLICIT(coin.getValue(), core::Exception); - coin.init(); CHECK_CLOSE(2300 / 2900.0, coin.getValue(), errorConstant); //ref dose: 65 -> Vref=0 for all HT -> cn=cn*(1-0)=cn - CHECK_EQUAL(coin.getValue(), coin.getDoseIndexAt(0)); - CHECK_THROW_EXPLICIT(coin.getDoseIndexAt(1), core::InvalidParameterException); + CHECK_EQUAL(coin.getValue(), coin.getValueAt(0)); + CHECK_THROW_EXPLICIT(coin.getValueAt(1), core::InvalidParameterException); /*ConformityIndex */ - indices::ConformityIndex ci = indices::ConformityIndex(&dvhSet, 30); - //if not init, throw Exception - CHECK_THROW_EXPLICIT(ci.getValue(), core::Exception); - ci.init(); + indices::ConformityIndex ci = indices::ConformityIndex(dvhSetPtr, 30); CHECK_CLOSE(362.5 / 363.75, ci.getValue(), errorConstant); ci.setDoseReference(65); - //if not init, throw Exception - CHECK_THROW_EXPLICIT(ci.getValue(), core::Exception); - ci.init(); CHECK_CLOSE(2300 / 2900.0, ci.getValue(), errorConstant); //ref dose: 65->ci=2300/2900*1*1*1 - CHECK_EQUAL(ci.getValue(), ci.getDoseIndexAt(0)); - CHECK_THROW_EXPLICIT(ci.getDoseIndexAt(1), core::InvalidParameterException); + CHECK_EQUAL(ci.getValue(), ci.getValueAt(0)); + CHECK_THROW_EXPLICIT(ci.getValueAt(1), core::InvalidParameterException); /*CoverageIndex*/ - indices::CoverageIndex coverageI = indices::CoverageIndex(&dvhSet, 30); - //if not init, throw Exception - CHECK_THROW_EXPLICIT(coverageI.getValue(), core::Exception); - coverageI.init(); + indices::CoverageIndex coverageI = indices::CoverageIndex(dvhSetPtr, 30); CHECK_CLOSE(362.5 / 362.5, coverageI.getValue(), errorConstant); //ref dose: 30 -> coverage index=1 coverageI.setDoseReference(65); - //if not init, throw Exception - CHECK_THROW_EXPLICIT(coverageI.getValue(), core::Exception); - coverageI.init(); CHECK_CLOSE(2300 / 2900.0, coverageI.getValue(), errorConstant); //ref dose: 65->coverage index=2300/2900 - CHECK_EQUAL(coverageI.getValue(), coverageI.getDoseIndexAt(0)); - CHECK_THROW_EXPLICIT(coverageI.getDoseIndexAt(1), core::InvalidParameterException); + CHECK_EQUAL(coverageI.getValue(), coverageI.getValueAt(0)); + CHECK_THROW_EXPLICIT(coverageI.getValueAt(1), core::InvalidParameterException); /*HomogeneityIndex TV max: 133*0.5=66.5, TV min: 127*0.5=63.5 -> hi=(66.5-63.5)/30*/ - indices::HomogeneityIndex hi = indices::HomogeneityIndex(&dvhSet, 30); - //if not init, throw Exception - CHECK_THROW_EXPLICIT(hi.getValue(), core::Exception); - hi.init(); + indices::HomogeneityIndex hi = indices::HomogeneityIndex(dvhSetPtr, 30); CHECK_CLOSE(3 / 30.0, hi.getValue(), errorConstant); hi.setDoseReference(65); - //if not init, throw Exception - CHECK_THROW_EXPLICIT(hi.getValue(), core::Exception); - hi.init(); CHECK_CLOSE(3 / 65.0, hi.getValue(), errorConstant); - CHECK_EQUAL(hi.getValue(), hi.getDoseIndexAt(0)); - CHECK_THROW_EXPLICIT(hi.getDoseIndexAt(1), core::InvalidParameterException); + CHECK_EQUAL(hi.getValue(), hi.getValueAt(0)); + CHECK_THROW_EXPLICIT(hi.getValueAt(1), core::InvalidParameterException); RETURN_AND_REPORT_TEST_SUCCESS; } }//testing }//rttb \ No newline at end of file