Skip to content

Commit

Permalink
BUG: Masking issues.
Browse files Browse the repository at this point in the history
  • Loading branch information
ntustison committed Feb 21, 2020
1 parent 03d09dc commit c30f044
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions Examples/N4BiasFieldCorrection.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -151,14 +151,10 @@ int N4( itk::ants::CommandLineParser *parser )
thresholder->SetUpperThreshold( itk::NumericTraits<typename MaskImageType::PixelType>::ZeroValue() );
thresholder->SetInput( maskImage );

typename IntImageType::Pointer thresholdedMask = thresholder->GetOutput();
thresholdedMask->Update();
thresholdedMask->DisconnectPipeline();

typedef itk::LabelStatisticsImageFilter<ImageType, IntImageType> StatsType;
typename StatsType::Pointer statsOriginal = StatsType::New();
statsOriginal->SetInput( inputImage );
statsOriginal->SetLabelInput( thresholdedMask );
statsOriginal->SetLabelInput( thresholder->GetOutput() );
statsOriginal->UseHistogramsOff();
statsOriginal->Update();

Expand Down Expand Up @@ -540,11 +536,16 @@ int N4( itk::ants::CommandLineParser *parser )

if( doRescale )
{
thresholdedMask->SetRegions( dividedImage->GetLargestPossibleRegion() );
typename ThresholderType::Pointer thresholder2 = ThresholderType::New();
thresholder2->SetInsideValue( itk::NumericTraits<typename IntImageType::PixelType>::ZeroValue() );
thresholder2->SetOutsideValue( itk::NumericTraits<typename IntImageType::PixelType>::OneValue() );
thresholder2->SetLowerThreshold( itk::NumericTraits<typename MaskImageType::PixelType>::ZeroValue() );
thresholder2->SetUpperThreshold( itk::NumericTraits<typename MaskImageType::PixelType>::ZeroValue() );
thresholder2->SetInput( maskImage );

typename StatsType::Pointer statsBiasCorrected = StatsType::New();
statsBiasCorrected->SetInput( dividedImage );
statsBiasCorrected->SetLabelInput( thresholdedMask );
statsBiasCorrected->SetLabelInput( thresholder2->GetOutput() );
statsBiasCorrected->UseHistogramsOff();
statsBiasCorrected->Update();

Expand Down

2 comments on commit c30f044

@gdevenyi
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you describe the issue this addresses?

@ntustison
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.