# SetOptimizerWeights in parameter file in SimpleElastix

**URL:** https://discourse.itk.org/t/setoptimizerweights-in-parameter-file-in-simpleelastix/7488
**Category:** Algorithms
**Tags:** registration
**Created:** [April 1, 2025, 9:37am UTC](https://discourse.itk.org/t/setoptimizerweights-in-parameter-file-in-simpleelastix/7488 "2025-04-01T09:37:53Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![Brynolf](https://discourse.itk.org/letter_avatar_proxy/v4/letter/b/898d66/32.png) [@Brynolf](https://discourse.itk.org/u/Brynolf)
#### Post date: [April 1, 2025, 9:37am UTC](https://discourse.itk.org/t/setoptimizerweights-in-parameter-file-in-simpleelastix/7488/1 "2025-04-01T09:37:53Z")

</div>

Hello!

I would like to restrict the registration to some dimensions, and found that you can use SetOptimizerWeights() in python. How can I define this if I setup my registration using a parameter file? I would like to restrict a BSplines deformation to be in the y direction only. I found this answer, which perfectly answers my question:  
[https://discourse.itk.org/t/deformable-registration-but-only-allow-deformation-in-one-direction/3789/4](https://discourse.itk.org/t/deformable-registration-but-only-allow-deformation-in-one-direction/3789/4)  
However I need to know how to define this parameter from a parameter file, and also how to know how many control points I have. I use FinalGridSpacingInPhysicalUnits to define the grid, but from that I dont know exactly how many points I have.

Any help is appreciated!

Regards Patrik
