I am registering two images using Elastix. I want to define an initial transform which I created outside of Elastix in .nrrd format. However, I see Elastix can only accept a text file transform (.txt) defined using -t0 option. I was wondering is there a way to put the deformation field .nrrd as an initial transform? Or convert the deformation field to a text file parameters that Elastix can read?
Unfortunately, Elastix does not use standard ITK transform file format. I’ve already reported this issue and several users supported it but it was not important enough for Elastix developers to work on it and I did not have time to implement it. You may add a comment to the issue to confirm that this is an important need.
Until it gets fixed in Elastix, you can harden the initial transform in Slicer. Hardening a linear transform only changes the image header, does not resample the voxels, so it is fast and does not affect image quality.
@lassoan, I found that at least for affine transforms returned by Elastix one can simply copy/paste the parameters 1:1 into an ITK .tfm file to import the linear transform into Slicer.
So, for example, the Elastix output
This ITK .tfm file can then be loaded into Slicer to get a linear transform. Something similar might be possible with the Elastix BSplineTransform and the corresponding ITK .tfm “BSplineTransform_double_3_3”, but I have not tested this.
I admit it’s a little bit crude as work-around and direct ITK output would be great, but for the time being this is what I resort to when I have an affine transform from SlicerElastix and do not want to have it represented by gigabytes of deformation data.
Yes, for basic transforms parameter conversion is trivial. I’ve been considering adding a Elastix transform file parser to SlicerElastix instead of improving transform reader/writer classes in Elastix.