Hello, I’m trying to plot target registration error (TRE) values at each iteration as shown in this notebook in the Registration cell. The input images are 3D and 2D, where the 3D image is sliced into 2D. They are transformed using the affine transformation (specified in centered transform initialization as sitk.AffineTransform(2)). The registration method has the following Command callbacks added to get the TRE at each iteration, specifically metric_and_reference_plot_values and its start and stop variants.

I’m more than happy with the registration result, however, I can’t get the TREs due to the following error:

```
sitk::ERROR: Transform argument has dimension 3 does not match this dimension of 2
```

and occurs at this part of the above mention callbacks:

```
# Compute and store TRE statistics (mean, min, max).
current_transform = sitk.CompositeTransform(registration_method.GetInitialTransform())
current_transform.SetParameters(registration_method.GetOptimizerPosition())
current_transform.AddTransform(registration_method.GetMovingInitialTransform()) <--- error at this line
current_transform.AddTransform(registration_method.GetFixedInitialTransform().GetInverse())
```

It is caused by the different dimensions of InitialTransform (dim = 2), MovingInitialTransform (dim = 3) and is also likely to occur when adding the inverse of FixedInitialTransform (also dim = 3).

Is there a way to change the above lines, in the initialization transform, add a dimension to the 2D fixed image or change the dimension of transforms in order to get the TREs values and plot them based on iteration?

So far I’ve tried various ways of reshaping the fixed 2D image into a 3D array, but that throws this error when executing the registration:

```
ITK ERROR: SmoothingRecursiveGaussianImageFilter(000001D511A21330): The number of pixels along dimension 2 is less than 4. This filter requires a minimum of four pixels along the dimension to be processed.
```

The expand filter also doesn’t work since the input image is doesn’t have a third dimension. Either the reshaping is done wrong or I’m missing something. I think a more likely reason, is that the newly created image doesn’t have the relevant pixel information or something.

Thanks in advance