I am trying to write a very simple gui that allows to choose to cancatenate different types of trasforms (rigid, affine and elastic) with different parameters/metrics/optimizers and save the tfm file. I tried first the VH_registration example, but when I try to write the .tfm file I get this error:
RuntimeError: Exception thrown in SimpleITK WriteTransform: D:\a\1\sitk-build\ITK\Modules\IO\TransformInsightLegacy\include\itkTxtTransformIO.hxx:349:
itk::ERROR: TxtTransformIOTemplate(0000000045619F60): Composite Transform can only be 1st transform in a file
I looked a bit also in composite transforms, but I didn’t get these two issues: is it possible to optimize more than one transform? Can I use the CenteredTransformInitializer?
The following code will work with this updated transform type:
import SimpleITK as sitk
# Two translations in a list used in constructor,
#we can also add transforms with the AddTransform method
tx = sitk.CompositeTransform([sitk.TranslationTransform(2,[1,2])]*2)
sitk.WriteTransform(tx, 'result.tfm')
Hello @lucilla7,
Generally speaking, yes, you would use the same mask for all registrations. The mask is the subregion of the image that contains relevant information for registration. Usually this is the same region for all steps (affine followed by Bspline/Demons…). If for some reason you only need to deform a portion of the image after doing a global affine registration then you would potentially have one mask or no mask for the initial registration and a sedond mask limited to the region undergoing deformation.