From fbc4127002017d954a14d15e79773ccec55ddb61 Mon Sep 17 00:00:00 2001 From: muschellij2 Date: Mon, 23 Mar 2020 14:15:17 -0400 Subject: [PATCH] N4 verbosity --- Examples/N4BiasFieldCorrection.cxx | 46 +++++++++++++++++++++++++----- 1 file changed, 39 insertions(+), 7 deletions(-) diff --git a/Examples/N4BiasFieldCorrection.cxx b/Examples/N4BiasFieldCorrection.cxx index 7e5b5eb56..91c553abf 100644 --- a/Examples/N4BiasFieldCorrection.cxx +++ b/Examples/N4BiasFieldCorrection.cxx @@ -71,12 +71,6 @@ int N4( itk::ants::CommandLineParser *parser ) { using RealType = float; - using ImageType = itk::Image; - typename ImageType::Pointer inputImage = nullptr; - - using MaskImageType = itk::Image; - typename MaskImageType::Pointer maskImage = nullptr; - bool verbose = false; typename itk::ants::CommandLineParser::OptionType::Pointer verboseOption = parser->GetOption( "verbose" ); @@ -84,15 +78,37 @@ int N4( itk::ants::CommandLineParser *parser ) { verbose = parser->Convert( verboseOption->GetFunction( 0 )->GetName() ); } + if( verbose ) + { + std::cout << std::endl << "Creating ImageType" << std::endl; + } + using ImageType = itk::Image; + typename ImageType::Pointer inputImage = nullptr; + + if( verbose ) + { + std::cout << std::endl << "Creating MaskImageType" << std::endl; + } + using MaskImageType = itk::Image; + typename MaskImageType::Pointer maskImage = nullptr; + if( verbose ) { std::cout << std::endl << "Running N4 for " << ImageDimension << "-dimensional images." << std::endl << std::endl; } + if( verbose ) + { + std::cout << std::endl << "Getting CorrecterType" << std::endl; + } using CorrecterType = itk::N4BiasFieldCorrectionImageFilter; typename CorrecterType::Pointer correcter = CorrecterType::New(); + if( verbose ) + { + std::cout << std::endl << "Reading in Input Image" << std::endl; + } typename itk::ants::CommandLineParser::OptionType::Pointer inputImageOption = parser->GetOption( "input-image" ); if( inputImageOption && inputImageOption->GetNumberOfFunctions() ) @@ -117,9 +133,17 @@ int N4( itk::ants::CommandLineParser *parser ) typename itk::ants::CommandLineParser::OptionType::Pointer maskImageOption = parser->GetOption( "mask-image" ); - if( maskImageOption && maskImageOption->GetNumberOfFunctions() ) + if( verbose ) { + std::cout << std::endl << "maskImageOption: " << maskImageOption << std::endl; + } + if( maskImageOption && maskImageOption->GetNumberOfFunctions() ) + { std::string inputMaskFile = maskImageOption->GetFunction( 0 )->GetName(); + if( verbose ) + { + std::cout << std::endl << "Reading in Mask file: " << inputMaskFile << std::endl; + } ReadImage( maskImage, inputMaskFile.c_str() ); isMaskImageSpecified = true; @@ -140,6 +164,10 @@ int N4( itk::ants::CommandLineParser *parser ) /** * check for negative values in the masked region */ + if( verbose ) + { + std::cout << std::endl << "Checking for Negative Values" << std::endl; + } using ThresholderType = itk::BinaryThresholdImageFilter; typename ThresholderType::Pointer thresholder = ThresholderType::New(); thresholder->SetInsideValue( itk::NumericTraits::ZeroValue() ); @@ -148,6 +176,10 @@ int N4( itk::ants::CommandLineParser *parser ) thresholder->SetUpperThreshold( itk::NumericTraits::ZeroValue() ); thresholder->SetInput( maskImage ); + if( verbose ) + { + std::cout << std::endl << "Running LabelStatisticsImageFilter" << std::endl; + } using StatsType = itk::LabelStatisticsImageFilter; typename StatsType::Pointer statsOriginal = StatsType::New(); statsOriginal->SetInput( inputImage );