diff --git a/Modules/DiffusionImaging/DiffusionCore/Testing/mitkImageReconstructionTest.cpp b/Modules/DiffusionImaging/DiffusionCore/Testing/mitkImageReconstructionTest.cpp index aba2d59a9a..ee713ff1fe 100755 --- a/Modules/DiffusionImaging/DiffusionCore/Testing/mitkImageReconstructionTest.cpp +++ b/Modules/DiffusionImaging/DiffusionCore/Testing/mitkImageReconstructionTest.cpp @@ -1,152 +1,152 @@ /*=================================================================== 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 #include #include #include #include #include #include #include using namespace std; int mitkImageReconstructionTest(int argc, char* argv[]) { MITK_TEST_BEGIN("mitkImageReconstructionTest"); MITK_TEST_CONDITION_REQUIRED(argc>1,"check for input data") try { mitk::DiffusionImage::Pointer dwi = dynamic_cast*>(mitk::IOUtil::LoadDataNode(argv[1])->GetData()); { MITK_INFO << "Tensor reconstruction " << argv[2]; mitk::TensorImage::Pointer tensorImage = dynamic_cast(mitk::IOUtil::LoadDataNode(argv[2])->GetData()); typedef itk::DiffusionTensor3DReconstructionImageFilter< short, short, float > TensorReconstructionImageFilterType; TensorReconstructionImageFilterType::Pointer filter = TensorReconstructionImageFilterType::New(); filter->SetGradientImage( dwi->GetDirections(), dwi->GetVectorImage() ); filter->SetBValue(dwi->GetB_Value()); filter->Update(); mitk::TensorImage::Pointer testImage = mitk::TensorImage::New(); testImage->InitializeByItk( filter->GetOutput() ); testImage->SetVolume( filter->GetOutput()->GetBufferPointer() ); - MITK_TEST_CONDITION_REQUIRED(mitk::Equal(testImage, tensorImage, 0.0001, true), "tensor reconstruction test."); + MITK_TEST_CONDITION_REQUIRED(mitk::Equal(*testImage, *tensorImage, 0.0001, true), "tensor reconstruction test."); } { MITK_INFO << "Numerical Q-ball reconstruction " << argv[3]; mitk::QBallImage::Pointer qballImage = dynamic_cast(mitk::IOUtil::LoadDataNode(argv[3])->GetData()); typedef itk::DiffusionQballReconstructionImageFilter QballReconstructionImageFilterType; QballReconstructionImageFilterType::Pointer filter = QballReconstructionImageFilterType::New(); filter->SetGradientImage( dwi->GetDirections(), dwi->GetVectorImage() ); filter->SetBValue(dwi->GetB_Value()); filter->SetNormalizationMethod(QballReconstructionImageFilterType::QBR_STANDARD); filter->Update(); mitk::QBallImage::Pointer testImage = mitk::QBallImage::New(); testImage->InitializeByItk( filter->GetOutput() ); testImage->SetVolume( filter->GetOutput()->GetBufferPointer() ); - MITK_TEST_CONDITION_REQUIRED(mitk::Equal(testImage, qballImage, 0.0001, true), "Numerical Q-ball reconstruction test."); + MITK_TEST_CONDITION_REQUIRED(mitk::Equal(*testImage, *qballImage, 0.0001, true), "Numerical Q-ball reconstruction test."); } { MITK_INFO << "Standard Q-ball reconstruction " << argv[4]; mitk::QBallImage::Pointer qballImage = dynamic_cast(mitk::IOUtil::LoadDataNode(argv[4])->GetData()); typedef itk::AnalyticalDiffusionQballReconstructionImageFilter FilterType; FilterType::Pointer filter = FilterType::New(); filter->SetGradientImage( dwi->GetDirections(), dwi->GetVectorImage() ); filter->SetBValue(dwi->GetB_Value()); filter->SetLambda(0.006); filter->SetNormalizationMethod(FilterType::QBAR_STANDARD); filter->Update(); mitk::QBallImage::Pointer testImage = mitk::QBallImage::New(); testImage->InitializeByItk( filter->GetOutput() ); testImage->SetVolume( filter->GetOutput()->GetBufferPointer() ); - MITK_TEST_CONDITION_REQUIRED(mitk::Equal(testImage, qballImage, 0.0001, true), "Standard Q-ball reconstruction test."); + MITK_TEST_CONDITION_REQUIRED(mitk::Equal(*testImage, *qballImage, 0.0001, true), "Standard Q-ball reconstruction test."); } { MITK_INFO << "CSA Q-ball reconstruction " << argv[5]; mitk::QBallImage::Pointer qballImage = dynamic_cast(mitk::IOUtil::LoadDataNode(argv[5])->GetData()); typedef itk::AnalyticalDiffusionQballReconstructionImageFilter FilterType; FilterType::Pointer filter = FilterType::New(); filter->SetGradientImage( dwi->GetDirections(), dwi->GetVectorImage() ); filter->SetBValue(dwi->GetB_Value()); filter->SetLambda(0.006); filter->SetNormalizationMethod(FilterType::QBAR_SOLID_ANGLE); filter->Update(); mitk::QBallImage::Pointer testImage = mitk::QBallImage::New(); testImage->InitializeByItk( filter->GetOutput() ); testImage->SetVolume( filter->GetOutput()->GetBufferPointer() ); - MITK_TEST_CONDITION_REQUIRED(mitk::Equal(testImage, qballImage, 0.0001, true), "CSA Q-ball reconstruction test."); + MITK_TEST_CONDITION_REQUIRED(mitk::Equal(*testImage, *qballImage, 0.0001, true), "CSA Q-ball reconstruction test."); } { MITK_INFO << "ADC profile reconstruction " << argv[6]; mitk::QBallImage::Pointer qballImage = dynamic_cast(mitk::IOUtil::LoadDataNode(argv[6])->GetData()); typedef itk::AnalyticalDiffusionQballReconstructionImageFilter FilterType; FilterType::Pointer filter = FilterType::New(); filter->SetGradientImage( dwi->GetDirections(), dwi->GetVectorImage() ); filter->SetBValue(dwi->GetB_Value()); filter->SetLambda(0.006); filter->SetNormalizationMethod(FilterType::QBAR_ADC_ONLY); filter->Update(); mitk::QBallImage::Pointer testImage = mitk::QBallImage::New(); testImage->InitializeByItk( filter->GetOutput() ); testImage->SetVolume( filter->GetOutput()->GetBufferPointer() ); - MITK_TEST_CONDITION_REQUIRED(mitk::Equal(testImage, qballImage, 0.0001, true), "ADC profile reconstruction test."); + MITK_TEST_CONDITION_REQUIRED(mitk::Equal(*testImage, *qballImage, 0.0001, true), "ADC profile reconstruction test."); } { MITK_INFO << "Raw signal modeling " << argv[7]; mitk::QBallImage::Pointer qballImage = dynamic_cast(mitk::IOUtil::LoadDataNode(argv[7])->GetData()); typedef itk::AnalyticalDiffusionQballReconstructionImageFilter FilterType; FilterType::Pointer filter = FilterType::New(); filter->SetGradientImage( dwi->GetDirections(), dwi->GetVectorImage() ); filter->SetBValue(dwi->GetB_Value()); filter->SetLambda(0.006); filter->SetNormalizationMethod(FilterType::QBAR_RAW_SIGNAL); filter->Update(); mitk::QBallImage::Pointer testImage = mitk::QBallImage::New(); testImage->InitializeByItk( filter->GetOutput() ); testImage->SetVolume( filter->GetOutput()->GetBufferPointer() ); - MITK_TEST_CONDITION_REQUIRED(mitk::Equal(testImage, qballImage, 0.0001, true), "Raw signal modeling test."); + MITK_TEST_CONDITION_REQUIRED(mitk::Equal(*testImage, *qballImage, 0.0001, true), "Raw signal modeling test."); } } catch (itk::ExceptionObject e) { MITK_INFO << e; return EXIT_FAILURE; } catch (std::exception e) { MITK_INFO << e.what(); return EXIT_FAILURE; } catch (...) { MITK_INFO << "ERROR!?!"; return EXIT_FAILURE; } MITK_TEST_END(); } diff --git a/Modules/DiffusionImaging/Quantification/Testing/mitkTbssSkeletonizationTest.cpp b/Modules/DiffusionImaging/Quantification/Testing/mitkTbssSkeletonizationTest.cpp index 09ba2ed05b..4b105de9cc 100644 --- a/Modules/DiffusionImaging/Quantification/Testing/mitkTbssSkeletonizationTest.cpp +++ b/Modules/DiffusionImaging/Quantification/Testing/mitkTbssSkeletonizationTest.cpp @@ -1,167 +1,167 @@ /*=================================================================== 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 #include #include /**Documentation * test for the class "itkSkeletonizationFilter". */ int mitkTbssSkeletonizationTest(int argc , char* argv[]) { MITK_TEST_BEGIN("TbssSkeletonizationTest"); // Load images typedef itk::Image FloatImageType; typedef itk::ImageFileReader ImageReaderType; ImageReaderType::Pointer reader = ImageReaderType::New(); reader->SetFileName(argv[1]); // Initialize skeletonization filter and feed it with the mean_FA.nii.gz typedef itk::SkeletonizationFilter SkeletonisationFilterType; SkeletonisationFilterType::Pointer skeletonizer = SkeletonisationFilterType::New(); skeletonizer->SetInput(reader->GetOutput()); skeletonizer->Update(); // Create a new image so the skeletonizaton won't be performed every time the skeleton is needed. FloatImageType::Pointer skeleton = skeletonizer->GetOutput(); // Check whether the skeleton is correct reader->SetFileName(argv[2]); reader->Update(); FloatImageType::Pointer controlSkeleton = reader->GetOutput(); // Convert itk images to mitk images and use the mitk::Equal method to compare the result with the reference skeleton. mitk::Image::Pointer mitkSkeleton = mitk::Image::New(); mitkSkeleton->InitializeByItk(skeleton.GetPointer()); mitk::Image::Pointer mitkRefSkeleton = mitk::Image::New(); mitkRefSkeleton->InitializeByItk(controlSkeleton.GetPointer()); - MITK_TEST_CONDITION(mitk::Equal(mitkSkeleton, mitkRefSkeleton, 0.001, true), "Check correctness of the skeleton"); + MITK_TEST_CONDITION(mitk::Equal(*mitkSkeleton, *mitkRefSkeleton, 0.001, true), "Check correctness of the skeleton"); // Test the projection filter typedef itk::CovariantVector VectorType; typedef itk::Image DirectionImageType; // Retrieve direction image needed later by the projection filter DirectionImageType::Pointer directionImg = skeletonizer->GetVectorImage(); // Define a distance map filter that creates a distance map to limit the projection search typedef itk::DistanceMapFilter DistanceMapFilterType; DistanceMapFilterType::Pointer distanceMapFilter = DistanceMapFilterType::New(); distanceMapFilter->SetInput(controlSkeleton); //use controlSkeleton to prevent updating the skeletonfilter, which is time consuming distanceMapFilter->Update(); FloatImageType::Pointer distanceMap = distanceMapFilter->GetOutput(); // Threshold the skeleton on FA=0.2 to create a binary skeleton mask typedef itk::Image CharImageType; typedef itk::BinaryThresholdImageFilter ThresholdFilterType; ThresholdFilterType::Pointer thresholder = ThresholdFilterType::New(); thresholder->SetInput(controlSkeleton); //use controlSkeleton to prevent updating the skeletonfilter, which is time consuming thresholder->SetLowerThreshold(0.2); thresholder->SetUpperThreshold(std::numeric_limits::max()); thresholder->SetOutsideValue(0); thresholder->SetInsideValue(1); thresholder->Update(); CharImageType::Pointer thresholdedImg = thresholder->GetOutput(); // Load the cingulum mask that defines the region where a tubular structure must be searched for typedef itk::ImageFileReader< CharImageType > CharReaderType; CharReaderType::Pointer charReader = CharReaderType::New(); charReader->SetFileName(argv[3]); charReader->Update(); CharImageType::Pointer cingulum = charReader->GetOutput(); // Define projection filter typedef itk::ProjectionFilter ProjectionFilterType; // Read the 4d test image containing the registered FA data of one subject typedef itk::Image Float4DImageType; typedef itk::ImageFileReader ImageReader4DType; ImageReader4DType::Pointer reader4d = ImageReader4DType::New(); reader4d->SetFileName(argv[4]); reader4d->Update(); ProjectionFilterType::Pointer projectionFilter = ProjectionFilterType::New(); projectionFilter->SetDistanceMap(distanceMap); projectionFilter->SetDirections(directionImg); projectionFilter->SetAllFA(reader4d->GetOutput()); projectionFilter->SetTube(cingulum); projectionFilter->SetSkeleton(thresholdedImg); projectionFilter->Project(); Float4DImageType::Pointer projected = projectionFilter->GetProjections(); // Open control projection image reader4d->SetFileName(argv[5]); reader4d->Update(); Float4DImageType::Pointer controlProjection = reader4d->GetOutput(); // control dimensions Float4DImageType::SizeType pSize = projected->GetLargestPossibleRegion().GetSize(); Float4DImageType::SizeType pControlSize = controlProjection->GetLargestPossibleRegion().GetSize(); typedef itk::Testing::ComparisonImageFilter ComparisonFilterType; ComparisonFilterType::Pointer comparisonFilter = ComparisonFilterType::New(); comparisonFilter->SetTestInput(projected); comparisonFilter->SetValidInput(controlProjection); comparisonFilter->Update(); float diff = comparisonFilter->GetTotalDifference(); MITK_TEST_CONDITION(pSize == pControlSize, "Size of projection image and control projection image are the same"); MITK_TEST_CONDITION(diff < 0.001, "Check correctness of the projections"); MITK_TEST_END(); }