I am doing B-Spline registration, I use Sum of Squared Differences (SSD) as the cost and found images were deformed too much. I would like to add some regularization in the cost function to constrain image deformation. Can I use self-defined cost function for optimization in SimpleITK? Do I need to make the changes in the C++ ITK library then compile them? (e.g. write a class for customized cost in C++ …). Many thanks.