Change optimizer parameters for multiresolution image registration

Hi all,

I saw the example of MultiResImageRegistration1.cxx can change the optimizer parameters (e.g learning rate) for different level of a image pyramid. But when I learnt from it to write python-supported ITK code, the optimizer parameters did not change. Did I miss something in the code below? Thanks in advance.

Here is my code

rigid_registration = itk.ImageRegistrationMethodv4[itk.Image.F3, itk.Image.F3].New()

rigid_optimizer = itk.RegularStepGradientDescentOptimizerv4[itk.D].New()
rigid_optimizer.SetScales(rigid_optimizer_scales)
rigid_optimizer.ReturnBestParametersAndValueOn()

if rigid_registration.GetCurrentLevel() == 0:
rigid_optimizer.SetLearningRate(16.0)
rigid_optimizer.SetMinimumStepLength(2.5)
else:
rigid_optimizer.SetLearningRate(rigid_optimizer.GetCurrentStepLength())
rigid_optimizer.SetMinimumStepLength(rigid_optimizer.GetMinimumStepLength()*0.2)

registration

rigid_registration.SetFixedImage(caster_fixed_image.GetOutput())
rigid_registration.SetMovingImage(caster_moving_image.GetOutput())
rigid_registration.SetMetric(rigid_metric)
rigid_registration.SetOptimizer(rigid_optimizer)
rigid_registration.SetInitialTransform(rigid_transform)

def iterationUpdate():
print(rigid_optimizer.GetLearningRate())

iteration_command = itk.PyCommand.New()
iteration_command.SetCommandCallable(iterationUpdate)
rigid_optimizer.AddObserver(itk.IterationEvent(), iteration_command)

rigid_registration.Update()

Hi @zhuangming.shen,

Could the complete code and data please be shared so the issue can be reproduced?

Thanks,
Matt

Hi Matt,

Thanks for your reply. But the Upload in discourse can only support file formats such as jpg, jpeg, png, etc. How can I shared my code and data?

Regards,

Zhuangming Shen

Hi Matt,

I just sent my code and data to your kitware’s email.

Regards,

Zhuangming Shen

Hi Zhuangming Shen,

Thank you for sending the data. I also fixed the Discourse setting so we can upload any file type now.

However, the file was still over the size limit, so I uploaded it here:

https://drive.google.com/file/d/0B986LSX8iqF-ckxkS1UyemJVYWVyVlc3Y0RWQ1ljdGdiWmxV/view?usp=sharing

Thanks,
Matt

1 Like

Great! The limitation to just embedding images was so annoying! The only option was to make code part of the post.