Is it possible to create a user-defined cost function for registration?

Hi, I am trying register two images with Bspline. I tried with itk::MeanSquaresImageToImageMetricv4 and itk::MattesMutualInformationImageToImageMetricv4. Both doesn’t give the correct registration for all the images. I want to combine both the metric and form a user-defined cost function for registration. Is it possible?

Is there any way to stop and restart optimization in between registration process?