SuperElastix / SimpleElastix

Multi-lingual medical image registration library
http://simpleelastix.github.io
Apache License 2.0
511 stars 149 forks source link

Perform Affine transformation without shear #451

Open siddpiku opened 2 years ago

siddpiku commented 2 years ago

Hello,

I would like to only allow rotation, translation, and scaling as transformations for image registration or the affine transformation without the shear option. Is there a way to set the parameterMap[ "Transform" ] to perform this?

NHPatterson commented 2 years ago

You can use a SimilarityTransform. Link is how to use this.

siddpiku commented 2 years ago

Thanks a lot for the link. The Similarity Transform seems to only allow isotropic scaling. I am interested in allowing for different scaling along different axes. Is this allowed?

PatrikBrynolfsson commented 2 years ago

You can use the AffineDTITransform. It is a different parameterization of the affine transform with 3 rotations, 3 shear, 3 scaling and 3 translation parameters. You can set AutimaticScalesEstimation "true" to initialize scaling for each parameter. You can then change the scaling to basically prevent some parameters to change: Settings scales to (Scales -1 -1 -1 1e9 1e9 1e9 -1 -1 -1 -1 -1 -1) will leave rotation, scaling and translation scales unaffected (-1), but scales the shear very high, effectively eliminating them from the registration.

siddpiku commented 2 years ago

Thank you for the explanation. I understand the method, but I am struggling to set the scales in python. Following the examples in https://simpleelastix.readthedocs.io/ParameterMaps.html I have the following code -

import SimpleITK as sitk parameterMap = sitk.GetDefaultParameterMap("rigid") parameterMap["Transform"] = ["AffineDTITransform"]

I can see that the AffineDTITransform has a SetScale() method, but I am not sure how to access that in python.