diff --git a/Modules/ImageStatistics/Testing/CMakeLists.txt b/Modules/ImageStatistics/Testing/CMakeLists.txt index 834d6d6592..69d31db025 100644 --- a/Modules/ImageStatistics/Testing/CMakeLists.txt +++ b/Modules/ImageStatistics/Testing/CMakeLists.txt @@ -1,38 +1,41 @@ MITK_CREATE_MODULE_TESTS() if(TARGET ${TESTDRIVER}) mitk_use_modules(TARGET ${TESTDRIVER} PACKAGES ITK|IOXML) endif() # mitkAddCustomModuleTest(mitkRoiMeasurementsTests mitkRoiMeasurementsTest ${MITK_DATA_DIR}/ImageStatisticsTestData/) -file(GLOB allHotSpotTests RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}/Data/Hotspot" "${CMAKE_CURRENT_SOURCE_DIR}/Data/Hotspot/*.xml") -foreach(testcase ${allHotSpotTests}) - string(REGEX REPLACE "[^a-zA-Z0-9_]" "_" testcaseName ${testcase}) - mitkAddCustomModuleTest(mitkImageStatisticsHotspotTest_${testcaseName} mitkImageStatisticsHotspotTest ${CMAKE_CURRENT_SOURCE_DIR}/Data/Hotspot/${testcase}) -endforeach() - -# -# The following lines may be activated to generate new test cases for mitkImageStatisticsHotspotTest. -# Test cases are generated by mitkMultiGaussianTest. All .xml files in Data/TestGeneration/Input will -# be processed and transformed into new .xml files containing statistics in Data/TestGeneration/Output. -# +# All hotspot tests are currently deactivated. See T30375 for details if (false) - set(testInputDir ${CMAKE_CURRENT_SOURCE_DIR}/Data/TestGeneration/Input) - set(testOutputDir ${CMAKE_CURRENT_SOURCE_DIR}/Data/TestGeneration/Output) - file(GLOB testcasesToGenerate RELATIVE "${testInputDir}" "${testInputDir}/*.xml") + file(GLOB allHotSpotTests RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}/Data/Hotspot" "${CMAKE_CURRENT_SOURCE_DIR}/Data/Hotspot/*.xml") + foreach(testcase ${allHotSpotTests}) + string(REGEX REPLACE "[^a-zA-Z0-9_]" "_" testcaseName ${testcase}) + mitkAddCustomModuleTest(mitkImageStatisticsHotspotTest_${testcaseName} mitkImageStatisticsHotspotTest ${CMAKE_CURRENT_SOURCE_DIR}/Data/Hotspot/${testcase}) + endforeach() - if (NOT EXISTS ${testOutputDir}) - file(MAKE_DIRECTORY ${testOutputDir}) - endif() + # + # The following lines may be activated to generate new test cases for mitkImageStatisticsHotspotTest. + # Test cases are generated by mitkMultiGaussianTest. All .xml files in Data/TestGeneration/Input will + # be processed and transformed into new .xml files containing statistics in Data/TestGeneration/Output. + # + if (false) + set(testInputDir ${CMAKE_CURRENT_SOURCE_DIR}/Data/TestGeneration/Input) + set(testOutputDir ${CMAKE_CURRENT_SOURCE_DIR}/Data/TestGeneration/Output) + file(GLOB testcasesToGenerate RELATIVE "${testInputDir}" "${testInputDir}/*.xml") - foreach(testinput ${testcasesToGenerate}) - string(REGEX REPLACE "[^a-zA-Z0-9_]\\+" "_" testcaseName ${testinput}) - string(REGEX REPLACE "\\.xml" "" testoutput ${testinput}) - message("Generate hotspot test case '${testinput}'. Output in '${testoutput}.xml' and '${testoutput}.nrrd'") - mitkAddCustomModuleTest(mitkMultiGaussianTest_${testcaseName} - mitkMultiGaussianTest - ${testOutputDir}/${testoutput} - ${testInputDir}/${testinput}) - endforeach() + if (NOT EXISTS ${testOutputDir}) + file(MAKE_DIRECTORY ${testOutputDir}) + endif() + + foreach(testinput ${testcasesToGenerate}) + string(REGEX REPLACE "[^a-zA-Z0-9_]\\+" "_" testcaseName ${testinput}) + string(REGEX REPLACE "\\.xml" "" testoutput ${testinput}) + message("Generate hotspot test case '${testinput}'. Output in '${testoutput}.xml' and '${testoutput}.nrrd'") + mitkAddCustomModuleTest(mitkMultiGaussianTest_${testcaseName} + mitkMultiGaussianTest + ${testOutputDir}/${testoutput} + ${testInputDir}/${testinput}) + endforeach() + endif() endif() diff --git a/Modules/ImageStatistics/Testing/files.cmake b/Modules/ImageStatistics/Testing/files.cmake index 6ca36d87ec..190337c956 100644 --- a/Modules/ImageStatistics/Testing/files.cmake +++ b/Modules/ImageStatistics/Testing/files.cmake @@ -1,13 +1,15 @@ set(MODULE_TESTS mitkImageStatisticsCalculatorTest.cpp mitkPointSetStatisticsCalculatorTest.cpp mitkPointSetDifferenceStatisticsCalculatorTest.cpp mitkImageStatisticsTextureAnalysisTest.cpp mitkImageStatisticsContainerTest.cpp mitkImageStatisticsContainerManagerTest.cpp ) set(MODULE_CUSTOM_TESTS - mitkImageStatisticsHotspotTest.cpp +# see T30375 for mitkImageStatisticsHotspotTest +# mitkImageStatisticsHotspotTest.cpp + # mitkMultiGaussianTest.cpp # TODO: activate test to generate new test cases for mitkImageStatisticsHotspotTest ) diff --git a/Modules/ImageStatistics/files.cmake b/Modules/ImageStatistics/files.cmake index 3d89557ffe..4395fdd0ff 100644 --- a/Modules/ImageStatistics/files.cmake +++ b/Modules/ImageStatistics/files.cmake @@ -1,50 +1,51 @@ set(CPP_FILES mitkImageStatisticsCalculator.cpp mitkImageStatisticsContainer.cpp mitkPointSetStatisticsCalculator.cpp mitkPointSetDifferenceStatisticsCalculator.cpp mitkIntensityProfile.cpp - mitkHotspotMaskGenerator.cpp + #See T30375 + #mitkHotspotMaskGenerator.cpp mitkMaskGenerator.cpp mitkPlanarFigureMaskGenerator.cpp mitkMultiLabelMaskGenerator.cpp mitkImageMaskGenerator.cpp mitkHistogramStatisticsCalculator.cpp mitkIgnorePixelMaskGenerator.cpp mitkImageStatisticsPredicateHelper.cpp mitkImageStatisticsContainerNodeHelper.cpp mitkImageStatisticsContainerManager.cpp mitkStatisticsToImageRelationRule.cpp mitkStatisticsToMaskRelationRule.cpp mitkImageStatisticsConstants.cpp ) set(H_FILES mitkImageStatisticsCalculator.h mitkImageStatisticsContainer.h mitkPointSetDifferenceStatisticsCalculator.h mitkPointSetStatisticsCalculator.h mitkStatisticsImageFilter.h mitkLabelStatisticsImageFilter.h mitkHotspotMaskGenerator.h mitkMaskGenerator.h mitkPlanarFigureMaskGenerator.h mitkMultiLabelMaskGenerator.h mitkImageMaskGenerator.h mitkHistogramStatisticsCalculator.h mitkMaskUtilities.h mitkitkMaskImageFilter.h mitkIgnorePixelMaskGenerator.h mitkMinMaxImageFilterWithIndex.h mitkMinMaxLabelmageFilterWithIndex.h mitkImageStatisticsPredicateHelper.h mitkImageStatisticsContainerNodeHelper.h mitkImageStatisticsContainerManager.h mitkStatisticsToImageRelationRule.h mitkStatisticsToMaskRelationRule.h mitkImageStatisticsConstants.h ) set(TPP_FILES mitkMaskUtilities.tpp ) diff --git a/Modules/ImageStatistics/mitkHotspotMaskGenerator.h b/Modules/ImageStatistics/mitkHotspotMaskGenerator.h index ca388e9bde..ba40564049 100644 --- a/Modules/ImageStatistics/mitkHotspotMaskGenerator.h +++ b/Modules/ImageStatistics/mitkHotspotMaskGenerator.h @@ -1,153 +1,155 @@ /*============================================================================ The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center (DKFZ) All rights reserved. Use of this source code is governed by a 3-clause BSD license that can be found in the LICENSE file. ============================================================================*/ #ifndef mitkHotspotMaskGenerator_h #define mitkHotspotMaskGenerator_h #include #include #include #include #include #include #include #include namespace mitk { /** + * @warning Until T30375 is not clarified the class should be deemed deprecated/erroneous and should not + * be used * @brief The HotspotMaskGenerator class is used when a hotspot has to be found in an image. A hotspot is * the region of the image where the mean intensity is maximal (=brightest spot). It is usually used in PET scans. * The identification of the hotspot is done as follows: First a cubic (or circular, if image is 2d) * mask of predefined size is generated. This mask is then convolved with the input image (in fourier domain). * The maximum value of the convolved image then corresponds to the hotspot. * If a maskGenerator is set, only the pixels of the convolved image where the corresponding mask is == @a label * are searched for the maximum value. */ class MITKIMAGESTATISTICS_EXPORT HotspotMaskGenerator: public MaskGenerator { public: /** Standard Self typedef */ typedef HotspotMaskGenerator Self; typedef MaskGenerator Superclass; typedef itk::SmartPointer< Self > Pointer; typedef itk::SmartPointer< const Self > ConstPointer; /** Method for creation through the object factory. */ itkNewMacro(Self); /** Runtime information support. */ itkTypeMacro(HotspotMaskGenerator, MaskGenerator); unsigned int GetNumberOfMasks() const override; /** @brief Set a mask (can be nullptr if no mask is desired) */ itkSetObjectMacro(Mask, MaskGenerator); /** @brief Set the radius of the hotspot (in MM) */ itkGetConstMacro(HotspotRadiusInMM, double); itkSetMacro(HotspotRadiusInMM, double); /** @brief Define whether the hotspot must be completely inside the image. Default is true */ itkGetConstMacro(HotspotMustBeCompletelyInsideImage, bool); itkSetMacro(HotspotMustBeCompletelyInsideImage, bool); /** @brief If a maskGenerator is set, this detemines which mask value is used */ itkSetMacro(Label, unsigned short); protected: HotspotMaskGenerator(); ~HotspotMaskGenerator() override; Image::ConstPointer DoGetMask(unsigned int) override; class ImageExtrema { public: bool Defined; double Max; double Min; vnl_vector MaxIndex; vnl_vector MinIndex; ImageExtrema() :Defined(false) ,Max(itk::NumericTraits::min()) ,Min(itk::NumericTraits::max()) { } }; private: /** \brief Returns size of convolution kernel depending on spacing and radius. */ template itk::Size CalculateConvolutionKernelSize(double spacing[VImageDimension], double radiusInMM); /** \brief Generates image of kernel which is needed for convolution. */ template itk::SmartPointer< itk::Image > GenerateHotspotSearchConvolutionKernel(double spacing[VImageDimension], double radiusInMM); /** \brief Convolves image with spherical kernel image. Used for hotspot calculation. */ template itk::SmartPointer< itk::Image > GenerateConvolutionImage( const itk::Image* inputImage ); /** \brief Fills pixels of the spherical hotspot mask. */ template < typename TPixel, unsigned int VImageDimension> void FillHotspotMaskPixels( itk::Image* maskImage, itk::Point sphereCenter, double sphereRadiusInMM); /** \brief */ template void CalculateHotspotMask(const itk::Image* inputImage, const itk::Image* maskImage, unsigned int label); template ImageExtrema CalculateExtremaWorld( const itk::Image* inputImage, const itk::Image* maskImage, double neccessaryDistanceToImageBorderInMM, unsigned int label); bool IsUpdateRequired() const; HotspotMaskGenerator(const HotspotMaskGenerator &); HotspotMaskGenerator & operator=(const HotspotMaskGenerator &); MaskGenerator::Pointer m_Mask; mitk::Image::Pointer m_InternalMask; itk::Image::ConstPointer m_internalMask2D; itk::Image::ConstPointer m_internalMask3D; double m_HotspotRadiusInMM; bool m_HotspotMustBeCompletelyInsideImage; unsigned short m_Label; vnl_vector m_ConvolutionImageMinIndex, m_ConvolutionImageMaxIndex; unsigned long m_InternalMaskUpdateTime; }; } #endif