# Create a short video to visualise a transform

**URL:** <https://discourse.slicer.org/t/create-a-short-video-to-visualise-a-transform/39794>\
**Category:** Feature requests\
**Created:** [October 22, 2024, 12:32pm UTC](https://discourse.slicer.org/t/create-a-short-video-to-visualise-a-transform/39794 "2024-10-22T12:32:07Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Matteboo](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/matteboo/32/66548_2.png) [@Matteboo](https://discourse.slicer.org/u/Matteboo)\
**Post date:** [October 22, 2024, 12:32pm UTC](https://discourse.slicer.org/t/create-a-short-video-to-visualise-a-transform/39794/1 "2024-10-22T12:32:07Z")

</div>

Hello,  
I have a transform that I apply to an organ segmentation. It would be nice to have a short animation of the segmentation moving from its original position/orientation/shape to the final one to visualize the transform.

This would be very helpfull to communicate with healthcare professional and for outside communication in general.

Is there any module/script that could help me to do that ?

---

<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:** [October 22, 2024, 12:37pm UTC](https://discourse.slicer.org/t/create-a-short-video-to-visualise-a-transform/39794/2 "2024-10-22T12:37:19Z")

</div>

Yes, this would be nice. Not all transforms are easy to interpolate, but for something like a grid transform it’s doable. This could be added to the Animator module with some scripting.

> **[SlicerMorph/Docs/Animator at master · SlicerMorph/SlicerMorph](https://github.com/SlicerMorph/SlicerMorph/tree/master/Docs/Animator)**
>
> Extension to import microCT data and conduct 3D morphometrics in Slicer - SlicerMorph/SlicerMorph

---

<div class="post-metadata">

**Author:** ![Matteboo](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/matteboo/32/66548_2.png) [@Matteboo](https://discourse.slicer.org/u/Matteboo)\
**Post date:** [October 22, 2024, 12:46pm UTC](https://discourse.slicer.org/t/create-a-short-video-to-visualise-a-transform/39794/3 "2024-10-22T12:46:38Z")

</div>

Unfortunately, I have a B-spline transform.  
Fortunately, I don’t have a computation time limit.  
My first idea is to compute the destination position for each voxel and make them move linearly between the starting and ending position, taking a screenshot of the created segmentation at everystep and putting everything together as a video.  
This would work with any transform.

---

<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:** [October 22, 2024, 1:03pm UTC](https://discourse.slicer.org/t/create-a-short-video-to-visualise-a-transform/39794/4 "2024-10-22T13:03:46Z")

</div>

Did you try just interpolating the coefficients of the b-spline control points?

---

<div class="post-metadata">

**Author:** ![Matteboo](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/matteboo/32/66548_2.png) [@Matteboo](https://discourse.slicer.org/u/Matteboo)\
**Post date:** [October 22, 2024, 1:31pm UTC](https://discourse.slicer.org/t/create-a-short-video-to-visualise-a-transform/39794/5 "2024-10-22T13:31:16Z")

</div>

I didn’t  
I haven’t started coding this (and I don’t think I will soon)  
I don’t know how to interpolate the coefficient of the b-spline control point (and I haven’t looked into it).  
Also, I think it’s easier to code soething that works with every transform even if it’s more computationnally costly.

---

<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:** [October 22, 2024, 5:16pm UTC](https://discourse.slicer.org/t/create-a-short-video-to-visualise-a-transform/39794/6 "2024-10-22T17:16:22Z")

</div>

Actually, you should be able to do something quick with `SetDisplaycementScale` so very little coding required (at least for the bspine case).

I just did this with a bspline registration result

```auto
>>> 
>>> bs = getNode("BS*")
>>> t = bs.GetTransformFromParent()
>>> t.GetDisplacementScale()
1.0
>>> t.SetDisplacementScale(.5)
>>> t.SetDisplacementScale(.25)
>>> t.SetDisplacementScale(.75)

```
