diff --git a/code/algorithms/rttbArithmetic.cpp b/code/algorithms/rttbArithmetic.cpp
index 52bdf2b..fa10e9a 100644
--- a/code/algorithms/rttbArithmetic.cpp
+++ b/code/algorithms/rttbArithmetic.cpp
@@ -1,106 +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)
-*/
#include "rttbArithmetic.h"
-
namespace rttb
{
namespace algorithms
{
namespace arithmetic
{
void add(const DoseAccessorPointer dose1, const DoseAccessorPointer dose2,
MutableDoseAccessorPointer result)
{
doseOp::Add addOP;
arithmetic(dose1, dose2, result, addOP);
}
void add(const MaskAccessorPointer mask1, const MaskAccessorPointer mask2,
MutableMaskAccessorPointer result)
{
maskOp::Add addOP;
arithmetic(mask1, mask2, result, addOP);
}
void subtract(const MaskAccessorPointer mask1, const MaskAccessorPointer mask2,
MutableMaskAccessorPointer result)
{
maskOp::Subtract subOP;
arithmetic(mask1, mask2, result, subOP);
}
void multiply(const DoseAccessorPointer dose, const MaskAccessorPointer mask,
MutableDoseAccessorPointer result)
{
doseMaskOp::Multiply multOP;
arithmetic(dose, mask, result, multOP);
}
namespace doseOp
{
DoseTypeGy Add::calc(const DoseTypeGy dose1Val, const DoseTypeGy dose2Val) const
{
return dose1Val + dose2Val;
}
AddWeighted::AddWeighted(const DoseCalcType w1, const DoseCalcType w2):
weight1(w1), weight2(w2) {};
DoseTypeGy AddWeighted::calc(const DoseTypeGy dose1Val, const DoseTypeGy dose2Val) const
{
return weight1 * dose1Val + weight2 * dose2Val;
}
rttb::DoseTypeGy Multiply::calc(const DoseTypeGy dose1Val, const DoseTypeGy dose2Val) const
{
return dose1Val * dose2Val;
}
}
namespace doseMaskOp
{
DoseTypeGy Multiply::calc(const DoseTypeGy doseVal, const FractionType maskVal) const
{
return doseVal * maskVal;
}
}
namespace maskOp
{
FractionType Add::calc(const FractionType mask1Val, const FractionType mask2Val) const
{
FractionType added = mask1Val + mask2Val;
return (1 < added ? 1 : added);
}
FractionType Subtract::calc(const FractionType mask1Val, const FractionType mask2Val) const
{
FractionType sub = mask1Val - mask2Val;
return (0 > sub ? 0 : sub);
}
}
}
}
}
\ No newline at end of file
diff --git a/code/algorithms/rttbArithmetic.h b/code/algorithms/rttbArithmetic.h
index d62e403..3049953 100644
--- a/code/algorithms/rttbArithmetic.h
+++ b/code/algorithms/rttbArithmetic.h
@@ -1,159 +1,153 @@
// -----------------------------------------------------------------------
// 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
{
using DoseAccessorPointer = core::DoseAccessorInterface::Pointer;
using MutableDoseAccessorPointer = core::MutableDoseAccessorInterface::Pointer;
using MutableMaskAccessorPointer = core::MutableMaskAccessorInterface::Pointer;
using MaskAccessorPointer = core::MaskAccessorInterface::Pointer;
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/rttbArithmetic.tpp b/code/algorithms/rttbArithmetic.tpp
index 21de034..09eabec 100644
--- a/code/algorithms/rttbArithmetic.tpp
+++ b/code/algorithms/rttbArithmetic.tpp
@@ -1,129 +1,123 @@
// -----------------------------------------------------------------------
// 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 "rttbNullPointerException.h"
#include "rttbInvalidParameterException.h"
#ifndef __ARITHMETIC_TPP
#define __ARITHMETIC_TPP
namespace rttb
{
namespace algorithms
{
namespace arithmetic
{
template
void arithmetic(const DoseAccessorPointer dose1, const DoseAccessorPointer dose2,
MutableDoseAccessorPointer result, TDoseOperation op)
{
//handle null pointers
if (dose1 == nullptr || dose2 == nullptr || result == nullptr)
{
throw core::NullPointerException("Pointers to input accessors cannot be nullptr.");
}
//handle differences in geometricInfo
if (!(dose1->getGeometricInfo().equalsAlmost(dose2->getGeometricInfo())
&& dose1->getGeometricInfo().equalsAlmost(result->getGeometricInfo())))
{
throw core::InvalidParameterException("The geometricInfo of all given accessors needs to be equal.");
}
//apply operation op to doses with equal geometricInfo (same grid)
GridSizeType numVoxels = dose1->getGridSize();
for (VoxelGridID id = 0; id < numVoxels; ++id)
{
DoseTypeGy opVal = op.calc(dose1->getValueAt(id), dose2->getValueAt(id));
result->setDoseAt(id, opVal);
}
}
template
void arithmetic(const DoseAccessorPointer dose, const MaskAccessorPointer mask,
MutableDoseAccessorPointer result, TDoseMaskOperation op)
{
//handle null pointers
if (dose == nullptr || mask == nullptr || result == nullptr)
{
throw core::NullPointerException("Pointers to input accessors cannot be nullptr.");
}
//handle differences in geometricInfo
if (!(dose->getGeometricInfo().equalsAlmost(mask->getGeometricInfo())
&& dose->getGeometricInfo().equalsAlmost(result->getGeometricInfo())))
{
throw core::InvalidParameterException("The geometricInfo of all given accessors needs to be equal.");
}
//apply operation op to accessors with equal geometricInfo (same grid)
core::MaskVoxel mVoxel(0);
GridSizeType numVoxels = dose->getGridSize();
for (VoxelGridID id = 0; id < numVoxels; ++id)
{
mask->getMaskAt(id, mVoxel);
DoseTypeGy opVal = op.calc(dose->getValueAt(id), mVoxel.getRelevantVolumeFraction());
result->setDoseAt(id, opVal);
}
}
template
void arithmetic(const MaskAccessorPointer mask1, const MaskAccessorPointer mask2,
MutableMaskAccessorPointer result, TMaskOperation op)
{
//handle null pointers
if (mask1 == nullptr || mask2 == nullptr || result == nullptr)
{
throw core::NullPointerException("Pointers to input accessors cannot be nullptr.");
}
//handle differences in geometricInfo
if (!(mask1->getGeometricInfo().equalsAlmost(mask2->getGeometricInfo())
&& mask1->getGeometricInfo().equalsAlmost(result->getGeometricInfo())))
{
throw core::InvalidParameterException("The geometricInfo of all given accessors needs to be equal.");
}
//apply operation op to accessors with equal geometricInfo (same grid)
core::MaskVoxel m1Voxel(0);
//initialize results list with mask1 values
result->setRelevantVoxelVector(mask1->getRelevantVoxelVector());
MaskVoxelListPointer voxelListMask2 = mask2->getRelevantVoxelVector();
auto it = voxelListMask2->begin();
while (it != voxelListMask2->end())
{
mask1->getMaskAt(it->getVoxelGridID(), m1Voxel);
FractionType opVal = op.calc(m1Voxel.getRelevantVolumeFraction(), it->getRelevantVolumeFraction());
result->setMaskAt(it->getVoxelGridID(), core::MaskVoxel(it->getVoxelGridID(), opVal));
++it;
}
}
}
}
}
#endif
\ No newline at end of file
diff --git a/code/algorithms/rttbBinaryFunctorAccessor.h b/code/algorithms/rttbBinaryFunctorAccessor.h
index ffa3e45..0b927a9 100644
--- a/code/algorithms/rttbBinaryFunctorAccessor.h
+++ b/code/algorithms/rttbBinaryFunctorAccessor.h
@@ -1,99 +1,94 @@
// -----------------------------------------------------------------------
// 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 __BINARY_FUNCTOR_ACCESSOR_H
#define __BINARY_FUNCTOR_ACCESSOR_H
#include "rttbAccessorInterface.h"
#include "rttbBaseType.h"
namespace rttb
{
namespace algorithms
{
/*! @class BinaryFunctorAccessor
@brief Class that allows to access the results of a binary operation.
@details this Accessor takes two accessors as operants (the operants must have the same geometry)
and computes a resulting value by using a given operation functor.
The resulting value will be returned from the accessor as its value upon request.
@remark this can be seen as a lazy filter pattern, thus the accessor is filtering/operating on dose values upon request.
*/
template
class BinaryFunctorAccessor: public core::AccessorInterface
{
protected:
core::AccessorInterface::ConstPointer _spData1;
core::AccessorInterface::ConstPointer _spData2;
TDoseOperation _functor;
public:
/*! @brief Constructor.
@param data1 pointer to the 1st data operand
@param data2 pointer to the 2nd data operand
@param functor Instance of the operation that should be used
@pre all input parameters have to be valid
@exception core::NullPointerException if one input parameter is nullptr or if geometricInfos don't match
*/
BinaryFunctorAccessor(core::AccessorInterface::ConstPointer data1, core::AccessorInterface::ConstPointer data2,
const TDoseOperation& functor);
/*! @brief Virtual destructor
*/
~BinaryFunctorAccessor() override = default;
/*! @pre: the geometricInfo of both doseAccessors are equal
*/
inline const core::GeometricInfo& getGeometricInfo() const override
{
return _spData1->getGeometricInfo();
};
/*! @pre: the geometricInfo of both doseAccessors are equal
*/
inline GridSizeType getGridSize() const override
{
return _spData1->getGeometricInfo().getNumberOfVoxels();
};
/*! @brief Returns the result dose computed by the functor.
It uses the dose values of both operand doses specified via the passed ID.
@return the dose value if inside, -1 else
@pre .calc(dose1,dose2) has to be implemented
*/
GenericValueType getValueAt(const VoxelGridID aID) const override;
/*! @brief Returns the result dose computed by the functor.
It uses the dose values of both operand doses specified via the passed index.
@return the dose value if inside, -1 else
@pre .calc(dose1,dose2) has to be implemented
*/
GenericValueType getValueAt(const VoxelGridIndex3D& aIndex) const override;
const IDType getUID() const override
{
return IDType();
}
};
}
}
#include "rttbBinaryFunctorAccessor.tpp"
#endif
diff --git a/code/algorithms/rttbBinaryFunctorAccessor.tpp b/code/algorithms/rttbBinaryFunctorAccessor.tpp
index 7b2887d..c56e9ed 100644
--- a/code/algorithms/rttbBinaryFunctorAccessor.tpp
+++ b/code/algorithms/rttbBinaryFunctorAccessor.tpp
@@ -1,82 +1,76 @@
// -----------------------------------------------------------------------
// RTToolbox - DKFZ radiotherapy quantitative evaluation library
//
// Copyright (c) German Cancer Research Center (DKFZ),
// Software development for Integrated Diagnostics and Therapy (SIDT).
// ALL RIGHTS RESERVED.
// See rttbCopyright.txt or
// http://www.dkfz.de/en/sidt/projects/rttb/copyright.html
//
// This software is distributed WITHOUT ANY WARRANTY; without even
// the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
// PURPOSE. See the above copyright notices for more information.
//
//------------------------------------------------------------------------
-/*!
-// @file
-// @version $Revision$ (last changed revision)
-// @date $Date$ (last change date)
-// @author $Author$ (last changed by)
-*/
#include "rttbBinaryFunctorAccessor.h"
#ifndef __BINARY_FUNCTOR_ACCESSOR_TPP
#define __BINARY_FUNCTOR_ACCESSOR_TPP
namespace rttb
{
namespace algorithms
{
template
BinaryFunctorAccessor::BinaryFunctorAccessor(core::AccessorInterface::ConstPointer
data1, core::AccessorInterface::ConstPointer data2,
const TDoseOperation& functor)
{
if (data1 == nullptr || data2 == nullptr)
{
throw core::NullPointerException("Pointers to input accessors cannot be nullptr.");
}
if (!(data1->getGeometricInfo() == data2->getGeometricInfo()))
{
throw core::InvalidParameterException("The geometricInfo of all given accessors needs to be equal.");
}
_spData1 = data1;
_spData2 = data2;
_functor = functor;
}
template GenericValueType BinaryFunctorAccessor::getValueAt(
const VoxelGridID aID) const
{
if (getGeometricInfo().validID(aID))
{
GenericValueType value = _functor.calc(_spData1->getValueAt(aID), _spData2->getValueAt(aID));
return value;
}
else
{
return -1;
}
}
template DoseTypeGy BinaryFunctorAccessor::getValueAt(
const VoxelGridIndex3D& aIndex) const
{
VoxelGridID aVoxelGridID;
if (_spData1->getGeometricInfo().convert(aIndex, aVoxelGridID))
{
return getValueAt(aVoxelGridID);
}
else
{
return -1;
}
}
}
}
#endif
\ No newline at end of file
diff --git a/code/algorithms/rttbDoseStatistics.cpp b/code/algorithms/rttbDoseStatistics.cpp
index 464a80f..a1147a0 100644
--- a/code/algorithms/rttbDoseStatistics.cpp
+++ b/code/algorithms/rttbDoseStatistics.cpp
@@ -1,293 +1,287 @@
// -----------------------------------------------------------------------
// 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 "rttbDoseStatistics.h"
#include "boost/make_shared.hpp"
#include "rttbDataNotAvailableException.h"
#include "rttbInvalidParameterException.h"
namespace rttb
{
namespace algorithms
{
DoseStatistics::DoseStatistics(DoseStatisticType minimum, DoseStatisticType maximum, DoseStatisticType mean,
DoseStatisticType stdDeviation, VoxelNumberType numVoxels, VolumeType volume,
ResultListPointer maximumVoxelPositions /*= ResultListPointer()*/,
ResultListPointer minimumVoxelPositions /*= ResultListPointer()*/,
VolumeToDoseMeasureCollection Dx,
DoseToVolumeMeasureCollection Vx,
VolumeToDoseMeasureCollection MOHx,
VolumeToDoseMeasureCollection MOCx,
VolumeToDoseMeasureCollection MaxOHx,
VolumeToDoseMeasureCollection MinOCx,
DoseTypeGy referenceDose /*=-1*/):
_minimum(minimum), _maximum(maximum), _mean(mean), _stdDeviation(stdDeviation),
_numVoxels(numVoxels), _volume(volume),
_Dx(::boost::make_shared(Dx)),
_Vx(::boost::make_shared(Vx)),
_MOHx(::boost::make_shared(MOHx)),
_MOCx(::boost::make_shared(MOCx)),
_MaxOHx(::boost::make_shared(MaxOHx)),
_MinOCx(::boost::make_shared(MinOCx))
{
if (maximumVoxelPositions == nullptr)
{
_maximumVoxelPositions = boost::make_shared > >
(std::vector >());
}
else
{
_maximumVoxelPositions = maximumVoxelPositions;
}
if (minimumVoxelPositions == nullptr)
{
_minimumVoxelPositions = boost::make_shared > >
(std::vector >());
}
else
{
_minimumVoxelPositions = minimumVoxelPositions;
}
if (referenceDose <= 0)
{
_referenceDose = _maximum;
}
else
{
_referenceDose = referenceDose;
}
}
DoseStatistics::~DoseStatistics()
= default;
void DoseStatistics::setMinimumVoxelPositions(ResultListPointer minimumVoxelPositions)
{
_minimumVoxelPositions = minimumVoxelPositions;
}
void DoseStatistics::setMaximumVoxelPositions(ResultListPointer maximumVoxelPositions)
{
_maximumVoxelPositions = maximumVoxelPositions;
}
void DoseStatistics::setDx(VolumeToDoseMeasureCollection::Pointer DxValues)
{
_Dx = DxValues;
}
void DoseStatistics::setVx(DoseToVolumeMeasureCollection::Pointer VxValues)
{
_Vx = VxValues;
}
void DoseStatistics::setMOHx(VolumeToDoseMeasureCollection::Pointer MOHxValues)
{
_MOHx = MOHxValues;
}
void DoseStatistics::setMOCx(VolumeToDoseMeasureCollection::Pointer MOCxValues)
{
_MOCx = MOCxValues;
}
void DoseStatistics::setMaxOHx(VolumeToDoseMeasureCollection::Pointer MaxOHValues)
{
_MaxOHx = MaxOHValues;
}
void DoseStatistics::setMinOCx(VolumeToDoseMeasureCollection::Pointer MinOCValues)
{
_MinOCx = MinOCValues;
}
void DoseStatistics::setReferenceDose(DoseTypeGy referenceDose)
{
if (referenceDose <= 0)
{
_referenceDose = _maximum;
}
else
{
_referenceDose = referenceDose;
}
}
VoxelNumberType DoseStatistics::getNumberOfVoxels() const
{
return _numVoxels;
}
VolumeType DoseStatistics::getVolume() const
{
return _volume;
}
DoseTypeGy DoseStatistics::getReferenceDose() const
{
return _referenceDose;
}
DoseStatisticType DoseStatistics::getMaximum() const
{
return _maximum;
}
DoseStatisticType DoseStatistics::getMinimum() const
{
return _minimum;
}
DoseStatisticType DoseStatistics::getMean() const
{
return _mean;
}
DoseStatisticType DoseStatistics::getStdDeviation() const
{
return _stdDeviation;
}
DoseStatisticType DoseStatistics::getVariance() const
{
return _stdDeviation * _stdDeviation;
}
double DoseStatistics::getValue(const std::map& aMap, double key,
bool findNearestValueInstead, double& storedKey) const
{
if (aMap.find(key) != std::end(aMap))
{
return aMap.find(key)->second;
}
else
{
//value not in map. We have to find the nearest value
if (aMap.empty())
{
throw core::DataNotAvailableException("No Vx values are defined");
}
else
{
if (findNearestValueInstead)
{
auto iterator = findNearestKeyInMap(aMap, key);
storedKey = iterator->first;
return iterator->second;
}
else
{
throw core::DataNotAvailableException("No Vx value with required dose is defined");
}
}
}
}
std::map::const_iterator DoseStatistics::findNearestKeyInMap(
const std::map& aMap,
double key) const
{
double minDistance = 1e19;
double minDistanceLast = 1e20;
auto iterator = std::begin(aMap);
while (iterator != std::end(aMap))
{
minDistanceLast = minDistance;
minDistance = fabs(iterator->first - key);
if (minDistanceLast > minDistance)
{
++iterator;
}
else
{
if (iterator != std::begin(aMap))
{
--iterator;
return iterator;
}
else
{
return std::begin(aMap);
}
}
}
--iterator;
return iterator;
}
DoseStatistics::ResultListPointer DoseStatistics::getMaximumVoxelPositions() const
{
return _maximumVoxelPositions;
}
DoseStatistics::ResultListPointer DoseStatistics::getMinimumVoxelPositions() const
{
return _minimumVoxelPositions;
}
DoseToVolumeMeasureCollection DoseStatistics::getVx() const
{
return *_Vx;
}
VolumeToDoseMeasureCollection DoseStatistics::getDx() const
{
return *_Dx;
}
VolumeToDoseMeasureCollection DoseStatistics::getMOHx() const
{
return *_MOHx;
}
VolumeToDoseMeasureCollection DoseStatistics::getMOCx() const
{
return *_MOCx;
}
VolumeToDoseMeasureCollection DoseStatistics::getMaxOHx() const
{
return *_MaxOHx;
}
VolumeToDoseMeasureCollection DoseStatistics::getMinOCx() const
{
return *_MinOCx;
}
}//end namespace algorithms
}//end namespace rttb
diff --git a/code/algorithms/rttbDoseStatistics.h b/code/algorithms/rttbDoseStatistics.h
index 6bd70bb..2480321 100644
--- a/code/algorithms/rttbDoseStatistics.h
+++ b/code/algorithms/rttbDoseStatistics.h
@@ -1,178 +1,172 @@
// -----------------------------------------------------------------------
// 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