SuperElastix / SimpleElastix

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

paarameterMap modification #392

Closed AmericaBG closed 4 years ago

AmericaBG commented 4 years ago

Hi! I'm designing a parameterMap (translation -> affine -> b-spline) and I want to change the number of iterations too.

My code:

elastixImageFilter.SetParameterMap(sitk.GetDefaultParameterMap('translation'))
elastixImageFilter.AddParameterMap(sitk.GetDefaultParameterMap('affine'))
elastixImageFilter.AddParameterMap(sitk.GetDefaultParameterMap('bspline'))

parameter_map=elastixImageFilter.GetParameterMap()
parameter_map['MaximumNumberOfIterations']=['600']

The error:

Traceback (most recent call last):

  File "<ipython-input-16-cbbf254b1c4d>", line 1, in <module>
    parameter_map=elastixImageFilter.GetDefaultParameterMap()

TypeError: GetDefaultParameterMap() missing 1 required positional argument: 'transformName'

Could you say me how should I do that?

Thank you very much in advance!

NHPatterson commented 4 years ago

You are 90% of the way there. It looks like you directly place the parameter map into the elastix image filter, maybe a more explicit approach would help here:

# initialize parameter maps based on defaults
translation_params = sitk.GetDefaultParameterMap('translation')
affine_params = sitk.GetDefaultParameterMap('affine')
bspline_params = sitk.GetDefaultParameterMap('bspline')

# set iterations for translation component
translation_params['MaximumNumberOfIterations']=['600']

elastixImageFilter.SetParameterMap(translation_params)
elastixImageFilter.AddParameterMap(affine_params)
elastixImageFilter.AddParameterMap(bspline_params)

# run registration here
AmericaBG commented 4 years ago

Thank you very much! Now I understand how It works!

You're very kind :)