ITKElastix
ITKElastix copied to clipboard
Groupwise registration of 4D objects and registration with mask
Hello,
First I would like to thank you for this library, it's incredibly helpful!
I would like to ask for some guidance on groupwise registration for 4D objects.
Context: I have a 4D-CT of 10 breathing phases and each volume is of shape 128,128,128 (height, width, depth). Since this 4D-CT represent respiratory motion of a patient with a marked ROI of tumor (there is a separate structure of the same shape), groupwise registration would help a lot, by removing the need to select a reference frame.
End goal: After successfully registering this 4D object, I would like to use it to get the deformation fields for each of the phases (10) and apply linear interpolation to them (deformation fields) in-between phases and then warp the original images based on the deformation fields to get more fluid motion of the chest (basically much more breathing phases).
Code: This is what I have tried out:
image_itk_4D_ct = itk.image_view_from_array(ct_data)
image_itk_4D_tumor = itk.image_view_from_array(tumor_data)
parameter_object = itk.ParameterObject.New()
groupwise_parameter_map = parameter_object.GetDefaultParameterMap('groupwise')
parameter_object.AddParameterMap(groupwise_parameter_map)
result_image_ct, result_transform_parameters_ct = itk.elastix_registration_method(
image_itk_4D_ct,
image_itk_4D_ct,
parameter_object=parameter_object,
log_to_console=True)
result_image_tumor, result_transform_parameters_tumor = itk.elastix_registration_method(
tumor_data, tumor_data,
parameter_object=parameter_object,
log_to_console=False)
fixed_image_itk_ct = itk.image_from_array(ct_data[0])
fixed_image_itk_tumor = itk.image_from_array(tumor_data[0])
deformation_field_ct = itk.transformix_deformation_field(fixed_image_itk_ct, result_transform_parameters_ct)
deformation_field_tumor = itk.transformix_deformation_field(fixed_image_itk_tumor, result_transform_parameters_tumor)
The problem is that I get Description: itk::ERROR: Image(000001B34E052610): Bad direction, determinant is 0. Direction is 1 0 0 0 in this line: deformation_field_ct = itk.transformix_deformation_field(fixed_image_itk_ct, result_transform_parameters_ct).
Both ct_data and tumor_data are 4D numpy arrays of shape (10,128,128,128).
Maybe you could tell me how could I avoid this situation ?
Additional question: is it possible to somehow stick the mask (tumor_data) together with the chest (ct) ? To get more fluid and correlated deformation fields between the two ?
As a reference, I'm adding a GIF of what I have and what I'm trying to register. Basically I would like to get a much smoother (with more frames/breathing phases) version of this GIF.