ANTsX / ANTs

Advanced Normalization Tools (ANTs)

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

iMath TruncateImageIntensity segfaults on certain input

cookpa opened this issue · comments

As reported in ANTsX/ANTsPy#597

To Reproduce

See ANTsX/ANTsPy#597 for data and code

System information (please complete the following information)

  • OS: Mac
  • OS version: 12.7
  • Type of system: Desktop
  • CPU architecture: x86

ANTs version information

  • ANTs code version: 2.5.1.post24-g6c29d9d
  • ANTs installation type: Compiled from source

@stnava this appears to be an error with images that have negative intensities. The range of your T1w is [-32768, -31932]. The seg fault goes away if I multiply it by -1.

The mask step will not contain any voxels in an image that is all negative. Should I change it to default to use the full range of pixel type?

typedef itk::BinaryThresholdImageFilter<ImageType, MaskType> ThresholdFilterType;
typename ThresholdFilterType::Pointer thresh = ThresholdFilterType::New();
thresh->SetInput(image);
thresh->SetLowerThreshold(1e-6);
thresh->SetUpperThreshold(itk::NumericTraits<PixelType>::max());
thresh->SetInsideValue(1);
thresh->SetOutsideValue(0);
thresh->Update();
mask = thresh->GetOutput();

thanks @cookpa for searching this out