# SetShrinkFactorsPerLevel anisotropically

**URL:** <https://discourse.itk.org/t/setshrinkfactorsperlevel-anisotropically/5964>\
**Category:** Beginner Questions\
**Tags:** simpleitk, registration\
**Created:** [May 25, 2023, 6:32pm UTC](https://discourse.itk.org/t/setshrinkfactorsperlevel-anisotropically/5964 "2023-05-25T18:32:21Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![ktdiedrich](https://discourse.itk.org/user_avatar/discourse.itk.org/ktdiedrich/32/2784_2.png) [@ktdiedrich](https://discourse.itk.org/u/ktdiedrich)\
**Post date:** [May 25, 2023, 6:32pm UTC](https://discourse.itk.org/t/setshrinkfactorsperlevel-anisotropically/5964/1 "2023-05-25T18:32:21Z")

</div>

Is there a way to set shrink factors anisotropically? This would be for cases when one dimension of an image is much thinner than the others so it doesn’t need as much shrinking.  
In Simple ITK it doesn’t work to pass `SetShrinkFactorsPerLevel` a sub list/tuple of shrink factors for each dimension.

```auto
registration_method = sitk.ImageRegistrationMethod()
registration_method.SetShrinkFactorsPerLevel([(16, 8, 16), (8, 4, 8), (2,1,2)])

```

only registration\_method.SetShrinkFactorsPerLevel([16, 8, 2]) works so each dimension is shank by the same amount at each level.

---

<div class="post-metadata">

**Author:** ![blowekamp](https://discourse.itk.org/user_avatar/discourse.itk.org/blowekamp/32/79_2.png) [@blowekamp](https://discourse.itk.org/u/blowekamp)\
**Post date:** [May 25, 2023, 7:29pm UTC](https://discourse.itk.org/t/setshrinkfactorsperlevel-anisotropically/5964/2 "2023-05-25T19:29:15Z")

</div>

For the above case of wanting: `[(16, 8, 16), (8, 4, 8), (2,1,2)]` shrink factor, the XZ dimensions can be reduced outside the registration framework then processed by the frame work.

For other shrink sequences, separate registration can be done for each level.

---

<div class="post-metadata">

**Author:** ![zivy](https://discourse.itk.org/user_avatar/discourse.itk.org/zivy/32/1726_2.png) [@zivy](https://discourse.itk.org/u/zivy)\
**Post date:** [May 25, 2023, 7:42pm UTC](https://discourse.itk.org/t/setshrinkfactorsperlevel-anisotropically/5964/3 "2023-05-25T19:42:08Z")

</div>

Hello @ktdiedrich,

This [jupyter notebook](https://github.com/InsightSoftwareConsortium/SimpleITK-Notebooks/blob/master/Python/66_Registration_Demons.ipynb) illustrates how to create such a pyramid with the flexibility you want. Specifically the `smooth_and_resample` and `multiscale_demons` functions.
