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 3901994..3a47019 100644 --- a/code/core/rttbDVHSet.h +++ b/code/core/rttbDVHSet.h @@ -1,126 +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/rttbConformalIndex.cpp b/code/indices/rttbConformalIndex.cpp index d361059..ed53aa9 100644 --- a/code/indices/rttbConformalIndex.cpp +++ b/code/indices/rttbConformalIndex.cpp @@ -1,101 +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(ConformalIndex::DVHSetPtr dvhSet, DoseTypeGy aDoseReference) :DvhBasedDoseIndex(dvhSet, aDoseReference) { 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::getValueAt(core::DVHSet::IndexType tvIndex){ - std::vector dvhTVSet=this->_dvhSet->getDVHTVSet(); + 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/rttbConformationNumber.cpp b/code/indices/rttbConformationNumber.cpp index 616105d..ea94bf0 100644 --- a/code/indices/rttbConformationNumber.cpp +++ b/code/indices/rttbConformationNumber.cpp @@ -1,77 +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(DVHSetPtr dvhSet, DoseTypeGy aDoseReference) :DvhBasedDoseIndex(dvhSet, aDoseReference) { 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::getValueAt(core::DVHSet::IndexType tvIndex){ - std::vector dvhTVSet=this->_dvhSet->getDVHTVSet(); + 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 diff --git a/code/indices/rttbConformityIndex.cpp b/code/indices/rttbConformityIndex.cpp index 5b6b6d6..b65cd4a 100644 --- a/code/indices/rttbConformityIndex.cpp +++ b/code/indices/rttbConformityIndex.cpp @@ -1,76 +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(DVHSetPtr dvhSet, DoseTypeGy aDoseReference) :DvhBasedDoseIndex(dvhSet, aDoseReference) { 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::getValueAt(core::DVHSet::IndexType tvIndex){ - std::vector dvhTVSet=this->_dvhSet->getDVHTVSet(); + 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 diff --git a/code/indices/rttbCoverageIndex.cpp b/code/indices/rttbCoverageIndex.cpp index faa9fb8..1071356 100644 --- a/code/indices/rttbCoverageIndex.cpp +++ b/code/indices/rttbCoverageIndex.cpp @@ -1,64 +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(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::getValueAt(core::DVHSet::IndexType tvIndex){ - std::vector dvhTVSet=this->_dvhSet->getDVHTVSet(); + std::vector dvhTVSet=this->_dvhSet->getTargetVolumeSet(); VolumeType Vref=_dvhSet->getWholeVolume(_doseReference); if(tvIndex>=dvhTVSet.size()){ rttbExceptionMacro(core::InvalidParameterException, <<"tvIndex invalid: it should be <"<checkInputs())){ throw core::InvalidParameterException("Check inputs failed: invalid parameters! "); } if( this->calcIndex()){ - initSuccess=true; + _initSuccess=true; } else{ throw core::InvalidParameterException("Index calculation failed! "); } - return initSuccess; + 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 462f160..9f06bc2 100644 --- a/code/indices/rttbDoseIndex.h +++ b/code/indices/rttbDoseIndex.h @@ -1,88 +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" -#include "rttbNullPointerException.h" namespace rttb{ namespace indices{ /*! @class DoseIndex @brief This is the interface for dose/plan comparison indices. @ingroup indices */ class DoseIndex { protected: 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 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 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.getDVHTVSet() + @param tvIndex index in the DVH in the current set of DVH subset for target volume: use DVHSet.getTargetVolumeSet() */ virtual IndexValueType getValueAt(const core::DVHSet::IndexType tvIndex)=0; }; } } #endif diff --git a/code/indices/rttbDvhBasedDoseIndex.cpp b/code/indices/rttbDvhBasedDoseIndex.cpp index 53ea6f0..f250b48 100644 --- a/code/indices/rttbDvhBasedDoseIndex.cpp +++ b/code/indices/rttbDvhBasedDoseIndex.cpp @@ -1,46 +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: 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 "rttbDvhBasedDoseIndex.h" -#include "rttbException.h" -#include "rttbInvalidParameterException.h" + namespace rttb{ namespace indices{ DvhBasedDoseIndex::DvhBasedDoseIndex(DvhBasedDoseIndex::DVHSetPtr aDVHSet, DoseTypeGy aDoseReference) - :DoseIndex(aDoseReference) + :DoseIndex(aDoseReference),_dvhSet(aDVHSet) { - _dvhSet = aDVHSet; } bool DvhBasedDoseIndex::checkInputs(){ if(!_dvhSet){ return false; } else{ return true; } } } } diff --git a/code/indices/rttbHomogeneityIndex.cpp b/code/indices/rttbHomogeneityIndex.cpp index 1910d0a..b56bce0 100644 --- a/code/indices/rttbHomogeneityIndex.cpp +++ b/code/indices/rttbHomogeneityIndex.cpp @@ -1,77 +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(DVHSetPtr dvhSet, DoseTypeGy aDoseReference) :DvhBasedDoseIndex(dvhSet, aDoseReference) { 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::getValueAt(core::DVHSet::IndexType tvIndex){ - std::vector dvhTVSet=this->_dvhSet->getDVHTVSet(); + 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/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