# Better performance for TPS deformation?

**URL:** <https://discourse.slicer.org/t/better-performance-for-tps-deformation/41693>\
**Category:** Support\
**Created:** [February 13, 2025, 11:59pm UTC](https://discourse.slicer.org/t/better-performance-for-tps-deformation/41693 "2025-02-13T23:59:14Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![muratmaga](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/muratmaga/32/3622_2.png) [@muratmaga](https://discourse.slicer.org/u/muratmaga)\
**Post date:** [February 13, 2025, 11:59pm UTC](https://discourse.slicer.org/t/better-performance-for-tps-deformation/41693/1 "2025-02-13T23:59:14Z")

</div>

we use TPS to create interactive visualization of landmark based deformations, in which the user sets a slider to adjust magnitude of the deformation:

> <https://github.com/SlicerMorph/SlicerMorph/blob/d9b1c22e0b92959929e2ceedb5d5a978cf5bd29a/GPA/GPA.py#L1846>

This works well (fast enough to be interactive) up to about 50-60 points. But as the number of points increase, the calculation becomes slower removing or interfering with the interactivy. What can we do to make this performant for high number of points?

---

<div class="post-metadata">

**Author:** ![pieper](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/pieper/32/8_2.png) [@pieper](https://discourse.slicer.org/u/pieper)\
**Post date:** [February 14, 2025, 6:08pm UTC](https://discourse.slicer.org/t/better-performance-for-tps-deformation/41693/2 "2025-02-14T18:08:04Z")

</div>

If all you are doing is scaling the amount of the displacement then you shouldn’t need to recalculate every time. You could convert to a grid transform and then scale the offsets based on the slider.

Something like this:

> <https://github.com/pieper/SlicerGetFEM/blob/main/Experiments/lung/lung.slicer.py#L63-L70>
