InsightSoftwareConsortium / InsightSoftwareConsortium/ITKElastix

Error when using GradientDifference or NormalizedGradientCorrelation Metric

Open
#140 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
Python
Stars
281
Forks
29
Avg merge
16h 28m
Merged PRs (30d)
8

Description

I am trying to use the GradientDifference and NormalizedGradientCorrelation metrics but could not quite figure out how to prepare the input. I am following the ITK_Example07_MultimetricMultiImageRegistration example and use a parameters_Bspline_Multimetric.txt where I have only changed the metric.
When I am using the NormalizedGradientCorrelation metric alone with 2D float32 images in the same way as in the example, I get the error
```
File: _deps/elx-src/Components/Metrics/NormalizedGradientCorrelation/elxNormalizedGradientCorrelationMetric.hxx
Line: 55
Description: ITK ERROR: NormalizedGradientCorrelationMetric(0x555fb32f4fd0): FixedImage must be 3D
```

So I figured that it probably needs the two gradient channels as input. When I run the following code

```python
fixed_grad = itk.GradientImageFilter(fixed)
moving_grad = itk.GradientImageFilter(moving)

elastix_object = itk.ElastixRegistrationMethod.New(fixed_grad, moving_grad,
log_to_console=True,
number_of_threads=12)
```
it throws `itk.support.extras.TemplateTypeError: itk.ElastixRegistrationMethod is not wrapped for input type None.`
The images from the gradient filter have vector pixel type so, combining the two error messages, the next thing I have tried is to convert the gradient filter to 3D float images. But then I end up with the following error:
```
File: _deps/elx-src/Components/Metrics/NormalizedGradientCorrelation/elxNormalizedGradientCorrelationMetric.hxx
Line: 61
Description: ITK ERROR: NormalizedGradientCorrelationMetric(0x5649875b3f90): Metric can only be used for 2D-3D registration. FixedImageSize[2] must be 1
```

Do you have any idea what I am missing or could point me to resources that I could check out? Ideally, could you consider adding an example for the gradient-based metrics?
Thanks and best wishes,
Philipp

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.