InsightSoftwareConsortium / ITKElastix

An ITK Python interface to elastix, a toolbox for rigid and nonrigid registration of images
Apache License 2.0
210 stars 23 forks source link

Error on grid spacing #139

Open jeffwitz opened 2 years ago

jeffwitz commented 2 years ago

Hello, We are trying to register 2 3D images with ITK-Elastix with the following code

# Load images in itk workspace
fixed_image = itk.imread('0N_ROI.tif')
moving_image = itk.imread('1450N_ROI.tif')

# Cast images to an elastix compatible one
fixed_image = fixed_image.astype(itk.F)
moving_image = moving_image.astype(itk.F)

#Load and set parameter file
parameter_object = itk.ParameterObject.New()
parameter_map_rigid = parameter_object.GetDefaultParameterMap('affine',1)
parameter_object.AddParameterMap(parameter_map_rigid)
parameter_map_Bspline = parameter_object.GetDefaultParameterMap('bspline',5)
parameter_object.AddParameterMap(parameter_map_Bspline)
parameter_object.SetParameter("FinalGridSpacingInPhysicalUnits", "16")
parameter_object.SetParameter("Metric1Weight","10000")
parameter_object.SetParameter("MaximumNumberOfIterations","1500")

# check the parameter object
print(parameter_object)

# Call registration function
result_image, result_transform_parameters = itk.elastix_registration_method(
    fixed_image, moving_image,
    parameter_object=parameter_object,
    log_to_console=True,
    output_directory='Res/')I`

I get an strange error : Description: ITK ERROR: ParameterMapInterface(0x6018de0): ERROR: Casting entry number 0 for the parameter "GridSpacingSchedule" failed! You tried to cast "3,952542" from std::string to d

Do you have any idea of what is happening ?

thewtex commented 2 years ago

Hi,

Is the issue the comma character, , here: "3,952542"?