diff --git a/Modules/PhotoacousticSimulation/src/Algorithms/mitkPhotoacousticFatTissueGenerator.cpp b/Modules/PhotoacousticSimulation/src/Algorithms/mitkPhotoacousticFatTissueGenerator.cpp index 6a1df077c2..bedaa8412a 100644 --- a/Modules/PhotoacousticSimulation/src/Algorithms/mitkPhotoacousticFatTissueGenerator.cpp +++ b/Modules/PhotoacousticSimulation/src/Algorithms/mitkPhotoacousticFatTissueGenerator.cpp @@ -1,45 +1,51 @@ #include "mitkPhotoacousticFatTissueGenerator.h" #include #include #include void mitk::PhotoacousticFatTissueGenerator::CreateFatGlobules(mitk::PhotoacousticVolume::Pointer image, double bodyFatPercentage, double fatAbsorption, double fatScattering, double fatAnisotropy, std::mt19937* rng) { + const double VOLUME_CONSTANT = 4.0 / 3.0 * 3.14159265359; + const double NORMAL_DISTRIBUTION_SIGMA = 0.2; + const double MINIMUM_FAT_GLOBULES_FACTOR = 0.83; + const double MAXIMUM_FAT_GLOBULES_FACTOR = 1.2; + int xDim = image->getXDim(); int yDim = image->getYDim(); int zDim = image->getZDim(); long length = xDim*yDim*zDim; double sqrtLength = 2 * sqrt(sqrt(length)); - std::uniform_int_distribution<> numberOfFatGlobulesDist(0.83*sqrtLength, 1.2*sqrtLength); - std::normal_distribution<> normal(1, 0.1); + std::uniform_int_distribution<> numberOfFatGlobulesDist(MINIMUM_FAT_GLOBULES_FACTOR*sqrtLength, + MAXIMUM_FAT_GLOBULES_FACTOR*sqrtLength); + std::normal_distribution<> normalDistribution(1, NORMAL_DISTRIBUTION_SIGMA); int numberOfFatGlobules = numberOfFatGlobulesDist(*rng); - double radius = pow(length*bodyFatPercentage/100.0/(numberOfFatGlobules * 4.0 / 3.0 * 3.141), (1.0/3.0)); + double radius = pow(length*bodyFatPercentage/100.0/(numberOfFatGlobules * VOLUME_CONSTANT), (1.0/3.0)); std::uniform_int_distribution<> xDist(-radius, xDim+radius); std::uniform_int_distribution<> yDist(-radius, yDim+radius); std::uniform_int_distribution<> zDist(1.5*radius, zDim+radius); for(int fatGlobuleIdx = 0; fatGlobuleIdxSetVolumeValues(x, y, z, fatAbsorption, fatScattering, fatAnisotropy, mitk::PhotoacousticVolume::SegmentationType::FAT); } } } } diff --git a/Modules/PhotoacousticSimulation/src/Algorithms/mitkPhotoacousticFatTissueGenerator.h b/Modules/PhotoacousticSimulation/src/Algorithms/mitkPhotoacousticFatTissueGenerator.h index 6509b43454..13ed049ca7 100644 --- a/Modules/PhotoacousticSimulation/src/Algorithms/mitkPhotoacousticFatTissueGenerator.h +++ b/Modules/PhotoacousticSimulation/src/Algorithms/mitkPhotoacousticFatTissueGenerator.h @@ -1,41 +1,40 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #ifndef MITKPHOTOACOUSTICFATTISSUEGENERATOR_H #define MITKPHOTOACOUSTICFATTISSUEGENERATOR_H #include "MitkPhotoacousticSimulationExports.h" #include "mitkPhotoacousticVolume.h" namespace mitk { class MITKPHOTOACOUSTICSIMULATION_EXPORT PhotoacousticFatTissueGenerator { public: static void CreateFatGlobules(mitk::PhotoacousticVolume::Pointer image, double bodyFatPercentage, double fatAbsorption, double fatScattering, double fatAnisotropy, std::mt19937* rng); - private: PhotoacousticFatTissueGenerator(); ~PhotoacousticFatTissueGenerator(); }; } #endif // MITKPHOTOACOUSTICFATTISSUEGENERATOR_H diff --git a/Modules/PhotoacousticSimulation/src/Algorithms/mitkPhotoacousticVessel.h b/Modules/PhotoacousticSimulation/src/Algorithms/mitkPhotoacousticVessel.h index 10d5a990a4..bed86c90bf 100644 --- a/Modules/PhotoacousticSimulation/src/Algorithms/mitkPhotoacousticVessel.h +++ b/Modules/PhotoacousticSimulation/src/Algorithms/mitkPhotoacousticVessel.h @@ -1,125 +1,125 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #ifndef MITKVESSEL_H #define MITKVESSEL_H #include "mitkVector.h" #include "mitkPhotoacousticVesselMeanderStrategy.h" #include "mitkPhotoacousticVolume.h" #include "mitkPhotoacousticSmartVector.h" #include "mitkPhotoacousticStatefulObject.h" #include //Includes for smart pointer usage #include "mitkCommon.h" #include "itkLightObject.h" namespace mitk { class MITKPHOTOACOUSTICSIMULATION_EXPORT PhotoacousticVessel : public itk::LightObject, public mitk::PhotoacousticStatefulObject { public: mitkClassMacroItkParent(mitk::PhotoacousticVessel, itk::LightObject) itkFactorylessNewMacro(Self) /** * Callback function definition of a PhotoacousticVesselMeanderStrategy */ typedef void (mitk::PhotoacousticVesselMeanderStrategy::*CalculateNewVesselPositionCallback) (mitk::PhotoacousticSmartVector::Pointer, mitk::PhotoacousticSmartVector::Pointer, double, std::mt19937*); /** * @brief Initialize initializes this PhotoacousticVessel with the given parameters. * * @param initialPosition * @param initialDirection * @param initialRadius * @param absorptionCoefficient * @param scatteringCoefficient * @param anisotropyCoefficient * @param bifurcationFrequency * @param rng */ void Initialize(mitk::PhotoacousticSmartVector::Pointer initialPosition, mitk::PhotoacousticSmartVector::Pointer initialDirection, double initialRadius, double absorptionCoefficient, double scatteringCoefficient, double anisotropyCoefficient, double bifurcationFrequency, std::mt19937* rng); /** * @brief ExpandVessel makes this PhotoacousticVessel expand one step in its current direction. * After expanding, the vessel will draw itself into the given PhotoacousticVolume. * * @param volume volume for the vessel to draw itself in * @param calculateNewPosition a callback function of the PhotoacousticVesselMeanderStrategy class. * It is used to calculate the final position after taking the step. * @param bendingFactor a metric of how much the PhotoacousticVessel should bend. If set to 0 the vessel will go in a straight line. */ void ExpandVessel(mitk::PhotoacousticVolume::Pointer volume, CalculateNewVesselPositionCallback calculateNewPosition, double bendingFactor, std::mt19937* rng); /** * @brief CanBifurcate * @return true if the PhotoacousticVessel is ready to Bifurcate() */ bool CanBifurcate(); /** * @brief Bifurcate bifurcates this vessel into two new ones. Makes sure that the volume of the vessels stays the same. * * @return a new vessel split up from the current one. */ mitk::PhotoacousticVessel::Pointer Bifurcate(std::mt19937* rng); /** * @brief IsFinished * @return true if the vessel cannot expand any further */ bool IsFinished(); protected: PhotoacousticVessel(); virtual ~PhotoacousticVessel(); private: - const double MIN_RADIUS = 1; + const double MINIMUM_VESSEL_RADIUS = 1; const double SCALING_FACTOR = 0.33; const double VESSEL_BIFURCATION_VARIATION_SIGMA = 0.2; const double NEW_RADIUS_MINIMUM_RELATIVE_SIZE = 0.6; const double NEW_RADIUS_MAXIMUM_RELATIVE_SIZE = 0.8; void DrawVesselInVolume(mitk::PhotoacousticSmartVector::Pointer toPosition, mitk::PhotoacousticVolume::Pointer volume); mitk::PhotoacousticSmartVector::Pointer m_Position; mitk::PhotoacousticSmartVector::Pointer m_Direction; double m_Radius; double m_AbsorptionCoefficient; double m_ScatteringCoefficient; double m_AnisotropyCoefficient; double m_WalkedDistance; double m_BifurcationFrequency; mitk::PhotoacousticVesselMeanderStrategy::Pointer m_VesselMeanderStrategy; bool m_Finished; std::uniform_real_distribution<> m_RangeDistribution; std::uniform_real_distribution<> m_SignDistribution; std::uniform_real_distribution<> m_RadiusRangeDistribution; int GetSign(std::mt19937* rng); }; } #endif // MITKVESSEL_H