(Segmentation fault.) Is it possible to use a single data set with integers (double) as the fixed and moving inputs for registration?

Hi. I’m getting a segmentation fault. I’m almost sure that I must be messing something up. In summary, I want to check if using a single data set as both moving and fixed images can be registered. I tried the same with floats (np.float32, itk.F) and I did not get the segmentation fault. Thanks.

import numpy as np
import pyvista as pv
import itk


ref_vti = pv.UniformGrid("tmp_gmsh.vti")
ref_vti.save("tmp_ref_vti.vti")
print("tmp_ref_vti.vti")

image_type = itk.Image[itk.D, 3]
nx, ny, nz = [val - 1 for val in ref_vti.dimensions]
fixed_image_arr = np.reshape(
    np.asarray(ref_vti.cell_data["material"], dtype=int), [nz, nx, ny])
fixed_image = itk.image_from_array(
    fixed_image_arr.astype(int), ttype=image_type)

param_obj = itk.ParameterObject.New()
param_map_rigid = param_obj.GetDefaultParameterMap('rigid')
param_map_bspline = param_obj.GetDefaultParameterMap('bspline')

param_obj.AddParameterMap(param_map_rigid)
param_obj.AddParameterMap(param_map_bspline)

registration_res = itk.elastix_registration_method(
    fixed_image, fixed_image,
    parameter_object=param_obj,
    output_directory='./')
# | itk                       |  5.3.0 |
# | itk-core                  |  5.3.0 |
# | itk-elastix               | 0.15.0 |
# | itk-filtering             |  5.3.0 |
# | itk-io                    |  5.3.0 |
# | itk-meshtopolydata        | 0.10.0 |
# | itk-minimalpathextraction |  1.2.4 |
# | itk-numerics              |  5.3.0 |
# | itk-registration          |  5.3.0 |
# | itk-segmentation          |  5.3.0 |
# | itk-strain                |  0.3.6 |
# | itk-tubetk                |  1.3.4 |
# | itkwidgets                | 0.32.5 |
# | numpy                     | 1.24.1 |
# | pyvista                   | 0.37.0 |
# | scipy                     | 1.10.0 |
# | python                    | 3.10.9 |

This is what I get

Process Python segmentation fault (core dumped)

tmp_gmsh.vti (25.6 KB)

Hi @edgar ,

Elastix is currently only wrapped for 32-bit floats, so you will need to use that for now.

HTH,
Matt

Thanks, @matt.mccormick .

1 Like