You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When the fixed image has a single value (any value will work) and using MattesMutualInformation, calling the MetricEvaluate results in an exception which is misleading, message refers to image spacing which isn't the problem:
RuntimeError: Exception thrown in SimpleITK ImageRegistrationMethod_MetricEvaluate: /usr/local/miniconda/envs/bld/conda-bld/simpleitk_1649359436444/work/build/ITK-prefix/include/ITK-5.2/itkImageBase.hxx:165:
ITK ERROR: Image(0x7fe989578e00): A spacing of 0 is not allowed: Spacing is [0, 0.00396808]
import SimpleITK as sitk
import numpy as np
fixed_image = sitk.Image([32]*3, sitk.sitkFloat32)
# Uncommenting the following line, fills the image with random content, and all is ok.
#fixed_image = sitk.Cast(sitk.GetImageFromArray(np.random.random([32]*3)), sitk.sitkFloat32)
moving_image = sitk.Cast(sitk.GetImageFromArray(np.random.random([32]*3)), sitk.sitkFloat32)
irm = sitk.ImageRegistrationMethod()
irm.SetMetricAsMattesMutualInformation(numberOfHistogramBins=256)
initial_metric_value = irm.MetricEvaluate(fixed_image, moving_image)
The text was updated successfully, but these errors were encountered:
Indeed an ITK issue. Logged a bug report on the ITK issue tracker and provided a test illustrating the problem. Closing the issue here in favor of the ITK issue.
When the fixed image has a single value (any value will work) and using MattesMutualInformation, calling the MetricEvaluate results in an exception which is misleading, message refers to image spacing which isn't the problem:
This issue was raised in this ITK discourse question.
Minimal working example:
The text was updated successfully, but these errors were encountered: