ANTsX / ANTs

Advanced Normalization Tools (ANTs)
Apache License 2.0
1.19k stars 380 forks source link

itk::ERROR: ImageToImageFilter(0x352ff90): Inputs do not occupy the same physical space! #74

Closed cookpa closed 9 years ago

cookpa commented 10 years ago

I'm getting an error when running a registration as part of antsCorticalThickness. It happens in the segmentation warp at the deformable stage.

To check that it wasn't bad initialization, I ran the affine part separately, then the deformable part. The affine initialization looks good. When I run the deformable part,

''' antsRegistration -d 3 -u 1 -w [0.01,0.99] -o inputprefix_BrainSegmentationPriorDeformableOnly --float 1 -r [inputprefix_BrainExtractionPrior0GenericAffine.mat] -x [inputprefix_BrainSegmentationMaskDilated.nii.gz] -m CC[inputprefix_BrainExtractionBrain.nii.gz,inputprefix_ExtractedTemplateBrain.nii.gz,1,4] -c [100x100x70x20,1e-9,15] -t SyN[0.1,3,0] -f 6x4x2x1 -s 3x2x1x0 '''

It finishes the first level and then says

''' Current level = 2 of 4 number of iterations = 100 shrink factors = [4, 4, 1] smoothing sigmas = 2.0000e+00 vox required fixed parameters = [128, 128, 96, 95.32296, -112.5134, -134.74442, 1.875, 1.875, 1.6999999, -0.05405264, -0.059213325, -0.9967809, 0.9985381, -0.0032052274, -0.053957522, -9.497458e-8, 0.99824023, -0.05930001] Exception caught: itk::ExceptionObject (0x352e7f0) Location: "unknown" File: /home/pcook/bin/ants/ITKv4-install/include/ITK-4.6/itkImageToImageFilter.hxx Line: 248 Description: itk::ERROR: ImageToImageFilter(0x352ff90): Inputs do not occupy the same physical space! InputImage Origin: [9.5322963e+01, -1.1251340e+02, -1.3474442e+02], InputImage_1 Origin: [9.5322960e+01, -1.1251340e+02, -1.3474442e+02] Tolerance: 1.8750000e-06 '''

The difference in the origins appears to be less than the stated tolerance. I'm also confused why this would happen at this point after the affine and first level registration complete successfully.

cookpa commented 10 years ago

I found an earlier post that suggested the problem is related to the use of --float

https://github.com/stnava/ANTs/issues/31

That appears to be the case here too - it is currently running successfully without the --float option.

ntustison commented 10 years ago

Hi Phil,

I don't think the issue is isolated to the use of float. I encountered this problem so frequently on my cluster that I finally increased the tolerance to 10^-2 in two places (in addition to the imageToImageFilter, there's also a similar tolerance check in the DisplacementFieldTransform. I think the issue is in the ShrinkImageFilter (as you noticed, it always happens at the beginning of a level) The shrink filter does some manipulation of that image information in order to maintain the geometric center consistent. Hans did a whole case study on this issue awhile back and so he might have something to add to this. Anyway, in addition to the kludge described above, I've also found (for the single image case) that if you change the direction cosines to the nearest canonical orientation and you change the origin to all zeros, that alleviates the problem as well.

Nick

hjmjohnson commented 10 years ago

All,

First, I want to apologize and clearly state that I will not be able to work on this problem very much until after May 15th (my teaching load is taxing me greatly this year).

This problem is not isolated to ANTS, it shows up a lot in my diffusion work as well. The maintenance of physical space consistency and the sub-sampling of data can not always be guaranteed to be within tolerance.

Regarding Nicks suggestion to "change the direction cosines “ and “change all origins to all zeros” does circumvent the problem, but is completely unacceptable for any of my medical imaging needs.

When I run into this problem, where I feel the results are good enough I don’t change the tolerance because that is a fix that does not propagate to other tools, but instead I pick one of the images as a reference image, and use a nearest neighbor resampling to numerically align the point sources. This solution persists to other programs when saving the images out to disk.

Hans

From: Nick Tustison notifications@github.com<mailto:notifications@github.com> Reply-To: stnava/ANTs reply@reply.github.com<mailto:reply@reply.github.com> Date: Friday, March 7, 2014 at 4:09 PM To: stnava/ANTs ANTs@noreply.github.com<mailto:ANTs@noreply.github.com> Subject: Re: [ANTs] itk::ERROR: ImageToImageFilter(0x352ff90): Inputs do not occupy the same physical space! (#74)

Hi Phil,

I don't think the issue is isolated to the use of float. I encountered this problem so frequently on my cluster that I finally increased the tolerance to 10^-2 in two places (in addition to the imageToImageFilter, there's also a similar tolerance check in the DisplacementFieldTransform. I think the issue is in the ShrinkImageFilter (as you noticed, it always happens at the beginning of a level) The shrink filter does some manipulation of that image information in order to maintain the geometric center consistent. Hans did a whole case study on this issue awhile back and so he might have something to add to this. Anyway, in addition to the kludge described above, I've also found (for the single image case) that if you change the direction cosines to the nearest canonical orientation and you change the origin to all zeros, that alleviates the problem as well.

Nick

— Reply to this email directly or view it on GitHubhttps://github.com/stnava/ANTs/issues/74#issuecomment-37073402.


Notice: This UI Health Care e-mail (including attachments) is covered by the Electronic Communications Privacy Act, 18 U.S.C. 2510-2521, is confidential and may be legally privileged. If you are not the intended recipient, you are hereby notified that any retention, dissemination, distribution, or copying of this communication is strictly prohibited. Please reply to the sender that you have received the message in error, then delete it. Thank you.


cookpa commented 10 years ago

Thanks guys. Sounds like a tricky problem. So far I am doing OK by not using --float, but since that's not really the root cause I will keep an eye out for this error.

stnava commented 10 years ago

This problem is cropping up seemingly more often for me. A hack solution is to edit:

ITKv4/Modules/Filtering/DisplacementField/include/itkDisplacementFieldTransform.hxx

and

ITKv4/Modules/Core/Common/include/itkImageToImageFilter.hxx

changing direction tolerance and coordinate tolerance to 1.e-4

then recompile ANTs ---- obviously not a real solution.

stnava commented 9 years ago

@hjmjohnson - i have some time to work on this ... am wondering if it might be possible to implement a SetDirectionTolerance and SetCoordinateTolerance within the offending filters. is there a better solution?

armaneshaghi commented 9 years ago

@stnava I'm wondering whether you have had any final thoughts on this? as I'm experiencing this problem on a subset of my data. I get this in antsCorticalThickness.sh script, where ImageMath comes in: ImageMath 3 antsCT_BrainSegmentation0N4.nii.gz TruncateImageIntensity T1.nii.gz 0.025 0.995 256 antsCT_BrainExtractionMask.nii.gz, and then error propagates.

stnava commented 9 years ago

See my comments above: "A hack solution is ..."

That's all we have for now ---- Hans proposes something else which you might do if you understand it.

Nick sometimes uses ClosestSimplifiedHeaderMatrix in ImageMath which may help.

stnava commented 9 years ago

actually in this particular case, CopyImageHeaderInformation may help - you always want to copy the original image's header into the problematic one

brian

On Mon, Oct 13, 2014 at 8:42 AM, Arman Eshaghi notifications@github.com wrote:

@stnava https://github.com/stnava I'm wondering whether you have had any final thoughts on this? as I'm experiencing this problem on a subset of my data. I get this in antsCorticalThickness.sh script, where ImageMath comes in: ImageMath 3 antsCT_BrainSegmentation0N4.nii.gz TruncateImageIntensity T1.nii.gz 0.025 0.995 256 antsCT_BrainExtractionMask.nii.gz

— Reply to this email directly or view it on GitHub https://github.com/stnava/ANTs/issues/74#issuecomment-58886411.

armaneshaghi commented 9 years ago

thanks

On Mon, Oct 13, 2014 at 5:21 PM, stnava notifications@github.com wrote:

actually in this particular case, CopyImageHeaderInformation may help - you always want to copy the original image's header into the problematic one

brian

On Mon, Oct 13, 2014 at 8:42 AM, Arman Eshaghi notifications@github.com wrote:

@stnava https://github.com/stnava I'm wondering whether you have had any final thoughts on this? as I'm experiencing this problem on a subset of my data. I get this in antsCorticalThickness.sh script, where ImageMath comes in: ImageMath 3 antsCT_BrainSegmentation0N4.nii.gz TruncateImageIntensity T1.nii.gz 0.025 0.995 256 antsCT_BrainExtractionMask.nii.gz

Reply to this email directly or view it on GitHub https://github.com/stnava/ANTs/issues/74#issuecomment-58886411.

Reply to this email directly or view it on GitHub https://github.com/stnava/ANTs/issues/74#issuecomment-58894633.

cookpa commented 9 years ago

I had an idea that I haven't had a chance to test yet.

If you run the T1 image through ANTs before calling antsCorticalThickness, you might be able to avoid the problem.

I've observed that derived images tend to be slightly but consistently different from the original input. I believe this is because of a data type conversions that happen when the Nifti transform is read / written by ITK, introducing small floating point errors. But they seem to be stable after one pass through the ANTs I/O. So for example:

PrintHeader input.nii.gz | grep srow srow_x = -1.99858 -0.000973955 -0.075406 118.814 srow_y = -0.0195841 1.93792 0.49403 -102.067 srow_z = -0.072825 -0.494417 1.93656 -40.2311

PrintHeader copy.nii.gz | grep srow srow_x = -1.99858 -0.000973466 -0.0754099 118.814 srow_y = -0.0195846 1.93792 0.49403 -102.067 srow_z = -0.0728289 -0.494417 1.93656 -40.2311

See how copy.nii.gz is slightly different to the input it was supposedly copied from. But,

CopyImageHeaderInformation copy.nii.gz copy.nii.gz copy2.nii.gz 1 1 1 0

PrintHeader copy2.nii.gz | grep srow srow_x = -1.99858 -0.000973466 -0.0754099 118.814 srow_y = -0.0195846 1.93792 0.49403 -102.067 srow_z = -0.0728289 -0.494417 1.93656 -40.2311

copy2 appears to be identical to copy, at least to the precision printed out.

Thus if you were to do something like:

CopyImageHeaderInformation t1.nii.gz t1.nii.gz t1_headerFix.nii.gz 1 1 1 0

antsCorticalThickness ... -a t1_headerFix.nii.gz

it might avoid the problem.

On Oct 13, 2014, at 10:19 AM, Arman Eshaghi notifications@github.com wrote:

thanks

On Mon, Oct 13, 2014 at 5:21 PM, stnava notifications@github.com wrote:

actually in this particular case, CopyImageHeaderInformation may help - you always want to copy the original image's header into the problematic one

brian

On Mon, Oct 13, 2014 at 8:42 AM, Arman Eshaghi notifications@github.com wrote:

@stnava https://github.com/stnava I'm wondering whether you have had any final thoughts on this? as I'm experiencing this problem on a subset of my data. I get this in antsCorticalThickness.sh script, where ImageMath comes in: ImageMath 3 antsCT_BrainSegmentation0N4.nii.gz TruncateImageIntensity T1.nii.gz 0.025 0.995 256 antsCT_BrainExtractionMask.nii.gz

Reply to this email directly or view it on GitHub https://github.com/stnava/ANTs/issues/74#issuecomment-58886411.

Reply to this email directly or view it on GitHub https://github.com/stnava/ANTs/issues/74#issuecomment-58894633.

— Reply to this email directly or view it on GitHub.

stnava commented 9 years ago

interesting - it's true that the ITK nifti I/O is consistently buggy.

small but irritating bugs.

i also wonder if nrrd or mha would avoid this.

brian

On Mon, Oct 13, 2014 at 10:43 AM, Philip Cook notifications@github.com wrote:

I had an idea that I haven't had a chance to test yet.

If you run the T1 image through ANTs before calling antsCorticalThickness, you might be able to avoid the problem.

I've observed that derived images tend to be slightly but consistently different from the original input. I believe this is because of a data type conversions that happen when the Nifti transform is read / written by ITK, introducing small floating point errors. But they seem to be stable after one pass through the ANTs I/O. So for example:

PrintHeader input.nii.gz | grep srow srow_x = -1.99858 -0.000973955 -0.075406 118.814 srow_y = -0.0195841 1.93792 0.49403 -102.067 srow_z = -0.072825 -0.494417 1.93656 -40.2311

PrintHeader copy.nii.gz | grep srow srow_x = -1.99858 -0.000973466 -0.0754099 118.814 srow_y = -0.0195846 1.93792 0.49403 -102.067 srow_z = -0.0728289 -0.494417 1.93656 -40.2311

See how copy.nii.gz is slightly different to the input it was supposedly copied from. But,

CopyImageHeaderInformation copy.nii.gz copy.nii.gz copy2.nii.gz 1 1 1 0

PrintHeader copy2.nii.gz | grep srow srow_x = -1.99858 -0.000973466 -0.0754099 118.814 srow_y = -0.0195846 1.93792 0.49403 -102.067 srow_z = -0.0728289 -0.494417 1.93656 -40.2311

copy2 appears to be identical to copy, at least to the precision printed out.

Thus if you were to do something like:

CopyImageHeaderInformation t1.nii.gz t1.nii.gz t1_headerFix.nii.gz 1 1 1 0

antsCorticalThickness ... -a t1_headerFix.nii.gz

it might avoid the problem.

On Oct 13, 2014, at 10:19 AM, Arman Eshaghi notifications@github.com wrote:

thanks

On Mon, Oct 13, 2014 at 5:21 PM, stnava notifications@github.com wrote:

actually in this particular case, CopyImageHeaderInformation may help

you always want to copy the original image's header into the problematic one

brian

On Mon, Oct 13, 2014 at 8:42 AM, Arman Eshaghi < notifications@github.com> wrote:

@stnava https://github.com/stnava I'm wondering whether you have had any final thoughts on this? as I'm experiencing this problem on a subset of my data. I get this in antsCorticalThickness.sh script, where ImageMath comes in: ImageMath 3 antsCT_BrainSegmentation0N4.nii.gz TruncateImageIntensity T1.nii.gz 0.025 0.995 256 antsCT_BrainExtractionMask.nii.gz

Reply to this email directly or view it on GitHub https://github.com/stnava/ANTs/issues/74#issuecomment-58886411.

Reply to this email directly or view it on GitHub https://github.com/stnava/ANTs/issues/74#issuecomment-58894633.

— Reply to this email directly or view it on GitHub.

— Reply to this email directly or view it on GitHub https://github.com/stnava/ANTs/issues/74#issuecomment-58901783.

armaneshaghi commented 9 years ago

Phil, what I did based on your very first comment: changing the input to FLOAT32 solved the issue.

stnava commented 9 years ago

@cookpa - did you ever find a good work around for this bug?

cookpa commented 9 years ago

I have not found a workaround that works for all cases. I think we've minimized the likelihood of seeing this in antsCorticalThickness by being careful about the choice of reference image for ImageMath operations etc.

I've heard via Ted that this error can arise during template construction. @jeffduda and I have both observed the issue when using antsMalfLabeling. In that case I'm not sure if we can really do anything by fiddling with the headers, unless one is willing to try Nick's "nuclear option" of changing all the matrices to identity and all the origins to zero, and dealing with the various problems that can cause elsewhere.

stnava commented 9 years ago

Thanks - @dorianps https://github.com/dorianps has seen this too.

I proposed this to ITK developers:

ITK currently enforces a relatively strict check that image and displacement fields "occupy the same physical space." However, for some unclear (to me) reasons, the direction matrices or origins of images can lose precision when passing through ITK pipelines ( especially through resampling or resolution-changing filters ). This results in filters aborting and this can occur at various different places in a complex series of ITK-based operations.

My concern with this is that it can lead to a very severe loss of productivity when this somewhat unpredictable error occurs. For instance, a user downloads a toolkit based on ITK ( itk-snap, ants, elastic, brainsfit, joint label fusion, etc). The user expects registration or segmentation filters to "work well" especially when the data is of a standard sort. Then, after some oft-substantial execution time, this mysterious error appears:

itk::ERROR: ImageToImageFilter(0x7fb3b2307ac0): Inputs do not occupy the same physical space! https://github.com/stnava/ANTs/issues/31

While I am all for correctness, when the impact on productivity exceeds a certain threshold, I think it is useful to bend the rules a bit. Perhaps one of these would improve the situation:

1) change:

ITKv4/Modules/Filtering/DisplacementField/include/itkDisplacementFieldTransform.hxx

and

ITKv4/Modules/Core/Common/include/itkImageToImageFilter.hxx

changing direction tolerance and coordinate tolerance to 1.e-4

https://github.com/InsightSoftwareConsortium/ITK/blob/master/Modules/Filtering/DisplacementField/include/itkDisplacementFieldTransform.hxx#L454-L457

https://github.com/InsightSoftwareConsortium/ITK/blob/master/Modules/Core/Common/include/itkImageToImageFilter.hxx#L40-L41

and change the documentation too:

https://github.com/InsightSoftwareConsortium/ITK/blob/master/Modules/Core/Common/include/itkImageToImageFilter.h#L76-L87 2) Change the exception to a warning. This would at least allow complex pipelines to execute while notifying the user of a possible issue.

3) Document all of the places that the user/developer should call:

Set/GetCoordinateTolerance Set/GetDirectionTolerance .

This last solution would require adding Set/GetCoordinate and Direction tolerance to:

https://github.com/InsightSoftwareConsortium/ITK/blob/master/Modules/Filtering/DisplacementField/include/itkDisplacementFieldTransform.h

as well, for consistency.

Anyway, I raise this issue b/c of the many man and computer hours lost by this check.

Not once has this check actually helped us, in any measurable way, avoid errors.

gdevenyi commented 9 years ago

Just ran into this as well with

N4BiasFieldCorrection -d 3 -r -s 1 -b [200] -c [200x200x200x200,0.0] -i mtl_FEGlu064_t1.anlm_denoise.mnc -o mtl_FEGlu064_t1.anlm_denoise.n4correct.mnc

Running this without -s1 (using whatever the default -s value is) succeeds.

stnava commented 9 years ago

do you have a reproducible example for this?

we want to solve this issue once and for all and are trying to collect failure instances.

brian

On Wed, Nov 5, 2014 at 6:41 PM, Gabriel A. Devenyi <notifications@github.com

wrote:

Just ran into this as well with

N4BiasFieldCorrection -d 3 -r -s 1 -b [200] -c [200x200x200x200,0.0] -i mtl_FEGlu064_t1.anlm_denoise.mnc -o mtl_FEGlu064_t1.anlm_denoise.n4correct.mnc

Running this without -s1 (using whatever the default -s value is) succeeds.

— Reply to this email directly or view it on GitHub https://github.com/stnava/ANTs/issues/74#issuecomment-61903015.

gdevenyi commented 9 years ago

I'll do some tests to see if it happens at the same point every time.

Gabriel A. Devenyi B.Eng. Ph.D. Research Computing Associate Computational Brain Anatomy Laboratory Cerebral Imaging Center Douglas Mental Health University Institute McGill University t: 514.761.6131x4781 e: gdevenyi@gmail.com

On Wed, Nov 5, 2014 at 7:30 PM, stnava notifications@github.com wrote:

do you have a reproducible example for this?

we want to solve this issue once and for all and are trying to collect failure instances.

brian

On Wed, Nov 5, 2014 at 6:41 PM, Gabriel A. Devenyi < notifications@github.com

wrote:

Just ran into this as well with

N4BiasFieldCorrection -d 3 -r -s 1 -b [200] -c [200x200x200x200,0.0] -i mtl_FEGlu064_t1.anlm_denoise.mnc -o mtl_FEGlu064_t1.anlm_denoise.n4correct.mnc

Running this without -s1 (using whatever the default -s value is) succeeds.

— Reply to this email directly or view it on GitHub https://github.com/stnava/ANTs/issues/74#issuecomment-61903015.

— Reply to this email directly or view it on GitHub https://github.com/stnava/ANTs/issues/74#issuecomment-61908065.

stnava commented 9 years ago

thanks much! we are tired of this bug and want to exterminate it. but we need help from collaborators like you!

brian

On Wed, Nov 5, 2014 at 8:06 PM, Gabriel A. Devenyi <notifications@github.com

wrote:

I'll do some tests to see if it happens at the same point every time.

Gabriel A. Devenyi B.Eng. Ph.D. Research Computing Associate Computational Brain Anatomy Laboratory Cerebral Imaging Center Douglas Mental Health University Institute McGill University t: 514.761.6131x4781 e: gdevenyi@gmail.com

On Wed, Nov 5, 2014 at 7:30 PM, stnava notifications@github.com wrote:

do you have a reproducible example for this?

we want to solve this issue once and for all and are trying to collect failure instances.

brian

On Wed, Nov 5, 2014 at 6:41 PM, Gabriel A. Devenyi < notifications@github.com

wrote:

Just ran into this as well with

N4BiasFieldCorrection -d 3 -r -s 1 -b [200] -c [200x200x200x200,0.0] -i mtl_FEGlu064_t1.anlm_denoise.mnc -o mtl_FEGlu064_t1.anlm_denoise.n4correct.mnc

Running this without -s1 (using whatever the default -s value is) succeeds.

— Reply to this email directly or view it on GitHub https://github.com/stnava/ANTs/issues/74#issuecomment-61903015.

— Reply to this email directly or view it on GitHub https://github.com/stnava/ANTs/issues/74#issuecomment-61908065.

— Reply to this email directly or view it on GitHub https://github.com/stnava/ANTs/issues/74#issuecomment-61911575.

gdevenyi commented 9 years ago

Here is a reproducible error:

> N4BiasFieldCorrection -d 3 -b [200] -c [200x200x200x200,0] -s 1 -i input.mnc -o output.n4correct.mnc

Running N4 for 3-dimensional images.

Mask not read.  Creating Otsu mask.
Current level = 1
  Iteration 1 (of 200).   Current convergence value = 0.000523047 (threshold = 0)
  Iteration 2 (of 200).   Current convergence value = 0.000514704 (threshold = 0)
  Iteration 3 (of 200).   Current convergence value = 0.000506521 (threshold = 0)
  Iteration 4 (of 200).   Current convergence value = 0.000498305 (threshold = 0)
  Iteration 5 (of 200).   Current convergence value = 0.000490561 (threshold = 0)
  Iteration 6 (of 200).   Current convergence value = 0.000482496 (threshold = 0)
  Iteration 7 (of 200).   Current convergence value = 0.00047464 (threshold = 0)
  Iteration 8 (of 200).   Current convergence value = 0.000466832 (threshold = 0)
  Iteration 9 (of 200).   Current convergence value = 0.000459199 (threshold = 0)
  Iteration 10 (of 200).   Current convergence value = 0.000451811 (threshold = 0)
  Iteration 11 (of 200).   Current convergence value = 0.000444384 (threshold = 0)
  Iteration 12 (of 200).   Current convergence value = 0.000437152 (threshold = 0)
  Iteration 13 (of 200).   Current convergence value = 0.000430054 (threshold = 0)
  Iteration 14 (of 200).   Current convergence value = 0.000423153 (threshold = 0)
  Iteration 15 (of 200).   Current convergence value = 0.000416445 (threshold = 0)
  Iteration 16 (of 200).   Current convergence value = 0.000410021 (threshold = 0)
  Iteration 17 (of 200).   Current convergence value = 0.000403481 (threshold = 0)
  Iteration 18 (of 200).   Current convergence value = 0.000397065 (threshold = 0)
  Iteration 19 (of 200).   Current convergence value = 0.000390742 (threshold = 0)
  Iteration 20 (of 200).   Current convergence value = 0.000384591 (threshold = 0)
  Iteration 21 (of 200).   Current convergence value = 0.000378648 (threshold = 0)
  Iteration 22 (of 200).   Current convergence value = 0.000372623 (threshold = 0)
  Iteration 23 (of 200).   Current convergence value = 0.000366634 (threshold = 0)
  Iteration 24 (of 200).   Current convergence value = 0.000360754 (threshold = 0)
  Iteration 25 (of 200).   Current convergence value = 0.000354869 (threshold = 0)
  Iteration 26 (of 200).   Current convergence value = 0.000349103 (threshold = 0)
  Iteration 27 (of 200).   Current convergence value = 0.000343317 (threshold = 0)
  Iteration 28 (of 200).   Current convergence value = 0.000337811 (threshold = 0)
  Iteration 29 (of 200).   Current convergence value = 0.000332206 (threshold = 0)
  Iteration 30 (of 200).   Current convergence value = 0.000326853 (threshold = 0)
  Iteration 31 (of 200).   Current convergence value = 0.000321587 (threshold = 0)
  Iteration 32 (of 200).   Current convergence value = 0.000316197 (threshold = 0)
  Iteration 33 (of 200).   Current convergence value = 0.000311074 (threshold = 0)
  Iteration 34 (of 200).   Current convergence value = 0.000305989 (threshold = 0)
  Iteration 35 (of 200).   Current convergence value = 0.00030097 (threshold = 0)
  Iteration 36 (of 200).   Current convergence value = 0.000296094 (threshold = 0)
  Iteration 37 (of 200).   Current convergence value = 0.000291265 (threshold = 0)
  Iteration 38 (of 200).   Current convergence value = 0.000286352 (threshold = 0)
  Iteration 39 (of 200).   Current convergence value = 0.000281723 (threshold = 0)
  Iteration 40 (of 200).   Current convergence value = 0.000277085 (threshold = 0)
  Iteration 41 (of 200).   Current convergence value = 0.000272494 (threshold = 0)
  Iteration 42 (of 200).   Current convergence value = 0.000268028 (threshold = 0)
  Iteration 43 (of 200).   Current convergence value = 0.000263601 (threshold = 0)
  Iteration 44 (of 200).   Current convergence value = 0.000259179 (threshold = 0)
  Iteration 45 (of 200).   Current convergence value = 0.000254861 (threshold = 0)
  Iteration 46 (of 200).   Current convergence value = 0.000250624 (threshold = 0)
  Iteration 47 (of 200).   Current convergence value = 0.000246499 (threshold = 0)
  Iteration 48 (of 200).   Current convergence value = 0.000242422 (threshold = 0)
  Iteration 49 (of 200).   Current convergence value = 0.000238242 (threshold = 0)
  Iteration 50 (of 200).   Current convergence value = 0.000234345 (threshold = 0)
  Iteration 51 (of 200).   Current convergence value = 0.000230383 (threshold = 0)
  Iteration 52 (of 200).   Current convergence value = 0.000226723 (threshold = 0)
  Iteration 53 (of 200).   Current convergence value = 0.000223185 (threshold = 0)
  Iteration 54 (of 200).   Current convergence value = 0.000219522 (threshold = 0)
  Iteration 55 (of 200).   Current convergence value = 0.000216017 (threshold = 0)
  Iteration 56 (of 200).   Current convergence value = 0.000212612 (threshold = 0)
  Iteration 57 (of 200).   Current convergence value = 0.000209046 (threshold = 0)
  Iteration 58 (of 200).   Current convergence value = 0.000205622 (threshold = 0)
  Iteration 59 (of 200).   Current convergence value = 0.00020238 (threshold = 0)
  Iteration 60 (of 200).   Current convergence value = 0.000198992 (threshold = 0)
  Iteration 61 (of 200).   Current convergence value = 0.000195692 (threshold = 0)
  Iteration 62 (of 200).   Current convergence value = 0.000192583 (threshold = 0)
  Iteration 63 (of 200).   Current convergence value = 0.000189461 (threshold = 0)
  Iteration 64 (of 200).   Current convergence value = 0.000186264 (threshold = 0)
  Iteration 65 (of 200).   Current convergence value = 0.000183253 (threshold = 0)
  Iteration 66 (of 200).   Current convergence value = 0.000180213 (threshold = 0)
  Iteration 67 (of 200).   Current convergence value = 0.000177374 (threshold = 0)
  Iteration 68 (of 200).   Current convergence value = 0.000174417 (threshold = 0)
  Iteration 69 (of 200).   Current convergence value = 0.000171485 (threshold = 0)
  Iteration 70 (of 200).   Current convergence value = 0.000168613 (threshold = 0)
  Iteration 71 (of 200).   Current convergence value = 0.000165778 (threshold = 0)
  Iteration 72 (of 200).   Current convergence value = 0.000163072 (threshold = 0)
  Iteration 73 (of 200).   Current convergence value = 0.0001604 (threshold = 0)
  Iteration 74 (of 200).   Current convergence value = 0.00015785 (threshold = 0)
  Iteration 75 (of 200).   Current convergence value = 0.000155292 (threshold = 0)
  Iteration 76 (of 200).   Current convergence value = 0.000152627 (threshold = 0)
  Iteration 77 (of 200).   Current convergence value = 0.000149988 (threshold = 0)
  Iteration 78 (of 200).   Current convergence value = 0.0001475 (threshold = 0)
  Iteration 79 (of 200).   Current convergence value = 0.00014502 (threshold = 0)
  Iteration 80 (of 200).   Current convergence value = 0.000142593 (threshold = 0)
  Iteration 81 (of 200).   Current convergence value = 0.000140047 (threshold = 0)
  Iteration 82 (of 200).   Current convergence value = 0.000137788 (threshold = 0)
  Iteration 83 (of 200).   Current convergence value = 0.00013541 (threshold = 0)
  Iteration 84 (of 200).   Current convergence value = 0.0001331 (threshold = 0)
  Iteration 85 (of 200).   Current convergence value = 0.00013086 (threshold = 0)
  Iteration 86 (of 200).   Current convergence value = 0.000128682 (threshold = 0)
  Iteration 87 (of 200).   Current convergence value = 0.000126583 (threshold = 0)
  Iteration 88 (of 200).   Current convergence value = 0.000124411 (threshold = 0)
  Iteration 89 (of 200).   Current convergence value = 0.000122434 (threshold = 0)
  Iteration 90 (of 200).   Current convergence value = 0.000120269 (threshold = 0)
  Iteration 91 (of 200).   Current convergence value = 0.000118334 (threshold = 0)
  Iteration 92 (of 200).   Current convergence value = 0.000116381 (threshold = 0)
  Iteration 93 (of 200).   Current convergence value = 0.000114328 (threshold = 0)
  Iteration 94 (of 200).   Current convergence value = 0.000112391 (threshold = 0)
  Iteration 95 (of 200).   Current convergence value = 0.000110486 (threshold = 0)
  Iteration 96 (of 200).   Current convergence value = 0.000108533 (threshold = 0)
  Iteration 97 (of 200).   Current convergence value = 0.000106733 (threshold = 0)
  Iteration 98 (of 200).   Current convergence value = 0.000104956 (threshold = 0)
  Iteration 99 (of 200).   Current convergence value = 0.000103304 (threshold = 0)
  Iteration 100 (of 200).   Current convergence value = 0.000101521 (threshold = 0)
  Iteration 101 (of 200).   Current convergence value = 9.98432e-05 (threshold = 0)
  Iteration 102 (of 200).   Current convergence value = 9.81591e-05 (threshold = 0)
  Iteration 103 (of 200).   Current convergence value = 9.65419e-05 (threshold = 0)
  Iteration 104 (of 200).   Current convergence value = 9.49434e-05 (threshold = 0)
  Iteration 105 (of 200).   Current convergence value = 9.3467e-05 (threshold = 0)
  Iteration 106 (of 200).   Current convergence value = 9.18644e-05 (threshold = 0)
  Iteration 107 (of 200).   Current convergence value = 9.04502e-05 (threshold = 0)
  Iteration 108 (of 200).   Current convergence value = 8.90076e-05 (threshold = 0)
  Iteration 109 (of 200).   Current convergence value = 8.76508e-05 (threshold = 0)
  Iteration 110 (of 200).   Current convergence value = 8.62357e-05 (threshold = 0)
  Iteration 111 (of 200).   Current convergence value = 8.49316e-05 (threshold = 0)
  Iteration 112 (of 200).   Current convergence value = 8.36634e-05 (threshold = 0)
  Iteration 113 (of 200).   Current convergence value = 8.22721e-05 (threshold = 0)
  Iteration 114 (of 200).   Current convergence value = 8.09784e-05 (threshold = 0)
  Iteration 115 (of 200).   Current convergence value = 7.9561e-05 (threshold = 0)
  Iteration 116 (of 200).   Current convergence value = 7.85308e-05 (threshold = 0)
  Iteration 117 (of 200).   Current convergence value = 7.72905e-05 (threshold = 0)
  Iteration 118 (of 200).   Current convergence value = 7.61061e-05 (threshold = 0)
  Iteration 119 (of 200).   Current convergence value = 7.49924e-05 (threshold = 0)
  Iteration 120 (of 200).   Current convergence value = 7.38926e-05 (threshold = 0)
  Iteration 121 (of 200).   Current convergence value = 7.28283e-05 (threshold = 0)
  Iteration 122 (of 200).   Current convergence value = 7.17107e-05 (threshold = 0)
  Iteration 123 (of 200).   Current convergence value = 7.06179e-05 (threshold = 0)
  Iteration 124 (of 200).   Current convergence value = 6.96794e-05 (threshold = 0)
  Iteration 125 (of 200).   Current convergence value = 6.86839e-05 (threshold = 0)
  Iteration 126 (of 200).   Current convergence value = 6.77398e-05 (threshold = 0)
  Iteration 127 (of 200).   Current convergence value = 6.68274e-05 (threshold = 0)
  Iteration 128 (of 200).   Current convergence value = 6.58962e-05 (threshold = 0)
  Iteration 129 (of 200).   Current convergence value = 6.50119e-05 (threshold = 0)
  Iteration 130 (of 200).   Current convergence value = 6.41325e-05 (threshold = 0)
  Iteration 131 (of 200).   Current convergence value = 6.32825e-05 (threshold = 0)
  Iteration 132 (of 200).   Current convergence value = 6.25253e-05 (threshold = 0)
  Iteration 133 (of 200).   Current convergence value = 6.16872e-05 (threshold = 0)
  Iteration 134 (of 200).   Current convergence value = 6.08981e-05 (threshold = 0)
  Iteration 135 (of 200).   Current convergence value = 6.01897e-05 (threshold = 0)
  Iteration 136 (of 200).   Current convergence value = 5.93826e-05 (threshold = 0)
  Iteration 137 (of 200).   Current convergence value = 5.87803e-05 (threshold = 0)
  Iteration 138 (of 200).   Current convergence value = 5.8048e-05 (threshold = 0)
  Iteration 139 (of 200).   Current convergence value = 5.73737e-05 (threshold = 0)
  Iteration 140 (of 200).   Current convergence value = 5.68243e-05 (threshold = 0)
  Iteration 141 (of 200).   Current convergence value = 5.61131e-05 (threshold = 0)
  Iteration 142 (of 200).   Current convergence value = 5.5569e-05 (threshold = 0)
  Iteration 143 (of 200).   Current convergence value = 5.49754e-05 (threshold = 0)
  Iteration 144 (of 200).   Current convergence value = 5.44474e-05 (threshold = 0)
  Iteration 145 (of 200).   Current convergence value = 5.39256e-05 (threshold = 0)
  Iteration 146 (of 200).   Current convergence value = 5.3386e-05 (threshold = 0)
  Iteration 147 (of 200).   Current convergence value = 5.28985e-05 (threshold = 0)
  Iteration 148 (of 200).   Current convergence value = 5.23735e-05 (threshold = 0)
  Iteration 149 (of 200).   Current convergence value = 5.19556e-05 (threshold = 0)
  Iteration 150 (of 200).   Current convergence value = 5.15313e-05 (threshold = 0)
  Iteration 151 (of 200).   Current convergence value = 5.11061e-05 (threshold = 0)
  Iteration 152 (of 200).   Current convergence value = 5.06941e-05 (threshold = 0)
  Iteration 153 (of 200).   Current convergence value = 5.02942e-05 (threshold = 0)
  Iteration 154 (of 200).   Current convergence value = 4.99425e-05 (threshold = 0)
  Iteration 155 (of 200).   Current convergence value = 4.95716e-05 (threshold = 0)
  Iteration 156 (of 200).   Current convergence value = 4.92522e-05 (threshold = 0)
  Iteration 157 (of 200).   Current convergence value = 4.89327e-05 (threshold = 0)
  Iteration 158 (of 200).   Current convergence value = 4.86172e-05 (threshold = 0)
  Iteration 159 (of 200).   Current convergence value = 4.83475e-05 (threshold = 0)
  Iteration 160 (of 200).   Current convergence value = 4.8076e-05 (threshold = 0)
  Iteration 161 (of 200).   Current convergence value = 4.78169e-05 (threshold = 0)
  Iteration 162 (of 200).   Current convergence value = 4.75676e-05 (threshold = 0)
  Iteration 163 (of 200).   Current convergence value = 4.73496e-05 (threshold = 0)
  Iteration 164 (of 200).   Current convergence value = 4.7099e-05 (threshold = 0)
  Iteration 165 (of 200).   Current convergence value = 4.69187e-05 (threshold = 0)
  Iteration 166 (of 200).   Current convergence value = 4.67068e-05 (threshold = 0)
  Iteration 167 (of 200).   Current convergence value = 4.6521e-05 (threshold = 0)
  Iteration 168 (of 200).   Current convergence value = 4.63348e-05 (threshold = 0)
  Iteration 169 (of 200).   Current convergence value = 4.61856e-05 (threshold = 0)
  Iteration 170 (of 200).   Current convergence value = 4.60145e-05 (threshold = 0)
  Iteration 171 (of 200).   Current convergence value = 4.58856e-05 (threshold = 0)
  Iteration 172 (of 200).   Current convergence value = 4.57679e-05 (threshold = 0)
  Iteration 173 (of 200).   Current convergence value = 4.56349e-05 (threshold = 0)
  Iteration 174 (of 200).   Current convergence value = 4.54793e-05 (threshold = 0)
  Iteration 175 (of 200).   Current convergence value = 4.53794e-05 (threshold = 0)
  Iteration 176 (of 200).   Current convergence value = 4.52466e-05 (threshold = 0)
  Iteration 177 (of 200).   Current convergence value = 4.51456e-05 (threshold = 0)
  Iteration 178 (of 200).   Current convergence value = 4.50922e-05 (threshold = 0)
  Iteration 179 (of 200).   Current convergence value = 4.49961e-05 (threshold = 0)
  Iteration 180 (of 200).   Current convergence value = 4.49308e-05 (threshold = 0)
Exception caught: 
itk::ExceptionObject (0x24bb510)
Location: "unknown" 
File: /opt/quarantine/ANTs/2.1.0rc3/src/ANTs-2.1.0rc3/build/ITKv4-install/include/ITK-4.7/itkImageToImageFilter.hxx
Line: 248
Description: itk::ERROR: SubtractImageFilter(0x24d2210): Inputs do not occupy the same physical space! 
InputImage Origin: [-1.2617146e+02, -1.1369123e+02, -3.5961143e+01], InputImage_1 Origin: [-4.0086121e+02, -4.2618646e+02, -1.8814694e+02]
    Tolerance: 9.9999999e-07
InputImage Spacing: [9.9999999e-01, 1.0000000e+00, 1.0000000e+00], InputImage_1 Spacing: [2.0000000e+02, 2.0000002e+02, 2.0000000e+02]
    Tolerance: 9.9999999e-07

Example file at https://dl.dropboxusercontent.com/u/307000/input.mnc

gdevenyi commented 9 years ago

Key to triggering this is the -s 1 parameter, without it, the correction is successful

gdevenyi commented 9 years ago

Update: other key to triggering this is high-resolution files, essentially, crunching lots of voxels with no shink value triggers the exception.

satra commented 9 years ago

just as a note - this cropped up running antsCorticalThickness with the float option.

Exception caught: 
itk::ExceptionObject (0x3a5cba0)
Location: "unknown" 
File: /data/software/sources/build/ITKv4-install/include/ITK-4.7/itkImageToImageFilter.hxx
Line: 248
Description: itk::ERROR: ImageToImageFilter(0x3b08df0): Inputs do not occupy the same physical space! 
InputImage Origin: [-1.0227216e+02, -1.4657317e+02, 1.0400308e+02], InputImage_1 Origin: [-1.0227216e+02, -1.4657318e+02, 1.0400308e+02]
        Tolerance: 1.9865040e-06

ERROR: command exited with nonzero status 1
Command: /data/software/ANTS//antsRegistration -d 3 -u 1 -w [0.025,0.975] -o antsCT_BrainExtractionPrior -r antsCT_BrainExtractionInitialAffine.mat -z 1 --float 1 -x [/data/scripts/templates/T_template0_BrainCerebellumExractionMask.nii.gz] -m
 MI[/data/scripts/templates/T_template0.nii.gz,antsCT_N4Corrected0.nii.gz,1,32,Regular,0.25] -c [1000x500x250x100,1e-8,10] -t Rigid[0.1] -f 8x4x2x1 -s 4x2x1x0 -m MI[/data/scripts/templates/T_template0.nii.gz,antsCT_N4Corrected0.nii.gz,1,32,Regular,0.25] -c [1000x500x250x100,1e-8,10] -t Affine[0.1] -f 8x4x2x1 -s 4x2x1x0 -m CC[/data/scripts/templates/T_template0.nii.gz,antsCT_N4Corrected0.nii.gz,0.5,4] -m CC[antsCT_BrainExtractionTemplateLaplacian.nii.gz,antsCT_BrainExtractionLaplacian.nii.gz,0.5,4] -c [50x10x0,1e-9,15] -t SyN[0.1,3,0] -f 4x2x1 -s 2x1x0
stnava commented 9 years ago

yes - double may prevent ... or follow one of the other suggestions above. i havent encountered this issue w/recent versions which may be due to some recent changes in ITK.

chrisadamsonmcri commented 9 years ago

I ran into this problem and it is due to internal transformations applied to the q/s forms by ITK. It is not an ANTS bug. The only way I could get around it was to modify antsCorticalThickness.sh, antsBrainExtraction.sh and antsAtroposN4.sh to use fslcpgeom to copy the geometry from the input files at every processing stage.

I have posted about this problem to the ITK bug system.

ntustison commented 9 years ago

This is great. Thanks for finding this. Can you post a link to the post that you made to ITK? Thanks again.

chrisadamsonmcri commented 9 years ago

Sure my bad, https://issues.itk.org/jira/browse/ITK-3346

satra commented 9 years ago

using @cookpa solution of CopyImageHeaderInformation plus disabling float computations, appears to have gotten 6 of my images through antsCT.

stnava commented 9 years ago

do we have an updated set of instructions for how to change the coordinate tolerance during ITK compile? i see, for example, the option ITK_USE_FLOAT_SPACE_PRECISION but nothing about coordinate tolerance .... anyone know how to set that?

ntustison commented 9 years ago

I was wondering the same thing. My impression was that the solution was similar to what we used to do for multithreading, i.e., putting

itk::MultiThreader::SetGlobalDefaultNumberOfThreads(1)

at the top of the program. So in this case I assumed we'd have to put

itk::ImageToImageFilter::SetGlobalDefaultCoordinateTolerance( 1e-2 )
itk::ImageToImageFilter::SetGlobalDefaultDirectionTolerance( 1e-2 )

in antsRegistration and others.

stnava commented 9 years ago

yes - seems right ... wondering if that could be added to cmakelists.txt?

brian

On Fri, May 1, 2015 at 11:26 AM, Nick Tustison notifications@github.com wrote:

I was wondering the same thing. My impression was that the solution was similar to what we used to do for multithreading, i.e., putting

itk::MultiThreader::SetGlobalDefaultNumberOfThreads(1)

at the top of the program. So in this case I assumed we'd have to put

itk::ImageToImageFilter::SetGlobalDefaultCoordinateTolerance( 1e-2 ) itk::ImageToImageFilter::SetGlobalDefaultDirectionTolerance( 1e-2 )

in antsRegistration and others.

— Reply to this email directly or view it on GitHub https://github.com/stnava/ANTs/issues/74#issuecomment-98156582.

hjmjohnson commented 9 years ago

It should not be part of the standard CMakeLists.txt environment directly.

If you wanted that behavior, then i would recommend writing a configuration time header file to be shared in all of ANTs tools that contains the desired behavior and include that configured file in every binary.

set( ANTS_COMMON_CONFIGURATION_FILE ${CMAKE_BINARY_DIR}/antsConfiguration.h )

file(WRITE ${ANTS_COMMON_CONFIGURATION_FILE} “static const double ANTS_MAX_TOLERANCE=0.01;\n" )

Hans

Hans J. Johnson hans.j.johnson@gmail.com

On May 1, 2015, at 10:53 AM, stnava notifications@github.com wrote:

yes - seems right ... wondering if that could be added to cmakelists.txt?

brian

On Fri, May 1, 2015 at 11:26 AM, Nick Tustison notifications@github.com wrote:

I was wondering the same thing. My impression was that the solution was similar to what we used to do for multithreading, i.e., putting

itk::MultiThreader::SetGlobalDefaultNumberOfThreads(1)

at the top of the program. So in this case I assumed we'd have to put

itk::ImageToImageFilter::SetGlobalDefaultCoordinateTolerance( 1e-2 ) itk::ImageToImageFilter::SetGlobalDefaultDirectionTolerance( 1e-2 )

in antsRegistration and others.

— Reply to this email directly or view it on GitHub https://github.com/stnava/ANTs/issues/74#issuecomment-98156582.

— Reply to this email directly or view it on GitHub https://github.com/stnava/ANTs/issues/74#issuecomment-98163718.

chrisadamsonmcri commented 9 years ago

I updated antsCorticalThickness.sh, antsAtroposN4.sh and antsBrainExtraction.sh to use fslcpgeom to reset the geometries, could you use those?

From: stnava [mailto:notifications@github.com] Sent: Saturday, 2 May 2015 12:29 AM To: stnava/ANTs Cc: Chris Adamson Subject: Re: [ANTs] itk::ERROR: ImageToImageFilter(0x352ff90): Inputs do not occupy the same physical space! (#74)

do we have an updated set of instructions for how to change the coordinate tolerance during ITK compile? i see, for example, the option ITK_USE_FLOAT_SPACE_PRECISION but nothing about coordinate tolerance .... anyone know how to set that?

— Reply to this email directly or view it on GitHubhttps://github.com/stnava/ANTs/issues/74#issuecomment-98144763.


This email has been scanned by the Symantec Email Security.cloud service. For more information please visit http://www.symanteccloud.com

If you have any question, please contact MCRI IT Helpdesk for further assistance.



This email has been scanned by the Symantec Email Security.cloud service. For more information please visit http://www.symanteccloud.com


ntustison commented 9 years ago

Thanks but we'd rather not have any additional external dependencies when we have a potential internal solution. Thanks for the offer, though. You can certainly post your modifications somewhere and leave a link here in case somebody prefers your solution.

hjmjohnson commented 9 years ago

@ntustison @stnava

Exception caught: InputImage Origin: [1.2463061e+01, 7.8023135e+01, 3.9683256e+01], InputImage_1 Origin: [1.2463061e+01, 7.8023132e+01, 3.9683254e+01] Tolerance: 1.0277778e-06

This annoying bug finally got me so upset that I spent a whole day tracking down the problem.
I finally had time to figure out exactly what is going on.

The problem does occur when transforms are floating point, but not because the the transform parameters! It ONLY occurs with displacement field transforms.

The problem is that when a DisplacementField (aka itk::Image< vector<xxx,3>,3>) is converted to a transform, the Image space description (i.e. the Size, Spacing, Origin, Direction) are serialized into the FixedParameters of the transform. Ah Ha! The FixedParameters were specified to have the same storage type as the Parameters! This is unnecesssary, and the FixedParameters should probably always be double.

I am working through a patch set for ITK to decouple the types for m_FixedParameters and m_Parameters so that this problem can be eradicated! I have an inital patch set for both ANTS and ITK that I have proven to work!

NOTE: This only happens when a scale factor is used that causes the change of origin/spacing/direction to be different when interpreted as float or double. Power of 2 images that are scaled by powers of two that have spacing of 1x1x1 and identity direction cosines are very tolerant of float/double differences!

I'll keep everyone informed as I push these fixes through.

Hans

stnava commented 9 years ago

Hallelujah! On Jun 3, 2015 3:54 PM, "Hans Johnson" notifications@github.com wrote:

@ntustison https://github.com/ntustison @stnava https://github.com/stnava

Exception caught: InputImage Origin: [1.2463061e+01, 7.8023135e+01, 3.9683256e+01], InputImage_1 Origin: [1.2463061e+01, 7.8023132e+01, 3.9683254e+01] Tolerance: 1.0277778e-06

This annoying bug finally got me so upset that I spent a whole day tracking down the problem.

I finally had time to figure out exactly what is going on.

The problem does occur when transforms are floating point, but not because the the transform parameters! It ONLY occurs with displacement field transforms.

The problem is that when a DisplacementField (aka itk::Image< vector,3>) is converted to a transform, the Image space description (i.e. the Size, Spacing, Origin, Direction) are serialized into the FixedParameters of the transform. Ah Ha! The FixedParameters were specified to have the same storage type as the Parameters! This is unnecesssary, and the FixedParameters should probably always be double.

I am working through a patch set for ITK to decouple the types for m_FixedParameters and m_Parameters so that this problem can be eradicated! I have an inital patch set for both ANTS and ITK that I have proven to work!

NOTE: This only happens when a scale factor is used that causes the change of origin/spacing/direction to be different when interpreted as float or double. Power of 2 images that are scaled by powers of two that have spacing of 1x1x1 and identity direction cosines are very tolerant of float/double differences!

I'll keep everyone informed as I push these fixes through.

Hans

— Reply to this email directly or view it on GitHub https://github.com/stnava/ANTs/issues/74#issuecomment-108613642.

cookpa commented 9 years ago

It will be great to have this finally fixed at the source! Thanks for the update

On Jun 3, 2015, at 4:54 PM, Hans Johnson notifications@github.com wrote:

@ntustison @stnava

Exception caught: InputImage Origin: [1.2463061e+01, 7.8023135e+01, 3.9683256e+01], InputImage_1 Origin: [1.2463061e+01, 7.8023132e+01, 3.9683254e+01] Tolerance: 1.0277778e-06

This annoying bug finally got me so upset that I spent a whole day tracking down the problem.

I finally had time to figure out exactly what is going on.

The problem does occur when transforms are floating point, but not because the the transform parameters! It ONLY occurs with displacement field transforms.

The problem is that when a DisplacementField (aka itk::Image< vector,3>) is converted to a transform, the Image space description (i.e. the Size, Spacing, Origin, Direction) are serialized into the FixedParameters of the transform. Ah Ha! The FixedParameters were specified to have the same storage type as the Parameters! This is unnecesssary, and the FixedParameters should probably always be double.

I am working through a patch set for ITK to decouple the types for m_FixedParameters and m_Parameters so that this problem can be eradicated! I have an inital patch set for both ANTS and ITK that I have proven to work!

NOTE: This only happens when a scale factor is used that causes the change of origin/spacing/direction to be different when interpreted as float or double. Power of 2 images that are scaled by powers of two that have spacing of 1x1x1 and identity direction cosines are very tolerant of float/double differences!

I'll keep everyone informed as I push these fixes through.

Hans

— Reply to this email directly or view it on GitHub.

ntustison commented 9 years ago

This is awesome, Hans! Thanks for this.

ntustison commented 9 years ago

I think this is fixed since @hjmjohnson 's ITK patch is now included in the ANTs' ITK build.

https://github.com/stnava/ANTs/commit/b0f178b541ef86e305d63670b348ae798dafab31

chrisadamsonmcri commented 9 years ago

Fantastic.

From: Nick Tustison [mailto:notifications@github.com] Sent: Saturday, 4 July 2015 7:31 AM To: stnava/ANTs Cc: Chris Adamson Subject: Re: [ANTs] itk::ERROR: ImageToImageFilter(0x352ff90): Inputs do not occupy the same physical space! (#74)

Closed #74https://github.com/stnava/ANTs/issues/74.

— Reply to this email directly or view it on GitHubhttps://github.com/stnava/ANTs/issues/74#event-347630615.


This email has been scanned by the Symantec Email Security.cloud service. For more information please visit http://www.symanteccloud.com

If you have any questions, please contact MCRI IT Servicedesk for further assistance.



This email has been scanned by the Symantec Email Security.cloud service. For more information please visit http://www.symanteccloud.com


cookpa commented 9 years ago

I'm afraid I'm still seeing this :(

I built version 6db2e19e1acf6ecb45bbaead55646910a29959be (August 10) on Linux.

ImageMath 3 headerTest2.nii.gz m headerTest1.nii.gz 0 ImageMath 3 headerTest3.nii.gz m headerTest2.nii.gz 0

PrintHeader headerTest1.nii.gz | grep srow srow_x = -0.0194786 -0.0129191 0.999725 -86.0149 srow_y = -0.99981 0.000250538 -0.019477 138.432 srow_z = -1.15606e-06 0.999917 0.0129215 -145.691

PrintHeader headerTest2.nii.gz | grep srow srow_x = -0.0194786 -0.0129192 0.999725 -86.0149 srow_y = -0.99981 0.000250479 -0.019477 138.432 srow_z = -1.21664e-06 0.999917 0.0129216 -145.691

PrintHeader headerTest3.nii.gz | grep srow srow_x = -0.0194786 -0.0129192 0.999725 -86.0149 srow_y = -0.99981 0.000250419 -0.019477 138.432 srow_z = -1.27723e-06 0.999917 0.0129216 -145.691

These errors accumulate - for example I warp an image and then mask the result. It's causing antsJointFusion to fail with the physical space error.

On Jul 3, 2015, at 5:31 PM, Nick Tustison notifications@github.com wrote:

I think this is fixed since @hjmjohnson 's ITK patch is now included in the ANTs' ITK build.

b0f178b

— Reply to this email directly or view it on GitHub.

gdevenyi commented 7 years ago

Just ran into this as well:

Total elapsed time: 1.0070e+04
Exception Object caught: 

itk::ExceptionObject (0x4abab40)
Location: "unknown" 
File: /opt/quarantine/ANTs/git/src/build/ITKv4-install/include/ITK-4.10/itkImageToImageFilter.hxx
Line: 250
Description: itk::ERROR: ImageToImageFilter(0x4ac5b00): Inputs do not occupy the same physical space! 
InputImage Origin: [-8.4818800e+01, -8.6685700e+01, -4.7260700e+01], InputImage_1 Origin: [-8.5068800e+01, -8.7185700e+01, -4.7760700e+01]
    Tolerance: 1.0000000e-06
InputImage Spacing: [1.0000000e+00, 1.0000000e+00, 1.0000000e+00], InputImage_1 Spacing: [5.0000000e-01, 5.0000000e-01, 5.0000000e-01]
    Tolerance: 1.0000000e-06

With version 9e1c52ec280b279a2c8f89ea2c5b8fb1995c26c5

Building HEAD now to see if ITK-4.11 fixes this.

ntustison commented 7 years ago

Your two images are very different---look at the spacing. The filter is working as intended.

gdevenyi commented 7 years ago

Then antsRegistration went way off the rails...

--CLIP--
Stage 4
  iterations = 100x100x100x0
  convergence threshold = 1.0000e-06
  convergence window size = 10
  number of levels = 4
  using the CC metric (radius = 4, weight = 1.0000e+00)
  preprocessing:  winsorizing the image intensities
  preprocessing:  histogram matching the images
  Shrink factors (level 1 out of 4): [16, 16, 16]
  Shrink factors (level 2 out of 4): [8, 8, 8]
  Shrink factors (level 3 out of 4): [4, 4, 4]
  Shrink factors (level 4 out of 4): [2, 2, 2]
  smoothing sigmas per level: [3, 2, 1, 0]
  Using default NONE metricSamplingStrategy 

*** Running B-spline SyN registration (updateMeshSizeAtBaseLevel = [7, 9, 7], totalMeshSizeAtBaseLevel = [0, 0, 0]) ***

XDIAGNOSTIC,Iteration,metricValue,convergenceValue,ITERATION_TIME_INDEX,SINCE_LAST
WDIAGNOSTIC,     1, -6.689031216676e-01, 1.797693134862e+308, 5.6470e+00, 5.6470e+00, 
WDIAGNOSTIC,     2, -6.756881338815e-01, 1.797693134862e+308, 5.8977e+00, 2.5063e-01, 
WDIAGNOSTIC,     3, -6.802291921783e-01, 1.797693134862e+308, 6.1085e+00, 2.1084e-01, 
WDIAGNOSTIC,     4, -6.836133718701e-01, 1.797693134862e+308, 6.3504e+00, 2.4192e-01, 
WDIAGNOSTIC,     5, -6.861661062030e-01, 1.797693134862e+308, 6.5670e+00, 2.1657e-01, 
WDIAGNOSTIC,     6, -6.885354950988e-01, 1.797693134862e+308, 6.8079e+00, 2.4092e-01, 
WDIAGNOSTIC,     7, -6.902636506544e-01, 1.797693134862e+308, 7.0380e+00, 2.3004e-01, 
WDIAGNOSTIC,     8, -6.915336750177e-01, 1.797693134862e+308, 7.2442e+00, 2.0623e-01, 
WDIAGNOSTIC,     9, -6.924172257640e-01, 1.797693134862e+308, 7.4507e+00, 2.0650e-01, 
WDIAGNOSTIC,    10, -6.928107985435e-01, 2.075815247313e-03, 7.6456e+00, 1.9496e-01, 
WDIAGNOSTIC,    11, -6.929793546916e-01, 1.406603539560e-03, 7.8692e+00, 2.2357e-01, 
WDIAGNOSTIC,    12, -6.931454408049e-01, 9.614705511783e-04, 8.1039e+00, 2.3469e-01, 
WDIAGNOSTIC,    13, -6.933181403245e-01, 6.472023978900e-04, 8.3293e+00, 2.2538e-01, 
WDIAGNOSTIC,    14, -6.932800998335e-01, 4.174108832557e-04, 8.5341e+00, 2.0487e-01, 
WDIAGNOSTIC,    15, -6.934872957705e-01, 2.558019928494e-04, 8.7579e+00, 2.2372e-01, 
WDIAGNOSTIC,    16, -6.933132052917e-01, 1.472429387842e-04, 8.9987e+00, 2.4081e-01, 
WDIAGNOSTIC,    17, -6.935895343027e-01, 8.645586023005e-05, 9.2376e+00, 2.3893e-01, 
WDIAGNOSTIC,    18, -6.932762966357e-01, 4.595922998504e-05, 9.4554e+00, 2.1775e-01, 
WDIAGNOSTIC,    19, -6.935684936409e-01, 3.123276524580e-05, 9.6542e+00, 1.9888e-01, 
WDIAGNOSTIC,    20, -6.931338392174e-01, 1.418421537081e-05, 9.8845e+00, 2.3027e-01, 
WDIAGNOSTIC,    21, -6.935097997513e-01, 8.456019111529e-06, 1.0109e+01, 2.2414e-01, 
WDIAGNOSTIC,    22, -6.929659108936e-01, -4.774559444989e-06, 1.0343e+01, 2.3389e-01, 
XDIAGNOSTIC,Iteration,metricValue,convergenceValue,ITERATION_TIME_INDEX,SINCE_LAST
WDIAGNOSTIC,     1, -6.247680417341e-01, 1.797693134862e+308, 1.5032e+01, 4.6894e+00, 
WDIAGNOSTIC,     2, -6.364120418253e-01, 1.797693134862e+308, 1.6111e+01, 1.0792e+00, 
WDIAGNOSTIC,     3, -6.491909350567e-01, 1.797693134862e+308, 1.7119e+01, 1.0080e+00, 
WDIAGNOSTIC,     4, -6.610774692025e-01, 1.797693134862e+308, 1.8111e+01, 9.9194e-01, 
WDIAGNOSTIC,     5, -6.702621535828e-01, 1.797693134862e+308, 1.9096e+01, 9.8464e-01, 
WDIAGNOSTIC,     6, -6.792082682495e-01, 1.797693134862e+308, 2.0154e+01, 1.0588e+00, 
WDIAGNOSTIC,     7, -6.879097195654e-01, 1.797693134862e+308, 2.1192e+01, 1.0372e+00, 
WDIAGNOSTIC,     8, -6.946713106906e-01, 1.797693134862e+308, 2.2187e+01, 9.9525e-01, 
WDIAGNOSTIC,     9, -7.000957277428e-01, 1.797693134862e+308, 2.3276e+01, 1.0894e+00, 
WDIAGNOSTIC,    10, -7.046709114096e-01, 7.691735810863e-03, 2.4348e+01, 1.0717e+00, 
WDIAGNOSTIC,    11, -7.088259309281e-01, 6.176357172338e-03, 2.5321e+01, 9.7293e-01, 
WDIAGNOSTIC,    12, -7.120702598687e-01, 4.884053308977e-03, 2.6380e+01, 1.0592e+00, 
WDIAGNOSTIC,    13, -7.153067112631e-01, 3.867254329946e-03, 2.7473e+01, 1.0926e+00, 
WDIAGNOSTIC,    14, -7.183574155493e-01, 3.091999604041e-03, 2.8428e+01, 9.5545e-01, 
WDIAGNOSTIC,    15, -7.211652196987e-01, 2.470678279524e-03, 2.9481e+01, 1.0526e+00, 
WDIAGNOSTIC,    16, -7.236314357342e-01, 1.995046108945e-03, 3.0480e+01, 9.9889e-01, 
WDIAGNOSTIC,    17, -7.259085036289e-01, 1.657834567396e-03, 3.1569e+01, 1.0896e+00, 
WDIAGNOSTIC,    18, -7.280827675458e-01, 1.408675719860e-03, 3.2563e+01, 9.9375e-01, 
WDIAGNOSTIC,    19, -7.299991209200e-01, 1.212922980452e-03, 3.3871e+01, 1.3075e+00, 
WDIAGNOSTIC,    20, -7.318236564609e-01, 1.054178154870e-03, 3.4859e+01, 9.8841e-01, 
WDIAGNOSTIC,    21, -7.335180744025e-01, 9.256695337737e-04, 3.5886e+01, 1.0267e+00, 
WDIAGNOSTIC,    22, -7.349018132899e-01, 8.075874318731e-04, 3.6930e+01, 1.0446e+00, 
WDIAGNOSTIC,    23, -7.362550696336e-01, 7.048666401000e-04, 3.8000e+01, 1.0699e+00, 
WDIAGNOSTIC,    24, -7.375243572759e-01, 6.171358180961e-04, 3.9065e+01, 1.0645e+00, 
WDIAGNOSTIC,    25, -7.387730067260e-01, 5.437029691080e-04, 4.0064e+01, 9.9909e-01, 
WDIAGNOSTIC,    26, -7.399064655361e-01, 4.802870552607e-04, 4.1129e+01, 1.0649e+00, 
WDIAGNOSTIC,    27, -7.409834035326e-01, 4.260651460038e-04, 4.2275e+01, 1.1466e+00, 
WDIAGNOSTIC,    28, -7.419230491190e-01, 3.800129609994e-04, 4.3284e+01, 1.0088e+00, 
WDIAGNOSTIC,    29, -7.428266376358e-01, 3.400165107674e-04, 4.4352e+01, 1.0675e+00, 
WDIAGNOSTIC,    30, -7.436653568562e-01, 3.058269700559e-04, 4.5349e+01, 9.9777e-01, 
WDIAGNOSTIC,    31, -7.444738077802e-01, 2.770157201116e-04, 4.6335e+01, 9.8575e-01, 
WDIAGNOSTIC,    32, -7.452813820695e-01, 2.509370997074e-04, 4.7385e+01, 1.0504e+00, 
WDIAGNOSTIC,    33, -7.460398309155e-01, 2.280054206393e-04, 4.8496e+01, 1.1107e+00, 
WDIAGNOSTIC,    34, -7.467598152127e-01, 2.079280804496e-04, 4.9541e+01, 1.0450e+00, 
WDIAGNOSTIC,    35, -7.473896496201e-01, 1.904604508368e-04, 5.0537e+01, 9.9608e-01, 
WDIAGNOSTIC,    36, -7.481449413929e-01, 1.765748861364e-04, 5.1589e+01, 1.0515e+00, 
WDIAGNOSTIC,    37, -7.487571630390e-01, 1.646008992508e-04, 5.2669e+01, 1.0800e+00, 
WDIAGNOSTIC,    38, -7.494292635084e-01, 1.542913259601e-04, 5.3711e+01, 1.0421e+00, 
WDIAGNOSTIC,    39, -7.500663656429e-01, 1.453574635269e-04, 5.4779e+01, 1.0686e+00, 
WDIAGNOSTIC,    40, -7.506477137901e-01, 1.369662024264e-04, 5.5807e+01, 1.0275e+00, 
WDIAGNOSTIC,    41, -7.511593909852e-01, 1.285515181257e-04, 5.6787e+01, 9.7994e-01, 
WDIAGNOSTIC,    42, -7.516966544443e-01, 1.208360123809e-04, 5.7845e+01, 1.0581e+00, 
WDIAGNOSTIC,    43, -7.522027637648e-01, 1.134595807231e-04, 5.8813e+01, 9.6844e-01, 
WDIAGNOSTIC,    44, -7.527104161483e-01, 1.065148915621e-04, 5.9803e+01, 9.8942e-01, 
WDIAGNOSTIC,    45, -7.531137240664e-01, 9.865521452947e-05, 6.0839e+01, 1.0364e+00, 
WDIAGNOSTIC,    46, -7.535293461802e-01, 9.170298478953e-05, 6.1884e+01, 1.0451e+00, 
WDIAGNOSTIC,    47, -7.539177595339e-01, 8.458982135061e-05, 6.2928e+01, 1.0434e+00, 
WDIAGNOSTIC,    48, -7.542711846929e-01, 7.800675925385e-05, 6.3984e+01, 1.0561e+00, 
WDIAGNOSTIC,    49, -7.546140070036e-01, 7.203099163063e-05, 6.4938e+01, 9.5391e-01, 
WDIAGNOSTIC,    50, -7.548373997690e-01, 6.569128175318e-05, 6.5966e+01, 1.0287e+00, 
WDIAGNOSTIC,    51, -7.550701235187e-01, 5.902623150464e-05, 6.6959e+01, 9.9251e-01, 
WDIAGNOSTIC,    52, -7.553838150962e-01, 5.335051642948e-05, 6.7998e+01, 1.0389e+00, 
WDIAGNOSTIC,    53, -7.555734201621e-01, 4.786102860406e-05, 6.9038e+01, 1.0397e+00, 
WDIAGNOSTIC,    54, -7.557590662608e-01, 4.301486939716e-05, 7.0126e+01, 1.0882e+00, 
WDIAGNOSTIC,    55, -7.559629262493e-01, 3.854713844703e-05, 7.1162e+01, 1.0367e+00, 
WDIAGNOSTIC,    56, -7.561713610403e-01, 3.488863950823e-05, 7.2240e+01, 1.0779e+00, 
WDIAGNOSTIC,    57, -7.563827673554e-01, 3.209909341450e-05, 7.3287e+01, 1.0464e+00, 
WDIAGNOSTIC,    58, -7.565815198293e-01, 3.002680590845e-05, 7.4419e+01, 1.1318e+00, 
WDIAGNOSTIC,    59, -7.568225478101e-01, 2.902501405209e-05, 7.5493e+01, 1.0746e+00, 
WDIAGNOSTIC,    60, -7.570009863166e-01, 2.788620098749e-05, 7.6534e+01, 1.0410e+00, 
WDIAGNOSTIC,    61, -7.571639929595e-01, 2.662749929828e-05, 7.7596e+01, 1.0620e+00, 
WDIAGNOSTIC,    62, -7.573220203047e-01, 2.583230695863e-05, 7.8701e+01, 1.1048e+00, 
WDIAGNOSTIC,    63, -7.574858329534e-01, 2.477935721853e-05, 7.9798e+01, 1.0970e+00, 
WDIAGNOSTIC,    64, -7.576576199173e-01, 2.355798170464e-05, 8.0854e+01, 1.0559e+00, 
WDIAGNOSTIC,    65, -7.578279869469e-01, 2.235787219635e-05, 8.1877e+01, 1.0229e+00, 
WDIAGNOSTIC,    66, -7.579992753913e-01, 2.129682639753e-05, 8.2890e+01, 1.0137e+00, 
WDIAGNOSTIC,    67, -7.581728455335e-01, 2.046761230131e-05, 8.3941e+01, 1.0510e+00, 
WDIAGNOSTIC,    68, -7.583419594183e-01, 1.979690076193e-05, 8.4970e+01, 1.0284e+00, 
WDIAGNOSTIC,    69, -7.585090471660e-01, 1.954655978391e-05, 8.6004e+01, 1.0339e+00, 
WDIAGNOSTIC,    70, -7.586760240616e-01, 1.935013721638e-05, 8.7027e+01, 1.0238e+00, 
WDIAGNOSTIC,    71, -7.588391512759e-01, 1.909276789857e-05, 8.8118e+01, 1.0909e+00, 
WDIAGNOSTIC,    72, -7.590024396830e-01, 1.874871334336e-05, 8.9096e+01, 9.7779e-01, 
WDIAGNOSTIC,    73, -7.591583496127e-01, 1.831893173403e-05, 9.0106e+01, 1.0095e+00, 
WDIAGNOSTIC,    74, -7.592900502322e-01, 1.773978959588e-05, 9.1551e+01, 1.4456e+00, 
WDIAGNOSTIC,    75, -7.594581746587e-01, 1.723159368322e-05, 9.2574e+01, 1.0228e+00, 
WDIAGNOSTIC,    76, -7.596208933993e-01, 1.678641553981e-05, 9.3587e+01, 1.0130e+00, 
WDIAGNOSTIC,    77, -7.597850214033e-01, 1.644232656610e-05, 9.4609e+01, 1.0219e+00, 
WDIAGNOSTIC,    78, -7.599469483654e-01, 1.617742553792e-05, 9.5590e+01, 9.8106e-01, 
WDIAGNOSTIC,    79, -7.600915156701e-01, 1.589995306576e-05, 9.6614e+01, 1.0240e+00, 
WDIAGNOSTIC,    80, -7.602344707250e-01, 1.560845277677e-05, 9.7636e+01, 1.0221e+00, 
WDIAGNOSTIC,    81, -7.604112750259e-01, 1.545086463877e-05, 9.8687e+01, 1.0506e+00, 
WDIAGNOSTIC,    82, -7.605474488111e-01, 1.522483974293e-05, 9.9754e+01, 1.0670e+00, 
WDIAGNOSTIC,    83, -7.606794052731e-01, 1.489474718348e-05, 1.0082e+02, 1.0634e+00, 
WDIAGNOSTIC,    84, -7.608188704090e-01, 1.439890424560e-05, 1.0193e+02, 1.1145e+00, 
WDIAGNOSTIC,    85, -7.609381334167e-01, 1.384323247498e-05, 1.0295e+02, 1.0148e+00, 
WDIAGNOSTIC,    86, -7.610727850440e-01, 1.331060961172e-05, 1.0392e+02, 9.7501e-01, 
WDIAGNOSTIC,    87, -7.612061706381e-01, 1.283563198881e-05, 1.0497e+02, 1.0456e+00, 
WDIAGNOSTIC,    88, -7.613405706211e-01, 1.244669388008e-05, 1.0598e+02, 1.0181e+00, 
WDIAGNOSTIC,    89, -7.614873181164e-01, 1.214214764468e-05, 1.0699e+02, 1.0077e+00, 
WDIAGNOSTIC,    90, -7.616257573875e-01, 1.188538737126e-05, 1.0801e+02, 1.0149e+00, 
WDIAGNOSTIC,    91, -7.617556545578e-01, 1.179904625002e-05, 1.0912e+02, 1.1123e+00, 
WDIAGNOSTIC,    92, -7.618815374793e-01, 1.168749441830e-05, 1.1013e+02, 1.0062e+00, 
WDIAGNOSTIC,    93, -7.620039906550e-01, 1.151648590235e-05, 1.1124e+02, 1.1089e+00, 
WDIAGNOSTIC,    94, -7.621222668236e-01, 1.130754212169e-05, 1.1223e+02, 9.9920e-01, 
WDIAGNOSTIC,    95, -7.622282236245e-01, 1.093757759981e-05, 1.1331e+02, 1.0762e+00, 
WDIAGNOSTIC,    96, -7.623357780657e-01, 1.050623826590e-05, 1.1443e+02, 1.1227e+00, 
WDIAGNOSTIC,    97, -7.624367747174e-01, 1.001436591651e-05, 1.1553e+02, 1.0982e+00, 
WDIAGNOSTIC,    98, -7.625481788337e-01, 9.543370288871e-06, 1.1655e+02, 1.0209e+00, 
WDIAGNOSTIC,    99, -7.626567811018e-01, 9.164356754339e-06, 1.1761e+02, 1.0616e+00, 
WDIAGNOSTIC,   100, -7.627715990552e-01, 8.895348281353e-06, 1.1871e+02, 1.0972e+00, 
XDIAGNOSTIC,Iteration,metricValue,convergenceValue,ITERATION_TIME_INDEX,SINCE_LAST
WDIAGNOSTIC,     1, -6.966127306152e-01, 1.797693134862e+308, 1.2805e+02, 9.3434e+00, 
WDIAGNOSTIC,     2, -7.032493716933e-01, 1.797693134862e+308, 1.3527e+02, 7.2172e+00, 
WDIAGNOSTIC,     3, -7.090487276419e-01, 1.797693134862e+308, 1.4192e+02, 6.6528e+00, 
WDIAGNOSTIC,     4, -7.144849873160e-01, 1.797693134862e+308, 1.4904e+02, 7.1164e+00, 
WDIAGNOSTIC,     5, -7.198559277527e-01, 1.797693134862e+308, 1.5578e+02, 6.7426e+00, 
WDIAGNOSTIC,     6, -7.245299848702e-01, 1.797693134862e+308, 1.6284e+02, 7.0576e+00, 
WDIAGNOSTIC,     7, -7.285705383903e-01, 1.797693134862e+308, 1.6983e+02, 6.9845e+00, 
WDIAGNOSTIC,     8, -7.322489711156e-01, 1.797693134862e+308, 1.7682e+02, 6.9937e+00, 
WDIAGNOSTIC,     9, -7.352486024760e-01, 1.797693134862e+308, 1.8400e+02, 7.1784e+00, 
WDIAGNOSTIC,    10, -7.378113385087e-01, 3.665117701847e-03, 1.9068e+02, 6.6830e+00, 
WDIAGNOSTIC,    11, -7.398359461550e-01, 2.964194975874e-03, 1.9766e+02, 6.9755e+00, 
WDIAGNOSTIC,    12, -7.416252066046e-01, 2.390147200118e-03, 2.0427e+02, 6.6166e+00, 
WDIAGNOSTIC,    13, -7.433494442326e-01, 1.915149988317e-03, 2.1150e+02, 7.2300e+00, 
WDIAGNOSTIC,    14, -7.451780762614e-01, 1.536117926625e-03, 2.1836e+02, 6.8547e+00, 
WDIAGNOSTIC,    15, -7.468949643011e-01, 1.251032011828e-03, 2.2531e+02, 6.9552e+00, 
WDIAGNOSTIC,    16, -7.485797089977e-01, 1.041129498750e-03, 2.3233e+02, 7.0205e+00, 
WDIAGNOSTIC,    17, -7.500667978768e-01, 8.858629326558e-04, 2.3902e+02, 6.6826e+00, 
WDIAGNOSTIC,    18, -7.513464990097e-01, 7.724163203192e-04, 2.4630e+02, 7.2860e+00, 
WDIAGNOSTIC,    19, -7.525289460353e-01, 6.841157479159e-04, 2.5340e+02, 7.0972e+00, 
WDIAGNOSTIC,    20, -7.534877353724e-01, 6.088475225716e-04, 2.6006e+02, 6.6635e+00, 
WDIAGNOSTIC,    21, -7.544478491939e-01, 5.387694200421e-04, 2.6723e+02, 7.1648e+00, 
WDIAGNOSTIC,    22, -7.553430709342e-01, 4.716778102441e-04, 2.7423e+02, 7.0002e+00, 
WDIAGNOSTIC,    23, -7.561419046721e-01, 4.083642004416e-04, 2.8117e+02, 6.9393e+00, 
WDIAGNOSTIC,    24, -7.570047587703e-01, 3.550911934627e-04, 2.8790e+02, 6.7302e+00, 
WDIAGNOSTIC,    25, -7.579111722352e-01, 3.128652316226e-04, 2.9487e+02, 6.9684e+00, 
WDIAGNOSTIC,    26, -7.589332337477e-01, 2.842245857146e-04, 3.0193e+02, 7.0678e+00, 
WDIAGNOSTIC,    27, -7.600774800573e-01, 2.680937677441e-04, 3.0870e+02, 6.7683e+00, 
WDIAGNOSTIC,    28, -7.613395438301e-01, 2.623763365001e-04, 3.1567e+02, 6.9687e+00, 
WDIAGNOSTIC,    29, -7.625092160755e-01, 2.631311123100e-04, 3.2269e+02, 7.0214e+00, 
WDIAGNOSTIC,    30, -7.635775750330e-01, 2.646239170568e-04, 3.2966e+02, 6.9635e+00, 
WDIAGNOSTIC,    31, -7.645591230022e-01, 2.647679735804e-04, 3.3667e+02, 7.0104e+00, 
WDIAGNOSTIC,    32, -7.655124386275e-01, 2.617485999841e-04, 3.4333e+02, 6.6653e+00, 
WDIAGNOSTIC,    33, -7.663577667930e-01, 2.529374121366e-04, 3.5008e+02, 6.7496e+00, 
WDIAGNOSTIC,    34, -7.671791744848e-01, 2.394282018128e-04, 3.5681e+02, 6.7258e+00, 
WDIAGNOSTIC,    35, -7.679651406265e-01, 2.222956465255e-04, 3.6377e+02, 6.9596e+00, 
WDIAGNOSTIC,    36, -7.687151200804e-01, 2.036252689770e-04, 3.7069e+02, 6.9256e+00, 
WDIAGNOSTIC,    37, -7.694361561967e-01, 1.856281727435e-04, 3.7757e+02, 6.8800e+00, 
WDIAGNOSTIC,    38, -7.700023173263e-01, 1.690727890802e-04, 3.8435e+02, 6.7769e+00, 
WDIAGNOSTIC,    39, -7.707366746789e-01, 1.557377327361e-04, 3.9112e+02, 6.7730e+00, 
WDIAGNOSTIC,    40, -7.713028466556e-01, 1.436070766835e-04, 3.9801e+02, 6.8859e+00, 
WDIAGNOSTIC,    41, -7.718767453049e-01, 1.326728125722e-04, 4.0485e+02, 6.8466e+00, 
WDIAGNOSTIC,    42, -7.724422183812e-01, 1.232512331139e-04, 4.1179e+02, 6.9321e+00, 
WDIAGNOSTIC,    43, -7.729948246634e-01, 1.147526398251e-04, 4.1917e+02, 7.3836e+00, 
WDIAGNOSTIC,    44, -7.734976915652e-01, 1.069992811775e-04, 4.2584e+02, 6.6686e+00, 
WDIAGNOSTIC,    45, -7.738715831372e-01, 9.905517215443e-05, 4.3280e+02, 6.9627e+00, 
WDIAGNOSTIC,    46, -7.744249866944e-01, 9.267993539638e-05, 4.3982e+02, 7.0182e+00, 
WDIAGNOSTIC,    47, -7.747802144257e-01, 8.631446143973e-05, 4.4694e+02, 7.1235e+00, 
WDIAGNOSTIC,    48, -7.752867904071e-01, 8.034068535909e-05, 4.5369e+02, 6.7429e+00, 
WDIAGNOSTIC,    49, -7.757889558294e-01, 7.640833097258e-05, 4.6058e+02, 6.8915e+00, 
WDIAGNOSTIC,    50, -7.762503525828e-01, 7.302970150467e-05, 4.6758e+02, 7.0033e+00, 
WDIAGNOSTIC,    51, -7.768497865249e-01, 7.142904136658e-05, 4.7422e+02, 6.6388e+00, 
WDIAGNOSTIC,    52, -7.774031293624e-01, 7.108374874578e-05, 4.8144e+02, 7.2220e+00, 
WDIAGNOSTIC,    53, -7.779415350224e-01, 7.164427851844e-05, 4.8814e+02, 6.7036e+00, 
WDIAGNOSTIC,    54, -7.781047515704e-01, 6.994359535304e-05, 4.9485e+02, 6.7057e+00, 
WDIAGNOSTIC,    55, -7.784212245702e-01, 6.634007637521e-05, 5.0204e+02, 7.1923e+00, 
WDIAGNOSTIC,    56, -7.785813575411e-01, 6.128988441435e-05, 5.0873e+02, 6.6917e+00, 
WDIAGNOSTIC,    57, -7.789077513842e-01, 5.499886757147e-05, 5.1600e+02, 7.2693e+00, 
WDIAGNOSTIC,    58, -7.790555890179e-01, 4.785277041536e-05, 5.2319e+02, 7.1845e+00, 
WDIAGNOSTIC,    59, -7.793374433154e-01, 4.139268459847e-05, 5.3009e+02, 6.9061e+00, 
WDIAGNOSTIC,    60, -7.794757413070e-01, 3.491845163198e-05, 5.3685e+02, 6.7531e+00, 
WDIAGNOSTIC,    61, -7.797732777822e-01, 3.080740029346e-05, 5.4356e+02, 6.7128e+00, 
WDIAGNOSTIC,    62, -7.798914415573e-01, 2.787475779525e-05, 5.5052e+02, 6.9579e+00, 
WDIAGNOSTIC,    63, -7.799237188575e-01, 2.579556532366e-05, 5.5762e+02, 7.0993e+00, 
WDIAGNOSTIC,    64, -7.802912749560e-01, 2.444128949859e-05, 5.6459e+02, 6.9759e+00, 
WDIAGNOSTIC,    65, -7.803125348944e-01, 2.270723790857e-05, 5.7177e+02, 7.1733e+00, 
WDIAGNOSTIC,    66, -7.806303520909e-01, 2.157128280864e-05, 5.7850e+02, 6.7378e+00, 
WDIAGNOSTIC,    67, -7.805971646322e-01, 2.005038245232e-05, 5.8528e+02, 6.7714e+00, 
WDIAGNOSTIC,    68, -7.808701858909e-01, 1.901019086963e-05, 5.9214e+02, 6.8613e+00, 
WDIAGNOSTIC,    69, -7.809948575992e-01, 1.837374412901e-05, 5.9884e+02, 6.7076e+00, 
WDIAGNOSTIC,    70, -7.812802659280e-01, 1.823581798956e-05, 6.0599e+02, 7.1451e+00, 
WDIAGNOSTIC,    71, -7.813940112347e-01, 1.852744686538e-05, 6.1276e+02, 6.7731e+00, 
WDIAGNOSTIC,    72, -7.816971938992e-01, 1.927510118742e-05, 6.1986e+02, 7.0925e+00, 
WDIAGNOSTIC,    73, -7.817197351567e-01, 1.840177650173e-05, 6.2684e+02, 6.9810e+00, 
WDIAGNOSTIC,    74, -7.819333012567e-01, 1.876584058635e-05, 6.3378e+02, 6.9415e+00, 
WDIAGNOSTIC,    75, -7.822154561506e-01, 1.880191351367e-05, 6.4097e+02, 7.1893e+00, 
WDIAGNOSTIC,    76, -7.825701114531e-01, 2.034710187814e-05, 6.4791e+02, 6.9474e+00, 
WDIAGNOSTIC,    77, -7.828221435824e-01, 2.093631155595e-05, 6.5535e+02, 7.4351e+00, 
WDIAGNOSTIC,    78, -7.834814813049e-01, 2.398587619353e-05, 6.6266e+02, 7.3065e+00, 
WDIAGNOSTIC,    79, -7.840900428437e-01, 2.805708271567e-05, 6.6962e+02, 6.9603e+00, 
WDIAGNOSTIC,    80, -7.848029962462e-01, 3.394449835525e-05, 6.7650e+02, 6.8827e+00, 
WDIAGNOSTIC,    81, -7.855941781626e-01, 4.052907817801e-05, 6.8344e+02, 6.9444e+00, 
WDIAGNOSTIC,    82, -7.864897353172e-01, 4.848255810787e-05, 6.9075e+02, 7.3107e+00, 
WDIAGNOSTIC,    83, -7.873011989127e-01, 5.525763851238e-05, 6.9750e+02, 6.7462e+00, 
WDIAGNOSTIC,    84, -7.879966816057e-01, 6.052170476280e-05, 7.0425e+02, 6.7492e+00, 
WDIAGNOSTIC,    85, -7.887409667286e-01, 6.429223700727e-05, 7.1139e+02, 7.1421e+00, 
WDIAGNOSTIC,    86, -7.894470603113e-01, 6.633895704928e-05, 7.1841e+02, 7.0192e+00, 
WDIAGNOSTIC,    87, -7.901155603432e-01, 6.579909237704e-05, 7.2547e+02, 7.0550e+00, 
WDIAGNOSTIC,    88, -7.907280685642e-01, 6.425004438415e-05, 7.3265e+02, 7.1828e+00, 
WDIAGNOSTIC,    89, -7.912956000683e-01, 6.141257336677e-05, 7.3985e+02, 7.2024e+00, 
WDIAGNOSTIC,    90, -7.918510231955e-01, 5.790286073984e-05, 7.4682e+02, 6.9661e+00, 
WDIAGNOSTIC,    91, -7.923706925851e-01, 5.416208023556e-05, 7.5373e+02, 6.9085e+00, 
WDIAGNOSTIC,    92, -7.928757822708e-01, 5.086979834915e-05, 7.6063e+02, 6.9022e+00, 
WDIAGNOSTIC,    93, -7.933573848130e-01, 4.785962609943e-05, 7.6787e+02, 7.2470e+00, 
WDIAGNOSTIC,    94, -7.937678544487e-01, 4.461586021342e-05, 7.7456e+02, 6.6896e+00, 
WDIAGNOSTIC,    95, -7.940788893887e-01, 4.121874936176e-05, 7.8156e+02, 6.9935e+00, 
WDIAGNOSTIC,    96, -7.942845050752e-01, 3.740928793781e-05, 7.8849e+02, 6.9319e+00, 
WDIAGNOSTIC,    97, -7.944038944745e-01, 3.306196701794e-05, 7.9563e+02, 7.1372e+00, 
WDIAGNOSTIC,    98, -7.944333351147e-01, 2.802872429759e-05, 8.0258e+02, 6.9569e+00, 
WDIAGNOSTIC,    99, -7.944720092697e-01, 2.265537001481e-05, 8.1007e+02, 7.4859e+00, 
WDIAGNOSTIC,   100, -7.944954675750e-01, 1.734356804574e-05, 8.1736e+02, 7.2899e+00, 
  Elapsed time (stage 4): 8.2693e+02

Stage 5
  iterations = 20
  convergence threshold = 1.0000e-06
  convergence window size = 10
  number of levels = 1
  using the CC metric (radius = 6, weight = 1.0000e+00)
  preprocessing:  winsorizing the image intensities
  preprocessing:  histogram matching the images
  Shrink factors (level 1 out of 1): [1, 1, 1]
  smoothing sigmas per level: [0]
  Using default NONE metricSamplingStrategy 

*** Running B-spline SyN registration (updateMeshSizeAtBaseLevel = [57, 77, 59], totalMeshSizeAtBaseLevel = [0, 0, 0]) ***

XDIAGNOSTIC,Iteration,metricValue,convergenceValue,ITERATION_TIME_INDEX,SINCE_LAST
WDIAGNOSTIC,     1, -3.176077838421e-01, 1.797693134862e+308, 5.0426e+02, 5.0426e+02, 
WDIAGNOSTIC,     2, -3.195493920580e-01, 1.797693134862e+308, 9.8458e+02, 4.8032e+02, 
WDIAGNOSTIC,     3, -3.215670599101e-01, 1.797693134862e+308, 1.4665e+03, 4.8193e+02, 
WDIAGNOSTIC,     4, -3.236455090574e-01, 1.797693134862e+308, 1.9478e+03, 4.8133e+02, 
WDIAGNOSTIC,     5, -3.257846394362e-01, 1.797693134862e+308, 2.4194e+03, 4.7152e+02, 
WDIAGNOSTIC,     6, -3.279690892742e-01, 1.797693134862e+308, 2.8805e+03, 4.6112e+02, 
WDIAGNOSTIC,     7, -3.302417490554e-01, 1.797693134862e+308, 3.3612e+03, 4.8071e+02, 
WDIAGNOSTIC,     8, -3.326403768995e-01, 1.797693134862e+308, 3.8235e+03, 4.6234e+02, 
WDIAGNOSTIC,     9, -3.350961569554e-01, 1.797693134862e+308, 4.2887e+03, 4.6518e+02, 
WDIAGNOSTIC,    10, -3.375683043930e-01, 3.891242204037e-03, 4.7519e+03, 4.6314e+02, 
WDIAGNOSTIC,    11, -3.400680633738e-01, 3.631568664909e-03, 5.2072e+03, 4.5534e+02, 
WDIAGNOSTIC,    12, -3.426827880727e-01, 3.413650544611e-03, 5.6757e+03, 4.6849e+02, 
WDIAGNOSTIC,    13, -3.452638949721e-01, 3.221655112989e-03, 6.1235e+03, 4.4785e+02, 
WDIAGNOSTIC,    14, -3.476138507349e-01, 3.032522285725e-03, 6.5674e+03, 4.4382e+02, 
WDIAGNOSTIC,    15, -3.497944119083e-01, 2.835649760579e-03, 7.0189e+03, 4.5151e+02, 
WDIAGNOSTIC,    16, -3.519028840791e-01, 2.630028974125e-03, 7.4704e+03, 4.5157e+02, 
WDIAGNOSTIC,    17, -3.539938433178e-01, 2.422374058258e-03, 7.9257e+03, 4.5527e+02, 
WDIAGNOSTIC,    18, -3.560044556593e-01, 2.219369281132e-03, 8.3347e+03, 4.0897e+02, 
WDIAGNOSTIC,    19, -3.579248894911e-01, 2.024926131213e-03, 8.7162e+03, 3.8153e+02, 
WDIAGNOSTIC,    20, -3.597844503973e-01, 1.842773316389e-03, 9.0982e+03, 3.8194e+02, 
  Elapsed time (stage 5): 9.1074e+03

Total elapsed time: 1.0070e+04
Exception Object caught: 

itk::ExceptionObject (0x4abab40)
Location: "unknown" 
File: /opt/quarantine/ANTs/git/src/build/ITKv4-install/include/ITK-4.10/itkImageToImageFilter.hxx
Line: 250
Description: itk::ERROR: ImageToImageFilter(0x4ac5b00): Inputs do not occupy the same physical space! 
InputImage Origin: [-8.4818800e+01, -8.6685700e+01, -4.7260700e+01], InputImage_1 Origin: [-8.5068800e+01, -8.7185700e+01, -4.7760700e+01]
    Tolerance: 1.0000000e-06
InputImage Spacing: [1.0000000e+00, 1.0000000e+00, 1.0000000e+00], InputImage_1 Spacing: [5.0000000e-01, 5.0000000e-01, 5.0000000e-01]
    Tolerance: 1.0000000e-06
ntustison commented 7 years ago

That's really interesting. I don't think I've ever seen that before. Can you put together a complete example so I can investigate? Thanks.

gdevenyi commented 7 years ago

See example in #375

naomifridman commented 7 years ago

Thats intersting. I have this problem as well, while running N4BiasFieldCorrectionImageFilter in python. casting to float32, helps but not all images. Setting origin and spacing to 0 and 1, not helping to all the cases. I had a batch of similar data in mha, there was no problem. Now my data is in nii.gz, and I have this problem very pften. did not found any good workaround, will try to set the header as suggested.

gdevenyi commented 7 years ago

I wonder if this is related? https://issues.itk.org/jira/browse/ITK-3513

nimzodisaster commented 7 years ago

I just got 'itk::ExceptionObject' what(): /mnt/build/pauly/itk42/InsightToolkit-4.2.1/Modules/Core/Common/include/itkImageToImageFilter.hxx:243: itk::ERROR: ImageToImageFilter(0x1cf9420): Inputs do not occupy the same physical space!

while using Paul's hippocampal subfield scripts...I think during label fusion. Any ideas?