InsightSoftwareConsortium / InsightSoftwareConsortium/ITKElastix
Extremely slow (compared to SimpleITK - Elastix)
- Dominant language
- Python
- Stars
- 281
- Forks
- 29
- Avg merge
- 16h 28m
- Merged PRs (30d)
- 8
Description
Hi,
I am trying to use Elastix in python. I went with itk-elastix first as its the most maintained version that can be easily installed. However, it seems to be having some sort of issues. Im using python 3.9 and the example outline and parameter file from: https://github.com/InsightSoftwareConsortium/ITKElastix/blob/main/examples/ITK_Example03_Masked_3D_Registration.ipynb
When I run this code using SimpleElastix (https://pypi.org/project/SimpleITK-SimpleElastix/), I get a registration in ~5seconds. When I do it with itk-elastix it ran overnight and didnt complete. Both were installed in a fresh python 3.9 environment using pip. itk elastix is version 5.4.0 and sitk elastix is 2.0.0. Simple code is below.
I also tried other parameter files (e.g., default rigid in both versions) and it has the same result.
ITK ELASTIX:
```python
path_param_file = 'parameters.3D.NC.affine.ASGD.001.txt'
fixed_image = itk.imread(path_fixed_image, itk.F)
moving_image = itk.imread(path_moving_image, itk.F)
parameter_object = itk.ParameterObject.New()
parameter_object.AddParameterFile(path_param_file)
parameter_object.SetParameter(0, "WriteResultImage", "true")
elastix_object = itk.ElastixRegistrationMethod.New(fixed_image, moving_image)
elastix_object.SetParameterObject(parameter_object)
elastix_object.SetLogToConsole(True)
elastix_object.UpdateLargestPossibleRegion()
result_image = elastix_object.GetOutput()
result_transform_parameters = elastix_object.GetTransformParameterObject()
```
SITK ELASTIX:
```python
path_param_file = 'parameters.3D.NC.affine.ASGD.001.txt'
fixed_image = sitk.ReadImage(path_fixed_image)
moving_image = sitk.ReadImage(path_moving_image)
selx = sitk.ElastixImageFilter()
selx.SetMovingImage(moving_image)
selx.SetFixedImage(fixed_image)
parameter_map = sitk.ReadParameterFile(path_param_file)
# parameter_map = sitk.GetDefaultParameterMap("rigid")
selx.SetParameterMap(parameter_map)
# Specify the output directory
selx.SetOutputDirectory(out_path)
# Execute registration
selx.Execute()
# Extract Image
registered_image = selx.GetResultImage()
```
Contributor guide
No contributing guide indexed for this repository
Research direction
Start with examples/ITK_Example03_Masked_3D_Registration.ipynb and the referenced parameters.3D.NC.affine.ASGD.001.txt, then reproduce both snippets in fresh Python 3.9 environments using itk-elastix 5.4.0 and SimpleITK-SimpleElastix 2.0.0. Compare the registration logs and configuration to identify why itk-elastix does not complete; done means the cause and a verified resolution or limitation are documented.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- computer-vision
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100