diff --git a/apps/DoseMap/DoseMap.cpp b/apps/DoseMap/DoseMap.cpp index fa7349d..d46d82c 100644 --- a/apps/DoseMap/DoseMap.cpp +++ b/apps/DoseMap/DoseMap.cpp @@ -1,214 +1,214 @@ // ----------------------------------------------------------------------- // 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: 1221 $ (last changed revision) // @date $Date: 2015-12-01 13:43:31 +0100 (Di, 01 Dez 2015) $ (last change date) // @author $Author: hentsch $ (last changed by) */ #include "DoseMapApplicationData.h" #include "DoseMapHelper.h" #include "DoseMapCmdLineParser.h" #include "boost/shared_ptr.hpp" #include "boost/make_shared.hpp" #include "RTToolboxConfigure.h" #include "rttbException.h" #include "mapDummyRegistrationAlgorithm.h" #include "rttbDoseLoader.cpp" /** Main function of dose mapper. @retval 0 normal program execution @retval 2 not enough required input files. @retval 4 Error loading input dose file @retval 5 Error loading reference dose file @retval 6 Error loading registration @retval 9 Error while mapping or storing result. */ int main(int argc, const char** argv) { int result = 0; rttb::apps::doseMap::ApplicationData appData; boost::shared_ptr argParser; try { std::string appName = "DoseMap"; std::string appVersion = RTTB_FULL_VERSION_STRING; argParser = boost::make_shared(argc, argv, appName, appVersion); } catch (const std::exception& e) { std::cerr << e.what() << std::endl; return 2; } // This is vital. The application needs to exit if the "help" or "version" parameter is set // because this means the other parameters won't be parsed. if (argParser->isSet(argParser->OPTION_HELP) || argParser->isSet(argParser->OPTION_VERSION)) { return 0; } try{ rttb::apps::doseMap::populateAppData(argParser, appData); } catch (const std::exception& e) { std::cerr << e.what() << std::endl; } std::cout << std::endl << "*******************************************" << std::endl; std::cout << "Input dose file: " << appData._inputDoseFileName << std::endl; std::cout << "Input dose file load style: " << appData._inputDoseLoadStyle.at(0) << std::endl; std::cout << "Output file: " << appData._outputFileName << std::endl; if (!(appData._regFileName.empty())) { std::cout << "Registration file: " << appData._regFileName << std::endl; } if (!(appData._refDoseFileName.empty())) { std::cout << "Reference dose file: " << appData._refDoseFileName << std::endl; std::cout << "Reference dose style: " << appData._refDoseLoadStyle.at(0) << std::endl; } std::cout << std::endl << "read dose file... "; try { appData._inputDose = rttb::io::utils::loadDose(appData._inputDoseFileName, appData._inputDoseLoadStyle); std::cout << "done." << std::endl; } catch (::itk::ExceptionObject& e) { std::cerr << "Error!!!" << std::endl; std::cerr << e << std::endl; return 4; } catch (std::exception& e) { std::cerr << "Error!!!" << std::endl; std::cerr << e.what() << std::endl; return 4; } catch (...) { std::cerr << "Error!!! unknown error while reading input image." << std::endl; return 4; } if (!(appData._refDoseFileName.empty())) { try { appData._refDose = rttb::io::utils::loadDose(appData._refDoseFileName, appData._refDoseLoadStyle); } catch (::itk::ExceptionObject& e) { std::cerr << "Error!!!" << std::endl; std::cerr << e << std::endl; return 5; } catch (std::exception& e) { std::cerr << "Error!!!" << std::endl; std::cerr << e.what() << std::endl; return 5; } catch (...) { std::cerr << "Error!!! unknown error while reading reference image." << std::endl; return 5; } } else { appData._refDose = appData._inputDose; } if (!(appData._regFileName.empty())) { try { appData._spReg = rttb::apps::doseMap::loadRegistration(appData._regFileName); } catch (::itk::ExceptionObject& e) { std::cerr << "Error!!!" << std::endl; std::cerr << e << std::endl; return 6; } catch (std::exception& e) { std::cerr << "Error!!!" << std::endl; std::cerr << e.what() << std::endl; return 6; } catch (...) { std::cerr << "Error!!! unknown error while reading registration file." << std::endl; return 6; } } else { //generate dummy identity registration - typedef map::algorithm::DummyRegistrationAlgorithm<3> DummyRegType; + using DummyRegType = map::algorithm::DummyRegistrationAlgorithm<3>; DummyRegType::Pointer regAlg = DummyRegType::New(); appData._spReg = regAlg->getRegistration(); } try { rttb::apps::doseMap::processData(appData); } catch (::itk::ExceptionObject& e) { std::cerr << "Error!!!" << std::endl; std::cerr << e << std::endl; return 9; } catch (std::exception& e) { std::cerr << "Error!!!" << std::endl; std::cerr << e.what() << std::endl; return 9; } catch (...) { std::cerr << "Error!!! unknown error while mapping and writing image." << std::endl; return 9; } std::cout << std::endl; return result; } diff --git a/apps/DoseTool/DoseToolCmdLineParser.cpp b/apps/DoseTool/DoseToolCmdLineParser.cpp index 75a6026..7dee71c 100644 --- a/apps/DoseTool/DoseToolCmdLineParser.cpp +++ b/apps/DoseTool/DoseToolCmdLineParser.cpp @@ -1,185 +1,185 @@ // ----------------------------------------------------------------------- // 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: 1374 $ (last changed revision) // @date $Date: 2016-05-30 14:15:42 +0200 (Mo, 30 Mai 2016) $ (last change date) // @author $Author: hentsch $ (last changed by) */ #include "DoseToolCmdLineParser.h" namespace rttb { namespace apps { namespace doseTool { DoseToolCmdLineParser::DoseToolCmdLineParser(int argc, const char** argv, const std::string& name, const std::string& version, const std::string& description, const std::string& contributor, const std::string& category) : CmdLineParserBase(name, version, description, contributor, category) { //REQUIRED - typedef double DoseTypeGy; + using DoseTypeGy = double; addOption(OPTION_DOSE_FILE, OPTION_GROUP_REQUIRED, "The name of the dose file. Can be omitted if used as " "positional argument (see above).", 'd', true); addInformationForXML(OPTION_DOSE_FILE, cmdlineparsing::XMLGenerator::paramType::INPUT, { "*" }); addOption(OPTION_STRUCT_FILE, OPTION_GROUP_REQUIRED, "The name of the struct file. Can be omitted if used as " "positional argument (see above).", 's', true); addInformationForXML(OPTION_STRUCT_FILE, cmdlineparsing::XMLGenerator::paramType::INPUT, { "*" }); addOptionWithDefaultValue(OPTION_STRUCT_NAME, OPTION_GROUP_REQUIRED, "The name of the struct as regular expression. Can be omitted if used as " "positional argument or with itk struct loadingStyle (see above).", "", "", 'n', true); addInformationForXML(OPTION_STRUCT_NAME, cmdlineparsing::XMLGenerator::paramType::STRING); addPositionalOption(OPTION_DOSE_FILE, 1); addPositionalOption(OPTION_STRUCT_FILE, 1); addPositionalOption(OPTION_STRUCT_NAME, 1); addPositionalOption(OPTION_DOSE_STATISTICS, 1); std::vector defaultLoadingStyle; defaultLoadingStyle.push_back("dicom"); std::string doseLoadStyleDescription = "\"dicom\": normal dicom dose\n" "\"itk\": use itk image loading\n\"helax\": load a helax dose (choosing this style, the dose path should only be a directory)."; addOptionWithDefaultValue >(OPTION_DOSE_LOAD_STYLE, OPTION_GROUP_REQUIRED, doseLoadStyleDescription, defaultLoadingStyle, defaultLoadingStyle.at(0), 't', true, true); addInformationForXML(OPTION_DOSE_LOAD_STYLE, cmdlineparsing::XMLGenerator::paramType::STRINGENUMERATION, { "dicom", "itk", "helax" }); std::string structLoadStyleDescription = "\"dicom\": normal dicom dose\n" "\"itk\": use itk image loading\""; addOptionWithDefaultValue >(OPTION_STRUCT_LOAD_STYLE, OPTION_GROUP_REQUIRED, structLoadStyleDescription, defaultLoadingStyle, defaultLoadingStyle.at(0), 'u', true, true); addInformationForXML(OPTION_STRUCT_LOAD_STYLE, cmdlineparsing::XMLGenerator::paramType::STRINGENUMERATION, { "dicom", "itk"}); //OPTIONAL addOption(OPTION_DOSE_STATISTICS, OPTION_GROUP_OPTIONAL, "If dose statistics should be computed. The argument is the output file. Can be omitted if used as " "positional argument (see above).", 'y'); addInformationForXML(OPTION_DOSE_STATISTICS, cmdlineparsing::XMLGenerator::paramType::OUTPUT, { "*" }); addOption(OPTION_DVH, OPTION_GROUP_OPTIONAL, "If the DVH should be computed. The argument is the output file", 'z'); addInformationForXML(OPTION_DVH, cmdlineparsing::XMLGenerator::paramType::OUTPUT, { "*" }); addOption(OPTION_COMPLEX_STATISTICS, OPTION_GROUP_OPTIONAL, "If the complex dose statistics (Dx, Vx, MOHx, MOCx, MaxOHx, MinOCx) should be computed.", 'f'); addInformationForXML(OPTION_COMPLEX_STATISTICS, cmdlineparsing::XMLGenerator::paramType::BOOLEAN); addOption(OPTION_PRESCRIBED_DOSE, OPTION_GROUP_OPTIONAL, "The prescribed dose in Gy.", 'p'); addInformationForXML(OPTION_PRESCRIBED_DOSE, cmdlineparsing::XMLGenerator::paramType::DOUBLE); addOption(OPTION_ALLOW_SELF_INTERSECTION_STRUCT, OPTION_GROUP_OPTIONAL, "If a struct file contains self intersecting contours: Allow the processing of these structures and ignore potential problems." "WARNING: only use this parameter if you know what you are doing.", 'a'); addInformationForXML(OPTION_ALLOW_SELF_INTERSECTION_STRUCT, cmdlineparsing::XMLGenerator::paramType::BOOLEAN); addOption(OPTION_MULTIPLE_STRUCTS_MODE, OPTION_GROUP_OPTIONAL, "If the regex agrees with multiple structs: write a dose statistic for every struct file." "The struct name will be appended to the chosen output filename.", 'm'); addInformationForXML(OPTION_MULTIPLE_STRUCTS_MODE, cmdlineparsing::XMLGenerator::paramType::BOOLEAN); parse(argc, argv); } void DoseToolCmdLineParser::validateInput() const { std::vector doseLoadStyle = get >(OPTION_DOSE_LOAD_STYLE); std::string doseLoadStyleAbbreviation = doseLoadStyle.at(0); if (doseLoadStyleAbbreviation != "dicom" && doseLoadStyleAbbreviation != "itk" && doseLoadStyleAbbreviation != "helax") { throw cmdlineparsing::InvalidConstraintException("Unknown load style for dose file:" + doseLoadStyleAbbreviation + ".\nPlease refer to the help for valid loading style settings."); } std::vector structLoadStyle = get >(OPTION_STRUCT_LOAD_STYLE); std::string structLoadStyleAbbreviation = structLoadStyle.at(0); if (structLoadStyleAbbreviation != "dicom" && structLoadStyleAbbreviation != "itk") { throw cmdlineparsing::InvalidConstraintException("Unknown load style for struct file:" + structLoadStyleAbbreviation + ".\nPlease refer to the help for valid loading style settings."); } if (structLoadStyleAbbreviation == "dicom" || structLoadStyleAbbreviation == "helax") { if (get(OPTION_STRUCT_NAME) == "") { throw cmdlineparsing::InvalidConstraintException("The struct name (--" + OPTION_STRUCT_NAME + ") has to be defined for dicom or helax struct files."); } } if (!isSet(OPTION_DVH) && !isSet(OPTION_DOSE_STATISTICS)) { throw cmdlineparsing::InvalidConstraintException("Neither the Dose statistics (--" + OPTION_DOSE_STATISTICS + "), nor the DVH (--" + OPTION_DVH + ") option was used."); } if (isSet(OPTION_DOSE_STATISTICS) && isSet(OPTION_COMPLEX_STATISTICS)) { if (!isSet(OPTION_PRESCRIBED_DOSE)) { throw cmdlineparsing::InvalidConstraintException("The prescribed dose (--" + OPTION_PRESCRIBED_DOSE + ") has to be set for computation of complex dose statistics."); } else { if (get(OPTION_PRESCRIBED_DOSE) <= 0) { throw cmdlineparsing::InvalidConstraintException("The prescribed dose (--" + OPTION_PRESCRIBED_DOSE + ") has to be >0!"); } } } } void DoseToolCmdLineParser::printHelp() const { cmdlineparsing::CmdLineParserBase::printHelp(); std::cout << "Example:" << std::endl << std::endl; std::cout << m_programName << " dose.dcm struct.dcm Liver result.xml --" + OPTION_DVH + " dvh.xml" << std::endl << std::endl; std::cout << "This will calculate the Dose statistic for liver using \"dose.dcm\" and the struct file \"struct.dcm\" and will write the dose statistics to \"result.xml\". " " The DVH is computed as well, its values are written to \"dvh.xml\". " << std::endl; } } } } diff --git a/code/algorithms/rttbArithmetic.h b/code/algorithms/rttbArithmetic.h index e31b107..88ba643 100644 --- a/code/algorithms/rttbArithmetic.h +++ b/code/algorithms/rttbArithmetic.h @@ -1,159 +1,159 @@ // ----------------------------------------------------------------------- // 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 __ARITHMETIC_H #define __ARITHMETIC_H #include "rttbDoseAccessorInterface.h" #include "rttbMutableMaskAccessorInterface.h" #include "rttbMutableDoseAccessorInterface.h" #include "rttbMaskAccessorInterface.h" namespace rttb { namespace algorithms { namespace arithmetic { - typedef core::DoseAccessorInterface::DoseAccessorPointer DoseAccessorPointer; - typedef core::MutableDoseAccessorInterface::MutableDoseAccessorPointer MutableDoseAccessorPointer; - typedef core::MutableMaskAccessorInterface::MutableMaskAccessorPointer MutableMaskAccessorPointer; - typedef core::MaskAccessorInterface::MaskAccessorPointer MaskAccessorPointer; - typedef core::MaskAccessorInterface::MaskVoxelList MaskVoxelList; - typedef core::MaskAccessorInterface::MaskVoxelListPointer MaskVoxelListPointer; + using DoseAccessorPointer = core::DoseAccessorInterface::DoseAccessorPointer; + using MutableDoseAccessorPointer = core::MutableDoseAccessorInterface::MutableDoseAccessorPointer; + using MutableMaskAccessorPointer = core::MutableMaskAccessorInterface::MutableMaskAccessorPointer; + using MaskAccessorPointer = core::MaskAccessorInterface::MaskAccessorPointer; + using MaskVoxelList = core::MaskAccessorInterface::MaskVoxelList; + using MaskVoxelListPointer = core::MaskAccessorInterface::MaskVoxelListPointer; /*! Applies the given dose operation to the given doses and stores the result in result @pre pointers to accessors are !nullptr. The geometric Info of the individual accessors must be equal. @exception NullPointerException thrown if one of the input accessors is nullptr. @exception InvalidParameterException thrown if the geometricInfo of the given accessors does not match. */ template void arithmetic(const DoseAccessorPointer dose1, const DoseAccessorPointer dose2, MutableDoseAccessorPointer result, TDoseOperation op); ///*! Applies the given dose operation to the mapped given doses (transformation given by MatchPoint) and stores the result in result // @pre pointers to accessors are ! nullptr. // @exception NullPointerException thrown if one of the input accessors is nullptr. // @exception TransformationOutsideImageException thrown if the transformation maps to a position outside the original image. // */ // template // void arithmetic (const DoseAccessorPointer dose1, const MappableDoseAccessorPointer dose2, // MutableDoseAccessorPointer result, TDoseOperation op); /*! Applies the given dose-mask operation to the given dose and mask and stores the result in result @pre pointers to accessors are ! nullptr. The geometric Info of the individual accessors must be equal. @exception NullPointerException thrown if one of the input accessors is nullptr. @exception InvalidParameterException thrown if the geometricInfo of the given accessors does not match. */ template void arithmetic(const DoseAccessorPointer dose, const MaskAccessorPointer mask, MutableDoseAccessorPointer result, TDoseMaskOperation op); /*! Applies the given mask operation to the given masks and stores the result in result @pre pointers to accessors are !nullptr. The geometric Info of the individual accessors must be equal. @exception NullPointerException thrown if one of the input accessors is nullptr. @exception InvalidParameterException thrown if the geometricInfo of the given accessors does not match. */ template void arithmetic(const MaskAccessorPointer mask1, const MaskAccessorPointer mask2, MutableMaskAccessorPointer result, TMaskOperation op); //convenience functions void add(const DoseAccessorPointer dose1, const DoseAccessorPointer dose2, MutableDoseAccessorPointer result); //void add(const DoseAccessorPointer dose1, const MappableDoseAccessorPointer dose2, // MutableDoseAccessorPointer result); void add(const MaskAccessorPointer mask1, const MaskAccessorPointer mask2, MutableMaskAccessorPointer result); void subtract(const MaskAccessorPointer mask1, const MaskAccessorPointer mask2, MutableMaskAccessorPointer result); void multiply(const DoseAccessorPointer dose, const MaskAccessorPointer mask, MutableDoseAccessorPointer result); /*all operation classes need to implement the function calc() that performs the entry wise operation The operations are sorted into name spaces according to useful application. If the input values are compatible the operations can also be applied to accessors they were not meant for. */ //Operations for binary-dose-operation template namespace doseOp { class Add { public: DoseTypeGy calc(const DoseTypeGy dose1Val, const DoseTypeGy dose2Val) const; }; class AddWeighted { private: DoseCalcType weight1, weight2; public: /* ! Constructor initializes weights applied to individual doses values on adding. */ AddWeighted(const DoseCalcType w1 = 1, const DoseCalcType w2 = 1); DoseTypeGy calc(const DoseTypeGy dose1Val, const DoseTypeGy dose2Val) const; }; class Multiply { public: DoseTypeGy calc(const DoseTypeGy dose1Val, const DoseTypeGy dose2Val) const; }; } //Operations for binary-dose-mask-operation template namespace doseMaskOp { class Multiply { public: DoseTypeGy calc(const DoseTypeGy doseVal, const FractionType maskVal) const; }; } //Operations for binary-mask-operation template //the result of these operations needs to be between 0 and 1 namespace maskOp { class Add { public: FractionType calc(const FractionType mask1Val, const FractionType mask2Val) const; }; class Subtract { public: FractionType calc(const FractionType mask1Val, const FractionType mask2Val) const; }; } }//end namespace arithmetic }//end namespace algorithms }//end namespace core #include "rttbArithmetic.tpp" #endif diff --git a/code/algorithms/rttbDoseStatistics.h b/code/algorithms/rttbDoseStatistics.h index 590b536..c7f11a9 100644 --- a/code/algorithms/rttbDoseStatistics.h +++ b/code/algorithms/rttbDoseStatistics.h @@ -1,171 +1,171 @@ // ----------------------------------------------------------------------- // 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_STATISTICS_H #define __DOSE_STATISTICS_H #include #include #include "boost/shared_ptr.hpp" #include #include "rttbBaseType.h" #include "RTTBAlgorithmsExports.h" #include "rttbVolumeToDoseMeasureCollection.h" #include "rttbDoseToVolumeMeasureCollection.h" namespace rttb { namespace algorithms { /*! @class DoseStatistics @brief This is a data class storing different statistical values from a rt dose distribution @sa DoseStatisticsCalculator */ class RTTBAlgorithms_EXPORT DoseStatistics { public: typedef boost::shared_ptr > > ResultListPointer; - typedef boost::shared_ptr VolumeToDoseMeasureCollectionPointer; - typedef boost::shared_ptr DoseToVolumeMeasureCollectionPointer; - typedef boost::shared_ptr DoseStatisticsPointer; + using VolumeToDoseMeasureCollectionPointer = boost::shared_ptr; + using DoseToVolumeMeasureCollectionPointer = boost::shared_ptr; + using DoseStatisticsPointer = boost::shared_ptr; private: double getValue(const std::map& aMap, double key, bool findNearestValueInstead, double& storedKey) const; std::map::const_iterator findNearestKeyInMap(const std::map& aMap, double key) const; DoseStatisticType _minimum; DoseStatisticType _maximum; DoseStatisticType _mean; DoseStatisticType _stdDeviation; VoxelNumberType _numVoxels; VolumeType _volume; ResultListPointer _minimumVoxelPositions; ResultListPointer _maximumVoxelPositions; VolumeToDoseMeasureCollectionPointer _Dx; DoseToVolumeMeasureCollectionPointer _Vx; VolumeToDoseMeasureCollectionPointer _MOHx; VolumeToDoseMeasureCollectionPointer _MOCx; VolumeToDoseMeasureCollectionPointer _MaxOHx; VolumeToDoseMeasureCollectionPointer _MinOCx; DoseTypeGy _referenceDose; //for Vx computation public: /*! @brief Standard Constructor */ //DoseStatistics(); /*! @brief Constructor @details the dose statistic values are set. Complex values maximumVoxelLocation, maximumVoxelLocation, Dx, Vx, MOHx, MOCx, MaxOHx and MinOCx are optional */ DoseStatistics(DoseStatisticType minimum, DoseStatisticType maximum, DoseStatisticType mean, DoseStatisticType stdDeviation, VoxelNumberType numVoxels, VolumeType volume, ResultListPointer minimumVoxelPositions = nullptr, ResultListPointer maximumVoxelPositions = nullptr, VolumeToDoseMeasureCollection Dx = VolumeToDoseMeasureCollection(VolumeToDoseMeasureCollection::Dx), DoseToVolumeMeasureCollection Vx = DoseToVolumeMeasureCollection(DoseToVolumeMeasureCollection::Vx), VolumeToDoseMeasureCollection MOHx = VolumeToDoseMeasureCollection(VolumeToDoseMeasureCollection::MOHx), VolumeToDoseMeasureCollection MOCx = VolumeToDoseMeasureCollection(VolumeToDoseMeasureCollection::MOCx), VolumeToDoseMeasureCollection MaxOHx = VolumeToDoseMeasureCollection(VolumeToDoseMeasureCollection::MaxOHx), VolumeToDoseMeasureCollection MinOCx = VolumeToDoseMeasureCollection(VolumeToDoseMeasureCollection::MinOCx), DoseTypeGy referenceDose = -1); ~DoseStatistics(); void setMinimumVoxelPositions(ResultListPointer minimumVoxelPositions); void setMaximumVoxelPositions(ResultListPointer maximumVoxelPositions); void setDx(VolumeToDoseMeasureCollectionPointer DxValues); void setVx(DoseToVolumeMeasureCollectionPointer VxValues); void setMOHx(VolumeToDoseMeasureCollectionPointer MOHxValues); void setMOCx(VolumeToDoseMeasureCollectionPointer MOCxValues); void setMaxOHx(VolumeToDoseMeasureCollectionPointer MaxOHxValues); void setMinOCx(VolumeToDoseMeasureCollectionPointer MinOCxValues); void setReferenceDose(DoseTypeGy referenceDose); /*! @brief Get number of voxels in doseIterator, with sub-voxel accuracy. */ VoxelNumberType getNumberOfVoxels() const; /*! @brief Get the volume of the voxels in doseIterator (in cm3), with sub-voxel accuracy */ VolumeType getVolume() const; /*! @brief Get the reference dose for Vx computation */ DoseTypeGy getReferenceDose() const; /*! @brief Get the maximum of the current dose distribution. @return Return the maximum dose in Gy */ DoseStatisticType getMaximum() const; /*! @brief Get a vector of the the maximum dose VoxelGridIDs together with their dose value in Gy @exception InvalidDoseException if the vector has not been set (i.e. is empty) */ ResultListPointer getMaximumVoxelPositions() const; /*! @brief Get the minimum of the current dose distribution. @return Return the minimum dose in Gy */ DoseStatisticType getMinimum() const; /*! @brief Get a vector of the the minimum dose VoxelGridIDs together with their dose value in Gy @exception InvalidDoseException if the vector has not been set (i.e. is empty) */ ResultListPointer getMinimumVoxelPositions() const; /*! @brief Get the mean of the current dose distribution. @return Return the mean dose in Gy */ DoseStatisticType getMean() const; /*! @brief Get the standard deviation of the current dose distribution. @return Return the standard deviation in Gy */ DoseStatisticType getStdDeviation() const; /*! @brief Get the variance of of the current dose distribution. @return Return the variance in Gy */ DoseStatisticType getVariance() const; VolumeToDoseMeasureCollection getDx() const; DoseToVolumeMeasureCollection getVx() const; VolumeToDoseMeasureCollection getMOHx() const; VolumeToDoseMeasureCollection getMOCx() const; VolumeToDoseMeasureCollection getMaxOHx() const; VolumeToDoseMeasureCollection getMinOCx() const; }; } } #endif diff --git a/code/algorithms/rttbDoseStatisticsCalculator.h b/code/algorithms/rttbDoseStatisticsCalculator.h index cabd8f4..75ba9c6 100644 --- a/code/algorithms/rttbDoseStatisticsCalculator.h +++ b/code/algorithms/rttbDoseStatisticsCalculator.h @@ -1,199 +1,199 @@ // ----------------------------------------------------------------------- // 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_STATISTICS_CALCULATOR_H #define __DOSE_STATISTICS_CALCULATOR_H #include #include #include #include "rttbDoseIteratorInterface.h" #include "rttbDoseStatistics.h" #include "RTTBAlgorithmsExports.h" #include "rttbDxVolumeToDoseMeasureCollectionCalculator.h" #include "rttbVxDoseToVolumeMeasureCollectionCalculator.h" #include "rttbMOHxVolumeToDoseMeasureCollectionCalculator.h" #include "rttbMOCxVolumeToDoseMeasureCollectionCalculator.h" #include "rttbMaxOHxVolumeToDoseMeasureCollectionCalculator.h" #include "rttbMinOCxVolumeToDoseMeasureCollectionCalculator.h" namespace rttb { namespace algorithms { /*! @class DoseStatisticsCalculator @brief Class for calculating different statistical values from a RT dose distribution @details These values range from standard statistical values such as minimum, maximum and mean to more complex dose specific measures such as Vx (volume irradiated with a dose >=x), Dx (minimal dose delivered to x% of the VOI) or MOHx (mean in the hottest volume). For a complete list, see calculateDoseStatistics(). @note the complex dose statistics are precomputed and cannot be computed "on the fly" lateron! The doses/volumes that should be used for precomputation have to be set in calculateDoseStatistics() */ class RTTBAlgorithms_EXPORT DoseStatisticsCalculator { public: - typedef core::DoseIteratorInterface::DoseIteratorPointer DoseIteratorPointer; - typedef DoseStatistics::ResultListPointer ResultListPointer; - typedef DoseStatistics::DoseStatisticsPointer DoseStatisticsPointer; + using DoseIteratorPointer = core::DoseIteratorInterface::DoseIteratorPointer; + using ResultListPointer = DoseStatistics::ResultListPointer; + using DoseStatisticsPointer = DoseStatistics::DoseStatisticsPointer; private: DoseIteratorPointer _doseIterator; /*! @brief Contains relevant dose values sorted in descending order. */ std::vector _doseVector; /*! @brief Contains the corresponding voxel proportions to the values in doseVector. */ std::vector _voxelProportionVector; /*! @brief The doseStatistics are stored here. */ DoseStatisticsPointer _statistics; bool _simpleDoseStatisticsCalculated; bool _complexDoseStatisticsCalculated; bool _multiThreading; ::boost::shared_ptr _mutex; ::boost::shared_ptr _Vx; ::boost::shared_ptr _Dx; ::boost::shared_ptr _MOHx; ::boost::shared_ptr _MOCx; ::boost::shared_ptr _MaxOHx; ::boost::shared_ptr _MinOCx; /*! @brief Calculates the positions where the dose has its maximum @param maxNumberMaximaPositions the maximal amount of computed positions @pre maximumDose must be defined in _statistics with the correct value */ ResultListPointer computeMaximumPositions(unsigned int maxNumberMaximaPositions) const; /*! @brief Calculates the positions where the dose has its minimum @param maxNumberMinimaPositions the maximal amount of computed positions (they are read sequentially using the iterator until maxNumberMinimaPositions have been read, other positions are not considered) @pre minimumDose must be defined in _statistics with the correct value */ ResultListPointer computeMinimumPositions(unsigned int maxNumberMinimaPositions) const; /*! @brief Calculates simple dose statistics (min, mean, max, stdDev, minDosePositions, maxDosePositions) @param maxNumberMinimaPositions the maximal amount of computed positions where the dose has its minimum that is computed @param maxNumberMaximaPositions the maximal amount of computed positions where the dose has its maximum that is computed */ void calculateSimpleDoseStatistics(unsigned int maxNumberMinimaPositions, unsigned int maxNumberMaximaPositions); /*! @brief Calculates complex dose statistics (Dx, Vx, MOHx, MOCx, MaxOHx, MinOCx) @warning computations can take quite long (>1 min) for large structures as many statistics are precomputed */ void calculateComplexDoseStatistics(DoseTypeGy referenceDose, const std::vector& precomputeDoseValues, const std::vector& precomputeVolumeValues); public: ~DoseStatisticsCalculator(); /*! @brief Constructor @param aDoseIterator the dose to be analyzed */ DoseStatisticsCalculator(DoseIteratorPointer aDoseIterator); DoseIteratorPointer getDoseIterator() const; /*! @brief Compute simple or complex dose statistics with default relative x values and the maximum dose as default reference dose (for Vx computation) @details The following statistics are calculated always (i.e. also if computeComplexMeasures=false):
  • minimum dose
  • mean dose
  • maximum dose
  • standard deviation dose
  • voxel positions of minimum dose
  • voxel positions of maximum dose
Additionally, these statistics are computed if computeComplexMeasures=true:
  • Dx (the minimal dose delivered to a volume >= x)
  • Vx (the volume irradiated with a dose >= x)
  • MOHx (mean dose of the hottest x volume)
  • MOCx (mean dose of the coldest x volume)
  • MaxOHx (Maximum outside of the hottest x volume)
  • MinOCx (Minimum outside of the coldest x volume)
Default x values for Vx are 0.02, 0.05, 0.1, 0.9, 0.95 and 0.98, with respect to maxDose. Default x values for Dx, MOHx, MOCx, MaxOHx and MinOCx are 0.02, 0.05, 0.1, 0.9, 0.95 and 0.98, with respect to volume. @param computeComplexMeasures should complex statistics be calculated? If it is true, the complex dose statistics will be calculated with default relative x values and the maximum dose as reference dose @param maxNumberMinimaPositions the maximal amount of computed positions where the dose has its minimum that is computed @param maxNumberMaximaPositions the maximal amount of computed positions where the dose has its maximum that is computed @warning If computeComplexMeasures==true, computations can take quite long (>1 min) for large structures as many statistics are precomputed @note The complex dose statistics are precomputed and cannot be computed "on the fly" lateron! Only the default x values can be requested in DoseStatistics! */ DoseStatisticsPointer calculateDoseStatistics(bool computeComplexMeasures = false, unsigned int maxNumberMinimaPositions = 10, unsigned int maxNumberMaximaPositions = 10); /*! @brief Compute complex dose statistics with given reference dose and default relative x values @param referenceDose the reference dose to compute Vx, normally it should be the prescribed dose @param maxNumberMinimaPositions the maximal amount of computed positions where the dose has its minimum that is computed @param maxNumberMaximaPositions the maximal amount of computed positions where the dose has its maximum that is computed @exception InvalidParameterException thrown if referenceDose <= 0 @warning Computations can take quite long (>1 min) for large structures as many statistics are precomputed @note The complex dose statistics are precomputed and cannot be computed "on the fly" lateron! Only the default x values can be requested in DoseStatistics! */ DoseStatisticsPointer calculateDoseStatistics(DoseTypeGy referenceDose, unsigned int maxNumberMinimaPositions = 10, unsigned int maxNumberMaximaPositions = 10); /*! @brief Compute complex dose statistics with given relative x values and reference dose @param precomputeDoseValues the relative dose values for Vx precomputation, e.g. 0.02, 0.05, 0.95... @param precomputeVolumeValues the relative volume values for Dx, MOHx, MOCx, MaxOHx and MinOCx precomputation, e.g. 0.02, 0.05, 0.95... @param referenceDose the reference dose to compute Vx, normally it should be the prescribed dose. Default value is the maximum dose. @param maxNumberMinimaPositions the maximal amount of computed positions where the dose has its minimum that is computed @param maxNumberMaximaPositions the maximal amount of computed positions where the dose has its maximum that is computed @warning Computations can take quite long (>1 min) for large structures as many statistics are precomputed @note The complex dose statistics are precomputed and cannot be computed "on the fly" lateron! The doses/volumes that should be used for precomputation have to be set by in precomputeDoseValues and precomputeVolumeValues. Only these values can be requested in DoseStatistics! */ DoseStatisticsPointer calculateDoseStatistics(const std::vector& precomputeDoseValues, const std::vector& precomputeVolumeValues, DoseTypeGy referenceDose = -1, unsigned int maxNumberMinimaPositions = 10, unsigned int maxNumberMaximaPositions = 10); /*! @brief Adds additonal precompute values for all complex Dose Statistics @exception InvalidDoseException if complexDoseStatistics are not already calculated */ void addPrecomputeValues(const std::vector& values); /*! @brief Recalculates the DoseMeasures for all complex Dose Statistics @exception InvalidDoseException if complexDoseStatistics are not already calculated */ void recalculateDoseStatistics(); void setMultiThreading(bool choice); }; } } #endif diff --git a/code/core/rttbAccessorInterface.h b/code/core/rttbAccessorInterface.h index 83f75da..c532cb1 100644 --- a/code/core/rttbAccessorInterface.h +++ b/code/core/rttbAccessorInterface.h @@ -1,95 +1,95 @@ // ----------------------------------------------------------------------- // 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 __ACCESSOR_INTERFACE_H #define __ACCESSOR_INTERFACE_H #include #include "rttbBaseType.h" #include "rttbGeometricInfo.h" #include "rttbIndexConversionInterface.h" #include namespace rttb { namespace core { /*! @class AccessorInterface @brief Interface for any sort of Accessor */ class RTTBCore_EXPORT AccessorInterface : public IndexConversionInterface { public: - typedef boost::shared_ptr AccessorPointer; - typedef boost::shared_ptr DoseAccessorPointer; + using AccessorPointer = boost::shared_ptr; + using DoseAccessorPointer = boost::shared_ptr; private: AccessorInterface(const AccessorInterface&); //not implemented on purpose -> non-copyable AccessorInterface& operator=(const AccessorInterface&);//not implemented on purpose -> non-copyable public: AccessorInterface() = default; ~AccessorInterface() override = default; /*! @brief test if given ID is inside current dose grid */ bool validID(const VoxelGridID aID) const { return this->getGeometricInfo().validID(aID); }; /*! @brief test if given index is inside current dose grid */ bool validIndex(const VoxelGridIndex3D& aIndex) const { return this->getGeometricInfo().validIndex(aIndex); }; virtual const core::GeometricInfo& getGeometricInfo() const = 0; virtual GridSizeType getGridSize() const { return this->getGeometricInfo().getNumberOfVoxels(); }; virtual GenericValueType getValueAt(const VoxelGridID aID) const = 0; virtual GenericValueType getValueAt(const VoxelGridIndex3D& aIndex) const = 0; /*! @brief is true if dose is on a homogeneous grid @remarks Inhomogeneous grids are not supported at the moment, but if they will be supported in the future the interface does not need to change. */ virtual bool isGridHomogeneous() const { return true; } virtual const IDType getUID() const = 0; }; } } #endif diff --git a/code/core/rttbBaseType.h b/code/core/rttbBaseType.h index 4a37757..a761712 100644 --- a/code/core/rttbBaseType.h +++ b/code/core/rttbBaseType.h @@ -1,604 +1,604 @@ // ----------------------------------------------------------------------- // 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 __BASE_TYPE_NEW_H #define __BASE_TYPE_NEW_H #include #include #include #include #include #include #include #include namespace rttb { const double errorConstant = 1e-5; const double reducedErrorConstant = 0.0001; - typedef unsigned short UnsignedIndex1D; + using UnsignedIndex1D = unsigned short; /*! @class UnsignedIndex3D @brief 3D index. */ class UnsignedIndex3D: public boost::numeric::ublas::vector { public: UnsignedIndex3D() : boost::numeric::ublas::vector(3,0) {} UnsignedIndex3D(const UnsignedIndex1D value) : boost::numeric::ublas::vector(3, value) {} UnsignedIndex3D(const UnsignedIndex1D xValue, const UnsignedIndex1D yValue, const UnsignedIndex1D zValue) : boost::numeric::ublas::vector(3, xValue) { (*this)(1) = yValue; (*this)(2) = zValue; } const UnsignedIndex1D x() const { return (*this)(0); } const UnsignedIndex1D y() const { return (*this)(1); } const UnsignedIndex1D z() const { return (*this)(2); } friend bool operator==(const UnsignedIndex3D& gi1, const UnsignedIndex3D& gi2) { if (gi1.size() != gi2.size()) { return false; } for (size_t i = 0; i < gi1.size(); i++) { if (gi1(i) != gi2(i)) { return false; } } return true; } friend std::ostream& operator<<(std::ostream& s, const UnsignedIndex3D& aVector) { s << "[ " << aVector(0) << ", " << aVector(1) << ", " << aVector(2) << " ]"; return s; } }; - typedef std::list UnsignedIndexList; + using UnsignedIndexList = std::list; - typedef std::string FileNameString; + using FileNameString = std::string; - typedef std::string ContourGeometricTypeString; + using ContourGeometricTypeString = std::string; - typedef double WorldCoordinate; + using WorldCoordinate = double; /*! @class WorldCoordinate3D @brief 3D coordinate in real world coordinates like in DICOM to define ImagePositionPatient. */ class WorldCoordinate3D: public boost::numeric::ublas::vector { public: WorldCoordinate3D() : boost::numeric::ublas::vector(3,0) {} WorldCoordinate3D(const WorldCoordinate value) : boost::numeric::ublas::vector(3, value) {} WorldCoordinate3D(const WorldCoordinate xValue, const WorldCoordinate yValue, const WorldCoordinate zValue) : boost::numeric::ublas::vector(3, xValue) { (*this)(1) = yValue; (*this)(2) = zValue; } WorldCoordinate3D(const WorldCoordinate3D& w): boost::numeric::ublas::vector(3) { (*this)(0) = w.x(); (*this)(1) = w.y(); (*this)(2) = w.z(); } const WorldCoordinate x() const { return (*this)(0); } const WorldCoordinate y() const { return (*this)(1); } const WorldCoordinate z() const { return (*this)(2); } //vector cross product (not included in boost.ublas) WorldCoordinate3D cross(WorldCoordinate3D aVector) const { WorldCoordinate3D result; WorldCoordinate x = (*this)(0); WorldCoordinate y = (*this)(1); WorldCoordinate z = (*this)(2); result(0) = y * aVector(2) - z * aVector(1); result(1) = z * aVector(0) - x * aVector(2); result(2) = x * aVector(1) - y * aVector(0); return result; } const std::string toString() const { std::string s = std::to_string(x()) + " " + std::to_string(y()) + " " + std::to_string(z()); return s; } WorldCoordinate3D& operator=(const WorldCoordinate3D& wc) { (*this)(0) = wc.x(); (*this)(1) = wc.y(); (*this)(2) = wc.z(); return (*this); } WorldCoordinate3D& operator=(const boost::numeric::ublas::vector wc) { (*this)(0) = wc(0); (*this)(1) = wc(1); (*this)(2) = wc(2); return (*this); } WorldCoordinate3D operator-(const boost::numeric::ublas::vector wc) { return WorldCoordinate3D((*this)(0) - wc(0), (*this)(1) - wc(1), (*this)(2) - wc(2)); } WorldCoordinate3D operator+(const boost::numeric::ublas::vector wc) { return WorldCoordinate3D((*this)(0) + wc(0), (*this)(1) + wc(1), (*this)(2) + wc(2)); } friend bool operator==(const WorldCoordinate3D& wc1, const WorldCoordinate3D& wc2) { if (wc1.size() != wc2.size()) { return false; } for (size_t i = 0; i < wc1.size(); i++) { if (wc1(i) != wc2(i)) { return false; } } return true; } bool equalsAlmost(const WorldCoordinate3D& another, double errorConstantWC = 1e-5) const { if (size() != another.size()) { return false; } double dist = norm_2(*this - another); return dist < errorConstantWC; } friend std::ostream& operator<<(std::ostream& s, const WorldCoordinate3D& aVector) { s << "[ " << aVector(0) << ", " << aVector(1) << ", " << aVector(2) << " ]"; return s; } }; /* ! @brief continuous index */ - typedef WorldCoordinate3D DoubleVoxelGridIndex3D; + using DoubleVoxelGridIndex3D = rttb::WorldCoordinate3D; - typedef UnsignedIndex3D ImageSize; + using ImageSize = rttb::UnsignedIndex3D; - typedef double GridVolumeType; + using GridVolumeType = double; /*! @class SpacingVectorType3D @brief 3D spacing vector. @pre values of this vector may not be negative. */ class SpacingVectorType3D: public boost::numeric::ublas::vector { public: SpacingVectorType3D() : boost::numeric::ublas::vector(3,0) {} SpacingVectorType3D(const GridVolumeType value) : boost::numeric::ublas::vector(3, value) {} SpacingVectorType3D(const GridVolumeType xValue, const GridVolumeType yValue, const GridVolumeType zValue) : boost::numeric::ublas::vector(3, xValue) { (*this)(1) = yValue; (*this)(2) = zValue; } SpacingVectorType3D(const SpacingVectorType3D& w): boost::numeric::ublas::vector(3) { (*this)(0) = w.x(); (*this)(1) = w.y(); (*this)(2) = w.z(); } const GridVolumeType x() const { return (*this)(0); } const GridVolumeType y() const { return (*this)(1); } const GridVolumeType z() const { return (*this)(2); } const std::string toString() const { std::string s = std::to_string(x()) + " " + std::to_string(y()) + " " + std::to_string(z()); return s; } SpacingVectorType3D& operator=(const SpacingVectorType3D& wc) { (*this)(0) = wc.x(); (*this)(1) = wc.y(); (*this)(2) = wc.z(); return (*this); } SpacingVectorType3D& operator=(const WorldCoordinate3D& wc) { (*this)(0) = GridVolumeType(wc.x()); (*this)(1) = GridVolumeType(wc.y()); (*this)(2) = GridVolumeType(wc.z()); return (*this); } SpacingVectorType3D& operator=(const boost::numeric::ublas::vector wc) { (*this)(0) = wc(0); (*this)(1) = wc(1); (*this)(2) = wc(2); return (*this); } friend bool operator==(const SpacingVectorType3D& wc1, const SpacingVectorType3D& wc2) { if (wc1.size() != wc2.size()) { return false; } for (size_t i = 0; i < wc1.size(); i++) { if (wc1(i) != wc2(i)) { return false; } } return true; } bool equalsAlmost(const SpacingVectorType3D& another, double errorConstantSV = 1e-5) const { if ((*this).size() != another.size()) { return false; } double dist = norm_2(*this - another); return dist < errorConstantSV; } friend std::ostream& operator<<(std::ostream& s, const SpacingVectorType3D& aVector) { s << "[ " << aVector(0) << ", " << aVector(1) << ", " << aVector(2) << " ]"; return s; } }; /*! @class OrientationMatrix @brief Used to store image orientation information */ class OrientationMatrix : public boost::numeric::ublas::matrix { public: /*! The default constructor generates a 3x3 unit matrix */ OrientationMatrix() : boost::numeric::ublas::matrix(3, 3, 0) { for (std::size_t m = 0; m < (*this).size1(); m++) { (*this)(m, m) = 1; } } OrientationMatrix(const WorldCoordinate value) : boost::numeric::ublas::matrix(3, 3, value) {} bool equalsAlmost(const OrientationMatrix& anOrientationMatrix, double errorConstantOM=1e-5) const { if (anOrientationMatrix.size1() == (*this).size1()) { if (anOrientationMatrix.size2() == (*this).size2()) { for (std::size_t m = 0; m < anOrientationMatrix.size1(); m++) { for (std::size_t n = 0; n < anOrientationMatrix.size2(); n++) { if ((std::abs((*this)(m, n) - anOrientationMatrix(m, n)) > errorConstantOM)) { return false; } } }// end element comparison } else { return false; } } else { return false; } return true; } friend bool operator==(const OrientationMatrix& om1, const OrientationMatrix& om2) { return om1.equalsAlmost(om2, 0.0); } friend std::ostream& operator<<(std::ostream& s, const OrientationMatrix& anOrientationMatrix) { s << "[ "; for (std::size_t m = 0; m < anOrientationMatrix.size1(); m++) { s << "[ "; for (std::size_t n = 0; n < anOrientationMatrix.size2(); n++) { if (n == 0) { s << anOrientationMatrix(m, n); } else { s << ", " << anOrientationMatrix(m, n); } } s << " ]"; } s << " ]"; return s; } }; /*! base for 2D and 3D VoxelIndex; Therefore required beside VoxelGridID */ - typedef unsigned int GridIndexType; + using GridIndexType = unsigned int; /*! @class VoxelGridIndex3D @brief 3D voxel grid index in a discret geometry (matrix/image). @details analogous to DICOM where ImagePositionPatient gives the position of the center of the first coordinate (0/0/0) */ class VoxelGridIndex3D: public boost::numeric::ublas::vector { public: VoxelGridIndex3D() : boost::numeric::ublas::vector(3,0) {} VoxelGridIndex3D(const GridIndexType value) : boost::numeric::ublas::vector(3, value) {} VoxelGridIndex3D(const GridIndexType xValue, const GridIndexType yValue, const GridIndexType zValue) : boost::numeric::ublas::vector(3, xValue) { (*this)(1) = yValue; (*this)(2) = zValue; } const GridIndexType x() const { return (*this)(0); } const GridIndexType y() const { return (*this)(1); } const GridIndexType z() const { return (*this)(2); } const std::string toString() const { std::string s = std::to_string(x()) + " " + std::to_string(y()) + " " + std::to_string(z()); return s; } VoxelGridIndex3D& operator=(const UnsignedIndex3D& ui) { (*this)(0) = ui(0); (*this)(1) = ui(1); (*this)(2) = ui(2); return (*this); } friend bool operator==(const VoxelGridIndex3D& gi1, const VoxelGridIndex3D& gi2) { if (gi1.size() != gi2.size()) { return false; } for (size_t i = 0; i < gi1.size(); i++) { if (gi1(i) != gi2(i)) { return false; } } return true; } friend std::ostream& operator<<(std::ostream& s, const VoxelGridIndex3D& aVector) { s << "[ " << aVector(0) << ", " << aVector(1) << ", " << aVector(2) << " ]"; return s; } }; /*! @class VoxelGridIndex3D @brief 2D voxel grid index. */ class VoxelGridIndex2D: public boost::numeric::ublas::vector { public: VoxelGridIndex2D() : boost::numeric::ublas::vector(2,0) {} VoxelGridIndex2D(const GridIndexType value) : boost::numeric::ublas::vector(2, value) {} VoxelGridIndex2D(const GridIndexType xValue, const GridIndexType yValue) : boost::numeric::ublas::vector(2, xValue) { (*this)(1) = yValue; } const GridIndexType x() const { return (*this)(0); } const GridIndexType y() const { return (*this)(1); } const std::string toString() const { std::string s = std::to_string(x()) + " " + std::to_string(y()); return s; } friend bool operator==(const VoxelGridIndex2D& gi1, const VoxelGridIndex2D& gi2) { if (gi1.size() != gi2.size()) { return false; } for (size_t i = 0; i < gi1.size(); i++) { if (gi1(i) != gi2(i)) { return false; } } return true; } friend std::ostream& operator<<(std::ostream& s, const VoxelGridIndex2D& aVector) { s << "[ " << aVector(0) << ", " << aVector(1) << " ]"; return s; } }; - typedef long GridSizeType; + using GridSizeType = long; - typedef int VoxelGridID; //starts from 0 and is continuously counting all positions on the grid - typedef unsigned int VoxelGridDimensionType; + using VoxelGridID = int; //starts from 0 and is continuously counting all positions on the grid + using VoxelGridDimensionType = unsigned int; typedef double FractionType, DVHVoxelNumber; typedef double DoseCalcType, DoseTypeGy, GenericValueType, DoseVoxelVolumeType, VolumeType, GridVolumeType, PercentType, VoxelNumberType, BEDType, LQEDType; - typedef std::string IDType; + using IDType = std::string; - typedef std::string StructureLabel; + using StructureLabel = std::string; struct DVHRole { enum Type { TargetVolume = 1, HealthyTissue = 2, WholeVolume = 4, UserDefined = 128 } Type; }; struct DVHType { enum Type { Differential = 1, Cumulative = 2 } Type; }; - typedef std::string FileNameType; + using FileNameType = std::string; - typedef std::vector PolygonType; + using PolygonType = std::vector; - typedef std::vector PolygonSequenceType; + using PolygonSequenceType = std::vector; - typedef double IndexValueType; + using IndexValueType = double; - typedef double DoseStatisticType; + using DoseStatisticType = double; - typedef std::string DICOMRTFileNameString; + using DICOMRTFileNameString = std::string; - typedef unsigned short Uint16; + using Uint16 = unsigned short; typedef std::string XMLString, StatisticsString; }//end: namespace rttb #endif diff --git a/code/core/rttbDVH.h b/code/core/rttbDVH.h index 5849de0..0185c1e 100644 --- a/code/core/rttbDVH.h +++ b/code/core/rttbDVH.h @@ -1,207 +1,207 @@ // ----------------------------------------------------------------------- // 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_H #define __DVH_H #include #include #include #include "boost/shared_ptr.hpp" #include "rttbBaseType.h" #include "RTTBCoreExports.h" namespace rttb { namespace core { /*! @class DVH @brief This is a class representing a dose volume histogram (DVH) */ class RTTBCore_EXPORT DVH { public: - typedef std::deque DataDifferentialType; - typedef boost::shared_ptr DVHPointer; + using DataDifferentialType = std::deque; + using DVHPointer = boost::shared_ptr; private: /*! @brief Differential dvh data index is the dose bin, value is the voxel number (sub voxel accuracy) of the dose bin */ DataDifferentialType _dataDifferential; /*! @brief Differential dvh data relative to the total number of voxels */ DataDifferentialType _dataDifferentialRelative; /*! @brief Absolute dose value of a dose-bin in Gy */ DoseTypeGy _deltaD; /*! @brief Volume of a voxel in cm3 */ DoseVoxelVolumeType _deltaV; IDType _structureID; IDType _doseID; IDType _voxelizationID; StructureLabel _label; DoseStatisticType _maximum; DoseStatisticType _minimum; DoseStatisticType _mean; DoseStatisticType _modal; DVHVoxelNumber _numberOfVoxels; DoseStatisticType _median; DoseStatisticType _stdDeviation; DoseStatisticType _variance; DataDifferentialType _dataCumulative; DataDifferentialType _dataCumulativeRelative; /*! @brief DVH initialization The DVH is initialized and all statistical values are calculated. @throw if _deltaV or _deltaD are zero @throw is _data differential is empty */ void init(); /*! @brief Calculate the cumulative data of dvh */ void calcCumulativeDVH(); public: ~DVH(); /*! @throw if _deltaV or _deltaD are zero @throw is _data differential is empty */ DVH(const DataDifferentialType& aDataDifferential, const DoseTypeGy& aDeltaD, const DoseVoxelVolumeType& aDeltaV, const IDType& aStructureID, const IDType& aDoseID); /*! @throw if _deltaV or _deltaD are zero @throw is _data differential is empty */ DVH(const DataDifferentialType& aDataDifferential, DoseTypeGy aDeltaD, DoseVoxelVolumeType aDeltaV, const IDType& aStructureID, const IDType& aDoseID, const IDType& aVoxelizationID); DVH(const DVH& copy); /*! @throw if _deltaV or _deltaD are zero @throw is _data differential is empty */ DVH& operator=(const DVH& copy); /*! equality operator DVHs are considered equal if the following are equal (let alone double inconsistencies): - structureID - doseID - voxelizationID - number of voxels - Histogram entries. */ bool friend operator==(const DVH& aDVH, const DVH& otherDVH); friend std::ostream& operator<<(std::ostream& s, const DVH& aDVH); void setLabel(StructureLabel aLabel); StructureLabel getLabel() const; /*! @param relativeVolume default false-> Value is the voxel number of the dose bin; if true-> value is the relative volume % between 0 and 1, (the voxel number of this dose bin)/(number of voxels) @return Return differential data of the dvh (relative or absolute depending on the input parameter). */ DataDifferentialType getDataDifferential(bool relativeVolume = false) const; /*! @param relativeVolume default false-> Value is the voxel number of the dose bin; if true-> value is the relative volume % between 0 and 1, (the voxel number of this dose bin)/(number of voxels) @return Return cumulative data of the dvh */ DataDifferentialType getDataCumulative(bool relativeVolume = false) const; DoseVoxelVolumeType getDeltaV() const; DoseTypeGy getDeltaD() const; IDType getStructureID() const; IDType getDoseID() const; IDType getVoxelizationID() const; void setDoseID(IDType aDoseID); void setStructureID(IDType aStrID); /*! @brief Calculate number of the voxels (with sub voxel accuracy) @return Return -1 if not initialized */ DVHVoxelNumber getNumberOfVoxels() const; /*! @brief Get the maximum dose in Gy from dvh @return Return the maximum dose in Gy (i+0.5)*deltaD, i-the maximal dose-bin with volume>0 Return -1 if not initialized */ DoseStatisticType getMaximum() const; /*! @brief Get the minimum dose in Gy from dvh @return Return the minimum dose (i+0.5)*deltaD, i-the minimal dose-bin with volume>0 Return -1 if not initialized */ DoseStatisticType getMinimum() const; DoseStatisticType getMean() const; DoseStatisticType getMedian() const; DoseStatisticType getModal() const; DoseStatisticType getStdDeviation() const; DoseStatisticType getVariance() const; /*! @brief Get Vx the volume irradiated to >= x @return Return absolute Volume in absolute cm3 Return -1 if not initialized */ VolumeType getVx(DoseTypeGy xDoseAbsolute) const; /*! @brief Get Dx the minimal dose delivered to x @return Return absolute dose value in Gy Return -1 if not initialized */ DoseTypeGy getDx(VolumeType xVolumeAbsolute) const; /*! @brief Calculate the absolute volume in cm3 @param relativePercent 0~100, the percent of the whole volume */ VolumeType getAbsoluteVolume(int relativePercent) const; /* @brief Multiplies each values with its Delta value. Values depend on DVHType. @param The DVHType that is being used DVHType::Cumulative or DVHType::Differential */ std::map getNormalizedDVH(DVHType dvhType = { DVHType::Cumulative }) const; }; } } #endif diff --git a/code/core/rttbDVHCalculator.h b/code/core/rttbDVHCalculator.h index 606cf0c..fb6e126 100644 --- a/code/core/rttbDVHCalculator.h +++ b/code/core/rttbDVHCalculator.h @@ -1,74 +1,74 @@ // ----------------------------------------------------------------------- // 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_CALCULATOR_H #define __DVH_CALCULATOR_H #include "rttbBaseType.h" #include "rttbDoseIteratorInterface.h" #include "rttbMaskedDoseIteratorInterface.h" #include "rttbDVHGeneratorInterface.h" #include "RTTBCoreExports.h" namespace rttb { namespace core { /*! @class DVHCalculator @brief Calculates a DVH for a given DoseIterator. */ class RTTBCore_EXPORT DVHCalculator : public DVHGeneratorInterface { public: - typedef core::DoseIteratorInterface::DoseIteratorPointer DoseIteratorPointer; - typedef core::MaskedDoseIteratorInterface::MaskedDoseIteratorPointer MaskedDoseIteratorPointer; + using DoseIteratorPointer = core::DoseIteratorInterface::DoseIteratorPointer; + using MaskedDoseIteratorPointer = core::MaskedDoseIteratorInterface::MaskedDoseIteratorPointer; DoseIteratorPointer _doseIteratorPtr; IDType _structureID; IDType _doseID; DoseTypeGy _deltaD; int _numberOfBins; /*! @brief Constructor. @param aDeltaD the absolute dose value in Gy for dose_bin [i,i+1). Optional, if aDeltaD==0, it will be calculated using aDeltaD=max(aDoseIterator)*1.5/aNumberOfBins @exception InvalidParameterException throw if _numberOfBins<=0 or _deltaD<0 */ DVHCalculator(DoseIteratorPointer aDoseIterator, const IDType& aStructureID, const IDType& aDoseID, const DoseTypeGy aDeltaD = 0, const int aNumberOfBins = 201); ~DVHCalculator(); /*! @brief Generate DVH @return Return new shared pointer of DVH. @exception InvalidParameterException throw if _numberOfBins invalid: _numberOfBins must be > max(aDoseIterator)/aDeltaD! */ DVHPointer generateDVH() override; }; } } #endif diff --git a/code/core/rttbDVHGeneratorInterface.h b/code/core/rttbDVHGeneratorInterface.h index 7ea6ce7..ceb095f 100644 --- a/code/core/rttbDVHGeneratorInterface.h +++ b/code/core/rttbDVHGeneratorInterface.h @@ -1,50 +1,50 @@ // ----------------------------------------------------------------------- // 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_GENERATOR_INTERFACE_H #define __DVH_GENERATOR_INTERFACE_H #include #include "rttbDVH.h" namespace rttb { namespace core { /*! @class DVHGeneratorInterface @brief Interface for all DVH generating classes */ class DVHGeneratorInterface { public: - typedef core::DVH::DVHPointer DVHPointer; + using DVHPointer = core::DVH::DVHPointer; protected: DVHPointer _dvh; public: /*! @brief Generate DVH @return Return new shared pointer of DVH. */ virtual DVHPointer generateDVH() = 0; }; } } #endif diff --git a/code/core/rttbDVHSet.h b/code/core/rttbDVHSet.h index 91d5fd8..34b4e21 100644 --- a/code/core/rttbDVHSet.h +++ b/code/core/rttbDVHSet.h @@ -1,141 +1,141 @@ // ----------------------------------------------------------------------- // 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" #include "RTTBCoreExports.h" namespace rttb { namespace core { /*! @class DVHSet @brief This is a class representing a RT DVHSet including Target Volume and Organ at Risk. @details 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 RTTBCore_EXPORT DVHSet { public: - typedef std::vector DVHSetType; - typedef DVHSetType::size_type IndexType; + using DVHSetType = std::vector; + using IndexType = DVHSetType::size_type; 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 nullptr 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& getTargetVolumeSet() const { return _dvhTVSet; }; /*! @brief Get DVH subset for healthy tissue */ const DVHSetType& getHealthyTissueSet() const { return _dvhHTSet; }; /*! @brief Get DVH subset for whole volume */ 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 getHealthyTissueVolume(DoseTypeGy aDoseAbsolute) const; /*! @brief Get the target volume irradiated to >= aDoseAbsolute @return Return -1 if DVH of _dvhTVSet init() failed */ 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/core/rttbDoseAccessorGeneratorInterface.h b/code/core/rttbDoseAccessorGeneratorInterface.h index 01723e5..e059744 100644 --- a/code/core/rttbDoseAccessorGeneratorInterface.h +++ b/code/core/rttbDoseAccessorGeneratorInterface.h @@ -1,61 +1,61 @@ // ----------------------------------------------------------------------- // 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_ACCESSOR_GENERATOR_INTERFACE_H #define __DOSE_ACCESSOR_GENERATOR_INTERFACE_H #include "rttbDoseAccessorInterface.h" namespace rttb { namespace core { /*! @class DoseAccessorGeneratorInterface @brief Interface for all Dose Accessor generating classes */ class DoseAccessorGeneratorInterface { public: - typedef core::AccessorInterface::AccessorPointer DoseAccessorPointer; + using DoseAccessorPointer = core::AccessorInterface::AccessorPointer; private: DoseAccessorGeneratorInterface(const DoseAccessorGeneratorInterface&); //not implemented on purpose -> non-copyable DoseAccessorGeneratorInterface& operator=(const DoseAccessorGeneratorInterface&);//not implemented on purpose -> non-copyable protected: DoseAccessorGeneratorInterface() = default; virtual ~DoseAccessorGeneratorInterface() = default; public: /*! @brief Generate DoseAccessor @return Return shared pointer of DoseAccessor. */ virtual DoseAccessorPointer generateDoseAccessor() = 0; }; } } #endif diff --git a/code/core/rttbDoseAccessorInterface.h b/code/core/rttbDoseAccessorInterface.h index da5c37c..4ae053b 100644 --- a/code/core/rttbDoseAccessorInterface.h +++ b/code/core/rttbDoseAccessorInterface.h @@ -1,34 +1,34 @@ // ----------------------------------------------------------------------- // 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_ACCESSOR_INTERFACE_NEW_H #define __DOSE_ACCESSOR_INTERFACE_NEW_H #include "rttbAccessorInterface.h" namespace rttb { namespace core { - typedef AccessorInterface DoseAccessorInterface; + using DoseAccessorInterface = rttb::core::AccessorInterface; } } #endif diff --git a/code/core/rttbDoseIteratorInterface.h b/code/core/rttbDoseIteratorInterface.h index 3ae05a6..23bcb18 100644 --- a/code/core/rttbDoseIteratorInterface.h +++ b/code/core/rttbDoseIteratorInterface.h @@ -1,97 +1,97 @@ // ----------------------------------------------------------------------- // 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_ITERATOR_INTERFACE_NEW_H #define __DOSE_ITERATOR_INTERFACE_NEW_H #include #include "rttbBaseType.h" #include "rttbDoseAccessorInterface.h" namespace rttb { namespace core { class GeometricInfo; /*! @class DoseIteratorInterface @brief This class represents the dose iterator interface. */ class DoseIteratorInterface { public: - typedef boost::shared_ptr DoseAccessorPointer; - typedef boost::shared_ptr DoseIteratorPointer; + using DoseAccessorPointer = boost::shared_ptr; + using DoseIteratorPointer = boost::shared_ptr; private: DoseIteratorInterface(const DoseIteratorInterface&); //not implemented on purpose -> non-copyable DoseIteratorInterface& operator=(const DoseIteratorInterface&);//not implemented on purpose -> non-copyable DoseIteratorInterface() = default; protected: /*! @brief DoseAccessor to get access to actual dose data */ DoseAccessorPointer _spDoseAccessor; public: /*! @brief Constructor with a DoseIterator this should be the default for all implementations. */ DoseIteratorInterface(DoseAccessorPointer aDoseAccessor); virtual ~DoseIteratorInterface() = default; /*! @brief Set the iterator to the start of the dose. */ virtual bool reset() = 0; /*! @brief Move to next position. If this position is valid is not necessarily tested. */ virtual void next() = 0; virtual bool isPositionValid() const = 0; /*! @brief Return volume of one voxel (in cm3)*/ //previously getDeltaV() virtual DoseVoxelVolumeType getCurrentVoxelVolume() const = 0; virtual DoseTypeGy getCurrentDoseValue() const = 0; /*! @return If this is a masked dose iterator, return the voxel proportion inside a given structure, value 0~1; Otherwise, 1 */ virtual FractionType getCurrentRelevantVolumeFraction() const = 0; virtual VoxelGridID getCurrentVoxelGridID() const = 0; virtual IDType getVoxelizationID() const { return ""; }; IDType getDoseUID() const { return _spDoseAccessor->getUID(); }; }; //end class }//end: namespace core }//end: namespace rttb #endif diff --git a/code/core/rttbGenericDoseIterator.h b/code/core/rttbGenericDoseIterator.h index a649c5d..0f6d446 100644 --- a/code/core/rttbGenericDoseIterator.h +++ b/code/core/rttbGenericDoseIterator.h @@ -1,102 +1,102 @@ // ----------------------------------------------------------------------- // 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 __GENERIC_DOSE_ITERATOR_INTERFACE_NEW_H #define __GENERIC_DOSE_ITERATOR_INTERFACE_NEW_H #include #include #include #include "rttbBaseType.h" #include "rttbDoseIteratorInterface.h" #include "RTTBCoreExports.h" namespace rttb { namespace core { /*! @class GenericDoseIterator @brief Standard implementation of the dose iterator interface. */ class RTTBCore_EXPORT GenericDoseIterator : public DoseIteratorInterface { public: - typedef DoseIteratorInterface::DoseAccessorPointer DoseAccessorPointer; - typedef DoseIteratorInterface::DoseIteratorPointer DoseIteratorPointer; + using DoseAccessorPointer = DoseIteratorInterface::DoseAccessorPointer; + using DoseIteratorPointer = DoseIteratorInterface::DoseIteratorPointer; private: VoxelGridID _currentDoseVoxelGridID; DoseVoxelVolumeType _currentVoxelVolume; GenericDoseIterator(const GenericDoseIterator&); //not implemented on purpose -> non-copyable GenericDoseIterator& operator=(const GenericDoseIterator&);//not implemented on purpose -> non-copyable public: /*! @brief Constructor @param aDoseAccessor contains the corresponding dose data */ GenericDoseIterator(DoseAccessorPointer aDoseAccessor); /*! @brief Set the itterator to the start of the Dose. @exception InvalidParameterException if a inhomogeneous grid is defined in the dose accessors, because these grids are currently not supported. */ bool reset() override; /*! @brief Test if next voxel position is still on the data grid, if so move to next position. */ void next() override; /*! @brief Determine if the current voxel position is valid. */ bool isPositionValid() const override; /*! @brief Return volume of one voxel (in cm3) @exception InvalidParameterException if a inhomogeneous grid is defined in the dose accessors, because these grids are currently not supported. */ DoseVoxelVolumeType getCurrentVoxelVolume() const override; DoseTypeGy getCurrentDoseValue() const override; /*! @brief For DoseIterators this function returns 1, always, because no mask is applied. */ inline FractionType getCurrentRelevantVolumeFraction() const override { return 1; }; inline VoxelGridID getCurrentVoxelGridID() const override { return _currentDoseVoxelGridID; }; }; } } #endif diff --git a/code/core/rttbGenericMaskedDoseIterator.h b/code/core/rttbGenericMaskedDoseIterator.h index a6c6743..78a9939 100644 --- a/code/core/rttbGenericMaskedDoseIterator.h +++ b/code/core/rttbGenericMaskedDoseIterator.h @@ -1,106 +1,106 @@ // ----------------------------------------------------------------------- // 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 __GENERIC_MASKED_DOSE_ITERATOR_NEW_H #define __GENERIC_MASKED_DOSE_ITERATOR_NEW_H #include #include "rttbBaseType.h" #include "rttbMaskedDoseIteratorInterface.h" #include "rttbMaskAccessorInterface.h" #include "RTTBCoreExports.h" namespace rttb { namespace core { /*! @class GenericMaskedDoseIterator @brief This is a templated class representing a generic masked dose iterator for a VoxelizationPolicy. @see testing/GenericMaskedDoseIteratorTest.cpp for more information. */ class RTTBCore_EXPORT GenericMaskedDoseIterator : public MaskedDoseIteratorInterface { public: - typedef MaskAccessorInterface::MaskVoxelListPointer MaskVoxelListPointer; - typedef MaskAccessorInterface::MaskVoxelList MaskVoxelList; - typedef MaskedDoseIteratorInterface::MaskAccessorPointer MaskAccessorPointer; - typedef MaskedDoseIteratorInterface::DoseAccessorPointer DoseAccessorPointer; + using MaskVoxelListPointer = MaskAccessorInterface::MaskVoxelListPointer; + using MaskVoxelList = MaskAccessorInterface::MaskVoxelList; + using MaskAccessorPointer = MaskedDoseIteratorInterface::MaskAccessorPointer; + using DoseAccessorPointer = MaskedDoseIteratorInterface::DoseAccessorPointer; private: - typedef MaskVoxelList::const_iterator MaskVoxelListIterator; + using MaskVoxelListIterator = MaskVoxelList::const_iterator; /*! The current index position of the vector _maskVoxelVec*/ MaskVoxelListIterator _currentMaskPos; /*! vector of MaskVoxel, as defined in the voxelization*/ MaskVoxelListPointer _maskVoxelVec; /*! the volume in cm^3 of the current dose voxel*/ DoseVoxelVolumeType _currentVoxelVolume; public: GenericMaskedDoseIterator(MaskAccessorPointer aSpMask, DoseAccessorPointer aDoseAccessor) : MaskedDoseIteratorInterface(aSpMask, aDoseAccessor) {}; /*! @brief Set the position on the first index. Use also as initialization. */ bool reset() override; /*! move to next mask position. The validity of the position is not checked here. */ void next() override; /*! @brief Volume of one voxel (in cm3) @exception InvalidParameterException if a inhomogeneous grid is defined in the dose accessors, because these grids are currently not supported. */ DoseVoxelVolumeType getCurrentVoxelVolume() const override; FractionType getCurrentRelevantVolumeFraction() const override; inline MaskVoxelListPointer getMaskVoxelVec() const { return _maskVoxelVec; }; /*! Check first if the position inside the maskedVoxelVector is valid. If so, check if the gridID at the current position in the MaskedVoxelVector is valid in the dose and mask grid. */ bool isPositionValid() const override; /*! @brief get current VoxelGridID (on dose voxel grid)*/ VoxelGridID getCurrentVoxelGridID() const override; /*! @return current dose value multiplied by current volume fraction*/ DoseTypeGy getCurrentMaskedDoseValue() const override; /*! @return current dose value without masking*/ DoseTypeGy getCurrentDoseValue() const override; }; } } #endif diff --git a/code/core/rttbGeometricInfo.cpp b/code/core/rttbGeometricInfo.cpp index 6878e61..e402699 100644 --- a/code/core/rttbGeometricInfo.cpp +++ b/code/core/rttbGeometricInfo.cpp @@ -1,310 +1,310 @@ // ----------------------------------------------------------------------- // 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 "rttbGeometricInfo.h" #include #include #include namespace rttb { namespace core { void GeometricInfo::setSpacing(const SpacingVectorType3D& aSpacingVector) { _spacing = aSpacingVector; } const SpacingVectorType3D& GeometricInfo::getSpacing() const { return _spacing; } void GeometricInfo::setImagePositionPatient(const WorldCoordinate3D& aImagePositionPatient) { _imagePositionPatient = aImagePositionPatient; } const WorldCoordinate3D& GeometricInfo::getImagePositionPatient() const { return _imagePositionPatient; } void GeometricInfo::setOrientationMatrix(const OrientationMatrix& anOrientationMatrix) { _orientationMatrix = anOrientationMatrix; computeInvertOrientation(); } bool GeometricInfo::computeInvertOrientation() { - typedef boost::numeric::ublas::permutation_matrix pmatrix; + using pmatrix = boost::numeric::ublas::permutation_matrix; boost::numeric::ublas::matrix A(_orientationMatrix); // create a permutation matrix for the LU-factorization pmatrix pm(A.size1()); size_t res = boost::numeric::ublas::lu_factorize(A, pm); if (res != 0) { return false; } _invertedOrientationMatrix.assign(boost::numeric::ublas::identity_matrix (A.size1())); // backsubstitute to get the inverse boost::numeric::ublas::lu_substitute(A, pm, _invertedOrientationMatrix); return true; } void GeometricInfo::setImageSize(const ImageSize& aSize) { setNumColumns(aSize(0)); setNumRows(aSize(1)); setNumSlices(aSize(2)); } const ImageSize GeometricInfo::getImageSize() const { return ImageSize(static_cast(getNumColumns()), static_cast(getNumRows()), static_cast(getNumSlices())); } void GeometricInfo::setNumColumns(const VoxelGridDimensionType aValue) { _numberOfColumns = aValue; } const VoxelGridDimensionType GeometricInfo::getNumColumns() const { return _numberOfColumns; } void GeometricInfo::setNumRows(const VoxelGridDimensionType aValue) { _numberOfRows = aValue; } const VoxelGridDimensionType GeometricInfo::getNumRows() const { return _numberOfRows; } void GeometricInfo::setNumSlices(const VoxelGridDimensionType aValue) { _numberOfFrames = aValue; } const VoxelGridDimensionType GeometricInfo::getNumSlices() const { return _numberOfFrames; } bool operator==(const GeometricInfo& gInfo, const GeometricInfo& gInfo1) { return (gInfo.getImagePositionPatient() == gInfo1.getImagePositionPatient() && gInfo.getOrientationMatrix() == gInfo1.getOrientationMatrix() && gInfo.getSpacing() == gInfo1.getSpacing() && gInfo.getNumColumns() == gInfo1.getNumColumns() && gInfo.getNumRows() == gInfo1.getNumRows() && gInfo.getNumSlices() == gInfo1.getNumSlices()); } bool GeometricInfo::equalsAlmost(const GeometricInfo& another, double errorConstantGI /*= 1e-5*/) const { return (getImagePositionPatient().equalsAlmost(another.getImagePositionPatient(), errorConstantGI) && getOrientationMatrix().equalsAlmost(another.getOrientationMatrix(), errorConstantGI) && getSpacing().equalsAlmost(another.getSpacing(), errorConstantGI) && getNumColumns() == another.getNumColumns() && getNumRows() == another.getNumRows() && getNumSlices() == another.getNumSlices()); } bool GeometricInfo::worldCoordinateToGeometryCoordinate(const WorldCoordinate3D& aWorldCoordinate, DoubleVoxelGridIndex3D& aIndex) const { WorldCoordinate3D distanceToIP; distanceToIP = aWorldCoordinate - _imagePositionPatient; boost::numeric::ublas::vector result = boost::numeric::ublas::prod( _invertedOrientationMatrix, distanceToIP); boost::numeric::ublas::vector resultS = boost::numeric::ublas::element_div(result, _spacing); aIndex = DoubleVoxelGridIndex3D(resultS(0), resultS(1), resultS(2)); //if we convert DoubleVoxelGridIndex3D (double) to VoxelGridIndex3D (unsigned int), we can't find out if it's negative. //So we have to check before. if (aIndex(0) < -0.5 || aIndex(1) < -0.5 || aIndex(2) < -0.5){ return false; } else { //check if it is inside VoxelGridIndex3D indexInt = VoxelGridIndex3D(GridIndexType(aIndex(0) + 0.5), GridIndexType(aIndex(1) + 0.5), GridIndexType(aIndex(2) + 0.5)); return isInside(indexInt); } } bool GeometricInfo::worldCoordinateToIndex(const WorldCoordinate3D& aWorldCoordinate, VoxelGridIndex3D& aIndex) const { DoubleVoxelGridIndex3D doubleIndex; bool inside = worldCoordinateToGeometryCoordinate(aWorldCoordinate, doubleIndex); aIndex = VoxelGridIndex3D(GridIndexType(doubleIndex(0)+0.5), GridIndexType(doubleIndex(1)+0.5), GridIndexType(doubleIndex(2)+0.5)); return inside; } bool GeometricInfo::geometryCoordinateToWorldCoordinate(const DoubleVoxelGridIndex3D& aIndex, WorldCoordinate3D& aWorldCoordinate) const { boost::numeric::ublas::vector resultS = boost::numeric::ublas::element_prod( aIndex, _spacing); boost::numeric::ublas::vector result = boost::numeric::ublas::prod( _orientationMatrix, resultS); aWorldCoordinate = result + _imagePositionPatient; //if we convert DoubleVoxelGridIndex3D (double) to VoxelGridIndex3D (unsigned int), we can't find out if it's negative. //So we have to check before. if (aIndex(0) < -0.5 || aIndex(1) < -0.5 || aIndex(2) < -0.5){ return false; } else { VoxelGridIndex3D indexInt = VoxelGridIndex3D(GridIndexType(aIndex(0) + 0.5), GridIndexType(aIndex(1) + 0.5), GridIndexType(aIndex(2) + 0.5)); return isInside(indexInt); } } bool GeometricInfo::indexToWorldCoordinate(const VoxelGridIndex3D& aIndex, WorldCoordinate3D& aWorldCoordinate) const { DoubleVoxelGridIndex3D indexDouble = DoubleVoxelGridIndex3D(aIndex(0), aIndex(1), aIndex(2)); return geometryCoordinateToWorldCoordinate(indexDouble, aWorldCoordinate); } bool GeometricInfo::isInside(const VoxelGridIndex3D& aIndex) const { return (aIndex(0) >= 0 && aIndex(1) >= 0 && aIndex(2) >= 0 && aIndex(0) < static_cast(_numberOfColumns) && aIndex(1) < static_cast(_numberOfRows) && aIndex(2) < static_cast(_numberOfFrames)); } bool GeometricInfo::isInside(const WorldCoordinate3D& aWorldCoordinate) const { VoxelGridIndex3D currentIndex; return (worldCoordinateToIndex(aWorldCoordinate, currentIndex)); } const GridSizeType GeometricInfo::getNumberOfVoxels() const { auto nVoxels = static_cast(_numberOfRows * _numberOfColumns * _numberOfFrames); return nVoxels; } bool GeometricInfo::convert(const VoxelGridID& gridID, VoxelGridIndex3D& gridIndex) const { if (validID(gridID)) { gridIndex(0) = gridID % getNumColumns(); VoxelGridID tempID = (gridID - gridIndex.x()) / getNumColumns(); gridIndex(1) = tempID % getNumRows(); gridIndex(2) = (tempID - gridIndex.y()) / getNumRows(); return true; } return false; } bool GeometricInfo::convert(const VoxelGridIndex3D& gridIndex, VoxelGridID& gridID) const { if ((gridIndex.x() >= static_cast(getNumColumns())) || (gridIndex.y() >= static_cast(getNumRows())) || (gridIndex.z() >= static_cast(getNumSlices()))) { return false; } else { gridID = gridIndex.z() * getNumColumns() * getNumRows() + gridIndex.y() * getNumColumns() + gridIndex.x(); return validID(gridID); } } bool GeometricInfo::validID(const VoxelGridID aID) const { return (aID >= 0 && aID < getNumberOfVoxels()); } bool GeometricInfo::validIndex(const VoxelGridIndex3D& aIndex) const { VoxelGridID aID; if (!convert(aIndex, aID)) { return false; } else { return validID(aID); } } std::ostream& operator<<(std::ostream& s, const GeometricInfo& anGeometricInfo) { s << "[ " << anGeometricInfo.getImagePositionPatient() << "; " << anGeometricInfo.getOrientationMatrix() << "; " << anGeometricInfo.getSpacing() << "; " << "; " << anGeometricInfo.getNumColumns() << "; " << anGeometricInfo.getNumRows() << "; " << anGeometricInfo.getNumSlices() << " ]"; return s; } }//end namespace core }//end namespace rttb diff --git a/code/core/rttbMaskAccessorGeneratorBase.h b/code/core/rttbMaskAccessorGeneratorBase.h index ca1ddfb..5a6477f 100644 --- a/code/core/rttbMaskAccessorGeneratorBase.h +++ b/code/core/rttbMaskAccessorGeneratorBase.h @@ -1,54 +1,54 @@ // ----------------------------------------------------------------------- // 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 __MASK_ACCESSOR_GENERATOR_BASE_H #define __MASK_ACCESSOR_GENERATOR_BASE_H #include "rttbMaskAccessorGeneratorInterface.h" namespace rttb { namespace core { /*! @class MaskAccessorGeneratorBase @brief Abstract class for all DoseAccessor generating classes */ class MaskAccessorGeneratorBase: public MaskAccessorGeneratorInterface { public: - typedef core::MaskAccessorInterface::MaskAccessorPointer MaskAccessorPointer; + using MaskAccessorPointer = core::MaskAccessorInterface::MaskAccessorPointer; private: protected: /*! @brief Mask accessor which should be generated */ MaskAccessorPointer _maskAccessor; public: }; } } #endif diff --git a/code/core/rttbMaskAccessorGeneratorInterface.h b/code/core/rttbMaskAccessorGeneratorInterface.h index 3f22c4d..95119da 100644 --- a/code/core/rttbMaskAccessorGeneratorInterface.h +++ b/code/core/rttbMaskAccessorGeneratorInterface.h @@ -1,62 +1,62 @@ // ----------------------------------------------------------------------- // 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 __MASK_ACCESSOR_GENERATOR_INTERFACE_H #define __MASK_ACCESSOR_GENERATOR_INTERFACE_H #include "rttbMaskAccessorInterface.h" namespace rttb { namespace core { /*! @class MaskAccessorGeneratorInterface @brief Interface for all MaskAccessor generating classes */ class MaskAccessorGeneratorInterface { public: - typedef core::MaskAccessorInterface::MaskAccessorPointer MaskAccessorPointer; + using MaskAccessorPointer = core::MaskAccessorInterface::MaskAccessorPointer; private: MaskAccessorGeneratorInterface(const MaskAccessorGeneratorInterface&); //not implemented on purpose -> non-copyable MaskAccessorGeneratorInterface& operator=(const MaskAccessorGeneratorInterface&);//not implemented on purpose -> non-copyable protected: MaskAccessorGeneratorInterface() = default; virtual ~MaskAccessorGeneratorInterface() = default; public: /*! @brief Generate MaskAccessor @return Return shared pointer of MaskAccessor. */ virtual MaskAccessorPointer generateMaskAccessor() = 0; }; } } #endif diff --git a/code/core/rttbMaskAccessorInterface.h b/code/core/rttbMaskAccessorInterface.h index 89ff46f..2d5c470 100644 --- a/code/core/rttbMaskAccessorInterface.h +++ b/code/core/rttbMaskAccessorInterface.h @@ -1,103 +1,103 @@ // ----------------------------------------------------------------------- // 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 __MASK_ACCESSOR_INTERFACE_NEW_H #define __MASK_ACCESSOR_INTERFACE_NEW_H #include #include "rttbBaseType.h" #include "rttbMaskVoxel.h" #include "rttbIndexConversionInterface.h" namespace rttb { namespace core { class GeometricInfo; /*! @class MaskAccessorInterface @brief This class triggers the voxelization and gives acess to the masked voxels. */ class MaskAccessorInterface: public IndexConversionInterface { public: - typedef std::vector MaskVoxelList; - typedef boost::shared_ptr MaskVoxelListPointer; - typedef boost::shared_ptr MaskAccessorPointer; + using MaskVoxelList = std::vector; + using MaskVoxelListPointer = boost::shared_ptr; + using MaskAccessorPointer = boost::shared_ptr; private: MaskAccessorInterface(const MaskAccessorInterface&); //not implemented on purpose -> non-copyable MaskAccessorInterface& operator=(const MaskAccessorInterface&);//not implemented on purpose -> non-copyable public: MaskAccessorInterface() = default; ~MaskAccessorInterface() override = default; /*! @brief Start generation of mask @post mask is valid and acessible */ virtual void updateMask() = 0; virtual const GeometricInfo& getGeometricInfo() const = 0; /*! @brief Get vector containing all relevant voxels that are inside the given structure. */ virtual MaskVoxelListPointer getRelevantVoxelVector() = 0; /*! @brief get vector containing all relevant voxels that have a relevant volume above the given threshold and are inside the given structure @pre updateMask should have been called (at least once, to ensure a valid mask). */ virtual MaskVoxelListPointer getRelevantVoxelVector(float lowerThreshold) = 0; /*! @brief Get masked voxel value corresponding to a given VoxelGridID. @post after a valid call voxel contains the mask information corresponding to aID. If aID is not valid, voxel values are undefined. @return Indicates if a MaskVoxel for the given ID exists and therefore if parameter voxel containes valid values. @pre updateMask should have been called (at least once, to ensure a valid mask). */ virtual bool getMaskAt(const VoxelGridID aID, MaskVoxel& voxel) const = 0; /*! @brief Get masked voxel value corresponding to a given VoxelGridIndex. @post after a valid call voxel contains the mask information corresponding to gridIndex. If gridIndex is not valid, voxel values are undefined. @return Indicates if a MaskVoxel for the given index exists and therefore if parameter voxel containes valid values. @pre updateMask should have been called (at least once, to ensure a valid mask). */ virtual bool getMaskAt(const VoxelGridIndex3D& gridIndex, MaskVoxel& voxel) const = 0; /* @brief Is true if dose is on a homogeneous grid. @note Inhomogeneous grids are not supported at the moment, but if they will be supported in the future the interface does not need to change. */ virtual bool isGridHomogeneous() const { return true; } virtual IDType getMaskUID() const = 0; }; } } #endif diff --git a/code/core/rttbMaskAccessorProcessorBase.h b/code/core/rttbMaskAccessorProcessorBase.h index b588a0e..2485b89 100644 --- a/code/core/rttbMaskAccessorProcessorBase.h +++ b/code/core/rttbMaskAccessorProcessorBase.h @@ -1,59 +1,59 @@ // ----------------------------------------------------------------------- // 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 __MASK_ACCESSOR_PROCESSOR_BASE_H #define __MASK_ACCESSOR_PROCESSOR_BASE_H #include "rttbMaskAccessorProcessorInterface.h" namespace rttb { namespace core { /*! @class MaskAccessorProcessorBase @brief Abstract class for all MaskAccessor converter classes */ class MaskAccessorProcessorBase: public MaskAccessorProcessorInterface { public: - typedef core::MaskAccessorInterface::MaskAccessorPointer MaskAccessorPointer; + using MaskAccessorPointer = core::MaskAccessorInterface::MaskAccessorPointer; void setMaskAccessor(MaskAccessorPointer accessor) override { _maskAccessor = accessor; }; private: MaskAccessorProcessorBase(const MaskAccessorProcessorBase&); //not implemented on purpose -> non-copyable MaskAccessorProcessorBase& operator=(const MaskAccessorProcessorBase&);//not implemented on purpose -> non-copyable protected: MaskAccessorProcessorBase() = default; ~MaskAccessorProcessorBase() override = default; /*! @brief Mask accessor which should be generated */ MaskAccessorPointer _maskAccessor; }; } } #endif diff --git a/code/core/rttbMaskAccessorProcessorInterface.h b/code/core/rttbMaskAccessorProcessorInterface.h index aed9ca5..fef97a4 100644 --- a/code/core/rttbMaskAccessorProcessorInterface.h +++ b/code/core/rttbMaskAccessorProcessorInterface.h @@ -1,65 +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 __MASK_ACCESSOR_PROCESSOR_INTERFACE_H #define __MASK_ACCESSOR_PROCESSOR_INTERFACE_H #include "rttbMaskAccessorInterface.h" namespace rttb { namespace core { /*! @class MaskAccessorProcessorInterface @brief Interface for all MaskAccessor converter classes */ class MaskAccessorProcessorInterface { public: - typedef core::MaskAccessorInterface::MaskAccessorPointer MaskAccessorPointer; + using MaskAccessorPointer = core::MaskAccessorInterface::MaskAccessorPointer; private: MaskAccessorProcessorInterface(const MaskAccessorProcessorInterface&); //not implemented on purpose -> non-copyable MaskAccessorProcessorInterface& operator=(const MaskAccessorProcessorInterface&);//not implemented on purpose -> non-copyable protected: MaskAccessorProcessorInterface() = default; virtual ~MaskAccessorProcessorInterface() = default; public: /*! @brief Sets the MaskAccessor that should be processed @pre passed accessor must point to a valid instance. */ virtual void setMaskAccessor(MaskAccessorPointer accessor) = 0; /*! @brief Process the passed MaskAccessor @return if the processing was successful. */ virtual bool process() = 0; }; } } #endif diff --git a/code/core/rttbMaskedDoseIteratorInterface.h b/code/core/rttbMaskedDoseIteratorInterface.h index 8dff525..ff285c5 100644 --- a/code/core/rttbMaskedDoseIteratorInterface.h +++ b/code/core/rttbMaskedDoseIteratorInterface.h @@ -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) */ #ifndef __MASKED_DOSE_ITERATOR_INTERFACE_NEW_H #define __MASKED_DOSE_ITERATOR_INTERFACE_NEW_H #include #include "rttbDoseIteratorInterface.h" #include "RTTBCoreExports.h" namespace rttb { namespace core { class MaskAccessorInterface; /*! @class MaskedDoseIteratorInterface @brief Give access to masked dose data. */ class RTTBCore_EXPORT MaskedDoseIteratorInterface : public DoseIteratorInterface { public: - typedef boost::shared_ptr MaskAccessorPointer; - typedef DoseIteratorInterface::DoseAccessorPointer DoseAccessorPointer; - typedef DoseIteratorInterface::DoseIteratorPointer DoseIteratorPointer; - typedef boost::shared_ptr MaskedDoseIteratorPointer; + using MaskAccessorPointer = boost::shared_ptr; + using DoseAccessorPointer = DoseIteratorInterface::DoseAccessorPointer; + using DoseIteratorPointer = DoseIteratorInterface::DoseIteratorPointer; + using MaskedDoseIteratorPointer = boost::shared_ptr; private: MaskedDoseIteratorInterface(const MaskedDoseIteratorInterface&); MaskedDoseIteratorInterface& operator=(const MaskedDoseIteratorInterface&); protected: /*! @brief Mask that is to be applied to currently loaded dose*/ MaskAccessorPointer _spMask; public: /* Constructor @pre core::GeometricInfo represents the same geometric space for both mask and dose, i.e. both live on the same data grid. Both accessors need to be valid. */ MaskedDoseIteratorInterface(MaskAccessorPointer aMaskAccessor, DoseAccessorPointer aDoseAccessor); ~MaskedDoseIteratorInterface() override = default; inline MaskAccessorPointer getMaskAccessor() const { return _spMask; }; /* Return doseValue*voxelFraction for the current position */ virtual DoseTypeGy getCurrentMaskedDoseValue() const = 0; }; } } #endif \ No newline at end of file diff --git a/code/core/rttbMutableDoseAccessorInterface.h b/code/core/rttbMutableDoseAccessorInterface.h index a21f03c..71c75ae 100644 --- a/code/core/rttbMutableDoseAccessorInterface.h +++ b/code/core/rttbMutableDoseAccessorInterface.h @@ -1,49 +1,49 @@ // ----------------------------------------------------------------------- // 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 __MUTABLE_DOSE_ACCESSOR_INTERFACE_NEW_H #define __MUTABLE_DOSE_ACCESSOR_INTERFACE_NEW_H #include "rttbDoseAccessorInterface.h" #include "rttbBaseType.h" namespace rttb { namespace core { /*! @class MutableDoseAccessorInterface @brief Extends the DoseAccessorInterface to provide writing access to the data. */ class MutableDoseAccessorInterface: public DoseAccessorInterface { public: - typedef boost::shared_ptr MutableDoseAccessorPointer; + using MutableDoseAccessorPointer = boost::shared_ptr; virtual void setDoseAt(const VoxelGridID aID, DoseTypeGy value) = 0; virtual void setDoseAt(const VoxelGridIndex3D& aIndex, DoseTypeGy value) = 0; }; } } #endif diff --git a/code/core/rttbMutableMaskAccessorInterface.h b/code/core/rttbMutableMaskAccessorInterface.h index 6cf307d..ec17e37 100644 --- a/code/core/rttbMutableMaskAccessorInterface.h +++ b/code/core/rttbMutableMaskAccessorInterface.h @@ -1,56 +1,56 @@ // ----------------------------------------------------------------------- // 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 __MUTABLE_MASK_ACCESSOR_INTERFACE_H #define __MUTABLE_MASK_ACCESSOR_INTERFACE_H #include #include "rttbMaskAccessorInterface.h" #include "rttbBaseType.h" namespace rttb { namespace core { class MaskVoxel; /*! @class MutableMaskAccessorInterface @brief Extends the MaskAccessorInterface to provide writing access to the data. @details This interface is created for external manipulation of generated masks. For example to store the results of arithmetic operations on other masks. */ class MutableMaskAccessorInterface: public MaskAccessorInterface { public: - typedef boost::shared_ptr MutableMaskAccessorPointer; - typedef core::MaskAccessorInterface::MaskVoxelList MaskVoxelList; - typedef core::MaskAccessorInterface::MaskVoxelListPointer MaskVoxelListPointer; + using MutableMaskAccessorPointer = boost::shared_ptr; + using MaskVoxelList = core::MaskAccessorInterface::MaskVoxelList; + using MaskVoxelListPointer = core::MaskAccessorInterface::MaskVoxelListPointer; virtual void setRelevantVoxelVector(MaskVoxelListPointer aVoxelListPointer) = 0; virtual void setMaskAt(VoxelGridID aID, const MaskVoxel& voxel) = 0; virtual void setMaskAt(const VoxelGridIndex3D& gridIndex, const MaskVoxel& voxel) = 0; }; } } #endif diff --git a/code/core/rttbStrVectorStructureSetGenerator.h b/code/core/rttbStrVectorStructureSetGenerator.h index 375c15a..1319c47 100644 --- a/code/core/rttbStrVectorStructureSetGenerator.h +++ b/code/core/rttbStrVectorStructureSetGenerator.h @@ -1,74 +1,74 @@ // ----------------------------------------------------------------------- // 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 __STR_VECTOR_STRUCTURE_SET_GENERATOR_H #define __STR_VECTOR_STRUCTURE_SET_GENERATOR_H #include #include #include "rttbStructureSetGeneratorInterface.h" #include "rttbStructureSet.h" #include "RTTBCoreExports.h" namespace rttb { namespace core { /*! @class StrVectorStructureSetGenerator @brief Generate a structure set with a vector of Structures. */ class RTTBCore_EXPORT StrVectorStructureSetGenerator : public core::StructureSetGeneratorInterface { public: - typedef core::StructureSet::StructTypePointer StructTypePointer; + using StructTypePointer = core::StructureSet::StructTypePointer; - typedef StructureSetGeneratorInterface::StructureSetPointer StructureSetPointer; + using StructureSetPointer = StructureSetGeneratorInterface::StructureSetPointer; protected: IDType _patientUID; std::vector _strVector; StrVectorStructureSetGenerator() = default; public: /*! @brief Constructor @param aStructureVector the vector of structure shared pointer @param aPatientUID the patient UID. */ StrVectorStructureSetGenerator(std::vector& aStructureVector, IDType aPatientUID = ""); /*! @brief Generate StructureSet @return Return shared pointer of StructureSet. */ StructureSetPointer generateStructureSet() override; }; } } #endif diff --git a/code/core/rttbStructure.h b/code/core/rttbStructure.h index f8932bb..dbb78b4 100644 --- a/code/core/rttbStructure.h +++ b/code/core/rttbStructure.h @@ -1,109 +1,109 @@ // ----------------------------------------------------------------------- // 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) */ /* Changes in Architecture: This class should be universally used independent of the origin of the Structures. All UID references are omitted. */ #ifndef __STRUCTURE_H #define __STRUCTURE_H #include #include #include #include "rttbBaseType.h" #include "RTTBCoreExports.h" namespace rttb { namespace core { /*! @class Structure @brief This is a class representing a RT Structure */ class RTTBCore_EXPORT Structure { public: - typedef boost::shared_ptr StructTypePointer; + using StructTypePointer = boost::shared_ptr; private: /*! @brief WorldCoordinate3D in mm */ PolygonSequenceType _structureVector; /*! @brief Contour Geometric Type using DICOM-RT definition (3006,0042). * POINT: indicates that the contour is a single point, defining a specific location of significance. * OPEN_PLANAR: indicates that the last vertex shall not be connected to the first point, and that all points * in Contour Data (3006,0050) shall be coplanar. * OPEN_NONPLANAR: indicates that the last vertex shall not be connected to the first point, and that the points * in Contour Data(3006,0050) may be non-coplanar. * CLOSED_PLANAR: indicates that the last point shall be connected to the first point, where the first point is * not repeated in the Contour Data. All points in Contour Data (3006,0050) shall be coplanar. */ std::vector _contourGeometricTypeVector; /*! @brief Structure UID*/ IDType _strUID; /*! @brief Structure Label*/ StructureLabel _label; public: /*! @brief Structure Standard Constructor uid will be randomly generated using boost::uuid library at first. To change the uid using setUID(). */ Structure(); /*! @brief Structure Constructor uid will be randomly generated using boost::uuid library at first. To change the uid using setUID(). */ Structure(PolygonSequenceType strVector); Structure(const Structure& copy); ~Structure(); const PolygonSequenceType& getStructureVector() const; /*! @brief Get the number of end points (points that define the polygon) of all contours of the structure. */ int getNumberOfEndpoints() const; IDType getUID() const; void setUID(const IDType& aUID); void setLabel(const StructureLabel& aLabel); StructureLabel getLabel() const; }; }//end namespace core }//end namespace rttb #endif diff --git a/code/core/rttbStructureSet.h b/code/core/rttbStructureSet.h index 7556458..4e60e7b 100644 --- a/code/core/rttbStructureSet.h +++ b/code/core/rttbStructureSet.h @@ -1,85 +1,85 @@ // ----------------------------------------------------------------------- // 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 __STRUCTURE_SET_H #define __STRUCTURE_SET_H #include #include #include "rttbBaseType.h" #include "rttbStructure.h" #include "RTTBCoreExports.h" namespace rttb { namespace core { /*! @class StructureSet @brief This is an class representing a structure set, which can be used to generate masks. */ class RTTBCore_EXPORT StructureSet { public: - typedef Structure::StructTypePointer StructTypePointer; - typedef size_t NumberOfStructuresType; + using StructTypePointer = Structure::StructTypePointer; + using NumberOfStructuresType = size_t; protected: std::vector _structureSetVector; IDType _UID; IDType _patientUID; public: virtual ~StructureSet() = default; /*! @brief Constructor @param aPatientUID the patient UID. @param aUID the structure set UID. If it is empty, it will be calculated in the constructor */ StructureSet(const std::vector& aStructureVector, IDType aPatientUID = "", IDType aUID = ""); /*! @brief Get the Structure with the index aStructureNo @return Return Structure pointer. @exception InvalidParameterException Thrown if structureNo not between 0 and number of structures of structureSet. */ StructTypePointer getStructure(size_t aStructureNo) const; /*! @brief Get the number of structures @return Return the number of structures. */ NumberOfStructuresType getNumberOfStructures() const; virtual IDType getUID() const; virtual IDType getPatientUID() const; }; } } #endif diff --git a/code/core/rttbStructureSetGeneratorInterface.h b/code/core/rttbStructureSetGeneratorInterface.h index 9ba7f4b..10e95e4 100644 --- a/code/core/rttbStructureSetGeneratorInterface.h +++ b/code/core/rttbStructureSetGeneratorInterface.h @@ -1,86 +1,86 @@ // ----------------------------------------------------------------------- // RTToolbox - DKFZ radiotherapy quantitative evaluation library // // Copyright (c) German Cancer Research Center (DKFZ), // Software development for Integrated Diagnostics and Therapy (SIDT). // ALL RIGHTS RESERVED. // See rttbCopyright.txt or // http://www.dkfz.de/en/sidt/projects/rttb/copyright.html // // This software is distributed WITHOUT ANY WARRANTY; without even // the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // PURPOSE. See the above copyright notices for more information. // //------------------------------------------------------------------------ /*! // @file // @version $Revision$ (last changed revision) // @date $Date$ (last change date) // @author $Author$ (last changed by) */ #ifndef __STRUCTURE_SET_GENERATOR_INTERFACE_H #define __STRUCTURE_SET_GENERATOR_INTERFACE_H #include namespace rttb { namespace core { class StructureSet; /*! @class StructureSetGeneratorInterface @brief Interface for all structure set generating classes */ class StructureSetGeneratorInterface { public: - typedef boost::shared_ptr StructureSetPointer; + using StructureSetPointer = boost::shared_ptr; private: StructureSetGeneratorInterface(const StructureSetGeneratorInterface&); //not implemented on purpose -> non-copyable StructureSetGeneratorInterface& operator=(const StructureSetGeneratorInterface&);//not implemented on purpose -> non-copyable protected: StructureSetGeneratorInterface() = default; virtual ~StructureSetGeneratorInterface() = default; private: bool _activeFilter{false}; std::string _filterRegEx; public: void setStructureLabelFilterActive(bool active) { _activeFilter = active; }; bool getStructureLabelFilterActive() const { return _activeFilter; }; void setFilterRegEx(const std::string& filter) { _filterRegEx = filter; }; std::string getFilterRegEx() const { return _filterRegEx; }; /*! @brief Generate StructureSet @return Return shared pointer of StructureSet. */ virtual StructureSetPointer generateStructureSet() = 0; }; } } #endif diff --git a/code/indices/rttbDvhBasedDoseIndex.h b/code/indices/rttbDvhBasedDoseIndex.h index 53aedae..49a9079 100644 --- a/code/indices/rttbDvhBasedDoseIndex.h +++ b/code/indices/rttbDvhBasedDoseIndex.h @@ -1,58 +1,58 @@ // ----------------------------------------------------------------------- // 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_BASED_DOSE_INDEX_H #define __DVH_BASED_DOSE_INDEX_H #include "rttbBaseType.h" #include "rttbDVHSet.h" #include "rttbDoseIndex.h" #include "RTTBIndicesExports.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 RTTBIndices_EXPORT DvhBasedDoseIndex : public DoseIndex { public: - typedef boost::shared_ptr DVHSetPtr; + using DVHSetPtr = boost::shared_ptr; protected: DVHSetPtr _dvhSet; /*! @brief Check inputs*/ bool checkInputs() override; public: /*! @brief Constructor*/ DvhBasedDoseIndex(DVHSetPtr aDVHSet, DoseTypeGy aDoseReference); }; } } #endif diff --git a/code/interpolation/ITKTransformation/rttbITKTransformation.h b/code/interpolation/ITKTransformation/rttbITKTransformation.h index 8e9fc0c..c2a9f9b 100644 --- a/code/interpolation/ITKTransformation/rttbITKTransformation.h +++ b/code/interpolation/ITKTransformation/rttbITKTransformation.h @@ -1,82 +1,82 @@ // ----------------------------------------------------------------------- // 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 __ITK_MAPPABLE_DOSE_ACCESSOR_H #define __ITK_MAPPABLE_DOSE_ACCESSOR_H #include #include "itkTransform.h" #include "rttbTransformationInterface.h" #include "RTTBInterpolationITKTransformationExports.h" namespace rttb { namespace interpolation { /*! @class ITKTransformation @brief This class can deal with dose information that has to be transformed into another geometry than the original dose image (transformation specified by ITK transformation object). */ class RTTBInterpolationITKTransformation_EXPORT ITKTransformation : public TransformationInterface { public: static const unsigned int InputDimension3D = 3; static const unsigned int OutputDimension3D = 3; - typedef double TransformScalarType; + using TransformScalarType = double; typedef itk::Transform Transform3D3DType; - typedef Transform3D3DType::InputPointType InputPointType; - typedef Transform3D3DType::OutputPointType OutputPointType; - typedef boost::shared_ptr Pointer; + using InputPointType = Transform3D3DType::InputPointType; + using OutputPointType = Transform3D3DType::OutputPointType; + using Pointer = boost::shared_ptr; private: //! Has to be a Pointer type because of inheritance issues with itkSmartPointer (that doesn't recognize the inheritance) const Transform3D3DType* _pTransformation; protected: void convert(const WorldCoordinate3D& aWorldCoordinate, InputPointType& aInputPoint) const; void convert(const OutputPointType& aOutputPoint, WorldCoordinate3D& aWorldCoordinate) const; public: /*! @brief Constructor. @param aTransformation transformation in ITK format. @sa MappableDoseAccessorBase @pre all input parameters have to be valid @exception core::NullPointerException if one input parameter is nullptr @exception core::PaddingException if the transformation is undefined and if _acceptPadding==false */ ITKTransformation(const Transform3D3DType* aTransformation); ~ITKTransformation() override = default; /*! @brief performs a transformation targetImage --> movingImage */ bool transformInverse(const WorldCoordinate3D& worldCoordinateTarget, WorldCoordinate3D& worldCoordinateMoving) const override; /*! @brief performs a transformation movingImage --> targetImage */ bool transform(const WorldCoordinate3D& worldCoordinateMoving, WorldCoordinate3D& worldCoordinateTarget) const override; }; } } #endif diff --git a/code/interpolation/rttbInterpolationBase.h b/code/interpolation/rttbInterpolationBase.h index 19ffe81..4db726c 100644 --- a/code/interpolation/rttbInterpolationBase.h +++ b/code/interpolation/rttbInterpolationBase.h @@ -1,91 +1,91 @@ // ----------------------------------------------------------------------- // 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 __INTERPOLATION_BASE_H #define __INTERPOLATION_BASE_H #include #include #include "rttbAccessorInterface.h" #include "RTTBInterpolationExports.h" namespace rttb { namespace interpolation { /*! @class InterpolationBase @brief Base class for interpolation. @ingroup interpolation */ class RTTBInterpolation_EXPORT InterpolationBase { public: - typedef boost::shared_ptr Pointer; - typedef rttb::core::AccessorInterface::AccessorPointer AccessorPointer; + using Pointer = boost::shared_ptr; + using AccessorPointer = rttb::core::AccessorInterface::AccessorPointer; /*! @brief Constructor */ InterpolationBase() = default; /*! @brief Virtual destructor of base class */ virtual ~InterpolationBase() = default; /*! @brief Sets the AccessorPointer @pre originalData initialized @exception core::NullPointerException if originalData==nullptr */ void setAccessorPointer(const AccessorPointer originalData); /*! @brief Returns the interpolated value for the given world coordinate */ virtual DoseTypeGy getValue(const WorldCoordinate3D& aWorldCoordinate) const = 0; protected: AccessorPointer _spOriginalData; /*! @brief determines voxels in a certain neighborhood of a physical based coordinate and converts in a standard cube with corner points [0 0 0], [1 0 0], [0 1 0], [1 1 0], [0 0 1], [1 0 1], [0 1 1], [1 1 1]. @param aWorldCoordinate the coordinate where to start @param neighborhood voxel around coordinate (currently only 0 and 8 implemented) @param target coordinates inside the standard cube with values [0 1] in each dimension. @param values dose values at all corner points of the standard cube. Is of type boost:shared_ptr[neighborhood] @pre target and values have to be correctly initialized (e.g. std::array target = {0.0, 0.0, 0.0}; boost::shared_ptr values(new DoseTypeGy[8]()); where 8 is neighborhood) @exception core::InvalidParameterException if neighborhood =! 0 && !=8 @exception core::MappingOutsideOfImageException if initial mapping of aWorldCoordinate is outside image @exception core::NullPointerException if dose is nullptr */ void getNeighborhoodVoxelValues(const WorldCoordinate3D& aWorldCoordinate, unsigned int neighborhood, std::array& target, boost::shared_ptr values) const; /*! @brief returns the nearest inside voxel value @pre the voxelGridIndex is outside the image and voxelGridIndex>image.size() for all dimensions. Also voxelGridIndex[]>=0 for all dimensions @note used for virtually expanding the image by one voxel as edge handling */ DoseTypeGy getNearestInsideVoxelValue(const VoxelGridIndex3D& currentVoxelIndex) const; }; } } #endif diff --git a/code/interpolation/rttbMappableDoseAccessorInterface.h b/code/interpolation/rttbMappableDoseAccessorInterface.h index 011bc40..ec6fc74 100644 --- a/code/interpolation/rttbMappableDoseAccessorInterface.h +++ b/code/interpolation/rttbMappableDoseAccessorInterface.h @@ -1,100 +1,100 @@ // ----------------------------------------------------------------------- // 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 __MAPPABLE_DOSE_ACCESSOR_BASE_H #define __MAPPABLE_DOSE_ACCESSOR_BASE_H #include #include "rttbDoseAccessorInterface.h" #include "rttbGeometricInfo.h" #include "rttbBaseType.h" #include "rttbTransformationInterface.h" #include "rttbNullPointerException.h" namespace rttb { namespace interpolation { /*! @class MappableDoseAccessorInterface @brief Interface for dealing with dose information that has to be transformed into another geometry than the original dose image @details implementation of strategy is done by derived class (e.g. SimpleMappableDoseAccessor or RosuMappableDoseAccessor. Transformation is defined in TransformationInterface @ingroup interpolation */ class MappableDoseAccessorInterface: public core::DoseAccessorInterface { public: - typedef boost::shared_ptr Pointer; + using Pointer = boost::shared_ptr; protected: DoseAccessorPointer _spOriginalDoseDataMovingImage; TransformationInterface::Pointer _spTransformation; core::GeometricInfo _geoInfoTargetImage; bool _acceptPadding; DoseTypeGy _defaultOutsideValue; public: /*! @brief Constructor. @param geoInfoTargetImage target image geometry @param doseMovingImage dose of moving image @param aTransformation the transformation @param acceptPadding is mapping outside the image allowed @param defaultOutsideValue the default outside voxel value if accepptPadding=true @pre all input parameters have to be valid @exception core::NullPointerException if one input parameter is nullptr */ MappableDoseAccessorInterface(const core::GeometricInfo& geoInfoTargetImage, const DoseAccessorPointer doseMovingImage, const TransformationInterface::Pointer aTransformation, bool acceptPadding = true, DoseTypeGy defaultOutsideValue = 0.0): _spOriginalDoseDataMovingImage(doseMovingImage), _spTransformation(aTransformation), _geoInfoTargetImage(geoInfoTargetImage), _acceptPadding(acceptPadding), _defaultOutsideValue(defaultOutsideValue) { //handle null pointers if (doseMovingImage == nullptr || aTransformation == nullptr) { throw core::NullPointerException("Pointers to input accessors/transformation cannot be nullptr."); } } /*! @brief Virtual destructor of base class */ ~MappableDoseAccessorInterface() override = default; inline const core::GeometricInfo& getGeometricInfo() const override { return _geoInfoTargetImage; }; inline GridSizeType getGridSize() const override { return _geoInfoTargetImage.getNumberOfVoxels(); }; const IDType getUID() const override { return _spOriginalDoseDataMovingImage->getUID(); }; }; } } #endif diff --git a/code/interpolation/rttbRosuMappableDoseAccessor.h b/code/interpolation/rttbRosuMappableDoseAccessor.h index e89bba5..ea52d49 100644 --- a/code/interpolation/rttbRosuMappableDoseAccessor.h +++ b/code/interpolation/rttbRosuMappableDoseAccessor.h @@ -1,82 +1,82 @@ // ----------------------------------------------------------------------- // 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 __ROSU_MAPPABLE_DOSE_ACCESSOR_H #define __ROSU_MAPPABLE_DOSE_ACCESSOR_H #include #include "rttbBaseType.h" #include "rttbInterpolationBase.h" #include "rttbMappableDoseAccessorInterface.h" namespace rttb { namespace interpolation { class TransformationInterface; /*! @class RosuMappableDoseAccessor @brief Class for dose mapping based on interpolation described in the Rosu2005 paper @details implementation of the following paper: Rosu, M., Chetty, I. J., Balter, J. M., Kessler, M. L., McShan, D. L., & Ten Haken, R. K. (2005). Dose reconstruction in deforming lung anatomy: Dose grid size effects and clinical implications. Medical Physics, 32(8), 2487. @ingroup interpolation */ class RosuMappableDoseAccessor: public MappableDoseAccessorInterface { private: InterpolationBase::Pointer _spInterpolation; public: - typedef boost::shared_ptr Pointer; - typedef boost::shared_ptr TransformationPointer; + using Pointer = boost::shared_ptr; + using TransformationPointer = boost::shared_ptr; /*! @brief Constructor. Just hands values over to base class constructor. @note no interpolation as parameter since linear interpolation is fixed. @sa MappableDoseAccessorBase */ RosuMappableDoseAccessor(const core::GeometricInfo& geoInfoTargetImage, const DoseAccessorPointer doseMovingImage, const TransformationPointer aTransformation, bool acceptPadding = true, DoseTypeGy defaultOutsideValue = 0.0); /*! @brief Virtual destructor. */ ~RosuMappableDoseAccessor() override = default; GenericValueType getValueAt(const VoxelGridID aID) const override; /*! @brief Returns the dose for a given voxel grid index. The computation of the octant around the voxel is done and the interpolation is performed. @details Boundary treatment: if more than 6 subvoxels are outside: return _defaultOutsideValue. Otherwise: ignore the outside values. @return the dose or if (isOutside==true && _acceptPadding==true) then _defaultValue @exception core::MappingOutsideOfImageException if the point is mapped outside and if _acceptPadding==false, possibly returning _defaultValue) */ GenericValueType getValueAt(const VoxelGridIndex3D& aIndex) const override; private: /*! @brief returns the octant coordinates around a coordinate. @details i.e. coordinate is the center of a virtual voxel. Then, each side is divided into equal parts. The centers of the new subvoxels are then returned. @return a vector of the octant coordinates. */ std::vector getOctants(const WorldCoordinate3D& aCoordinate) const; }; } } #endif diff --git a/code/interpolation/rttbSimpleMappableDoseAccessor.h b/code/interpolation/rttbSimpleMappableDoseAccessor.h index 44035ba..d4f8bc8 100644 --- a/code/interpolation/rttbSimpleMappableDoseAccessor.h +++ b/code/interpolation/rttbSimpleMappableDoseAccessor.h @@ -1,78 +1,78 @@ // ----------------------------------------------------------------------- // 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 __SIMPLE_MAPPABLE_DOSE_ACCESSOR_H #define __SIMPLE_MAPPABLE_DOSE_ACCESSOR_H #include #include #include "rttbInterpolationBase.h" #include "rttbLinearInterpolation.h" #include "rttbTransformationInterface.h" #include "rttbMappableDoseAccessorInterface.h" #include "RTTBInterpolationExports.h" namespace rttb { namespace interpolation { /*! @class SimpleMappableDoseAccessor @brief Class for dose mapping based on simple trilinear interpolation @ingroup interpolation */ class RTTBInterpolation_EXPORT SimpleMappableDoseAccessor : public MappableDoseAccessorInterface { private: InterpolationBase::Pointer _spInterpolation; public: - typedef boost::shared_ptr Pointer; + using Pointer = boost::shared_ptr; /*! @brief Constructor. Just hands values over to base class constructor. @param aInterpolation the used interpolation. @sa MappableDoseAccessorBase */ SimpleMappableDoseAccessor(const core::GeometricInfo& geoInfoTargetImage, const DoseAccessorPointer doseMovingImage, const TransformationInterface::Pointer aTransformation, const InterpolationBase::Pointer aInterpolation = ::boost::make_shared(), bool acceptPadding = true, DoseTypeGy defaultOutsideValue = 0.0); /*! @brief Virtual destructor of class */ ~SimpleMappableDoseAccessor() override = default; /*! @brief Returns the dose for a given voxel grid id. Plain trilinear interpolation is performed. @sa getDoseAt(const VoxelGridIndex3D& aIndex) */ GenericValueType getValueAt(const VoxelGridID aID) const override; /*! @brief Returns the dose for a given voxel grid index. Plain trilinear interpolation is performed. @return the dose or if (isOutside==true && _acceptPadding==true) then _defaultValue @exception core::MappingOutsideOfImageException if the point is mapped outside and if _acceptPadding==false, possibly returning _defaultValue) */ GenericValueType getValueAt(const VoxelGridIndex3D& aIndex) const override; }; } } #endif diff --git a/code/interpolation/rttbTransformationInterface.h b/code/interpolation/rttbTransformationInterface.h index aa18a31..9584d25 100644 --- a/code/interpolation/rttbTransformationInterface.h +++ b/code/interpolation/rttbTransformationInterface.h @@ -1,71 +1,71 @@ // ----------------------------------------------------------------------- // 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 __TRANSFORMATION_INTERFACE_H #define __TRANSFORMATION_INTERFACE_H #include #include "rttbBaseType.h" #include "RTTBInterpolationExports.h" namespace rttb { namespace interpolation { /*! @class TransformationInterface @brief Base class for transformation (in World coordinates). @ingroup interpolation */ class RTTBInterpolation_EXPORT TransformationInterface { public: - typedef boost::shared_ptr Pointer; + using Pointer = boost::shared_ptr; protected: /*! @brief Constructor */ TransformationInterface() = default; /*! @brief Virtual destructor of interface class */ virtual ~TransformationInterface() = default; public: /*! @brief performs a transformation targetImage --> movingImage */ virtual bool transformInverse(const WorldCoordinate3D& worldCoordinateTarget, WorldCoordinate3D& worldCoordinateMoving) const = 0; /*! @brief performs a transformation movingImage --> targetImage */ virtual bool transform(const WorldCoordinate3D& worldCoordinateMoving, WorldCoordinate3D& worldCoordinateTarget) const = 0; private: TransformationInterface(const TransformationInterface&);//not implemented on purpose -> non-copyable TransformationInterface& operator=(const TransformationInterface&);//not implemented on purpose -> non-copyable }; } } #endif diff --git a/code/io/dicom/rttbDicomDoseAccessor.h b/code/io/dicom/rttbDicomDoseAccessor.h index ffd8194..8480d51 100644 --- a/code/io/dicom/rttbDicomDoseAccessor.h +++ b/code/io/dicom/rttbDicomDoseAccessor.h @@ -1,99 +1,99 @@ // ----------------------------------------------------------------------- // 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 __DICOM_DOSE_ACCESSOR_H #define __DICOM_DOSE_ACCESSOR_H #include "dcmtk/config/osconfig.h" /* make sure OS specific configuration is included first */ #include "drtdose.h" #include #include #include #include "rttbAccessorWithGeoInfoBase.h" #include "rttbBaseType.h" namespace rttb { namespace io { namespace dicom { /*! @class DicomDoseAccessor @brief This class gives access to dose information from DRTDoseIOD and DcmItem */ class DicomDoseAccessor: public core::AccessorWithGeoInfoBase { public: - typedef boost::shared_ptr DRTDoseIODPtr; - typedef boost::shared_ptr DcmItemPtr; + using DRTDoseIODPtr = boost::shared_ptr; + using DcmItemPtr = boost::shared_ptr; private: DRTDoseIODPtr _dose; DcmItemPtr _dataSet; /*! vector of dose data(absolute Gy dose/doseGridScaling)*/ std::vector doseData; double _doseGridScaling; IDType _doseUID; DicomDoseAccessor(); protected: /*! @brief Initialize dose data @exception InvalidDoseException Thrown if _dose is invalid: one of column/row/numberOfFrames/doseGridScaling/pixelSpacing=0 @exception DcmrtException Throw if dcmrt error @exception boost/bad_lexical_cast Thrown if the imported header tags are not numerical. */ bool begin(); /*! @brief get all required data from dicom information contained in _dose @exception boost/bad_lexical_cast Thrown if the imported header tags are not numerical. */ bool assembleGeometricInfo(); public: ~DicomDoseAccessor() override; /*! @brief Constructor. Initialisation with a boost::shared_ptr of DRTDoseIOD and of DcmItem to get the pixel data @exception DcmrtException Throw if dcmrt error */ DicomDoseAccessor(DRTDoseIODPtr aDRTDoseIODP, DcmItemPtr aDcmDataset); GenericValueType getValueAt(const VoxelGridID aID) const override; GenericValueType getValueAt(const VoxelGridIndex3D& aIndex) const override; const IDType getUID() const override { return _doseUID; }; }; } } } #endif diff --git a/code/io/dicom/rttbDicomFileDoseAccessorGenerator.h b/code/io/dicom/rttbDicomFileDoseAccessorGenerator.h index 7724cde..3765e5b 100644 --- a/code/io/dicom/rttbDicomFileDoseAccessorGenerator.h +++ b/code/io/dicom/rttbDicomFileDoseAccessorGenerator.h @@ -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) */ #ifndef __DICOM_FILE_DOSE_ACCESSOR_GENERATOR_H #define __DICOM_FILE_DOSE_ACCESSOR_GENERATOR_H #include "dcmtk/config/osconfig.h" /* make sure OS specific configuration is included first */ #include "drtdose.h" #include "rttbDoseAccessorGeneratorBase.h" #include "rttbBaseType.h" namespace rttb { namespace io { namespace dicom { /*! @class DicomFileDoseAccessorGenerator @brief Load dose data from dicom file and generate DicomDoseAccessor. */ class DicomFileDoseAccessorGenerator: public core::DoseAccessorGeneratorBase { public: - typedef boost::shared_ptr DRTDoseIODPtr; - typedef boost::shared_ptr DcmItemPtr; + using DRTDoseIODPtr = boost::shared_ptr; + using DcmItemPtr = boost::shared_ptr; private: FileNameType _dicomDoseFileName; DicomFileDoseAccessorGenerator(); protected: public: ~DicomFileDoseAccessorGenerator() override; /*! @brief Constructor. Initialization with a DICOM-RT dose file or a directory name @param aDICOMRTDoseFileName a DICOM-RT dose file name or a directory name @exception InvalidParameterException thrown if the file does not exist or the directory has no dicom dose file @exception DcmrtException thrown if load and read file failed */ DicomFileDoseAccessorGenerator(FileNameType aDICOMRTDoseFileName); /*! @brief Generate DoseAccessor @return Return shared pointer of DoseAccessor. @exception InvalidDoseException Thrown if the loaded dose is invalid: one of column/row/numberOfFrames/doseGridScaling/pixelSpacing=0 @exception DcmrtException Throw if dcmrt error */ DoseAccessorPointer generateDoseAccessor() override ; }; } } } #endif diff --git a/code/io/dicom/rttbDicomFileDoseAccessorWriter.h b/code/io/dicom/rttbDicomFileDoseAccessorWriter.h index bd0cb60..087cbe3 100644 --- a/code/io/dicom/rttbDicomFileDoseAccessorWriter.h +++ b/code/io/dicom/rttbDicomFileDoseAccessorWriter.h @@ -1,82 +1,82 @@ // ----------------------------------------------------------------------- // 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 __DICOM_FILE_DOSE_ACCESSOR_WRITER_H #define __DICOM_FILE_DOSE_ACCESSOR_WRITER_H #include "../itk/rttbDoseAccessorProcessorBase.h" #include "../itk/rttbDoseAccessorConversionSettingInterface.h" #include "rttbDicomDoseAccessor.h" //pixel data max value UINT16_MAX #define PixelDataMaxValue 0xffff namespace rttb { namespace io { namespace dicom { /*! @class DicomFileDoseAccessorWriter @brief Class converts/dumps the processed accessor into an dicom file @remark DoseAccessorConversionInterface defines how the converter should react on non valid dose values. */ class DicomFileDoseAccessorWriter: public core::DoseAccessorProcessorBase, public core::DoseAccessorConversionSettingInterface { public: - typedef core::DoseAccessorInterface::DoseAccessorPointer DoseAccessorPointer; - typedef DicomDoseAccessor::DRTDoseIODPtr DRTDoseIODPointer; + using DoseAccessorPointer = core::DoseAccessorInterface::DoseAccessorPointer; + using DRTDoseIODPointer = DicomDoseAccessor::DRTDoseIODPtr; /*! @brief Standard Constructor. */ DicomFileDoseAccessorWriter(); ~DicomFileDoseAccessorWriter() override = default; /*! Set a file name to write the dose @param aFileName a file name to write the dose */ void setFileName(DICOMRTFileNameString aFileName); /*! @brief Convert the accessor into dicom dataset and write dicom dataset to a file @exception InvalidDoseException thrown if put and insert pixel data into dicom dataset failed */ bool process() override; private: DicomFileDoseAccessorWriter(const DicomFileDoseAccessorWriter&); //not implemented on purpose -> non-copyable DicomFileDoseAccessorWriter& operator=(const DicomFileDoseAccessorWriter&);//not implemented on purpose -> non-copyable DRTDoseIODPointer _doseIOD; DICOMRTFileNameString _fileName; DcmFileFormat _fileformat; DcmDataset* _dataset; }; } } } #endif diff --git a/code/io/dicom/rttbDicomFileReaderHelper.h b/code/io/dicom/rttbDicomFileReaderHelper.h index df44bd1..ab55f3e 100644 --- a/code/io/dicom/rttbDicomFileReaderHelper.h +++ b/code/io/dicom/rttbDicomFileReaderHelper.h @@ -1,88 +1,88 @@ // ----------------------------------------------------------------------- // 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 __DICOM_FILE_READER_HELPER_H #define __DICOM_FILE_READER_HELPER_H #include #include "dcmtk/config/osconfig.h" /* make sure OS specific configuration is included first */ #include "drtdose.h" #include "rttbBaseType.h" #include "boost/shared_ptr.hpp" namespace rttb { namespace io { namespace dicom { struct Modality { enum Type { RTDOSE = 1, RTSTRUCT = 2, RTPLAN = 3, UserDefined = 128 } Type; }; - typedef boost::shared_ptr DRTDoseIODPtr; - typedef boost::shared_ptr DcmDataSetPtr; + using DRTDoseIODPtr = boost::shared_ptr; + using DcmDataSetPtr = boost::shared_ptr; /*! Return the vector of all files with the same UID in the given directory, the UID is defined by the first file with the modality. @exception InvalidParameterException thrown if the file/directory does not exist or the modality is invalid @exception DcmrtException thrown if load/read file failed */ std::vector getFileNamesWithSameUID(FileNameType aDirName, Modality aModality); /*! Return the vector of all files with the same UID in the directory of the given file @exception InvalidParameterException thrown if the file does not exist @exception DcmrtException thrown if load/read file failed */ std::vector getFileNames(FileNameType aFileName); /*! Return if the given name is a file */ bool isFile(FileNameType aName); /*! Return if the given name is a directory */ bool isDirectory(FileNameType aName); /*! Return modality DcmTagKey(0x0008, 0x0060) @exception DcmrtException thrown if reading modality failed*/ OFString getModality(DcmDataSetPtr aDcmDataSet); /*! Return uid DcmTagKey(0x0020, 0x000e) @exception DcmrtException thrown if reading uid failed*/ OFString getUID(DcmDataSetPtr aDcmDataSet); }; } } #endif diff --git a/code/io/dicom/rttbDicomFileStructureSetGenerator.h b/code/io/dicom/rttbDicomFileStructureSetGenerator.h index 5aec017..08fadc1 100644 --- a/code/io/dicom/rttbDicomFileStructureSetGenerator.h +++ b/code/io/dicom/rttbDicomFileStructureSetGenerator.h @@ -1,86 +1,86 @@ // ----------------------------------------------------------------------- // RTToolbox - DKFZ radiotherapy quantitative evaluation library // // Copyright (c) German Cancer Research Center (DKFZ), // Software development for Integrated Diagnostics and Therapy (SIDT). // ALL RIGHTS RESERVED. // See rttbCopyright.txt or // http://www.dkfz.de/en/sidt/projects/rttb/copyright.html // // This software is distributed WITHOUT ANY WARRANTY; without even // the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // PURPOSE. See the above copyright notices for more information. // //------------------------------------------------------------------------ /*! // @file // @version $Revision$ (last changed revision) // @date $Date$ (last change date) // @author $Author$ (last changed by) */ /* Changes in Architecture: The DICOM specific classes will be removed and transfered to the corresponding IO classes. This class should only provide general structure functionality. */ #ifndef __DICOM_FILE_STRUCTURE_SET_GENERATOR_H #define __DICOM_FILE_STRUCTURE_SET_GENERATOR_H #include #include #include "drtstrct.h" #include "rttbBaseType.h" #include "rttbStrVectorStructureSetGenerator.h" namespace rttb { namespace io { namespace dicom { /*! @class DicomFileStructureSetGenerator @brief Generate a structure set from a corresponding dicomRT file. */ class DicomFileStructureSetGenerator: public core::StrVectorStructureSetGenerator { public: - typedef core::StructureSet::StructTypePointer StructTypePointer; - typedef StructureSetGeneratorInterface::StructureSetPointer StructureSetPointer; - typedef boost::shared_ptr DRTStrSetIODPtr; + using StructTypePointer = core::StructureSet::StructTypePointer; + using StructureSetPointer = StructureSetGeneratorInterface::StructureSetPointer; + using DRTStrSetIODPtr = boost::shared_ptr; private: IDType _UID; DICOMRTFileNameString _fileName; DicomFileStructureSetGenerator() = default; public: /*! @brief Constructor @param aDICOMRTStrSetFileName a DICOM-RT Structure set file name or a directory name @exception InvalidParameterException thrown if the file does not exist or the directory has no dicom structure file @exception DcmrtException thrown if load and read file failed */ DicomFileStructureSetGenerator(DICOMRTFileNameString aDICOMRTStrSetFileName); /*! @brief Destructor */ ~DicomFileStructureSetGenerator() override; /*! @brief generate structure set @return return shared pointer of StructureSet @exception DcmrtException Thrown if loadFile and read failed @exception InvalidParameterException throw if the imported header tags are not numerical. */ StructureSetPointer generateStructureSet() override; }; } } } #endif diff --git a/code/io/dicom/rttbDicomIODDoseAccessorGenerator.h b/code/io/dicom/rttbDicomIODDoseAccessorGenerator.h index ba36879..c058b64 100644 --- a/code/io/dicom/rttbDicomIODDoseAccessorGenerator.h +++ b/code/io/dicom/rttbDicomIODDoseAccessorGenerator.h @@ -1,75 +1,75 @@ // ----------------------------------------------------------------------- // RTToolbox - DKFZ radiotherapy quantitative evaluation library // // Copyright (c) German Cancer Research Center (DKFZ), // Software development for Integrated Diagnostics and Therapy (SIDT). // ALL RIGHTS RESERVED. // See rttbCopyright.txt or // http://www.dkfz.de/en/sidt/projects/rttb/copyright.html // // This software is distributed WITHOUT ANY WARRANTY; without even // the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // PURPOSE. See the above copyright notices for more information. // //------------------------------------------------------------------------ /*! // @file // @version $Revision$ (last changed revision) // @date $Date$ (last change date) // @author $Author$ (last changed by) */ #ifndef __DICOM_IOD_DOSE_ACCESSOR_GENERATOR_H #define __DICOM_IOD_DOSE_ACCESSOR_GENERATOR_H #include "dcmtk/config/osconfig.h" /* make sure OS specific configuration is included first */ #include "drtdose.h" #include "rttbDoseAccessorGeneratorBase.h" namespace rttb { namespace io { namespace dicom { /*! @class DicomIODDoseAccessorGenerator @brief Generate DicomDoseAccessor with a DRTDoseIOD. */ class DicomIODDoseAccessorGenerator: public core::DoseAccessorGeneratorBase { public: - typedef boost::shared_ptr DRTDoseIODPtr; - typedef boost::shared_ptr DcmItemPtr; + using DRTDoseIODPtr = boost::shared_ptr; + using DcmItemPtr = boost::shared_ptr; protected: private: DRTDoseIODPtr _doseIODPtr; DicomIODDoseAccessorGenerator(); public: ~DicomIODDoseAccessorGenerator() override; /*! @brief Constructor. Initialization with a boost shared pointer of DRTDoseIOD */ DicomIODDoseAccessorGenerator(DRTDoseIODPtr aDRTDoseIODP); /*! @brief Generate DoseAccessor @return Return shared pointer of DoseAccessor. @exception InvalidDoseException Thrown if aDRTDoseIODP is invalid: one of column/row/numberOfFrames/doseGridScaling/pixelSpacing=0 @exception DcmrtException Throw if dcmrt error */ DoseAccessorPointer generateDoseAccessor() override ; }; } } } #endif diff --git a/code/io/dicom/rttbDicomIODStructureSetGenerator.h b/code/io/dicom/rttbDicomIODStructureSetGenerator.h index 07ea320..6b8d223 100644 --- a/code/io/dicom/rttbDicomIODStructureSetGenerator.h +++ b/code/io/dicom/rttbDicomIODStructureSetGenerator.h @@ -1,89 +1,89 @@ // ----------------------------------------------------------------------- // 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) */ /* Changes in Architecture: The DICOM specific classes will be removed and transfered to the corresponding IO classes. This class should only provide general structure functionality. */ #ifndef __DICOM_IOD_STRUCTURE_SET_GENERATOR_H #define __DICOM_IOD_STRUCTURE_SET_GENERATOR_H #include #include "drtstrct.h" #include "rttbBaseType.h" #include "rttbStrVectorStructureSetGenerator.h" namespace rttb { namespace io { namespace dicom { /*! @class DicomIODStructureSetGenerator @brief Generate a structure set from a DRTStructureSetIOD pointer. */ class DicomIODStructureSetGenerator: public core::StrVectorStructureSetGenerator { public: - typedef core::StructureSet::StructTypePointer StructTypePointer; - typedef StructureSetGeneratorInterface::StructureSetPointer StructureSetPointer; - typedef boost::shared_ptr DRTStrSetIODPtr; + using StructTypePointer = core::StructureSet::StructTypePointer; + using StructureSetPointer = StructureSetGeneratorInterface::StructureSetPointer; + using DRTStrSetIODPtr = boost::shared_ptr; private: DRTStrSetIODPtr _drtStrSetIOD; IDType _UID; /*! Import Structure data from file. @exception InvalidParameterException Thrown if the imported header tags are not numerical. */ void readStrSet(); public: /*! @brief Structure Constructor Get the vector of structures from DRTStructureSetIOD object @exception NullPointerException Thrown if structureSet is nullptr */ DicomIODStructureSetGenerator(DRTStrSetIODPtr aDRTStructureSetIOD); /*! @brief Destructor */ ~DicomIODStructureSetGenerator() override; /*! @brief generate structure set @return return shared pointer of StructureSet @exception InvalidParameterException throw if the imported header tags are not numerical. */ StructureSetPointer generateStructureSet() override; }; } } } #endif diff --git a/code/io/helax/rttbDicomHelaxDoseAccessor.h b/code/io/helax/rttbDicomHelaxDoseAccessor.h index a5b1c3a..eca66ae 100644 --- a/code/io/helax/rttbDicomHelaxDoseAccessor.h +++ b/code/io/helax/rttbDicomHelaxDoseAccessor.h @@ -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) */ #ifndef __DICOM_HELAX_DOSE_ACCESSOR_H #define __DICOM_HELAX_DOSE_ACCESSOR_H #include #include "dcmtk/config/osconfig.h" /* make sure OS specific configuration is included first */ #include "drtdose.h" #include "rttbBaseType.h" #include "rttbAccessorWithGeoInfoBase.h" namespace rttb { namespace io { namespace helax { /*! @class DicomHelaxDoseAccessor @brief Load dose data from a directory containing dicom dose files, each file describes the helax dose in one slice. */ class DicomHelaxDoseAccessor: public core::AccessorWithGeoInfoBase { public: - typedef boost::shared_ptr DRTDoseIODPtr; + using DRTDoseIODPtr = boost::shared_ptr; private: /*! vector of DRTDoseIOD shared pointers, each DRTDoseIOD pointer presents the dose in one slice*/ std::vector _doseVector; /*! vector of dose data(absolute Gy dose/doseGridScaling)*/ std::vector _doseData; double _doseGridScaling; IDType _doseUID; DicomHelaxDoseAccessor(); protected: /*! @brief Initialize dose data @exception InvalidDoseException Thrown if any DRTDoseIOD pointer of _doseVector is invalid: one of column/row/numberOfFrames/doseGridScaling/pixelSpacing=0 @exception DcmrtException Throw if dcmrt error @exception boost/bad_lexical_cast Thrown if the imported header tags are not numerical. */ bool begin(); /*! @brief get all required data from dicom information contained in _dose @exception boost/bad_lexical_cast Thrown if the imported header tags are not numerical. */ bool assembleGeometricInfo(); public: ~DicomHelaxDoseAccessor() override; /*! @brief Constructor. Initialisation with a vector of DRTDoseIOD pointers @exception InvalidDoseException Thrown if any DRTDoseIOD pointer of _doseVector is invalid: one of column/row/numberOfFrames/doseGridScaling/pixelSpacing=0 @exception DcmrtException Throw if dcmrt error */ DicomHelaxDoseAccessor(std::vector aDICOMRTDoseVector); GenericValueType getValueAt(const VoxelGridID aID) const override; GenericValueType getValueAt(const VoxelGridIndex3D& aIndex) const override; const IDType getUID() const override { return _doseUID; }; }; } } } #endif diff --git a/code/io/helax/rttbDicomHelaxFileDoseAccessorGenerator.h b/code/io/helax/rttbDicomHelaxFileDoseAccessorGenerator.h index 96b69ca..3bb02b7 100644 --- a/code/io/helax/rttbDicomHelaxFileDoseAccessorGenerator.h +++ b/code/io/helax/rttbDicomHelaxFileDoseAccessorGenerator.h @@ -1,79 +1,79 @@ // ----------------------------------------------------------------------- // 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 __DICOM_HELAX_FILE_DOSE_ACCESSOR_GENERATOR_H #define __DICOM_HELAX_FILE_DOSE_ACCESSOR_GENERATOR_H #include #include #include #include "dcmtk/config/osconfig.h" /* make sure OS specific configuration is included first */ #include "drtdose.h" #include "rttbDoseAccessorGeneratorBase.h" #include "rttbBaseType.h" namespace rttb { namespace io { namespace helax { /*! @class DicomHelaxFileDoseAccessorGenerator @brief Load dose data from dicom helax files and generate DoseAccessor */ class DicomHelaxFileDoseAccessorGenerator: public core::DoseAccessorGeneratorBase { public: - typedef boost::shared_ptr DRTDoseIODPtr; + using DRTDoseIODPtr = boost::shared_ptr; protected: private: FileNameType _doseDirName; DicomHelaxFileDoseAccessorGenerator(); public: ~DicomHelaxFileDoseAccessorGenerator() override; /*! @brief Constructor. Initialisation with a directory name */ DicomHelaxFileDoseAccessorGenerator(FileNameType aDICOMRTDoseDirName); /*! @brief Generate DoseAccessor @return Return shared pointer of DoseAccessor. @exception InvalidParameterException Thrown if aDICOMRTDoseDirName is not found @exception InvalidDoseException Thrown if any loaded dose is invalid: one of column/row/numberOfFrames/doseGridScaling/pixelSpacing=0 @exception DcmrtException Throw if dcmrt error */ DoseAccessorPointer generateDoseAccessor() override ; }; } } } #endif diff --git a/code/io/helax/rttbDicomHelaxIODVecDoseAccessorGenerator.h b/code/io/helax/rttbDicomHelaxIODVecDoseAccessorGenerator.h index c4bb7a3..10fe3ba 100644 --- a/code/io/helax/rttbDicomHelaxIODVecDoseAccessorGenerator.h +++ b/code/io/helax/rttbDicomHelaxIODVecDoseAccessorGenerator.h @@ -1,74 +1,74 @@ // ----------------------------------------------------------------------- // 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 __DICOM_HELAX_IOD_VEC_DOSE_ACCESSOR_GENERATOR_H #define __DICOM_HELAX_IOD_VEC_DOSE_ACCESSOR_GENERATOR_H #include #include "dcmtk/config/osconfig.h" /* make sure OS specific configuration is included first */ #include "drtdose.h" #include "rttbDoseAccessorGeneratorBase.h" namespace rttb { namespace io { namespace helax { /*! @class DicomHelaxIODVecDoseAccessorGenerator @brief Generate DoseAccessor with a vector of DRTDoseIOD. */ class DicomHelaxIODVecDoseAccessorGenerator: public core::DoseAccessorGeneratorBase { public: - typedef boost::shared_ptr DRTDoseIODPtr; + using DRTDoseIODPtr = boost::shared_ptr; protected: private: std::vector _dosePtrVector; DicomHelaxIODVecDoseAccessorGenerator(); public: ~DicomHelaxIODVecDoseAccessorGenerator() override; /*! @brief Constructor. Initialisation with a vector of DRTDoseIOD pointers */ DicomHelaxIODVecDoseAccessorGenerator(std::vector& aDICOMRTDoseVector); /*! @brief Generate DoseAccessor @return Return shared pointer of DoseAccessor. @exception InvalidDoseException Thrown if any DRTDoseIOD pointer of _doseVector is invalid: one of column/row/numberOfFrames/doseGridScaling/pixelSpacing=0 @exception DcmrtException Throw if dcmrt error */ DoseAccessorPointer generateDoseAccessor() override ; }; } } } #endif diff --git a/code/io/itk/itkDoseAccessorImageFilter.cpp b/code/io/itk/itkDoseAccessorImageFilter.cpp index 81b511a..e5c9331 100644 --- a/code/io/itk/itkDoseAccessorImageFilter.cpp +++ b/code/io/itk/itkDoseAccessorImageFilter.cpp @@ -1,84 +1,84 @@ // ----------------------------------------------------------------------- // 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 "itkDoseAccessorImageFilter.h" #include "itkImageRegionIterator.h" #include "itkImageRegionConstIteratorWithIndex.h" #include "itkProgressReporter.h" namespace itk { /** * Constructor */ DoseAccessorImageFilter ::DoseAccessorImageFilter() { this->SetNumberOfRequiredInputs(1); } void DoseAccessorImageFilter ::ThreadedGenerateData(const OutputImageRegionType& outputRegionForThread, ThreadIdType threadId) { ProgressReporter progress(this, threadId, outputRegionForThread.GetNumberOfPixels()); - typedef ImageRegionConstIteratorWithIndex< InputImageType > ImageRegionConstIteratorType; - typedef ImageRegionIterator< OutputImageType > OutputImageRegionIteratorType; + using ImageRegionConstIteratorType = ImageRegionConstIteratorWithIndex; + using OutputImageRegionIteratorType = ImageRegionIterator; InputImagePointer inputPtr = dynamic_cast< InputImageType* >(ProcessObject::GetInput(0)); ImageRegionConstIteratorType inputItr; if (inputPtr) { inputItr = ImageRegionConstIteratorType(inputPtr, outputRegionForThread); } OutputImagePointer outputPtr = dynamic_cast< OutputImageType* >(ProcessObject::GetOutput(0)); OutputImageRegionIteratorType outputItr; if (outputPtr) { outputItr = OutputImageRegionIteratorType(outputPtr, outputRegionForThread); } if (inputPtr && outputPtr) { while (!(outputItr.IsAtEnd())) { ImageRegionConstIteratorType::IndexType index = inputItr.GetIndex(); rttb::VoxelGridIndex3D doseIndex(index[0], index[1], index[2]); outputItr.Set(m_Accessor->getValueAt(doseIndex)); ++outputItr; ++inputItr; progress.CompletedPixel(); } } } } // end namespace itk diff --git a/code/io/itk/itkMaskAccessorImageSource.cpp b/code/io/itk/itkMaskAccessorImageSource.cpp index 842f527..b781774 100644 --- a/code/io/itk/itkMaskAccessorImageSource.cpp +++ b/code/io/itk/itkMaskAccessorImageSource.cpp @@ -1,108 +1,108 @@ // ----------------------------------------------------------------------- // 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: 1233 $ (last changed revision) // @date $Date: 2016-01-20 15:47:47 +0100 (Mi, 20 Jan 2016) $ (last change date) // @author $Author: hentsch $ (last changed by) */ #include "itkMaskAccessorImageSource.h" #include "itkImageRegionIterator.h" #include "itkImageRegionConstIteratorWithIndex.h" #include "itkProgressReporter.h" #include "itkExceptionObject.h" #include "rttbGeometricInfo.h" namespace itk { /** * Constructor */ MaskAccessorImageSource ::MaskAccessorImageSource() = default; void MaskAccessorImageSource ::ThreadedGenerateData(const OutputImageRegionType& outputRegionForThread, ThreadIdType threadId) { ProgressReporter progress(this, threadId, outputRegionForThread.GetNumberOfPixels()); - typedef ImageRegionIterator< OutputImageType > OutputImageRegionIteratorType; + using OutputImageRegionIteratorType = ImageRegionIterator; OutputImagePointer outputPtr = dynamic_cast< OutputImageType* >(ProcessObject::GetOutput(0)); OutputImageRegionIteratorType outputItr; if (outputPtr) { outputItr = OutputImageRegionIteratorType(outputPtr, outputRegionForThread); for (; !(outputItr.IsAtEnd()); ++outputItr) { OutputImageType::IndexType index = outputItr.GetIndex(); rttb::VoxelGridIndex3D maskIndex(index[0], index[1], index[2]); rttb::VoxelGridID id = 0; if (m_Accessor->getGeometricInfo().convert(maskIndex, id)) { auto finding = m_idMap.find(id); if (finding != m_idMap.end()) { // Set the current pixel outputItr.Set(m_MaskedVoxels->at(finding->second).getRelevantVolumeFraction()); } } else { if (m_FailsOnInvalidIDs) { itkExceptionMacro(<<"invalid Mask index. Index:"<(ProcessObject::GetOutput(0)); outputPtr->FillBuffer(0.0); //The id map approach and working with relevant voxel vector is a workarround till task T22067 is solved and and can be used again. m_MaskedVoxels = m_Accessor->getRelevantVoxelVector(); m_idMap.clear(); for (rttb::core::MaskAccessorInterface::MaskVoxelList::size_type pos = 0; pos < m_MaskedVoxels->size(); ++pos) { m_idMap.insert(std::make_pair((*m_MaskedVoxels)[pos].getVoxelGridID(), pos)); } } } // end namespace itk diff --git a/code/io/itk/rttbDoseAccessorProcessorBase.h b/code/io/itk/rttbDoseAccessorProcessorBase.h index d32236d..ee3615e 100644 --- a/code/io/itk/rttbDoseAccessorProcessorBase.h +++ b/code/io/itk/rttbDoseAccessorProcessorBase.h @@ -1,61 +1,61 @@ // ----------------------------------------------------------------------- // 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_ACCESSOR_PROCESSOR_BASE_H #define __DOSE_ACCESSOR_PROCESSOR_BASE_H #include #include "rttbDoseAccessorProcessorInterface.h" namespace rttb { namespace core { /*! @class DoseAccessorProcessorBase @brief Abstract class for all DoseAccessor generating classes */ class DoseAccessorProcessorBase: public DoseAccessorProcessorInterface { public: - typedef core::DoseAccessorInterface::DoseAccessorPointer DoseAccessorPointer; + using DoseAccessorPointer = core::DoseAccessorInterface::DoseAccessorPointer; void setDoseAccessor(DoseAccessorPointer accessor) override { _doseAccessor = accessor; }; private: DoseAccessorProcessorBase(const DoseAccessorProcessorBase&); //not implemented on purpose -> non-copyable DoseAccessorProcessorBase& operator=(const DoseAccessorProcessorBase&);//not implemented on purpose -> non-copyable protected: DoseAccessorProcessorBase() = default; ~DoseAccessorProcessorBase() override = default; /*! @brief Dose accessor which should be generated */ DoseAccessorPointer _doseAccessor; }; } } #endif diff --git a/code/io/itk/rttbDoseAccessorProcessorInterface.h b/code/io/itk/rttbDoseAccessorProcessorInterface.h index 0ea4d9a..f331c33 100644 --- a/code/io/itk/rttbDoseAccessorProcessorInterface.h +++ b/code/io/itk/rttbDoseAccessorProcessorInterface.h @@ -1,65 +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 __DOSE_ACCESSOR_PROCESSOR_INTERFACE_H #define __DOSE_ACCESSOR_PROCESSOR_INTERFACE_H #include "rttbDoseAccessorInterface.h" namespace rttb { namespace core { /*! @class DoseAccessorProcessorInterface @brief Interface for all DoseAccessor generating classes */ class DoseAccessorProcessorInterface { public: - typedef core::DoseAccessorInterface::DoseAccessorPointer DoseAccessorPointer; + using DoseAccessorPointer = core::DoseAccessorInterface::DoseAccessorPointer; private: DoseAccessorProcessorInterface(const DoseAccessorProcessorInterface&); //not implemented on purpose -> non-copyable DoseAccessorProcessorInterface& operator=(const DoseAccessorProcessorInterface&);//not implemented on purpose -> non-copyable protected: DoseAccessorProcessorInterface() = default; virtual ~DoseAccessorProcessorInterface() = default; public: /*! @brief Sets the DoseAccessor that should be processed @pre passed accessor must point to a valid instance. */ virtual void setDoseAccessor(DoseAccessorPointer accessor) = 0; /*! @brief Process the passed DoseAccessor @return if the processing was successful. */ virtual bool process() = 0; }; } } #endif diff --git a/code/io/itk/rttbGenericImageReader.cpp b/code/io/itk/rttbGenericImageReader.cpp index 9657c09..0fb76ab 100644 --- a/code/io/itk/rttbGenericImageReader.cpp +++ b/code/io/itk/rttbGenericImageReader.cpp @@ -1,301 +1,301 @@ // ----------------------------------------------------------------------- // MatchPoint - DKFZ translational registration framework // // Copyright (c) German Cancer Research Center (DKFZ), // Software development for Integrated Diagnostics and Therapy (SIDT). // ALL RIGHTS RESERVED. // See mapCopyright.txt or // http://www.dkfz.de/en/sidt/projects/MatchPoint/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) // Subversion HeadURL: $HeadURL: https://svn/sbr/Sources/SBR-Projects/MatchPoint/trunk/Code/IO/source/mapGenericImageReader.cpp $ */ #include "rttbGenericImageReader.h" namespace rttb { namespace io { namespace itk { void GenericImageReader::load() { _spImage = nullptr; FileNameString probeFileName = this->_fileName; if (this->_seriesReadStyle == ImageSeriesReadStyle::Numeric) { - typedef ::itk::NumericSeriesFileNames NamesType; + using NamesType = ::itk::NumericSeriesFileNames; NamesType::Pointer names = NamesType::New(); names->SetStartIndex(1); names->SetEndIndex(1); names->SetSeriesFormat(this->_fileName.c_str()); probeFileName = names->GetFileNames()[0]; } ::itk::ImageIOBase::Pointer imageIO = ::itk::ImageIOFactory::CreateImageIO(probeFileName.c_str(), ::itk::ImageIOFactory::ReadMode); if (!imageIO) { throw ::itk::ExceptionObject("No ImageIO found for given file. Please check if the file exists and has a supported format. File:" + probeFileName); } // Now that we found the appropriate ImageIO class, ask it to // read the meta data from the image file. imageIO->SetFileName(probeFileName.c_str()); imageIO->ReadImageInformation(); this->_loadedComponentType = imageIO->GetComponentType(); this->_loadedPixelType = imageIO->GetPixelType(); if (this->_loadedPixelType == ::itk::ImageIOBase::RGB && imageIO->GetNumberOfComponents() == 1) { //if only one channel per pixel handle as scalar as long as RGB etc. is not supported this->_loadedPixelType = ::itk::ImageIOBase::SCALAR; } this->_loadedComponentTypeStr = imageIO->GetComponentTypeAsString(this->_loadedComponentType); this->_loadedPixelTypeStr = imageIO->GetPixelTypeAsString(this->_loadedPixelType); this->_loadedDimensions = imageIO->GetNumberOfDimensions(); if (this->_seriesReadStyle == ImageSeriesReadStyle::Numeric && this->_loadedDimensions == 2) { this->_loadedDimensions = 3; //it is a stack of 2D images -> 3D } if (this->_loadedDimensions < 2 || this->_loadedDimensions > 3) { throw ::itk::ExceptionObject("The file uses a number of dimensions that is not supported in this application. Only dim<=3 supported "); } switch (_loadedPixelType) { case ::itk::ImageIOBase::SCALAR: { if (this->_loadedDimensions == 2) { loadScalar<2>(); } else { loadScalar<3>(); } break; } default: { throw ::itk::ExceptionObject("The file uses a pixel type that is not supported in this application. Only SCALAR pixel type supported "); } } _upToDate = true; }; template void GenericImageReader:: loadScalar() { // Use the pixel type to instantiate the appropriate reader switch (this->_loadedComponentType) { case ::itk::ImageIOBase::UCHAR: { this->_spImage = readImage(_fileName, _seriesReadStyle, false, 0, 0, _upperSeriesLimit, &_dictionaryArray); break; } case ::itk::ImageIOBase::CHAR: { this->_spImage = readImage(_fileName, _seriesReadStyle, false, 0, 0, _upperSeriesLimit, &_dictionaryArray); break; } case ::itk::ImageIOBase::USHORT: { this->_spImage = readImage(_fileName, _seriesReadStyle, false, 0, 0, _upperSeriesLimit, &_dictionaryArray); break; } case ::itk::ImageIOBase::SHORT: { this->_spImage = readImage(_fileName, _seriesReadStyle, false, 0, 0, _upperSeriesLimit, &_dictionaryArray); break; } case ::itk::ImageIOBase::UINT: { this->_spImage = readImage(_fileName, _seriesReadStyle, false, 0, 0, _upperSeriesLimit, &_dictionaryArray); break; } case ::itk::ImageIOBase::INT: { this->_spImage = readImage(_fileName, _seriesReadStyle, false, 0, 0, _upperSeriesLimit, &_dictionaryArray); break; } case ::itk::ImageIOBase::ULONG: { this->_spImage = readImage(_fileName, _seriesReadStyle, false, 0, 0, _upperSeriesLimit, &_dictionaryArray); break; } case ::itk::ImageIOBase::LONG: { this->_spImage = readImage(_fileName, _seriesReadStyle, false, 0, 0, _upperSeriesLimit, &_dictionaryArray); break; } case ::itk::ImageIOBase::FLOAT: { this->_spImage = readImage(_fileName, _seriesReadStyle, false, 0, 0, _upperSeriesLimit, &_dictionaryArray); break; } case ::itk::ImageIOBase::DOUBLE: { this->_spImage = readImage(_fileName, _seriesReadStyle, false, 0, 0, _upperSeriesLimit, &_dictionaryArray); break; } default: { throw ::itk::ExceptionObject("The file uses a pixel component type that is not supported in this application. ComponentType: " + this->_loadedComponentTypeStr); } } }; const FileNameString& GenericImageReader:: getFileName() const { return _fileName; }; void GenericImageReader:: setFileName(const FileNameString& fileName) { if (fileName != _fileName) { _upToDate = false; _fileName = fileName; } } const unsigned int GenericImageReader:: getUpperSeriesLimit() const { return _upperSeriesLimit; }; void GenericImageReader:: setUpperSeriesLimit(const unsigned int upperLimit) { if (upperLimit != _upperSeriesLimit) { _upToDate = false; _upperSeriesLimit = upperLimit; }; }; const ImageSeriesReadStyle::Type GenericImageReader:: getSeriesReadStyle() const { return _seriesReadStyle; }; void GenericImageReader:: setSeriesReadStyle(ImageSeriesReadStyle::Type readStyle) { if (readStyle != _seriesReadStyle) { _upToDate = false; _seriesReadStyle = readStyle; }; }; GenericImageReader::GenericOutputImageType* GenericImageReader:: GetOutput(unsigned int& loadedDimensions, LoadedPixelType& loadedPixelType, LoadedComponentType& loadedComponentType) { if (!_upToDate) { load(); loadedPixelType = _loadedPixelType; loadedComponentType = _loadedComponentType; loadedDimensions = _loadedDimensions; }; return _spImage; }; GenericImageReader:: GenericImageReader() : _fileName() { }; GenericImageReader:: ~GenericImageReader() = default; const GenericImageReader::MetaDataDictionaryArrayType& GenericImageReader:: getMetaDictionaryArray() { return _dictionaryArray; }; }//end namespace itk }//end namespace io }//end namespace rttb diff --git a/code/io/itk/rttbGenericImageReader.h b/code/io/itk/rttbGenericImageReader.h index 3b12d79..037a154 100644 --- a/code/io/itk/rttbGenericImageReader.h +++ b/code/io/itk/rttbGenericImageReader.h @@ -1,163 +1,163 @@ // ----------------------------------------------------------------------- // MatchPoint - DKFZ translational registration framework // // Copyright (c) German Cancer Research Center (DKFZ), // Software development for Integrated Diagnostics and Therapy (SIDT). // ALL RIGHTS RESERVED. // See mapCopyright.txt or // http://www.dkfz.de/en/sidt/projects/MatchPoint/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) // Subversion HeadURL: $HeadURL: https://svn/sbr/Sources/SBR-Projects/MatchPoint/trunk/Code/IO/include/mapGenericImageReader.h $ */ #ifndef __RTTB_GENERIC_IMAGE_READER_H #define __RTTB_GENERIC_IMAGE_READER_H #include "rttbImageReader.h" namespace rttb { namespace io { namespace itk { /** @class ImageReader * @brief Helper class manages the generic loading (unspecified dimension and pixel type) of 2D/3D images ... * * GenericImageReader uses the ImageReader class and dispatches the dimension and pixel type information from the specified image file. * GenericImageReader supports 2D and 3D images and the following pixel types: * - (unsigned) char * - (unsigned) short * - (unsigned) int * - (unsigned) long * - float * - double * . * Due to the fact that it builds upon the itk io infrastructure, all formats supported by ITK * can be read. * For further information regarding the usage see documentation of ImageReader. * @sa ImageReader * @note code copied from MatchPoint, see documentation (http://sourceforge.net/projects/matchpoint/) */ class GenericImageReader : public ::itk::Object { public: - typedef GenericImageReader Self; - typedef ::itk::Object Superclass; - typedef ::itk::SmartPointer Pointer; - typedef ::itk::SmartPointer ConstPointer; + using Self = rttb::io::itk::GenericImageReader; + using Superclass = ::itk::Object; + using Pointer = ::itk::SmartPointer; + using ConstPointer = ::itk::SmartPointer; itkTypeMacro(GenericImageReader, ::itk::Object); itkNewMacro(Self); - typedef ::itk::DataObject GenericOutputImageType; + using GenericOutputImageType = ::itk::DataObject; - typedef ::itk::ImageIOBase::IOPixelType LoadedPixelType; + using LoadedPixelType = ::itk::ImageIOBase::IOPixelType; - typedef ::itk::ImageIOBase::IOComponentType LoadedComponentType; + using LoadedComponentType = ::itk::ImageIOBase::IOComponentType; - typedef std::vector< ::itk::MetaDataDictionary> MetaDataDictionaryArrayType; + using MetaDataDictionaryArrayType = std::vector< ::itk::MetaDataDictionary>; private: /** Loaded Image.*/ GenericOutputImageType::Pointer _spImage; /** The file name of the image. */ FileNameString _fileName; /** The upper limit for the searching of series files in the path.*/ unsigned int _upperSeriesLimit{255}; /** Indicates if the image data is up to date or should be read again.*/ bool _upToDate{false}; /** Defines if the specified image file is part of a series and the * whole series should be read into one image. Only relevant for 3D images.*/ ImageSeriesReadStyle::Type _seriesReadStyle{ImageSeriesReadStyle::Default}; unsigned int _loadedDimensions; LoadedPixelType _loadedPixelType; LoadedComponentType _loadedComponentType; std::string _loadedComponentTypeStr; std::string _loadedPixelTypeStr; MetaDataDictionaryArrayType _dictionaryArray; /** Loads the image. First identifies pixel type and dimension and then deligates according * to the pixel type. * @exception map::core::ExceptionObject If no ImageIO is found. * @exception map::core::ExceptionObject If dimension of the image is not supported. Only 2D/3D is supported. * @exception map::core::ExceptionObject If pixel type is not supported. Currently only scalar pixels are supported. */ void load(); /** Loads an scalar image. * @exception map::core::ExceptionObject If pixel component type is not supported. */ template void loadScalar(); //template //void loadRGB(); public: /** Function to access the member variable _FileName. _FileName represents the filename of the * headerfile. The path must be included, the file extension may left away. * @return File name of the header file.*/ const FileNameString& getFileName() const; /** Function to access the member variable _FileName. _FileName represents the filename of the * headerfile. The path must be included, the file extension may left away. * @param [in] sFileName The file name of the header file.*/ void setFileName(const FileNameString& sFileName); /** Function to access the member variable _upperSeriesLimit. _upperSeriesLimit represents * the upper limit for the series file search. * @return The upper limit of the series search.*/ const unsigned int getUpperSeriesLimit() const; /** Function to access the member variable _upperSeriesLimit. _upperSeriesLimit represents * the upper limit for the series file search. Changing the series limit out dates the ImageReader. * @remark It is only relevant if series style is set to "Numeric". * @param [in] upperLimit The upper limit of the header file.*/ void setUpperSeriesLimit(const unsigned int upperLimit); /** Function to access the member variable _seriesReadStyle (see member description for more information).*/ const ImageSeriesReadStyle::Type getSeriesReadStyle() const; /** Function to access the member variable _seriesReadStyle (see member description for more information). * Changing the style out dates the ImageReader.*/ void setSeriesReadStyle(ImageSeriesReadStyle::Type readStyle); /** Function loads the image if needed and returns the data. * @return Pointer to loaded image. * @exception map::core::ExceptionObject If no ImageIO is found. * @exception map::core::ExceptionObject If dimension of the image is not supported. Only 2D/3D is supported. * @exception map::core::ExceptionObject If pixel type is not supported. Currently only scalar pixels are supported. * @exception map::core::ExceptionObject If pixel component type is not supported. */ GenericOutputImageType* GetOutput(unsigned int& loadedDimensions, LoadedPixelType& loadedPixelType, LoadedComponentType& loadedComponentType); /** Function returns the reference to the meta data dictionary(ies) of the latest file(s) loaded by this class. * Array may be empty if no MetaDictionary exists.*/ const MetaDataDictionaryArrayType& getMetaDictionaryArray(); protected: GenericImageReader(); ~GenericImageReader() override; }; }//end namespace itk }//end namespace io }//end namespace rttb #endif diff --git a/code/io/itk/rttbITKIOHelper.tpp b/code/io/itk/rttbITKIOHelper.tpp index 0fbb256..d80a09d 100644 --- a/code/io/itk/rttbITKIOHelper.tpp +++ b/code/io/itk/rttbITKIOHelper.tpp @@ -1,65 +1,65 @@ // ----------------------------------------------------------------------- // MatchPoint - DKFZ translational registration framework // // Copyright (c) German Cancer Research Center (DKFZ), // Software development for Integrated Diagnostics and Therapy (SIDT). // ALL RIGHTS RESERVED. // See mapCopyright.txt or // http://www.dkfz.de/en/sidt/projects/MatchPoint/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) // Subversion HeadURL: $HeadURL: https://svn/sbr/Sources/SBR-Projects/MatchPoint/trunk/Code/IO/include/mapImageReader.tpp $ */ #ifndef __RTTB_ITK_IO_HELPER_TPP #define __RTTB_ITK_IO_HELPER_TPP #include "rttbITKImageAccessor.h" #include "itkCastImageFilter.h" namespace rttb { namespace io { namespace itk { template ITKImageType::Pointer doCasting( GenericImageReader::GenericOutputImageType* genericImage) { ITKImageType::Pointer itkDoubleImage; typedef ::itk::Image InputImageType; - typedef ITKImageType OutputImageType; + using OutputImageType = ITKImageType; typename InputImageType::Pointer pCastedInput = dynamic_cast(genericImage); typedef ::itk::CastImageFilter CastFilterType; typename CastFilterType::Pointer castFilter = CastFilterType::New(); castFilter->SetInput(pCastedInput); try { //important to update the filter! castFilter->Update(); itkDoubleImage = castFilter->GetOutput(); } catch (::itk::ExceptionObject& e) { std::cerr << "ITK Error!!!" << std::endl; std::cerr << e << std::endl; } return itkDoubleImage; } } } } #endif diff --git a/code/io/itk/rttbITKImageAccessorConverter.h b/code/io/itk/rttbITKImageAccessorConverter.h index 7c6e1c9..7fb397e 100644 --- a/code/io/itk/rttbITKImageAccessorConverter.h +++ b/code/io/itk/rttbITKImageAccessorConverter.h @@ -1,69 +1,69 @@ // ----------------------------------------------------------------------- // 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 __ITK_IMAGE_ACCESSOR_CONVERTER_H #define __ITK_IMAGE_ACCESSOR_CONVERTER_H #include "rttbDoseAccessorProcessorBase.h" #include "rttbDoseAccessorConversionSettingInterface.h" #include "itkImage.h" #include "RTTBITKIOExports.h" namespace rttb { namespace io { namespace itk { /*! @class ITKImageAccessorConverter @brief Class converts/dumps the processed accessor into an itk image @remark DoseAccessorConversionInterface defines how the converter should react on non valid dose values. */ class RTTBITKIO_EXPORT ITKImageAccessorConverter : public core::DoseAccessorProcessorBase, public core::DoseAccessorConversionSettingInterface { public: typedef ::itk::Image ITKImageType; - typedef core::DoseAccessorInterface::DoseAccessorPointer DoseAccessorPointer; + using DoseAccessorPointer = core::DoseAccessorInterface::DoseAccessorPointer; bool process() override; ITKImageType::Pointer getITKImage() { return _itkImage; } ITKImageAccessorConverter(DoseAccessorPointer accessor); ~ITKImageAccessorConverter() override = default; private: ITKImageAccessorConverter(const ITKImageAccessorConverter&); //not implemented on purpose -> non-copyable ITKImageAccessorConverter& operator=(const ITKImageAccessorConverter&);//not implemented on purpose -> non-copyable ITKImageType::Pointer _itkImage; }; } } } #endif diff --git a/code/io/itk/rttbITKImageAccessorGenerator.h b/code/io/itk/rttbITKImageAccessorGenerator.h index bbcf942..98fa6d8 100644 --- a/code/io/itk/rttbITKImageAccessorGenerator.h +++ b/code/io/itk/rttbITKImageAccessorGenerator.h @@ -1,71 +1,71 @@ // ----------------------------------------------------------------------- // 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 __ITK_IMAGE_ACCESSOR_GENERATOR_H #define __ITK_IMAGE_ACCESSOR_GENERATOR_H #include "rttbDoseAccessorGeneratorBase.h" #include "itkImage.h" #include "RTTBITKIOExports.h" namespace rttb { namespace io { namespace itk { /*! @class ITKImageAccessorGenerator @brief Generate ITKImageAccessor wrapping an itk image as object (not as file). @note it implies that the information is stored in absolute values. */ class RTTBITKIO_EXPORT ITKImageAccessorGenerator : public core::DoseAccessorGeneratorBase { public: typedef ::itk::Image ITKImageType; - typedef DoseAccessorGeneratorBase::DoseAccessorPointer DoseAccessorPointer; + using DoseAccessorPointer = DoseAccessorGeneratorBase::DoseAccessorPointer; private: /** @brief The dose as itkImage */ ITKImageType::ConstPointer _dosePtr; ITKImageAccessorGenerator(); public: ~ITKImageAccessorGenerator() override = default; /*! @pre aDoseImage must point to a valid instance. @exception InvalidDoseException Thrown if aDoseImage is invalid. */ ITKImageAccessorGenerator(const ITKImageType* aDoseImage); /*! @brief Generate DoseAccessor @return Return shared pointer of DoseAccessor. */ DoseAccessorPointer generateDoseAccessor() override ; }; } } } #endif diff --git a/code/io/itk/rttbITKImageFileAccessorGenerator.h b/code/io/itk/rttbITKImageFileAccessorGenerator.h index e835379..02b6a3a 100644 --- a/code/io/itk/rttbITKImageFileAccessorGenerator.h +++ b/code/io/itk/rttbITKImageFileAccessorGenerator.h @@ -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) */ #ifndef __ITK_IMAGE_FILE_ACCESSOR_GENERATOR_H #define __ITK_IMAGE_FILE_ACCESSOR_GENERATOR_H #include "rttbDoseAccessorGeneratorBase.h" #include "rttbBaseType.h" #include "itkImage.h" namespace rttb { namespace io { namespace itk { /*! @class ITKImageFileAccessorGenerator @brief Load image data using the itk loading methods and wraps the resulting itk image in a ITKImageAccessor. * this can be used if dose distributions are stored in formats like meta image, nrrd... * @note it implies that the dose information is stored in absolute Gy values. */ class ITKImageFileAccessorGenerator: public core::DoseAccessorGeneratorBase { public: typedef ::itk::Image ITKImageType; - typedef DoseAccessorGeneratorBase::DoseAccessorPointer DoseAccessorPointer; + using DoseAccessorPointer = DoseAccessorGeneratorBase::DoseAccessorPointer; private: FileNameType _fileName; /** @brief The dose as itkImage */ ITKImageType::Pointer _itkDoubleImage; ITKImageFileAccessorGenerator(); public: ~ITKImageFileAccessorGenerator() override; ITKImageFileAccessorGenerator(const FileNameType& fileName); /*! @brief Generate DoseAccessor @return Return shared pointer of DoseAccessor. @exception InvalidDoseException Thrown if file could not be read @exception InvalidParameterException Thrown if file has imageDimension !=3 or image component type != SCALAR @details is always converted into a itkImage by using a CastImageFilter @sa doCasting, handleGenericImage */ DoseAccessorPointer generateDoseAccessor() override; }; }//end namespace itk }//end namespace io }//end namespace rttb #endif diff --git a/code/io/itk/rttbITKImageFileMaskAccessorGenerator.h b/code/io/itk/rttbITKImageFileMaskAccessorGenerator.h index fde0329..2104218 100644 --- a/code/io/itk/rttbITKImageFileMaskAccessorGenerator.h +++ b/code/io/itk/rttbITKImageFileMaskAccessorGenerator.h @@ -1,73 +1,73 @@ // ----------------------------------------------------------------------- // 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 __ITK_IMAGE_MASK_FILE_ACCESSOR_GENERATOR_H #define __ITK_IMAGE_MASK_FILE_ACCESSOR_GENERATOR_H #include "rttbMaskAccessorGeneratorBase.h" #include "rttbBaseType.h" #include "rttbITKImageMaskAccessor.h" namespace rttb { namespace io { namespace itk { /*! @class ITKImageFileMaskAccessorGenerator @brief Load 3D Mask data using the itk loading methods and wraps the resulting itk image in a ITKImageMaskAccessor. * this is normally used if Mask distributions are stored in formats like meta image, nrrd... */ class ITKImageFileMaskAccessorGenerator: public core::MaskAccessorGeneratorBase { public: - typedef MaskAccessorGeneratorBase::MaskAccessorPointer MaskAccessorPointer; + using MaskAccessorPointer = MaskAccessorGeneratorBase::MaskAccessorPointer; private: FileNameType _itkMaskFileName; /** @brief The mask as itkImage */ ITKImageMaskAccessor::ITKMaskImageType::Pointer _itkDoubleImage; ITKImageFileMaskAccessorGenerator(); public: ~ITKImageFileMaskAccessorGenerator() override; ITKImageFileMaskAccessorGenerator(const FileNameType& fileName); /*! @brief Generate MaskAccessor @return Return shared pointer of MaskAccessor. @exception InvalidDoseException Thrown if file could not be read @exception InvalidParameterException Thrown if file has imageDimension !=3 or image component type != SCALAR @details is always converted into a itkImage by using a CastImageFilter @sa doCasting, handleGenericImage */ MaskAccessorPointer generateMaskAccessor() override; }; }//end namespace itk }//end namespace io }//end namespace rttb #endif diff --git a/code/io/itk/rttbITKImageMaskAccessor.h b/code/io/itk/rttbITKImageMaskAccessor.h index c6e6eb3..60ed22a 100644 --- a/code/io/itk/rttbITKImageMaskAccessor.h +++ b/code/io/itk/rttbITKImageMaskAccessor.h @@ -1,112 +1,112 @@ // ----------------------------------------------------------------------- // 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 __ITK_IMAGE_MASK_ACCESSOR_H #define __ITK_IMAGE_MASK_ACCESSOR_H #include "rttbMaskAccessorInterface.h" #include "rttbBaseType.h" #include "itkImage.h" namespace rttb { namespace io { namespace itk { /*! @class ITKImageMaskAccessor @brief This class gives access to mask information stored in an itk image */ class ITKImageMaskAccessor: public core::MaskAccessorInterface { public: typedef ::itk::Image ITKMaskImageType; - typedef ::itk::ImageBase<3> ITKImageBaseType; - typedef core::MaskAccessorInterface::MaskVoxelList MaskVoxelList; - typedef core::MaskAccessorInterface::MaskVoxelListPointer MaskVoxelListPointer; + using ITKImageBaseType = ::itk::ImageBase<3>; + using MaskVoxelList = core::MaskAccessorInterface::MaskVoxelList; + using MaskVoxelListPointer = core::MaskAccessorInterface::MaskVoxelListPointer; - typedef boost::shared_ptr GeometricInfoPointer; + using GeometricInfoPointer = boost::shared_ptr; private: /** @brief The mask as itkImage */ ITKMaskImageType::ConstPointer _mask; IDType _maskUID; GeometricInfoPointer _geoInfo; /*! vector containing list of mask voxels*/ MaskVoxelListPointer _relevantVoxelVector; /*! @brief get all required data from the itk image contained in _Mask @exception InvalidDoseException if PixelSpacing is 0 or size in any dimension is 0. */ bool assembleGeometricInfo(); public: ~ITKImageMaskAccessor() override; ITKImageMaskAccessor(ITKMaskImageType::ConstPointer aMaskImage); /*! @brief voxelization of the given structures according to the original RTToolbox algorithm*/ void updateMask() override; /*! @brief get vector conatining al relevant voxels that are inside the given structure*/ MaskVoxelListPointer getRelevantVoxelVector() override; /*! @brief get vector conatining al relevant voxels that have a relevant volume above the given threshold and are inside the given structure*/ MaskVoxelListPointer getRelevantVoxelVector(float lowerThreshold) override; /*!@brief determine how a given voxel on the dose grid is masked * @param aID ID of the voxel in grid. * @param voxel Reference to the voxel. * @post after a valid call voxel contains the information of the specified grid voxel. If aID is not valid, voxel values are undefined. * The relevant volume fraction will be set to zero. * @return Indicates of the voxel exists and therefore if parameter voxel contains valid values.*/ bool getMaskAt(const VoxelGridID aID, core::MaskVoxel& voxel) const override; bool getMaskAt(const VoxelGridIndex3D& aIndex, core::MaskVoxel& voxel) const override; /*! @brief give access to GeometricInfo*/ const core::GeometricInfo& getGeometricInfo() const override; /* @ brief is true if Mask is on a homogeneous grid */ // Inhomogeneous grids are not supported at the moment, but if they will // be supported in the future the interface does not need to change. bool isGridHomogeneous() const override { return true; }; IDType getMaskUID() const override { return _maskUID; }; }; } } } #endif diff --git a/code/io/itk/rttbITKImageMaskAccessorConverter.h b/code/io/itk/rttbITKImageMaskAccessorConverter.h index 20986ae..13459f2 100644 --- a/code/io/itk/rttbITKImageMaskAccessorConverter.h +++ b/code/io/itk/rttbITKImageMaskAccessorConverter.h @@ -1,70 +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) */ #ifndef __ITK_IMAGE_MASK_ACCESSOR_CONVERTER_H #define __ITK_IMAGE_MASK_ACCESSOR_CONVERTER_H #include "rttbITKImageMaskAccessor.h" #include "rttbMaskAccessorProcessorBase.h" #include "../itk/rttbDoseAccessorConversionSettingInterface.h" #include "RTTBITKIOExports.h" namespace rttb { namespace io { namespace itk { /*! @class ITKImageMaskAccessorConverter @brief Class converts/dumps the processed accessor into an itk image @remark MaskAccessorConversionInterface defines how the converter should react on non valid Mask values. */ class RTTBITKIO_EXPORT ITKImageMaskAccessorConverter : public core::MaskAccessorProcessorBase, public rttb::core::DoseAccessorConversionSettingInterface { public: - typedef core::MaskAccessorInterface::MaskAccessorPointer MaskAccessorPointer; + using MaskAccessorPointer = core::MaskAccessorInterface::MaskAccessorPointer; bool process() override; const ITKImageMaskAccessor::ITKMaskImageType::Pointer getITKImage() { return _itkImage; } ITKImageMaskAccessorConverter(MaskAccessorPointer accessor); ~ITKImageMaskAccessorConverter() override = default; private: ITKImageMaskAccessorConverter(const ITKImageMaskAccessorConverter&); //not implemented on purpose -> non-copyable ITKImageMaskAccessorConverter& operator=(const ITKImageMaskAccessorConverter&);//not implemented on purpose -> non-copyable ITKImageMaskAccessor::ITKMaskImageType::Pointer _itkImage; }; } } } #endif diff --git a/code/io/itk/rttbITKImageMaskAccessorGenerator.h b/code/io/itk/rttbITKImageMaskAccessorGenerator.h index 8db2104..a4e7420 100644 --- a/code/io/itk/rttbITKImageMaskAccessorGenerator.h +++ b/code/io/itk/rttbITKImageMaskAccessorGenerator.h @@ -1,68 +1,68 @@ // ----------------------------------------------------------------------- // 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 __ITK_IMAGE_MASK_ACCESSOR_GENERATOR_H #define __ITK_IMAGE_MASK_ACCESSOR_GENERATOR_H #include "rttbITKImageMaskAccessor.h" #include "rttbMaskAccessorGeneratorBase.h" #include "RTTBITKIOExports.h" namespace rttb { namespace io { namespace itk { /*! @class ITKImageMaskAccessorGenerator @brief Generate ITKImageMaskAccessor wrapping an itk image as object (not as file). */ class RTTBITKIO_EXPORT ITKImageMaskAccessorGenerator : public core::MaskAccessorGeneratorBase { public: - typedef MaskAccessorGeneratorBase::MaskAccessorPointer MaskAccessorPointer; + using MaskAccessorPointer = MaskAccessorGeneratorBase::MaskAccessorPointer; private: /** @brief The Mask as itkImage */ ITKImageMaskAccessor::ITKMaskImageType::ConstPointer _maskPtr; ITKImageMaskAccessorGenerator(); public: ~ITKImageMaskAccessorGenerator() override = default; /*! @pre aMaskImage must point to a valid instance. @exception InvalidDoseException Thrown if aMaskImage is invalid. */ ITKImageMaskAccessorGenerator(const ITKImageMaskAccessor::ITKMaskImageType* aMaskImage); /*! @brief Generate MaskAccessor @return Return shared pointer of MaskAccessor. */ MaskAccessorPointer generateMaskAccessor() override ; }; } } } #endif diff --git a/code/io/itk/rttbImageReader.h b/code/io/itk/rttbImageReader.h index d9604db..df3db02 100644 --- a/code/io/itk/rttbImageReader.h +++ b/code/io/itk/rttbImageReader.h @@ -1,224 +1,224 @@ // ----------------------------------------------------------------------- // MatchPoint - DKFZ translational registration framework // // Copyright (c) German Cancer Research Center (DKFZ), // Software development for Integrated Diagnostics and Therapy (SIDT). // ALL RIGHTS RESERVED. // See mapCopyright.txt or // http://www.dkfz.de/en/sidt/projects/MatchPoint/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) // Subversion HeadURL: $HeadURL: https://svn/sbr/Sources/SBR-Projects/MatchPoint/trunk/Code/IO/include/mapImageReader.h $ */ #ifndef __RTTB_IMAGE_READER_H #define __RTTB_IMAGE_READER_H #include "itkImage.h" #include "itkImageSource.h" namespace rttb { namespace io { namespace itk { struct ImageSeriesReadStyle { enum Type { Default = 0, //* - Depending on the file extension (DICOM images (*.dcm, *.ima): Dicom; others: None; No image file: Dicom) None = 1, //* - No series reading, only the specified file Dicom = 2, //* - Use series reader and DCMTKSeriesFileNames Numeric = 3, //* - Use series reader and NumericSeriesFileNames GDCM = 4 //* - Use series reader and GDCMSeriesFileNames }; }; /** @class ImageReader * @brief Helper class manages the loading of 2D/3D images based on itk but with some convenience features ... * * ImageReader is used to load 2D or 3D images in an itk like style, but also offers * some convenience features and the specialties of different formats into account.\n * 2D images will be loaded directly by the IO classes of itk, so in this case the * ImageReader is only a layer of abstraction.\n * 3D images will be handled different, depending on the type of files and the chosen * series read style:\n * - Default: Depending on the file extension (DICOM images (*.dcm, *.ima): Dicom; others: None; No image file: Dicom * - None: directly by the itk io (no series reading) * - Dicom: uses itk series reader, currently a list of files will be generated that is similar to GDCM (old ::itk::DICOMKSeriesFileNames is not supported any more by itk > 4.3.x.) * - GDCM: uses itk series reader, the list of files will be generated * by the ::itk::GDCMSeriesFileNames in the specified path ordered by * imagePositionPatient. * - Numeric: Will be considered as series of images. The list of files will be * created by ::itk::NumericSeriesFileNames, so in this case the given * file name is already masked by %d for the increasing index within * the file name. * . * @note code copied from MatchPoint, see documentation (http://sourceforge.net/projects/matchpoint/) */ template class ImageReader { public: typedef ::itk::Image InputImageType; typedef ::itk::Image OutputImageType; - typedef TInputPixel RescaleValueType; - typedef std::vector< ::itk::MetaDataDictionary> MetaDataDictionaryArrayType; + using RescaleValueType = TInputPixel; + using MetaDataDictionaryArrayType = std::vector< ::itk::MetaDataDictionary>; - typedef std::string String; + using String = std::string; - typedef std::ostringstream OStringStream; - typedef std::istringstream IStringStream; + using OStringStream = std::ostringstream; + using IStringStream = std::istringstream; virtual const char* GetNameOfClass() const { return "ImageReader"; } private: /** Loaded Image.*/ typename OutputImageType::Pointer _spImage; /** The file name of the image. */ String _fileName; /** The upper limit for the searching of series files in the path.*/ unsigned int _upperSeriesLimit; /** Indicates if the image data is up to date or should be read again.*/ bool _upToDate; /** Indicates if the output image intensity should be rescaled.*/ bool _rescaleImage; /** Indicates the minimum of the output.*/ RescaleValueType _rescaleMin; /** Indicates the maximum of the output.*/ RescaleValueType _rescaleMax; /** Defines if the specified image file is part of a series and the * whole series should be read into one image. Only relevant for 3D images.*/ typename ImageSeriesReadStyle::Type _seriesReadStyle; MetaDataDictionaryArrayType _dictionaryArray; void load2D(); typename ::itk::ImageSource::Pointer prepareNumericSource() const; typename ::itk::ImageSource::Pointer prepareDICOMSource() const; typename ::itk::ImageSource::Pointer prepareNormalSource() const; typename ::itk::ImageSource::Pointer prepareGDCMSource() const; void load3D(); - typedef std::vector< ::itk::MetaDataDictionary*> ITKMetaDataDictionaryArray; + using ITKMetaDataDictionaryArray = std::vector< ::itk::MetaDataDictionary *>; void copyMetaDictionaryArray(const ITKMetaDataDictionaryArray* fromArray, MetaDataDictionaryArrayType& toArray); public: /** Function to access the member variable _FileName. _FileName represents the filename of the * headerfile. The path must be included, the file extension may left away. * @return File name of the header file.*/ const String& getFileName() const; /** Function to access the member variable _FileName. _FileName represents the filename of the * headerfile. The path must be included, the file extension may left away. * @param [in] sFileName The file name of the header file.*/ void setFileName(const String& sFileName); /** Function to access the member variable _rescaleMin. _rescaleMin represents * the minimum of the intensity rescale filter. * @return The minimum of the intensity rescale filter.*/ const RescaleValueType& getRescaleMinimum() const; /** Function to access the member variable _rescaleMin. _rescaleMin represents * the minimum of the intensity rescale filter. Changing the rescale minimum out dates the ImageReader. * @param [in] rescaleMin The minimum of the intensity rescale filter.*/ void setRescaleMinimum(const RescaleValueType& rescaleMin); /** Function to access the member variable _rescaleMin. _rescaleMax represents * the minimum of the intensity rescale filter. * @return The minimum of the intensity rescale filter.*/ const RescaleValueType& getRescaleMaximum() const; /** Function to access the member variable _rescaleMin. _rescaleMax represents * the minimum of the intensity rescale filter. Changing the rescale maximum out dates the ImageReader. * @param [in] rescaleMax The minimum of the intensity rescale filter.*/ void setRescaleMaximum(const RescaleValueType& rescaleMax); /** Function to access the member variable _rescaleImage. _rescaleImage indicates if a * loaded image should be rescaled regarding its intensities. * @return If the ImageReader converts images to iso-voxel.*/ const bool getRescaleImage() const; /** Function to access the member variable _rescaleImage. _rescaleImage indicates if a * loaded image should be rescaled regarding its intensities. Changing the rescale option out dates the ImageReader. * @param [in] rescaleImage Specifies if image should be converted to isovoxel.*/ void setRescaleImage(const bool rescaleImage); /** Function to access the member variable _upperSeriesLimit. _upperSeriesLimit represents * the upper limit for the series file search. * @return The upper limit of the series search.*/ const unsigned int getUpperSeriesLimit() const; /** Function to access the member variable _upperSeriesLimit. _upperSeriesLimit represents * the upper limit for the series file search. Changing the series limit out dates the ImageReader. * @remark It is only relevant if series style is set to "Numeric". * @param [in] upperLimit The upper limit of the header file.*/ void setUpperSeriesLimit(const unsigned int upperLimit); /** Function to access the member variable _seriesReadStyle (see member description for more information).*/ const typename ImageSeriesReadStyle::Type getSeriesReadStyle() const; /** Function to access the member variable _seriesReadStyle (see member description for more information). * Changing the style out dates the ImageReader.*/ void setSeriesReadStyle(typename ImageSeriesReadStyle::Type readStyle); /** Function loads the image if needed and returns the data. * @return Pointer to loaded image.*/ OutputImageType* GetOutput(); /** Function returns the reference to the meta data dictionary(ies) of the latest file(s) loaded by this class. * Array may be empty if no MetaDictionary exists.*/ const MetaDataDictionaryArrayType& getMetaDictionaryArray(); ImageReader(); virtual ~ImageReader(); }; /** * @brief Helper function for the use of ImageReader in on statement ... * * for specific informations please see the documentation of ImageReader. * @param pLoadedDictArray Pass a pointer to valid array to receive the meta dictionaries * loaded with the image. If the pointer is null, no dictionaries will be transfered. The array * will be reseted before the loaded dictionaries will be added. * @sa ImageReader * @ingroup Utils */ template typename ImageReader::OutputImageType::Pointer readImage(const std::string& fileName, ImageSeriesReadStyle::Type readStyle = ImageSeriesReadStyle::Default, bool rescaleImage = false, typename ImageReader::RescaleValueType rescaleMin = 0, typename ImageReader::RescaleValueType rescaleMax = 255, unsigned int upperNumericSeriesLimit = 100, typename ImageReader::MetaDataDictionaryArrayType* pLoadedDictArray = NULL); }//end namespace itk }//end namespace io }//end namespace rttb #include "rttbImageReader.tpp" #endif diff --git a/code/io/itk/rttbImageReader.tpp b/code/io/itk/rttbImageReader.tpp index c9b460f..2611246 100644 --- a/code/io/itk/rttbImageReader.tpp +++ b/code/io/itk/rttbImageReader.tpp @@ -1,532 +1,532 @@ // ----------------------------------------------------------------------- // MatchPoint - DKFZ translational registration framework // // Copyright (c) German Cancer Research Center (DKFZ), // Software development for Integrated Diagnostics and Therapy (SIDT). // ALL RIGHTS RESERVED. // See mapCopyright.txt or // http://www.dkfz.de/en/sidt/projects/MatchPoint/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) // Subversion HeadURL: $HeadURL: https://svn/sbr/Sources/SBR-Projects/MatchPoint/trunk/Code/IO/include/mapImageReader.tpp $ */ #ifndef __RTTB_IMAGE_READER_TPP #define __RTTB_IMAGE_READER_TPP #include "rttbImageReader.h" #include "rttbFileDispatch.h" #include "RTToolboxConfigure.h" #ifdef RTTB_DISABLE_ITK_IO_FACTORY_AUTO_REGISTER #undef ITK_IO_FACTORY_REGISTER_MANAGER #endif #include "itkImageFileReader.h" #include "itkImageSeriesReader.h" #include "itkImageSeriesWriter.h" #include "itkNumericSeriesFileNames.h" #include "itkGDCMSeriesFileNames.h" #include "itkRescaleIntensityImageFilter.h" #include "itkCastImageFilter.h" #include "itkFixedArray.h" #include "itksys/SystemTools.hxx" #include #include namespace rttb { namespace io { namespace itk { template void ImageReader:: load2D() { - typedef ::itk::ImageFileReader< InputImageType > ImageReaderType; + using ImageReaderType = ::itk::ImageFileReader< InputImageType >; typedef ::itk::RescaleIntensityImageFilter< InputImageType, InputImageType > RescaleFilterType; typedef ::itk::CastImageFilter< InputImageType, OutputImageType > CastFilterType; typename CastFilterType::Pointer imageCaster = CastFilterType::New(); typename ImageReaderType::Pointer imageReader = ImageReaderType::New(); typename RescaleFilterType::Pointer rescaleFilter = RescaleFilterType::New(); rescaleFilter->SetOutputMinimum(static_cast(_rescaleMin)); rescaleFilter->SetOutputMaximum(static_cast(_rescaleMax)); imageReader->SetFileName(_fileName.c_str()); rescaleFilter->SetInput(imageReader->GetOutput()); if (_rescaleImage) { imageCaster->SetInput(rescaleFilter->GetOutput()); } else { imageCaster->SetInput(imageReader->GetOutput()); } _spImage = imageCaster->GetOutput(); imageCaster->Update(); _dictionaryArray.clear(); _dictionaryArray.push_back(imageReader->GetImageIO()->GetMetaDataDictionary()); _upToDate = true; }; template const typename ImageReader::MetaDataDictionaryArrayType& ImageReader:: getMetaDictionaryArray() { return _dictionaryArray; }; template void ImageReader:: copyMetaDictionaryArray(const ITKMetaDataDictionaryArray* fromArray, MetaDataDictionaryArrayType& toArray) { toArray.clear(); auto itr = fromArray->begin(); auto end = fromArray->end(); while (itr != end) { toArray.push_back(*(*itr)); ++itr; } }; template typename ::itk::ImageSource::InputImageType>::Pointer ImageReader:: prepareNumericSource() const { //mumeric series image reader - typedef ::itk::ImageSeriesReader< InputImageType > SeriesReaderType; - typedef ::itk::NumericSeriesFileNames NamesType; + using SeriesReaderType = ::itk::ImageSeriesReader; + using NamesType = ::itk::NumericSeriesFileNames; typename SeriesReaderType::Pointer seriesReader = SeriesReaderType::New(); NamesType::Pointer names = NamesType::New(); names->SetStartIndex(1); names->SetEndIndex(_upperSeriesLimit); names->SetSeriesFormat(_fileName.c_str()); seriesReader->SetFileNames(names->GetFileNames()); if (seriesReader->GetFileNames().size() == 0) { throw ::itk::ExceptionObject("Image reader is not correctly configured. Preparing a series reading of a numeric source no(!) files were found."); } typename ::itk::ImageSource::InputImageType>::Pointer genericReader = seriesReader.GetPointer(); return genericReader; }; template typename ::itk::ImageSource::InputImageType>::Pointer ImageReader:: prepareDICOMSource() const { //ITK > v4.3.x removed old DICOMSeriesFileNames. Thus currently only support GDCM as source by default return prepareGDCMSource(); }; template typename ::itk::ImageSource::InputImageType>::Pointer ImageReader:: prepareGDCMSource() const { core::FileDispatch dispatch(_fileName); FileNameString dir = dispatch.getPath(); FileNameString strippedFileName = dispatch.getFullName(); - typedef ::itk::GDCMSeriesFileNames NamesGeneratorType; + using NamesGeneratorType = ::itk::GDCMSeriesFileNames; NamesGeneratorType::Pointer nameGenerator = NamesGeneratorType::New(); nameGenerator->SetInputDirectory(dir); nameGenerator->SetUseSeriesDetails(true); ::itk::FilenamesContainer fileNames; if (strippedFileName.empty()) { std::cerr << "No file name specified. Use first DICOM series found in directory." << std::endl; fileNames = nameGenerator->GetInputFileNames(); } else { ::itk::SerieUIDContainer seriesUIDs = nameGenerator->GetSeriesUIDs(); std::cerr << "Checking found DICOM series." << std::endl; //check the found series for the filename to pick the right series correlated to the passed filename while (seriesUIDs.size() > 0) { fileNames = nameGenerator->GetFileNames(seriesUIDs.back()); std::cerr << "Checking series: " << seriesUIDs.back() << " (file count: " << fileNames.size() << ")" << std::endl; seriesUIDs.pop_back(); for (::itk::SerieUIDContainer::const_iterator pos = fileNames.begin(); pos != fileNames.end(); ++pos) { if (pos->find(strippedFileName) != FileNameString::npos) { //this series containes the passed filename -> //we have the right block of files -> we are done. std::cerr << "Found right series!" << std::endl; seriesUIDs.clear(); break; } } } } - typedef ::itk::ImageSeriesReader< InputImageType > SeriesReaderType; + using SeriesReaderType = ::itk::ImageSeriesReader; typename SeriesReaderType::Pointer seriesReader = SeriesReaderType::New(); seriesReader->SetFileNames(fileNames); if (seriesReader->GetFileNames().size() == 0) { throw ::itk::ExceptionObject("Image reader is not correctly configured. Preparing a series reading of a DICOM source no(!) dicom files were found. search location: " + _fileName); } typename ::itk::ImageSource::InputImageType>::Pointer genericReader = seriesReader.GetPointer(); return genericReader; }; template typename ::itk::ImageSource::InputImageType>::Pointer ImageReader:: prepareNormalSource() const { //Normal image reader (no series read style) - typedef ::itk::ImageFileReader< InputImageType > ImageReaderType; + using ImageReaderType = ::itk::ImageFileReader< InputImageType >; typename ImageReaderType::Pointer imageReader = ImageReaderType::New(); imageReader->SetFileName(_fileName.c_str()); typename ::itk::ImageSource::InputImageType>::Pointer genericReader = imageReader.GetPointer(); return genericReader; }; template void ImageReader:: load3D() { core::FileDispatch dispatch(_fileName); FileNameString sTemp = dispatch.getExtension(); //Convert to lowercase for (char & spos : sTemp) { spos = std::tolower(spos, std::locale("")); } typedef ::itk::RescaleIntensityImageFilter< InputImageType, InputImageType > RescaleFilterType; typedef ::itk::CastImageFilter< InputImageType, OutputImageType > CastFilterType; typename CastFilterType::Pointer imageCaster = CastFilterType::New(); typename RescaleFilterType::Pointer rescaleFilter = RescaleFilterType::New(); typename ::itk::ImageSource::Pointer spReader; rescaleFilter->SetOutputMinimum(static_cast(_rescaleMin)); rescaleFilter->SetOutputMaximum(static_cast(_rescaleMax)); if (_seriesReadStyle == ImageSeriesReadStyle::Numeric) { spReader = prepareNumericSource(); } else if (_seriesReadStyle == ImageSeriesReadStyle::Dicom) { spReader = prepareDICOMSource(); } else if (_seriesReadStyle == ImageSeriesReadStyle::GDCM) { spReader = prepareGDCMSource(); } else if (_seriesReadStyle == ImageSeriesReadStyle::Default) { bool isDir = itksys::SystemTools::FileIsDirectory(_fileName.c_str()); if (isDir || sTemp == ".dcm" || sTemp == ".ima") { spReader = prepareDICOMSource(); } else { spReader = prepareNormalSource(); } } else { //style is none spReader = prepareNormalSource(); } if (_rescaleImage) { rescaleFilter->SetInput(spReader->GetOutput()); imageCaster->SetInput(rescaleFilter->GetOutput()); } else { imageCaster->SetInput(spReader->GetOutput()); } imageCaster->Update(); _spImage = imageCaster->GetOutput(); - typedef ::itk::ImageFileReader< InputImageType > ImageReaderType; - typedef ::itk::ImageSeriesReader< InputImageType > ImageSeriesReaderType; + using ImageReaderType = ::itk::ImageFileReader< InputImageType >; + using ImageSeriesReaderType = ::itk::ImageSeriesReader; auto* pFileReader = dynamic_cast(spReader.GetPointer()); auto* pSeriesReader = dynamic_cast(spReader.GetPointer()); if (pFileReader) { _dictionaryArray.clear(); _dictionaryArray.push_back(pFileReader->GetImageIO()->GetMetaDataDictionary()); } else if (pSeriesReader) { copyMetaDictionaryArray(pSeriesReader->GetMetaDataDictionaryArray(), _dictionaryArray); } else { throw ::itk::ExceptionObject("Image reader is not valid. Internal reader seams not to be itk::ImageFileReader or itk::ImageSeriesReader."); } _upToDate = true; }; template const FileNameString& ImageReader:: getFileName() const { return _fileName; }; template void ImageReader:: setFileName(const FileNameString& fileName) { if (fileName != _fileName) { _upToDate = false; _fileName = fileName; } } template const typename ImageReader::RescaleValueType& ImageReader:: getRescaleMinimum() const { return _rescaleMin; }; template void ImageReader:: setRescaleMinimum(const RescaleValueType& dRescaleMin) { if (dRescaleMin != _rescaleMin) { _upToDate = false; _rescaleMin = dRescaleMin; }; }; template const typename ImageReader::RescaleValueType& ImageReader:: getRescaleMaximum() const { return _rescaleMax; }; template void ImageReader:: setRescaleMaximum(const RescaleValueType& dRescaleMax) { if (dRescaleMax != _rescaleMax) { _upToDate = false; _rescaleMax = dRescaleMax; }; }; template const bool ImageReader:: getRescaleImage() const { return _rescaleImage; }; template void ImageReader:: setRescaleImage(const bool rescaleImage) { if (rescaleImage != _rescaleImage) { _upToDate = false; _rescaleImage = rescaleImage; }; }; template const unsigned int ImageReader:: getUpperSeriesLimit() const { return _upperSeriesLimit; }; template void ImageReader:: setUpperSeriesLimit(const unsigned int upperLimit) { if (upperLimit != _upperSeriesLimit) { _upToDate = false; _upperSeriesLimit = upperLimit; }; }; template const ImageSeriesReadStyle::Type ImageReader:: getSeriesReadStyle() const { return _seriesReadStyle; }; template void ImageReader:: setSeriesReadStyle(ImageSeriesReadStyle::Type readStyle) { if (readStyle != _seriesReadStyle) { _upToDate = false; _seriesReadStyle = readStyle; }; }; template typename ImageReader::OutputImageType* ImageReader:: GetOutput() { if (!_upToDate) { switch (OutputImageType::GetImageDimension()) { case 2: load2D(); break; case 3: load3D(); break; default: throw ::itk::ExceptionObject("Image reader only accepts 2 or 3 dimensional images."); }; }; return _spImage; }; template ImageReader:: ImageReader() { _fileName = ""; _upperSeriesLimit = 255; _upToDate = false; _rescaleImage = false; _rescaleMax = 255; _rescaleMin = 0; _seriesReadStyle = ImageSeriesReadStyle::Default; }; template ImageReader:: ~ImageReader() = default; template typename ImageReader::OutputImageType::Pointer readImage( const FileNameString& fileName, ImageSeriesReadStyle::Type readStyle, bool rescaleImage, typename ImageReader::RescaleValueType rescaleMin, typename ImageReader::RescaleValueType rescaleMax, unsigned int upperNumericSeriesLimit, typename ImageReader::MetaDataDictionaryArrayType* pLoadedDictArray) { ImageReader reader; reader.setFileName(fileName); reader.setSeriesReadStyle(readStyle); reader.setRescaleImage(rescaleImage); reader.setRescaleMaximum(rescaleMax); reader.setRescaleMinimum(rescaleMin); reader.setUpperSeriesLimit(upperNumericSeriesLimit); typename ImageReader::OutputImageType::Pointer spResult = reader.GetOutput(); if (pLoadedDictArray) { *pLoadedDictArray = reader.getMetaDictionaryArray(); }; return spResult; }; } } } #endif diff --git a/code/io/itk/rttbImageWriter.h b/code/io/itk/rttbImageWriter.h index 526cf9a..70778fa 100644 --- a/code/io/itk/rttbImageWriter.h +++ b/code/io/itk/rttbImageWriter.h @@ -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) */ #ifndef __RTTB_IMAGE_WRITER_H #define __RTTB_IMAGE_WRITER_H #include "RTToolboxConfigure.h" #ifdef RTTB_DISABLE_ITK_IO_FACTORY_AUTO_REGISTER #undef ITK_IO_FACTORY_REGISTER_MANAGER #endif #include "itkImage.h" #include "itkImageFileWriter.h" #include "rttbBaseType.h" #include "RTTBITKIOExports.h" namespace rttb { namespace io { namespace itk { /** @class ImageWriter * @brief Helper class writing 3D images to file ... * */ class RTTBITKIO_EXPORT ImageWriter { typedef ::itk::Image ITKMaskImageType; - typedef ITKMaskImageType::ConstPointer ITKImageTypeConstPointer; - typedef ::itk::ImageFileWriter WriterType; + using ITKImageTypeConstPointer = ITKMaskImageType::ConstPointer; + using WriterType = ::itk::ImageFileWriter; private: FileNameString _fileName; ITKImageTypeConstPointer _itkImage; public: ImageWriter(const FileNameString& aFileName, ITKImageTypeConstPointer aITKImage); /*! @brief Write itk image to file @return Return true if successful. @exception InvalidParameterException thrown if itk exception by writing the image */ bool writeFile(); }; }//end namespace itk }//end namespace io }//end namespace rttb #endif diff --git a/code/io/other/rttbDVHTxtFileWriter.h b/code/io/other/rttbDVHTxtFileWriter.h index fad9274..1c7ff50 100644 --- a/code/io/other/rttbDVHTxtFileWriter.h +++ b/code/io/other/rttbDVHTxtFileWriter.h @@ -1,75 +1,75 @@ // ----------------------------------------------------------------------- // RTToolbox - DKFZ radiotherapy quantitative evaluation library // // Copyright (c) German Cancer Research Center (DKFZ), // Software development for Integrated Diagnostics and Therapy (SIDT). // ALL RIGHTS RESERVED. // See rttbCopyright.txt or // http://www.dkfz.de/en/sidt/projects/rttb/copyright.html // // This software is distributed WITHOUT ANY WARRANTY; without even // the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // PURPOSE. See the above copyright notices for more information. // //------------------------------------------------------------------------ /*! // @file // @version $Revision$ (last changed revision) // @date $Date$ (last change date) // @author $Author$ (last changed by) */ #ifndef __DVH_TXT_FILE_WRITER_H #define __DVH_TXT_FILE_WRITER_H #include "rttbDVH.h" #include "../rttbDVHWriterInterface.h" #include "rttbBaseType.h" namespace rttb { namespace io { namespace other { /*! @class DVHTxtFileWriter @brief Writes DVHs to simple text files. @deprecated Please use DVHXMLFileWriter. */ class DVHTxtFileWriter: public DVHWriterInterface { public: - typedef core::DVH::DataDifferentialType DataDifferentialType; - typedef core::DVH::DVHPointer DVHPointer; + using DataDifferentialType = core::DVH::DataDifferentialType; + using DVHPointer = core::DVH::DVHPointer; private: FileNameString _fileName; DVHType _dvhType; public: /*! @brief Constructor @param aFileName a .txt file name to write the DVH to aDVHType: DIFFERENTIAL or CUMULATIVE. */ DVHTxtFileWriter(FileNameString aFileName, DVHType aDVHType); void setFileName(FileNameString aFileName); FileNameString getFileName() const; void setDVHType(DVHType aDVHType); DVHType getDVHType() const; /*! @brief Write aDvh to txt file with the name: _fileName @exception NullPointerException Thrown if _aDvh is nullptr @exception InvalidParameterException Thrown if _fileName invalid: could not open; or if _dvhType invalid: only DIFFERENTIAL or CUMULATIVE is accepted! @exception Exception thrown if dvh init error @exception InvalidParameterException Thrown if normalized is true. This feature is not implemented because this Writer is deprecated. */ void writeDVH(DVHPointer aDvh, bool normalized = false) override; }; } } } #endif diff --git a/code/io/other/rttbDVHXMLFileWriter.h b/code/io/other/rttbDVHXMLFileWriter.h index be60a5d..23016c5 100644 --- a/code/io/other/rttbDVHXMLFileWriter.h +++ b/code/io/other/rttbDVHXMLFileWriter.h @@ -1,75 +1,75 @@ // ----------------------------------------------------------------------- // RTToolbox - DKFZ radiotherapy quantitative evaluation library // // Copyright (c) German Cancer Research Center (DKFZ), // Software development for Integrated Diagnostics and Therapy (SIDT). // ALL RIGHTS RESERVED. // See rttbCopyright.txt or // http://www.dkfz.de/en/sidt/projects/rttb/copyright.html // // This software is distributed WITHOUT ANY WARRANTY; without even // the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // PURPOSE. See the above copyright notices for more information. // //------------------------------------------------------------------------ /*! // @file // @version $Revision$ (last changed revision) // @date $Date$ (last change date) // @author $Author$ (last changed by) */ #ifndef __DVH_XML_FILE_WRITER_H #define __DVH_XML_FILE_WRITER_H #include "rttbDVH.h" #include "../rttbDVHWriterInterface.h" #include "rttbBaseType.h" #include "RTTBOtherIOExports.h" namespace rttb { namespace io { namespace other { /*! @class DVHXMLFileWriter @brief Writes DVHs to xml files. */ class RTTBOtherIO_EXPORT DVHXMLFileWriter : public DVHWriterInterface { public: - typedef core::DVH::DataDifferentialType DataDifferentialType; - typedef core::DVH::DVHPointer DVHPointer; + using DataDifferentialType = core::DVH::DataDifferentialType; + using DVHPointer = core::DVH::DVHPointer; private: FileNameString _fileName; DVHType _dvhType; public: /*! @brief Constructor @param aFileName a xml file name to write @param aDVHType: DIFFERENTIAL or CUMULATIVE. */ DVHXMLFileWriter(FileNameString aFileName, DVHType aDVHType); void setFileName(FileNameString aFileName); FileNameString getFileName() const; void setDVHType(DVHType aDVHType); DVHType getDVHType() const; /*! @brief Write aDvh to xml file with the name: _fileName @exception NullPointerException Thrown if _aDvh is nullptr @exception InvalidParameterException Thrown if _fileName invalid: could not open; or if _dvhType invalid: only DIFFERENTIAL or CUMULATIVE is accepted! @exception Exception thrown if dvh init error */ void writeDVH(DVHPointer aDvh, bool normalized = false) override; }; } } } #endif diff --git a/code/io/other/rttbDoseStatisticsXMLReader.cpp b/code/io/other/rttbDoseStatisticsXMLReader.cpp index ac892e7..41c1293 100644 --- a/code/io/other/rttbDoseStatisticsXMLReader.cpp +++ b/code/io/other/rttbDoseStatisticsXMLReader.cpp @@ -1,222 +1,222 @@ // ----------------------------------------------------------------------- // 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: 1328 $ (last changed revision) // @date $Date: 2016-04-22 09:50:01 +0200 (Fr, 22 Apr 2016) $ (last change date) // @author $Author: hentsch $ (last changed by) */ #include #include #include #include #include #include #include "rttbDoseStatisticsXMLReader.h" #include "rttbInvalidParameterException.h" #include "rttbVolumeToDoseMeasureCollection.h" namespace rttb { namespace io { namespace other { - typedef boost::shared_ptr DoseStatisticsPtr; + using DoseStatisticsPtr = boost::shared_ptr; DoseStatisticsXMLReader::DoseStatisticsXMLReader(const std::string& filename) : _filename(filename), _newFile(true) { } DoseStatisticsXMLReader::~DoseStatisticsXMLReader() = default; void DoseStatisticsXMLReader::setFilename(const std::string& filename) { _filename = filename; _newFile = true; } DoseStatisticsPtr DoseStatisticsXMLReader::generateDoseStatistic() { if (_newFile) { this->createDoseStatistic(); } return _doseStatistic; } void DoseStatisticsXMLReader::createDoseStatistic() { boost::property_tree::ptree pt; // Load the XML file into the property tree. If reading fails // (cannot open file, parse error), an exception is thrown. try { read_xml(_filename, pt); } catch (boost::property_tree::xml_parser_error& /*e*/) { throw rttb::core::InvalidParameterException("DoseStatistics file name invalid: could not open the xml file!"); } // data to fill the parameter for the DoseStatistics std::string name; std::string datum; unsigned int x; std::pair voxelid; std::vector < std::pair> vec; //initialize all parameters for the DoseStatistics double minimum=-1; double maximum=-1; double numVoxels=-1; double volume=-1; double referenceDose = -1; double mean=-1; double stdDeviation=-1; boost::shared_ptr > > minimumVoxelPositions = nullptr; boost::shared_ptr > > maximumVoxelPositions = nullptr; rttb::algorithms::VolumeToDoseMeasureCollection Dx(rttb::algorithms::VolumeToDoseMeasureCollection::Dx); rttb::algorithms::DoseToVolumeMeasureCollection Vx(rttb::algorithms::DoseToVolumeMeasureCollection::Vx); rttb::algorithms::VolumeToDoseMeasureCollection MOHx(rttb::algorithms::VolumeToDoseMeasureCollection::MOHx); rttb::algorithms::VolumeToDoseMeasureCollection MOCx(rttb::algorithms::VolumeToDoseMeasureCollection::MOCx); rttb::algorithms::VolumeToDoseMeasureCollection MaxOHx(rttb::algorithms::VolumeToDoseMeasureCollection::MaxOHx); rttb::algorithms::VolumeToDoseMeasureCollection MinOCx(rttb::algorithms::VolumeToDoseMeasureCollection::MinOCx); BOOST_FOREACH(boost::property_tree::ptree::value_type & data, pt.get_child("statistics.results")) { datum = data.second.data(); BOOST_FOREACH(boost::property_tree::ptree::value_type & middle, data.second) { BOOST_FOREACH(boost::property_tree::ptree::value_type & innernode, middle.second) { std::string mia = innernode.first; if (innernode.first == "name") { name = innernode.second.data(); } else if (innernode.first == "voxelGridID") { boost::replace_all(datum, "\r\n", ""); boost::replace_all(datum, "\n", ""); boost::trim(datum); voxelid.first = boost::lexical_cast(datum); voxelid.second = boost::lexical_cast(innernode.second.data()); vec.push_back(voxelid); } else if (innernode.first == "x") { x = boost::lexical_cast(innernode.second.data()); } } } // fill with the extracted data if (name == "numberOfVoxels") { numVoxels = boost::lexical_cast(datum); } else if (name == "volume") { volume = boost::lexical_cast(datum); Dx.setVolume(volume); MOHx.setVolume(volume); MOCx.setVolume(volume); MaxOHx.setVolume(volume); } else if (name == "referenceDose") { referenceDose = boost::lexical_cast(datum); Vx.setReferenceDose(referenceDose); } else if (name == "mean") { mean = boost::lexical_cast(datum); } else if (name == "standardDeviation") { stdDeviation = boost::lexical_cast(datum); } else if (name == "minimum") { minimum = boost::lexical_cast(datum); if (!vec.empty()) { minimumVoxelPositions = boost::make_shared>>(vec); vec.clear(); } } else if (name == "maximum") { maximum = boost::lexical_cast(datum); if (!vec.empty()) { maximumVoxelPositions = boost::make_shared>>(vec); vec.clear(); } } else if (name == "Dx") { Dx.insertValue(static_cast(x)*volume / 100, boost::lexical_cast(datum)); } else if (name == "Vx") { Vx.insertValue(static_cast(x)*referenceDose / 100, boost::lexical_cast(datum)); } else if (name == "MOHx") { MOHx.insertValue(static_cast(x)*volume / 100, boost::lexical_cast(datum)); } else if (name == "MOCx") { MOCx.insertValue(static_cast(x)*volume / 100, boost::lexical_cast(datum)); } else if (name == "MaxOHx") { MaxOHx.insertValue(static_cast(x)*volume / 100, boost::lexical_cast(datum)); } else if (name == "MinOCx") { MinOCx.insertValue(static_cast(x)*volume / 100, boost::lexical_cast(datum)); } } // make DoseStatistcs _doseStatistic = boost::make_shared( minimum, maximum, mean, stdDeviation, numVoxels, volume, minimumVoxelPositions, maximumVoxelPositions , Dx, Vx, MOHx, MOCx, MaxOHx, MinOCx, referenceDose); } }//end namespace other }//end namespace io }//end namespace rttb diff --git a/code/io/other/rttbDoseStatisticsXMLReader.h b/code/io/other/rttbDoseStatisticsXMLReader.h index aa240c2..fe78681 100644 --- a/code/io/other/rttbDoseStatisticsXMLReader.h +++ b/code/io/other/rttbDoseStatisticsXMLReader.h @@ -1,69 +1,69 @@ // ----------------------------------------------------------------------- // 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: 1250 $ (last changed revision) // @date $Date: 2016-02-18 15:25:55 +0100 (Do, 18 Feb 2016) $ (last change date) // @author $Author: zhangl $ (last changed by) */ #ifndef __DOSE_STATISTICS_XML_READER_H #define __DOSE_STATISTICS_XML_READER_H #include "rttbDoseStatistics.h" /*boost includes*/ #include namespace rttb { namespace io { namespace other { /*! @class DoseStatisticsXMLReader @brief Reads a dose statistics XML into a DoseStatistics object */ class DoseStatisticsXMLReader{ public: - typedef boost::shared_ptr DoseStatisticsPtr; + using DoseStatisticsPtr = boost::shared_ptr; DoseStatisticsXMLReader(const std::string& filename); ~DoseStatisticsXMLReader(); void setFilename(const std::string& filename); /*! @brief Generate a Model, createModel() will be called @return Return new shared pointer of a Model. @exception InvalidParameterException Thrown if _filename invalid */ DoseStatisticsPtr generateDoseStatistic(); private: std::string _filename; bool _newFile; DoseStatisticsPtr _doseStatistic; /*! @brief Create new Model object using the info from model xml file @exception InvalidParameterException Thrown if _filename invalid */ void createDoseStatistic(); }; } } } #endif diff --git a/code/io/other/rttbDoseStatisticsXMLWriter.h b/code/io/other/rttbDoseStatisticsXMLWriter.h index 634a316..d9cb436 100644 --- a/code/io/other/rttbDoseStatisticsXMLWriter.h +++ b/code/io/other/rttbDoseStatisticsXMLWriter.h @@ -1,98 +1,98 @@ // ----------------------------------------------------------------------- // 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_STATISTICS_XML_WRITER_H #define __DOSE_STATISTICS_XML_WRITER_H #include "rttbDoseStatistics.h" #include #include #include "RTTBOtherIOExports.h" namespace rttb { namespace io { namespace other { - typedef boost::shared_ptr DoseStatisticsPtr; + using DoseStatisticsPtr = boost::shared_ptr; /*! @brief Write statistics to boost::property_tree::ptree. @param aDoseStatistics DoseStatistics to write @pre aReferenceDose must >0 @exception rttb::core::InvalidParameterException Thrown if aReferenceDose<=0 or xml_parse_error @note The precision is float */ boost::property_tree::ptree RTTBOtherIO_EXPORT writeDoseStatistics(DoseStatisticsPtr aDoseStatistics); /*! @brief Write statistics to String. @param aDoseStatistics DoseStatistics to write @pre aReferenceDose must >0 @exception rttb::core::InvalidParameterException Thrown if aReferenceDose<=0 or xml_parse_error @note The precision is float */ XMLString RTTBOtherIO_EXPORT writerDoseStatisticsToString(DoseStatisticsPtr aDoseStatistics); /*! @brief Write statistics to xml file. @details includes the following statistics: - numberOfVoxels, - volume, - minimum, - maximum, - mean, - standard deviation, - variance, - D2,D5,D10,D90,D95,D98, - V2,V5,V10,V90,V95,V98, - MOH2,MOH5,MOH10, - MOC2,MOC5,MOC10, - MaxOH2,MaxOH5,MaxOH10, - MinOC2,MinOC5,MinOC10. @param aDoseStatistics DoseStatistics to write @param aFileName To write dose statistics @pre aReferenceDose must >0 @exception rttb::core::InvalidParameterException Thrown if aReferenceDose<=0 or xml_parse_error @note The precision is float */ void RTTBOtherIO_EXPORT writeDoseStatistics(DoseStatisticsPtr aDoseStatistics, FileNameString aFileName); boost::property_tree::ptree RTTBOtherIO_EXPORT createNodeWithNameAttribute(DoseTypeGy doseValue, const std::string& attributeName); boost::property_tree::ptree RTTBOtherIO_EXPORT createNodeWithNameAndXAttribute(DoseTypeGy doseValue, const std::string& attributeName, int xValue); /*! @brief Write statistics to String to generate a table @details The table is: "Volume mm3@Max@Min@Mean@Std.Dev.@Variance@D2@D5@D10@D90@D95@D98@V2@V5@V10@V90@V95@V98@MOH2@MOH5@MOH10@MOC2@MOC5@MOC10@MaxOH2@MaxOH5@MaxOH10@MinOC2@MinOC5@MinOC10" @param aDoseStatistics DoseStatistics to write @pre aReferenceDose must >0 @exception rttb::core::InvalidParameterException Thrown if aReferenceDose<=0 or xml_parse_error @note is used for the Mevislab-Linking of RTTB @note The precision is float */ StatisticsString RTTBOtherIO_EXPORT writerDoseStatisticsToTableString(DoseStatisticsPtr aDoseStatistics); double RTTBOtherIO_EXPORT convertToPercent(double value, double maximum); } } } #endif diff --git a/code/io/rttbDVHWriterInterface.h b/code/io/rttbDVHWriterInterface.h index e971255..1880b54 100644 --- a/code/io/rttbDVHWriterInterface.h +++ b/code/io/rttbDVHWriterInterface.h @@ -1,48 +1,48 @@ // ----------------------------------------------------------------------- // 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_WRITER_INTERFACE_H #define __DVH_WRITER_INTERFACE_H #include "rttbDVH.h" #include "RTTBOtherIOExports.h" namespace rttb { namespace io { /*! @class DVHWriterInterface @brief Interface for classes that write DVH data to files. */ class RTTBOtherIO_EXPORT DVHWriterInterface { - typedef core::DVH::DVHPointer DVHPointer; + using DVHPointer = core::DVH::DVHPointer; /*! @brief Write aDvh */ public: virtual void writeDVH(DVHPointer aDvh, bool normalized = false) = 0; }; } } #endif diff --git a/code/io/utils/rttbStructLoader.cpp b/code/io/utils/rttbStructLoader.cpp index 8d55856..897ebc4 100644 --- a/code/io/utils/rttbStructLoader.cpp +++ b/code/io/utils/rttbStructLoader.cpp @@ -1,86 +1,86 @@ // ----------------------------------------------------------------------- // RTToolbox - DKFZ radiotherapy quantitative evaluation library // // Copyright (c) German Cancer Research Center (DKFZ), // Software development for Integrated Diagnostics and Therapy (SIDT). // ALL RIGHTS RESERVED. // See rttbCopyright.txt or // http://www.dkfz.de/en/sidt/projects/rttb/copyright.html // // This software is distributed WITHOUT ANY WARRANTY; without even // the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // PURPOSE. See the above copyright notices for more information. // //------------------------------------------------------------------------ /*! // @file // @version $Revision: 1674 $ (last changed revision) // @date $Date: 2017-01-27 10:34:46 +0100 (Fr, 27 Jan 2017) $ (last change date) // @author $Author: hentsch $ (last changed by) */ #ifndef __RTTB_STRUCT_LOADER_H #define __RTTB_STRUCT_LOADER_H #include "rttbDicomFileStructureSetGenerator.h" #include "rttbExceptionMacros.h" namespace rttb { namespace io { namespace utils { - typedef std::vector LoadingStyleArgType; + using LoadingStyleArgType = std::vector; /*! @brief loads a dicom struct from a file. You may pass a structure name regex. If is not empty, it will be used to filter structure in the loading process. Only structures with a name matching the reg ex will be loaded. This speeds up the loading process significantly if you need only one structure out of a structure set. @exception Throws an rttb::Exception if loading fails @sa DicomFileStructureSetGenerator */ rttb::core::StructureSetGeneratorInterface::StructureSetPointer loadDicomStruct( const std::string& fileName, const std::string& structNameRegex = "") { rttb::io::dicom::DicomFileStructureSetGenerator generator(fileName); if (!structNameRegex.empty()) { generator.setStructureLabelFilterActive(true); generator.setFilterRegEx(structNameRegex); } return generator.generateStructureSet(); } /*! @brief loads a struct from a file based on the loadingStyle. You may pass a structure name regex. If is not empty, it will be used to filter structure in the loading process. Only structures with a name matching the reg ex will be loaded. This speeds up the loading process significantly if you need only one structure out of a structure set. @exception Throws an rttb::Exception if loading fails @details voxelized itk images are read in generateMask() directly */ rttb::core::StructureSetGeneratorInterface::StructureSetPointer loadStruct( const std::string& fileName, const LoadingStyleArgType& args, const std::string& structNameRegex = "") { rttb::core::StructureSetGeneratorInterface::StructureSetPointer result; if (args.empty() || args[0] == "dicom") { result = rttb::io::utils::loadDicomStruct(fileName, structNameRegex); } else { rttbDefaultExceptionStaticMacro(<< "Unknown io style selected. Cannot load data. Selected style: " << args[0]); } return result; } } } } #endif diff --git a/code/masks/boost/rttbBoostMask.h b/code/masks/boost/rttbBoostMask.h index 7609b30..00c85a6 100644 --- a/code/masks/boost/rttbBoostMask.h +++ b/code/masks/boost/rttbBoostMask.h @@ -1,206 +1,204 @@ // ----------------------------------------------------------------------- // 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 __BOOST_MASK_R_H #define __BOOST_MASK_R_H #include "rttbBaseType.h" #include "rttbStructure.h" #include "rttbGeometricInfo.h" #include "rttbMaskAccessorInterface.h" #include #include #include #include namespace rttb { namespace masks { namespace boost { /*! @class BoostMask * @brief Implementation of voxelization using boost::geometry. * @attention If "strict" is set to true, an exception will be thrown when the given structure has self intersection. * (A structure without self intersection means all contours of the structure have no self intersection, and * the polygons on the same slice have no intersection between each other, unless the case of a donut. A donut is accepted.) * If "strict" is set to false, debug information will be displayed when the given structure has self intersection. Self intersections will be ignored * and the mask will be calculated, however, it may cause errors in the mask results. */ class BoostMask { public: - typedef ::boost::shared_ptr GeometricInfoPointer; - typedef core::Structure::StructTypePointer StructPointer; - typedef core::MaskAccessorInterface::MaskVoxelList MaskVoxelList; - typedef core::MaskAccessorInterface::MaskVoxelListPointer MaskVoxelListPointer; + using GeometricInfoPointer = ::boost::shared_ptr; + using StructPointer = core::Structure::StructTypePointer; + using MaskVoxelList = core::MaskAccessorInterface::MaskVoxelList; + using MaskVoxelListPointer = core::MaskAccessorInterface::MaskVoxelListPointer; /*! @brief Constructor * @exception rttb::core::NullPointerException thrown if aDoseGeoInfo or aStructure is nullptr * @param aDoseGeoInfo the GeometricInfo * @param aStructure the structure set * @param strict indicates whether to allow self intersection in the structure. If it is set to true, an exception will be thrown when the given structure has self intersection. * @param numberOfThreads number of threads used for voxelization. default value 0 means automatic detection, using the number of Hardware thread/cores * @exception InvalidParameterException thrown if strict is true and the structure has self intersections */ BoostMask(GeometricInfoPointer aDoseGeoInfo, StructPointer aStructure, bool strict = true, unsigned int numberOfThreads = 0); /*! @brief Generate mask and return the voxels in the mask * @exception rttb::core::InvalidParameterException thrown if the structure has self intersections */ MaskVoxelListPointer getRelevantVoxelVector(); private: - typedef ::boost::geometry::model::d2::point_xy BoostPoint2D; - typedef ::boost::geometry::model::polygon< ::boost::geometry::model::d2::point_xy > - BoostPolygon2D; - typedef ::boost::geometry::model::ring< ::boost::geometry::model::d2::point_xy > - BoostRing2D; - typedef std::vector BoostRingVector;//polygon without holes - typedef std::vector BoostPolygonVector;//polygon with or without holes - typedef std::vector VoxelIndexVector; + using BoostPoint2D = ::boost::geometry::model::d2::point_xy; + using BoostPolygon2D = ::boost::geometry::model::polygon< ::boost::geometry::model::d2::point_xy >; + using BoostRing2D = ::boost::geometry::model::ring< ::boost::geometry::model::d2::point_xy >; + using BoostRingVector = std::vector;//polygon without holes + using BoostPolygonVector = std::vector;//polygon with or without holes + using VoxelIndexVector = std::vector; typedef std::map BoostPolygonMap;//map of the z index with the vector of boost 2d polygon typedef std::map BoostRingMap;//map of the z index with the vector of boost 2d ring typedef ::boost::multi_array BoostArray2D; - typedef ::boost::shared_ptr BoostArray2DPointer; + using BoostArray2DPointer = ::boost::shared_ptr; typedef ::boost::shared_ptr > BoostArrayMapPointer; GeometricInfoPointer _geometricInfo; StructPointer _structure; bool _strict; /*! @brief The number of threads */ unsigned int _numberOfThreads; //@brief The thickness of the voxelization plane (the contour plane), in double dose grid index //@details for example, the first contour has the double grid index 0.1, the second 0.3, the third 0.5, then the thickness is 0.2 double _voxelizationThickness; //@brief vector of the MaskVoxel inside the structure MaskVoxelListPointer _voxelInStructure; /*! @brief The map of z index and a vector of boost ring 2d (without holes) * @details Key: the double z grid index * Value: the vector of boost ring 2d (without holes) */ BoostRingMap _ringMap; /*! @brief The min and max index of the global bounding box. * @details The first index has the minimum for x/y/z of the global bounding box. * The second index has the maximum for x/y/z of the global bounding index. */ VoxelIndexVector _globalBoundingBox; /*! @brief The voxelization map * @details key: the converted double z grid index of a contour plane * value: the 2d mask, array[i][j] = the mask value of the position (i,j) in the global bounding box, * i: 0 - (_globalBoundingBoxSize0-1), j: 0 - (_globalBoundingBoxSize1-1) */ BoostArrayMapPointer _voxelizationMap; /*! @brief If the mask is up to date */ bool _isUpToDate; /*! @brief Voxelization and generate mask */ void calcMask(); /*! @brief The preprocessing step, wich consists of the following logic and Sub setps: * @details For all contours in a struct: * 1) Transfer the contour polygons into boost::geometry structures * 1a) Convert the contur points from world coordinates into geometry coordinates. * 1b) get min and max for x/y/z of a contour * 2) Tilt check: if difference of z_min and z_max is larger then a tolerance value -> there is a tilt. Throw rttb::TiltedMaskPlaneException. * 3) Get struct-bounding-box: get x_min_struct, y_min_struct, x_max_struct, y_max_struct to define the bounding box that containes all contours of a struct in x-y-dimensions. */ void preprocessing(); /*! @brief The voxelization step, which computes the voxelization planes (in x/y) for all contours of an struct. * @details For each contour (that is in the z-Range of the reference geometry) of the struct: * 1) Allocate result array (voxelization plane) based on the bounding box (see Preprocessing Step 3) * 2) Generate voxelization plane for the contour (based on the x-y-raster of the reference geometry). * 3) Add result Array (key is the z-Value of the contour) */ void voxelization(); /*! @brief mask voxel Generation step which transfers the voxelization planes into the (z-)geometry of the reference geometry. * @details It consists of following Sub steps : * For all "slices" in the reference geometry : * 1) generate weight vector for all voxelization planes for a given z - value of a slice * Iterate over the bounding box of a struct.For each voxel : * 2) Compute weighted sum of all voxelization planes(use weight vector, step 1) * 2a) If sum > 0 : Add mask voxel for the current x / y(inner Loop) and z value(outer Loop). * 3) return mask voxel list. */ void generateMaskVoxelList(); /*! @brief Convert the rttb polygon with world coordinate to the rttb polygon with double geometry coordinate, calculate the current min/max * and check if the polygon is planar * @param minimum the current global minimum * @param maximum the current global maximum * @return Return true if the polygon is planar, which means that the minimal and maximal z-coordinate of the polygon is not larger than a error constant */ bool preprocessingPolygon(const rttb::PolygonType& aRTTBPolygon, rttb::PolygonType& geometryCoordinatePolygon, rttb::DoubleVoxelGridIndex3D& minimum, rttb::DoubleVoxelGridIndex3D& maximum, double aErrorConstant) const; /*! @brief Convert a rttb 3d polygon to a 2d boost ring*/ BoostRing2D convertRTTBPolygonToBoostRing(const rttb::PolygonType& aRTTBPolygon) const; /*! @brief Convert a rttb 3d polygon to a map of z index with a vector of boost 2d ring, because of tilt check use the first z index of the polygon as the map key*/ BoostRingMap convertRTTBPolygonSequenceToBoostRingMap(const rttb::PolygonSequenceType& aRTTBPolygonVector) const; /*! @brief Find the key with error constant to aIndex * @pre aBoostRingMap should not be empty * @return Return aBoostRingMap.end() if the key is not found */ BoostMask::BoostRingMap::iterator findNearestKey(BoostMask::BoostRingMap& aBoostRingMap, double aIndex, double aErrorConstant) const; /*! @brief If 2 rings in the vector build a donut, convert the 2 rings to a donut polygon, other rings unchanged*/ BoostPolygonVector checkDonutAndConvert(const BoostRingVector& aRingVector) const; /*! @brief Calculate the voxelization thickness. Return false, if the voxelization plane is not homogeneous */ bool calcVoxelizationThickness(double& aThickness) const; }; } } } #endif diff --git a/code/masks/boost/rttbBoostMaskAccessor.h b/code/masks/boost/rttbBoostMaskAccessor.h index 3ccc4bc..4e92fd8 100644 --- a/code/masks/boost/rttbBoostMaskAccessor.h +++ b/code/masks/boost/rttbBoostMaskAccessor.h @@ -1,121 +1,121 @@ // ----------------------------------------------------------------------- // 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 __BOOST_MASK_R_ACCESSOR__H #define __BOOST_MASK_R_ACCESSOR__H #include "rttbBaseType.h" #include "rttbGeometricInfo.h" #include "rttbMaskAccessorInterface.h" #include "rttbStructure.h" #include "RTTBBoostMaskExports.h" namespace rttb { namespace masks { namespace boost { /*! @class BoostMaskAccessor * @brief Using the voxelization based on boost::geometry and generate the mask accessor. * @attention If "strict" is set to true, an exception will be thrown when the given structure has self intersection. * (A structure without self intersection means all contours of the structure have no self intersection, and * the polygons on the same slice have no intersection between each other, unless the case of a donut. A donut is accepted.) * If "strict" is set to false, debug information will be displayed when the given structure has self intersection. Self intersections will be ignored * and the mask will be calculated, however, it may cause errors in the mask results. */ class RTTBBoostMask_EXPORT BoostMaskAccessor : public core::MaskAccessorInterface { public: - typedef core::MaskAccessorInterface::MaskVoxelList MaskVoxelList; - typedef core::MaskAccessorInterface::MaskVoxelListPointer MaskVoxelListPointer; + using MaskVoxelList = core::MaskAccessorInterface::MaskVoxelList; + using MaskVoxelListPointer = core::MaskAccessorInterface::MaskVoxelListPointer; - typedef core::Structure::StructTypePointer StructTypePointer; + using StructTypePointer = core::Structure::StructTypePointer; private: StructTypePointer _spStructure; core::GeometricInfo _geoInfo; bool _strict; /*! vector containing list of mask voxels*/ MaskVoxelListPointer _spRelevantVoxelVector; IDType _maskUID; public: /*! @brief Constructor with a structure pointer and a geometric info pointer * @param aStructurePointer smart pointer of the structure * @param aGeometricInfo smart pointer of the geometricInfo of the dose * @param strict indicates whether to allow self intersection in the structure. If it is set to true, an exception will be thrown when the given structure has self intersection. * @exception InvalidParameterException thrown if strict is true and the structure has self intersections */ BoostMaskAccessor(StructTypePointer aStructurePointer, const core::GeometricInfo& aGeometricInfo, bool strict = true); /*! @brief destructor*/ ~BoostMaskAccessor() override; /*! @brief voxelization of the given structures using boost algorithms*/ void updateMask() override; /*! @brief get vector containing all relevant voxels that are inside the given structure*/ MaskVoxelListPointer getRelevantVoxelVector() override; /*! @brief get vector containing all relevant voxels that have a relevant volume above the given threshold and are inside the given structure*/ MaskVoxelListPointer getRelevantVoxelVector(float lowerThreshold) override; /*!@brief determine how a given voxel on the dose grid is masked * @param aID ID of the voxel in grid. * @param voxel Reference to the voxel. * @post after a valid call voxel containes the information of the specified grid voxel. If aID is not valid, voxel values are undefined. * The relevant volume fraction will be set to zero. * @return Indicates of the voxel exists and therefore if parameter voxel containes valid values.*/ bool getMaskAt(const VoxelGridID aID, core::MaskVoxel& voxel) const override; /*!@brief determine how a given voxel on the dose grid is masked * @param aIndex 3d index of the voxel in grid. * @param voxel Reference to the voxel. * @return Indicates of the voxel exists and therefore if parameter voxel containes valid values.*/ bool getMaskAt(const VoxelGridIndex3D& aIndex, core::MaskVoxel& voxel) const override; /*! @brief give access to GeometricInfo*/ const core::GeometricInfo& getGeometricInfo() const override; /* @ brief is true if dose is on a homogeneous grid * @remark Inhomogeneous grids are not supported at the moment, but if they will be supported in the future the interface does not need to change.*/ bool isGridHomogeneous() const override { return true; }; IDType getMaskUID() const override { return _maskUID; }; }; } } } #endif diff --git a/code/masks/boost/rttbBoostMaskGenerateMaskVoxelListThread.h b/code/masks/boost/rttbBoostMaskGenerateMaskVoxelListThread.h index e157429..3914f79 100644 --- a/code/masks/boost/rttbBoostMaskGenerateMaskVoxelListThread.h +++ b/code/masks/boost/rttbBoostMaskGenerateMaskVoxelListThread.h @@ -1,90 +1,90 @@ // ----------------------------------------------------------------------- // 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: 1127 $ (last changed revision) // @date $Date: 2015-10-01 13:33:33 +0200 (Do, 01 Okt 2015) $ (last change date) // @author $Author: hentsch $ (last changed by) */ #ifndef __BOOST_MASK_GENERATE_MASK_VOXEL_LIST_H #define __BOOST_MASK_GENERATE_MASK_VOXEL_LIST_H #include "rttbBaseType.h" #include "rttbGeometricInfo.h" #include "rttbMaskAccessorInterface.h" #include #include #include namespace rttb { namespace masks { namespace boost { /*! @class BoostMaskGenerateMaskVoxelListThread * */ class BoostMaskGenerateMaskVoxelListThread { public: - typedef ::boost::shared_ptr GeometricInfoPointer; + using GeometricInfoPointer = ::boost::shared_ptr; typedef ::boost::multi_array BoostArray2D; - typedef ::boost::shared_ptr BoostArray2DPointer; + using BoostArray2DPointer = ::boost::shared_ptr; typedef ::boost::shared_ptr > BoostArrayMapPointer; - typedef std::vector VoxelIndexVector; - typedef core::MaskAccessorInterface::MaskVoxelListPointer MaskVoxelListPointer; + using VoxelIndexVector = std::vector; + using MaskVoxelListPointer = core::MaskAccessorInterface::MaskVoxelListPointer; BoostMaskGenerateMaskVoxelListThread(const VoxelIndexVector& aGlobalBoundingBox, GeometricInfoPointer aGeometricInfo, BoostArrayMapPointer aVoxelizationMap, double aVoxelizationThickness, unsigned int aBeginSlice, unsigned int aEndSlice, MaskVoxelListPointer aMaskVoxelList, ::boost::shared_ptr<::boost::shared_mutex> aMutex); void operator()(); private: VoxelIndexVector _globalBoundingBox; GeometricInfoPointer _geometricInfo; BoostArrayMapPointer _voxelizationMap; //(for example, the first contour has the double grid index 0.1, the second 0.3, the third 0.5, then the thickness is 0.2) double _voxelizationThickness; unsigned int _beginSlice; /*! @brief _endSlice is the first index not to be processed (like a end iterator) */ unsigned int _endSlice; MaskVoxelListPointer _resultMaskVoxelList; ::boost::shared_ptr<::boost::shared_mutex> _mutex; /*! @brief For each dose grid index z, calculate the weight vector for each structure contour */ void calcWeightVector(const rttb::VoxelGridID& aIndexZ, std::map& weightVector) const; }; } } } #endif \ No newline at end of file diff --git a/code/masks/boost/rttbBoostMaskVoxelizationThread.h b/code/masks/boost/rttbBoostMaskVoxelizationThread.h index 4ddd536..9743c4e 100644 --- a/code/masks/boost/rttbBoostMaskVoxelizationThread.h +++ b/code/masks/boost/rttbBoostMaskVoxelizationThread.h @@ -1,111 +1,109 @@ // ----------------------------------------------------------------------- // 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: 1127 $ (last changed revision) // @date $Date: 2015-10-01 13:33:33 +0200 (Do, 01 Okt 2015) $ (last change date) // @author $Author: hentsch $ (last changed by) */ #ifndef __BOOST_MASK_VOXELIZATION_THREAD_H #define __BOOST_MASK_VOXELIZATION_THREAD_H #include #include "rttbBaseType.h" #include #include #include #include #include namespace rttb { namespace masks { namespace boost { /*! @class BoostMaskGenerateMaskVoxelListThread * */ class BoostMaskVoxelizationThread { public: - typedef ::boost::geometry::model::polygon< ::boost::geometry::model::d2::point_xy > - BoostPolygon2D; - typedef std::vector BoostPolygonVector;//polygon with or without holes + using BoostPolygon2D = ::boost::geometry::model::polygon< ::boost::geometry::model::d2::point_xy >; + using BoostPolygonVector = std::vector;//polygon with or without holes typedef std::map BoostPolygonMap;//map of the z index with the vector of boost 2d polygon - typedef std::vector VoxelIndexVector; + using VoxelIndexVector = std::vector; typedef ::boost::multi_array BoostArray2D; - typedef ::boost::shared_ptr BoostArray2DPointer; + using BoostArray2DPointer = ::boost::shared_ptr; typedef ::boost::shared_ptr > BoostArrayMapPointer; /*! @brief Constructor * @param aMutex a mutex for thread-safe handling of the _resultVoxelization * @param strict true means that volumeFractions of <0 and >1 are NOT corrected. Otherwise, they are automatically corrected to 0 or 1, respectively. */ BoostMaskVoxelizationThread(const BoostPolygonMap& APolygonMap, const VoxelIndexVector& aGlobalBoundingBox, BoostArrayMapPointer anArrayMap, ::boost::shared_ptr<::boost::shared_mutex> aMutex, bool strict); void operator()(); private: - typedef std::deque BoostPolygonDeque; - typedef ::boost::geometry::model::ring< ::boost::geometry::model::d2::point_xy > - BoostRing2D; - typedef ::boost::geometry::model::d2::point_xy BoostPoint2D; + using BoostPolygonDeque = std::deque; + using BoostRing2D = ::boost::geometry::model::ring< ::boost::geometry::model::d2::point_xy >; + using BoostPoint2D = ::boost::geometry::model::d2::point_xy; BoostPolygonMap _geometryCoordinateBoostPolygonMap; VoxelIndexVector _globalBoundingBox; BoostArrayMapPointer _resultVoxelization; ::boost::shared_ptr<::boost::shared_mutex> _mutex; bool _strict; /*! @brief Get intersection polygons of the contour and a voxel polygon * @param aVoxelIndex3D The 3d grid index of the voxel * @param intersectionSlicePolygons The polygons of the slice intersecting the voxel * @return Return all intersection polygons of the structure and the voxel */ static BoostPolygonDeque getIntersections(const rttb::VoxelGridIndex3D& aVoxelIndex3D, const BoostPolygonVector& intersectionSlicePolygons); /*! @brief Get the voxel 2d contour polygon in geometry coordinate*/ static BoostRing2D get2DContour(const rttb::VoxelGridIndex3D& aVoxelGrid3D); /*! @brief Calculate the area of all polygons * @param aPolygonDeque The deque of polygons * @return Return the area of all polygons */ static double calcArea(const BoostPolygonDeque& aPolygonDeque); /*! @brief Corrects the volumeFraction * @details the volume fraction is corrected in case of strict=true. Otherwise, it's only corrected for double imprecision * @return The corrected volumeFraction */ double correctForErrorAndStrictness(double volumeFraction, bool strict) const; }; } } } #endif \ No newline at end of file diff --git a/code/masks/rttbGenericMutableMaskAccessor.h b/code/masks/rttbGenericMutableMaskAccessor.h index 6eea302..2ff195a 100644 --- a/code/masks/rttbGenericMutableMaskAccessor.h +++ b/code/masks/rttbGenericMutableMaskAccessor.h @@ -1,107 +1,107 @@ // ----------------------------------------------------------------------- // 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 __GENERIC_MUTABLE_MASK_ACCESSOR_H #define __GENERIC_MUTABLE_MASK_ACCESSOR_H #include "rttbMutableMaskAccessorInterface.h" #include "rttbBaseType.h" #include "rttbGeometricInfo.h" namespace rttb { namespace masks { /*! @class GenericMutableMaskAccessor @brief Default implementation of MutableMaskAccessorInterface. @see MutableMaskAccessorInterface */ class GenericMutableMaskAccessor: public core::MutableMaskAccessorInterface { public: - typedef core::MutableMaskAccessorInterface::MaskVoxelList MaskVoxelList; - typedef core::MutableMaskAccessorInterface::MaskVoxelListPointer MaskVoxelListPointer; + using MaskVoxelList = core::MutableMaskAccessorInterface::MaskVoxelList; + using MaskVoxelListPointer = core::MutableMaskAccessorInterface::MaskVoxelListPointer; private: core::GeometricInfo _geoInfo; /*! vector containing list of mask voxels*/ MaskVoxelListPointer _spRelevantVoxelVector; IDType _maskUID; GenericMutableMaskAccessor(const GenericMutableMaskAccessor&); //not implemented on purpose -> non-copyable GenericMutableMaskAccessor& operator=(const GenericMutableMaskAccessor&);//not implemented on purpose -> non-copyable public: ~GenericMutableMaskAccessor() override; GenericMutableMaskAccessor(const core::GeometricInfo& aGeometricInfo); /*! @brief initialize mask structure if _spRelevantVoxelVector was not previously initialized*/ void updateMask() override; /*! @brief get vector containing all relevant voxels that are inside the given structure*/ MaskVoxelListPointer getRelevantVoxelVector() override; /*! @brief get vector containing all relevant voxels that have a relevant volume above the given threshold and are inside the given structure*/ MaskVoxelListPointer getRelevantVoxelVector(float lowerThreshold) override; /*!@brief determine how a given voxel on the dose grid is masked * @param aID ID of the voxel in grid. * @param voxel Reference to the voxel. * @post after a valid call voxel contains the information of the specified grid voxel. If aID is not valid, voxel values are undefined. * The relevant volume fraction will be set to zero. * @return Indicates if the voxel exists and therefore if parameter voxel contains valid values.*/ bool getMaskAt(const VoxelGridID aID, core::MaskVoxel& voxel) const override; bool getMaskAt(const VoxelGridIndex3D& aIndex, core::MaskVoxel& voxel) const override; /* @ brief is true if dose is on a homogeneous grid */ // Inhomogeneous grids are not supported at the moment, but if they will // be supported in the future the interface does not need to change. bool isGridHomogeneous() const override { return true; }; /*! @brief give access to GeometricInfo*/ inline const core::GeometricInfo& getGeometricInfo() const override { return _geoInfo; }; IDType getMaskUID() const override { return _maskUID; }; void setMaskAt(VoxelGridID aID, const core::MaskVoxel& voxel) override; void setMaskAt(const VoxelGridIndex3D& gridIndex, const core::MaskVoxel& voxel) override; void setRelevantVoxelVector(MaskVoxelListPointer aVoxelListPointer) override; }; } } #endif \ No newline at end of file diff --git a/code/masks/rttbVOIindexIdentifier.h b/code/masks/rttbVOIindexIdentifier.h index 868040b..00ab200 100644 --- a/code/masks/rttbVOIindexIdentifier.h +++ b/code/masks/rttbVOIindexIdentifier.h @@ -1,90 +1,90 @@ // ----------------------------------------------------------------------- // 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: // @date $Date: // @author $Author: */ #ifndef __VOI_INDEX_IDENTIFIER_H #define __VOI_INDEX_IDENTIFIER_H #include "rttbStructureSet.h" #include "rttbStructure.h" #include "RTTBMasksExports.h" namespace rttb { namespace masks { /*! @class VOIindexIdentifier @brief Collection of functions for the identification of structs in RTSTRUCT files. */ class RTTBMasks_EXPORT VOIindexIdentifier { public: - typedef ::boost::shared_ptr Pointer; - typedef ::rttb::core::StructureSet StructSetType; - typedef ::boost::shared_ptr StructSetTypePointer; - typedef ::rttb::core::Structure StructType; + using Pointer = ::boost::shared_ptr; + using StructSetType = ::rttb::core::StructureSet; + using StructSetTypePointer = ::boost::shared_ptr; + using StructType = ::rttb::core::Structure; public: VOIindexIdentifier() = default; virtual ~VOIindexIdentifier() = default; /*!@brief get indices of all VOI that agree with the regex * @details if the regex does not agree with any VOI, the returning vector is empty. * @pre spStructSet must point to a valid structure set. * @param spStructSet Pointer to the structure set that should be checked for the named VOI. * @param name Regular expression of the VOI * @exception ::rttb::core::Exception on invalid spStructSet * @return a vector of all found indices */ static const std::vector getIndicesByVoiRegex(StructSetTypePointer spStructSet, const std::string& name); /*!@brief get the index of the corresponding VOI name * @details only if the exact name is found, the index will be given. * @pre name must contain a valid VOI name * @pre spStructSet must point to a valid structure set. * @param spStructSet Pointer to the structure set that should be checked for the named VOI. * @param name Name of the VOI * @exception ::rttb::core::Exception on invalid spStructSet * @exception ::rttb::core::Exception on invalid name (not found in structure set) * @return the index */ static const unsigned int getIndexByVoiName(StructSetTypePointer spStructSet, const std::string& name); /*!@brief get the VOI of the corresponding index * @pre index must specify a valid index value * @pre spStructSet must point to a valid structure set. * @param spStructSet Pointer to the structure set that should be checked for the named VOI. * @param index Index of the VOI * @exception ::rttb::core::Exception on invalid spStructSet or index>maxLabelIndex * @return voi name */ static const std::string getVoiNameByIndex(StructSetTypePointer spStructSet, unsigned int index); }; } } #endif diff --git a/code/models/rttbBaseTypeModels.h b/code/models/rttbBaseTypeModels.h index 2625e82..07285cd 100644 --- a/code/models/rttbBaseTypeModels.h +++ b/code/models/rttbBaseTypeModels.h @@ -1,52 +1,52 @@ // ----------------------------------------------------------------------- // 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 __BASE_TYPE_MODEL_H #define __BASE_TYPE_MODEL_H #include #include "rttbBaseType.h" namespace rttb { namespace models { - typedef double BioModelParamType; - typedef double BioModelValueType; + using BioModelParamType = double; + using BioModelValueType = double; const double infinity = 1e30; struct TcpParams { double alphaMean; double alphaVariance; double rho; std::vector volumeVector; std::vector bedVector; }; } } #endif \ No newline at end of file diff --git a/code/models/rttbBioModel.h b/code/models/rttbBioModel.h index 731073e..8c3f0db 100644 --- a/code/models/rttbBioModel.h +++ b/code/models/rttbBioModel.h @@ -1,108 +1,108 @@ // ----------------------------------------------------------------------- // 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 __BIO_MODEL_H #define __BIO_MODEL_H #include "rttbDVH.h" #include "rttbBaseTypeModels.h" #include "RTTBModelsExports.h" #include namespace rttb { namespace models { /*! @class BioModel @brief This is the interface class for biological models */ class RTTBModels_EXPORT BioModel { public: - typedef std::vector ParamVectorType; - typedef core::DVH::DVHPointer DVHPointer; + using ParamVectorType = std::vector; + using DVHPointer = core::DVH::DVHPointer; protected: DVHPointer _dvh; BioModelValueType _value{0}; /*! @brief Calculate the model value @param doseFactor scaling factor for the dose. The model calculation will use the dvh with each di=old di*doseFactor. */ virtual BioModelValueType calcModel(const double doseFactor = 1) = 0; /* Map of all parameters */ std::map parameterMap; std::string _name; public: BioModel() = default; BioModel(DVHPointer aDvh): _dvh(aDvh), _value(0) {}; virtual ~BioModel()= default; /*! @brief Start the calculation. If any parameter changed, init() should be called again and return =true before getValue() is called! @return Return true if successful */ bool init(const double doseFactor = 1); /*! @param aDVH must be a DVH calculated by a cumulative dose distribution, not a fraction DVH! */ void setDVH(const DVHPointer aDVH); const DVHPointer getDVH() const; /*! @brief Set parameter vector, where index of vector is the parameter ID. */ virtual void setParameterVector(const ParamVectorType& aParameterVector) = 0; virtual void setParameterByID(const int aParamId, const BioModelParamType aValue) = 0; /*! @brief Get parameter by ID. @return Return -1 if ID is not found. */ virtual const int getParameterID(const std::string& aParamName) const = 0; virtual std::map getParameterMap() const = 0; virtual void fillParameterMap() = 0 ; virtual std::string getModelType() const = 0; /*! @brief Get the value of biological model @pre init() must be called and =true! */ const BioModelValueType getValue() const; }; }//end namespace models }//end namespace rttb #endif diff --git a/code/models/rttbBioModelScatterPlots.h b/code/models/rttbBioModelScatterPlots.h index 0dd0f03..ea3d31b 100644 --- a/code/models/rttbBioModelScatterPlots.h +++ b/code/models/rttbBioModelScatterPlots.h @@ -1,96 +1,96 @@ // ----------------------------------------------------------------------- // 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 __MODEL_SCATTER_H #define __MODEL_SCATTER_H #include "rttbBaseType.h" #include "rttbBaseTypeModels.h" namespace rttb { namespace models { class BioModel; // maps dose to a pair of model value and probability typedef std::multimap > ScatterPlotType; - typedef std::vector ParamVectorType; + using ParamVectorType = std::vector; /*! @brief Get the points (TCP/NTCP Value, probability of the value) if 1 parameter vary from a normal- distribution with mean=aMean, variance=aVariance. @param aModel biological model for which the scatter plot will be generated @param aParamId ID of the parameter to be varied to generate the scatter plot @param aMean mean value for the distribution of the varied parameter @param aVariance variance of the varied parameter. The variance may not be exactly zero. If so, it is set to 1e-30 to avoid numerical instability. @param aNormalisationDose prescribed dose of the current _dvh @param numberOfPoints the size of the map, number of points to be calculated @param aMinDose dose will be randomly selected from [aMinDose] (uniform distribution). They will define the minvalue for x axis @param aMaxDose dose will be randomly selected from [aMaxDose] (uniform distribution). They will define the max value for x axis @return Map of scattered values. If all parameters are valid, this map contains numberOfPoints valid scatter values. If aMaxDose<=aMinDose, the scatter plot cannot be generated. The map will therefore be empty. @warning This method is slow, do not use with too many points. Because the scatter plot map must contain numberOfPoints the scatter plot generation may run more often (producing invalid values). In tests the generation process runs on average approximately 20% more often. @exception InvalidParameterException Thrown if aNormalisationDose<=0 or aMinDose<=aMaxiDose */ ScatterPlotType getScatterPlotVary1Parameter(BioModel& aModel, int aParamId, BioModelParamType aMean, BioModelParamType aVariance, DoseTypeGy aNormalisationDose, int numberOfPoints = 100, DoseTypeGy aMinDose = 0, DoseTypeGy aMaxDose = 150); /*! @brief Get the points (TCP/NTCP Value, probability of the value) if >=1 parameter vary from a normal- distribution with mean of parameter aParamIdVec.at(i)=aMeanVec.at(i), variance of parameter aParamIdVec.at(i)= aVarianceVec.at(i). @param aModel biological model for which the scatter plot will be generated @param aParamIdVec a vector containing the IDs of the parameters to be varied to generate the scatter plot @param aMeanVec a vector of mean values for the distribution of individually the varied parameters @param aVarianceVec a vector of variance values of the individually varied parameter. The variance may not be exactly zero for any parameter. If so, it is set to 1e-30 to avoid numerical instability. @param aNormalisationDose prescribed dose of the current _dvh @param numberOfPoints the size of the map, number of points to be calculated @param aMinDose dose will be randomly selected from [aMinDose] (uniform distribution). They will define the min value for x axis @param aMaxDose dose will be randomly selected from [aMaxDose] (uniform distribution). They will define the max value for x axis @throw InvalidParameterException is thrown if the parameter vectors do not have the same size. @return Map of scattered values. If all parameters are valid, this map contains numberOfPoints valid scatter values. If aMaxDose<=aMinDose, the scatter plot cannot be generated. The map will therefore be empty. @warning This method is very slow do not use with too many points. Because the scatter plot map must contain numberOfPoints the scatter plot generation may run more often (producing invalid values). In tests the generation process runs on average approximately 20% more often. @exception InvalidParameterException Thrown if aNormalisationDose<=0 or aMinDose<=aMaxiDose */ ScatterPlotType getScatterPlotVaryParameters(BioModel& aModel, std::vector aParamIdVec, ParamVectorType aMeanVec, ParamVectorType aVarianceVec, DoseTypeGy aNormalisationDose, int numberOfPoints = 50, DoseTypeGy aMinDose = 0, DoseTypeGy aMaxDose = 150); /*! Compute normal probability density function for zero mean at aValue with aVariance. */ double normal_pdf(double aValue, double aVariance); } } #endif \ No newline at end of file diff --git a/code/models/rttbDvhBasedModels.h b/code/models/rttbDvhBasedModels.h index 2ea7c76..559d83f 100644 --- a/code/models/rttbDvhBasedModels.h +++ b/code/models/rttbDvhBasedModels.h @@ -1,51 +1,51 @@ #include #include "rttbDVH.h" #include "rttbBaseType.h" namespace rttb { namespace models { - typedef core::DVH::DataDifferentialType DataDifferentialType; - typedef core::DVH::DVHPointer DVHPointer; + using DataDifferentialType = core::DVH::DataDifferentialType; + using DVHPointer = core::DVH::DVHPointer; typedef std::map BEDDVHType; typedef std::map LQEDDVHType; /*! @brief Get Equivalent Uniform Dose (EUD) @pre dvh data differential is not empty, @pre aA is not zero, @return Return calculated EUD value, @exception InvalidParameterException Thrown if parameters were not set correctly. */ DoseStatisticType getEUD(const DVHPointer dvh, const DoseCalcType aA); /*! @brief Calculate Biological Effective/Equivalent Dose (BED) of dvh @param relativeVolume default false-> the corresponding volume value is the voxel number of the dose bin; if true-> the corresponding volume value is the relative volume % between 0 and 1, (the voxel number of this dose bin)/(number of voxels) @pre dvh should be an accumulated dvh of all fractions, not a single fraction dvh @pre dvh data differential is not empty @pre alpha_beta > 0 @pre numberOfFractions > 1 @return Return map: keys are BEDi in Gy, values are the volume of the dose bin @exception InvalidParameterException Thrown if parameters were not set correctly. */ BEDDVHType calcBEDDVH(const DVHPointer dvh, const int numberOfFractions, const DoseCalcType alpha_beta, const bool relativeVolume = false); /*! @brief Calculate Linear-quadratic equivalent dose for 2-Gy (LQED2) of dvh @param relativeVolume default false-> the corresponding volume value is the voxel number of the dose bin; if true-> the corresponding volume value is the relative volume % between 0 and 1, (the voxel number of this dose bin)/(number of voxels) @pre dvh should be an accumulated dvh of all fractions, not a single fraction dvh @pre dvh data differential is not empty @pre alpha_beta > 0 @pre numberOfFractions > 1 @return Return map: keys are LQED2 in Gy, values are the volume of the dose bin; return empty map if not initialized @exception InvalidParameterException Thrown if parameters were not set correctly. */ LQEDDVHType calcLQED2DVH(const DVHPointer dvh, const int numberOfFractions, const DoseCalcType alpha_beta, const bool relativeVolume = false); } } \ No newline at end of file diff --git a/code/models/rttbIntegration.h b/code/models/rttbIntegration.h index c1c7085..5878aa0 100644 --- a/code/models/rttbIntegration.h +++ b/code/models/rttbIntegration.h @@ -1,119 +1,119 @@ // ----------------------------------------------------------------------- // 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 __INTEGRATION_H #define __INTEGRATION_H #include "rttbBaseTypeModels.h" namespace rttb { namespace models { - typedef double integrationType; + using integrationType = double; /*! @class LkbModelFunctor @brief A FunctorType: calculate the transformed LKB-Model @details LBK Model is calculated using the transformation \f$x = b - \frac{1-t}{t}\f$. \f$\int_{-\infty}^{b} dx\f$, \f$f(x) = \int_0^1 dt \frac{f(b - \frac{(1-t)}{t})}{t^2}\f$ */ class LkbModelFunctor { public: /*!b: upper bound of the lkb integration*/ double b; /*! calculate the transformed LKB-Model using the transformation \f$x = b - \frac{1-t}{t}.\f$ */ double calculate(double x) const; }; /*! @class tcpModelFunctor @brief A FunctorType: calculate the transformed TCP-LQ-Model @details LBK Model is calculated using the transformation \f$x = a + \frac{1-t}{t}\f$. \f$\int_{a}^{+\infty} dx f(x) =\int_0^1 dt \frac{f(a + \frac{(1-t)}{t}}{t^2}\f$ */ class tcpModelFunctor { public: //TCP parameters including alpha mean, alpha variance, rho, volume vector and bed vector TcpParams params; /*! a: lower bound of the tcp integration*/ double a; /*! calculate the transformed TCP-LQ-Model using the transformation \f$x = a + \frac{1-t}{t}\f$. */ double calculate(double x) const; }; /*! @brief Function to be integrated for TCP LQ model. @param x: variable of the TCP LQ model @param tcp_params: TCP parameters including alpha mean, alpha variance, rho, volume vector and bed vector @return Return the function value */ double tcpFunction(double x, const TcpParams& tcp_params); /*! @brief Compute integration step for \f$f(x) = exp(-\frac{t^2}{2})\f$. @param x: variable of the lkb function @return Return the function value */ double lkbFunction(double x); /*! @brief Calculate LKB Integration over \f$(-\infty,b)\f$. The integral is mapped onto the semi-open interval \f$(0,1]\f$ using the transformation \f$x = b - \frac{1-t}{t}\f$ @param b: upper bound of the lkb integration */ double integrateLKB(double b); /*! @brief Calculate TCP integration over \f$(a, \infty)\f$. The integral is mapped onto the semi-open interval \f$(0,1]\f$ using the transformation \f$x = a + \frac{1-t}{t}\f$ @param a: lower bound of the tcp integration @param params: TCP parameters including alpha mean, alpha variance, rho, volume vector and bed vector */ double integrateTCP(double a, const TcpParams& params); /* @brief This function returns the nth stage of refinement of the extended trapezoidal rule. @param BMfunction: function to be integrated, for example a LkbModelFunctor or a tcpModelFunctor @param a: lower bound of the integral @param b: upper bound of the integral @param stepNum: the nth stage @param result: the current result */ template integrationType trapzd(const FunctorType& BMfunction, integrationType a, integrationType b, int stepNum); /*! @brief Iterative integration routine @param BMfunction: function to be integrated, for example a LkbModelFunctor or a tcpModelFunctor @param a: lower bound of the integral @param b: upper bound of the integral @exception throw InvalidParameterException if integral calculation failed. */ template integrationType iterativeIntegration(const FunctorType& BMfunction, integrationType a, integrationType b); } } #endif \ No newline at end of file diff --git a/code/models/rttbLQModelAccessor.h b/code/models/rttbLQModelAccessor.h index 8791c6d..ee7d80a 100644 --- a/code/models/rttbLQModelAccessor.h +++ b/code/models/rttbLQModelAccessor.h @@ -1,92 +1,92 @@ // ----------------------------------------------------------------------- // 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 __LQ_MODEL_ACCESSOR_H #define __LQ_MODEL_ACCESSOR_H #include "rttbAccessorWithGeoInfoBase.h" #include "rttbDoseAccessorInterface.h" #include "rttbBaseTypeModels.h" namespace rttb { namespace models { /*! @class LQModelAccessor @brief This class gives access to the LQ Model information in an image */ class LQModelAccessor: public core::AccessorWithGeoInfoBase { public: - typedef core::DoseAccessorInterface::DoseAccessorPointer DoseAccessorPointer; + using DoseAccessorPointer = core::DoseAccessorInterface::DoseAccessorPointer; private: DoseAccessorPointer _dose; BioModelParamType _alpha; BioModelParamType _beta; unsigned int _nFractions; DoseAccessorPointer _alphaMap; DoseAccessorPointer _betaMap; double _doseScaling; bool _withAlphaBetaMaps; IDType _bioModelUID; LQModelAccessor(); /*! @brief get all required data from the dose geometric info */ bool assembleGeometricInfo(); public: ~LQModelAccessor() override; /*! @brief Constructor. @pre dose must be a valid instance (and != nullptr) @exception InvalidDoseException if _dose is nullptr */ LQModelAccessor(DoseAccessorPointer dose, BioModelParamType alpha, BioModelParamType beta, unsigned int nFractions=1, double doseScaling = 1.0); /*! @brief Constructor. @pre dose must be a valid instance (and != nullptr) @exception InvalidDoseException if dose is nullptr, if alphaMap is nullptr or if betaMap is nullptr */ LQModelAccessor(DoseAccessorPointer dose, DoseAccessorPointer alphaMap, DoseAccessorPointer betaMap, unsigned int nFractions = 1, double doseScaling = 1.0); /*! @brief returns the LQ Model value for an id */ GenericValueType getValueAt(const VoxelGridID aID) const override; /*! @brief returns the LQ Model value for an index */ GenericValueType getValueAt(const VoxelGridIndex3D& aIndex) const override; const IDType getUID() const override { return _bioModelUID; }; }; } } #endif diff --git a/code/models/rttbNTCPLKBModel.h b/code/models/rttbNTCPLKBModel.h index 2faf9ae..815f095 100644 --- a/code/models/rttbNTCPLKBModel.h +++ b/code/models/rttbNTCPLKBModel.h @@ -1,105 +1,105 @@ // ----------------------------------------------------------------------- // 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 __NTCP_LKB_MODEL_H #define __NTCP_LKB_MODEL_H #include #include "rttbNTCPModel.h" #include "rttbBaseTypeModels.h" namespace rttb { namespace models { /*! @class NTCPLKBModel @brief This class represents a NTCP(Normal Tissue Complication Probability) LKB model (Lyman 1985, Kutcher and Burman 1989) @see NTCPModel */ class NTCPLKBModel: public NTCPModel { public: - typedef NTCPModel::ParamVectorType ParamVectorType; - typedef NTCPModel::DVHPointer DVHPointer; + using ParamVectorType = NTCPModel::ParamVectorType; + using DVHPointer = NTCPModel::DVHPointer; private: /*! The steepness of the dose-response curve. Must not be zero on model evaluation. */ BioModelParamType _m{0}; /*! Tumor or normal tissue-specific parameter that describes the dose-volume effect, e.g. -10 for prostate (Wu 2002). Must not be zero on model evaluation, because EUD calculation will fail. */ BioModelParamType _a{0}; protected: /*! @brief Calculate the model value * @param doseFactor: scaling factor for the dose. The model calculation will use the dvh with each di=old di*doseFactor. * @throw if either _a or _m is zero for the model calculation */ BioModelValueType calcModel(const double doseFactor = 1) override; public: NTCPLKBModel(); NTCPLKBModel(DVHPointer aDvh, BioModelParamType aD50, BioModelParamType aM, BioModelParamType aA); void setM(const BioModelParamType aM); const BioModelParamType getM(); void setA(const BioModelParamType aA); const BioModelParamType getA(); /*! @brief Set parameter with ID. "d50":0,"m":1,"a":2 @exception InvalidParameterException Thrown if aParamId is not 0 or 1 or 2. */ void setParameterByID(const int aParamId, const BioModelParamType aValue) override; /*! @brief Set parameter vector, where index of vector is the parameter ID. "d50":0,"m":1,"a":2 @exception InvalidParameterException Thrown if aParamterVector.size()!=3. */ void setParameterVector(const ParamVectorType& aParameterVector) override; /*! @brief Get parameter ID. "d50":0,"m":1,"a":2 @return 0 for "d50", 1 for "m", 2 for "a" @exception InvalidParameterException Thrown if aParamName is not d50 or m or a. */ const int getParameterID(const std::string& aParamName) const override; std::map getParameterMap() const override; void fillParameterMap() override; std::string getModelType() const override; }; } } #endif diff --git a/code/models/rttbNTCPModel.h b/code/models/rttbNTCPModel.h index 3f09c3e..3364297 100644 --- a/code/models/rttbNTCPModel.h +++ b/code/models/rttbNTCPModel.h @@ -1,67 +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 __NTCP_MODEL_H #define __NTCP_MODEL_H #include "rttbBioModel.h" #include "rttbBaseTypeModels.h" namespace rttb { namespace models { /*! @class NTCPModel @brief This is the interface class for NTCP(Normal Tissue Complication Probability) models */ class NTCPModel: public BioModel { public: - typedef BioModel::ParamVectorType ParamVectorType; - typedef BioModel::DVHPointer DVHPointer; + using ParamVectorType = BioModel::ParamVectorType; + using DVHPointer = BioModel::DVHPointer; protected: BioModelParamType _d50{0}; public: NTCPModel(): BioModel() {} NTCPModel(const BioModelParamType aD50): BioModel(), _d50(aD50) {} NTCPModel(DVHPointer aDvh, const BioModelParamType aD50): BioModel(aDvh), _d50(aD50) {} const BioModelParamType getD50() { return _d50; } void setD50(const BioModelParamType aD50) { _d50 = aD50; } }; }//end namespace models }//end namespace rttb #endif diff --git a/code/models/rttbNTCPRSModel.h b/code/models/rttbNTCPRSModel.h index 32d237d..9aba15b 100644 --- a/code/models/rttbNTCPRSModel.h +++ b/code/models/rttbNTCPRSModel.h @@ -1,111 +1,111 @@ // ----------------------------------------------------------------------- // 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 __NTCP_RS_MODEL_H #define __NTCP_RS_MODEL_H #include #include "rttbNTCPModel.h" #include "rttbBaseTypeModels.h" namespace rttb { namespace models { /*! @class NTCPRSModel @brief This class represents a NTCP(Normal Tissue Complication Probability) relative seriality model (Kaellman 1992) @see NTCPModel */ class NTCPRSModel: public NTCPModel { public: - typedef NTCPModel::ParamVectorType ParamVectorType; - typedef NTCPModel::DVHPointer DVHPointer; + using ParamVectorType = NTCPModel::ParamVectorType; + using DVHPointer = NTCPModel::DVHPointer; private: /*! _gamma The normalised dose-response gradient, values between 1.7 and 2.0 are typical for human tumours. (Kaellman 1992) */ BioModelParamType _gamma{0}; /*! _s The relative seriality factor, e.g. s=3.4 for the esophagus (highly serial structure) and s=0.0061 for the lung(highly parallel structure). Must not be zero on model evaluation. */ BioModelParamType _s{0}; const double poissonModel(const double dose); protected: /*! @brief Calculate the model value @param doseFactor scaling factor for the dose. The model calculation will use the dvh with each di=old di*doseFactor. @throw if either _s or _d50 is zero for the model calculation. */ BioModelValueType calcModel(const double doseFactor = 1) override; public: NTCPRSModel(); /*!@brief Constructor initializing all member variables with given parameters. */ NTCPRSModel(DVHPointer aDvh, BioModelParamType aD50, BioModelParamType aGamma, BioModelParamType aS); void setGamma(const BioModelParamType aGamma); const BioModelParamType getGamma(); void setS(const BioModelParamType aS); const BioModelParamType getS(); /*! @brief Set parameter with ID. "d50":0,"gamma":1,"s":2 @exception InvalidParameterException Thrown if aParamId is not 0 or 1 or 2. */ void setParameterByID(const int aParamId, const BioModelParamType aValue) override; /*! @brief Set parameter vector, where index of vector is the parameter Id. "d50":0,"gamma":1,"s":2 @exception InvalidParameterException Thrown if aParamterVector.size()!=3. */ void setParameterVector(const ParamVectorType& aParameterVector) override; /*! @brief Get parameter ID. "d50":0,"gamma":1,"s":2 @return 0 for "d50", 1 for "gamma", 2 for "s" @exception InvalidParameterException Thrown if aParamName is not d50 or gamma or s. */ const int getParameterID(const std::string& aParamName) const override; std::map getParameterMap() const override; void fillParameterMap() override; std::string getModelType() const override; }; } } #endif diff --git a/code/models/rttbTCPLQModel.h b/code/models/rttbTCPLQModel.h index 9e1cdd6..adada5e 100644 --- a/code/models/rttbTCPLQModel.h +++ b/code/models/rttbTCPLQModel.h @@ -1,169 +1,169 @@ // ----------------------------------------------------------------------- // 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 __TCP_LQ_MODEL_H #define __TCP_LQ_MODEL_H #include #include #include "rttbTCPModel.h" #include "rttbBaseTypeModels.h" namespace rttb { namespace models { /*! @class TCPLQModel @brief This class represents a TCP(Tumor Control Probability) LQ model (Nahum and Sanchez-Nieto 2001, Hall and Giaccia 2006) @see TCPModel */ class TCPLQModel: public TCPModel { public: - typedef TCPModel::ParamVectorType ParamVectorType; - typedef TCPModel::DVHPointer DVHPointer; + using ParamVectorType = TCPModel::ParamVectorType; + using DVHPointer = TCPModel::DVHPointer; private: /*! @brief Calculate intermediate tcp using alpha constant. This is a helper function for calcTCP() @see calcTCP */ long double calcTCPi(BioModelParamType aRho, BioModelParamType aAlphaMean, double vj, double bedj); /*! @brief Calculate tcp using alpha constant. */ long double calcTCP(std::map aBEDDVH, BioModelParamType aRho, BioModelParamType aAlphaMean, double aDeltaV); /*! @brief Calculate tcp using a normal distribution for alpha. */ long double calcTCPAlphaNormalDistribution(std::map aBEDDVH, BioModelParamType aRho, BioModelParamType aAlphaMean, BioModelParamType aAlphaVariance, double aDeltaV); protected: BioModelParamType _alphaMean{0}; BioModelParamType _alphaVariance{0}; BioModelParamType _alpha_beta{0}; /*! Roh is the initial clonogenic cell density */ BioModelParamType _rho{0}; /*! @brief Calculate the model value @param doseFactor scaling factor for prescribed dose. The model calculation will use the dvh with each di=old di*doseFactor. @pre _alphaMean >0 @pre _alphaVariance >= 0 @pre _alpha_beta > 0 @pre _rho > 0 @pre _numberOfFractions > 1 @exception InvalidParameterException Thrown if parameters were not set correctly. */ BioModelValueType calcModel(const double doseFactor = 1) override; public: TCPLQModel(); /*! @brief Constructor initializes member variables with given parameters. @pre aAlphaMean >0 @pre aBeta > 0 @pre aRho > 0 @pre aNumberOfFractions > 1 */ TCPLQModel(DVHPointer aDVH, BioModelParamType aAlphaMean, BioModelParamType aBeta, BioModelParamType aRho, int aNumberOfFractions); /*! @brief Constructor for alpha distribution initializes member variables with given parameters. @pre aAlphaMean >0 @pre aAlphaVariance >0 @pre aAlpha_Beta > 0 @pre aRho > 0 @pre aNumberOfFractions > 1 */ TCPLQModel(DVHPointer aDVH, BioModelParamType aRho, int aNumberOfFractions, BioModelParamType aAlpha_Beta, BioModelParamType aAlphaMean, BioModelParamType aAlphaVariance); const BioModelParamType getRho(); void setRho(const BioModelParamType aRho); const BioModelParamType getAlphaMean(); const BioModelParamType getAlphaVariance(); /*! @brief The distribution of the parameter alpha, which is characteristic for a population of cells, is described by the its mean and variance. If alpha is constant the variance is 0. @param aAlphaVariance The variance of alpha can be given, the default value is 0 resulting in constant alpha. */ void setAlpha(const BioModelParamType aAlphaMean, const BioModelParamType aAlphaVariance = 0); const BioModelParamType getAlphaBeta(); void setAlphaBeta(const BioModelParamType aAlpha_Beta); /*! @brief Set parameters for the TCP model. _value will be reset to 0. @param aAlpha_Beta alpha/beta constant . @param aAlphaMean mean of alpha distribution. @param aAlphaVariance variance of alpha distribution. */ void setParameters(const BioModelParamType aAlphaMean, const BioModelParamType aAlpha_Beta, const BioModelParamType aRho, const BioModelParamType aAlphaVariance = 0); /*! @brief Set parameter with ID. "alphaMean":0,"alphaVariance":1,"alpha_beta":2, "rho":3 @exception InvalidParameterException Thrown if aParamId is not 0 or 1 or 2 or 3. */ void setParameterByID(const int aParamId, const BioModelParamType aValue) override; /*! @brief Set parameter vector, where index of vector is the parameter id. "alphaMean":0,"alphaVariance":1,"alpha_beta":2, "rho":3 @exception InvalidParameterException Thrown if aParamterVector.size()!=4. */ void setParameterVector(const ParamVectorType& aParameterVector) override; /*! @brief Get parameter id. "alphaMean":0,"alphaVariance":1,"alpha_beta":2, "rho":3 @return 0 for "alphaMean", 1 for "alphaVariance", 2 for "alpha_beta", 3 for "rho" @exception InvalidParameterException Thrown if aParamName is not alphaMean or alphaVariance or alpha_beta or rho. */ const int getParameterID(const std::string& aParamName) const override; std::map getParameterMap() const override; void fillParameterMap() override; std::string getModelType() const override; }; }//end algorithms }//end rttb #endif diff --git a/code/models/rttbTCPModel.h b/code/models/rttbTCPModel.h index 02d013d..b2ba8b3 100644 --- a/code/models/rttbTCPModel.h +++ b/code/models/rttbTCPModel.h @@ -1,63 +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 __TCP_MODEL_H #define __TCP_MODEL_H #include "rttbBioModel.h" namespace rttb { namespace models { /*! @class TCPModel @brief This is the interface class for TCP(Tumor Control Probability) models */ class TCPModel: public BioModel { public: - typedef BioModel::ParamVectorType ParamVectorType; - typedef BioModel::DVHPointer DVHPointer; + using ParamVectorType = BioModel::ParamVectorType; + using DVHPointer = BioModel::DVHPointer; protected: int _numberOfFractions{0}; public: TCPModel(): BioModel() {}; TCPModel(int aNum): BioModel(), _numberOfFractions(aNum) {}; TCPModel(DVHPointer aDvh, int aNum): BioModel(aDvh), _numberOfFractions(aNum) {}; void setNumberOfFractions(const int aNumberOfFractions); const int getNumberOfFractions(); }; }//end namespace models }//end namespace rttb #endif