InsightSoftwareConsortium / InsightSoftwareConsortium/ITKElastix

How to convert ITK transform into Elastix transform parameters file?

Open
#246 14 comments 0 reactions 2 assignees Claimed by @ViktorvdValk View on GitHub
Dominant language
Python
Stars
281
Forks
29
Avg merge
16h 28m
Merged PRs (30d)
8

Description

I have corresponding fiducial points between a pair of images. I use it to compute similarity transform. What is the best way to pass this as initial transform? See #245 for an attempt.

Setting it via `SetInitialTransform` seems to work (the compound registration does not work correctly in Slicer unless it is "split"), but a later call to:
```py
parameter_object.WriteParameterFile(elastix_transform, str(output_dir / "rigid_transform.txt"))
```
produces:
```log
RuntimeError: D:\a\im\_skbuild\win-amd64-3.9\cmake-build\_deps\elx-src\Core\Main\elxParameterObject.cxx:314:
ITK ERROR: ParameterObject(000002044268FF30): Error writing to disk: The number of parameter maps (2) does not match the number of provided filenames (1). Please call WriteParameterFiles instead, and provide a vector of filenames.
```
So I tried:
```py
parameter_object.WriteParameterFiles(
elastix_transform,
["fiducial_transform.txt", str(output_dir / "rigid_transform.txt")],
)
```
and it does not write the `fiducial_transform.txt` anywhere on the disk, with `rigid_transform.txt` having the following content:
```text
(CenterOfRotationPoint -4.944945387437201 -37.24496703995354 -59.44102459574103)
(CompressResultImage "false")
(DefaultPixelValue 0)
(Direction 1 0 0 0 1 0 0 0 1)
(FinalBSplineInterpolationOrder 3)
(FixedImageDimension 3)
(FixedInternalImagePixelType "float")
(HowToCombineTransforms "Compose")
(Index 0 0 0)
(InitialTransformParameterFileName "fiducial_transform.txt")
(MovingImageDimension 3)
(MovingInternalImagePixelType "float")
(NumberOfParameters 7)
(Origin -140 -140 -383.625)
(ResampleInterpolator "FinalBSplineInterpolator")
(Resampler "DefaultResampler")
(ResultImageFormat "nii")
(ResultImagePixelType "float")
(Size 281 281 355)
(Spacing 1 1 1)
(Transform "SimilarityTransform")
(TransformParameters 0.0015680670087272384 -0.0006157409483032898 0.0031103486499469784 0.16096493087864483 -0.12426840552647811 2.9018697571742758 0.988135955256508)
(UseDirectionCosines "true")
```
Passing `rigid_transform.txt` via `SetInitialTransformParameterFileName` to the next (BSpline) stage of registration produces an error:
```log
File: D:\a\im\_skbuild\win-amd64-3.9\cmake-build\_deps\elx-src\Common\ParameterFileParser\itkParameterFileParser.cxx
Line: 255
Description: ITK ERROR: ERROR: the file fiducial_transform.txt does not exist.
```
If I do not provide initial transform to the first registration phase, the whole pipeline works - with imperfect results.

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.