Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MattesMutualInformation corner case spacing error #1491

Open
michaelzenkay opened this issue Dec 12, 2019 · 0 comments
Open

MattesMutualInformation corner case spacing error #1491

michaelzenkay opened this issue Dec 12, 2019 · 0 comments
Labels

Comments

@michaelzenkay
Copy link

@michaelzenkay michaelzenkay commented Dec 12, 2019

Description

corner case error in ITK's MattesMutualInformation metric when both images are all zeros, then the internal data structure (Image) has the reported invalid size

Steps to Reproduce

import SimpleITK as sitk
import numpy as np

I = np.zeros((100,100,100))
I = sitk.GetImageFromArray(I)
I.SetSpacing((1.0,1.0,1.0))
I = sitk.Cast(I, sitk.sitkFloat32)

J = np.zeros((100,100,100))
J = sitk.GetImageFromArray(J)
J.SetSpacing((1.0,1.0,1.0))
J = sitk.Cast(J, sitk.sitkFloat32)

R = sitk.ImageRegistrationMethod()
R.SetMetricAsMattesMutualInformation()
MMI = R.MetricEvaluate(I, J)

Expected behavior

Evaluation of Mutual Information Metric

Actual behavior

ERROR: Image(0x32256f0): A spacing of 0 is not allowed: Spacing is [0, 0]

Reproducibility

100%

Versions

Environment

Ubuntu 18.04, python 3.7, SimpleITK 1.1.0, numpy 1.17.2

Additional Information

Changing metric e.g. SetMetricAsCorrelation() does not throw error -> therefore must be the MattesMutualInformation metric
Initializing image with np.random.rand(100,100,100) does not throw error -> therefore must be the corner case where inputs are zero

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
1 participant
You can’t perform that action at this time.