ANTsX / ANTs

Advanced Normalization Tools (ANTs)
Apache License 2.0
1.21k stars 381 forks source link

N4BiasFieldCorrection doesn't report exceptions without --verbose #215

Closed gdevenyi closed 9 years ago

gdevenyi commented 9 years ago

Followup to #214

When N4 runs and fails, it only shows what happened if --verbose is on

> N4BiasFieldCorrection -d 3 --verbose -r -b [200] -c [200x200x200x200,0.0] -t [0.05,0.01,200] -w mask.mnc -i 0102.mnc -o 0102.N4.mnc

Running N4 for 3-dimensional images.

Mask not read.  Creating Otsu mask.
Exception caught: 
itk::ExceptionObject (0x14cdf10)
Location: "unknown" 
File: /opt/quarantine/minc-toolkit/1.9.10/src/build/ITKv4/Modules/Core/Common/include/itkImageToImageFilter.hxx
Line: 248
Description: itk::ERROR: N4BiasFieldCorrectionImageFilter(0x14c0a60): Inputs do not occupy the same physical space! 
InputImage Origin: [-1.0770190e+02, -7.7216900e+01, -4.7320700e+01], InputImage_2 Origin: [-1.0770190e+02, -7.7216900e+01, -4.7320705e+01]
    Tolerance: 3.4376000e-06
InputImage Spacing: [3.4376000e+00, 3.4376000e+00, 5.2000000e+00], InputImage_2 Spacing: [3.4376000e+00, 3.4376000e+00, 5.1999899e+00]
    Tolerance: 3.4376000e-06

> N4BiasFieldCorrection -d 3 -r -b [200] -c [200x200x200x200,0.0] -t [0.05,0.01,200] -w mask.mnc -i 0102.mnc -o 0102.N4.mnc
<Silent failure>

A little more concerning on that, the exit code is success:

> N4BiasFieldCorrection -d 3 -r -b [200] -c [200x200x200x200,0.0] -t [0.05,0.01,200] -w mask.mnc -i 0102.mnc -o 0102.N4.mnc
> echo $?
0
ntustison commented 9 years ago

I don't see how that is the case:

https://github.com/stnava/ANTs/blob/master/Examples/N4BiasFieldCorrection.cxx#L376-L388

And, again, please use non-minc examples.

gdevenyi commented 9 years ago

Whoops, yeah, here's non-minc

N4BiasFieldCorrection -d 3 --verbose -r -b [200] -c [200x200x200x200,0.0] -t [0.05,0.01,200] -w mask.nii -i 0102.nii -o 0102.N4.nii

Running N4 for 3-dimensional images.

Mask not read.  Creating Otsu mask.
Exception caught: 
itk::ExceptionObject (0xd96a40)
Location: "unknown" 
File: /opt/quarantine/minc-toolkit/1.9.10/src/build/ITKv4/Modules/Core/Common/include/itkImageToImageFilter.hxx
Line: 248
Description: itk::ERROR: N4BiasFieldCorrectionImageFilter(0xd8ca30): Inputs do not occupy the same physical space! 
InputImage Origin: [1.0770190e+02, 7.7216897e+01, -4.7320700e+01], InputImage_2 Origin: [1.0770190e+02, 7.7216897e+01, -4.7320705e+01]
    Tolerance: 3.4375999e-06
InputImage Spacing: [3.4375999e+00, 3.4375999e+00, 5.1999998e+00], InputImage_2 Spacing: [3.4375999e+00, 3.4375999e+00, 5.1999898e+00]
    Tolerance: 3.4375999e-06
> N4BiasFieldCorrection -d 3 -r -b [200] -c [200x200x200x200,0.0] -t [0.05,0.01,200] -w mask.nii -i 0102.nii -o 0102.N4.nii
> echo $?
0
ntustison commented 9 years ago

Oh, wait, I see. That's intended. We don't want anything written if not in verbose mode due to ANTsR.