diff --git a/Modules/PhotoacousticsLib/CMakeLists.txt b/Modules/PhotoacousticsLib/CMakeLists.txt index 8c89b2658e..c8a54e6776 100644 --- a/Modules/PhotoacousticsLib/CMakeLists.txt +++ b/Modules/PhotoacousticsLib/CMakeLists.txt @@ -1,12 +1,14 @@ MITK_CREATE_MODULE( INCLUDE_DIRS PUBLIC include INTERNAL_INCLUDE_DIRS ${INCLUDE_DIRS_INTERNAL} DEPENDS PUBLIC MitkAlgorithmsExt tinyxml PACKAGE_DEPENDS tinyxml PUBLIC ITK ) add_subdirectory(MitkMCxyz) +add_subdirectory(MitkTissueBatchGenerator) + add_subdirectory(test) diff --git a/Modules/PhotoacousticsLib/MitkTissueBatchGenerator/CMakeLists.txt b/Modules/PhotoacousticsLib/MitkTissueBatchGenerator/CMakeLists.txt new file mode 100644 index 0000000000..73a948b462 --- /dev/null +++ b/Modules/PhotoacousticsLib/MitkTissueBatchGenerator/CMakeLists.txt @@ -0,0 +1,11 @@ +OPTION(BUILD_PhotoacousticTissueBatchGenerator "Build MiniApp for batch generating of photoacoustic tissue" ON) + +IF(BUILD_PhotoacousticTissueBatchGenerator) + PROJECT( MitkTissueBatchGenerator ) + mitk_create_executable(TissueBatchGenerator + DEPENDS MitkCommandLine MitkCore MitkPhotoacousticsLib + PACKAGE_DEPENDS + CPP_FILES TissueBatchGenerator.cpp) + + install(TARGETS ${EXECUTABLE_TARGET} RUNTIME DESTINATION bin) + ENDIF() diff --git a/Modules/PhotoacousticsLib/MitkTissueBatchGenerator/TissueBatchGenerator.cpp b/Modules/PhotoacousticsLib/MitkTissueBatchGenerator/TissueBatchGenerator.cpp new file mode 100644 index 0000000000..cd143fb612 --- /dev/null +++ b/Modules/PhotoacousticsLib/MitkTissueBatchGenerator/TissueBatchGenerator.cpp @@ -0,0 +1,88 @@ +/*=================================================================== + +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. + +===================================================================*/ + +#include +#include +#include +#include +#include + +using namespace mitk::pa; + +TissueGeneratorParameters::Pointer CreateMultivessel_06_10_17_Parameters() +{ + auto returnParameters = TissueGeneratorParameters::New(); + returnParameters->SetAirThicknessInMillimeters(12); + returnParameters->SetBackgroundAbsorption(0.1); + returnParameters->SetBackgroundAnisotropy(0.9); + returnParameters->SetBackgroundScattering(15); + returnParameters->SetCalculateNewVesselPositionCallback(&VesselMeanderStrategy::CalculateRandomlyDivergingPosition); + returnParameters->SetDoPartialVolume(true); + returnParameters->SetMinNumberOfVessels(1); + returnParameters->SetMaxNumberOfVessels(7); + returnParameters->SetMinVesselAbsorption(2); + returnParameters->SetMaxVesselAbsorption(8); + returnParameters->SetMinVesselAnisotropy(0.9); + returnParameters->SetMaxVesselAnisotropy(0.9); + returnParameters->SetMinVesselBending(0.1); + returnParameters->SetMaxVesselBending(0.3); + returnParameters->SetMinVesselRadiusInMillimeters(0.5); + returnParameters->SetMaxVesselRadiusInMillimeters(4); + returnParameters->SetMinVesselScattering(15); + returnParameters->SetMaxVesselScattering(15); + returnParameters->SetMinVesselZOrigin(2.2); + returnParameters->SetMaxVesselZOrigin(4); + returnParameters->SetVesselBifurcationFrequency(5000); + returnParameters->SetRandomizePhysicalProperties(false); + returnParameters->SetSkinThicknessInMillimeters(0); + returnParameters->SetUseRngSeed(false); + returnParameters->SetVoxelSpacingInCentimeters(0.03); + returnParameters->SetXDim(140); + returnParameters->SetYDim(200); + returnParameters->SetZDim(140); + return returnParameters; +} + +struct InputParameters +{ + std::string saveFolderPath; + std::string identifyer; + std::string exePath; +}; + +InputParameters parseInput(int argc, char* argv[]) +{ + InputParameters input; + + return input; +} + +int main(int argc, char * argv[]) +{ + auto input = parseInput(argc, argv); + unsigned int iterationNumber = 0; + + while (iterationNumber == 0) + { + auto parameters = CreateMultivessel_06_10_17_Parameters(); + auto resultTissue = InSilicoTissueGenerator::GenerateInSilicoData(parameters); + + std::string savePath = input.saveFolderPath + "/MultiVessel_" + input.identifyer + std::to_string(iterationNumber) + ".nrrd"; + mitk::IOUtil::Save(resultTissue->ConvertToMitkImage(), savePath); + + iterationNumber++; + } +} diff --git a/Modules/PhotoacousticsLib/MitkTissueBatchGenerator/files.cmake b/Modules/PhotoacousticsLib/MitkTissueBatchGenerator/files.cmake new file mode 100644 index 0000000000..d4e42c83d5 --- /dev/null +++ b/Modules/PhotoacousticsLib/MitkTissueBatchGenerator/files.cmake @@ -0,0 +1,3 @@ +set(CPP_FILES + TissueBatchGenerator.cpp +) diff --git a/Modules/PhotoacousticsLib/src/Utils/mitkPAVesselDrawer.cpp b/Modules/PhotoacousticsLib/src/Utils/mitkPAVesselDrawer.cpp index a0193346eb..2f9b266fa0 100644 --- a/Modules/PhotoacousticsLib/src/Utils/mitkPAVesselDrawer.cpp +++ b/Modules/PhotoacousticsLib/src/Utils/mitkPAVesselDrawer.cpp @@ -1,85 +1,82 @@ /*=================================================================== 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. ===================================================================*/ #include "mitkPAVesselDrawer.h" #include "mitkPAVesselProperties.h" mitk::pa::VesselDrawer::VesselDrawer() { } mitk::pa::VesselDrawer::~VesselDrawer() { } void mitk::pa::VesselDrawer::DrawVesselInVolume( VesselProperties::Pointer properties, InSilicoTissueVolume::Pointer volume) { Vector::Pointer stepDirection = properties->GetDirectionVector(); Vector::Pointer fromPosition = properties->GetPositionVector()->Clone(); Vector::Pointer toPosition = properties->GetPositionVector()->Clone(); Vector::Pointer totalWalkingDistance = stepDirection->Clone(); totalWalkingDistance->Scale(1.0 / volume->GetSpacing()); - MITK_INFO << "STEP DIRECTION NORM: " << stepDirection->GetNorm(); - MITK_INFO << "TOTAL WALKING DISTANCE NORM: " << totalWalkingDistance->GetNorm(); - while (totalWalkingDistance->GetNorm() >= 1) { double xPos = fromPosition->GetElement(0); double yPos = fromPosition->GetElement(1); double zPos = fromPosition->GetElement(2); if (!volume->IsInsideVolume(xPos, yPos, zPos)) { properties->SetRadiusInVoxel(0); return; } double radius = properties->GetRadiusInVoxel(); double ceiledRadius = ceil(radius); for (int x = xPos - ceiledRadius; x <= xPos + ceiledRadius; x += 1) for (int y = yPos - ceiledRadius; y <= yPos + ceiledRadius; y += 1) for (int z = zPos - ceiledRadius; z <= zPos + ceiledRadius; z += 1) { if (!volume->IsInsideVolume(x, y, z)) { continue; } double xDiff = x - xPos; double yDiff = y - yPos; double zDiff = z - zPos; double vectorLengthDiff = radius - sqrt(xDiff*xDiff + yDiff*yDiff + zDiff*zDiff); if (vectorLengthDiff > 0) { volume->SetVolumeValues(x, y, z, properties->GetAbsorptionCoefficient(), properties->GetScatteringCoefficient(), properties->GetAnisotopyCoefficient(), mitk::pa::InSilicoTissueVolume::SegmentationType::VESSEL); } } totalWalkingDistance->Subtract(stepDirection); fromPosition->Add(stepDirection); } properties->SetPositionVector(fromPosition); }